summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-07-13 11:43:24 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-07-16 11:49:09 +0900
commit1fb4e28002327c1224c3ed32783160b011f14747 (patch)
tree90092c1ed3c8d9d2f65aafd6e9d2bf2e812bda21 /tool
parent5d5b8a33f648753f69e10df5d3793bdaa83cfc1f (diff)
skip inlining cexpr! that are not attr! inline
Requested by ko1.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3314
Diffstat (limited to 'tool')
-rw-r--r--tool/mk_builtin_loader.rb48
-rw-r--r--tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb2
2 files changed, 27 insertions, 23 deletions
diff --git a/tool/mk_builtin_loader.rb b/tool/mk_builtin_loader.rb
index 271c47f9ad..fd8085086e 100644
--- a/tool/mk_builtin_loader.rb
+++ b/tool/mk_builtin_loader.rb
@@ -285,35 +285,39 @@ def mk_builtin_header file
}
bs.each_pair{|func, (argc, cfunc_name)|
+ decl = ', VALUE' * argc
+ argv = argc \
+ . times \
+ . map {|i|", argv[#{i}]"} \
+ . join('')
f.puts %'static void'
- f.puts %'mjit_compile_invokebuiltin_for_#{func}(FILE *f, long index, unsigned stack_size)'
+ f.puts %'mjit_compile_invokebuiltin_for_#{func}(FILE *f, long index, unsigned stack_size, bool inlinable_p)'
f.puts %'{'
+ f.puts %' fprintf(f, " VALUE self = GET_SELF();\\n");'
+ f.puts %' fprintf(f, " typedef VALUE (*func)(rb_execution_context_t *, VALUE#{decl});\\n");'
if inlines.has_key? cfunc_name
- f.puts %' fprintf(f, " MAYBE_UNUSED(VALUE) self = GET_SELF();\\n");'
body_lineno, text, locals, func_name = inlines[cfunc_name]
lineno, str = generate_cexpr(ofile, lineno, line_file, body_lineno, text, locals, func_name)
- str.each_line {|i|
- f.printf(%' fprintf(f, "%%s", %s);\n', RubyVM::CEscape.rstring2cstr(i.sub(/^return\b/ , ' val =')))
+ f.puts %' if (inlinable_p) {'
+ str.gsub(/^(?!#)/, ' ').each_line {|i|
+ j = RubyVM::CEscape.rstring2cstr(i).dup
+ j.sub!(/^ return\b/ , ' val =')
+ f.printf(%' fprintf(f, "%%s", %s);\n', j)
}
- else
- decl = ', VALUE' * argc
- argv = argc \
- . times \
- . map {|i|", argv[#{i}]"} \
- . join('')
- f.puts %' fprintf(f, " typedef VALUE (*func)(rb_execution_context_t *, VALUE#{decl});\\n");'
- if argc > 0
- f.puts %' if (index == -1) {'
- f.puts %' fprintf(f, " const VALUE *argv = &stack[%d];\\n", stack_size - #{argc});'
- f.puts %' }'
- f.puts %' else {'
- f.puts %' fprintf(f, " const unsigned int lnum = GET_ISEQ()->body->local_table_size;\\n");'
- f.puts %' fprintf(f, " const VALUE *argv = GET_EP() - lnum - VM_ENV_DATA_SIZE + 1 + %ld;\\n", index);'
- f.puts %' }'
- end
- f.puts %' fprintf(f, " func f = (func)%"PRIdPTR"; /* == #{cfunc_name} */\\n", (intptr_t)#{cfunc_name});'
- f.puts %' fprintf(f, " val = f(ec, GET_SELF()#{argv});\\n");'
+ f.puts(%' return;')
+ f.puts(%' }')
+ end
+ if argc > 0
+ f.puts %' if (index == -1) {'
+ f.puts %' fprintf(f, " const VALUE *argv = &stack[%d];\\n", stack_size - #{argc});'
+ f.puts %' }'
+ f.puts %' else {'
+ f.puts %' fprintf(f, " const unsigned int lnum = GET_ISEQ()->body->local_table_size;\\n");'
+ f.puts %' fprintf(f, " const VALUE *argv = GET_EP() - lnum - VM_ENV_DATA_SIZE + 1 + %ld;\\n", index);'
+ f.puts %' }'
end
+ f.puts %' fprintf(f, " func f = (func)%"PRIdPTR"; /* == #{cfunc_name} */\\n", (intptr_t)#{cfunc_name});'
+ f.puts %' fprintf(f, " val = f(ec, self#{argv});\\n");'
f.puts %'}'
f.puts
}
diff --git a/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb b/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb
index 9a9e53af40..a3796ffc5e 100644
--- a/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb
+++ b/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb
@@ -19,7 +19,7 @@
fprintf(f, " VALUE val;\n");
bf->compiler(f, <%=
insn.name == 'invokebuiltin' ? '-1' : '(rb_num_t)operands[1]'
- %>, b->stack_size);
+ %>, b->stack_size, body->builtin_inline_p);
fprintf(f, " stack[%u] = val;\n", sp - 1);
fprintf(f, "}\n");
% if insn.name != 'opt_invokebuiltin_delegate_leave'