Skip to content

8293291: Simplify relocation of native pointers in archive heap #10296

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

Conversation

iklam
Copy link
Member

@iklam iklam commented Sep 15, 2022

Some objects in the archive heap contain native pointers. E.g., archived java.lang.Class objects contain a pointer to its Klass*.

At runtime, if the archived metadata are mapped at an alternative address, all of the Klass* pointers must be relocated. Instead of doing this in an ad-hoc way, this PR uses a bitmap, FileMapRegion::ptrmap_view(), to track the position of all the native pointers.

This PR is done in preparation for supporting new types of archived heap objects that have native pointers. E.g., java.lang.invoke.ResolvedMethodName has a pointer to a Method*.

Notes for reviewers:

  • At dump time, the native pointers are remembered in HeapShared::mark_native_pointers().
  • At runtime, the native pointers are patched in ArchiveHeapLoader::patch_native_pointers().
  • The ad-hoc relocation code has been removed from javaClasses.cpp and systemDictionaryShared.cpp
  • Many of the changes are for renaming from "oopmaps" to "bitmaps": the old code handled only a single type of pointers (oop references). The new code handles two types of bitmaps ("oopmap" is for oop references, "ptrmap" is for native pointers).

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-8293291: Simplify relocation of native pointers in archive heap

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10296

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 15, 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 Sep 15, 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 Sep 15, 2022
@iklam iklam marked this pull request as ready for review September 15, 2022 21:07
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 15, 2022
@mlbridge
Copy link

mlbridge bot commented Sep 15, 2022

Webrevs

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.

I've a few minor comments. Thanks.

@@ -55,8 +55,12 @@ typedef struct CDSFileMapRegion {
// - for heap regions, the base address is the compressed oop encoding base
size_t _used; // Number of bytes actually used by this region (excluding padding bytes added
// for alignment purposed.
size_t _oopmap_offset; // Bitmap for relocating embedded oops (offset from SharedBaseAddress).
size_t _oopmap_offset; // Bitmap for relocating oop fields in archived heap objects.
// (The base address is the botom of the BM region)
Copy link
Member

Choose a reason for hiding this comment

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

typo: botom -> bottom

size_t _oopmap_size_in_bits;
size_t _ptrmap_offset; // Bitmap for relocating native pointer fields in archived heap objects.
// (The base address is the botom of the BM region).
Copy link
Member

Choose a reason for hiding this comment

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

typo: botom -> bottom

}
}

log_info(cds, heap)("calculate_ptrmap: marked %d non-null native pointers our of "
Copy link
Member

Choose a reason for hiding this comment

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

typo: our -> out

Comment on lines 1691 to 1693
int oopmap_idx = i * 2;
int ptrmap_idx = i * 2 + 1;
space_at(region_idx)->init_bitmaps(bitmaps->at(i*2), bitmaps->at(i*2 + 1));
Copy link
Member

Choose a reason for hiding this comment

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

Please add some comment on oopmap_idx and ptrmap_idx.

Line 1693 could be:
space_at(region_idx)->init_bitmaps(bitmaps->at(oopmap_idx), bitmaps->at(ptrmap_idx));

Comment on lines 908 to 915
for (int i=0; i<regions->length(); i++) {
ResourceBitMap oopmap = HeapShared::calculate_oopmap(regions->at(i));
Copy link
Member

Choose a reason for hiding this comment

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

Pre-existing: line 908.
While you're touching this code, please add a space before and after the '=' and '<'.

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.

Updates look good.

@openjdk
Copy link

openjdk bot commented Oct 13, 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:

8293291: Simplify relocation of native pointers in archive heap

Reviewed-by: ccheung, coleenp

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 Oct 13, 2022
Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

This makes sense and does seem cleaner.

…simplify-archive-heap-native-ptr-relocation
@iklam
Copy link
Member Author

iklam commented Oct 19, 2022

Thanks @calvinccheung and @coleenp for the review. I have merged with latest repo (after CPU sync) and retested with tiers 1-4. All passed.
/integrate

@openjdk
Copy link

openjdk bot commented Oct 19, 2022

Going to push as commit 3f4964f.

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

openjdk bot commented Oct 19, 2022

@iklam Pushed as commit 3f4964f.

💡 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