summaryrefslogtreecommitdiff
path: root/mjit_compiler.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-11-28 23:53:26 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2022-11-28 23:53:33 -0800
commit44165df121f13ef7b148b8ba4aa08386a24c4df5 (patch)
tree0032bb51ec1fe7e226c83220024d6a499d18e2c4 /mjit_compiler.c
parent2329cbeb5bf7c7e8720cd4512285e6784c41367e (diff)
MJIT: Cache an ISeq pointer instance
to obviate one rb_funcall. This also removes rb_ptr as refactoring.
Diffstat (limited to 'mjit_compiler.c')
-rw-r--r--mjit_compiler.c12
1 files changed, 3 insertions, 9 deletions
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));
}