Feature/four state forwarding bits #977
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DRAFT: This PR depends on cyclic marking state if forwarding bits are in the header.
Currently the forwarding bits is a 2-bits-per-object metadata, but it only has three states, namely "not triggered", "being forwarded" and "forwarded". Marking is supported by a separate marking bit. This PR uses the fourth state of the forwarding bits to represent the state that "the object is marked and should not move". With this change, Immix (and other GCs that do not evacuate all objects in a GC) will no longer need to "set the state to 'being forwarded' and then revert it if the object is marked". Instead, one CMPXCHG will be enough to atomically initiate forwarding as well as atomically mark an object, and fail if another thread is trying to mark or forward the same object.