Issue #10182 has been updated by Nobuyoshi Nakada.
Koichi Sasada wrote:
> I belive fstring codes in string.c.
OK.
~~~diff
diff --git i/eval.c w/eval.c
index f0a06fb..fbe17d0 100644
--- i/eval.c
+++ w/eval.c
@@ -52,7 +52,6 @@ ruby_setup(void)
Init_BareVM();
Init_heap();
Init_vm_objects();
- Init_frozen_strings();
PUSH_TAG();
if ((state = EXEC_TAG()) == 0) {
diff --git i/string.c w/string.c
index e7a971b..0b1540b 100644
--- i/string.c
+++ w/string.c
@@ -176,16 +176,9 @@ mustnot_broken(VALUE str)
static int fstring_cmp(VALUE a, VALUE b);
-/* in case we restart MVM development, this needs to be per-VM */
-static st_table* frozen_strings;
+st_table *rb_vm_fstring_table(void);
-static inline st_table*
-rb_vm_fstring_table(void)
-{
- return frozen_strings;
-}
-
-static const struct st_hash_type fstring_hash_type = {
+const struct st_hash_type rb_fstring_hash_type = {
fstring_cmp,
rb_str_hash,
};
@@ -8955,13 +8948,5 @@ Init_String(void)
rb_define_method(rb_cSymbol, "encoding", sym_encoding, 0);
- assert(rb_vm_fstring_table());
st_foreach(rb_vm_fstring_table(), fstring_set_class_i, rb_cString);
}
-
-void
-Init_frozen_strings(void)
-{
- assert(!frozen_strings);
- frozen_strings = st_init_table(&fstring_hash_type);
-}
diff --git i/vm.c w/vm.c
index cd80729..0251c9e 100644
--- i/vm.c
+++ w/vm.c
@@ -2787,6 +2787,14 @@ Init_BareVM(void)
ruby_thread_init_stack(th);
}
+st_table *
+rb_vm_fstring_table(void)
+{
+ return GET_VM()->frozen_strings;
+}
+
+extern const struct st_hash_type rb_fstring_hash_type;
+
void
Init_vm_objects(void)
{
@@ -2796,6 +2804,8 @@ Init_vm_objects(void)
/* initialize mark object array, hash */
vm->mark_object_ary = rb_ary_tmp_new(128);
+
+ vm->frozen_strings = st_init_table(&rb_fstring_hash_type);
}
/* top self */
~~~
----------------------------------------
Feature #10182: [PATCH] string.c: move frozen_strings table to rb_vm_t
https://bugs.ruby-lang.org/issues/10182#change-48553
* Author: Eric Wong
* Status: Closed
* Priority: Low
* Assignee: Eric Wong
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Cleanup in case MVM development proceeds.
---Files--------------------------------
mvm-fstring.patch (3.34 KB)
mvm-fstring.patch (5.77 KB)
--
https://bugs.ruby-lang.org/