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

ruby-changes:64386

From: Koichi <ko1@a...>
Date: Mon, 21 Dec 2020 01:15:41 +0900 (JST)
Subject: [ruby-changes:64386] 730f314171 (master): fix Ractor.make_shareable() with Class/Module

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

From 730f314171e67d981887c061d5dabf927ff5efd5 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Mon, 21 Dec 2020 01:13:39 +0900
Subject: fix Ractor.make_shareable() with Class/Module

To check shareable-ness, rb_ractor_shareable_p() is needed
for Class/Module objects isntead of checking flags.

diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index c587c2c..797ad0a 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -1149,6 +1149,14 @@ assert_equal '[:ok, false, false]', %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_ractor.rb#L1149
   [(Ractor.make_shareable(x) rescue :ok), Ractor.shareable?(x), Ractor.shareable?(y)]
 }
 
+# Ractor.make_shareable with Class/Module
+assert_equal '[C, M]', %q{
+  class C; end
+  module M; end
+
+  Ractor.make_shareable(ary = [C, M])
+}
+
 # define_method() can invoke different Ractor's proc if the proc is shareable.
 assert_equal '1', %q{
   class C
@@ -1191,7 +1199,6 @@ assert_equal '[false, false, true, true]', %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_ractor.rb#L1199
   r
 }
 
-
 # Ractor deep copies frozen objects (ary)
 assert_equal '[true, false]', %q{
   Ractor.new([[]].freeze) { |ary|
diff --git a/ractor.c b/ractor.c
index 180795b..d2d4ee2 100644
--- a/ractor.c
+++ b/ractor.c
@@ -2396,7 +2396,7 @@ make_shareable_check_shareable(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ractor.c#L2396
     VM_ASSERT(!SPECIAL_CONST_P(obj));
     bool made_shareable = false;
 
-    if (RB_OBJ_SHAREABLE_P(obj)) {
+    if (rb_ractor_shareable_p(obj)) {
         return traverse_skip;
     }
     else if (!frozen_shareable_p(obj, &made_shareable)) {
-- 
cgit v0.10.2


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

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