diff options
author | Aaron Patterson <tenderlove@ruby-lang.org> | 2020-11-12 09:25:14 -0800 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:26 -0400 |
commit | be91995a5e91c2ad0136e44f553ffdd80342d090 (patch) | |
tree | 5a9f1375d92b1dd973b2b52ae418b1e3f3854a68 | |
parent | e17053c72090dd8d732742386303f9964b6326ce (diff) |
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
-rw-r--r-- | ujit_compile.c | 12 |
1 files 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); |