-
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
Forwarding pointer is not an object metadata #1030
Comments
I feel like this might be a good idea for runtimes that need compressed pointers. The only thing stopping me from compressing object header right now is forwarding pointers |
@playXE I don't think the forwarding pointer has anything to do with compressed pointers. The forwarding pointer is stored in a dead object. When an object is dead, its fields are irrelevant. So you don't need to worry about a 64-bit forwarding pointer not fitting into a 32-bit compressed pointer field. |
We have to be careful with terminology. More precisely, we write a forwarding pointer into dead memory after we have already copied the object. So we can destroy the old memory location. Also @playXE I'm not sure I understand why the forwarding pointer matters with compressed references. MMTk only ever sees uncompressed references (since it does |
I suspect the problem here is the relationship between:
The former is object metadata the latter is not. The former may be located according to the availability of header bits in a specific VM. The latter is normally located in the memory formerly held by the object, but in some GCs (eg ZGC) may be held elsewhere. The trouble is that we often want to deal with 1. and 2. in the same (atomic) operation. So this issue straddles both concerns. |
Forwarding pointers are associated to dead memory instead of live objects.
Currently, forwarding pointers are implemented as an object metadata, namely
const LOCAL_FORWARDING_POINTER_SPEC: VMLocalForwardingPointerSpec;
intrait ObjectModel
. Like other metadata, the forwarding pointer metadata can be defined as on the side. However,There is a prior issue about putting all metadata on the side: #362 Forwarding pointer may be an exception. If the forwarding bits are on the side, we can simply use the first word of a dead object to store the forwarding pointer because it doesn't overlap with the forwarding bits which is on the side.
Even if the forwarding bits metadata is defined as in the header, we can make use of object alignment, and the reset of the word occupied by the forwarding bits to save the forwarding pointer.
What should we change?
We need to replace the
const LOCAL_FORWARDING_POINTER_SPEC: VMLocalForwardingPointerSpec;
Offset
We can replace it with an offset:
The unit of this offset will be bits, and it will be relative to the address returned by
ref_to_header
, or whatever is easy to compute.Method to compute the address
Alternatively, we can let
ObjectModel
provide a methodref_to_forwarding_pointer
:One advantage of
ref_to_forwarding_pointer
is that it is always computed from the raw object reference. If bothref_to_header()
andref_to_address()
needs some non-trivial computation, conditional branches or memory loading, this may outperform them.Methods to access the forwarding pointer (and forwarding bits?)
Alternatively, we can let the VM binding implement methods for getting and setting the forwarding pointer of a given object, and provide a default implementation that loads/stores the first word relative to the raw address:
We can let the binding implement forwarding states, too. In that case, it will be similar to what the PR #975 tries to implement.
The text was updated successfully, but these errors were encountered: