diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2020-06-20 17:13:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-20 17:13:03 -0700 |
commit | 7561db8c009bb79a75024fa4ed0350bfb3d0626c (patch) | |
tree | e11e51b98e795e09d51b3062d7f71987d7225187 /tool | |
parent | d95249ade34626dc3ae82f8bfc84e1668b1b8d01 (diff) | |
download | ruby-7561db8c009bb79a75024fa4ed0350bfb3d0626c.tar.gz |
Introduce Primitive.attr! to annotate 'inline' (#3242)
[Feature #15589]
Diffstat (limited to 'tool')
-rw-r--r-- | tool/mk_builtin_loader.rb | 6 | ||||
-rw-r--r-- | tool/ruby_vm/views/mjit_compile.inc.erb | 17 |
2 files changed, 22 insertions, 1 deletions
diff --git a/tool/mk_builtin_loader.rb b/tool/mk_builtin_loader.rb index 01551592bf..9d4b6405a1 100644 --- a/tool/mk_builtin_loader.rb +++ b/tool/mk_builtin_loader.rb @@ -135,6 +135,12 @@ def collect_builtin base, tree, name, bs, inlines, params = nil if /(.+)\!\z/ =~ func_name case $1 + when 'attr' + text = inline_text(argc, args.first) + if text != 'inline' + raise "Only 'inline' is allowed to be annotated (but got: '#{text}')" + end + break when 'cstmt' text = inline_text argc, args.first diff --git a/tool/ruby_vm/views/mjit_compile.inc.erb b/tool/ruby_vm/views/mjit_compile.inc.erb index 0d3678dfb5..fa2e52e480 100644 --- a/tool/ruby_vm/views/mjit_compile.inc.erb +++ b/tool/ruby_vm/views/mjit_compile.inc.erb @@ -63,12 +63,26 @@ switch (insn) { } % when 'getinstancevariable', 'setinstancevariable' <%= render 'mjit_compile_ivar', locals: { insn: insn } -%> -% when 'leave' +% when 'leave', 'opt_invokebuiltin_delegate_leave' + { +% # opt_invokebuiltin_delegate_leave also implements leave insn. We need to handle it here for inlining. +% if insn.name == 'opt_invokebuiltin_delegate_leave' + RB_BUILTIN bf = (RB_BUILTIN)operands[0]; + rb_num_t index = (rb_num_t)operands[0]; + fprintf(f, "{\n"); + fprintf(f, " VALUE val;\n"); + fprintf(f, " RB_BUILTIN bf = (RB_BUILTIN)0x%"PRIxVALUE";\n", operands[0]); + fprintf(f, " rb_num_t index = (rb_num_t)0x%"PRIxVALUE";\n", operands[1]); + fprintf(f, <%= rstring2cstr(insn.expr.expr.lines.find { |l| l =~ / vm_invoke_builtin_delegate\(/ }).gsub("\n", '\n') %>); + fprintf(f, " stack[0] = val;\n"); + fprintf(f, "}\n"); +% else 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 % # Skip vm_pop_frame for inlined call if (status->inlined_iseqs != NULL) { // the current ISeq is NOT being inlined % # Cancel on interrupts to make leave insn leaf @@ -84,6 +98,7 @@ switch (insn) { b->stack_size += <%= insn.call_attribute('sp_inc') %>; b->finish_p = TRUE; break; + } % end % % # Main insn implementation generated by insns.def |