summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2015-02-25 13:22:57 -0800
committerMathieu Chartier <mathieuc@google.com>2015-02-25 15:03:03 -0800
commitc0d5f89d99c55ab63d6757fbd71dbfe95d347c1f (patch)
treedbee9449a109e88237205a68aba9f445d7e3e91d
parent8db3d76ba7061da80f5eb58079830c796e4dea61 (diff)
downloadart-c0d5f89d99c55ab63d6757fbd71dbfe95d347c1f.zip
art-c0d5f89d99c55ab63d6757fbd71dbfe95d347c1f.tar.gz
art-c0d5f89d99c55ab63d6757fbd71dbfe95d347c1f.tar.bz2
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
-rw-r--r--compiler/dex/verification_results.cc7
-rw-r--r--compiler/jit/jit_compiler.cc15
-rw-r--r--runtime/class_linker.cc22
3 files changed, 30 insertions, 14 deletions
diff --git a/compiler/dex/verification_results.cc b/compiler/dex/verification_results.cc
index 51a3d84..150bdac 100644
--- a/compiler/dex/verification_results.cc
+++ b/compiler/dex/verification_results.cc
@@ -71,8 +71,11 @@ bool VerificationResults::ProcessVerifiedMethod(verifier::MethodVerifier* method
DCHECK_EQ(it->second->GetSafeCastSet().size(), verified_method->GetSafeCastSet().size());
}
DCHECK_EQ(it->second->GetDexGcMap().size(), verified_method->GetDexGcMap().size());
- delete it->second;
- verified_methods_.erase(it);
+ // Delete the new verified method since there was already an existing one registered. It
+ // is unsafe to replace the existing one since the JIT may be using it to generate a
+ // native GC map.
+ delete verified_method;
+ return true;
}
verified_methods_.Put(ref, verified_method);
DCHECK(verified_methods_.find(ref) != verified_methods_.end());
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 @@ bool JitCompiler::CompileMethod(Thread* self, mirror::ArtMethod* method) {
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;
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index f28253a..ee5eefb 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2520,16 +2520,16 @@ const void* ClassLinker::GetQuickOatCodeFor(mirror::ArtMethod* method) {
return GetQuickProxyInvokeHandler();
}
bool found;
- jit::Jit* const jit = Runtime::Current()->GetJit();
- if (jit != nullptr) {
- auto* code = jit->GetCodeCache()->GetCodeFor(method);
+ OatFile::OatMethod oat_method = FindOatMethodFor(method, &found);
+ if (found) {
+ auto* code = oat_method.GetQuickCode();
if (code != nullptr) {
return code;
}
}
- OatFile::OatMethod oat_method = FindOatMethodFor(method, &found);
- if (found) {
- auto* code = oat_method.GetQuickCode();
+ jit::Jit* const jit = Runtime::Current()->GetJit();
+ if (jit != nullptr) {
+ auto* code = jit->GetCodeCache()->GetCodeFor(method);
if (code != nullptr) {
return code;
}
@@ -2545,6 +2545,11 @@ const void* ClassLinker::GetOatMethodQuickCodeFor(mirror::ArtMethod* method) {
if (method->IsNative() || method->IsAbstract() || method->IsProxyMethod()) {
return nullptr;
}
+ bool found;
+ OatFile::OatMethod oat_method = FindOatMethodFor(method, &found);
+ if (found) {
+ return oat_method.GetQuickCode();
+ }
jit::Jit* jit = Runtime::Current()->GetJit();
if (jit != nullptr) {
auto* code = jit->GetCodeCache()->GetCodeFor(method);
@@ -2552,11 +2557,6 @@ const void* ClassLinker::GetOatMethodQuickCodeFor(mirror::ArtMethod* method) {
return code;
}
}
- bool found;
- OatFile::OatMethod oat_method = FindOatMethodFor(method, &found);
- if (found) {
- return oat_method.GetQuickCode();
- }
return nullptr;
}