ART: Conditionally install Dbg class callbacks
Temporary allocations in the dispatch code are unnecessary when they
end up in disabled code. Instead follow the example of the method
inspection callback and only add the callback when the debugger is
actually active.
Test: m test-art-host
Test: atest CtsJdwpTestCases
Change-Id: I750f2df475400147b1d569f463228d436aa3ae5a
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 914a750..4cc3583 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -698,7 +698,8 @@
}
instrumentation_events_ = 0;
Runtime::DoAndMaybeSwitchInterpreter([=](){ gDebuggerActive = true; });
- Runtime::Current()->GetRuntimeCallbacks()->AddMethodInspectionCallback(&gDebugActiveCallback);
+ runtime->GetRuntimeCallbacks()->AddClassLoadCallback(Dbg::GetClassLoadCallback());
+ runtime->GetRuntimeCallbacks()->AddMethodInspectionCallback(&gDebugActiveCallback);
LOG(INFO) << "Debugger is active";
}
@@ -736,7 +737,8 @@
runtime->GetInstrumentation()->DisableDeoptimization(kDbgInstrumentationKey);
}
Runtime::DoAndMaybeSwitchInterpreter([=](){ gDebuggerActive = false; });
- Runtime::Current()->GetRuntimeCallbacks()->RemoveMethodInspectionCallback(
+ runtime->GetRuntimeCallbacks()->RemoveClassLoadCallback(Dbg::GetClassLoadCallback());
+ runtime->GetRuntimeCallbacks()->RemoveMethodInspectionCallback(
&gDebugActiveCallback);
}
}
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index ad8ded4..d8c68e6 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1398,7 +1398,6 @@
}
}
callbacks_->AddThreadLifecycleCallback(Dbg::GetThreadLifecycleCallback());
- callbacks_->AddClassLoadCallback(Dbg::GetClassLoadCallback());
jit_options_.reset(jit::JitOptions::CreateFromRuntimeArguments(runtime_options));
if (IsAotCompiler()) {