diff options
| -rw-r--r-- | compiler/driver/compiler_driver.cc | 2 | ||||
| -rw-r--r-- | oatdump/oatdump.cc | 2 | ||||
| -rw-r--r-- | runtime/verifier/method_verifier.cc | 40 | ||||
| -rw-r--r-- | runtime/verifier/method_verifier.h | 12 |
4 files changed, 27 insertions, 29 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 39f01d85a6..b5bc2fb116 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -2289,7 +2289,7 @@ class VerifyClassVisitor : public CompilationVisitor { &dex_file, dex_cache, class_loader, - &class_def, + class_def, Runtime::Current()->GetCompilerCallbacks(), true /* allow soft failures */, log_level_, diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc index 36421ff9c7..c87a18b4ca 100644 --- a/oatdump/oatdump.cc +++ b/oatdump/oatdump.cc @@ -1268,7 +1268,7 @@ class OatDumper { DCHECK(options_.class_loader_ != nullptr); return verifier::MethodVerifier::VerifyMethodAndDump( soa.Self(), vios, dex_method_idx, dex_file, dex_cache, *options_.class_loader_, - &class_def, code_item, nullptr, method_access_flags); + class_def, code_item, nullptr, method_access_flags); } return nullptr; diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index 2259b41adf..589e71cf22 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -159,7 +159,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(Thread* self, &dex_file, dex_cache, class_loader, - class_def, + *class_def, callbacks, allow_soft_failures, log_level, @@ -190,7 +190,7 @@ template <bool kDirect> MethodVerifier::FailureData MethodVerifier::VerifyMethods(Thread* self, ClassLinker* linker, const DexFile* dex_file, - const DexFile::ClassDef* class_def, + const DexFile::ClassDef& class_def, ClassDataItemIterator* it, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, @@ -214,7 +214,7 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethods(Thread* self, continue; } previous_method_idx = method_idx; - InvokeType type = it->GetMethodInvokeType(*class_def); + InvokeType type = it->GetMethodInvokeType(class_def); ArtMethod* method = linker->ResolveMethod<ClassLinker::kNoICCECheckForCache>( *dex_file, method_idx, dex_cache, class_loader, nullptr, type); if (method == nullptr) { @@ -247,7 +247,7 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethods(Thread* self, } else { // If we didn't log a hard failure before, print the header of the message. *error_string += "Verifier rejected class "; - *error_string += PrettyDescriptor(dex_file->GetClassDescriptor(*class_def)); + *error_string += PrettyDescriptor(dex_file->GetClassDescriptor(class_def)); *error_string += ":"; } *error_string += " "; @@ -264,23 +264,22 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(Thread* self, const DexFile* dex_file, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, - const DexFile::ClassDef* class_def, + const DexFile::ClassDef& class_def, CompilerCallbacks* callbacks, bool allow_soft_failures, LogSeverity log_level, std::string* error) { - DCHECK(class_def != nullptr); ScopedTrace trace(__FUNCTION__); // A class must not be abstract and final. - if ((class_def->access_flags_ & (kAccAbstract | kAccFinal)) == (kAccAbstract | kAccFinal)) { + if ((class_def.access_flags_ & (kAccAbstract | kAccFinal)) == (kAccAbstract | kAccFinal)) { *error = "Verifier rejected class "; - *error += PrettyDescriptor(dex_file->GetClassDescriptor(*class_def)); + *error += PrettyDescriptor(dex_file->GetClassDescriptor(class_def)); *error += ": class is abstract and final."; return kHardFailure; } - const uint8_t* class_data = dex_file->GetClassData(*class_def); + const uint8_t* class_data = dex_file->GetClassData(class_def); if (class_data == nullptr) { // empty class, probably a marker interface return kNoFailure; @@ -327,7 +326,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(Thread* self, // warning. std::string tmp = StringPrintf("Class %s failed lock verification and will run slower.", - PrettyDescriptor(dex_file->GetClassDescriptor(*class_def)).c_str()); + PrettyDescriptor(dex_file->GetClassDescriptor(class_def)).c_str()); if (!gPrintedDxMonitorText) { tmp = tmp + "\nCommon causes for lock verification issues are non-optimized dex code\n" "and incorrect proguard optimizations."; @@ -355,7 +354,7 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethod(Thread* self, const DexFile* dex_file, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, - const DexFile::ClassDef* class_def, + const DexFile::ClassDef& class_def, const DexFile::CodeItem* code_item, ArtMethod* method, uint32_t method_access_flags, @@ -436,7 +435,7 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethod(Thread* self, if (callbacks != nullptr) { // Let the interested party know that we failed the class. - ClassReference ref(dex_file, dex_file->GetIndexForClassDef(*class_def)); + ClassReference ref(dex_file, dex_file->GetIndexForClassDef(class_def)); callbacks->ClassRejected(ref); } } @@ -463,7 +462,7 @@ MethodVerifier* MethodVerifier::VerifyMethodAndDump(Thread* self, const DexFile* dex_file, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, - const DexFile::ClassDef* class_def, + const DexFile::ClassDef& class_def, const DexFile::CodeItem* code_item, ArtMethod* method, uint32_t method_access_flags) { @@ -499,7 +498,7 @@ MethodVerifier::MethodVerifier(Thread* self, const DexFile* dex_file, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, - const DexFile::ClassDef* class_def, + const DexFile::ClassDef& class_def, const DexFile::CodeItem* code_item, uint32_t dex_method_idx, ArtMethod* method, @@ -544,7 +543,6 @@ MethodVerifier::MethodVerifier(Thread* self, is_constructor_(false), link_(nullptr) { self->PushVerifier(this); - DCHECK(class_def != nullptr); } MethodVerifier::~MethodVerifier() { @@ -561,7 +559,7 @@ void MethodVerifier::FindLocksAtDexPc(ArtMethod* m, uint32_t dex_pc, m->GetDexFile(), dex_cache, class_loader, - &m->GetClassDef(), + m->GetClassDef(), m->GetCodeItem(), m->GetDexMethodIndex(), m, @@ -616,7 +614,7 @@ ArtField* MethodVerifier::FindAccessedFieldAtDexPc(ArtMethod* m, uint32_t dex_pc m->GetDexFile(), dex_cache, class_loader, - &m->GetClassDef(), + m->GetClassDef(), m->GetCodeItem(), m->GetDexMethodIndex(), m, @@ -656,7 +654,7 @@ ArtMethod* MethodVerifier::FindInvokedMethodAtDexPc(ArtMethod* m, uint32_t dex_p m->GetDexFile(), dex_cache, class_loader, - &m->GetClassDef(), + m->GetClassDef(), m->GetCodeItem(), m->GetDexMethodIndex(), m, @@ -761,7 +759,7 @@ bool MethodVerifier::Verify() { return false; } } - if ((class_def_->GetJavaAccessFlags() & kAccInterface) != 0) { + if ((class_def_.GetJavaAccessFlags() & kAccInterface) != 0) { // Interface methods must be public and abstract (if default methods are disabled). uint32_t kRequired = kAccPublic; if ((method_access_flags_ & kRequired) != kRequired) { @@ -792,7 +790,7 @@ bool MethodVerifier::Verify() { return false; } - if ((class_def_->GetJavaAccessFlags() & kAccInterface) != 0) { + if ((class_def_.GetJavaAccessFlags() & kAccInterface) != 0) { // Interfaces may always have static initializers for their fields. If we are running with // default methods enabled we also allow other public, static, non-final methods to have code. // Otherwise that is the only type of method allowed. @@ -4023,7 +4021,7 @@ ArtMethod* MethodVerifier::VerifyInvocationArgs( } if (reference_class->IsInterface()) { // TODO Can we verify anything else. - if (class_idx == class_def_->class_idx_) { + if (class_idx == class_def_.class_idx_) { Fail(VERIFY_ERROR_CLASS_CHANGE) << "Cannot invoke-super on self as interface"; return nullptr; } diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h index e838900d19..d4e12f7b06 100644 --- a/runtime/verifier/method_verifier.h +++ b/runtime/verifier/method_verifier.h @@ -159,7 +159,7 @@ class MethodVerifier { const DexFile* dex_file, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, - const DexFile::ClassDef* class_def, + const DexFile::ClassDef& class_def, CompilerCallbacks* callbacks, bool allow_soft_failures, LogSeverity log_level, @@ -172,7 +172,7 @@ class MethodVerifier { const DexFile* dex_file, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, - const DexFile::ClassDef* class_def, + const DexFile::ClassDef& class_def, const DexFile::CodeItem* code_item, ArtMethod* method, uint32_t method_access_flags) REQUIRES_SHARED(Locks::mutator_lock_); @@ -283,7 +283,7 @@ class MethodVerifier { const DexFile* dex_file, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, - const DexFile::ClassDef* class_def, + const DexFile::ClassDef& class_def, const DexFile::CodeItem* code_item, uint32_t method_idx, ArtMethod* method, @@ -330,7 +330,7 @@ class MethodVerifier { static FailureData VerifyMethods(Thread* self, ClassLinker* linker, const DexFile* dex_file, - const DexFile::ClassDef* class_def, + const DexFile::ClassDef& class_def, ClassDataItemIterator* it, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, @@ -356,7 +356,7 @@ class MethodVerifier { const DexFile* dex_file, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, - const DexFile::ClassDef* class_def_idx, + const DexFile::ClassDef& class_def_idx, const DexFile::CodeItem* code_item, ArtMethod* method, uint32_t method_access_flags, @@ -759,7 +759,7 @@ class MethodVerifier { Handle<mirror::DexCache> dex_cache_ GUARDED_BY(Locks::mutator_lock_); // The class loader for the declaring class of the method. Handle<mirror::ClassLoader> class_loader_ GUARDED_BY(Locks::mutator_lock_); - const DexFile::ClassDef* const class_def_; // The class def of the declaring class of the method. + const DexFile::ClassDef& class_def_; // The class def of the declaring class of the method. const DexFile::CodeItem* const code_item_; // The code item containing the code for the method. const RegType* declaring_class_; // Lazily computed reg type of the method's declaring class. // Instruction widths and flags, one entry per code unit. |