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

Store (narrow) klass in object header #7

wants to merge 5 commits into from


Copy link

@rkennke rkennke commented May 21, 2021

This change stores compressed Klass* in the upper 32bits of the object header. It doesn't really use it, yet. But I added some code in heap-object-stats to verify that all objects receive it.

It is implemented by storing the compressed Klass* into the prototype-header for each Klass, and use that to initialize objects, pretty much like we used to do for +BiasedLocking.

It will take some serious effort to change all code to use this new location to find the Klass*:

  • We need to change all generated code (intepreter, c1, c2) to load Klass* from the header, and call to runtime when it encounters a displaced header word.
  • We need to change (sliding-compacting) GCs to be able to iterate heap while objects are forwarded. Most likely by using a forwarding table, but I'm not quite sure yet.
  • We need to change rest of runtime to load Klass* from header.

In this change, I modified some code in G1 that deals with checking consistent header, the same asserts that we have seen in #6. This is rather ugly, but I actually expect those asserts to go away or be rewritten in a more useful way.

CDS support is noteworthy because we need to ensure that we propagate the actual narrowKlass whenever we (re-)initialize object headers, because that may be encoded with a different base address for archived Klass instances than other Klass instances, and would create a mess if we would re-encode the Klass*.


  • tier1
  • tier2


  • Change must not contain extraneous whitespace
  • Change must be properly reviewed



Using git

Checkout this PR locally:
$ git fetch pull/7/head:pull/7
$ git checkout pull/7

Update a local copy of the PR:
$ git checkout pull/7
$ git pull pull/7/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 7

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

Using diff file

Download this PR as a diff file:

@rkennke rkennke requested review from shipilev and stefank May 21, 2021
Copy link

@bridgekeeper bridgekeeper bot commented May 21, 2021

👋 Welcome back rkennke! 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 label May 21, 2021
Copy link

@mlbridge mlbridge bot commented May 21, 2021


Copy link

@shipilev shipilev left a comment

Cursory review follows.

src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp Show resolved Hide resolved
src/hotspot/share/cds/archiveBuilder.cpp Show resolved Hide resolved
src/hotspot/share/oops/klass.cpp Outdated Show resolved Hide resolved
src/hotspot/share/oops/markWord.cpp Outdated Show resolved Hide resolved
@rkennke rkennke requested a review from shipilev May 25, 2021
Copy link

@shipilev shipilev left a comment

Looks fine for the experimental code.

Copy link

@openjdk openjdk bot commented May 25, 2021

@rkennke This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file for details.

After integration, the commit message for the final commit will be:

Store (narrow) klass in object header

Reviewed-by: shade

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 label May 25, 2021
Copy link
Collaborator Author

@rkennke rkennke commented May 26, 2021


@openjdk openjdk bot closed this May 26, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels May 26, 2021
Copy link

@openjdk openjdk bot commented May 26, 2021

@rkennke Pushed as commit 161e7c8.

💡 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
2 participants