aboutsummaryrefslogtreecommitdiffstats
path: root/variable.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-10-21 22:54:39 +0900
committerKoichi Sasada <ko1@atdot.net>2020-10-21 23:52:11 +0900
commit631eaa85109e4d6fa31eaeed393858e1e63300a4 (patch)
tree124487894718fab7823c5552fe74108a4dc42ced /variable.c
parent762be87759385cd495246b13c8c8eff5c3db0a3c (diff)
downloadruby-631eaa85109e4d6fa31eaeed393858e1e63300a4.tar.gz
check main-ractor or not first
On non-multi-ractor-mode, the cost of rb_ractor_main_p() is low so check it first.
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/variable.c b/variable.c
index 4ed60b626d..795ee3fb0a 100644
--- a/variable.c
+++ b/variable.c
@@ -923,7 +923,8 @@ generic_ivtbl(VALUE obj, ID id, bool force_check_ractor)
ASSERT_vm_locking();
if ((force_check_ractor || rb_is_instance_id(id)) && // not internal ID
- UNLIKELY(rb_ractor_shareable_p(obj) && !rb_ractor_main_p())) {
+ UNLIKELY(!rb_ractor_main_p()) &&
+ UNLIKELY(rb_ractor_shareable_p(obj))) {
rb_raise(rb_eRuntimeError, "can not access instance variables of shareable objects from non-main Ractors");
}
return generic_iv_tbl_;
@@ -2952,7 +2953,7 @@ rb_const_set(VALUE klass, ID id, VALUE val)
QUOTE_ID(id));
}
- if (!rb_ractor_shareable_p(val) && !rb_ractor_main_p()) {
+ if (!rb_ractor_main_p() && !rb_ractor_shareable_p(val)) {
rb_raise(rb_eNameError, "can not set constants with non-shareable objects by non-main Ractors");
}