diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-03 22:30:18 -0800 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-05 23:28:59 -0800 |
| commit | a1b23954093ef8e840736f78b02659a383fe4ade (patch) | |
| tree | 0862cb7cfb4bd73ee0f81066f0ea426dd25cbf79 /lib/ruby_vm | |
| parent | 6b2c3ff813a78559ab2e88495db593a54b47e995 (diff) | |
Check for classes consistently
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7448
Diffstat (limited to 'lib/ruby_vm')
| -rw-r--r-- | lib/ruby_vm/mjit/insn_compiler.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/ruby_vm/mjit/insn_compiler.rb b/lib/ruby_vm/mjit/insn_compiler.rb index 1c49c162f3..25db7c24c6 100644 --- a/lib/ruby_vm/mjit/insn_compiler.rb +++ b/lib/ruby_vm/mjit/insn_compiler.rb @@ -1559,7 +1559,7 @@ module RubyVM::MJIT side_exit = side_exit(jit, ctx) - if comptime_recv.class == Array && fixnum?(comptime_obj) + if C.rb_class_of(comptime_recv) == Array && fixnum?(comptime_obj) unless Invariants.assume_bop_not_redefined(jit, C.ARRAY_REDEFINED_OP_FLAG, C.BOP_AREF) return CantCompile end @@ -1592,7 +1592,7 @@ module RubyVM::MJIT # Let guard chains share the same successor jump_to_next_insn(jit, ctx, asm) EndBlock - elsif comptime_recv.class == Hash + elsif C.rb_class_of(comptime_recv) == Hash unless Invariants.assume_bop_not_redefined(jit, C.HASH_REDEFINED_OP_FLAG, C.BOP_AREF) return CantCompile end @@ -1645,7 +1645,7 @@ module RubyVM::MJIT key = ctx.stack_opnd(1) _val = ctx.stack_opnd(0) - if comptime_recv.class == Array && fixnum?(comptime_key) + if C.rb_class_of(comptime_recv) == Array && fixnum?(comptime_key) side_exit = side_exit(jit, ctx) # Guard receiver is an Array @@ -1680,7 +1680,7 @@ module RubyVM::MJIT jump_to_next_insn(jit, ctx, asm) EndBlock - elsif comptime_recv.class == Hash + elsif C.rb_class_of(comptime_recv) == Hash side_exit = side_exit(jit, ctx) # Guard receiver is a Hash @@ -2224,7 +2224,7 @@ module RubyVM::MJIT asm.and(:rax, C.RUBY_FLONUM_MASK) asm.cmp(:rax, C.RUBY_FLONUM_FLAG) jit_chain_guard(:jne, jit, ctx, asm, side_exit, limit:) - elsif known_klass.singleton_class? + elsif C.FL_TEST(known_klass, C.RUBY_FL_SINGLETON) && comptime_obj == C.rb_class_attached_object(known_klass) asm.comment('guard known object with singleton class') asm.mov(:rax, C.to_value(comptime_obj)) asm.cmp(obj_opnd, :rax) @@ -2359,7 +2359,7 @@ module RubyVM::MJIT asm.mov(dst, :rax) true - elsif comptime_a.class == String && comptime_b.class == String + elsif C.rb_class_of(comptime_a) == String && C.rb_class_of(comptime_b) == String unless Invariants.assume_bop_not_redefined(jit, C.STRING_REDEFINED_OP_FLAG, C.BOP_EQ) # if overridden, emit the generic version return false |
