summaryrefslogtreecommitdiff
path: root/ractor.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-09-04 05:51:55 +0900
committerKoichi Sasada <ko1@atdot.net>2020-09-04 14:18:48 +0900
commit3b0bcaf2872e5ab6d2475e9cd6dd5c374d93ae0b (patch)
treebec58277c5c1efe374236f8438661ad633740d13 /ractor.c
parent169b1d1aca0c26d38f8bbd25ecaf5fdb8015f5cf (diff)
check multi_ractor mode at main_p
rb_ractor_main_p() need to access to the ractor pointer in TLS. However it is slow operation so that we need to skip this check if it is not multi-ractor mode (!ruby_multi_ractor). This performance regression is pointed at https://bugs.ruby-lang.org/issues/17100#note-27
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3513
Diffstat (limited to 'ractor.c')
-rw-r--r--ractor.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/ractor.c b/ractor.c
index a0cd092433..9a8146e3d8 100644
--- a/ractor.c
+++ b/ractor.c
@@ -15,9 +15,12 @@ static VALUE rb_eRactorMovedError;
static VALUE rb_eRactorClosedError;
static VALUE rb_cRactorMovedObject;
+RUBY_SYMBOL_EXPORT_BEGIN
+// to share with MJIT
bool ruby_multi_ractor;
-static void vm_ractor_blocking_cnt_inc(rb_vm_t *vm, rb_ractor_t *r, const char *file, int line);
+RUBY_SYMBOL_EXPORT_END
+static void vm_ractor_blocking_cnt_inc(rb_vm_t *vm, rb_ractor_t *r, const char *file, int line);
static void
ASSERT_ractor_unlocking(rb_ractor_t *r)
@@ -1423,9 +1426,10 @@ rb_ractor_self(const rb_ractor_t *r)
return r->self;
}
-MJIT_FUNC_EXPORTED int
-rb_ractor_main_p(void)
+MJIT_FUNC_EXPORTED bool
+rb_ractor_main_p_(void)
{
+ VM_ASSERT(rb_multi_ractor_p());
rb_execution_context_t *ec = GET_EC();
return rb_ec_ractor_ptr(ec) == rb_ec_vm_ptr(ec)->ractor.main_ractor;
}