summaryrefslogtreecommitdiff
path: root/mjit_compiler.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-09-06 12:57:24 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2022-09-06 15:50:14 +0900
commit341b40bd0c2228a7759852b82af1fb11c15751e6 (patch)
tree79bad4020a33208089376816e7b11ddcf7bfb071 /mjit_compiler.c
parent5b3bd91fcba7224e9ece54c862dc96461cf4bf79 (diff)
Cache RubyVM::MJIT constants
for performance
Diffstat (limited to 'mjit_compiler.c')
-rw-r--r--mjit_compiler.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/mjit_compiler.c b/mjit_compiler.c
index fccd6cfd2a..5163bbcf6b 100644
--- a/mjit_compiler.c
+++ b/mjit_compiler.c
@@ -36,10 +36,8 @@ struct case_dispatch_var {
static VALUE
rb_ptr(const char *type, const void *ptr)
{
- // TODO: cache constant
- VALUE rb_mMJIT = rb_const_get(rb_cRubyVM, rb_intern("MJIT"));
- VALUE rb_mC = rb_const_get(rb_mMJIT, rb_intern("C"));
- VALUE rb_type = rb_funcall(rb_mC, rb_intern(type), 0);
+ 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));
}
@@ -124,10 +122,8 @@ mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname, int id)
bool original_call_p = mjit_call_p;
mjit_call_p = false; // Avoid impacting JIT metrics by itself
- // TODO: initialize the constant in mjit_init and use it
- VALUE rb_mMJIT = rb_const_get(rb_cRubyVM, rb_intern("MJIT"));
- VALUE rb_mCompiler = rb_const_get(rb_mMJIT, rb_intern("Compiler"));
- bool success = RTEST(rb_funcall(rb_mCompiler, rb_intern("compile"), 4,
+ extern VALUE rb_mMJITCompiler;
+ bool success = RTEST(rb_funcall(rb_mMJITCompiler, rb_intern("compile"), 4,
PTR2NUM((VALUE)f), rb_ptr("rb_iseq_t", iseq), rb_str_new_cstr(funcname), INT2NUM(id)));
mjit_call_p = original_call_p;