mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Eliminate a call instruction on JIT cancel path
by calling combined functions specialized for each cancel type. I'm hoping to improve locality of hot code, but this patch's impact should be insignificant.
This commit is contained in:
parent
4cabd77e33
commit
61b14bb32b
3 changed files with 42 additions and 11 deletions
36
mjit.c
36
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.
|
||||
|
|
5
mjit.h
5
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);
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue