summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2015-02-26 00:34:11 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-02-26 00:34:11 +0000
commit4f9bbe2a654165aedab62041101ae41d54c04e39 (patch)
tree04408947669116247ae202cace66d760004d08c5
parentb491375af0ffa7f0ee534b30d606d8748f7ad15f (diff)
parentc0d5f89d99c55ab63d6757fbd71dbfe95d347c1f (diff)
downloadart-4f9bbe2a654165aedab62041101ae41d54c04e39.zip
art-4f9bbe2a654165aedab62041101ae41d54c04e39.tar.gz
art-4f9bbe2a654165aedab62041101ae41d54c04e39.tar.bz2
Merge "Fix JIT for vmdebug test 99"
-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;
}