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

ruby-changes:66386

From: Takashi <ko1@a...>
Date: Tue, 1 Jun 2021 16:16:05 +0900 (JST)
Subject: [ruby-changes:66386] e1b03b0c2b (master): Enable VM_ASSERT in --jit CIs (#4543)

https://git.ruby-lang.org/ruby.git/commit/?id=e1b03b0c2b

From e1b03b0c2b2449a7794f4701bab8b2382eb15116 Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Tue, 1 Jun 2021 00:15:51 -0700
Subject: Enable VM_ASSERT in --jit CIs (#4543)

---
 .github/workflows/mjit.yml | 2 +-
 ractor.c                   | 6 +++---
 vm_core.h                  | 6 +++---
 vm_method.c                | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/mjit.yml b/.github/workflows/mjit.yml
index c2a6ed2..d5cc9e9 100644
--- a/.github/workflows/mjit.yml
+++ b/.github/workflows/mjit.yml
@@ -38,7 +38,7 @@ jobs: https://github.com/ruby/ruby/blob/trunk/.github/workflows/mjit.yml#L38
       - run: ./autogen.sh
         working-directory: src
       - name: Run configure
-        run: ../src/configure -C --disable-install-doc
+        run: ../src/configure -C --disable-install-doc cppflags=-DVM_CHECK_MODE
       - run: make $JOBS incs
       - run: make $JOBS
       - run: sudo make $JOBS -s install
diff --git a/ractor.c b/ractor.c
index 34cec08..372305c 100644
--- a/ractor.c
+++ b/ractor.c
@@ -34,7 +34,7 @@ ASSERT_ractor_unlocking(rb_ractor_t *r) https://github.com/ruby/ruby/blob/trunk/ractor.c#L34
 {
 #if RACTOR_CHECK_MODE > 0
     // GET_EC is NULL in an MJIT worker
-    if (GET_EC() != NULL && r->sync.locked_by == rb_ractor_self(GET_RACTOR())) {
+    if (rb_current_execution_context(false) != NULL && r->sync.locked_by == rb_ractor_self(GET_RACTOR())) {
         rb_bug("recursive ractor locking");
     }
 #endif
@@ -45,7 +45,7 @@ ASSERT_ractor_locking(rb_ractor_t *r) https://github.com/ruby/ruby/blob/trunk/ractor.c#L45
 {
 #if RACTOR_CHECK_MODE > 0
     // GET_EC is NULL in an MJIT worker
-    if (GET_EC() != NULL && r->sync.locked_by != rb_ractor_self(GET_RACTOR())) {
+    if (rb_current_execution_context(false) != NULL && r->sync.locked_by != rb_ractor_self(GET_RACTOR())) {
         rp(r->sync.locked_by);
         rb_bug("ractor lock is not acquired.");
     }
@@ -61,7 +61,7 @@ ractor_lock(rb_ractor_t *r, const char *file, int line) https://github.com/ruby/ruby/blob/trunk/ractor.c#L61
     rb_native_mutex_lock(&r->sync.lock);
 
 #if RACTOR_CHECK_MODE > 0
-    if (GET_EC() != NULL) { // GET_EC is NULL in an MJIT worker
+    if (rb_current_execution_context(false) != NULL) { // GET_EC is NULL in an MJIT worker
         r->sync.locked_by = rb_ractor_self(GET_RACTOR());
     }
 #endif
diff --git a/vm_core.h b/vm_core.h
index 72e2bcb..52baa40 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -1777,7 +1777,7 @@ RUBY_SYMBOL_EXPORT_END https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1777
 #define GET_VM()     rb_current_vm()
 #define GET_RACTOR() rb_current_ractor()
 #define GET_THREAD() rb_current_thread()
-#define GET_EC()     rb_current_execution_context()
+#define GET_EC()     rb_current_execution_context(true)
 
 static inline rb_thread_t *
 rb_ec_thread_ptr(const rb_execution_context_t *ec)
@@ -1811,7 +1811,7 @@ rb_ec_vm_ptr(const rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1811
 }
 
 static inline rb_execution_context_t *
-rb_current_execution_context(void)
+rb_current_execution_context(bool expect_ec)
 {
 #ifdef RB_THREAD_LOCAL_SPECIFIER
   #ifdef __APPLE__
@@ -1822,7 +1822,7 @@ rb_current_execution_context(void) https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1822
 #else
     rb_execution_context_t *ec = native_tls_get(ruby_current_ec_key);
 #endif
-    VM_ASSERT(ec != NULL);
+    VM_ASSERT(!expect_ec || ec != NULL);
     return ec;
 }
 
diff --git a/vm_method.c b/vm_method.c
index 740279c..ea7d2d4 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1490,7 +1490,7 @@ static void https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1490
 scope_visibility_check(void)
 {
     /* Check for public/protected/private/module_function called inside a method */
-    rb_control_frame_t *cfp = rb_current_execution_context()->cfp+1;
+    rb_control_frame_t *cfp = GET_EC()->cfp+1;
     if (cfp && cfp->iseq && cfp->iseq->body->type == ISEQ_TYPE_METHOD) {
         rb_warn("calling %s without arguments inside a method may not have the intended effect",
             rb_id2name(rb_frame_this_func()));
-- 
cgit v1.1


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

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