diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-29 06:30:03 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-29 06:30:03 +0000 |
commit | a1e95636acd2b507b3d5d7b770f271992622a571 (patch) | |
tree | cfe7aad8f88234842387beee4636720f5cada27a /string.c | |
parent | dacc19e409fba7a79b2a1c7e30f21c00191a9a7b (diff) |
string.c: move frozen_strings table to rb_vm_t
Cleanup in case MVM development proceeds.
* string.c: remove static frozen_strings
* string.c (Init_frozen_strings): new function
* string.c (rb_fstring): remove check for frozen strings,
use per-VM table
* string.c (rb_str_free): use per-VM table
* string.c (Init_String): use per-VM table
* vm_core.h (rb_vm_t): add frozen_strings table
* internal.h (Init_frozen_strings): new function prototype
* eval.c (ruby_setup): call Init_frozen_strings
[Feature #10182]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -17,6 +17,7 @@ #include "internal.h" #include "probes.h" #include "gc.h" +#include "vm_core.h" #include <assert.h> #define BEG(no) (regs->beg[(no)]) @@ -176,8 +177,6 @@ mustnot_broken(VALUE str) static int fstring_cmp(VALUE a, VALUE b); -static st_table* frozen_strings; - static const struct st_hash_type fstring_hash_type = { fstring_cmp, rb_str_hash, @@ -223,15 +222,13 @@ rb_fstring(VALUE str) Check_Type(str, T_STRING); - if (!frozen_strings) - frozen_strings = st_init_table(&fstring_hash_type); - if (FL_TEST(str, RSTRING_FSTR)) return str; do { ret = str; - st_update(frozen_strings, (st_data_t)str, fstr_update_callback, (st_data_t)&ret); + st_update(GET_VM()->frozen_strings, (st_data_t)str, + fstr_update_callback, (st_data_t)&ret); } while (ret == Qundef); return ret; @@ -952,7 +949,7 @@ rb_str_free(VALUE str) { if (FL_TEST(str, RSTRING_FSTR)) { st_data_t fstr = (st_data_t)str; - st_delete(frozen_strings, &fstr, NULL); + st_delete(GET_VM()->frozen_strings, &fstr, NULL); } if (!STR_EMBED_P(str) && !FL_TEST(str, STR_SHARED)) { @@ -8950,6 +8947,13 @@ Init_String(void) rb_define_method(rb_cSymbol, "encoding", sym_encoding, 0); - if (frozen_strings) - st_foreach(frozen_strings, fstring_set_class_i, rb_cString); + assert(GET_VM()->frozen_strings); + st_foreach(GET_VM()->frozen_strings, fstring_set_class_i, rb_cString); +} + +void +Init_frozen_strings(void) +{ + assert(!GET_VM()->frozen_strings); + GET_VM()->frozen_strings = st_init_table(&fstring_hash_type); } |