mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 09:33:59 +02:00
MJIT: Cache an ISeq pointer instance
to obviate one rb_funcall. This also removes rb_ptr as refactoring.
This commit is contained in:
parent
2329cbeb5b
commit
44165df121
2 changed files with 8 additions and 10 deletions
6
mjit.c
6
mjit.c
|
@ -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();
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue