[前][次][番号順一覧][スレッド一覧]

ruby-changes:55358

From: k0kubun <ko1@a...>
Date: Mon, 15 Apr 2019 23:39:02 +0900 (JST)
Subject: [ruby-changes:55358] k0kubun:r67566 (trunk): Carve out mjit_compile_body

k0kubun	2019-04-15 23:38:57 +0900 (Mon, 15 Apr 2019)

  New Revision: 67566

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67566

  Log:
    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.

  Modified files:
    trunk/mjit_compile.c
Index: mjit_compile.c
===================================================================
--- mjit_compile.c	(revision 67565)
+++ mjit_compile.c	(revision 67566)
@@ -215,9 +215,8 @@ compile_cancel_handler(FILE *f, const st https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L215
 
 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 *i https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L234
             && !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 *i https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L260
 
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]