Skip to content

Commit

Permalink
Allow symbols used for scopes to move
Browse files Browse the repository at this point in the history
This commit allows symbols used for instance variables, global variables,
constants, class names to be moved by GC compaction.

For example:

    require "objspace"

    Object.const_set("Hello".to_sym, 1)
    sym = "Hello".to_sym

    puts ObjectSpace.dump(sym)
    GC.verify_compaction_references(expand_heap: true, toward: :empty)
    puts ObjectSpace.dump(sym)

Before:

    {"address":"0x101274ac8", "type":"SYMBOL", ... }
    {"address":"0x101274ac8", "type":"SYMBOL", ... }

After:

    {"address":"0x101544a78", "type":"SYMBOL", ... }
    {"address":"0x1015d7f80", "type":"SYMBOL", ... }
  • Loading branch information
peterzhu2118 committed Apr 16, 2024
1 parent d6debba commit 764d019
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions gc.c
Expand Up @@ -9519,10 +9519,6 @@ gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj)
case T_ZOMBIE:
return FALSE;
case T_SYMBOL:
if (RSYMBOL(obj)->id & ~ID_SCOPE_MASK) {
return FALSE;
}
/* fall through */
case T_STRING:
case T_OBJECT:
case T_FLOAT:
Expand Down

0 comments on commit 764d019

Please sign in to comment.