OSDN Git Service

Do a type check for knowing if we can inline.
authorNicolas Geoffray <ngeoffray@google.com>
Thu, 4 Jun 2015 17:02:34 +0000 (18:02 +0100)
committerNicolas Geoffray <ngeoffray@google.com>
Thu, 4 Jun 2015 17:04:18 +0000 (18:04 +0100)
Otherwise, we might successfully inline:
((String)nonStringObject).charAt()

Because the lookup of the method is based on the index of charAt,
and not its name.

Change-Id: I72ce802fd50cfb71343197f0a32bb1ef56549097

compiler/optimizing/inliner.cc

index ea613b2..07d0dd6 100644 (file)
@@ -120,6 +120,9 @@ static ArtMethod* FindVirtualOrInterfaceTarget(HInvoke* invoke, ArtMethod* resol
     // Statically knowing that the receiver has an interface type cannot
     // help us find what is the target method.
     return nullptr;
+  } else if (!resolved_method->GetDeclaringClass()->IsAssignableFrom(info.GetTypeHandle().Get())) {
+    // The method that we're trying to call is not in the receiver's class or super classes.
+    return nullptr;
   }
 
   ClassLinker* cl = Runtime::Current()->GetClassLinker();