зеркало из https://github.com/github/ruby.git
_mjit_compile_insn_body.erb: refactor
renamed from tool/ruby_vm/views/_mjit_compile_insn_line.erb. Basically this file should handle everything about macro on JIT. _mjit_compile_insn.erb: follow the refactoring common.mk: follow the rename git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
f6cebb97e9
Коммит
268d9236f6
|
@ -928,7 +928,7 @@ $(srcs_vpath)vmtc.inc: $(srcdir)/tool/ruby_vm/views/vmtc.inc.erb
|
||||||
$(srcs_vpath)vm.inc: $(srcdir)/tool/ruby_vm/views/vm.inc.erb
|
$(srcs_vpath)vm.inc: $(srcdir)/tool/ruby_vm/views/vm.inc.erb
|
||||||
$(srcs_vpath)mjit_compile.inc: $(srcdir)/tool/ruby_vm/views/mjit_compile.inc.erb \
|
$(srcs_vpath)mjit_compile.inc: $(srcdir)/tool/ruby_vm/views/mjit_compile.inc.erb \
|
||||||
$(srcdir)/tool/ruby_vm/views/_mjit_compile_insn.erb $(srcdir)/tool/ruby_vm/views/_mjit_compile_send.erb \
|
$(srcdir)/tool/ruby_vm/views/_mjit_compile_insn.erb $(srcdir)/tool/ruby_vm/views/_mjit_compile_send.erb \
|
||||||
$(srcdir)/tool/ruby_vm/views/_mjit_compile_insn_line.erb
|
$(srcdir)/tool/ruby_vm/views/_mjit_compile_insn_body.erb
|
||||||
|
|
||||||
common-srcs: $(srcs_vpath)parse.c $(srcs_vpath)lex.c $(srcs_vpath)enc/trans/newline.c $(srcs_vpath)id.c \
|
common-srcs: $(srcs_vpath)parse.c $(srcs_vpath)lex.c $(srcs_vpath)enc/trans/newline.c $(srcs_vpath)id.c \
|
||||||
srcs-lib srcs-ext incs
|
srcs-lib srcs-ext incs
|
||||||
|
|
|
@ -61,9 +61,7 @@
|
||||||
% end
|
% end
|
||||||
%
|
%
|
||||||
% # JIT: Print insn body in insns.def
|
% # JIT: Print insn body in insns.def
|
||||||
% insn.expr.expr.each_line do |line|
|
<%= render 'mjit_compile_insn_body', locals: { insn: insn } -%>
|
||||||
<%= render 'mjit_compile_insn_line', locals: { line: line, insn: insn } -%>
|
|
||||||
% end
|
|
||||||
%
|
%
|
||||||
% # JIT: Set return values
|
% # JIT: Set return values
|
||||||
% unless dispatched
|
% unless dispatched
|
||||||
|
|
|
@ -12,18 +12,40 @@
|
||||||
% rstring2cstr(indented.rstrip).sub(/"\z/, '\\n"')
|
% rstring2cstr(indented.rstrip).sub(/"\z/, '\\n"')
|
||||||
% end
|
% end
|
||||||
%
|
%
|
||||||
% # Special macro expansion for ones that can't be resolved by macro redefinition.
|
% #
|
||||||
% if line =~ /\A\s+DISPATCH_ORIGINAL_INSN\((?<insn_name>[^)]+)\);\s+\z/
|
% # Expand simple macro, which doesn't require dynamic C code.
|
||||||
fprintf(f, " return Qundef; /* cancel JIT */\n");
|
% #
|
||||||
% elsif line =~ /\A\s+JUMP\((?<dest>[^)]+)\);\s+\z/
|
% expand_simple_macros = lambda do |arg_expr|
|
||||||
% # Before we `goto` next insn, we need to set return values, especially for getinlinecache
|
% arg_expr.dup.tap do |expr|
|
||||||
% insn.rets.reverse_each.with_index do |ret, i|
|
% # For `opt_xxx`'s fallbacks.
|
||||||
% # TOPN(n) = ...
|
% expr.gsub!(/\bDISPATCH_ORIGINAL_INSN\([^)]+\);/, 'return Qundef; /* cancel JIT */')
|
||||||
fprintf(f, " stack[%d] = <%= ret.fetch(:name) %>;\n", b->stack_size + (int)<%= insn.call_attribute('sp_inc') %> - <%= i + 1 %>);
|
|
||||||
% end
|
|
||||||
%
|
%
|
||||||
% dest = Regexp.last_match[:dest]
|
% # For `leave`. We can't proceed next ISeq in the same JIT function.
|
||||||
% if insn.name == 'opt_case_dispatch' # special case... TODO: use another macro to avoid checking name
|
% expr.gsub!(/^(?<indent>\s*)RESTORE_REGS\(\);\n/) do
|
||||||
|
% indent = Regexp.last_match[:indent]
|
||||||
|
% <<~RESTORE_REGS
|
||||||
|
% #if OPT_CALL_THREADED_CODE
|
||||||
|
% #{indent}rb_ec_thread_ptr(ec)->retval = val;
|
||||||
|
% #{indent}return 0;
|
||||||
|
% #else
|
||||||
|
% #{indent}return val;
|
||||||
|
% #endif
|
||||||
|
% RESTORE_REGS
|
||||||
|
% end
|
||||||
|
% end
|
||||||
|
% end
|
||||||
|
%
|
||||||
|
% #
|
||||||
|
% # Print a body of insn, but with macro expansion.
|
||||||
|
% #
|
||||||
|
% expand_simple_macros.call(insn.expr.expr).each_line do |line|
|
||||||
|
% #
|
||||||
|
% # Expand dynamic macro here (only JUMP for now)
|
||||||
|
% #
|
||||||
|
% if line =~ /\A\s+JUMP\((?<dest>[^)]+)\);\s+\z/
|
||||||
|
% dest = Regexp.last_match[:dest]
|
||||||
|
%
|
||||||
|
% if insn.name == 'opt_case_dispatch' # special case... TODO: use another macro to avoid checking name
|
||||||
{
|
{
|
||||||
struct case_dispatch_var arg;
|
struct case_dispatch_var arg;
|
||||||
arg.f = f;
|
arg.f = f;
|
||||||
|
@ -36,17 +58,17 @@
|
||||||
fprintf(f, " goto label_%lu;\n", arg.base_pos + else_offset);
|
fprintf(f, " goto label_%lu;\n", arg.base_pos + else_offset);
|
||||||
fprintf(f, " }\n");
|
fprintf(f, " }\n");
|
||||||
}
|
}
|
||||||
% else
|
% else
|
||||||
|
% # Before we `goto` next insn, we need to set return values, especially for getinlinecache
|
||||||
|
% insn.rets.reverse_each.with_index do |ret, i|
|
||||||
|
% # TOPN(n) = ...
|
||||||
|
fprintf(f, " stack[%d] = <%= ret.fetch(:name) %>;\n", b->stack_size + (int)<%= insn.call_attribute('sp_inc') %> - <%= i + 1 %>);
|
||||||
|
% end
|
||||||
|
%
|
||||||
next_pos = pos + insn_len(insn) + (unsigned int)<%= dest %>;
|
next_pos = pos + insn_len(insn) + (unsigned int)<%= dest %>;
|
||||||
fprintf(f, " goto label_%d;\n", next_pos);
|
fprintf(f, " goto label_%d;\n", next_pos);
|
||||||
% end
|
% end
|
||||||
% elsif line =~ /\A\s+RESTORE_REGS\(\);\s+\z/ # for `leave` only
|
% else
|
||||||
#if OPT_CALL_THREADED_CODE
|
|
||||||
fprintf(f, " rb_ec_thread_ptr(ec)->retval = val;\n");
|
|
||||||
fprintf(f, " return 0;\n");
|
|
||||||
#else
|
|
||||||
fprintf(f, " return val;\n");
|
|
||||||
#endif
|
|
||||||
% else
|
|
||||||
fprintf(f, <%= to_cstr.call(line) %>);
|
fprintf(f, <%= to_cstr.call(line) %>);
|
||||||
|
% end
|
||||||
% end
|
% end
|
Загрузка…
Ссылка в новой задаче