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
2 changes: 2 additions & 0 deletions src/hotspot/share/c1/c1_Compilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ void Compilation::install_code(int frame_size) {
has_unsafe_access(),
SharedRuntime::is_wide_vector(max_vector_size()),
has_monitors(),
has_scoped_access(),
_immediate_oops_patched
);
}
Expand Down Expand Up @@ -578,6 +579,7 @@ Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* metho
, _has_method_handle_invokes(false)
, _has_reserved_stack_access(method->has_reserved_stack_access())
, _has_monitors(method->is_synchronized() || method->has_monitor_bytecodes())
, _has_scoped_access(method->is_scoped())
, _install_code(install_code)
, _bailout_msg(nullptr)
, _first_failure_details(nullptr)
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/c1/c1_Compilation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Compilation: public StackObj {
bool _has_method_handle_invokes; // True if this method has MethodHandle invokes.
bool _has_reserved_stack_access;
bool _has_monitors; // Fastpath monitors detection for Continuations
bool _has_scoped_access; // For shared scope closure
bool _install_code;
const char* _bailout_msg;
CompilationFailureInfo* _first_failure_details; // Details for the first failure happening during compilation
Expand Down Expand Up @@ -143,6 +144,7 @@ class Compilation: public StackObj {
bool has_fpu_code() const { return _has_fpu_code; }
bool has_unsafe_access() const { return _has_unsafe_access; }
bool has_monitors() const { return _has_monitors; }
bool has_scoped_access() const { return _has_scoped_access; }
bool has_irreducible_loops() const { return _has_irreducible_loops; }
int max_vector_size() const { return 0; }
ciMethod* method() const { return _method; }
Expand Down Expand Up @@ -175,6 +177,7 @@ class Compilation: public StackObj {
void set_would_profile(bool f) { _would_profile = f; }
void set_has_access_indexed(bool f) { _has_access_indexed = f; }
void set_has_monitors(bool f) { _has_monitors = f; }
void set_has_scoped_access(bool f) { _has_scoped_access = f; }
// Add a set of exception handlers covering the given PC offset
void add_exception_handlers_for_pco(int pco, XHandlers* exception_handlers);
// Statistics gathering
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/c1/c1_GraphBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3518,6 +3518,9 @@ static void set_flags_for_inlined_callee(Compilation* compilation, ciMethod* cal
if (callee->is_synchronized() || callee->has_monitor_bytecodes()) {
compilation->set_has_monitors(true);
}
if (callee->is_scoped()) {
compilation->set_has_scoped_access(true);
}
}

bool GraphBuilder::try_inline(ciMethod* callee, bool holder_known, bool ignore_return, Bytecodes::Code bc, Value receiver) {
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/ci/ciEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ void ciEnv::register_method(ciMethod* target,
bool has_unsafe_access,
bool has_wide_vectors,
bool has_monitors,
bool has_scoped_access,
int immediate_oops_patched) {
VM_ENTRY_MARK;
nmethod* nm = nullptr;
Expand Down Expand Up @@ -1124,6 +1125,7 @@ void ciEnv::register_method(ciMethod* target,
nm->set_has_unsafe_access(has_unsafe_access);
nm->set_has_wide_vectors(has_wide_vectors);
nm->set_has_monitors(has_monitors);
nm->set_has_scoped_access(has_scoped_access);
assert(!method->is_synchronized() || nm->has_monitors(), "");

if (entry_bci == InvocationEntryBci) {
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/ci/ciEnv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ class ciEnv : StackObj {
bool has_unsafe_access,
bool has_wide_vectors,
bool has_monitors,
bool has_scoped_access,
int immediate_oops_patched);

// Access to certain well known ciObjects.
Expand Down
8 changes: 8 additions & 0 deletions src/hotspot/share/ci/ciMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,14 @@ bool ciMethod::is_object_initializer() const {
return name() == ciSymbols::object_initializer_name();
}

// ------------------------------------------------------------------
// ciMethod::is_scoped
//
// Return true for methods annotated with @Scoped
bool ciMethod::is_scoped() const {
return get_Method()->is_scoped();
}

// ------------------------------------------------------------------
// ciMethod::has_member_arg
//
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/ci/ciMethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ class ciMethod : public ciMetadata {
bool is_unboxing_method() const;
bool is_vector_method() const;
bool is_object_initializer() const;
bool is_scoped() const;

bool can_be_statically_bound(ciInstanceKlass* context) const;

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/code/nmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,7 @@ void nmethod::init_defaults(CodeBuffer *code_buffer, CodeOffsets* offsets) {
_has_method_handle_invokes = 0;
_has_wide_vectors = 0;
_has_monitors = 0;
_has_scoped_access = 0;
_has_flushed_dependencies = 0;
_is_unlinked = 0;
_load_reported = 0; // jvmti state
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/code/nmethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ class nmethod : public CodeBlob {
_has_method_handle_invokes:1,// Has this method MethodHandle invokes?
_has_wide_vectors:1, // Preserve wide vectors at safepoints
_has_monitors:1, // Fastpath monitor detection for continuations
_has_scoped_access:1, // used by for shared scope closure (scopedMemoryAccess.cpp)
_has_flushed_dependencies:1, // Used for maintenance of dependencies (under CodeCache_lock)
_is_unlinked:1, // mark during class unloading
_load_reported:1; // used by jvmti to track if an event has been posted for this nmethod
Expand Down Expand Up @@ -664,6 +665,9 @@ class nmethod : public CodeBlob {
bool has_monitors() const { return _has_monitors; }
void set_has_monitors(bool z) { _has_monitors = z; }

bool has_scoped_access() const { return _has_scoped_access; }
void set_has_scoped_access(bool z) { _has_scoped_access = z; }

bool has_method_handle_invokes() const { return _has_method_handle_invokes; }
void set_has_method_handle_invokes(bool z) { _has_method_handle_invokes = z; }

Expand Down
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
2 changes: 2 additions & 0 deletions 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,6 +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(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
1 change: 1 addition & 0 deletions src/hotspot/share/opto/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,7 @@ void Compile::Init(bool aliasing) {

set_do_vector_loop(false);
set_has_monitors(false);
set_has_scoped_access(false);

if (AllowVectorizeOnDemand) {
if (has_method() && _directive->VectorizeOption) {
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/opto/compile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ class Compile : public Phase {
// JSR 292
bool _has_method_handle_invokes; // True if this method has MethodHandle invokes.
bool _has_monitors; // Metadata transfered to nmethod to enable Continuations lock-detection fastpath
bool _has_scoped_access; // For shared scope closure
bool _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry
int _loop_opts_cnt; // loop opts round
uint _stress_seed; // Seed for stress testing
Expand Down Expand Up @@ -672,6 +673,8 @@ class Compile : public Phase {
void set_clinit_barrier_on_entry(bool z) { _clinit_barrier_on_entry = z; }
bool has_monitors() const { return _has_monitors; }
void set_has_monitors(bool v) { _has_monitors = v; }
bool has_scoped_access() const { return _has_scoped_access; }
void set_has_scoped_access(bool v) { _has_scoped_access = v; }

// check the CompilerOracle for special behaviours for this compile
bool method_has_option(CompileCommandEnum option) {
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/opto/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3434,6 +3434,7 @@ void PhaseOutput::install_code(ciMethod* target,
has_unsafe_access,
SharedRuntime::is_wide_vector(C->max_vector_size()),
C->has_monitors(),
C->has_scoped_access(),
0);

if (C->log() != nullptr) { // Print code cache state into compiler log
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/opto/parse1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ Parse::Parse(JVMState* caller, ciMethod* parse_method, float expected_uses)
C->set_has_monitors(true);
}

if (parse_method->is_scoped()) {
C->set_has_scoped_access(true);
}

_iter.reset_to_method(method());
C->set_has_loops(C->has_loops() || method()->has_loops());

Expand Down
Loading