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

ruby-changes:55095

From: k0kubun <ko1@a...>
Date: Tue, 19 Mar 2019 02:45:18 +0900 (JST)
Subject: [ruby-changes:55095] k0kubun:r67302 (trunk): Use designated initializers for compile_status

k0kubun	2019-03-19 02:45:10 +0900 (Tue, 19 Mar 2019)

  New Revision: 67302

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

  Log:
    Use designated initializers for compile_status
    
    to make it easier to understand what values are grouped.
    Just cosmetic changes.

  Modified files:
    trunk/mjit_compile.c
Index: mjit_compile.c
===================================================================
--- mjit_compile.c	(revision 67301)
+++ mjit_compile.c	(revision 67302)
@@ -203,24 +203,19 @@ bool https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L203
 mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname)
 {
     const struct rb_iseq_constant_body *body = iseq->body;
-
-    struct compile_status status;
-    status.success = true;
-    status.local_stack_p = !body->catch_except_p;
-    status.stack_size_for_pos = (int *)alloca(sizeof(int) * body->iseq_size);
+    struct compile_status status = {
+        .success = true,
+        .local_stack_p = !body->catch_except_p,
+        .stack_size_for_pos = (int *)alloca(sizeof(int) * body->iseq_size),
+        .cc_entries = (body->ci_size + body->ci_kw_size) > 0 ?
+            alloca(sizeof(struct rb_call_cache) * (body->ci_size + body->ci_kw_size)) : NULL,
+        .is_entries = (body->is_size > 0) ?
+            alloca(sizeof(union iseq_inline_storage_entry) * body->is_size) : NULL,
+    };
     memset(status.stack_size_for_pos, NOT_COMPILED_STACK_SIZE, sizeof(int) * body->iseq_size);
-
-    status.cc_entries = NULL;
-    if ((body->ci_size + body->ci_kw_size) > 0)
-        status.cc_entries = alloca(sizeof(struct rb_call_cache) * (body->ci_size + body->ci_kw_size));
-    status.is_entries = NULL;
-    if (body->is_size > 0)
-        status.is_entries = alloca(sizeof(union iseq_inline_storage_entry) * body->is_size);
-
     if ((status.cc_entries != NULL || status.is_entries != NULL)
-            && !mjit_copy_cache_from_main_thread(iseq, status.cc_entries, status.is_entries)) {
+            && !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) {

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

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