aboutsummaryrefslogtreecommitdiffstats
path: root/bootstraptest
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-10-13 13:16:08 +0900
committerKoichi Sasada <ko1@atdot.net>2020-10-14 14:02:06 +0900
commit11c2f0f36ccc50899a8dd69a260e85451f68b5ba (patch)
tree4d968f2742fb0cb4d260c1f2c6b2695184e21d9e /bootstraptest
parentc3ba3fa8d01aa3970dc1f4e3dc0090ae171e9e35 (diff)
downloadruby-11c2f0f36ccc50899a8dd69a260e85451f68b5ba.tar.gz
sync enc_table and rb_encoding_list
enc_table which manages Encoding information. rb_encoding_list also manages Encoding objects. Both are accessed/modified by ractors simultaneously so that they should be synchronized. For enc_table, this patch introduced GLOBAL_ENC_TABLE_ENTER/LEAVE/EVAL to access this table with VM lock. To make shortcut, three new global variables global_enc_ascii, global_enc_utf_8, global_enc_us_ascii are also introduced. For rb_encoding_list, we split it to rb_default_encoding_list (256 entries) and rb_additional_encoding_list. rb_default_encoding_list is fixed sized Array so we don't need to synchronized (and most of apps only needs it). To manage 257 or more encoding objects, they are stored into rb_additional_encoding_list. To access rb_additional_encoding_list., VM lock is needed.
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_ractor.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index 9e90d95274..05139e2081 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -780,4 +780,18 @@ assert_equal "#{N}#{N}", %Q{
}.map{|r| r.take}.join
}
+assert_equal "#{N/10}", %Q{
+ Ractor.new do
+ loop do
+ Encoding.find("test-enc-#{rand(5_000)}").inspect
+ rescue ArgumentError => e
+ end
+ end
+
+ src = Encoding.find("UTF-8")
+ #{N/10}.times{|i|
+ src.replicate("test-enc-\#{i}")
+ }
+}
+
end # if !ENV['GITHUB_WORKFLOW']