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 1984f9a commit 400c2a0
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions gc.c
Expand Up @@ -9473,10 +9473,6 @@ gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj)
case T_ZOMBIE:
return FALSE;
case T_SYMBOL:
if (DYNAMIC_SYM_P(obj) && (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 400c2a0

Please sign in to comment.