Skip to content

Record hidden ptr in layout #92

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

Merged

Conversation

qinsoon
Copy link
Member

@qinsoon qinsoon commented Jul 28, 2025

This PR records the hidden pointer offsets in jl_datatype_layout_t. Hidden pointers are fields like ptr_or_offset in jl_genericmemoryref_t, which is not recorded as a pointer but actually may be heap (internal) pointers.

There might be other types of hidden pointers. Currently we assume the recorded hidden pointers are all like ptr_or_offset -- a union of an internal pointer, or an integer.

The current implementation adds hiddenptrfields to jl_typename_t, and specifically define hiddenptrfields for jl_genericmemoryref_t. This is not an ideal solution. I think a better solution would be to introduce a new type that represents a hidden pointer, and use the type for fields like ptr_or_offset. However, I am not familiar with Julia's type system, and didn't get it to work. The current approach using hiddenptrfields is a workaround.

@qinsoon
Copy link
Member Author

qinsoon commented Jul 29, 2025

@d-netto Can you review the PR?

This PR just shows one way about how we can get the offsets of those 'hidden pointers', and it shows it is necessary for Julia to provide offsets of those pointers to GC impls. The actual implementation would be need to be discussed with Julia devs. The current implementation is not meant to be upstreamed.

@d-netto d-netto self-requested a review July 30, 2025 13:51
@udesou udesou self-requested a review August 5, 2025 09:58
@udesou udesou merged commit 0043065 into mmtk:mmtk-support-moving-upstream Aug 5, 2025
3 checks passed
udesou pushed a commit to udesou/julia that referenced this pull request Aug 6, 2025
* Add fields about hidden pointers in jl_datatype_layout_t

* Record hidden pointer in layout

* Move the new field to the end of the struct
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.

2 participants