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
8272315: Improve assert_different_registers #5083
Conversation
|
@kimbarrett The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
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 good.
@kimbarrett This change now passes all automated pre-integration checks. 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 no new commits pushed 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.
Looks nice!
src/hotspot/share/asm/register.hpp
Outdated
R regs[] = { first_register, more_registers... }; | ||
// Sort regs, so any equal entries are adjacent. | ||
struct Compare { ptrdiff_t operator()(R x, R y) const { return x - y; } }; | ||
QuickSort::sort(regs, ARRAY_SIZE(regs), Compare(), false); |
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.
Sorting is kind of overkill. Maybe I should have just use the obvious nested loop? What do reviewers think?
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.
Answering my own question, sorting imposes additional requirements on the type that might require adjustment for JDK-8270140. So I'm inclined to switch to the nested loop that only requires equality testing as before.
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.
Well, a nested loop is order n^2 but n is always going to be pretty small (the old code allowed for 12 but cases with n > 6 are rare). So I see no great perf problem with using a nested loop.
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.
... bearing in mind that quicksort is n.log(n) at best.
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.
Sorting is kind of overkill. Maybe I should have just use the obvious nested loop? What do reviewers think?
No strong preference on my side. I'm fine with it either way.
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.
Updated to use nested loops.
Isn't this macro only used for integer registers? I have an alternative implementation for arm somewhere that uses RegisterSet, but you can just use an array of bytes or bits and check for duplicates as you go in O(n) time, right? |
Probably, but that would require knowing the value range or dynamic allocation of the vector. And this is debug-only code, so keeping it simple would be nice. I don't think the N^2 behavior (which is what the old code had too) is a problem for the values of N we're dealing with. |
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.
Nice cleanup! Looks good to me.
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.
Still good
Thanks @TobiHartmann , @adinn , and @iwanowww for reviews. |
/integrate |
Going to push as commit 93cab7d. |
@kimbarrett Pushed as commit 93cab7d. |
Please review this improvement to assert_different_register.
It reduces ~250 lines of repetitive code to ~10 lines, and improves the
error message on failure by printing a duplicated registers name.
Unfortunately, this isn't enough to eliminate AbstractRegister[Impl].
Although it seems to no longer be needed for the Oracle-supported platforms,
the linux-arm/ppc64le/s390 platforms all use the value() function provided
by AbstractRegisterImpl.
Testing:
tier1 on Oracle supported platforms.
built linux-arm/ppc64le/s390.
Locally changed a call to have a duplicate register and verified the error
message had a useful register name.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5083/head:pull/5083
$ git checkout pull/5083
Update a local copy of the PR:
$ git checkout pull/5083
$ git pull https://git.openjdk.java.net/jdk pull/5083/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5083
View PR using the GUI difftool:
$ git pr show -t 5083
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5083.diff