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
8255550: x86: Assembler::cmpq(Address dst, Register src) encoding is incorrect #910
Conversation
👋 Welcome back shade! A progress list of the required criteria for merging this PR into |
The fix looks good to me. cmpq(Address,Register) should be using 0x39 as the opcode. |
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.
Good.
@shipilev This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 2 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
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.
Thanks for poking me. I would prefer to change to the cmpq instruction that has the opposite order in the stack watermark barrier instead. Everywhere in the code I talk about the condition being sp being "above" watermark. Changing it to less makes me twist my head in ways that heads should not twist.
Ok, so let's do this: can you change the parameter order in |
What I meant was "in a separate PR", not to mess up with the change here. I think it amounts to:
I can do that, if you want, and if you trust |
Forked |
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.
Yep, looks all good to me.
/integrate |
@shipilev Since your change was applied there have been 3 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 9e5bbff. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Compare:
They use the same opcode --
0x3B
, which is forCMP r, r/m
. Whilecmpq(Address,Register)
actually should be using0x39
forCMP r/m, r
. I also suspect they emit basically the same instruction, because theget_prefixq
andemit_operand
argument order is irrelevant.AFAIU, it does not break horribly, because the
cmpq(Address,Register)
is not used anywhere except the new code inMacroAssembler::safepoint_poll
, added by JDK-8253180. This was found by Zhengyu, when he tried to enable that new code on x86_32 by invertingcmpq(addr, reg); jcc(above, slow_path)
tocmpptr(reg, addr); jcc(belowEquals, slow_path)
. Then, everything blew up, because the semantics ofcmpq(addr,reg)
was wrong, and this inversion was subtly broken.Current candidate patch encodes this
cmpq
properly. Since that changes the semantics, I had to flip the condition code in its only use. I opted to do this, because maybe some code in downstream projects want to use this oddcmpq
. Although even if so, the uses could be trivially rewritten.Alternatives:
cmpq(Address,Register)
altogether, but it would require more work to untanglecmpptr(Address,Register)
andcmpptr(Address,AddressLiteral)
for x86_32.MacroAssembler::safepoint_poll
change to usecmpq(Register,Address)
to begin with, but current shape gives us a way to test the encoding.Additional testing:
Progress
Testing
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/910/head:pull/910
$ git checkout pull/910