From 9b6dec6cac17a507792add61247772ac76d23f48 Mon Sep 17 00:00:00 2001 From: k0kubun Date: Thu, 3 May 2018 00:52:30 +0000 Subject: mjit_compile.inc.erb: verify stack consistency on JIT compilation. r63092 was risky without this check. mjit_compile.c: update comment about stack consistency check git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/ruby_vm/views/mjit_compile.inc.erb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'tool') 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: -- cgit v1.2.3