From e1b03b0c2b2449a7794f4701bab8b2382eb15116 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Tue, 1 Jun 2021 00:15:51 -0700 Subject: [PATCH] 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 c2a6ed2188..d5cc9e93fd 100644 --- a/.github/workflows/mjit.yml +++ b/.github/workflows/mjit.yml @@ -38,7 +38,7 @@ jobs: - 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 34cec089b8..372305c256 100644 --- a/ractor.c +++ b/ractor.c @@ -34,7 +34,7 @@ ASSERT_ractor_unlocking(rb_ractor_t *r) { #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) { #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) 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 72e2bcb6fb..52baa401e2 100644 --- a/vm_core.h +++ b/vm_core.h @@ -1777,7 +1777,7 @@ RUBY_SYMBOL_EXPORT_END #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) } 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) #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 740279cdc9..ea7d2d4daf 100644 --- a/vm_method.c +++ b/vm_method.c @@ -1490,7 +1490,7 @@ static void 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()));