-
Notifications
You must be signed in to change notification settings - Fork 69
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
Require object reference to be aligned #1159
Conversation
The following is some discussion with Steve on this topic. ('in-object' address/mapping or 'in-allocation' address/mapping refers to the address returned by
There was a little bit more discussion about allocation alignment and payload.
|
Some high-level comments: Requiring
If If we do this, we can unify If we do this, we can further simplify operations on VO bits such that "VO bits are always set at the address of ObjectReference". That should greatly simplify things. One drawback I can think of is debugging. Previously, |
This is not introduced by this PR. We already stated this clearly in
This is also not introduced by this PR. We have agreed that we should use
The idea of object reference and in-object address is not introduced in this PR, though this PR does add more documentation to clarify it. Currently it is up to the binding. It is not as simple as what you propose, but it is still clear and works for different bindings.
|
Some detailed comments. Let's assume we do what you described in this PR (and forget about my aggressive suggestion of making raw address == in-allocation address). Alignment
Should we require
This means Using
|
For alignment, we can assume that most language use aligned object reference. So it is natural for us to require aligned object reference, rather than aligned in-object address. For the corner case that the internal pointer is before the in-object address, you are right. We would have to search forwards if that happens. We should let bindings to tell us, and possibly we can leave it as unimplemented for a while. |
I mean, I suggest adding a requirement that "both ObjectReference and in-object address needs to be word-aligned". (That implies their difference must be a multiple of word size, too.) I think all VMs can satisfy this, and this will simplify the VO bit searching algorithm. Concretely, in step 4, if VO bit is set at an (aligned) address, then |
Calling |
I am not talking about the complexity of calling I don't understand the part "The return value is an object reference, but may not be a valid one." If the in-object address |
The in-object address |
This will be a problem. If, in a VM, the in-object address is not aligned, and the offset between ObjectReference and in-object address is a constant, then the offset must not be a multiple of word size. This means if |
Requiring in-object address to be aligned can make things simpler. But we don't know concrete cases where this requirement can significantly simplify things. On the other hand, requiring aligned in-object address also imposes a risk that a binding may not be able to provide such an aligned in-object address. But, we also don't have concrete examples either. So at this point, I don't have think we have enough evidence to say we should or should not require aligned in-object address. |
We may want to replace |
@wks Can you review this PR again? I am working on the binding PRs. But you can review this PR first -- the binding PRs will be straightforward. |
binding-refs |
I have made changes based on the suggestions. |
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.
LGTM
The comments on the function I also mentioned the possibility of moving |
I updated the doc for |
This PR adds internal pointer support. It supersedes #1155 which provides a simple but inefficient implementation for internal pointers. This PR is based on #1159 which adds requirements for object reference alignment. This PR * adds `memory_manager::find_object_from_internal_pointer` * The call is dispatched using SFT to each space. * Large object space only checks the first word in VO bit for every page. * Mark sweep and immix space only searches for the max object size for those spaces. * Allow iterating side metadata bits. * Allow loading raw byte/word in side metadata.
This PR adds some assumptions about object reference, and the conversion between object reference and in-object address. To be specific, this PR requires the following:
With these requirements, we can do the following computation to find object reference for internal pointers:
ref_to_address
with the internal pointer to get the in-object address for the internal pointer.address_to_ref
with the data address above. The return value is an object reference, but may not be a valid one.Step 1 is necessary if the internal pointer is before the in-object address. If we concern about the invalid object reference in
ref_to_address
andaddress_to_ref
, we could consider removing the two functions, and use a constant offset instead.