From 042fd00295d21f936ba7a8c16915ce678970e658 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Mon, 22 Jun 2015 11:06:43 +0100 Subject: Revert "Revert "Use IsAssignableFrom instead of IsSubclass for robustness."" Don't use IsAssignableFrom, but check beforehand if the referrer is an interface. Otherwise, we are being too aggressive on removing clinit checks on interfaces (being a subclass doesn't imply the interface has been initialized). bug:21870666 This reverts commit 463580ca5a1e75e27ad0207537ffc6252091326a. (cherry picked from commit b783b408112d1797da646f576a40f94bcb5162f3) Change-Id: Ida03f453c9b0d4dda87a5696098f9ffbd69a3aa3 --- compiler/driver/compiler_driver-inl.h | 6 ++++-- compiler/optimizing/builder.cc | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'compiler') diff --git a/compiler/driver/compiler_driver-inl.h b/compiler/driver/compiler_driver-inl.h index e0c56fc..633bc1b 100644 --- a/compiler/driver/compiler_driver-inl.h +++ b/compiler/driver/compiler_driver-inl.h @@ -250,8 +250,10 @@ inline bool CompilerDriver::CanAssumeClassIsInitialized(mirror::Class* klass) { inline bool CompilerDriver::CanReferrerAssumeClassIsInitialized(mirror::Class* referrer_class, mirror::Class* klass) { - return (referrer_class != nullptr && referrer_class->IsSubClass(klass)) || - CanAssumeClassIsInitialized(klass); + return (referrer_class != nullptr + && !referrer_class->IsInterface() + && referrer_class->IsSubClass(klass)) + || CanAssumeClassIsInitialized(klass); } inline bool CompilerDriver::IsStaticFieldsClassInitialized(mirror::Class* referrer_class, diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc index 1a5f27c..ed39923 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -698,7 +698,8 @@ bool HGraphBuilder::BuildInvoke(const Instruction& instruction, &storage_index); } - if (outer_class.Get()->IsSubClass(resolved_method->GetDeclaringClass())) { + if (!outer_class->IsInterface() + && outer_class->IsSubClass(resolved_method->GetDeclaringClass())) { // If the outer class is the declaring class or a subclass // of the declaring class, no class initialization is needed // before the static method call. -- cgit v1.1