diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-07 23:14:07 -0800 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-07 23:16:24 -0800 |
commit | e93e780f3d37705a26a9160c60cc92255c1ff60a (patch) | |
tree | fcaee4606e3ba755cb1c560f8e1ce4db0385d37d | |
parent | b67f07fa2c5b7fe9a08563bbc8084401b2ec68c4 (diff) | |
download | ruby-e93e780f3d37705a26a9160c60cc92255c1ff60a.tar.gz |
Remove MJIT's builtin function compiler
-rw-r--r-- | builtin.h | 6 | ||||
-rw-r--r-- | rjit_c.rb | 11 | ||||
-rw-r--r-- | tool/mk_builtin_loader.rb | 42 | ||||
-rw-r--r-- | yjit/src/cruby_bindings.inc.rs | 8 |
4 files changed, 3 insertions, 64 deletions
@@ -11,17 +11,13 @@ struct rb_builtin_function { // for load const int index; const char * const name; - - // for jit - void (*compiler)(VALUE, long, unsigned, bool); }; -#define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity, _compiler) {\ +#define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity) {\ .name = _i < 0 ? NULL : #_name, \ .func_ptr = (void *)_fname, \ .argc = _arity, \ .index = _i, \ - .compiler = _compiler, \ } void rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table); @@ -435,16 +435,6 @@ module RubyVM::RJIT # :nodoc: all Primitive.cexpr! 'rb_hash_values((VALUE)NUM2PTR(cdhash_addr))' end - def builtin_compiler(buf, bf_ptr, index, stack_size, builtin_inline_p) - _bf_addr = bf_ptr.to_i - # Call "rjit_compile_invokebuiltin_for_#{func}" in mk_builtin_loader.rb - Primitive.cstmt! %{ - RB_BUILTIN bf = (RB_BUILTIN)NUM2PTR(_bf_addr); - bf->compiler(buf, NIL_P(index) ? -1 : NUM2LONG(index), NUM2UINT(stack_size), RTEST(builtin_inline_p)); - return Qnil; - } - end - def has_cache_for_send(cc_ptr, insn) _cc_addr = cc_ptr.to_i Primitive.cstmt! %{ @@ -1169,7 +1159,6 @@ module RubyVM::RJIT # :nodoc: all argc: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rb_builtin_function *)NULL)), argc)")], index: [CType::Immediate.parse("int"), Primitive.cexpr!("OFFSETOF((*((struct rb_builtin_function *)NULL)), index)")], name: [CType::Pointer.new { CType::Immediate.parse("char") }, Primitive.cexpr!("OFFSETOF((*((struct rb_builtin_function *)NULL)), name)")], - compiler: [CType::Immediate.parse("void *"), Primitive.cexpr!("OFFSETOF((*((struct rb_builtin_function *)NULL)), compiler)")], ) end diff --git a/tool/mk_builtin_loader.rb b/tool/mk_builtin_loader.rb index 0b16f9fc27..112c82c8f4 100644 --- a/tool/mk_builtin_loader.rb +++ b/tool/mk_builtin_loader.rb @@ -318,44 +318,6 @@ def mk_builtin_header file end } - bs.each_pair{|func, (argc, cfunc_name)| - decl = ', VALUE' * argc - argv = argc \ - . times \ - . map {|i|", argv[#{i}]"} \ - . join('') - f.puts %'static void' - f.puts %'rjit_compile_invokebuiltin_for_#{func}(VALUE buf, long index, unsigned stack_size, bool inlinable_p)' - f.puts %'{' - f.puts %' rb_str_catf(buf, " VALUE self = GET_SELF();\\n");' - f.puts %' rb_str_catf(buf, " typedef VALUE (*func)(rb_execution_context_t *, VALUE#{decl});\\n");' - if inlines.has_key? cfunc_name - body_lineno, text, locals, func_name = inlines[cfunc_name] - lineno, str = generate_cexpr(ofile, lineno, line_file, body_lineno, text, locals, func_name) - f.puts %' if (inlinable_p) {' - str.gsub(/^(?!#)/, ' ').each_line {|i| - j = RubyVM::CEscape.rstring2cstr(i).dup - j.sub!(/^ return\b/ , ' val =') - f.printf(%' rb_str_catf(buf, "%%s", %s);\n', j) - } - f.puts(%' return;') - f.puts(%' }') - end - if argc > 0 - f.puts %' if (index == -1) {' - f.puts %' rb_str_catf(buf, " const VALUE *argv = &stack[%d];\\n", stack_size - #{argc});' - f.puts %' }' - f.puts %' else {' - f.puts %' rb_str_catf(buf, " const unsigned int lnum = ISEQ_BODY(GET_ISEQ())->local_table_size;\\n");' - f.puts %' rb_str_catf(buf, " const VALUE *argv = GET_EP() - lnum - VM_ENV_DATA_SIZE + 1 + %ld;\\n", index);' - f.puts %' }' - end - f.puts %' rb_str_catf(buf, " func f = (func)%"PRIuVALUE"; /* == #{cfunc_name} */\\n", (VALUE)#{cfunc_name});' - f.puts %' rb_str_catf(buf, " val = f(ec, self#{argv});\\n");' - f.puts %'}' - f.puts - } - if SUBLIBS[base] f.puts "// sub libraries" SUBLIBS[base].each do |sub| @@ -371,9 +333,9 @@ def mk_builtin_header file f.puts " // table definition" f.puts " static const struct rb_builtin_function #{table}[] = {" bs.each.with_index{|(func, (argc, cfunc_name)), i| - f.puts " RB_BUILTIN_FUNCTION(#{i}, #{func}, #{cfunc_name}, #{argc}, rjit_compile_invokebuiltin_for_#{func})," + f.puts " RB_BUILTIN_FUNCTION(#{i}, #{func}, #{cfunc_name}, #{argc})," } - f.puts " RB_BUILTIN_FUNCTION(-1, NULL, NULL, 0, 0)," + f.puts " RB_BUILTIN_FUNCTION(-1, NULL, NULL, 0)," f.puts " };" f.puts diff --git a/yjit/src/cruby_bindings.inc.rs b/yjit/src/cruby_bindings.inc.rs index a683c5a1e4..87d06fc658 100644 --- a/yjit/src/cruby_bindings.inc.rs +++ b/yjit/src/cruby_bindings.inc.rs @@ -848,14 +848,6 @@ pub struct rb_builtin_function { pub argc: ::std::os::raw::c_int, pub index: ::std::os::raw::c_int, pub name: *const ::std::os::raw::c_char, - pub compiler: ::std::option::Option< - unsafe extern "C" fn( - arg1: VALUE, - arg2: ::std::os::raw::c_long, - arg3: ::std::os::raw::c_uint, - arg4: bool, - ), - >, } pub const YARVINSN_nop: ruby_vminsn_type = 0; pub const YARVINSN_getlocal: ruby_vminsn_type = 1; |