Fix longstanding deopt issue not using the right deopt type.
Also add comments for hotness entrypoints.
Test: test.py
Bug: 203253172
Change-Id: I68bc195b3ff5db13997a47fbb5e755d888e1dc04
diff --git a/runtime/entrypoints/quick/quick_thread_entrypoints.cc b/runtime/entrypoints/quick/quick_thread_entrypoints.cc
index 64be926..d8c1ee2 100644
--- a/runtime/entrypoints/quick/quick_thread_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_thread_entrypoints.cc
@@ -30,6 +30,12 @@
extern "C" void artCompileOptimized(ArtMethod* method, Thread* self)
REQUIRES_SHARED(Locks::mutator_lock_) {
ScopedQuickEntrypointChecks sqec(self);
+ // It is important this method is not suspended due to:
+ // * It is called on entry, and object parameters are in locations that are
+ // not marked in the stack map.
+ // * Async deoptimization does not expect runtime methods other than the
+ // suspend entrypoint before executing the first instruction of a Java
+ // method.
ScopedAssertNoThreadSuspension sants("Enqueuing optimized compilation");
Runtime::Current()->GetJit()->EnqueueOptimizedCompilation(method, self);
}
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 5f687ce..ab9825b 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -644,7 +644,7 @@
deopt_frame,
result,
from_code,
- DeoptimizationMethodType::kDefault);
+ method_type);
}
extern "C" uint64_t artQuickToInterpreterBridge(ArtMethod* method, Thread* self, ArtMethod** sp)
diff --git a/runtime/interpreter/mterp/nterp.cc b/runtime/interpreter/mterp/nterp.cc
index 4fe4e15..009f9bc 100644
--- a/runtime/interpreter/mterp/nterp.cc
+++ b/runtime/interpreter/mterp/nterp.cc
@@ -725,6 +725,10 @@
extern "C" jit::OsrData* NterpHotMethod(ArtMethod* method, uint16_t* dex_pc_ptr, uint32_t* vregs)
REQUIRES_SHARED(Locks::mutator_lock_) {
+ // It is important this method is not suspended because it can be called on
+ // method entry and async deoptimization does not expect runtime methods other than the
+ // suspend entrypoint before executing the first instruction of a Java
+ // method.
ScopedAssertNoThreadSuspension sants("In nterp");
Runtime* runtime = Runtime::Current();
method->ResetCounter(runtime->GetJITOptions()->GetWarmupThreshold());