diff options
author | John Hawthorn <[email protected]> | 2025-03-10 23:49:59 -0700 |
---|---|---|
committer | John Hawthorn <[email protected]> | 2025-04-18 13:03:54 +0900 |
commit | 89199a47db25a89cbce05f1be6685e96ded32db5 (patch) | |
tree | 0cb26b1ada0963e3f8ddd5148bc94812523b195d | |
parent | 6f6d07272e76682029112c4ceb6eb6b811ee8d6f (diff) |
Extract rb_gc_free_fstring to string.c
This allows more flexibility in how we deal with the fstring table
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12921
-rw-r--r-- | gc.c | 6 | ||||
-rw-r--r-- | internal/string.h | 1 | ||||
-rw-r--r-- | string.c | 10 |
3 files changed, 12 insertions, 5 deletions
@@ -1216,11 +1216,7 @@ rb_gc_obj_free_vm_weak_references(VALUE obj) switch (BUILTIN_TYPE(obj)) { case T_STRING: if (FL_TEST(obj, RSTRING_FSTR)) { - st_data_t fstr = (st_data_t)obj; - st_delete(rb_vm_fstring_table(), &fstr, NULL); - RB_DEBUG_COUNTER_INC(obj_str_fstr); - - FL_UNSET(obj, RSTRING_FSTR); + rb_gc_free_fstring(obj); } break; case T_SYMBOL: diff --git a/internal/string.h b/internal/string.h index 0ff92c3b84..ce4623cb52 100644 --- a/internal/string.h +++ b/internal/string.h @@ -83,6 +83,7 @@ VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb RUBY_SYMBOL_EXPORT_END VALUE rb_fstring_new(const char *ptr, long len); +void rb_gc_free_fstring(VALUE obj); VALUE rb_obj_as_string_result(VALUE str, VALUE obj); VALUE rb_str_opt_plus(VALUE x, VALUE y); VALUE rb_str_concat_literals(size_t num, const VALUE *strary); @@ -578,6 +578,16 @@ register_fstring(VALUE str, bool copy, bool force_precompute_hash) return args.fstr; } +void rb_gc_free_fstring(VALUE obj) { + ASSERT_vm_locking(); + + st_data_t fstr = (st_data_t)obj; + st_delete(rb_vm_fstring_table(), &fstr, NULL); + RB_DEBUG_COUNTER_INC(obj_str_fstr); + + FL_UNSET(obj, RSTRING_FSTR); +} + static VALUE setup_fake_str(struct RString *fake_str, const char *name, long len, int encidx) { |