Cleanup enabling / disabling deoptimization support
Enabling deoptimization support is a nop and doesn't need to do
anything. Deoptimize / DeoptimizeEverything install any
instrumentation stubs required.
Disabling deoptimization should uninstall any stubs installed
for deoptimization. We special cased only for interpreter stubs
earlier.
Bug: 206029744
Test: test.py --gtest --run-test
Change-Id: I714ac3f9e05509b1db1a9ef11a8d66420a5394fb
diff --git a/openjdkjvmti/deopt_manager.cc b/openjdkjvmti/deopt_manager.cc
index 6377050..3964596 100644
--- a/openjdkjvmti/deopt_manager.cc
+++ b/openjdkjvmti/deopt_manager.cc
@@ -476,8 +476,6 @@
ScopedDeoptimizationContext sdc(self, this);
art::instrumentation::Instrumentation* instrumentation =
art::Runtime::Current()->GetInstrumentation();
- // Enable deoptimization
- instrumentation->EnableDeoptimization();
// Tell instrumentation we will be deopting single threads.
instrumentation->EnableSingleThreadDeopt(kInstrumentationKey);
} else {
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index 0d038d7..71d48ee 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -184,7 +184,6 @@
have_exception_handled_listeners_(false),
deoptimized_methods_lock_(new ReaderWriterMutex("deoptimized methods lock",
kGenericBottomLock)),
- deoptimization_enabled_(false),
interpreter_handler_table_(kMainHandlerTable),
quick_alloc_entry_points_instrumentation_counter_(0),
alloc_entrypoints_instrumented_(false) {
@@ -1219,20 +1218,10 @@
return IsDeoptimizedMethod(method);
}
-void Instrumentation::EnableDeoptimization() {
- ReaderMutexLock mu(Thread::Current(), *GetDeoptimizedMethodsLock());
- CHECK(IsDeoptimizedMethodsEmpty());
- CHECK_EQ(deoptimization_enabled_, false);
- deoptimization_enabled_ = true;
-}
void Instrumentation::DisableDeoptimization(const char* key) {
- CHECK_EQ(deoptimization_enabled_, true);
- // If we deoptimized everything, undo it.
- InstrumentationLevel level = GetCurrentInstrumentationLevel();
- if (level == InstrumentationLevel::kInstrumentWithInterpreter) {
- UndeoptimizeEverything(key);
- }
+ // Remove any instrumentation support added for deoptimization.
+ ConfigureStubs(key, InstrumentationLevel::kInstrumentNothing);
// Undeoptimized selected methods.
while (true) {
ArtMethod* method;
@@ -1246,7 +1235,6 @@
}
Undeoptimize(method);
}
- deoptimization_enabled_ = false;
}
// Indicates if instrumentation should notify method enter/exit events to the listeners.
@@ -1254,17 +1242,15 @@
if (!HasMethodEntryListeners() && !HasMethodExitListeners()) {
return false;
}
- return !deoptimization_enabled_ && !InterpreterStubsInstalled();
+ return !InterpreterStubsInstalled();
}
void Instrumentation::DeoptimizeEverything(const char* key) {
- CHECK(deoptimization_enabled_);
ConfigureStubs(key, InstrumentationLevel::kInstrumentWithInterpreter);
}
void Instrumentation::UndeoptimizeEverything(const char* key) {
CHECK(InterpreterStubsInstalled());
- CHECK(deoptimization_enabled_);
ConfigureStubs(key, InstrumentationLevel::kInstrumentNothing);
}
diff --git a/runtime/instrumentation.h b/runtime/instrumentation.h
index 5209379..276d1ca 100644
--- a/runtime/instrumentation.h
+++ b/runtime/instrumentation.h
@@ -226,10 +226,6 @@
void RemoveListener(InstrumentationListener* listener, uint32_t events)
REQUIRES(Locks::mutator_lock_, !Locks::thread_list_lock_, !Locks::classlinker_classes_lock_);
- // Deoptimization.
- void EnableDeoptimization()
- REQUIRES(Locks::mutator_lock_)
- REQUIRES(!GetDeoptimizedMethodsLock());
// Calls UndeoptimizeEverything which may visit class linker classes through ConfigureStubs.
void DisableDeoptimization(const char* key)
REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_)
@@ -240,10 +236,6 @@
}
bool ShouldNotifyMethodEnterExitEvents() const REQUIRES_SHARED(Locks::mutator_lock_);
- bool CanDeoptimize() {
- return deoptimization_enabled_;
- }
-
// Executes everything with interpreter.
void DeoptimizeEverything(const char* key)
REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_)
@@ -748,7 +740,6 @@
// only.
mutable std::unique_ptr<ReaderWriterMutex> deoptimized_methods_lock_ BOTTOM_MUTEX_ACQUIRED_AFTER;
std::unordered_set<ArtMethod*> deoptimized_methods_ GUARDED_BY(GetDeoptimizedMethodsLock());
- bool deoptimization_enabled_;
// Current interpreter handler table. This is updated each time the thread state flags are
// modified.
diff --git a/runtime/instrumentation_test.cc b/runtime/instrumentation_test.cc
index d3fa5c8..37afcd1 100644
--- a/runtime/instrumentation_test.cc
+++ b/runtime/instrumentation_test.cc
@@ -259,7 +259,7 @@
EXPECT_FALSE(DidListenerReceiveEvent(listener, instrumentation_event, with_object));
}
- void DeoptimizeMethod(Thread* self, ArtMethod* method, bool enable_deoptimization)
+ void DeoptimizeMethod(Thread* self, ArtMethod* method)
REQUIRES_SHARED(Locks::mutator_lock_) {
Runtime* runtime = Runtime::Current();
instrumentation::Instrumentation* instrumentation = runtime->GetInstrumentation();
@@ -268,9 +268,6 @@
gc::kGcCauseInstrumentation,
gc::kCollectorTypeInstrumentation);
ScopedSuspendAll ssa("Single method deoptimization");
- if (enable_deoptimization) {
- instrumentation->EnableDeoptimization();
- }
instrumentation->Deoptimize(method);
}
@@ -290,7 +287,7 @@
}
}
- void DeoptimizeEverything(Thread* self, const char* key, bool enable_deoptimization)
+ void DeoptimizeEverything(Thread* self, const char* key)
REQUIRES_SHARED(Locks::mutator_lock_) {
Runtime* runtime = Runtime::Current();
instrumentation::Instrumentation* instrumentation = runtime->GetInstrumentation();
@@ -299,9 +296,6 @@
gc::kGcCauseInstrumentation,
gc::kCollectorTypeInstrumentation);
ScopedSuspendAll ssa("Full deoptimization");
- if (enable_deoptimization) {
- instrumentation->EnableDeoptimization();
- }
instrumentation->DeoptimizeEverything(key);
}
@@ -633,7 +627,7 @@
EXPECT_FALSE(instr->AreAllMethodsDeoptimized());
EXPECT_FALSE(instr->IsDeoptimized(method_to_deoptimize));
- DeoptimizeMethod(soa.Self(), method_to_deoptimize, true);
+ DeoptimizeMethod(soa.Self(), method_to_deoptimize);
EXPECT_FALSE(instr->AreAllMethodsDeoptimized());
EXPECT_TRUE(instr->AreExitStubsInstalled());
@@ -653,7 +647,7 @@
EXPECT_FALSE(instr->AreAllMethodsDeoptimized());
constexpr const char* instrumentation_key = "FullDeoptimization";
- DeoptimizeEverything(soa.Self(), instrumentation_key, true);
+ DeoptimizeEverything(soa.Self(), instrumentation_key);
EXPECT_TRUE(instr->AreAllMethodsDeoptimized());
EXPECT_TRUE(instr->AreExitStubsInstalled());
@@ -682,7 +676,7 @@
EXPECT_FALSE(instr->AreAllMethodsDeoptimized());
EXPECT_FALSE(instr->IsDeoptimized(method_to_deoptimize));
- DeoptimizeMethod(soa.Self(), method_to_deoptimize, true);
+ DeoptimizeMethod(soa.Self(), method_to_deoptimize);
// Deoptimizing a method does not change instrumentation level.
EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentNothing,
GetCurrentInstrumentationLevel());
@@ -691,7 +685,7 @@
EXPECT_TRUE(instr->IsDeoptimized(method_to_deoptimize));
constexpr const char* instrumentation_key = "MixedDeoptimization";
- DeoptimizeEverything(soa.Self(), instrumentation_key, false);
+ DeoptimizeEverything(soa.Self(), instrumentation_key);
EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter,
GetCurrentInstrumentationLevel());
EXPECT_TRUE(instr->AreAllMethodsDeoptimized());
diff --git a/test/597-deopt-new-string/deopt.cc b/test/597-deopt-new-string/deopt.cc
index 572be28..06dbca6 100644
--- a/test/597-deopt-new-string/deopt.cc
+++ b/test/597-deopt-new-string/deopt.cc
@@ -36,12 +36,6 @@
gc::kCollectorTypeInstrumentation);
// We need to suspend mutator threads first.
ScopedSuspendAll ssa(__FUNCTION__);
- static bool first = true;
- if (first) {
- // We need to enable deoptimization once in order to call DeoptimizeEverything().
- Runtime::Current()->GetInstrumentation()->EnableDeoptimization();
- first = false;
- }
Runtime::Current()->GetInstrumentation()->DeoptimizeEverything("test");
}