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

refactor/fix: Use object offsets instead of field indexes for precise object scanning #3736

Merged
merged 3 commits into from Feb 8, 2024

Conversation

WojciechMazur
Copy link
Contributor

Immix and Commix scan objects precisely based on array of indexes containing possible references. Previously this list was populate by indexes of fields, now it's a list of offsets starting from object address (also known as start of object header) to make the code more readable.

It also can possibly some issues on 32-bit CPU architectures, see code comment below.
As an additional improvement used when debugging we're adding an utility to extract Class name as wide-string allowing to show it in debug information from the GC (best effort, no guarantess about String object layout)

Comment on lines -35 to -37
nir.Val.Long(
(offset - sizeOfHeader) / MemoryLayout.BYTES_IN_LONG
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way on calculating reference field indexes could have lead to runtime issues in 32-bit runtime. It would lead to having double indexes (eg. offset=16 & offset=20 would point to the same index) and might omit scanning some of misaligned fields.

@kubukoz
Copy link
Contributor

kubukoz commented Feb 8, 2024

we're adding an utility to extract Class name as wide-string allowing to show it in debug information from the GC

<3

Co-authored-by: Jakub Kozłowski <kubukoz@gmail.com>
@WojciechMazur WojciechMazur merged commit 29612a1 into scala-native:main Feb 8, 2024
31 of 32 checks passed
@WojciechMazur WojciechMazur deleted the fix/offsets branch February 8, 2024 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants