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

8308463: Refactor regenerated class handling in lambdaFormInvokers.cpp #14573

Closed

Conversation

iklam
Copy link
Member

@iklam iklam commented Jun 21, 2023

The handling of regenerated classes need to be refactored to enable future development:

  • Improve the API to access the regenerated classes and their methods
  • Allow more classes to be regenerated, not just the Lambda Form invokers. Therefore, the code is moved to a new file cds/regeneratedClasses.cpp

Please see the bug report JDK-8308463 for motivation of this PR.


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-8308463: Refactor regenerated class handling in lambdaFormInvokers.cpp (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14573

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 21, 2023

👋 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 openjdk bot added the rfr Pull request is ready for review label Jun 21, 2023
@openjdk
Copy link

openjdk bot commented Jun 21, 2023

@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 Jun 21, 2023
@mlbridge
Copy link

mlbridge bot commented Jun 21, 2023

Webrevs

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.

I have some style comments. I don't know what regenerated classes are.

@@ -142,6 +142,10 @@ class ArchiveBuilder : public StackObj {
_buffered_addr = nullptr;
}
}
SourceObjInfo(address src, address buf) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't initialize all the fields, and should use initialization syntax. Could you make one of these constructors call a common one that zeros out the other fields?

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 cleaned up this constructor and added comments.

}

void RegeneratedClasses::record_regenerated_objects() {
if (_renegerated_objs != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the DumpTimeTable_lock protect regenerated_objs also?

Copy link
Member Author

Choose a reason for hiding this comment

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

This function is called inside a safepoint and can't lock DumpTimeTable_lock. I added assert(SafepointSynchronize::is_at_safepoint() instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

assert_locked_or_safepoint(DumpTimeTable_lock) might be better in case you someday don't dump during safepoint.

private:
using RegeneratedObjTable = ResourceHashtable<address, address, 15889, AnyObj::C_HEAP, mtClassShared>;
static RegeneratedObjTable* _renegerated_objs; // InstanceKlass* and Method*
static GrowableArrayCHeap<OopHandle, mtClassShared>* _regenerated_mirrors;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since these are private, and not used by the argument, do they need to be in the header file?

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 moved them to the cpp file.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

First pass looks reasonable. Unclear on some of the details.

Thanks.

#include "utilities/growableArray.hpp"
#include "utilities/resourceHash.hpp"

class RegeneratedClasses : public AllStatic {
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 a class comment describing what RegeneratedClasses are.

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 added the comment.

Copy link
Contributor

@matias9927 matias9927 left a comment

Choose a reason for hiding this comment

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

Nice refactor! Just one question, otherwise it looks good.

Method* regen_m = regen_klass->find_method(orig_m->name(), orig_m->signature());
if (regen_m == nullptr) {
ResourceMark rm;
log_info(cds, lambda)("Method in original class is missing from regenerated class: " INTPTR_FORMAT " %s",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this result in some sort of exception?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently the missing methods aren't a problem, as the CDS image will not have any direct references to them. (And if we did, it would result in a crash in ArchiveBuilder::get_buffered_addr(), so we will know pretty quickly).

See https://bugs.openjdk.org/browse/JDK-8310831 for more info.

Anyway, I've changed it to be a warning log so we can be aware of it. Currently, this seems to happen only during the JDK build, when creating intermediate CDS archive files (during which time the warnings are piped to /dev/null so you won't see it .....)

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.

Ok, now I get it. The comment helps.

}

void RegeneratedClasses::record_regenerated_objects() {
if (_renegerated_objs != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

assert_locked_or_safepoint(DumpTimeTable_lock) might be better in case you someday don't dump during safepoint.

@openjdk
Copy link

openjdk bot commented Jun 22, 2023

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

8308463: Refactor regenerated class handling in lambdaFormInvokers.cpp

Reviewed-by: coleenp, dholmes, matsaave

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 Jun 22, 2023
Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Seems fine. Thanks

@iklam
Copy link
Member Author

iklam commented Jun 29, 2023

Thanks @coleenp @matias9927 @dholmes-ora for the review.
/integrate

@openjdk
Copy link

openjdk bot commented Jun 29, 2023

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

  • 6f58ab2: 8301569: jmod list option and jimage list --help not interpreted correctly on turkish locale
  • 8f5a384: 8311032: Empty value for java.protocol.handler.pkgs system property can lead to unnecessary classloading attempts of protocol handlers

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jun 29, 2023

@iklam Pushed as commit cf8d706.

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