mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
e17053c720
commit
be91995a5e
1 changed files with 6 additions and 6 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue