summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-04-05 00:46:09 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2023-04-05 00:46:10 -0700
commit65d27d3c0a1235f04ca90f94e29a7f2ddfd1b574 (patch)
tree22f65e40ae12245e063a9a1d40970fca50ec6e4a
parent9bef39de74684343ef3a20269f1a37ee395c2057 (diff)
RJIT: Skip a class guard if known to be T_STRING
-rw-r--r--lib/ruby_vm/rjit/insn_compiler.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/ruby_vm/rjit/insn_compiler.rb b/lib/ruby_vm/rjit/insn_compiler.rb
index 5ad73dab11..906743ae0f 100644
--- a/lib/ruby_vm/rjit/insn_compiler.rb
+++ b/lib/ruby_vm/rjit/insn_compiler.rb
@@ -3878,9 +3878,12 @@ module RubyVM::RJIT
asm.je(equal_label)
# Otherwise guard that b is a T_STRING (from type info) or String (from runtime guard)
- # Note: any T_STRING is valid here, but we check for a ::String for simplicity
- # To pass a mutable static variable (rb_cString) requires an unsafe block
- jit_guard_known_klass(jit, ctx, asm, C.rb_class_of(comptime_b), b_opnd, StackOpnd[0], comptime_b, side_exit)
+ btype = ctx.get_opnd_type(StackOpnd[0])
+ unless btype.string?
+ # Note: any T_STRING is valid here, but we check for a ::String for simplicity
+ # To pass a mutable static variable (rb_cString) requires an unsafe block
+ jit_guard_known_klass(jit, ctx, asm, C.rb_class_of(comptime_b), b_opnd, StackOpnd[0], comptime_b, side_exit)
+ end
asm.comment('call rb_str_eql_internal')
asm.mov(C_ARGS[0], a_opnd)