From be91995a5e91c2ad0136e44f553ffdd80342d090 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 12 Nov 2020 09:25:14 -0800 Subject: [PATCH] Remove T_OBJECT runtime check If the cached class uses the default allocator, then all instances coming from the class should be T_OBJECT instances. Meaning we can just check the allocator function at compile time, then skip the runtime T_OBJECT check --- ujit_compile.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ujit_compile.c b/ujit_compile.c index 79a5f05bc4..923eb85e19 100644 --- a/ujit_compile.c +++ b/ujit_compile.c @@ -635,6 +635,12 @@ gen_getinstancevariable(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx) return false; } + // If the class uses the default allocator, instances should all be T_OBJECT + if (rb_get_alloc_func(ic->entry->class_value) != rb_class_allocate_instance) + { + return false; + } + uint32_t ivar_index = ic->entry->index; // Create a size-exit to fall back to the interpreter @@ -664,12 +670,6 @@ gen_getinstancevariable(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx) test(cb, flags_opnd, imm_opnd(ROBJECT_EMBED)); jnz_ptr(cb, side_exit); - // Check that this is a Ruby object (not a string, etc) - mov(cb, REG1, flags_opnd); - and(cb, REG1, imm_opnd(RUBY_T_MASK)); - cmp(cb, REG1, imm_opnd(T_OBJECT)); - jne_ptr(cb, side_exit); - // Get a pointer to the extended table x86opnd_t tbl_opnd = mem_opnd(64, REG0, offsetof(struct RObject, as.heap.ivptr)); mov(cb, REG0, tbl_opnd);