-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8360936: Test compiler/onSpinWait/TestOnSpinWaitAArch64.java fails after JDK-8359435 #26072
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
Conversation
👋 Welcome back eastigeevich! A progress list of the required criteria for merging this PR into |
@eastig 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 28 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
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 okay, but I am confused why the test did not fail before JDK-8359435?
@@ -29,6 +29,7 @@ | |||
* | |||
* @requires vm.flagless | |||
* @requires os.arch=="aarch64" | |||
* @requires vm.debug==true |
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.
Can be just @requires vm.debug
.
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.
Done
Just checked. It's not because of JDK-8359435. There were some changes which disabled printing debug info in release build. |
The test started failing after I had updated my branch. |
OK, are you able to bisect which change? This fix to only do debug VM needs to be correctly linked to the actual cause, IMO. |
I finished bisecting. This is my changes in the test which made it failing:
It looks like |
That's not great. What info do you need, exactly? |
The test searches for Assembly from all builds always has |
That's not great. C2 is free to move stuff around, so it's not certain this test will keep working. If you just want to make sure that the pattern is used, a block_comment() would be more reliable. |
I have rewritten the test not to use debug info at all. The test works with instructions instead. |
@shipilev, @theRealAph |
private static String retInst = "ret"; | ||
private static String neededAddInst = "addsp,sp,#0x20"; | ||
private static String neededLdpInst = "ldpx29,x30,[sp,#16]"; |
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.
Move these default inits down to analyzer.contains("[MachCode]")
block, since it looks like it selects between two options based on [MachCode]
presence. Something like:
boolean disassembly = analyzer.contains("[MachCode]");
retInst = disassembly ? "ret" : "c0035fd6";
...
String s = instrReverseIter.previous(); | ||
instrReverseIter.next(); | ||
if (instrReverseIter.previous().startsWith(neededAddInst)) { |
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.
Multiple issues here:
- Confusing: what's the use of
s
, did you mean to use it forstartsWith
? - Indenting is off
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.
Overall, I think searching for this multi-instruction stencil gets fairly hairy with iterators. Would a more straight-forward looping work?
int found = 0;
for (int c = 0; c < instrs.size() - 2; c++) {
if (instrs.get(c).startsWith(spinWaitInst) &&
instrs.get(c+1).startsWith(neededLdpInst) &&
instrs.get(c+2).startsWith(neededAddInst)) {
found++;
}
}
Then again, it does not address a central point: the test keeps relying on particular instruction scheduling, which is not reliable. Why do we even need to search for ldp+add anchor? Can we just blindly search for spin-wait-looking instructions? I would expect |
I have rewrote the test to use |
@@ -6803,6 +6803,7 @@ void MacroAssembler::verify_cross_modify_fence_not_required() { | |||
#endif | |||
|
|||
void MacroAssembler::spin_wait() { | |||
block_comment("spin_wait"); |
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.
You need something unique. e.g.
block_comment("spin_wait"); | |
block_comment("spin_wait_ohthoo8H"); |
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.
Erm, I don't see why?
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.
Erm, I don't see why?
To make it unique? I don't see why you don't see that we need to ensure that the string is unique.
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.
@theRealAph, what do you think to have it in the format: spin_wait_%INST-COUNT%_%INST_NAME%
?
For example: spin_wait_1_isb
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.
But this is a generic macroAssembler block comment. It does not make sense to me to have a block comment that looks like a memory corrupted string, just to satisfy a single test. There should be a middle-ground here, e.g. spin_wait {
, which looks reasonably enough as the block comment, and not anything else. Would also match nicely when we emit the closing }
at the end of the instruction block.
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 like the idea of having {
, }
.
IMO this should be informative:
;; spin_wait_3_nop {
nop
nop
nop
;; }
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.
Putting _3_nop
might be convenient, but I think that would introduce too much hassle in macroAssembler? Just this looks okay to me:
;; spin_wait {
nop
nop
nop
;; }
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.
@theRealAph, are you okay with the latest variant Aleksey proposes?
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.
But this is a generic macroAssembler block comment. It does not make sense to me to have a block comment that looks like a memory corrupted string, just to satisfy a single test. There should be a middle-ground here, e.g.
spin_wait {
, which looks reasonably enough as the block comment, and not anything else. Would also match nicely when we emit the closing}
at the end of the instruction block.
OK
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 update the PR to use spin_wait { ... }
Two MacOS tests failed due to time out. This is not related to my change. |
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 patch. I propose a few cosmetics: 8360936-cosmetics-1.patch.txt -- easier to express them as patch. Untested, see if it makes sense?
Thank you! It make sense. |
I tested it. It works as expected. |
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, thanks.
if (nextLine.contains(substring)) { | ||
return nextLine; | ||
String line = iter.next().trim(); | ||
if (line.startsWith(";;}")) { |
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.
Oh, apologies, I made a little mistake here when playing around with trims. Should be:
if (line.startsWith(";;}")) { | |
if (line.startsWith(";; }")) { |
The test probably does not fail because it meets no instructions beyond the spin_wait block. Cleaner to fix it anyway.
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 fixed this.
I have also added a specialized lambda function to count expected instructions:
- for disassembled code, just check a line.
- for hex code, split and count.
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.
Not sure lambdas make this cleaner, TBH.
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.
Ok, the lambda is removed.
… count instructions
/integrate |
Going to push as commit a86dd56.
Your commit was automatically rebased without conflicts. |
Test compiler/onSpinWait/TestOnSpinWaitAArch64.java needs debug info to identify a position of spin wait instructions in generated code. The test switched to use
XX:CompileCommand=print
instead ofXX:+PrintAssembly
to have assembly only for a tested Java method. In release buildsXX:+PrintAssembly
prints out debug info butXX:CompileCommand=print
does not.This PR reimplements the test to parse instructions and to check them. The test does not rely on debug info anymore.
Tested on Linux and MacOS with and without hsdis:
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26072/head:pull/26072
$ git checkout pull/26072
Update a local copy of the PR:
$ git checkout pull/26072
$ git pull https://git.openjdk.org/jdk.git pull/26072/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26072
View PR using the GUI difftool:
$ git pr show -t 26072
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26072.diff
Using Webrev
Link to Webrev Comment