mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
symbol.c: use rb_gc_mark_and_move
over rb_gc_location
The `p->field = rb_gc_location(p->field)` isn't ideal because it means all references are rewritten on compaction, regardless of whether the referenced object has moved. This isn't good for caches nor for Copy-on-Write. `rb_gc_mark_and_move` avoid needless writes, and most of the time allow to have a single function for both marking and updating references.
This commit is contained in:
parent
5bcfc53d6f
commit
1986d775cd
3 changed files with 6 additions and 16 deletions
15
symbol.c
15
symbol.c
|
@ -371,21 +371,12 @@ Init_sym(void)
|
|||
}
|
||||
|
||||
void
|
||||
rb_sym_global_symbols_mark(void)
|
||||
rb_sym_global_symbols_mark_and_move(void)
|
||||
{
|
||||
rb_symbols_t *symbols = &ruby_global_symbols;
|
||||
|
||||
rb_gc_mark_movable(symbols->sym_set);
|
||||
rb_gc_mark_movable(symbols->ids);
|
||||
}
|
||||
|
||||
void
|
||||
rb_sym_global_symbols_update_references(void)
|
||||
{
|
||||
rb_symbols_t *symbols = &ruby_global_symbols;
|
||||
|
||||
symbols->sym_set = rb_gc_location(symbols->sym_set);
|
||||
symbols->ids = rb_gc_location(symbols->ids);
|
||||
rb_gc_mark_and_move(&symbols->sym_set);
|
||||
rb_gc_mark_and_move(&symbols->ids);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue