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

ruby-changes:51522

From: k0kubun <ko1@a...>
Date: Sat, 23 Jun 2018 22:41:13 +0900 (JST)
Subject: [ruby-changes:51522] k0kubun:r63732 (trunk): mjit.c: unify the variable name with method name

k0kubun	2018-06-23 22:41:06 +0900 (Sat, 23 Jun 2018)

  New Revision: 63732

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

  Log:
    mjit.c: unify the variable name with method name
    
    `RubyVM::MJIT.enabled?`.
    
    It's set to be TRUE even before initialization is finished.
    So it was actually not "mjit initialized predicate".
    
    This flag is also used to check whether JIT-ed code should be called
    or not, but I'm going to split the responsibility to another flag.

  Modified files:
    trunk/cont.c
    trunk/mjit.c
    trunk/mjit.h
    trunk/vm.c
Index: cont.c
===================================================================
--- cont.c	(revision 63731)
+++ cont.c	(revision 63732)
@@ -378,7 +378,7 @@ cont_free(void *ptr) https://github.com/ruby/ruby/blob/trunk/cont.c#L378
 #endif
     RUBY_FREE_UNLESS_NULL(cont->saved_vm_stack.ptr);
 
-    if (mjit_init_p && cont->mjit_cont != NULL) {
+    if (mjit_enabled && cont->mjit_cont != NULL) {
         mjit_cont_free(cont->mjit_cont);
     }
     /* free rb_cont_t or rb_fiber_t */
@@ -565,7 +565,7 @@ cont_init(rb_context_t *cont, rb_thread_ https://github.com/ruby/ruby/blob/trunk/cont.c#L565
     cont->saved_ec.local_storage = NULL;
     cont->saved_ec.local_storage_recursive_hash = Qnil;
     cont->saved_ec.local_storage_recursive_hash_for_trace = Qnil;
-    if (mjit_init_p) {
+    if (mjit_enabled) {
         cont->mjit_cont = mjit_cont_new(&cont->saved_ec);
     }
 }
Index: vm.c
===================================================================
--- vm.c	(revision 63731)
+++ vm.c	(revision 63732)
@@ -2777,7 +2777,7 @@ core_hash_merge_kwd(int argc, VALUE *arg https://github.com/ruby/ruby/blob/trunk/vm.c#L2777
 static VALUE
 mjit_enabled_p(void)
 {
-    return mjit_init_p ? Qtrue : Qfalse;
+    return mjit_enabled ? Qtrue : Qfalse;
 }
 
 extern VALUE mjit_pause(void);
Index: mjit.c
===================================================================
--- mjit.c	(revision 63731)
+++ mjit.c	(revision 63732)
@@ -169,8 +169,8 @@ struct rb_mjit_unit_list { https://github.com/ruby/ruby/blob/trunk/mjit.c#L169
     int length; /* the list length */
 };
 
-/* TRUE if MJIT is initialized and will be used.  */
-int mjit_init_p = FALSE;
+/* TRUE if MJIT is enabled.  */
+int mjit_enabled = FALSE;
 
 /* Priority queue of iseqs waiting for JIT compilation.
    This variable is a pointer to head unit of the queue. */
@@ -422,7 +422,7 @@ CRITICAL_SECTION_FINISH(int level, const https://github.com/ruby/ruby/blob/trunk/mjit.c#L422
 void
 mjit_gc_start_hook(void)
 {
-    if (!mjit_init_p)
+    if (!mjit_enabled)
         return;
     CRITICAL_SECTION_START(4, "mjit_gc_start_hook");
     while (in_jit) {
@@ -439,7 +439,7 @@ mjit_gc_start_hook(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L439
 void
 mjit_gc_finish_hook(void)
 {
-    if (!mjit_init_p)
+    if (!mjit_enabled)
         return;
     CRITICAL_SECTION_START(4, "mjit_gc_finish_hook");
     in_gc = FALSE;
@@ -453,7 +453,7 @@ mjit_gc_finish_hook(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L453
 void
 mjit_free_iseq(const rb_iseq_t *iseq)
 {
-    if (!mjit_init_p)
+    if (!mjit_enabled)
         return;
     CRITICAL_SECTION_START(4, "mjit_free_iseq");
     if (iseq->body->jit_unit) {
@@ -947,7 +947,7 @@ worker(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L947
         make_pch();
     }
     if (pch_status == PCH_FAILED) {
-        mjit_init_p = FALSE;
+        mjit_enabled = FALSE;
         CRITICAL_SECTION_START(3, "in worker to update worker_stopped");
         worker_stopped = TRUE;
         verbose(3, "Sending wakeup signal to client in a mjit-worker");
@@ -1162,7 +1162,7 @@ mjit_add_iseq_to_process(const rb_iseq_t https://github.com/ruby/ruby/blob/trunk/mjit.c#L1162
 {
     struct rb_mjit_unit_node *node;
 
-    if (!mjit_init_p || pch_status == PCH_FAILED)
+    if (!mjit_enabled || pch_status == PCH_FAILED)
         return;
 
     iseq->body->jit_func = (mjit_func_t)NOT_READY_JIT_ISEQ_FUNC;
@@ -1274,7 +1274,7 @@ static void https://github.com/ruby/ruby/blob/trunk/mjit.c#L1274
 child_after_fork(void)
 {
     verbose(3, "Switching off MJIT in a forked child");
-    mjit_init_p = FALSE;
+    mjit_enabled = FALSE;
     /* TODO: Should we initiate MJIT in the forked Ruby.  */
 }
 
@@ -1388,7 +1388,7 @@ start_worker(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1388
     worker_stopped = FALSE;
 
     if (!rb_thread_create_mjit_thread(child_after_fork, worker)) {
-        mjit_init_p = FALSE;
+        mjit_enabled = FALSE;
         rb_native_mutex_destroy(&mjit_engine_mutex);
         rb_native_cond_destroy(&mjit_pch_wakeup);
         rb_native_cond_destroy(&mjit_client_wakeup);
@@ -1409,7 +1409,7 @@ mjit_init(struct mjit_options *opts) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1409
     VALUE rb_description;
 
     mjit_opts = *opts;
-    mjit_init_p = TRUE;
+    mjit_enabled = TRUE;
 
     /* Normalize options */
     if (mjit_opts.min_calls == 0)
@@ -1431,7 +1431,7 @@ mjit_init(struct mjit_options *opts) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1431
     init_header_filename();
     pch_file = get_uniq_filename(0, MJIT_TMP_PREFIX "h", ".h.gch");
     if (header_file == NULL || pch_file == NULL) {
-        mjit_init_p = FALSE;
+        mjit_enabled = FALSE;
         verbose(1, "Failure in MJIT header file name initialization\n");
         return;
     }
@@ -1481,7 +1481,7 @@ stop_worker(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1481
 VALUE
 mjit_pause(void)
 {
-    if (!mjit_init_p) {
+    if (!mjit_enabled) {
         rb_raise(rb_eRuntimeError, "MJIT is not enabled");
     }
     if (worker_stopped) {
@@ -1496,7 +1496,7 @@ mjit_pause(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1496
 VALUE
 mjit_resume(void)
 {
-    if (!mjit_init_p) {
+    if (!mjit_enabled) {
         rb_raise(rb_eRuntimeError, "MJIT is not enabled");
     }
     if (!worker_stopped) {
@@ -1515,7 +1515,7 @@ mjit_resume(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1515
 void
 mjit_finish(void)
 {
-    if (!mjit_init_p)
+    if (!mjit_enabled)
         return;
 
     /* Wait for pch finish */
@@ -1553,7 +1553,7 @@ mjit_finish(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1553
     free_list(&active_units);
     finish_conts();
 
-    mjit_init_p = FALSE;
+    mjit_enabled = FALSE;
     verbose(1, "Successful MJIT finish");
 }
 
@@ -1561,7 +1561,7 @@ void https://github.com/ruby/ruby/blob/trunk/mjit.c#L1561
 mjit_mark(void)
 {
     struct rb_mjit_unit_node *node;
-    if (!mjit_init_p)
+    if (!mjit_enabled)
         return;
     RUBY_MARK_ENTER("mjit");
     CRITICAL_SECTION_START(4, "mjit_mark");
@@ -1585,7 +1585,7 @@ mjit_mark(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1585
 void
 mjit_add_class_serial(rb_serial_t class_serial)
 {
-    if (!mjit_init_p)
+    if (!mjit_enabled)
         return;
 
     /* Do not wrap CRITICAL_SECTION here. This function is only called in main thread
@@ -1597,7 +1597,7 @@ mjit_add_class_serial(rb_serial_t class_ https://github.com/ruby/ruby/blob/trunk/mjit.c#L1597
 void
 mjit_remove_class_serial(rb_serial_t class_serial)
 {
-    if (!mjit_init_p)
+    if (!mjit_enabled)
         return;
 
     CRITICAL_SECTION_START(3, "in mjit_remove_class_serial");
Index: mjit.h
===================================================================
--- mjit.h	(revision 63731)
+++ mjit.h	(revision 63732)
@@ -53,7 +53,7 @@ typedef VALUE (*mjit_func_t)(rb_executio https://github.com/ruby/ruby/blob/trunk/mjit.h#L53
 
 RUBY_SYMBOL_EXPORT_BEGIN
 extern struct mjit_options mjit_opts;
-extern int mjit_init_p;
+extern int mjit_enabled;
 
 extern void mjit_add_iseq_to_process(const rb_iseq_t *iseq);
 extern mjit_func_t mjit_get_iseq_func(struct rb_iseq_constant_body *body);
@@ -94,7 +94,7 @@ mjit_exec(rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/mjit.h#L94
     long unsigned total_calls;
     mjit_func_t func;
 
-    if (!mjit_init_p)
+    if (!mjit_enabled)
         return Qundef;
 
     iseq = ec->cfp->iseq;

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

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