diff options
-rw-r--r-- | openjdkjvmti/deopt_manager.cc | 7 | ||||
-rw-r--r-- | runtime/instrumentation.cc | 28 | ||||
-rw-r--r-- | runtime/instrumentation.h | 12 | ||||
-rw-r--r-- | runtime/instrumentation_test.cc | 9 |
4 files changed, 12 insertions, 44 deletions
diff --git a/openjdkjvmti/deopt_manager.cc b/openjdkjvmti/deopt_manager.cc index f30a21d04f..6377050d98 100644 --- a/openjdkjvmti/deopt_manager.cc +++ b/openjdkjvmti/deopt_manager.cc @@ -450,6 +450,8 @@ jvmtiError DeoptManager::RemoveDeoptimizeThreadMethods(art::ScopedObjectAccessUn return OK; } +static constexpr const char* kInstrumentationKey = "JVMTI_DeoptRequester"; + void DeoptManager::RemoveDeoptimizationRequester() { art::Thread* self = art::Thread::Current(); art::ScopedThreadStateChange sts(self, art::ThreadState::kSuspended); @@ -458,8 +460,7 @@ void DeoptManager::RemoveDeoptimizationRequester() { deopter_count_--; if (deopter_count_ == 0) { ScopedDeoptimizationContext sdc(self, this); - // TODO Give this a real key. - art::Runtime::Current()->GetInstrumentation()->DisableDeoptimization(""); + art::Runtime::Current()->GetInstrumentation()->DisableDeoptimization(kInstrumentationKey); return; } else { deoptimization_status_lock_.ExclusiveUnlock(self); @@ -478,7 +479,7 @@ void DeoptManager::AddDeoptimizationRequester() { // Enable deoptimization instrumentation->EnableDeoptimization(); // Tell instrumentation we will be deopting single threads. - instrumentation->EnableSingleThreadDeopt(); + instrumentation->EnableSingleThreadDeopt(kInstrumentationKey); } else { deoptimization_status_lock_.ExclusiveUnlock(self); } diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc index 8ef5ef41fc..b7f2c3c537 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -185,8 +185,7 @@ Instrumentation::Instrumentation() deoptimization_enabled_(false), interpreter_handler_table_(kMainHandlerTable), quick_alloc_entry_points_instrumentation_counter_(0), - alloc_entrypoints_instrumented_(false), - can_use_instrumentation_trampolines_(true) { + alloc_entrypoints_instrumented_(false) { } void Instrumentation::InstallStubsForClass(ObjPtr<mirror::Class> klass) { @@ -755,19 +754,6 @@ bool Instrumentation::RequiresInstrumentationInstallation(InstrumentationLevel n return GetCurrentInstrumentationLevel() != new_level; } -void Instrumentation::UpdateInstrumentationLevels(InstrumentationLevel level) { - if (level == InstrumentationLevel::kInstrumentWithInterpreter) { - can_use_instrumentation_trampolines_ = false; - } - if (UNLIKELY(!can_use_instrumentation_trampolines_)) { - for (auto& p : requested_instrumentation_levels_) { - if (p.second == InstrumentationLevel::kInstrumentWithInstrumentationStubs) { - p.second = InstrumentationLevel::kInstrumentWithInterpreter; - } - } - } -} - void Instrumentation::ConfigureStubs(const char* key, InstrumentationLevel desired_level) { // Store the instrumentation level for this key or remove it. if (desired_level == InstrumentationLevel::kInstrumentNothing) { @@ -778,15 +764,12 @@ void Instrumentation::ConfigureStubs(const char* key, InstrumentationLevel desir requested_instrumentation_levels_.Overwrite(key, desired_level); } - UpdateInstrumentationLevels(desired_level); UpdateStubs(); } -void Instrumentation::EnableSingleThreadDeopt() { +void Instrumentation::EnableSingleThreadDeopt(const char* key) { // Single-thread deopt only uses interpreter. - can_use_instrumentation_trampolines_ = false; - UpdateInstrumentationLevels(InstrumentationLevel::kInstrumentWithInterpreter); - UpdateStubs(); + ConfigureStubs(key, InstrumentationLevel::kInstrumentWithInterpreter); } void Instrumentation::UpdateInstrumentationLevel(InstrumentationLevel requested_level) { @@ -800,11 +783,6 @@ void Instrumentation::UpdateStubs() { requested_level = std::max(requested_level, v.second); } - DCHECK(can_use_instrumentation_trampolines_ || - requested_level != InstrumentationLevel::kInstrumentWithInstrumentationStubs) - << "Use trampolines: " << can_use_instrumentation_trampolines_ << " level " - << requested_level; - if (!RequiresInstrumentationInstallation(requested_level)) { // We're already set. return; diff --git a/runtime/instrumentation.h b/runtime/instrumentation.h index a505ce3e6b..1f7ee7fd93 100644 --- a/runtime/instrumentation.h +++ b/runtime/instrumentation.h @@ -545,7 +545,7 @@ class Instrumentation { REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!GetDeoptimizedMethodsLock()); // Sets up instrumentation to allow single thread deoptimization using ForceInterpreterCount. - void EnableSingleThreadDeopt() + void EnableSingleThreadDeopt(const char* key) REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_) REQUIRES(!Locks::thread_list_lock_, !Locks::classlinker_classes_lock_, @@ -603,11 +603,6 @@ class Instrumentation { REQUIRES(!GetDeoptimizedMethodsLock(), !Locks::thread_list_lock_, !Locks::classlinker_classes_lock_); - void UpdateInstrumentationLevels(InstrumentationLevel level) - REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_) - REQUIRES(!GetDeoptimizedMethodsLock(), - !Locks::thread_list_lock_, - !Locks::classlinker_classes_lock_); void UpdateInterpreterHandlerTable() REQUIRES(Locks::mutator_lock_) { /* @@ -771,11 +766,6 @@ class Instrumentation { // alloc_entrypoints_instrumented_ change during suspend points. bool alloc_entrypoints_instrumented_; - // If we can use instrumentation trampolines. After the first time we instrument something with - // the interpreter we can no longer use trampolines because it can lead to stack corruption. - // TODO Figure out a way to remove the need for this. - bool can_use_instrumentation_trampolines_; - friend class InstrumentationTest; // For GetCurrentInstrumentationLevel and ConfigureStubs. friend class InstrumentationStackPopper; // For popping instrumentation frames. friend void InstrumentationInstallStack(Thread*, void*, bool); diff --git a/runtime/instrumentation_test.cc b/runtime/instrumentation_test.cc index cfca51e7cd..d3fa5c8289 100644 --- a/runtime/instrumentation_test.cc +++ b/runtime/instrumentation_test.cc @@ -837,8 +837,7 @@ TEST_F(InstrumentationTest, ConfigureStubs_InterpreterToInstrumentationStubs) { // Configure stubs with instrumentation stubs. CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs); - // Make sure we are still interpreter since going from interpreter->instrumentation is dangerous. - CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, + CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs, 1U); // Check we can disable instrumentation. @@ -864,7 +863,7 @@ TEST_F(InstrumentationTest, // Configure stubs with instrumentation stubs again. CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs); - CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, + CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs, 1U); // Check we can disable instrumentation. @@ -968,9 +967,9 @@ TEST_F(InstrumentationTest, MultiConfigureStubs_InterpreterThenInstrumentationSt CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, 2U); // 1st client requests instrumentation deactivation but 2nd client still needs - // instrumentation stubs. Since we already got interpreter stubs we need to stay there. + // instrumentation stubs. CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing); - CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, + CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs, 1U); // 2nd client requests instrumentation deactivation |