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

8263377: Store method handle linkers in the 'non-nmethods' heap #8760

Closed
wants to merge 21 commits into from

Conversation

yftsai
Copy link
Contributor

@yftsai yftsai commented May 17, 2022


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-8263377: Store method handle linkers in the 'non-nmethods' heap

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 8760

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented May 17, 2022

👋 Welcome back yftsai! 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 May 17, 2022

@yftsai 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 May 17, 2022
@openjdk
Copy link

openjdk bot commented May 26, 2022

@yftsai this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout intrinsics
git fetch https://git.openjdk.java.net/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label May 26, 2022
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label May 26, 2022
@yftsai yftsai marked this pull request as ready for review June 1, 2022 16:25
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 1, 2022
@mlbridge
Copy link

mlbridge bot commented Jun 1, 2022

Webrevs

Copy link
Member

@JornVernee JornVernee left a comment

Choose a reason for hiding this comment

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

Some initial comments. The codeBlob code looks mostly good to me. But, I don't have enough knowledge about the GC and IC changes to be able to say the same about that.

src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/arm/sharedRuntime_arm.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/s390/sharedRuntime_s390.cpp Outdated Show resolved Hide resolved
Comment on lines +352 to +354
if (mhi != NULL) {
debug_only(mhi->verify();) // might block
}
Copy link
Member

Choose a reason for hiding this comment

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

This is debug only. Looking at CodeCache::allocate, it can only return NULL if the allocation size is <= 0, in which case an earlier assert will already fire. So, this null check doesn't seem needed?

Suggested change
if (mhi != NULL) {
debug_only(mhi->verify();) // might block
}
debug_only(mhi->verify();) // might block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems needed. CodeCache::allocate may return NULL if the code cache is full.

src/hotspot/share/code/codeBlob.cpp Outdated Show resolved Hide resolved
Comment on lines 2048 to 2049
assert(Arguments::is_interpreter_only() || (spe->method()->has_compiled_code() &&
spe->method()->code()->entry_point() == spe->method()->from_compiled_entry()),
spe->method()->code()->code_begin() == spe->method()->from_compiled_entry()),
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this assert is still needed/useful, since we should only encounter MH linker blobs here, for which the from_compiled_entry is always code_begin.

I'd suggest just removing this assert.

Comment on lines 299 to 307
static nmethod* compile_method(const methodHandle& method,
static CodeBlob* compile_method(const methodHandle& method,
int osr_bci,
int comp_level,
const methodHandle& hot_method,
int hot_count,
CompileTask::CompileReason compile_reason,
TRAPS);

static nmethod* compile_method(const methodHandle& method,
static CodeBlob* compile_method(const methodHandle& method,
Copy link
Member

Choose a reason for hiding this comment

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

Not so sure about these changes. It seems to me that if a method is requested to be compiled, it should always result in an nmethod.

Alternatively, would it be possible to keep these functions returning an nmethod but add an assert at the start to check that the passed method is not a method handle intrinsic?

Copy link
Contributor Author

@yftsai yftsai Jun 7, 2022

Choose a reason for hiding this comment

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

The original implementation assumed that MH intrinsics are possible input. If that's not the cases, the newly added assertion simplifies some handling branches.

src/hotspot/share/oops/method.cpp Outdated Show resolved Hide resolved
@dean-long
Copy link
Member

I don't think we need a new RuntimeBlob subclasses. Can't we use the existing AdapterBlob or MethodHandlesAdapterBlob?

When changing from nmethod to CodeBlob, don't we need to replace COMPILED_METHOD_LOAD JVMTI events with DYNAMIC_CODE_GENERATED events?

@dean-long
Copy link
Member

Looking at all the CompiledMethod --> CodeBlob changes, I wondering if it wouldn't be better to use a subclass of CompiledMethod, liked we did for AOT methods. However, there may be assumptions in the code that the only subclass of CompiledMethod is nmethod.

@dean-long
Copy link
Member

/label hotspot-compiler

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Jun 4, 2022
@openjdk
Copy link

openjdk bot commented Jun 4, 2022

@dean-long
The hotspot-compiler label was successfully added.

code->log_identity(log);
CodeBlob* code = get_Method()->code();
if (code != NULL && code->is_compiled()) {
code->as_compiled_method()->log_identity(log);
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this change the log output?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the output of MH intrinsic cases will become like the cases where codes are not set. The removed parts are compiled ID, compiler, and compile level. They are all constants for MH intrinsics, not providing much information.

remove unused argument of NativeJump::check_verified_entry_alignment
remove unused argument of NativeJumip::patch_verified_entry
remove dead codes in SharedRuntime::generate_method_handle_intrinsic_wrapper
@yftsai
Copy link
Contributor Author

yftsai commented Jun 7, 2022

if it wouldn't be better to use a subclass of CompiledMethod

The idea has been explored in this earlier commit. Overall, it is more complex in reimplementing many CompiledMethod interfaces to support nmethod life cycle and GC scans. These interfaces are logically irrelevant to MH intrinsics which never unload and contain no oops.

@yftsai
Copy link
Contributor Author

yftsai commented Jun 7, 2022

Can't we use the existing AdapterBlob or MethodHandlesAdapterBlob?

An MH intrinsic is handled differently from them in SharedRuntime::continuation_for_implicit_exception and compiledIC.
The extra field _method is used in places like trace_exception unless this information is not important.

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 7, 2022

@yftsai This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 10, 2022

@yftsai This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

@bridgekeeper bridgekeeper bot closed this Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org hotspot-compiler hotspot-compiler-dev@openjdk.org rfr Pull request is ready for review
3 participants