diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/driver/compiler_driver.cc | 4 | ||||
| -rw-r--r-- | compiler/driver/compiler_driver_test.cc | 42 |
2 files changed, 46 insertions, 0 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index e823f67d3c..1a4452429e 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -2181,6 +2181,10 @@ class VerifyClassVisitor : public CompilationVisitor { CHECK(klass->ShouldVerifyAtRuntime() || klass->IsVerified() || klass->IsErroneous()) << klass->PrettyDescriptor() << ": state=" << klass->GetStatus(); + // Class has a meaningful status for the compiler now, record it. + ClassReference ref(manager_->GetDexFile(), class_def_index); + manager_->GetCompiler()->RecordClassStatus(ref, klass->GetStatus()); + // It is *very* problematic if there are verification errors in the boot classpath. For example, // we rely on things working OK without verification when the decryption dialog is brought up. // So abort in a debug build if we find this violated. diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc index fa1b3a304a..42ff1e748a 100644 --- a/compiler/driver/compiler_driver_test.cc +++ b/compiler/driver/compiler_driver_test.cc @@ -23,6 +23,7 @@ #include "art_method-inl.h" #include "class_linker-inl.h" #include "common_compiler_test.h" +#include "compiled_class.h" #include "dex_file.h" #include "dex_file_types.h" #include "gc/heap.h" @@ -319,6 +320,47 @@ TEST_F(CompilerDriverProfileTest, ProfileGuidedCompilation) { CheckCompiledMethods(class_loader, "LSecond;", s); } +// Test that a verify only compiler filter updates the CompiledClass map, +// which will be used for OatClass. +class CompilerDriverVerifyTest : public CompilerDriverTest { + protected: + CompilerFilter::Filter GetCompilerFilter() const OVERRIDE { + return CompilerFilter::kVerifyProfile; + } + + void CheckVerifiedClass(jobject class_loader, const std::string& clazz) const { + ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); + Thread* self = Thread::Current(); + ScopedObjectAccess soa(self); + StackHandleScope<1> hs(self); + Handle<mirror::ClassLoader> h_loader( + hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader))); + mirror::Class* klass = class_linker->FindClass(self, clazz.c_str(), h_loader); + ASSERT_NE(klass, nullptr); + EXPECT_TRUE(klass->IsVerified()); + + CompiledClass* compiled_class = compiler_driver_->GetCompiledClass( + ClassReference(&klass->GetDexFile(), klass->GetDexTypeIndex().index_)); + ASSERT_NE(compiled_class, nullptr); + EXPECT_EQ(compiled_class->GetStatus(), mirror::Class::kStatusVerified); + } +}; + +TEST_F(CompilerDriverVerifyTest, VerifyCompilation) { + Thread* self = Thread::Current(); + jobject class_loader; + { + ScopedObjectAccess soa(self); + class_loader = LoadDex("ProfileTestMultiDex"); + } + ASSERT_NE(class_loader, nullptr); + + CompileAll(class_loader); + + CheckVerifiedClass(class_loader, "LMain;"); + CheckVerifiedClass(class_loader, "LSecond;"); +} + // TODO: need check-cast test (when stub complete & we can throw/catch } // namespace art |