diff options
-rw-r--r-- | mjit.c | 6 | ||||
-rw-r--r-- | mjit_compiler.c | 12 |
2 files changed, 8 insertions, 10 deletions
@@ -1322,9 +1322,11 @@ mjit_target_iseq_p(const rb_iseq_t *iseq) // RubyVM::MJIT static VALUE rb_mMJIT = 0; // RubyVM::MJIT::C -VALUE rb_mMJITC = 0; +static VALUE rb_mMJITC = 0; // RubyVM::MJIT::Compiler VALUE rb_cMJITCompiler = 0; +// RubyVM::MJIT::CPointer::Struct_rb_iseq_t +VALUE rb_cMJITIseqPtr = 0; // [experimental] Call custom RubyVM::MJIT.compile if defined static void @@ -1767,7 +1769,9 @@ mjit_init(const struct mjit_options *opts) } rb_mMJITC = rb_const_get(rb_mMJIT, rb_intern("C")); rb_cMJITCompiler = rb_funcall(rb_const_get(rb_mMJIT, rb_intern("Compiler")), rb_intern("new"), 0); + rb_cMJITIseqPtr = rb_funcall(rb_mMJITC, rb_intern("rb_iseq_t"), 0); rb_gc_register_mark_object(rb_cMJITCompiler); + rb_gc_register_mark_object(rb_cMJITIseqPtr); mjit_call_p = true; mjit_pid = getpid(); diff --git a/mjit_compiler.c b/mjit_compiler.c index 6f0cfaa452..ebef0a80cd 100644 --- a/mjit_compiler.c +++ b/mjit_compiler.c @@ -33,14 +33,6 @@ struct case_dispatch_var { VALUE last_value; }; -static VALUE -rb_ptr(const char *type, const void *ptr) -{ - extern VALUE rb_mMJITC; - VALUE rb_type = rb_funcall(rb_mMJITC, rb_intern(type), 0); - return rb_funcall(rb_type, rb_intern("new"), 1, ULONG2NUM((size_t)ptr)); -} - // Returns true if call cache is still not obsoleted and vm_cc_cme(cc)->def->type is available. static bool has_valid_method_type(CALL_CACHE cc) @@ -112,8 +104,10 @@ mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname, int id) mjit_call_p = false; // Avoid impacting JIT metrics by itself extern VALUE rb_cMJITCompiler; + extern VALUE rb_cMJITIseqPtr; + VALUE iseq_ptr = rb_funcall(rb_cMJITIseqPtr, rb_intern("new"), 1, ULONG2NUM((size_t)iseq)); VALUE src = rb_funcall(rb_cMJITCompiler, rb_intern("compile"), 3, - rb_ptr("rb_iseq_t", iseq), rb_str_new_cstr(funcname), INT2NUM(id)); + iseq_ptr, rb_str_new_cstr(funcname), INT2NUM(id)); if (!NIL_P(src)) { fprintf(f, "%s", RSTRING_PTR(src)); } |