Fix JIT for vmdebug test 99
Test was flaky due to JIT re-compiliation after deoptimization
resulting in some invalid PC offsets.
Bug: 17950037
Change-Id: I276c84c918579259ce47ef873892c3c5dcf0c977
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc
index b1d972e..2577391 100644
--- a/compiler/jit/jit_compiler.cc
+++ b/compiler/jit/jit_compiler.cc
@@ -132,7 +132,20 @@
return false;
}
total_time_ += NanoTime() - start_time;
- const bool result = MakeExecutable(compiled_method, h_method.Get());
+ // Don't add the method if we are supposed to be deoptimized.
+ bool result = false;
+ if (!runtime->GetInstrumentation()->AreAllMethodsDeoptimized()) {
+ const void* code = Runtime::Current()->GetClassLinker()->GetOatMethodQuickCodeFor(
+ h_method.Get());
+ if (code != nullptr) {
+ // Already have some compiled code, just use this instead of linking.
+ // TODO: Fix recompilation.
+ h_method->SetEntryPointFromQuickCompiledCode(code);
+ result = true;
+ } else {
+ result = MakeExecutable(compiled_method, h_method.Get());
+ }
+ }
// Remove the compiled method to save memory.
compiler_driver_->RemoveCompiledMethod(method_ref);
return result;