Make ruby_global_symbols movable
The `ids` array and `dsymbol_fstr_hash` were pinned because they were kept alive by rb_vm_register_global_object. This prevented the GC from moving them even though there were reference updating code. This commit changes it to be marked movable by marking it as a root object.
This commit is contained in:
parent
397bb7e42c
commit
8d0416ae0b
Notes:
git
2025-02-10 13:48:02 +00:00
3
gc.c
3
gc.c
@ -2650,6 +2650,9 @@ rb_gc_mark_roots(void *objspace, const char **categoryp)
|
|||||||
MARK_CHECKPOINT("machine_context");
|
MARK_CHECKPOINT("machine_context");
|
||||||
mark_current_machine_context(ec);
|
mark_current_machine_context(ec);
|
||||||
|
|
||||||
|
MARK_CHECKPOINT("global_symbols");
|
||||||
|
rb_sym_global_symbols_mark();
|
||||||
|
|
||||||
MARK_CHECKPOINT("finish");
|
MARK_CHECKPOINT("finish");
|
||||||
|
|
||||||
#undef MARK_CHECKPOINT
|
#undef MARK_CHECKPOINT
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* symbol.c */
|
/* symbol.c */
|
||||||
|
void rb_sym_global_symbols_mark(void);
|
||||||
VALUE rb_to_symbol_type(VALUE obj);
|
VALUE rb_to_symbol_type(VALUE obj);
|
||||||
VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc);
|
VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc);
|
||||||
VALUE rb_sym_intern_ascii(const char *ptr, long len);
|
VALUE rb_sym_intern_ascii(const char *ptr, long len);
|
||||||
|
11
symbol.c
11
symbol.c
@ -95,17 +95,24 @@ Init_sym(void)
|
|||||||
|
|
||||||
VALUE dsym_fstrs = rb_ident_hash_new();
|
VALUE dsym_fstrs = rb_ident_hash_new();
|
||||||
symbols->dsymbol_fstr_hash = dsym_fstrs;
|
symbols->dsymbol_fstr_hash = dsym_fstrs;
|
||||||
rb_vm_register_global_object(dsym_fstrs);
|
|
||||||
rb_obj_hide(dsym_fstrs);
|
rb_obj_hide(dsym_fstrs);
|
||||||
|
|
||||||
symbols->str_sym = st_init_table_with_size(&symhash, 1000);
|
symbols->str_sym = st_init_table_with_size(&symhash, 1000);
|
||||||
symbols->ids = rb_ary_hidden_new(0);
|
symbols->ids = rb_ary_hidden_new(0);
|
||||||
rb_vm_register_global_object(symbols->ids);
|
|
||||||
|
|
||||||
Init_op_tbl();
|
Init_op_tbl();
|
||||||
Init_id();
|
Init_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rb_sym_global_symbols_mark(void)
|
||||||
|
{
|
||||||
|
rb_symbols_t *symbols = &ruby_global_symbols;
|
||||||
|
|
||||||
|
rb_gc_mark_movable(symbols->ids);
|
||||||
|
rb_gc_mark_movable(symbols->dsymbol_fstr_hash);
|
||||||
|
}
|
||||||
|
|
||||||
WARN_UNUSED_RESULT(static VALUE dsymbol_alloc(rb_symbols_t *symbols, const VALUE klass, const VALUE str, rb_encoding *const enc, const ID type));
|
WARN_UNUSED_RESULT(static VALUE dsymbol_alloc(rb_symbols_t *symbols, const VALUE klass, const VALUE str, rb_encoding *const enc, const ID type));
|
||||||
WARN_UNUSED_RESULT(static VALUE dsymbol_check(rb_symbols_t *symbols, const VALUE sym));
|
WARN_UNUSED_RESULT(static VALUE dsymbol_check(rb_symbols_t *symbols, const VALUE sym));
|
||||||
WARN_UNUSED_RESULT(static ID lookup_str_id(VALUE str));
|
WARN_UNUSED_RESULT(static ID lookup_str_id(VALUE str));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user