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

Correctly identify use of compressed references for CAS write barrier #2335

Merged
merged 1 commit into from
Jul 6, 2018

Conversation

fjeremic
Copy link
Contributor

@fjeremic fjeremic commented Jul 5, 2018

The usingCompressedReferences variable is misleading as it does not
imply compressed references are actually used. What this variable
actually means is that the value we are storing into the object via
compare and swap is a compressed reference.

Recognized CAS sequences are reduced at lower trees phase [1] where the
last two arguments being the expected value and the new value are
lowered into compressed objects since under compressed references
objects on heap are always compressed.

For concurrent scavenge we need a read barrier on the expected value
hence the read barrier under compressed references need not rely on the
use of the usingCompressedReferences variable which means something
totally different.

We take this opportunity to first fix the bug and to improve the
meaning of some of the variables in the modified function so it is not
confusing for future readers.

[1] https://github.com/eclipse/openj9/blob/8a36fcd5f23005bf5028d28b60fd61aa325940a1/runtime/compiler/codegen/J9CodeGenerator.cpp#L675-L683

Signed-off-by: Filip Jeremic [email protected]

The `usingCompressedReferences` variable is misleading as it does not
imply compressed references are actually used. What this variable
actually means is that the value we are storing into the object via
compare and swap is a compressed reference.

Recognized CAS sequences are reduced at lower trees phase [1] where the
last two arguments being the expected value and the new value are
lowered into compressed objects since under compressed references
objects on heap are always compressed.

For concurrent scavenge we need a read barrier on the expected value
hence the read barrier under compressed references need not rely on the
use of the `usingCompressedReferences` variable which means something
totally different.

We take this opportunity to first fix the bug and to improve the
meaning of some of the variables in the modified function so it is not
confusing for future readers.

[1] https://github.com/eclipse/openj9/blob/8a36fcd5f23005bf5028d28b60fd61aa325940a1/runtime/compiler/codegen/J9CodeGenerator.cpp#L675-L683

Signed-off-by: Filip Jeremic <[email protected]>
@fjeremic
Copy link
Contributor Author

fjeremic commented Jul 5, 2018

@dsouzai @amicic could I please get a review and @amicic could you please be the committer for this PR?

@fjeremic
Copy link
Contributor Author

fjeremic commented Jul 5, 2018

Jenkins test sanity zlinux

@dsouzai
Copy link
Contributor

dsouzai commented Jul 5, 2018

@joransiu I'm going to have to defer to your expertise for this review.

Copy link
Contributor

@dsouzai dsouzai left a comment

Choose a reason for hiding this comment

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

With the disclaimer that I'm not the content expert, the change looks good, and the reasoning makes sense. The updated comments and variable names makes this much more understandable.

@fjeremic
Copy link
Contributor Author

fjeremic commented Jul 5, 2018

@joransiu I'm going to have to defer to your expertise for this review.

I believe @joransiu is away until the end of July so a review may be pending for a while. Given the scope of this bug causing issues when concurrent scavenge is enabled I would like to see it fixed sooner rahter than later. I propose one of two things:

  1. Merge the change as is pending review and approval from @amicic
  2. Revert the original read barrier CAS change, merge it, then wait for a review from @joransiu for this change before we merge it

I'm ok with either as it will alleviate the problem immediately. Please advise.

@dsouzai
Copy link
Contributor

dsouzai commented Jul 5, 2018

I'm ok merging the change as is, as the PR does make sense to me. However, I think it would be worth getting someone from the z codegen team to also take a look at this, maybe @r30shah .

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.

Looks more cleaner to me. I agree with @fjeremic , usingCompressedPointers was a confusing name to use to check if value we are storing is compressed reference. Which I assume was leading to the bug where we decide wrong instruction for guarded load.

@fjeremic
Copy link
Contributor Author

fjeremic commented Jul 5, 2018

JDK10 failure is due to #2329. That build has now been suspended. Awaiting review + merge from @amicic.

@charliegracie
Copy link
Contributor

@fjeremic @amicic is on vacation for until the end of the month. I can review this for you if you like?

Looking at the change I like the refactoring (for names, etc.). The actual fix is:

auto guardedLoadMnemonic = comp->useCompressedPointers() ? TR::InstOpCode::LLGFSG : TR::InstOpCode::LGG;

which checks to see if compressed references is running and not whether or not this value is compressed correct?

@fjeremic
Copy link
Contributor Author

fjeremic commented Jul 6, 2018

@fjeremic @amicic is on vacation for until the end of the month. I can review this for you if you like?

Looking at the change I like the refactoring (for names, etc.). The actual fix is:

auto guardedLoadMnemonic = comp->useCompressedPointers() ? TR::InstOpCode::LLGFSG : TR::InstOpCode::LGG;

which checks to see if compressed references is running and not whether or not this value is compressed correct?

Thanks @charliegracie. Yes this is indeed the fix. Perhaps I should have broken it into two commits to be more clear. Apologies for that. I have manually tested the fix against the broken workload and it does fix the problem. I've also ran additional testing to the above Jenkins builds and there is no problem.

@charliegracie
Copy link
Contributor

@fjeremic no problem it was easy enough to figure out. Just wanted to make sure I was not missing something :). Merging as the only failure is a known issue.

@charliegracie charliegracie merged commit 31fe688 into eclipse-openj9:master Jul 6, 2018
@fjeremic fjeremic deleted the fix-cas-cs branch July 6, 2018 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants