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

8335480: Only deoptimize threads if needed when closing shared arena #20158

Closed
wants to merge 16 commits into from
Closed
3 changes: 3 additions & 0 deletions src/hotspot/share/jvmci/jvmciCodeInstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,13 +722,15 @@ JVMCI::CodeInstallResult CodeInstaller::install(JVMCICompiler* compiler,
jint entry_bci = -1;
JVMCICompileState* compile_state = nullptr;
bool has_unsafe_access = false;
bool has_scoped_access = false;
jint id = -1;

if (is_nmethod) {
method = methodHandle(thread, stream->read_method("method"));
entry_bci = is_nmethod ? stream->read_s4("entryBCI") : -1;
compile_state = (JVMCICompileState*) stream->read_u8("compileState");
has_unsafe_access = stream->read_bool("hasUnsafeAccess");
has_scoped_access = stream->read_bool("hasScopedAccess");
id = stream->read_s4("id");
}
stream->set_code_desc(name, method);
Expand Down Expand Up @@ -796,6 +798,7 @@ JVMCI::CodeInstallResult CodeInstaller::install(JVMCICompiler* compiler,
_has_monitors,
has_unsafe_access,
_has_wide_vector,
has_scoped_access,
compiled_code,
mirror,
failed_speculations,
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/jvmci/jvmciRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2079,6 +2079,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
bool has_monitors,
bool has_unsafe_access,
bool has_wide_vector,
bool has_scoped_access,
JVMCIObject compiled_code,
JVMCIObject nmethod_mirror,
FailedSpeculation** failed_speculations,
Expand Down Expand Up @@ -2183,7 +2184,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
nm->set_has_unsafe_access(has_unsafe_access);
nm->set_has_wide_vectors(has_wide_vector);
nm->set_has_monitors(has_monitors);
nm->set_has_scoped_access(true); // conservative
nm->set_has_scoped_access(has_scoped_access);

JVMCINMethodData* data = nm->jvmci_nmethod_data();
assert(data != nullptr, "must be");
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/jvmci/jvmciRuntime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ class JVMCIRuntime: public CHeapObj<mtJVMCI> {
bool has_monitors,
bool has_unsafe_access,
bool has_wide_vector,
bool has_scoped_access,
JVMCIObject compiled_code,
JVMCIObject nmethod_mirror,
FailedSpeculation** failed_speculations,
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/jvmci/vmStructs_jvmci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@
declare_constant(ConstMethodFlags::_misc_intrinsic_candidate) \
declare_constant(ConstMethodFlags::_misc_reserved_stack_access) \
declare_constant(ConstMethodFlags::_misc_changes_current_thread) \
declare_constant(ConstMethodFlags::_misc_is_scoped) \
\
declare_constant(CounterData::count_off) \
\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ private String codeDesc() {
writeInt("entryBCI", nmethod.entryBCI);
writeLong("compileState", nmethod.compileState);
writeBoolean("hasUnsafeAccess", nmethod.hasUnsafeAccess);
writeBoolean("hasScopedAccess", nmethod.hasScopedAccess);
writeInt("id", nmethod.id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public final class HotSpotCompiledNmethod extends HotSpotCompiledCode {

protected final boolean hasUnsafeAccess;

protected final boolean hasScopedAccess;

/**
* May be set by VM if code installation fails. It will describe in more detail why installation
* failed (e.g., exactly which dependency failed).
Expand All @@ -71,7 +73,8 @@ public HotSpotCompiledNmethod(String name,
int entryBCI,
int id,
long compileState,
boolean hasUnsafeAccess) {
boolean hasUnsafeAccess,
boolean hasScopedAccess) {
super(name,
targetCode,
targetCodeSize,
Expand All @@ -90,6 +93,7 @@ public HotSpotCompiledNmethod(String name,
this.id = id;
this.compileState = compileState;
this.hasUnsafeAccess = hasUnsafeAccess;
this.hasScopedAccess = hasScopedAccess;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ public interface HotSpotResolvedJavaMethod extends ResolvedJavaMethod {
*/
boolean hasReservedStackAccess();

/**
* Returns true if this method has a {@code Scoped} annotation.
JornVernee marked this conversation as resolved.
Show resolved Hide resolved
*
* @return true if Scoped annotation present, false otherwise
*/
boolean isScoped();

/**
* Sets flags on {@code method} indicating that it should never be inlined or compiled by the
* VM.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ public boolean hasReservedStackAccess() {
return (getConstMethodFlags() & config().constMethodFlagsReservedStackAccess) != 0;
}

/**
* Returns true if this method has a {@code Scoped} annotation.
*
* @return true if Scoped annotation present, false otherwise
*/
@Override
public boolean isScoped() {
return (getConstMethodFlags() & config().constMethodFlagsIsScoped) != 0;
}

/**
* Sets flags on {@code method} indicating that it should never be inlined or compiled by the
* VM.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ long prototypeMarkWord() {
final int constMethodFlagsReservedStackAccess = getConstant("ConstMethodFlags::_misc_reserved_stack_access", Integer.class);
final int constMethodFlagsCallerSensitive = getConstant("ConstMethodFlags::_misc_caller_sensitive", Integer.class);
final int constMethodFlagsIntrinsicCandidate = getConstant("ConstMethodFlags::_misc_intrinsic_candidate", Integer.class);
final int constMethodFlagsIsScoped = getConstant("ConstMethodFlags::_misc_is_scoped", Integer.class);
final int constMethodHasLineNumberTable = getConstant("ConstMethodFlags::_misc_has_linenumber_table", Integer.class);
final int constMethodHasLocalVariableTable = getConstant("ConstMethodFlags::_misc_has_localvariable_table", Integer.class);
final int constMethodHasMethodAnnotations = getConstant("ConstMethodFlags::_misc_has_method_annotations", Integer.class);
Expand Down