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

ruby-changes:51819

From: k0kubun <ko1@a...>
Date: Tue, 24 Jul 2018 23:36:18 +0900 (JST)
Subject: [ruby-changes:51819] k0kubun:r64033 (trunk): mjit.c: prevent GC on MJIT worker

k0kubun	2018-07-24 23:36:10 +0900 (Tue, 24 Jul 2018)

  New Revision: 64033

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

  Log:
    mjit.c: prevent GC on MJIT worker
    
    mjit_compile.c: ditto.
    
    REALLOC_N, ALLOC_N and xmalloc trigger GC but it's not expected.
    Other allocation calls in mjit.c are executed on Ruby's main thread and
    thus fine.

  Modified files:
    trunk/mjit.c
    trunk/mjit_compile.c
Index: mjit_compile.c
===================================================================
--- mjit_compile.c	(revision 64032)
+++ mjit_compile.c	(revision 64033)
@@ -192,7 +192,7 @@ mjit_compile(FILE *f, const struct rb_is https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L192
     struct compile_status status;
     status.success = TRUE;
     status.local_stack_p = !body->catch_except_p;
-    status.stack_size_for_pos = ALLOC_N(int, body->iseq_size);
+    status.stack_size_for_pos = (int *)malloc(sizeof(int) * body->iseq_size);
     memset(status.stack_size_for_pos, NOT_COMPILED_STACK_SIZE, sizeof(int) * body->iseq_size);
 
     /* For performance, we verify stack size only on compilation time (mjit_compile.inc.erb) without --jit-debug */
@@ -232,6 +232,6 @@ mjit_compile(FILE *f, const struct rb_is https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L232
     compile_cancel_handler(f, body, &status);
     fprintf(f, "\n} /* end of %s */\n", funcname);
 
-    xfree(status.stack_size_for_pos);
+    free(status.stack_size_for_pos);
     return status.success;
 }
Index: mjit.c
===================================================================
--- mjit.c	(revision 64032)
+++ mjit.c	(revision 64033)
@@ -334,7 +334,7 @@ form_args(int num, ...) https://github.com/ruby/ruby/blob/trunk/mjit.c#L334
     for (i = len = 0; i < num; i++) {
         args = va_arg(argp, char **);
         n = args_len(args);
-        REALLOC_N(res, char *, len + n + 1);
+        res = (char **)realloc(res, sizeof(char *) * (len + n + 1));
         MEMCPY(res + len, args, char *, n + 1);
         len += n;
     }
@@ -717,7 +717,7 @@ make_pch(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L717
     }
 
     exit_code = exec_process(cc_path, args);
-    xfree(args);
+    free(args);
 #endif
 
     CRITICAL_SECTION_START(3, "in make_pch");
@@ -766,7 +766,7 @@ compile_c_to_so(const char *c_file, cons https://github.com/ruby/ruby/blob/trunk/mjit.c#L766
 
 #ifdef _MSC_VER
     solen = strlen(so_file);
-    files[0] = p = xmalloc(rb_strlen_lit("-Fe") + solen + 1);
+    files[0] = p = (char *)malloc(sizeof(char) * (rb_strlen_lit("-Fe") + solen + 1));
     p = append_lit(p, "-Fe");
     p = append_str2(p, so_file, solen);
     *p = '\0';
@@ -784,9 +784,9 @@ compile_c_to_so(const char *c_file, cons https://github.com/ruby/ruby/blob/trunk/mjit.c#L784
         return FALSE;
 
     exit_code = exec_process(cc_path, args);
-    xfree(args);
+    free(args);
 #ifdef _MSC_VER
-    xfree((char *)files[0]);
+    free((char *)files[0]);
 #endif
 
     if (exit_code != 0)

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

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