-
Notifications
You must be signed in to change notification settings - Fork 738
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
Read Barrier for CompareAndSwapObject #1573
Conversation
3a6313d
to
d516fb0
Compare
Jenkins test sanity |
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.
Looks good to me
protectIfVolatileBefore(vmThread, true, false, false); | ||
|
||
/* One of these conditions will evaluate to true at compile time based on whether fields are 32 or 64 bits */ | ||
if (sizeof(fj9object_t) == sizeof(UDATA)) { |
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.
Could this just become a compile time check with a #error in the else?
#if (sizeof(fj9object) == sizeof(UDATA))
....
Not sure if sizeof gets evaluated at the right time though.
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.
I did not change this (it only got indented), but if we are to change, I believe it the cleanest is to rely on
#if defined (OMR_GC_COMPRESSED_POINTERS)
and then there is no need for error clause at all
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.
... or J9VM_GC_COMPRESSED_POINTERS?
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.
Replaced the check with J9VM_GC_COMPRESSED_POINTERS (and swapped the order of two lines)
Compare-And-Swap on object reference (like one used in sun/misc/Unsafe but also any other used internally by JVM), while primarily is a store operation, it is also an implicit read (it reads the existing value to be compared with a provided compare value, before the store itself), hence needs a read barrier. This change introduces the pre-read barrier in all VM/GC CompareAndSwapObject helpers, that is used in Evacuating read barrier triggered by the read value, used in Concurrent Scavenger. An interesting dilemma is which out of two pre operations (read and store) is to be executed first. Currently in OpenJ9, we do not have any collector that have both of them active at the same time, so the order ATM is not important. However, in theory (and it actually may happen later in OpenJ9), they could both be active. An example, for Gencon GC policy, is the same read barrier on reference value (Concurrent Scavenger) and Snap-Shot-At-The-Beginning store barrier (for concurrent global marking). Since read barrier can modify the value, and SATB cares about the value being overwritten, read barrier should go first to bring it up to date, before SATB evaluates it. On the other side, from SATB perspective, we do not care about the very original value of the field (even before read barrier modifies it), since it is an object being evacuated/collected and is not part of the Snapshot (it is the copy of that object that we want to be preserved as part of the Snapshot). Signed-off-by: Aleksandar Micic <amicic@ca.ibm.com>
@dmitripivkine you can merge at your leisure. |
Compare-And-Swap on object reference, while primarily is a store operation, it is also an implicit read (it reads the existing value to be compared with a provided compare value, before the store itself), hence needs a read barrier. This change is an extension of eclipse-openj9#1573 with JIT support. Signed-off-by: Filip Jeremic <fjeremic@ca.ibm.com>
Compare-And-Swap on object reference (like one used in sun/misc/Unsafe
but also any other used internally by JVM), while primarily is a store
operation, it is also an implicit read (it reads the existing value to
be compared with a provided compare value, before the store itself),
hence needs a read barrier.
This change introduces the pre-read barrier in all VM/GC
CompareAndSwapObject helpers, that is used in Evacuating read barrier
triggered by the read value, used in Concurrent Scavenger.
An interesting dilemma is which out of two pre operations (read and
store) is to be executed first. Currently in OpenJ9, we do not have any
collector that have both of them active at the same time, so the order
ATM is not important.
However, in theory (and it actually may happen later in OpenJ9), they
could both be active. An example, for Gencon GC policy, is the same read
barrier on reference value (Concurrent Scavenger) and
Snap-Shot-At-The-Beginning store barrier (for concurrent global
marking). Since read barrier can modify the value, and SATB cares about
the value being overwritten, read barrier should go first to bring it up
to date, before SATB evaluates it. On the other side, from SATB
perspective, we do not care about the very original value of the field
(even before read barrier modifies it), since it is an object being
evacuated/collected and is not part of the Snapshot (it is the copy of
that object that we want to be preserved as part of the Snapshot).
Signed-off-by: Aleksandar Micic amicic@ca.ibm.com