diff --git a/mjit.c b/mjit.c index 4b2e7c5fb8..f2443e027c 100644 --- a/mjit.c +++ b/mjit.c @@ -455,8 +455,8 @@ rb_mjit_iseq_compile_info(const struct rb_iseq_constant_body *body) return &body->jit_unit->compile_info; } -void -rb_mjit_recompile_iseq(const rb_iseq_t *iseq) +static void +mjit_recompile(const rb_iseq_t *iseq) { if ((uintptr_t)iseq->body->jit_func <= (uintptr_t)LAST_JIT_ISEQ_FUNC) return; @@ -476,6 +476,38 @@ rb_mjit_recompile_iseq(const rb_iseq_t *iseq) } } +// Recompile iseq, disabling send optimization +void +rb_mjit_recompile_send(const rb_iseq_t *iseq) +{ + rb_mjit_iseq_compile_info(iseq->body)->disable_send_cache = true; + mjit_recompile(iseq); +} + +// Recompile iseq, disabling ivar optimization +void +rb_mjit_recompile_ivar(const rb_iseq_t *iseq) +{ + rb_mjit_iseq_compile_info(iseq->body)->disable_ivar_cache = true; + mjit_recompile(iseq); +} + +// Recompile iseq, disabling exivar optimization +void +rb_mjit_recompile_exivar(const rb_iseq_t *iseq) +{ + rb_mjit_iseq_compile_info(iseq->body)->disable_exivar_cache = true; + mjit_recompile(iseq); +} + +// Recompile iseq, disabling method inlining +void +rb_mjit_recompile_inlining(const rb_iseq_t *iseq) +{ + rb_mjit_iseq_compile_info(iseq->body)->disable_inlining = true; + mjit_recompile(iseq); +} + extern VALUE ruby_archlibdir_path, ruby_prefix_path; // Initialize header_file, pch_file, libruby_pathflag. Return true on success. diff --git a/mjit.h b/mjit.h index 72d865e6d9..0c938965ac 100644 --- a/mjit.h +++ b/mjit.h @@ -80,7 +80,10 @@ RUBY_EXTERN bool mjit_call_p; extern void rb_mjit_add_iseq_to_process(const rb_iseq_t *iseq); extern VALUE rb_mjit_wait_call(rb_execution_context_t *ec, struct rb_iseq_constant_body *body); extern struct rb_mjit_compile_info* rb_mjit_iseq_compile_info(const struct rb_iseq_constant_body *body); -extern void rb_mjit_recompile_iseq(const rb_iseq_t *iseq); +extern void rb_mjit_recompile_send(const rb_iseq_t *iseq); +extern void rb_mjit_recompile_ivar(const rb_iseq_t *iseq); +extern void rb_mjit_recompile_exivar(const rb_iseq_t *iseq); +extern void rb_mjit_recompile_inlining(const rb_iseq_t *iseq); RUBY_SYMBOL_EXPORT_END extern bool mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname, int id); diff --git a/mjit_compile.c b/mjit_compile.c index 6a17d2408c..fe5c2413e4 100644 --- a/mjit_compile.c +++ b/mjit_compile.c @@ -241,8 +241,7 @@ compile_inlined_cancel_handler(FILE *f, const struct rb_iseq_constant_body *body { fprintf(f, "\ncancel:\n"); fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel);\n"); - fprintf(f, " rb_mjit_iseq_compile_info(original_iseq->body)->disable_inlining = true;\n"); - fprintf(f, " rb_mjit_recompile_iseq(original_iseq);\n"); + fprintf(f, " rb_mjit_recompile_inlining(original_iseq);\n"); // Swap pc/sp set on cancel with original pc/sp. fprintf(f, " const VALUE *current_pc = reg_cfp->pc;\n"); @@ -282,20 +281,17 @@ compile_cancel_handler(FILE *f, const struct rb_iseq_constant_body *body, struct fprintf(f, "\nsend_cancel:\n"); fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_send_inline);\n"); - fprintf(f, " rb_mjit_iseq_compile_info(original_iseq->body)->disable_send_cache = true;\n"); - fprintf(f, " rb_mjit_recompile_iseq(original_iseq);\n"); + fprintf(f, " rb_mjit_recompile_send(original_iseq);\n"); fprintf(f, " goto cancel;\n"); fprintf(f, "\nivar_cancel:\n"); fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_ivar_inline);\n"); - fprintf(f, " rb_mjit_iseq_compile_info(original_iseq->body)->disable_ivar_cache = true;\n"); - fprintf(f, " rb_mjit_recompile_iseq(original_iseq);\n"); + fprintf(f, " rb_mjit_recompile_ivar(original_iseq);\n"); fprintf(f, " goto cancel;\n"); fprintf(f, "\nexivar_cancel:\n"); fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_exivar_inline);\n"); - fprintf(f, " rb_mjit_iseq_compile_info(original_iseq->body)->disable_exivar_cache = true;\n"); - fprintf(f, " rb_mjit_recompile_iseq(original_iseq);\n"); + fprintf(f, " rb_mjit_recompile_exivar(original_iseq);\n"); fprintf(f, " goto cancel;\n"); fprintf(f, "\ncancel:\n");