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

8272315: Improve assert_different_registers #5083

Closed
wants to merge 3 commits into from

Conversation

kimbarrett
Copy link

@kimbarrett kimbarrett commented Aug 11, 2021

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

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

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

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 11, 2021

👋 Welcome back kbarrett! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 11, 2021
@openjdk
Copy link

openjdk bot commented Aug 11, 2021

@kimbarrett The following label will be automatically applied to this pull request:

  • hotspot-compiler

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.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Aug 11, 2021
@mlbridge
Copy link

mlbridge bot commented Aug 11, 2021

Webrevs

Copy link
Contributor

@adinn adinn left a comment

Choose a reason for hiding this comment

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

Looks good.

@openjdk
Copy link

openjdk bot commented Aug 11, 2021

@kimbarrett 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:

8272315: Improve assert_different_registers

Reviewed-by: adinn, vlivanov, thartmann

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 master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 11, 2021
Copy link

@iwanowww iwanowww left a comment

Choose a reason for hiding this comment

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

Looks nice!

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);
Copy link
Author

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?

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

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.

Copy link
Author

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.

@dean-long
Copy link
Member

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?

@kimbarrett
Copy link
Author

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.

Copy link
Member

@TobiHartmann TobiHartmann left a 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.

Copy link
Contributor

@adinn adinn left a comment

Choose a reason for hiding this comment

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

Still good

@kimbarrett
Copy link
Author

Thanks @TobiHartmann , @adinn , and @iwanowww for reviews.

@kimbarrett
Copy link
Author

/integrate

@openjdk
Copy link

openjdk bot commented Aug 12, 2021

Going to push as commit 93cab7d.

@openjdk openjdk bot closed this Aug 12, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 12, 2021
@openjdk
Copy link

openjdk bot commented Aug 12, 2021

@kimbarrett Pushed as commit 93cab7d.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@kimbarrett kimbarrett deleted the reg_enum branch August 12, 2021 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
5 participants