Make instrumentation trampoline able to jump to jit code
In order to get the benefit of the instrumentation trampoline it must
be able to jump to jit code. This patch adds support for doing that
and adds code to ensure that we will not be jumping back and forth
between the trampoline and the interpreter all the time if the jit has
not yet compiled the current method.
Note we also disable the jit-gc when turning on these trampolines
since otherwise we could end up either sending instrumentation events
multiple times or running uninitialized memory.
Bug: 110263880
Test: ./test/testrunner/testrunner.py --host --runtime-option=-Xplugin:libtracefast-trampolined.so
Test: ./test/testrunner/testrunner.py --host --runtime-option=-Xplugin:libtracefast-trampolined.so --runtime-option=-Xjitthreshhold:0
Test: ./test.py --host
Change-Id: Ie6e92ec6367452fe4fde24d520d808b7af91d1b5
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 4a5da1f..966d636 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2811,6 +2811,7 @@
}
bool ClassLinker::ShouldUseInterpreterEntrypoint(ArtMethod* method, const void* quick_code) {
+ ScopedAssertNoThreadSuspension sants(__FUNCTION__);
if (UNLIKELY(method->IsNative() || method->IsProxyMethod())) {
return false;
}
@@ -2840,6 +2841,12 @@
return true;
}
+ if (quick_code == GetQuickInstrumentationEntryPoint()) {
+ const void* instr_target = instr->GetCodeForInvoke(method);
+ DCHECK_NE(instr_target, GetQuickInstrumentationEntryPoint()) << method->PrettyMethod();
+ return ShouldUseInterpreterEntrypoint(method, instr_target);
+ }
+
if (runtime->IsJavaDebuggable()) {
// For simplicity, we ignore precompiled code and go to the interpreter
// assuming we don't already have jitted code.
@@ -2864,6 +2871,7 @@
}
void ClassLinker::FixupStaticTrampolines(ObjPtr<mirror::Class> klass) {
+ ScopedAssertNoThreadSuspension sants(__FUNCTION__);
DCHECK(klass->IsInitialized()) << klass->PrettyDescriptor();
if (klass->NumDirectMethods() == 0) {
return; // No direct methods => no static methods.
@@ -2923,6 +2931,7 @@
ArtMethod* method,
const OatFile::OatClass* oat_class,
uint32_t class_def_method_index) REQUIRES_SHARED(Locks::mutator_lock_) {
+ ScopedAssertNoThreadSuspension sants(__FUNCTION__);
Runtime* const runtime = Runtime::Current();
if (runtime->IsAotCompiler()) {
// The following code only applies to a non-compiler runtime.