diff options
Diffstat (limited to 'mjit_compile.c')
-rw-r--r-- | mjit_compile.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/mjit_compile.c b/mjit_compile.c index 1062fd87d1..95be02a4b5 100644 --- a/mjit_compile.c +++ b/mjit_compile.c @@ -215,9 +215,8 @@ compile_cancel_handler(FILE *f, const struct rb_iseq_constant_body *body, struct extern bool mjit_copy_cache_from_main_thread(const rb_iseq_t *iseq, struct rb_call_cache *cc_entries, union iseq_inline_storage_entry *is_entries); -// Compile ISeq to C code in `f`. It returns true if it succeeds to compile. -bool -mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname) +static bool +mjit_compile_body(FILE *f, const rb_iseq_t *iseq) { const struct rb_iseq_constant_body *body = iseq->body; struct compile_status status = { @@ -235,16 +234,6 @@ mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname) && !mjit_copy_cache_from_main_thread(iseq, status.cc_entries, status.is_entries)) return false; - // For performance, we verify stack size only on compilation time (mjit_compile.inc.erb) without --jit-debug - if (!mjit_opts.debug) { - fprintf(f, "#undef OPT_CHECKED_RUN\n"); - fprintf(f, "#define OPT_CHECKED_RUN 0\n\n"); - } - -#ifdef _WIN32 - fprintf(f, "__declspec(dllexport)\n"); -#endif - fprintf(f, "VALUE\n%s(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp)\n{\n", funcname); if (status.local_stack_p) { fprintf(f, " VALUE stack[%d];\n", body->stack_max); } @@ -271,8 +260,26 @@ mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname) compile_insns(f, body, 0, 0, &status); compile_cancel_handler(f, body, &status); - fprintf(f, "\n} /* end of %s */\n", funcname); return status.success; } +// Compile ISeq to C code in `f`. It returns true if it succeeds to compile. +bool +mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname) +{ + // For performance, we verify stack size only on compilation time (mjit_compile.inc.erb) without --jit-debug + if (!mjit_opts.debug) { + fprintf(f, "#undef OPT_CHECKED_RUN\n"); + fprintf(f, "#define OPT_CHECKED_RUN 0\n\n"); + } + +#ifdef _WIN32 + fprintf(f, "__declspec(dllexport)\n"); +#endif + fprintf(f, "VALUE\n%s(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp)\n{\n", funcname); + bool result = mjit_compile_body(f, iseq); + fprintf(f, "\n} // end of %s\n", funcname); + return result; +} + #endif // USE_MJIT |