OSDN Git Service

Revert "Revert "Fix ArtMethod::GetInvokeType for static methods on interfaces.""
authorNicolas Geoffray <ngeoffray@google.com>
Tue, 7 Jun 2016 14:14:37 +0000 (14:14 +0000)
committerNicolas Geoffray <ngeoffray@google.com>
Tue, 7 Jun 2016 16:29:50 +0000 (17:29 +0100)
bug:29089267
bug:27521545

We were hitting a compiler DCHECK that a class would never require to
do access checks on itself. The reason was that the compiler driver
was not trying to resolve a type, but instead relied on the verifier
for pre-populating the dex cache. However, the verifier doesn't
necessarily run in JIT mode.

This reverts commit 12abcbd950bd0ff4528e2e0d27ca5e881c7b0467.

(cherry picked from commit 3aaf9645639ff56fbfe49a981242cbda01d6796e)

Change-Id: I2f0de6e4f00f336dc61b2378054fb6d27a7298d0

compiler/optimizing/optimizing_compiler.cc

index 0e0a30b..c9a4bfe 100644 (file)
@@ -696,6 +696,16 @@ CodeGenerator* OptimizingCompiler::TryCompile(ArenaAllocator* arena,
     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());
+    }
   }
 
   std::unique_ptr<CodeGenerator> codegen(