-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[mono][wasm] Rework the handling of GC references in AOTed code. #59352
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
Conversation
Previously, variables holding GC refs were marked volatile so they were loaded/stored to the C stack on every access. Since the stack is conservatively scanned, all the objects pointed to by it are pinned, so there is no need to load them on every access. Instead of marking them as volatile, allocate a 'gc pinning' area on the stack, and store ref variables to it after they are assigned. This improves code size and performance.
lambdageek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach makes sense, but I wonder if LLVM's optimizer will outsmart us.
Also do we want to do this on non-wasm in the future? might avoid some spilling and copy_stack_data?
Fixed by dotnet#59352 . Fixes dotnet#59228 .
|
Can this be backported to rc2 too? |
|
/backport to release/6.0-rc2 |
|
Started backporting to release/6.0-rc2: https://github.com/dotnet/runtime/actions/runs/1256370822 |
Previously, variables holding GC refs were marked volatile so they
were loaded/stored to the C stack on every access. Since the stack
is conservatively scanned, all the objects pointed to by it are pinned,
so there is no need to load them on every access. Instead of
marking them as volatile, allocate a 'gc pinning' area on the stack,
and store ref variables to it after they are assigned. This improves
code size and performance.