summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2023-03-01 23:29:32 -0800
committerTakashi Kokubun <[email protected]>2023-03-05 23:28:59 -0800
commit42adcd5743d68b96391c96d7b23e3890606afb1a (patch)
tree9271bd4458b12d12206fc3de91c5bf8762964bf6
parent487d4aa970d910c8f521ea97ae78e3ffc119cad3 (diff)
Increase max depth for chain guards
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7448
-rw-r--r--lib/ruby_vm/mjit/insn_compiler.rb9
-rw-r--r--mjit_c.h3
-rw-r--r--mjit_c.rb3
3 files changed, 9 insertions, 6 deletions
diff --git a/lib/ruby_vm/mjit/insn_compiler.rb b/lib/ruby_vm/mjit/insn_compiler.rb
index 947739ddae..247cdbe260 100644
--- a/lib/ruby_vm/mjit/insn_compiler.rb
+++ b/lib/ruby_vm/mjit/insn_compiler.rb
@@ -1649,7 +1649,7 @@ module RubyVM::MJIT
# @param jit [RubyVM::MJIT::JITState]
# @param ctx [RubyVM::MJIT::Context]
# @param asm [RubyVM::MJIT::Assembler]
- def jit_chain_guard(opcode, jit, ctx, asm, side_exit, limit: 10)
+ def jit_chain_guard(opcode, jit, ctx, asm, side_exit, limit: 20)
opcode => :je | :jne | :jnz | :jz
if ctx.chain_depth < limit
@@ -2572,12 +2572,13 @@ module RubyVM::MJIT
end
asm.comment("Guard #{comptime_symbol.inspect} is on stack")
- mid_changed_exit = counted_exit(side_exit(jit, ctx), :send_optimized_send_mid_changed)
- jit_guard_known_klass(jit, ctx, asm, comptime_symbol.class, ctx.stack_opnd(argc), comptime_symbol, mid_changed_exit)
+ class_changed_exit = counted_exit(side_exit(jit, ctx), :send_optimized_send_mid_class_changed)
+ jit_guard_known_klass(jit, ctx, asm, comptime_symbol.class, ctx.stack_opnd(argc), comptime_symbol, class_changed_exit)
asm.mov(C_ARGS[0], ctx.stack_opnd(argc))
asm.call(C.rb_get_symbol_id)
asm.cmp(C_RET, mid)
- jit_chain_guard(:jne, jit, ctx, asm, mid_changed_exit)
+ id_changed_exit = counted_exit(side_exit(jit, ctx), :send_optimized_send_mid_id_changed)
+ jit_chain_guard(:jne, jit, ctx, asm, id_changed_exit)
# rb_callable_method_entry_with_refinements
cme = jit_search_method(jit, ctx, asm, mid, argc, flags, send_shift:)
diff --git a/mjit_c.h b/mjit_c.h
index 37c23ff8f0..6a8f4dc122 100644
--- a/mjit_c.h
+++ b/mjit_c.h
@@ -157,7 +157,8 @@ MJIT_RUNTIME_COUNTERS(
send_optimized_send_no_args,
send_optimized_send_not_sym_or_str,
- send_optimized_send_mid_changed,
+ send_optimized_send_mid_class_changed,
+ send_optimized_send_mid_id_changed,
send_optimized_send_null_mid,
send_optimized_send_send,
diff --git a/mjit_c.rb b/mjit_c.rb
index e118265e07..b1c573fe6e 100644
--- a/mjit_c.rb
+++ b/mjit_c.rb
@@ -1297,7 +1297,8 @@ module RubyVM::MJIT # :nodoc: all
send_optimized_unknown_type: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized_unknown_type)")],
send_optimized_send_no_args: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized_send_no_args)")],
send_optimized_send_not_sym_or_str: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized_send_not_sym_or_str)")],
- send_optimized_send_mid_changed: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized_send_mid_changed)")],
+ send_optimized_send_mid_class_changed: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized_send_mid_class_changed)")],
+ send_optimized_send_mid_id_changed: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized_send_mid_id_changed)")],
send_optimized_send_null_mid: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized_send_null_mid)")],
send_optimized_send_send: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), send_optimized_send_send)")],
invokesuper_me_changed: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_mjit_runtime_counters *)NULL)), invokesuper_me_changed)")],