Skip to content
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

Unhide compressed refs logic from Unsafe CAS codegen #20400

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

IBMJimmyk
Copy link
Contributor

Disables code on Power and Z that hides compressedrefs logic from the fast path code generation for the following recognized methods:
sun_misc_Unsafe_compareAndSwapObject_jlObjectJjlObjectjlObject_Z
jdk_internal_misc_Unsafe_compareAndExchangeObject
jdk_internal_misc_Unsafe_compareAndExchangeReference

Fast path code generation for those recognized methods is updated to handle compressedrefs.

Original behavior can be restored by setting the TR_UseOldCompareAndSwapObject environment variable. This behavior matches the X implementation which has already disabled the compressedrefs hiding logic when the envvar is not set.

Disables code on Power and Z that hides compressedrefs logic from the
fast path code generation for the following recognized methods:
sun_misc_Unsafe_compareAndSwapObject_jlObjectJjlObjectjlObject_Z
jdk_internal_misc_Unsafe_compareAndExchangeObject
jdk_internal_misc_Unsafe_compareAndExchangeReference

Fast path code generation for those recognized methods is updated to
handle compressedrefs.

Original behavior can be restored by setting the
TR_UseOldCompareAndSwapObject environment variable. This behavior
matches the X implementation which has already disabled the
compressedrefs hiding logic when the envvar is not set.

Signed-off-by: jimmyk <[email protected]>
@IBMJimmyk
Copy link
Contributor Author

@r30shah @zl-wang Could you take a look at these changes when you have a chance?

Copy link
Contributor

@r30shah r30shah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of nitpicks. Overall it looks good to me.

// Hiding compressedref logic from CodeGen doesn't seem a good practise, the evaluator always need the uncompressedref node for write barrier,
// therefore, this part is deprecated. It'll be removed once P and Z update their corresponding evaluators.
// Hiding compressedref logic from CodeGen isn't a good practice, and the evaluator still needs the uncompressedref node for write barriers.
// Therefore, this part is deprecated. It can only be activated on X, P or Z with the TR_UseOldCompareAndSwapObject envvar.
static bool UseOldCompareAndSwapObject = (bool)feGetEnv("TR_UseOldCompareAndSwapObject");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something that already in code, but not related to overall changes, Should we change UseOldCompareAndSwapObject to useOldCompareAndSwapObject ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change this.

runtime/compiler/codegen/J9CodeGenerator.cpp Show resolved Hide resolved
@@ -11952,7 +11952,7 @@ TR::Register*
J9::Z::TreeEvaluator::VMinlineCompareAndSwap(TR::Node *node, TR::CodeGenerator *cg, TR::InstOpCode::Mnemonic casOp, bool isObj, bool isExchange)
{
TR::Register *scratchReg = NULL;
TR::Register *objReg, *oldVReg, *newVReg;
TR::Register *objReg, *oldVReg, *newVReg, *decompressedValueRegister;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this exists, but we should initialize the registers here with NULL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change this.

@@ -11969,9 +11969,10 @@ J9::Z::TreeEvaluator::VMinlineCompareAndSwap(TR::Node *node, TR::CodeGenerator *
// compression sequence.
bool isValueCompressedReference = false;

TR::Node* decompressedValueNode = newVNode;
static bool UseOldCompareAndSwapObject = (bool)feGetEnv("TR_UseOldCompareAndSwapObject");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the intention was to match the environment set throughout the code base, but we should rename variable name useOldCompareAndSwapObject

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change this.

Added more comments to clarify issues.

Renamed UseOldCompareAndSwapObject to useOldCompareAndSwapObject.
@IBMJimmyk
Copy link
Contributor Author

My latest commit should address all previous comments.

Copy link
Contributor

@r30shah r30shah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Trivial change in x86 evaluator is fine as well. Sniffed at P code seems fine. Will wait for @zl-wang 's review.

Copy link
Contributor

@zl-wang zl-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@r30shah
Copy link
Contributor

r30shah commented Oct 25, 2024

jenkins test sanity all jdk21

@r30shah
Copy link
Contributor

r30shah commented Oct 25, 2024

Failure in https://openj9-jenkins.osuosl.org/job/Test_openjdk21_j9_sanity.openjdk_aarch64_linux_Personal/84/ is not related with the changes in this PR, they are related to #18463.

@r30shah
Copy link
Contributor

r30shah commented Oct 25, 2024

Given the one failure related to #18463, other tests on all other platform passes. Merging this one.

@r30shah r30shah merged commit c67b5f4 into eclipse-openj9:master Oct 25, 2024
25 of 27 checks passed
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.

3 participants