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
This commit is contained in:
k0kubun 2018-05-03 00:52:30 +00:00
Родитель 6afea14043
Коммит 9b6dec6cac
2 изменённых файлов: 16 добавлений и 5 удалений

Просмотреть файл

@ -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");

Просмотреть файл

@ -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: