diff options
| author | 2017-04-19 14:32:52 +0000 | |
|---|---|---|
| committer | 2017-04-19 14:32:53 +0000 | |
| commit | 26013c945c0f34917b7bd93c21e54baeecb73c85 (patch) | |
| tree | 58fdc14b86f38200979c1f8a99d4b72a65a2ab51 | |
| parent | 275ece38c1feb61eb1d964d22f783936ea42f374 (diff) | |
| parent | fbc9041636dcb1b8567317daee4cc687205683b8 (diff) | |
Merge "Record class status after verification." into oc-dev
| -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 35aa1eef2d..5b9ffb79b6 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" @@ -322,6 +323,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 |