Skip to content

Conversation

@adinn
Copy link
Contributor

@adinn adinn commented Jul 29, 2025

The AOT stub blob save and restore API handles Adapter blobs differently to other single-stub blobs by passing the associated entries in a separate auxiliary array. Storing the entry offsets in the blob, as happens with other generated blobs, simplifies the current save/restore API and implementation. It also makes it easier to define and implement an API extension supporting save and restore of multi-stub (StubGen) blobs.


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-8364269: Simplify code cache API by storing adapter entry offsets in blob (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26532

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 29, 2025

👋 Welcome back adinn! 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 Jul 29, 2025

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

8364269: Simplify code cache API by storing adapter entry offsets in blob

Reviewed-by: kvn, shade, asmehra

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

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 rfr Pull request is ready for review label Jul 29, 2025
@openjdk
Copy link

openjdk bot commented Jul 29, 2025

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

  • hotspot

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 hotspot-dev@openjdk.org label Jul 29, 2025
@mlbridge
Copy link

mlbridge bot commented Jul 29, 2025

Webrevs

@shipilev
Copy link
Member

Cross-compile GHA jobs would be fixed once you pull from recent master.

@adinn
Copy link
Contributor Author

adinn commented Jul 29, 2025

Testing: tier1 + runtime/cds/appcds

@adinn
Copy link
Contributor Author

adinn commented Jul 29, 2025

@ashu-mehra @vnkozlov could you review this cleanup?

@adinn
Copy link
Contributor Author

adinn commented Jul 29, 2025

Ah, sorry, the merge appears to have caused some issues in debug builds. Will let you know when this is ready again.

@adinn adinn marked this pull request as draft July 29, 2025 15:08
@openjdk openjdk bot removed the rfr Pull request is ready for review label Jul 29, 2025
@adinn
Copy link
Contributor Author

adinn commented Jul 30, 2025

@vnkozlov @ashu-mehra @shipilev

Ok, problem fixed, I believe, but I'm still gob-smacked that this built, ran and passed tier1 plus cds/appcds tests on Linux/aarch64 given the failure to run the exploded image on Linux/x86 and MacOS/aarch64.

The problem was with the blob layout. Adding extra fields to AdapterBlob requires propagating the adjusted blob size (i.e. header_size) up the Blob constructor chain, through BufferBlob into RuntimeBlob. Which I have now done -- previously, all subclasses were sized using sizeof(BufferBlob) as none of them had extra fields.

without that fix the content_start address for the Adpater blob was being reported in the tail of the blob proper which meant that in the broken builds data fields were being treated as code and we end up in hyperspace when we first use an i2c adapter to jump to Object.init(). Yet not on Linux/aarch64? Go figure.

Should be ready to review now.

@ashu-mehra
Copy link
Contributor

If the entry offsets are stored in AdapterBlob, AdapterHandlerEntry can then just store a pointer to the blob and get rid of the offsets. SharedRuntime::generate_i2c2i_adapters can be updated to return the AdapterBlob. And when storing the AdapterHandlerEntry, pointer to the blob can be cleared and restored in AdapterHandlerLibrary::lookup_aot_cache.
This assumes the AdapterBlob won't be moved around in the code cache.
@adinn does this make sense?

@adinn
Copy link
Contributor Author

adinn commented Jul 31, 2025

@ashu-mehra

If the entry offsets are stored in AdapterBlob, AdapterHandlerEntry can then just store a pointer to the blob and get rid of the offsets.

I planned that originally but it doesn't work because of one special case. Method AdapterHandlerLibrary::create_abstract_method_handler does this:

  address wrong_method_abstract = SharedRuntime::get_handle_wrong_method_abstract_stub();
  _abstract_method_handler = AdapterHandlerLibrary::new_entry(AdapterFingerPrint::allocate(0, nullptr));
  _abstract_method_handler->set_entry_points(SharedRuntime::throw_AbstractMethodError_entry(),
                                             wrong_method_abstract,
                                             wrong_method_abstract,
                                             nullptr);

So, in this one case we have a Frankenstein handler assembled from 3 disparate entry points (+ nullptr) which are not derived from an associated adapter blob.

@ashu-mehra
Copy link
Contributor

ashu-mehra commented Jul 31, 2025

So, in this one case we have a Frankenstein handler assembled from 3 disparate entry points (+ nullptr) which are not derived from an associated adapter blob.

That's true. I missed this special adapter handler. That special handler is a pain to accommodate.
I looked at how these entry points are accessed and it seems they are mostly accessed by the routines in Method. So it should be feasible to handle the case of abstract methods there and get rid of this special adapter completely. @adinn wdyt?

@adinn
Copy link
Contributor Author

adinn commented Aug 7, 2025

I looked at how these entry points are accessed and it seems they are mostly accessed by the routines in Method. So it should be feasible to handle the case of abstract methods there and get rid of this special adapter completely. @adinn wdyt?

I think maybe in follow-up RFE ;-)

@ashu-mehra
Copy link
Contributor

think maybe in follow-up RFE ;-)

Yeah, I can take a stab at that.
Meanwhile this PR is still in draft. Do you have any other changes to be made? Seems ready to me.

@adinn adinn marked this pull request as ready for review August 7, 2025 13:54
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 7, 2025
Copy link
Contributor

@vnkozlov vnkozlov 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. Let me test it.

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

This looks fine to me. API got indeed simpler.

private:
AdapterBlob(int size, CodeBuffer* cb);

AdapterBlob(int size, CodeBuffer* cb, int entry_offset[ENTRY_COUNT]);
Copy link
Member

Choose a reason for hiding this comment

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

I was today years old when I realized you can pass const-sized arrays as arguments.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 7, 2025
Copy link
Contributor

@ashu-mehra ashu-mehra left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

My testing passed.

@adinn
Copy link
Contributor Author

adinn commented Aug 8, 2025

Thanks all for the reviews. Integrating now.

@adinn
Copy link
Contributor Author

adinn commented Aug 8, 2025

/integrate

@openjdk
Copy link

openjdk bot commented Aug 8, 2025

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

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Aug 8, 2025

@adinn Pushed as commit 241808e.

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

@shqking
Copy link
Contributor

shqking commented Aug 11, 2025

Hi @adinn,

We encountered runtime error on Arm32 after this patch. I filed in https://bugs.openjdk.org/browse/JDK-8365229.
I was wondering if you have spare time to take a look at this issue. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

5 participants