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

8297534: Specify the size of MEMFLAGS #11336

Closed
wants to merge 3 commits into from

Conversation

jdksjolen
Copy link
Contributor

@jdksjolen jdksjolen commented Nov 23, 2022

Hi!

In MallocHeader we assume that MEMFLAGS can be stored in a uint8_t, see:

class MallocHeader {

  NOT_LP64(uint32_t _alt_canary);
  const size_t _size;
  const uint32_t _mst_marker;
  const uint8_t _flags;
  const uint8_t _unused;
  uint16_t _canary;
// SNIP!
  inline MEMFLAGS flags() const { return (MEMFLAGS)_flags; }

With C++11 we can specify the underlying type of an enum class, so let's just do that. If we generate 257 memflags we'll get a compile error. I don't believe that this would lead to any change in the behavior of the code.

Testing: Compiled the code. Running tier1 testing right now.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/11336/head:pull/11336
$ git checkout pull/11336

Update a local copy of the PR:
$ git checkout pull/11336
$ git pull https://git.openjdk.org/jdk pull/11336/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11336

View PR using the GUI difftool:
$ git pr show -t 11336

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/11336.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 23, 2022

👋 Welcome back jsjolen! 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 Nov 23, 2022
@openjdk
Copy link

openjdk bot commented Nov 23, 2022

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

  • hotspot-runtime

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-runtime hotspot-runtime-dev@openjdk.org label Nov 23, 2022
@mlbridge
Copy link

mlbridge bot commented Nov 23, 2022

Webrevs

Copy link
Member

@tstuefe tstuefe left a comment

Choose a reason for hiding this comment

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

Good and trivial.

@openjdk
Copy link

openjdk bot commented Nov 24, 2022

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

8297534: Specify the size of MEMFLAGS

Reviewed-by: stuefe, tschatzl

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 50 new commits pushed to the master branch:

  • fd910f7: 8297384: Add IR tests for existing idealizations of arithmetic nodes
  • cfe5a37: 8297556: Parse::check_interpreter_type fails with assert "must constrain OSR typestate"
  • 74d3bac: 8297417: Poly1305IntrinsicFuzzTest fails with tag mismatch exception
  • 0ed8b33: 8297385: Remove duplicated null typos in javadoc
  • 1fb9dad: 8296419: [REDO] JDK-8295319: pending_cards_at_gc_start doesn't include cards in thread buffers
  • 2f47f83: 8297569: URLPermission constructor throws IllegalArgumentException: Invalid characters in hostname after JDK-8294378
  • 87d1097: 8297530: java.lang.IllegalArgumentException: Negative length on strings concatenation
  • 390e69a: 8297150: Add a @sealedGraph tag to Reference
  • 8effaa8: 8223783: sun/net/www/http/HttpClient/MultiThreadTest.java sometimes detect threads+1 connections
  • ab1f9ff: 8051627: Invariants about java.net.URI resolve and relativize are wrong
  • ... and 40 more: https://git.openjdk.org/jdk/compare/42c2037429a8ee6f683bbbc99fb48c540519524c...master

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 24, 2022
Copy link
Contributor

@tschatzl tschatzl left a comment

Choose a reason for hiding this comment

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

Imo the _flags member of MallocHeader should then also be of type MEMFLAGS as it is now defined what size it is. That saves some casting around in related code too.
I tried the change and it at least compiled, and do not see a reason not to.

@jdksjolen
Copy link
Contributor Author

Imo the _flags member of MallocHeader should then also be of type MEMFLAGS as it is now defined what size it is. That saves some casting around in related code too. I tried the change and it at least compiled, and do not see a reason not to.

Oh yeah, I agree.

Copy link
Member

@tstuefe tstuefe left a comment

Choose a reason for hiding this comment

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

Hmm, I can live with that, though I would have preferred the raw type for clarity. After all, enum should follow the layout of the header, not the other way around.

Can you at least add a static assert that sizeof memflags is 8 bits?

Copy link
Member

@tstuefe tstuefe left a comment

Choose a reason for hiding this comment

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

Hmm, I can live with that, though I would have preferred the raw type for clarity. After all, enum should follow the layout of the header, not the other way around.

Can you at least add a static assert that sizeof memflags is 8 bits?

Copy link
Contributor

@tschatzl tschatzl left a comment

Choose a reason for hiding this comment

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

Lgtm.

@jdksjolen
Copy link
Contributor Author

jdksjolen commented Nov 24, 2022

Hmm, I can live with that, though I would have preferred the raw type for clarity. After all, enum should follow the layout of the header, not the other way around.

Can you at least add a static assert that sizeof memflags is 8 bits?

Absolutely. Would you like that right after the definition of MEMFLAGS then? (and not after the definition of MEMFLAGS _flags in the header)

@tstuefe
Copy link
Member

tstuefe commented Nov 25, 2022

Hmm, I can live with that, though I would have preferred the raw type for clarity. After all, enum should follow the layout of the header, not the other way around.
Can you at least add a static assert that sizeof memflags is 8 bits?

Absolutely. Would you like that right after the definition of MEMFLAGS then? (and not after the definition of MEMFLAGS _flags in the header)

I don't care much as long as it explodes when MEMFLAGS are changed :-) If you add it to the hpp file, you need to give it debug.hpp too. I leave it up to you.

@jdksjolen
Copy link
Contributor Author

Alright, I added it to allocation.hpp with a small comment. Right now gcc gives the type error in the enum definition precedence, which gives you nicer error messages. I also ensured that the static assert gives a compiler error (by removing the enum type first), which it does.

@tstuefe
Copy link
Member

tstuefe commented Nov 25, 2022

Still good.

@jdksjolen
Copy link
Contributor Author

/integrate

Thank you for the reviews!

@openjdk
Copy link

openjdk bot commented Nov 28, 2022

Going to push as commit 81eb5fb.
Since your change was applied there have been 63 commits pushed to the master branch:

  • 012dafe: 8297082: Remove sun/tools/jhsdb/BasicLauncherTest.java from problem list
  • 43d1173: 8286302: Port JEP 425 to PPC64
  • d610211: 8297408: Consolidate code in runtime/ErrorHandling
  • 2f83b5c: 8297640: Increase buffer size for buf (insert_features_names) in Abstract_VM_Version::insert_features_names
  • 50f9043: 8297451: ProcessHandleImpl should assert privilege when modifying reaper thread
  • 99d3840: 8297359: RISC-V: improve performance of floating Max Min intrinsics
  • 6c05771: 8295447: NullPointerException with invalid pattern matching construct in constructor call
  • 76a24c3: 8297145: Add a @sealedGraph tag to ConstantDesc
  • 099b42f: 8297148: Add a @sealedGraph tag to CallSite
  • 85ddd8f: 8295253: Remove kludge from v1_0/PerfDataBuffer.java
  • ... and 53 more: https://git.openjdk.org/jdk/compare/42c2037429a8ee6f683bbbc99fb48c540519524c...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 28, 2022
@openjdk openjdk bot closed this Nov 28, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 28, 2022
@openjdk
Copy link

openjdk bot commented Nov 28, 2022

@jdksjolen Pushed as commit 81eb5fb.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants