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

8297290: Use int indices to reference CDS archived primitive mirrors #11256

Conversation

iklam
Copy link
Member

@iklam iklam commented Nov 21, 2022

In CDS, when archived class metadata reference an object in the archive heap, it's usually done using an integer index, which can be passed to HeapShared::get_root(int) to retrieve the object. This way, we don't need to worry if the archive heap has been relocated. E.g.,

oop Klass::archived_java_mirror() {
  assert(has_archived_mirror_index(), "must have archived mirror");
  return HeapShared::get_root(_archived_mirror_index);
}

However, for the primitive mirror objects (in Universe::_mirrors[], which point to the java.lang.Class instances of the Java primitive types such as int, float, etc), we are still using a direct oop reference.

For consistency, we should change this code to use the same int indices as the rest of the system. This will also make it simpler to optimize the layout of the CDS archive heap (e.g., in JDK-8234679).

Testing: passed tiers 1-4


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

  • JDK-8297290: Use int indices to reference CDS archived primitive mirrors

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11256

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 21, 2022

👋 Welcome back iklam! 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
Copy link

openjdk bot commented Nov 21, 2022

@iklam 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 21, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 21, 2022
@mlbridge
Copy link

mlbridge bot commented Nov 21, 2022

Webrevs

@@ -236,29 +234,38 @@ void Universe::metaspace_pointers_do(MetaspaceClosure* it) {
_do_stack_walk_cache->metaspace_pointers_do(it);
}

#if INCLUDE_CDS_JAVA_HEAP
void Universe::set_archived_mirror_index(BasicType t, int index) {
Copy link
Member

Choose a reason for hiding this comment

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

Is it called during dump time only?
If so, maybe add an assert?
assert(DumpSharedSpaces, "dump-time only");

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed as suggested.

@@ -89,6 +89,9 @@ Klass* Universe::_typeArrayKlassObjs[T_LONG+1] = { NULL /*, NULL...*/ };
Klass* Universe::_objectArrayKlassObj = NULL;
Klass* Universe::_fillerArrayKlassObj = NULL;
OopHandle Universe::_mirrors[T_VOID+1];
#if INCLUDE_CDS_JAVA_HEAP
int Universe::_archived_mirror_indices[T_VOID+1];
Copy link
Contributor

Choose a reason for hiding this comment

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

a minor suggestion - I feel it would be better to name it as _archived_basic_type_mirror_indices as it only stores mirrors for primitive types. Same for the other functions accessing _archived_mirror_indices i.e. set_archived_mirror_index -> set_archived_basic_type_mirror_index and update_archived_mirrors -> update_archived_basic_type_mirrors.

Copy link
Member Author

Choose a reason for hiding this comment

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

I renamed the field/functions as you suggested. Now they are consistent with existing functions like Universe::initialize_basic_type_mirrors()

I think eventually they should be named to primitive_type_mirrors since we don't use them for the reference types. But there are a few functions that are unrelated to this RFE, so I'll probably do the renaming in a subsequent RFE.

@ashu-mehra
Copy link
Contributor

lgtm, thanks for updating the field/function names.

Copy link
Member

@calvinccheung calvinccheung left a comment

Choose a reason for hiding this comment

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

Updated changes look good.

@openjdk
Copy link

openjdk bot commented Nov 28, 2022

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

8297290: Use int indices to reference CDS archived primitive mirrors

Reviewed-by: ccheung

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

  • cdf9ed0: 8297528: java/io/File/TempDirDoesNotExist.java test failing on windows-x64
  • 105d9d7: 8295351: java/lang/Float/Binary16Conversion.java fails with "Unexpected result of converting"
  • a80552e: 8236919: Refactor com.sun.tools.javac.main.CommandLine into a reusable module for other JDK tools
  • a249a52: 8296754: AutoCreateSharedArchive in JDK 20 is not compatible with JDK 19
  • 405b188: 8297570: jdk/jfr/threading/TestDeepVirtualStackTrace.java fails with -XX:-UseTLAB
  • ba0a252: 8297717: Remove jdk/internal/misc/TerminatingThreadLocal/TestTerminatingThreadLocal.java from ProblemList
  • c05dc80: 8297660: x86: Redundant test+jump in C1 allocateArray
  • eff4c03: 8297343: TestStress*.java fail with "got different traces for the same seed"
  • 6a856bc: 8297499: Parallel: Missing iteration over klass when marking objArrays/objArrayOops during Full GC
  • b80f5af: 8297309: Memory leak in ShenandoahFullGC
  • ... and 59 more: https://git.openjdk.org/jdk/compare/260e4dcbfd8bdccdf332c2b6a07990cd14f6bcfb...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 28, 2022
@iklam
Copy link
Member Author

iklam commented Nov 30, 2022

Thanks @ashu-mehra and @calvinccheung for the review.
/integrate

@openjdk
Copy link

openjdk bot commented Nov 30, 2022

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

  • 37f613b: 8297676: DataBuffer.TYPE_SHORT/TYPE_FLOAT/TYPE_DOUBLE are not placeholders
  • 87f00f4: 8296878: Document Filter attached to JPasswordField and setText("") is not cleared instead inserted characters replaced with unicode null characters
  • 9ced2ea: 8297311: Improve exception message thrown by java.net.HostPortrange::toLowerCase(String s)
  • defe060: 8296905: Replace the native LCMS#getProfileID() method with the accessor
  • e10778a: 8297695: Fix typos in test/langtools files
  • 0ce1827: 8294321: Fix typos in files under test/jdk/java, test/jdk/jdk, test/jdk/jni
  • e2d71c0: 8297481: Create a regression test for JDK-4424517
  • f4063a3: 8297210: Add a @sealedGraph tag to selected java.desktop classes
  • 2084451: 8078471: Backspace does not work in JFileChooser with GTK L&F
  • 7af6b4b: 8296012: jshell crashes on mismatched record pattern
  • ... and 91 more: https://git.openjdk.org/jdk/compare/260e4dcbfd8bdccdf332c2b6a07990cd14f6bcfb...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Nov 30, 2022

@iklam Pushed as commit c7a679f.

💡 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