Prevent entering IMT conflict trampoline with j.l.Object methods.
This ensures that only interface methods enter the trampoline.
Test: 725-imt-conflict-object
Change-Id: Id730d921f213ee0f6d927dea5df69d57be431df0
diff --git a/runtime/interpreter/mterp/nterp.cc b/runtime/interpreter/mterp/nterp.cc
index c14a5ff..36cd675 100644
--- a/runtime/interpreter/mterp/nterp.cc
+++ b/runtime/interpreter/mterp/nterp.cc
@@ -247,8 +247,16 @@
}
if (invoke_type == kInterface) {
- UpdateCache(self, dex_pc_ptr, resolved_method->GetImtIndex());
- return resolved_method->GetImtIndex();
+ if (resolved_method->GetDeclaringClass()->IsObjectClass()) {
+ // Don't update the cache and return a value with high bit set to notify the
+ // interpreter it should do a vtable call instead.
+ DCHECK_LT(resolved_method->GetMethodIndex(), 0x10000);
+ return resolved_method->GetMethodIndex() | (1 << 31);
+ } else {
+ DCHECK(resolved_method->GetDeclaringClass()->IsInterface());
+ UpdateCache(self, dex_pc_ptr, resolved_method->GetImtIndex());
+ return resolved_method->GetImtIndex();
+ }
} else if (resolved_method->GetDeclaringClass()->IsStringClass()
&& !resolved_method->IsStatic()
&& resolved_method->IsConstructor()) {