summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mjit_compile.c2
-rw-r--r--tool/ruby_vm/views/mjit_compile.inc.erb19
2 files changed, 16 insertions, 5 deletions
diff --git a/mjit_compile.c b/mjit_compile.c
index fa686c005c..d3ca3eedea 100644
--- a/mjit_compile.c
+++ b/mjit_compile.c
@@ -176,7 +176,7 @@ mjit_compile(FILE *f, const struct rb_iseq_constant_body *body, const char *func
status.compiled_for_pos = ZALLOC_N(int, body->iseq_size);
status.local_stack_p = !body->catch_except_p;
- /* For performance, disable stack consistency check on JIT unless debugging */
+ /* For performance, we verify stack size only on compilation time (mjit_compile.inc.erb) without --jit-debug */
if (!mjit_opts.debug) {
fprintf(f, "#undef OPT_CHECKED_RUN\n");
fprintf(f, "#define OPT_CHECKED_RUN 0\n\n");
diff --git a/tool/ruby_vm/views/mjit_compile.inc.erb b/tool/ruby_vm/views/mjit_compile.inc.erb
index 9961b18453..f78c45385f 100644
--- a/tool/ruby_vm/views/mjit_compile.inc.erb
+++ b/tool/ruby_vm/views/mjit_compile.inc.erb
@@ -46,14 +46,25 @@ switch (insn) {
% (RubyVM::BareInstructions.to_a + RubyVM::OperandsUnifications.to_a).each do |insn|
% next if unsupported_insns.include?(insn.name)
case BIN(<%= insn.name %>):
-% if %w[opt_send_without_block send].include?(insn.name)
-<%= render 'mjit_compile_send', locals: { insn: insn } -%>
-% elsif %w[opt_aref].include?(insn.name) # experimental. TODO: increase insns and make the list automatically by finding DISPATCH_ORIGINAL_INSN
-<%= render 'mjit_compile_send', locals: { insn: opt_send_without_block } -%>
+% # Instruction-specific behavior in JIT
+% case insn.name
+% when 'opt_send_without_block', 'send'
+<%= render 'mjit_compile_send', locals: { insn: insn } -%>
+% when 'opt_aref' # experimental. TODO: increase insns and make the list automatically by finding DISPATCH_ORIGINAL_INSN
+<%= render 'mjit_compile_send', locals: { insn: opt_send_without_block } -%>
+% when 'leave'
+ if (b->stack_size != 1) {
+ if (mjit_opts.warnings || mjit_opts.verbose)
+ fprintf(stderr, "MJIT warning: Unexpected JIT stack_size on leave: %d\n", b->stack_size);
+ status->success = FALSE;
+ }
% end
+%
+% # Main insn implementation generated by insns.def
<%= render 'mjit_compile_insn', locals: { insn: insn, dispatched: false } -%>
break;
% end
+%
% # We don't support InstructionsUnifications yet because it's not used for now.
% # We don't support TraceInstructions yet. There is no blocker for it but it's just not implemented.
default: