summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_builder.cc
diff options
context:
space:
mode:
authorAart Bik <ajcbik@google.com>2016-04-04 17:28:59 -0700
committerNicolas Geoffray <ngeoffray@google.com>2016-05-06 13:53:29 +0100
commitf663e341c550d1aa6f8f587d0ae0dbf7d254ff55 (patch)
treecc919e9fb060ff73bbe5bdee8fdac6fc926a52ae /compiler/optimizing/instruction_builder.cc
parent4e377e58066ccef401276d7d0985521e5e63d1fb (diff)
Workaround invokesuper underspecified behavior.
The verifier allows invokesuper on a class unrelated to the referring class. However, the runtime uses the vtable of the super class of the referring class to lookup the ArtMethod. Since the receiver has no relation to the referring class, this lead to either jumping to a wrong method, or "luckily" throw a NoSuchMethodError if the vtable index is out of bounds of the super class of the referring class. This changes the runtime behavior to always throw NoSuchMethodError when hitting such invokesuper. Also, we make the verifier consistent with the runtime by treating such calls unresolved. bug=27627004 Change-Id: I68486501a9625f91679078c5a980b39974ddbf1c
Diffstat (limited to 'compiler/optimizing/instruction_builder.cc')
-rw-r--r--compiler/optimizing/instruction_builder.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index a834216d0c..aaddc01f1f 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -721,6 +721,11 @@ ArtMethod* HInstructionBuilder::ResolveMethod(uint16_t method_idx, InvokeType in
DCHECK(Runtime::Current()->IsAotCompiler());
return nullptr;
}
+ if (!methods_class->IsAssignableFrom(compiling_class.Get())) {
+ // We cannot statically determine the target method. The runtime will throw a
+ // NoSuchMethodError on this one.
+ return nullptr;
+ }
ArtMethod* actual_method;
if (methods_class->IsInterface()) {
actual_method = methods_class->FindVirtualMethodForInterfaceSuper(