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

ruby-changes:51125

From: k0kubun <ko1@a...>
Date: Thu, 3 May 2018 16:09:59 +0900 (JST)
Subject: [ruby-changes:51125] k0kubun:r63332 (trunk): mjit_compile.c: skip generating unnecessary goto

k0kubun	2018-05-03 16:09:51 +0900 (Thu, 03 May 2018)

  New Revision: 63332

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

  Log:
    mjit_compile.c: skip generating unnecessary goto
    
    after return or longjmp. This is mainly for skipping the check of stack
    size in such cases, which shouldn't be checked because it does never
    happen.

  Modified files:
    trunk/mjit_compile.c
Index: mjit_compile.c
===================================================================
--- mjit_compile.c	(revision 63331)
+++ mjit_compile.c	(revision 63332)
@@ -122,18 +122,18 @@ compile_insn(FILE *f, const struct rb_is https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L122
  #include "mjit_compile.inc"
 /*****************/
 
-    if (next_pos < body->iseq_size && ALREADY_COMPILED_P(status, next_pos)) {
+    /* If next_pos is already compiled and this branch is not finished yet,
+       next instruction won't be compiled in C code next and will need `goto`. */
+    if (!b->finish_p && next_pos < body->iseq_size && ALREADY_COMPILED_P(status, next_pos)) {
+        fprintf(f, "goto label_%d;\n", next_pos);
+
         /* Verify stack size assumption is the same among multiple branches */
         if ((unsigned int)status->stack_size_for_pos[next_pos] != b->stack_size) {
             if (mjit_opts.warnings || mjit_opts.verbose)
                 fprintf(stderr, "MJIT warning: JIT stack assumption is not the same between branches (%d != %u)\n",
                         status->stack_size_for_pos[next_pos], b->stack_size);
             status->success = FALSE;
-            return next_pos;
         }
-
-        /* If next_pos is already compiled, next instruction won't be compiled in C code and needs `goto`. */
-        fprintf(f, "goto label_%d;\n", next_pos);
     }
 
     return next_pos;

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

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