mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
skip inlining cexpr! that are not attr! inline
Requested by ko1.
This commit is contained in:
parent
5d5b8a33f6
commit
1fb4e28002
Notes:
git
2020-07-16 11:49:34 +09:00
3 changed files with 28 additions and 24 deletions
|
@ -13,7 +13,7 @@ struct rb_builtin_function {
|
|||
const char * const name;
|
||||
|
||||
// for jit
|
||||
void (*compiler)(FILE *, long, unsigned);
|
||||
void (*compiler)(FILE *, long, unsigned, bool);
|
||||
};
|
||||
|
||||
#define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity, _compiler) {\
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue