aboutsummaryrefslogtreecommitdiffstats
path: root/mjit_compile.c
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-15 14:38:57 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-15 14:38:57 +0000
commite68495e5f4dfd466ad56f745502d1d78cdba07de (patch)
treeb25064203164251e7fe966d652c19e05742a1d38 /mjit_compile.c
parent246723a34ce5024e1d018cee4327dcce1bbd55c6 (diff)
downloadruby-e68495e5f4dfd466ad56f745502d1d78cdba07de.tar.gz
Carve out mjit_compile_body
This refactoring is needed for implementing inlining later. I've had this since long ago and it has conflicted sometimes. So let me just commit this now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'mjit_compile.c')
-rw-r--r--mjit_compile.c35
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