Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow symbols used for scopes to move #10550

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

peterzhu2118
Copy link
Member

@peterzhu2118 peterzhu2118 commented Apr 16, 2024

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", ... }

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", ... }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants