diff options
author | 2016-06-07 16:26:48 +0000 | |
---|---|---|
committer | 2016-06-07 16:26:48 +0000 | |
commit | 83968f1a0949972e728d2302a26f9ae98dff34b2 (patch) | |
tree | 84d7b664e0a01948227ec9697510e3f9339f7a65 /compiler/optimizing/optimizing_compiler.cc | |
parent | 4fb652a5ca96cdefa6dca6fe739f1ea89d1bb3e4 (diff) | |
parent | 3aaf9645639ff56fbfe49a981242cbda01d6796e (diff) |
Merge "Revert "Revert "Fix ArtMethod::GetInvokeType for static methods on interfaces."""
Diffstat (limited to 'compiler/optimizing/optimizing_compiler.cc')
-rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 37197af460..c9a4bfe987 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -321,6 +321,7 @@ class OptimizingCompiler FINAL : public Compiler { jobject class_loader, const DexFile& dex_file, Handle<mirror::DexCache> dex_cache, + ArtMethod* method, bool osr) const; std::unique_ptr<OptimizingCompilerStats> compilation_stats_; @@ -614,6 +615,7 @@ CodeGenerator* OptimizingCompiler::TryCompile(ArenaAllocator* arena, jobject class_loader, const DexFile& dex_file, Handle<mirror::DexCache> dex_cache, + ArtMethod* method, bool osr) const { MaybeRecordStat(MethodCompilationStat::kAttemptCompilation); CompilerDriver* compiler_driver = GetCompilerDriver(); @@ -679,17 +681,30 @@ CodeGenerator* OptimizingCompiler::TryCompile(ArenaAllocator* arena, osr); const uint8_t* interpreter_metadata = nullptr; - { + if (method == nullptr) { ScopedObjectAccess soa(Thread::Current()); StackHandleScope<1> hs(soa.Self()); Handle<mirror::ClassLoader> loader(hs.NewHandle( soa.Decode<mirror::ClassLoader*>(class_loader))); - ArtMethod* art_method = compiler_driver->ResolveMethod( + method = compiler_driver->ResolveMethod( soa, dex_cache, loader, &dex_compilation_unit, method_idx, invoke_type); - // We may not get a method, for example if its class is erroneous. - if (art_method != nullptr) { - graph->SetArtMethod(art_method); - interpreter_metadata = art_method->GetQuickenedInfo(); + } + // For AOT compilation, we may not get a method, for example if its class is erroneous. + // JIT should always have a method. + DCHECK(Runtime::Current()->IsAotCompiler() || method != nullptr); + if (method != nullptr) { + graph->SetArtMethod(method); + ScopedObjectAccess soa(Thread::Current()); + interpreter_metadata = method->GetQuickenedInfo(); + uint16_t type_index = method->GetDeclaringClass()->GetDexTypeIndex(); + + // Update the dex cache if the type is not in it yet. Note that under AOT, + // the verifier must have set it, but under JIT, there's no guarantee, as we + // don't necessarily run the verifier. + // The compiler and the compiler driver assume the compiling class is + // in the dex cache. + if (dex_cache->GetResolvedType(type_index) == nullptr) { + dex_cache->SetResolvedType(type_index, method->GetDeclaringClass()); } } @@ -798,6 +813,7 @@ CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item, jclass_loader, dex_file, dex_cache, + nullptr, /* osr */ false)); if (codegen.get() != nullptr) { MaybeRecordStat(MethodCompilationStat::kCompiled); @@ -884,6 +900,7 @@ bool OptimizingCompiler::JitCompile(Thread* self, jclass_loader, *dex_file, dex_cache, + method, osr)); if (codegen.get() == nullptr) { return false; |