diff options
Diffstat (limited to 'runtime')
40 files changed, 337 insertions, 308 deletions
diff --git a/runtime/art_field-inl.h b/runtime/art_field-inl.h index 53e4c11511..fb4141886a 100644 --- a/runtime/art_field-inl.h +++ b/runtime/art_field-inl.h @@ -291,7 +291,7 @@ inline const char* ArtField::GetTypeDescriptor() REQUIRES_SHARED(Locks::mutator_ return field_index == 0 ? "[Ljava/lang/Class;" : "[[Ljava/lang/Class;"; } const DexFile* dex_file = GetDexFile(); - const DexFile::FieldId& field_id = dex_file->GetFieldId(field_index); + const dex::FieldId& field_id = dex_file->GetFieldId(field_index); return dex_file->GetFieldTypeDescriptor(field_id); } @@ -342,7 +342,7 @@ inline const DexFile* ArtField::GetDexFile() REQUIRES_SHARED(Locks::mutator_lock inline ObjPtr<mirror::String> ArtField::ResolveNameString() { uint32_t dex_field_index = GetDexFieldIndex(); CHECK_NE(dex_field_index, dex::kDexNoIndex); - const DexFile::FieldId& field_id = GetDexFile()->GetFieldId(dex_field_index); + const dex::FieldId& field_id = GetDexFile()->GetFieldId(dex_field_index); return Runtime::Current()->GetClassLinker()->ResolveString(field_id.name_idx_, this); } diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h index fda269c31d..02196baebd 100644 --- a/runtime/art_method-inl.h +++ b/runtime/art_method-inl.h @@ -224,11 +224,11 @@ inline const char* ArtMethod::GetName() { inline ObjPtr<mirror::String> ArtMethod::ResolveNameString() { DCHECK(!IsProxyMethod()); - const DexFile::MethodId& method_id = GetDexFile()->GetMethodId(GetDexMethodIndex()); + const dex::MethodId& method_id = GetDexFile()->GetMethodId(GetDexMethodIndex()); return Runtime::Current()->GetClassLinker()->ResolveString(method_id.name_idx_, this); } -inline const DexFile::CodeItem* ArtMethod::GetCodeItem() { +inline const dex::CodeItem* ArtMethod::GetCodeItem() { return GetDexFile()->GetCodeItem(GetCodeItemOffset()); } @@ -245,16 +245,16 @@ inline int32_t ArtMethod::GetLineNumFromDexPC(uint32_t dex_pc) { return annotations::GetLineNumFromPC(GetDexFile(), this, dex_pc); } -inline const DexFile::ProtoId& ArtMethod::GetPrototype() { +inline const dex::ProtoId& ArtMethod::GetPrototype() { DCHECK(!IsProxyMethod()); const DexFile* dex_file = GetDexFile(); return dex_file->GetMethodPrototype(dex_file->GetMethodId(GetDexMethodIndex())); } -inline const DexFile::TypeList* ArtMethod::GetParameterTypeList() { +inline const dex::TypeList* ArtMethod::GetParameterTypeList() { DCHECK(!IsProxyMethod()); const DexFile* dex_file = GetDexFile(); - const DexFile::ProtoId& proto = dex_file->GetMethodPrototype( + const dex::ProtoId& proto = dex_file->GetMethodPrototype( dex_file->GetMethodId(GetDexMethodIndex())); return dex_file->GetProtoParameters(proto); } @@ -273,7 +273,7 @@ inline uint16_t ArtMethod::GetClassDefIndex() { } } -inline const DexFile::ClassDef& ArtMethod::GetClassDef() { +inline const dex::ClassDef& ArtMethod::GetClassDef() { DCHECK(!IsProxyMethod()); return GetDexFile()->GetClassDef(GetClassDefIndex()); } @@ -344,8 +344,8 @@ inline ArtMethod* ArtMethod::GetInterfaceMethodIfProxy(PointerSize pointer_size) inline dex::TypeIndex ArtMethod::GetReturnTypeIndex() { DCHECK(!IsProxyMethod()); const DexFile* dex_file = GetDexFile(); - const DexFile::MethodId& method_id = dex_file->GetMethodId(GetDexMethodIndex()); - const DexFile::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id); + const dex::MethodId& method_id = dex_file->GetMethodId(GetDexMethodIndex()); + const dex::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id); return proto_id.return_type_idx_; } diff --git a/runtime/art_method.cc b/runtime/art_method.cc index 5f5361aed8..dd5b0d5492 100644 --- a/runtime/art_method.cc +++ b/runtime/art_method.cc @@ -133,7 +133,7 @@ uint16_t ArtMethod::FindObsoleteDexClassDefIndex() { DCHECK(IsObsolete()); const DexFile* dex_file = GetDexFile(); const dex::TypeIndex declaring_class_type = dex_file->GetMethodId(GetDexMethodIndex()).class_idx_; - const DexFile::ClassDef* class_def = dex_file->FindClassDef(declaring_class_type); + const dex::ClassDef* class_def = dex_file->FindClassDef(declaring_class_type); CHECK(class_def != nullptr); return dex_file->GetIndexForClassDef(*class_def); } @@ -182,13 +182,13 @@ size_t ArtMethod::NumArgRegisters(const StringPiece& shorty) { bool ArtMethod::HasSameNameAndSignature(ArtMethod* other) { ScopedAssertNoThreadSuspension ants("HasSameNameAndSignature"); const DexFile* dex_file = GetDexFile(); - const DexFile::MethodId& mid = dex_file->GetMethodId(GetDexMethodIndex()); + const dex::MethodId& mid = dex_file->GetMethodId(GetDexMethodIndex()); if (GetDexCache() == other->GetDexCache()) { - const DexFile::MethodId& mid2 = dex_file->GetMethodId(other->GetDexMethodIndex()); + const dex::MethodId& mid2 = dex_file->GetMethodId(other->GetDexMethodIndex()); return mid.name_idx_ == mid2.name_idx_ && mid.proto_idx_ == mid2.proto_idx_; } const DexFile* dex_file2 = other->GetDexFile(); - const DexFile::MethodId& mid2 = dex_file2->GetMethodId(other->GetDexMethodIndex()); + const dex::MethodId& mid2 = dex_file2->GetMethodId(other->GetDexMethodIndex()); if (!DexFileStringEquals(dex_file, mid.name_idx_, dex_file2, mid2.name_idx_)) { return false; // Name mismatch. } @@ -235,17 +235,17 @@ uint32_t ArtMethod::FindDexMethodIndexInOtherDexFile(const DexFile& other_dexfil uint32_t name_and_signature_idx) { const DexFile* dexfile = GetDexFile(); const uint32_t dex_method_idx = GetDexMethodIndex(); - const DexFile::MethodId& mid = dexfile->GetMethodId(dex_method_idx); - const DexFile::MethodId& name_and_sig_mid = other_dexfile.GetMethodId(name_and_signature_idx); + const dex::MethodId& mid = dexfile->GetMethodId(dex_method_idx); + const dex::MethodId& name_and_sig_mid = other_dexfile.GetMethodId(name_and_signature_idx); DCHECK_STREQ(dexfile->GetMethodName(mid), other_dexfile.GetMethodName(name_and_sig_mid)); DCHECK_EQ(dexfile->GetMethodSignature(mid), other_dexfile.GetMethodSignature(name_and_sig_mid)); if (dexfile == &other_dexfile) { return dex_method_idx; } const char* mid_declaring_class_descriptor = dexfile->StringByTypeIdx(mid.class_idx_); - const DexFile::TypeId* other_type_id = other_dexfile.FindTypeId(mid_declaring_class_descriptor); + const dex::TypeId* other_type_id = other_dexfile.FindTypeId(mid_declaring_class_descriptor); if (other_type_id != nullptr) { - const DexFile::MethodId* other_mid = other_dexfile.FindMethodId( + const dex::MethodId* other_mid = other_dexfile.FindMethodId( *other_type_id, other_dexfile.GetStringId(name_and_sig_mid.name_idx_), other_dexfile.GetProtoId(name_and_sig_mid.proto_idx_)); if (other_mid != nullptr) { @@ -447,11 +447,11 @@ static const OatFile::OatMethod FindOatMethodFromDexFileFor(ArtMethod* method, b // recreate the class_def_index from the descriptor. std::string descriptor_storage; - const DexFile::TypeId* declaring_class_type_id = + const dex::TypeId* declaring_class_type_id = dex_file->FindTypeId(method->GetDeclaringClass()->GetDescriptor(&descriptor_storage)); CHECK(declaring_class_type_id != nullptr); dex::TypeIndex declaring_class_type_index = dex_file->GetIndexForTypeId(*declaring_class_type_id); - const DexFile::ClassDef* declaring_class_type_def = + const dex::ClassDef* declaring_class_type_def = dex_file->FindClassDef(declaring_class_type_index); CHECK(declaring_class_type_def != nullptr); uint16_t declaring_class_def_index = dex_file->GetIndexForClassDef(*declaring_class_type_def); @@ -522,7 +522,7 @@ bool ArtMethod::EqualParameters(Handle<mirror::ObjectArray<mirror::Class>> param auto* dex_file = dex_cache->GetDexFile(); const auto& method_id = dex_file->GetMethodId(GetDexMethodIndex()); const auto& proto_id = dex_file->GetMethodPrototype(method_id); - const DexFile::TypeList* proto_params = dex_file->GetProtoParameters(proto_id); + const dex::TypeList* proto_params = dex_file->GetProtoParameters(proto_id); auto count = proto_params != nullptr ? proto_params->Size() : 0u; auto param_len = params != nullptr ? params->GetLength() : 0u; if (param_len != count) { diff --git a/runtime/art_method.h b/runtime/art_method.h index cc214f7ca3..6b598da6b3 100644 --- a/runtime/art_method.h +++ b/runtime/art_method.h @@ -29,7 +29,7 @@ #include "base/macros.h" #include "base/runtime_debug.h" #include "dex/code_item_accessors.h" -#include "dex/dex_file.h" +#include "dex/dex_file_structs.h" #include "dex/dex_instruction_iterator.h" #include "dex/modifiers.h" #include "dex/primitive.h" @@ -40,6 +40,7 @@ namespace art { +class DexFile; template<class T> class Handle; class ImtConflictTable; enum InvokeType : uint32_t; @@ -586,21 +587,21 @@ class ArtMethod final { ObjPtr<mirror::String> ResolveNameString() REQUIRES_SHARED(Locks::mutator_lock_); - const DexFile::CodeItem* GetCodeItem() REQUIRES_SHARED(Locks::mutator_lock_); + const dex::CodeItem* GetCodeItem() REQUIRES_SHARED(Locks::mutator_lock_); bool IsResolvedTypeIdx(dex::TypeIndex type_idx) REQUIRES_SHARED(Locks::mutator_lock_); int32_t GetLineNumFromDexPC(uint32_t dex_pc) REQUIRES_SHARED(Locks::mutator_lock_); - const DexFile::ProtoId& GetPrototype() REQUIRES_SHARED(Locks::mutator_lock_); + const dex::ProtoId& GetPrototype() REQUIRES_SHARED(Locks::mutator_lock_); - const DexFile::TypeList* GetParameterTypeList() REQUIRES_SHARED(Locks::mutator_lock_); + const dex::TypeList* GetParameterTypeList() REQUIRES_SHARED(Locks::mutator_lock_); const char* GetDeclaringClassSourceFile() REQUIRES_SHARED(Locks::mutator_lock_); uint16_t GetClassDefIndex() REQUIRES_SHARED(Locks::mutator_lock_); - const DexFile::ClassDef& GetClassDef() REQUIRES_SHARED(Locks::mutator_lock_); + const dex::ClassDef& GetClassDef() REQUIRES_SHARED(Locks::mutator_lock_); ALWAYS_INLINE size_t GetNumberOfParameters() REQUIRES_SHARED(Locks::mutator_lock_); diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h index 43f3ed36aa..978b1abbaf 100644 --- a/runtime/class_linker-inl.h +++ b/runtime/class_linker-inl.h @@ -23,6 +23,8 @@ #include "art_method-inl.h" #include "base/mutex.h" #include "class_linker.h" +#include "dex/dex_file.h" +#include "dex/dex_file_structs.h" #include "gc_root-inl.h" #include "handle_scope-inl.h" #include "mirror/class_loader.h" @@ -271,7 +273,7 @@ inline bool ClassLinker::CheckInvokeClassMismatch(ObjPtr<mirror::DexCache> dex_c dex_cache, type, [this, dex_cache, method_idx, class_loader]() REQUIRES_SHARED(Locks::mutator_lock_) { - const DexFile::MethodId& method_id = dex_cache->GetDexFile()->GetMethodId(method_idx); + const dex::MethodId& method_id = dex_cache->GetDexFile()->GetMethodId(method_idx); ObjPtr<mirror::Class> klass = LookupResolvedType(method_id.class_idx_, dex_cache, class_loader); DCHECK(klass != nullptr); @@ -286,7 +288,7 @@ inline ArtMethod* ClassLinker::LookupResolvedMethod(uint32_t method_idx, ArtMethod* resolved = dex_cache->GetResolvedMethod(method_idx, pointer_size); if (resolved == nullptr) { const DexFile& dex_file = *dex_cache->GetDexFile(); - const DexFile::MethodId& method_id = dex_file.GetMethodId(method_idx); + const dex::MethodId& method_id = dex_file.GetMethodId(method_idx); ObjPtr<mirror::Class> klass = LookupResolvedType(method_id.class_idx_, dex_cache, class_loader); if (klass != nullptr) { resolved = FindResolvedMethod(klass, dex_cache, class_loader, method_idx); diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 3b92e2c658..c22a5cbcd6 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -2628,13 +2628,13 @@ ObjPtr<mirror::Class> ClassLinker::EnsureResolved(Thread* self, return klass; } -using ClassPathEntry = std::pair<const DexFile*, const DexFile::ClassDef*>; +using ClassPathEntry = std::pair<const DexFile*, const dex::ClassDef*>; // Search a collection of DexFiles for a descriptor ClassPathEntry FindInClassPath(const char* descriptor, size_t hash, const std::vector<const DexFile*>& class_path) { for (const DexFile* dex_file : class_path) { - const DexFile::ClassDef* dex_class_def = OatDexFile::FindClassDef(*dex_file, descriptor, hash); + const dex::ClassDef* dex_class_def = OatDexFile::FindClassDef(*dex_file, descriptor, hash); if (dex_class_def != nullptr) { return ClassPathEntry(dex_file, dex_class_def); } @@ -2784,8 +2784,7 @@ ObjPtr<mirror::Class> ClassLinker::FindClassInBaseDexClassLoaderClassPath( ObjPtr<mirror::Class> ret; auto define_class = [&](const DexFile* cp_dex_file) REQUIRES_SHARED(Locks::mutator_lock_) { - const DexFile::ClassDef* dex_class_def = - OatDexFile::FindClassDef(*cp_dex_file, descriptor, hash); + const dex::ClassDef* dex_class_def = OatDexFile::FindClassDef(*cp_dex_file, descriptor, hash); if (dex_class_def != nullptr) { ObjPtr<mirror::Class> klass = DefineClass(soa.Self(), descriptor, @@ -2985,7 +2984,7 @@ ObjPtr<mirror::Class> ClassLinker::DefineClass(Thread* self, size_t hash, Handle<mirror::ClassLoader> class_loader, const DexFile& dex_file, - const DexFile::ClassDef& dex_class_def) { + const dex::ClassDef& dex_class_def) { StackHandleScope<3> hs(self); auto klass = hs.NewHandle<mirror::Class>(nullptr); @@ -3032,7 +3031,7 @@ ObjPtr<mirror::Class> ClassLinker::DefineClass(Thread* self, // Get the real dex file. This will return the input if there aren't any callbacks or they do // nothing. DexFile const* new_dex_file = nullptr; - DexFile::ClassDef const* new_class_def = nullptr; + dex::ClassDef const* new_class_def = nullptr; // TODO We should ideally figure out some way to move this after we get a lock on the klass so it // will only be called once. Runtime::Current()->GetRuntimeCallbacks()->ClassPreDefine(descriptor, @@ -3153,7 +3152,7 @@ ObjPtr<mirror::Class> ClassLinker::DefineClass(Thread* self, } uint32_t ClassLinker::SizeOfClassWithoutEmbeddedTables(const DexFile& dex_file, - const DexFile::ClassDef& dex_class_def) { + const dex::ClassDef& dex_class_def) { size_t num_ref = 0; size_t num_8 = 0; size_t num_16 = 0; @@ -3171,7 +3170,7 @@ uint32_t ClassLinker::SizeOfClassWithoutEmbeddedTables(const DexFile& dex_file, continue; } last_field_idx = field_idx; - const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx); + const dex::FieldId& field_id = dex_file.GetFieldId(field_idx); const char* descriptor = dex_file.GetFieldTypeDescriptor(field_id); char c = descriptor[0]; switch (c) { @@ -3400,7 +3399,7 @@ static void LinkCode(ClassLinker* class_linker, } void ClassLinker::SetupClass(const DexFile& dex_file, - const DexFile::ClassDef& dex_class_def, + const dex::ClassDef& dex_class_def, Handle<mirror::Class> klass, ObjPtr<mirror::ClassLoader> class_loader) { CHECK(klass != nullptr); @@ -3481,7 +3480,7 @@ LinearAlloc* ClassLinker::GetOrCreateAllocatorForClassLoader(ObjPtr<mirror::Clas void ClassLinker::LoadClass(Thread* self, const DexFile& dex_file, - const DexFile::ClassDef& dex_class_def, + const dex::ClassDef& dex_class_def, Handle<mirror::Class> klass) { ClassAccessor accessor(dex_file, dex_class_def, @@ -3606,7 +3605,7 @@ void ClassLinker::LoadMethod(const DexFile& dex_file, Handle<mirror::Class> klass, ArtMethod* dst) { const uint32_t dex_method_idx = method.GetIndex(); - const DexFile::MethodId& method_id = dex_file.GetMethodId(dex_method_idx); + const dex::MethodId& method_id = dex_file.GetMethodId(dex_method_idx); const char* method_name = dex_file.StringDataByIdx(method_id.name_idx_); ScopedAssertNoThreadSuspension ants("LoadMethod"); @@ -4987,7 +4986,7 @@ bool ClassLinker::CanWeInitializeClass(ObjPtr<mirror::Class> klass, bool can_ini } // Check if there are encoded static values needing initialization. if (klass->NumStaticFields() != 0) { - const DexFile::ClassDef* dex_class_def = klass->GetClassDef(); + const dex::ClassDef* dex_class_def = klass->GetClassDef(); DCHECK(dex_class_def != nullptr); if (dex_class_def->static_values_off_ != 0) { return false; @@ -5204,7 +5203,7 @@ bool ClassLinker::InitializeClass(Thread* self, Handle<mirror::Class> klass, const size_t num_static_fields = klass->NumStaticFields(); if (num_static_fields > 0) { - const DexFile::ClassDef* dex_class_def = klass->GetClassDef(); + const dex::ClassDef* dex_class_def = klass->GetClassDef(); CHECK(dex_class_def != nullptr); StackHandleScope<3> hs(self); Handle<mirror::ClassLoader> class_loader(hs.NewHandle(klass->GetClassLoader())); @@ -5413,8 +5412,8 @@ static void ThrowSignatureCheckResolveReturnTypeException(Handle<mirror::Class> DCHECK(Thread::Current()->IsExceptionPending()); DCHECK(!m->IsProxyMethod()); const DexFile* dex_file = m->GetDexFile(); - const DexFile::MethodId& method_id = dex_file->GetMethodId(m->GetDexMethodIndex()); - const DexFile::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id); + const dex::MethodId& method_id = dex_file->GetMethodId(m->GetDexMethodIndex()); + const dex::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id); dex::TypeIndex return_type_idx = proto_id.return_type_idx_; std::string return_type = dex_file->PrettyType(return_type_idx); std::string class_loader = mirror::Object::PrettyTypeOf(m->GetDeclaringClass()->GetClassLoader()); @@ -5492,8 +5491,8 @@ static bool HasSameSignatureWithDifferentClassLoaders(Thread* self, return false; } } - const DexFile::TypeList* types1 = method1->GetParameterTypeList(); - const DexFile::TypeList* types2 = method2->GetParameterTypeList(); + const dex::TypeList* types1 = method1->GetParameterTypeList(); + const dex::TypeList* types2 = method2->GetParameterTypeList(); if (types1 == nullptr) { if (types2 != nullptr && types2->Size() != 0) { ThrowSignatureMismatch(klass, super_klass, method1, @@ -5852,7 +5851,7 @@ bool ClassLinker::LinkClass(Thread* self, bool ClassLinker::LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexFile& dex_file) { CHECK_EQ(ClassStatus::kIdx, klass->GetStatus()); - const DexFile::ClassDef& class_def = dex_file.GetClassDef(klass->GetDexClassDefIndex()); + const dex::ClassDef& class_def = dex_file.GetClassDef(klass->GetDexClassDefIndex()); dex::TypeIndex super_class_idx = class_def.superclass_idx_; if (super_class_idx.IsValid()) { // Check that a class does not inherit from itself directly. @@ -5883,7 +5882,7 @@ bool ClassLinker::LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexF CHECK(super_class->IsResolved()); klass->SetSuperClass(super_class); } - const DexFile::TypeList* interfaces = dex_file.GetInterfacesList(class_def); + const dex::TypeList* interfaces = dex_file.GetInterfacesList(class_def); if (interfaces != nullptr) { for (size_t i = 0; i < interfaces->Size(); i++) { dex::TypeIndex idx = interfaces->GetTypeItem(i).type_idx_; @@ -6027,7 +6026,7 @@ class MethodNameAndSignatureComparator final : public ValueObject { REQUIRES_SHARED(Locks::mutator_lock_) { DCHECK(!other->IsProxyMethod()) << other->PrettyMethod(); const DexFile* other_dex_file = other->GetDexFile(); - const DexFile::MethodId& other_mid = other_dex_file->GetMethodId(other->GetDexMethodIndex()); + const dex::MethodId& other_mid = other_dex_file->GetMethodId(other->GetDexMethodIndex()); if (dex_file_ == other_dex_file) { return mid_->name_idx_ == other_mid.name_idx_ && mid_->proto_idx_ == other_mid.proto_idx_; } @@ -6045,7 +6044,7 @@ class MethodNameAndSignatureComparator final : public ValueObject { // Dex file for the method to compare against. const DexFile* const dex_file_; // MethodId for the method to compare against. - const DexFile::MethodId* const mid_; + const dex::MethodId* const mid_; // Lazily computed name from the dex file's strings. const char* name_; // Lazily computed name length. @@ -8336,7 +8335,7 @@ ArtMethod* ClassLinker::ResolveMethod(uint32_t method_idx, return resolved; } const DexFile& dex_file = *dex_cache->GetDexFile(); - const DexFile::MethodId& method_id = dex_file.GetMethodId(method_idx); + const dex::MethodId& method_id = dex_file.GetMethodId(method_idx); ObjPtr<mirror::Class> klass = nullptr; if (valid_dex_cache_method) { // We have a valid method from the DexCache but we need to perform ICCE and IAE checks. @@ -8417,7 +8416,7 @@ ArtMethod* ClassLinker::ResolveMethodWithoutInvokeType(uint32_t method_idx, return resolved; } // Fail, get the declaring class. - const DexFile::MethodId& method_id = dex_cache->GetDexFile()->GetMethodId(method_idx); + const dex::MethodId& method_id = dex_cache->GetDexFile()->GetMethodId(method_idx); ObjPtr<mirror::Class> klass = ResolveType(method_id.class_idx_, dex_cache, class_loader); if (klass == nullptr) { Thread::Current()->AssertPendingException(); @@ -8443,7 +8442,7 @@ ArtField* ClassLinker::LookupResolvedField(uint32_t field_idx, ObjPtr<mirror::ClassLoader> class_loader, bool is_static) { const DexFile& dex_file = *dex_cache->GetDexFile(); - const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx); + const dex::FieldId& field_id = dex_file.GetFieldId(field_idx); ObjPtr<mirror::Class> klass = dex_cache->GetResolvedType(field_id.class_idx_); if (klass == nullptr) { klass = LookupResolvedType(field_id.class_idx_, dex_cache, class_loader); @@ -8468,7 +8467,7 @@ ArtField* ClassLinker::ResolveField(uint32_t field_idx, return resolved; } const DexFile& dex_file = *dex_cache->GetDexFile(); - const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx); + const dex::FieldId& field_id = dex_file.GetFieldId(field_idx); ObjPtr<mirror::Class> klass = ResolveType(field_id.class_idx_, dex_cache, class_loader); if (klass == nullptr) { DCHECK(Thread::Current()->IsExceptionPending()); @@ -8494,7 +8493,7 @@ ArtField* ClassLinker::ResolveFieldJLS(uint32_t field_idx, return resolved; } const DexFile& dex_file = *dex_cache->GetDexFile(); - const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx); + const dex::FieldId& field_id = dex_file.GetFieldId(field_idx); ObjPtr<mirror::Class> klass = ResolveType(field_id.class_idx_, dex_cache, class_loader); if (klass == nullptr) { DCHECK(Thread::Current()->IsExceptionPending()); @@ -8523,7 +8522,7 @@ ArtField* ClassLinker::FindResolvedField(ObjPtr<mirror::Class> klass, : klass->FindInstanceField(dex_cache, field_idx); if (resolved == nullptr) { - const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx); + const dex::FieldId& field_id = dex_file.GetFieldId(field_idx); const char* name = dex_file.GetFieldName(field_id); const char* type = dex_file.GetFieldTypeDescriptor(field_id); resolved = is_static ? mirror::Class::FindStaticField(self, klass, name, type) @@ -8551,7 +8550,7 @@ ArtField* ClassLinker::FindResolvedFieldJLS(ObjPtr<mirror::Class> klass, ArtField* resolved = nullptr; Thread* self = Thread::Current(); const DexFile& dex_file = *dex_cache->GetDexFile(); - const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx); + const dex::FieldId& field_id = dex_file.GetFieldId(field_idx); const char* name = dex_file.GetFieldName(field_id); const char* type = dex_file.GetFieldTypeDescriptor(field_id); @@ -8588,7 +8587,7 @@ ObjPtr<mirror::MethodType> ClassLinker::ResolveMethodType( // First resolve the return type. const DexFile& dex_file = *dex_cache->GetDexFile(); - const DexFile::ProtoId& proto_id = dex_file.GetProtoId(proto_idx); + const dex::ProtoId& proto_id = dex_file.GetProtoId(proto_idx); Handle<mirror::Class> return_type(hs.NewHandle( ResolveType(proto_id.return_type_idx_, dex_cache, class_loader))); if (return_type == nullptr) { @@ -8644,7 +8643,7 @@ ObjPtr<mirror::MethodType> ClassLinker::ResolveMethodType(Thread* self, mirror::MethodHandle* ClassLinker::ResolveMethodHandleForField( Thread* self, - const DexFile::MethodHandleItem& method_handle, + const dex::MethodHandleItem& method_handle, ArtMethod* referrer) { DexFile::MethodHandleType handle_type = static_cast<DexFile::MethodHandleType>(method_handle.method_handle_type_); @@ -8772,7 +8771,7 @@ mirror::MethodHandle* ClassLinker::ResolveMethodHandleForField( mirror::MethodHandle* ClassLinker::ResolveMethodHandleForMethod( Thread* self, - const DexFile::MethodHandleItem& method_handle, + const dex::MethodHandleItem& method_handle, ArtMethod* referrer) { DexFile::MethodHandleType handle_type = static_cast<DexFile::MethodHandleType>(method_handle.method_handle_type_); @@ -8895,7 +8894,7 @@ mirror::MethodHandle* ClassLinker::ResolveMethodHandleForMethod( } const DexFile* dex_file = referrer->GetDexFile(); - const DexFile::MethodId& method_id = dex_file->GetMethodId(method_handle.field_or_method_idx_); + const dex::MethodId& method_id = dex_file->GetMethodId(method_handle.field_or_method_idx_); int32_t index = 0; if (receiver_count != 0) { // Insert receiver. Use the class identified in the method handle rather than the declaring @@ -8907,7 +8906,7 @@ mirror::MethodHandle* ClassLinker::ResolveMethodHandleForMethod( method_params->Set(index++, receiver_class); } - const DexFile::ProtoId& proto_id = dex_file->GetProtoId(method_id.proto_idx_); + const dex::ProtoId& proto_id = dex_file->GetProtoId(method_id.proto_idx_); DexFileParameterIterator it(*dex_file, proto_id); while (it.HasNext()) { DCHECK_LT(index, num_params); @@ -8951,7 +8950,7 @@ ObjPtr<mirror::MethodHandle> ClassLinker::ResolveMethodHandle(Thread* self, ArtMethod* referrer) REQUIRES_SHARED(Locks::mutator_lock_) { const DexFile* const dex_file = referrer->GetDexFile(); - const DexFile::MethodHandleItem& method_handle = dex_file->GetMethodHandle(method_handle_idx); + const dex::MethodHandleItem& method_handle = dex_file->GetMethodHandle(method_handle_idx); switch (static_cast<DexFile::MethodHandleType>(method_handle.method_handle_type_)) { case DexFile::MethodHandleType::kStaticPut: case DexFile::MethodHandleType::kStaticGet: diff --git a/runtime/class_linker.h b/runtime/class_linker.h index d0a7c9b846..fa5df441c7 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -29,7 +29,6 @@ #include "base/macros.h" #include "dex/class_accessor.h" #include "dex/dex_cache_resolved_classes.h" -#include "dex/dex_file.h" #include "dex/dex_file_types.h" #include "gc_root.h" #include "handle.h" @@ -39,6 +38,10 @@ namespace art { +namespace dex { +struct ClassDef; +} // namespace dex + namespace gc { namespace space { class ImageSpace; @@ -73,6 +76,7 @@ class ArtMethod; class ClassHierarchyAnalysis; enum class ClassRoot : uint32_t; class ClassTable; +class DexFile; template<class T> class Handle; class ImtConflictTable; template<typename T> class LengthPrefixedArray; @@ -185,7 +189,7 @@ class ClassLinker { size_t hash, Handle<mirror::ClassLoader> class_loader, const DexFile& dex_file, - const DexFile::ClassDef& dex_class_def) + const dex::ClassDef& dex_class_def) REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::dex_lock_); @@ -844,19 +848,19 @@ class ClassLinker { // Precomputes size needed for Class, in the case of a non-temporary class this size must be // sufficient to hold all static fields. uint32_t SizeOfClassWithoutEmbeddedTables(const DexFile& dex_file, - const DexFile::ClassDef& dex_class_def); + const dex::ClassDef& dex_class_def); // Setup the classloader, class def index, type idx so that we can insert this class in the class // table. void SetupClass(const DexFile& dex_file, - const DexFile::ClassDef& dex_class_def, + const dex::ClassDef& dex_class_def, Handle<mirror::Class> klass, ObjPtr<mirror::ClassLoader> class_loader) REQUIRES_SHARED(Locks::mutator_lock_); void LoadClass(Thread* self, const DexFile& dex_file, - const DexFile::ClassDef& dex_class_def, + const dex::ClassDef& dex_class_def, Handle<mirror::Class> klass) REQUIRES_SHARED(Locks::mutator_lock_); @@ -1028,12 +1032,12 @@ class ClassLinker { REQUIRES_SHARED(Locks::mutator_lock_); mirror::MethodHandle* ResolveMethodHandleForField(Thread* self, - const DexFile::MethodHandleItem& method_handle, + const dex::MethodHandleItem& method_handle, ArtMethod* referrer) REQUIRES_SHARED(Locks::mutator_lock_); mirror::MethodHandle* ResolveMethodHandleForMethod(Thread* self, - const DexFile::MethodHandleItem& method_handle, + const dex::MethodHandleItem& method_handle, ArtMethod* referrer) REQUIRES_SHARED(Locks::mutator_lock_); @@ -1403,9 +1407,9 @@ class ClassLoadCallback { Handle<mirror::Class> klass ATTRIBUTE_UNUSED, Handle<mirror::ClassLoader> class_loader ATTRIBUTE_UNUSED, const DexFile& initial_dex_file ATTRIBUTE_UNUSED, - const DexFile::ClassDef& initial_class_def ATTRIBUTE_UNUSED, + const dex::ClassDef& initial_class_def ATTRIBUTE_UNUSED, /*out*/DexFile const** final_dex_file ATTRIBUTE_UNUSED, - /*out*/DexFile::ClassDef const** final_class_def ATTRIBUTE_UNUSED) + /*out*/dex::ClassDef const** final_class_def ATTRIBUTE_UNUSED) REQUIRES_SHARED(Locks::mutator_lock_) {} // A class has been loaded. diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index 061c788a41..f3aefc2701 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -429,13 +429,13 @@ class ClassLinkerTest : public CommonRuntimeTest { REQUIRES_SHARED(Locks::mutator_lock_) { // Verify all the classes defined in this file for (size_t i = 0; i < dex.NumClassDefs(); i++) { - const DexFile::ClassDef& class_def = dex.GetClassDef(i); + const dex::ClassDef& class_def = dex.GetClassDef(i); const char* descriptor = dex.GetClassDescriptor(class_def); AssertDexFileClass(class_loader, descriptor); } // Verify all the types referenced by this file for (size_t i = 0; i < dex.NumTypeIds(); i++) { - const DexFile::TypeId& type_id = dex.GetTypeId(dex::TypeIndex(i)); + const dex::TypeId& type_id = dex.GetTypeId(dex::TypeIndex(i)); const char* descriptor = dex.GetTypeDescriptor(type_id); AssertDexFileClass(class_loader, descriptor); } @@ -997,7 +997,7 @@ TEST_F(ClassLinkerTest, LookupResolvedTypeArray) { Handle<mirror::DexCache> dex_cache = hs.NewHandle(all_fields_klass->GetDexCache()); const DexFile& dex_file = *dex_cache->GetDexFile(); // Get the index of the array class we want to test. - const DexFile::TypeId* array_id = dex_file.FindTypeId("[Ljava/lang/Object;"); + const dex::TypeId* array_id = dex_file.FindTypeId("[Ljava/lang/Object;"); ASSERT_TRUE(array_id != nullptr); dex::TypeIndex array_idx = dex_file.GetIndexForTypeId(*array_id); // Check that the array class wasn't resolved yet. @@ -1323,7 +1323,7 @@ TEST_F(ClassLinkerTest, ResolveVerifyAndClinit) { klass->FindClassMethod("getS0", "()Ljava/lang/Object;", kRuntimePointerSize); ASSERT_TRUE(getS0 != nullptr); ASSERT_TRUE(getS0->IsStatic()); - const DexFile::TypeId* type_id = dex_file->FindTypeId("LStaticsFromCode;"); + const dex::TypeId* type_id = dex_file->FindTypeId("LStaticsFromCode;"); ASSERT_TRUE(type_id != nullptr); dex::TypeIndex type_idx = dex_file->GetIndexForTypeId(*type_id); ObjPtr<mirror::Class> uninit = ResolveVerifyAndClinit(type_idx, @@ -1564,7 +1564,7 @@ TEST_F(ClassLinkerMethodHandlesTest, TestResolveMethodTypes) { Handle<mirror::DexCache> dex_cache = hs.NewHandle( class_linker_->FindDexCache(soa.Self(), dex_file)); - const DexFile::MethodId& method1_id = dex_file.GetMethodId(method1->GetDexMethodIndex()); + const dex::MethodId& method1_id = dex_file.GetMethodId(method1->GetDexMethodIndex()); // This is the MethodType corresponding to the prototype of // String MethodTypes# method1(String). @@ -1596,7 +1596,7 @@ TEST_F(ClassLinkerMethodHandlesTest, TestResolveMethodTypes) { kRuntimePointerSize); ASSERT_TRUE(method2 != nullptr); ASSERT_FALSE(method2->IsDirect()); - const DexFile::MethodId& method2_id = dex_file.GetMethodId(method2->GetDexMethodIndex()); + const dex::MethodId& method2_id = dex_file.GetMethodId(method2->GetDexMethodIndex()); Handle<mirror::MethodType> method2_type = hs.NewHandle( class_linker_->ResolveMethodType(soa.Self(), method2_id.proto_idx_, dex_cache, class_loader)); ASSERT_OBJ_PTR_NE(method1_type.Get(), method2_type.Get()); diff --git a/runtime/common_dex_operations.h b/runtime/common_dex_operations.h index 5c5431d5d9..1c95622ab1 100644 --- a/runtime/common_dex_operations.h +++ b/runtime/common_dex_operations.h @@ -24,6 +24,7 @@ #include "base/macros.h" #include "class_linker.h" #include "dex/code_item_accessors.h" +#include "dex/dex_file_structs.h" #include "dex/primitive.h" #include "handle_scope-inl.h" #include "instrumentation.h" @@ -42,7 +43,7 @@ namespace art { namespace interpreter { void ArtInterpreterToInterpreterBridge(Thread* self, - const DexFile::CodeItem* code_item, + const dex::CodeItem* code_item, ShadowFrame* shadow_frame, JValue* result) REQUIRES_SHARED(Locks::mutator_lock_); diff --git a/runtime/debugger.cc b/runtime/debugger.cc index 80140b3aa1..adf01c3428 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -3927,7 +3927,7 @@ JDWP::JdwpError Dbg::PrepareInvokeMethod(uint32_t request_id, JDWP::ObjectId thr StackHandleScope<2> hs(soa.Self()); HandleWrapper<mirror::Object> h_obj(hs.NewHandleWrapper(&receiver)); HandleWrapper<mirror::Class> h_klass(hs.NewHandleWrapper(&c)); - const DexFile::TypeList* types = m->GetParameterTypeList(); + const dex::TypeList* types = m->GetParameterTypeList(); for (size_t i = 0; i < arg_count; ++i) { if (shorty[i + 1] != JdwpTagToShortyChar(arg_types[i])) { return JDWP::ERR_ILLEGAL_ARGUMENT; diff --git a/runtime/dex/dex_file_annotations.cc b/runtime/dex/dex_file_annotations.cc index 9127a27bc8..e75baf88fb 100644 --- a/runtime/dex/dex_file_annotations.cc +++ b/runtime/dex/dex_file_annotations.cc @@ -44,6 +44,15 @@ namespace art { using android::base::StringPrintf; +using dex::AnnotationItem; +using dex::AnnotationSetItem; +using dex::AnnotationSetRefItem; +using dex::AnnotationSetRefList; +using dex::AnnotationsDirectoryItem; +using dex::FieldAnnotationsItem; +using dex::MethodAnnotationsItem; +using dex::ParameterAnnotationsItem; + struct DexFile::AnnotationValue { JValue value_; uint8_t type_; @@ -75,7 +84,7 @@ class ClassData { return dex_file_; } - const DexFile::ClassDef* GetClassDef() const REQUIRES_SHARED(Locks::mutator_lock_) { + const dex::ClassDef* GetClassDef() const REQUIRES_SHARED(Locks::mutator_lock_) { return class_def_; } @@ -107,7 +116,7 @@ class ClassData { ClassData(Handle<mirror::Class> klass, ArtMethod* method, const DexFile& dex_file, - const DexFile::ClassDef* class_def) REQUIRES_SHARED(Locks::mutator_lock_) + const dex::ClassDef* class_def) REQUIRES_SHARED(Locks::mutator_lock_) : real_klass_(klass), method_(method), dex_file_(dex_file), @@ -118,7 +127,7 @@ class ClassData { Handle<mirror::Class> real_klass_; ArtMethod* method_; const DexFile& dex_file_; - const DexFile::ClassDef* class_def_; + const dex::ClassDef* class_def_; DISALLOW_COPY_AND_ASSIGN(ClassData); }; @@ -137,21 +146,20 @@ bool IsVisibilityCompatible(uint32_t actual, uint32_t expected) { return actual == expected; } -const DexFile::AnnotationSetItem* FindAnnotationSetForField(ArtField* field) +const AnnotationSetItem* FindAnnotationSetForField(ArtField* field) REQUIRES_SHARED(Locks::mutator_lock_) { const DexFile* dex_file = field->GetDexFile(); ObjPtr<mirror::Class> klass = field->GetDeclaringClass(); - const DexFile::ClassDef* class_def = klass->GetClassDef(); + const dex::ClassDef* class_def = klass->GetClassDef(); if (class_def == nullptr) { DCHECK(klass->IsProxyClass()); return nullptr; } - const DexFile::AnnotationsDirectoryItem* annotations_dir = - dex_file->GetAnnotationsDirectory(*class_def); + const AnnotationsDirectoryItem* annotations_dir = dex_file->GetAnnotationsDirectory(*class_def); if (annotations_dir == nullptr) { return nullptr; } - const DexFile::FieldAnnotationsItem* field_annotations = + const FieldAnnotationsItem* field_annotations = dex_file->GetFieldAnnotations(annotations_dir); if (field_annotations == nullptr) { return nullptr; @@ -166,14 +174,14 @@ const DexFile::AnnotationSetItem* FindAnnotationSetForField(ArtField* field) return nullptr; } -const DexFile::AnnotationItem* SearchAnnotationSet(const DexFile& dex_file, - const DexFile::AnnotationSetItem* annotation_set, - const char* descriptor, - uint32_t visibility) +const AnnotationItem* SearchAnnotationSet(const DexFile& dex_file, + const AnnotationSetItem* annotation_set, + const char* descriptor, + uint32_t visibility) REQUIRES_SHARED(Locks::mutator_lock_) { - const DexFile::AnnotationItem* result = nullptr; + const AnnotationItem* result = nullptr; for (uint32_t i = 0; i < annotation_set->size_; ++i) { - const DexFile::AnnotationItem* annotation_item = dex_file.GetAnnotationItem(annotation_set, i); + const AnnotationItem* annotation_item = dex_file.GetAnnotationItem(annotation_set, i); if (!IsVisibilityCompatible(annotation_item->visibility_, visibility)) { continue; } @@ -268,16 +276,14 @@ const uint8_t* SearchEncodedAnnotation(const DexFile& dex_file, return nullptr; } -const DexFile::AnnotationSetItem* FindAnnotationSetForMethod(const DexFile& dex_file, - const DexFile::ClassDef& class_def, - uint32_t method_index) { - const DexFile::AnnotationsDirectoryItem* annotations_dir = - dex_file.GetAnnotationsDirectory(class_def); +const AnnotationSetItem* FindAnnotationSetForMethod(const DexFile& dex_file, + const dex::ClassDef& class_def, + uint32_t method_index) { + const AnnotationsDirectoryItem* annotations_dir = dex_file.GetAnnotationsDirectory(class_def); if (annotations_dir == nullptr) { return nullptr; } - const DexFile::MethodAnnotationsItem* method_annotations = - dex_file.GetMethodAnnotations(annotations_dir); + const MethodAnnotationsItem* method_annotations = dex_file.GetMethodAnnotations(annotations_dir); if (method_annotations == nullptr) { return nullptr; } @@ -290,7 +296,7 @@ const DexFile::AnnotationSetItem* FindAnnotationSetForMethod(const DexFile& dex_ return nullptr; } -inline const DexFile::AnnotationSetItem* FindAnnotationSetForMethod(ArtMethod* method) +inline const AnnotationSetItem* FindAnnotationSetForMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) { if (method->IsProxyMethod()) { return nullptr; @@ -300,15 +306,15 @@ inline const DexFile::AnnotationSetItem* FindAnnotationSetForMethod(ArtMethod* m method->GetDexMethodIndex()); } -const DexFile::ParameterAnnotationsItem* FindAnnotationsItemForMethod(ArtMethod* method) +const ParameterAnnotationsItem* FindAnnotationsItemForMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) { const DexFile* dex_file = method->GetDexFile(); - const DexFile::AnnotationsDirectoryItem* annotations_dir = + const AnnotationsDirectoryItem* annotations_dir = dex_file->GetAnnotationsDirectory(method->GetClassDef()); if (annotations_dir == nullptr) { return nullptr; } - const DexFile::ParameterAnnotationsItem* parameter_annotations = + const ParameterAnnotationsItem* parameter_annotations = dex_file->GetParameterAnnotations(annotations_dir); if (parameter_annotations == nullptr) { return nullptr; @@ -323,16 +329,15 @@ const DexFile::ParameterAnnotationsItem* FindAnnotationsItemForMethod(ArtMethod* return nullptr; } -const DexFile::AnnotationSetItem* FindAnnotationSetForClass(const ClassData& klass) +const AnnotationSetItem* FindAnnotationSetForClass(const ClassData& klass) REQUIRES_SHARED(Locks::mutator_lock_) { const DexFile& dex_file = klass.GetDexFile(); - const DexFile::ClassDef* class_def = klass.GetClassDef(); + const dex::ClassDef* class_def = klass.GetClassDef(); if (class_def == nullptr) { DCHECK(klass.GetRealClass()->IsProxyClass()); return nullptr; } - const DexFile::AnnotationsDirectoryItem* annotations_dir = - dex_file.GetAnnotationsDirectory(*class_def); + const AnnotationsDirectoryItem* annotations_dir = dex_file.GetAnnotationsDirectory(*class_def); if (annotations_dir == nullptr) { return nullptr; } @@ -768,15 +773,14 @@ ObjPtr<mirror::Object> CreateAnnotationMember(const ClassData& klass, return new_member.Get(); } -const DexFile::AnnotationItem* GetAnnotationItemFromAnnotationSet( - const ClassData& klass, - const DexFile::AnnotationSetItem* annotation_set, - uint32_t visibility, - Handle<mirror::Class> annotation_class) +const AnnotationItem* GetAnnotationItemFromAnnotationSet(const ClassData& klass, + const AnnotationSetItem* annotation_set, + uint32_t visibility, + Handle<mirror::Class> annotation_class) REQUIRES_SHARED(Locks::mutator_lock_) { const DexFile& dex_file = klass.GetDexFile(); for (uint32_t i = 0; i < annotation_set->size_; ++i) { - const DexFile::AnnotationItem* annotation_item = dex_file.GetAnnotationItem(annotation_set, i); + const AnnotationItem* annotation_item = dex_file.GetAnnotationItem(annotation_set, i); if (!IsVisibilityCompatible(annotation_item->visibility_, visibility)) { continue; } @@ -805,13 +809,12 @@ const DexFile::AnnotationItem* GetAnnotationItemFromAnnotationSet( return nullptr; } -ObjPtr<mirror::Object> GetAnnotationObjectFromAnnotationSet( - const ClassData& klass, - const DexFile::AnnotationSetItem* annotation_set, - uint32_t visibility, - Handle<mirror::Class> annotation_class) +ObjPtr<mirror::Object> GetAnnotationObjectFromAnnotationSet(const ClassData& klass, + const AnnotationSetItem* annotation_set, + uint32_t visibility, + Handle<mirror::Class> annotation_class) REQUIRES_SHARED(Locks::mutator_lock_) { - const DexFile::AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet( + const AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet( klass, annotation_set, visibility, annotation_class); if (annotation_item == nullptr) { return nullptr; @@ -821,7 +824,7 @@ ObjPtr<mirror::Object> GetAnnotationObjectFromAnnotationSet( } ObjPtr<mirror::Object> GetAnnotationValue(const ClassData& klass, - const DexFile::AnnotationItem* annotation_item, + const AnnotationItem* annotation_item, const char* annotation_name, Handle<mirror::Class> array_class, uint32_t expected_type) @@ -855,11 +858,11 @@ ObjPtr<mirror::Object> GetAnnotationValue(const ClassData& klass, static ObjPtr<mirror::ObjectArray<mirror::String>> GetSignatureValue( const ClassData& klass, - const DexFile::AnnotationSetItem* annotation_set) + const AnnotationSetItem* annotation_set) REQUIRES_SHARED(Locks::mutator_lock_) { const DexFile& dex_file = klass.GetDexFile(); StackHandleScope<1> hs(Thread::Current()); - const DexFile::AnnotationItem* annotation_item = + const AnnotationItem* annotation_item = SearchAnnotationSet(dex_file, annotation_set, "Ldalvik/annotation/Signature;", DexFile::kDexVisibilitySystem); if (annotation_item == nullptr) { @@ -877,12 +880,11 @@ static ObjPtr<mirror::ObjectArray<mirror::String>> GetSignatureValue( return obj->AsObjectArray<mirror::String>(); } -ObjPtr<mirror::ObjectArray<mirror::Class>> GetThrowsValue( - const ClassData& klass, - const DexFile::AnnotationSetItem* annotation_set) +ObjPtr<mirror::ObjectArray<mirror::Class>> GetThrowsValue(const ClassData& klass, + const AnnotationSetItem* annotation_set) REQUIRES_SHARED(Locks::mutator_lock_) { const DexFile& dex_file = klass.GetDexFile(); - const DexFile::AnnotationItem* annotation_item = + const AnnotationItem* annotation_item = SearchAnnotationSet(dex_file, annotation_set, "Ldalvik/annotation/Throws;", DexFile::kDexVisibilitySystem); if (annotation_item == nullptr) { @@ -903,7 +905,7 @@ ObjPtr<mirror::ObjectArray<mirror::Class>> GetThrowsValue( ObjPtr<mirror::ObjectArray<mirror::Object>> ProcessAnnotationSet( const ClassData& klass, - const DexFile::AnnotationSetItem* annotation_set, + const AnnotationSetItem* annotation_set, uint32_t visibility) REQUIRES_SHARED(Locks::mutator_lock_) { const DexFile& dex_file = klass.GetDexFile(); @@ -925,7 +927,7 @@ ObjPtr<mirror::ObjectArray<mirror::Object>> ProcessAnnotationSet( uint32_t dest_index = 0; for (uint32_t i = 0; i < size; ++i) { - const DexFile::AnnotationItem* annotation_item = dex_file.GetAnnotationItem(annotation_set, i); + const AnnotationItem* annotation_item = dex_file.GetAnnotationItem(annotation_set, i); // Note that we do not use IsVisibilityCompatible here because older code // was correct for this case. if (annotation_item->visibility_ != visibility) { @@ -961,7 +963,7 @@ ObjPtr<mirror::ObjectArray<mirror::Object>> ProcessAnnotationSet( ObjPtr<mirror::ObjectArray<mirror::Object>> ProcessAnnotationSetRefList( const ClassData& klass, - const DexFile::AnnotationSetRefList* set_ref_list, + const AnnotationSetRefList* set_ref_list, uint32_t size) REQUIRES_SHARED(Locks::mutator_lock_) { const DexFile& dex_file = klass.GetDexFile(); @@ -982,8 +984,8 @@ ObjPtr<mirror::ObjectArray<mirror::Object>> ProcessAnnotationSetRefList( return nullptr; } for (uint32_t index = 0; index < size; ++index) { - const DexFile::AnnotationSetRefItem* set_ref_item = &set_ref_list->list_[index]; - const DexFile::AnnotationSetItem* set_item = dex_file.GetSetRefItemItem(set_ref_item); + const AnnotationSetRefItem* set_ref_item = &set_ref_list->list_[index]; + const AnnotationSetItem* set_item = dex_file.GetSetRefItemItem(set_ref_item); ObjPtr<mirror::Object> annotation_set = ProcessAnnotationSet(klass, set_item, DexFile::kDexVisibilityRuntime); @@ -1000,7 +1002,7 @@ namespace annotations { ObjPtr<mirror::Object> GetAnnotationForField(ArtField* field, Handle<mirror::Class> annotation_class) { - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForField(field); + const AnnotationSetItem* annotation_set = FindAnnotationSetForField(field); if (annotation_set == nullptr) { return nullptr; } @@ -1013,14 +1015,14 @@ ObjPtr<mirror::Object> GetAnnotationForField(ArtField* field, } ObjPtr<mirror::ObjectArray<mirror::Object>> GetAnnotationsForField(ArtField* field) { - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForField(field); + const AnnotationSetItem* annotation_set = FindAnnotationSetForField(field); StackHandleScope<1> hs(Thread::Current()); const ClassData field_class(hs, field); return ProcessAnnotationSet(field_class, annotation_set, DexFile::kDexVisibilityRuntime); } ObjPtr<mirror::ObjectArray<mirror::String>> GetSignatureAnnotationForField(ArtField* field) { - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForField(field); + const AnnotationSetItem* annotation_set = FindAnnotationSetForField(field); if (annotation_set == nullptr) { return nullptr; } @@ -1030,13 +1032,13 @@ ObjPtr<mirror::ObjectArray<mirror::String>> GetSignatureAnnotationForField(ArtFi } bool IsFieldAnnotationPresent(ArtField* field, Handle<mirror::Class> annotation_class) { - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForField(field); + const AnnotationSetItem* annotation_set = FindAnnotationSetForField(field); if (annotation_set == nullptr) { return false; } StackHandleScope<1> hs(Thread::Current()); const ClassData field_class(hs, field); - const DexFile::AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet( + const AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet( field_class, annotation_set, DexFile::kDexVisibilityRuntime, annotation_class); return annotation_item != nullptr; } @@ -1044,17 +1046,17 @@ bool IsFieldAnnotationPresent(ArtField* field, Handle<mirror::Class> annotation_ ObjPtr<mirror::Object> GetAnnotationDefaultValue(ArtMethod* method) { const ClassData klass(method); const DexFile* dex_file = &klass.GetDexFile(); - const DexFile::AnnotationsDirectoryItem* annotations_dir = + const AnnotationsDirectoryItem* annotations_dir = dex_file->GetAnnotationsDirectory(*klass.GetClassDef()); if (annotations_dir == nullptr) { return nullptr; } - const DexFile::AnnotationSetItem* annotation_set = + const AnnotationSetItem* annotation_set = dex_file->GetClassAnnotationSet(annotations_dir); if (annotation_set == nullptr) { return nullptr; } - const DexFile::AnnotationItem* annotation_item = SearchAnnotationSet(*dex_file, annotation_set, + const AnnotationItem* annotation_item = SearchAnnotationSet(*dex_file, annotation_set, "Ldalvik/annotation/AnnotationDefault;", DexFile::kDexVisibilitySystem); if (annotation_item == nullptr) { return nullptr; @@ -1087,7 +1089,7 @@ ObjPtr<mirror::Object> GetAnnotationDefaultValue(ArtMethod* method) { ObjPtr<mirror::Object> GetAnnotationForMethod(ArtMethod* method, Handle<mirror::Class> annotation_class) { - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method); + const AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method); if (annotation_set == nullptr) { return nullptr; } @@ -1096,14 +1098,14 @@ ObjPtr<mirror::Object> GetAnnotationForMethod(ArtMethod* method, } ObjPtr<mirror::ObjectArray<mirror::Object>> GetAnnotationsForMethod(ArtMethod* method) { - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method); + const AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method); return ProcessAnnotationSet(ClassData(method), annotation_set, DexFile::kDexVisibilityRuntime); } ObjPtr<mirror::ObjectArray<mirror::Class>> GetExceptionTypesForMethod(ArtMethod* method) { - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method); + const AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method); if (annotation_set == nullptr) { return nullptr; } @@ -1112,12 +1114,12 @@ ObjPtr<mirror::ObjectArray<mirror::Class>> GetExceptionTypesForMethod(ArtMethod* ObjPtr<mirror::ObjectArray<mirror::Object>> GetParameterAnnotations(ArtMethod* method) { const DexFile* dex_file = method->GetDexFile(); - const DexFile::ParameterAnnotationsItem* parameter_annotations = + const ParameterAnnotationsItem* parameter_annotations = FindAnnotationsItemForMethod(method); if (parameter_annotations == nullptr) { return nullptr; } - const DexFile::AnnotationSetRefList* set_ref_list = + const AnnotationSetRefList* set_ref_list = dex_file->GetParameterAnnotationSetRefList(parameter_annotations); if (set_ref_list == nullptr) { return nullptr; @@ -1128,12 +1130,12 @@ ObjPtr<mirror::ObjectArray<mirror::Object>> GetParameterAnnotations(ArtMethod* m uint32_t GetNumberOfAnnotatedMethodParameters(ArtMethod* method) { const DexFile* dex_file = method->GetDexFile(); - const DexFile::ParameterAnnotationsItem* parameter_annotations = + const ParameterAnnotationsItem* parameter_annotations = FindAnnotationsItemForMethod(method); if (parameter_annotations == nullptr) { return 0u; } - const DexFile::AnnotationSetRefList* set_ref_list = + const AnnotationSetRefList* set_ref_list = dex_file->GetParameterAnnotationSetRefList(parameter_annotations); if (set_ref_list == nullptr) { return 0u; @@ -1145,12 +1147,11 @@ ObjPtr<mirror::Object> GetAnnotationForMethodParameter(ArtMethod* method, uint32_t parameter_idx, Handle<mirror::Class> annotation_class) { const DexFile* dex_file = method->GetDexFile(); - const DexFile::ParameterAnnotationsItem* parameter_annotations = - FindAnnotationsItemForMethod(method); + const ParameterAnnotationsItem* parameter_annotations = FindAnnotationsItemForMethod(method); if (parameter_annotations == nullptr) { return nullptr; } - const DexFile::AnnotationSetRefList* set_ref_list = + const AnnotationSetRefList* set_ref_list = dex_file->GetParameterAnnotationSetRefList(parameter_annotations); if (set_ref_list == nullptr) { return nullptr; @@ -1158,8 +1159,8 @@ ObjPtr<mirror::Object> GetAnnotationForMethodParameter(ArtMethod* method, if (parameter_idx >= set_ref_list->size_) { return nullptr; } - const DexFile::AnnotationSetRefItem* annotation_set_ref = &set_ref_list->list_[parameter_idx]; - const DexFile::AnnotationSetItem* annotation_set = + const AnnotationSetRefItem* annotation_set_ref = &set_ref_list->list_[parameter_idx]; + const AnnotationSetItem* annotation_set = dex_file->GetSetRefItemItem(annotation_set_ref); if (annotation_set == nullptr) { return nullptr; @@ -1174,14 +1175,14 @@ bool GetParametersMetadataForMethod( ArtMethod* method, /*out*/ MutableHandle<mirror::ObjectArray<mirror::String>>* names, /*out*/ MutableHandle<mirror::IntArray>* access_flags) { - const DexFile::AnnotationSetItem* annotation_set = + const AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method); if (annotation_set == nullptr) { return false; } const DexFile* dex_file = method->GetDexFile(); - const DexFile::AnnotationItem* annotation_item = + const AnnotationItem* annotation_item = SearchAnnotationSet(*dex_file, annotation_set, "Ldalvik/annotation/MethodParameters;", @@ -1228,7 +1229,7 @@ bool GetParametersMetadataForMethod( } ObjPtr<mirror::ObjectArray<mirror::String>> GetSignatureAnnotationForMethod(ArtMethod* method) { - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method); + const AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method); if (annotation_set == nullptr) { return nullptr; } @@ -1238,11 +1239,11 @@ ObjPtr<mirror::ObjectArray<mirror::String>> GetSignatureAnnotationForMethod(ArtM bool IsMethodAnnotationPresent(ArtMethod* method, Handle<mirror::Class> annotation_class, uint32_t visibility /* = DexFile::kDexVisibilityRuntime */) { - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method); + const AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method); if (annotation_set == nullptr) { return false; } - const DexFile::AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet( + const AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet( ClassData(method), annotation_set, visibility, annotation_class); return annotation_item != nullptr; } @@ -1263,11 +1264,11 @@ static void DCheckNativeAnnotation(const char* descriptor, jclass cls) { // Check whether a method from the `dex_file` with the given `annotation_set` // is annotated with `annotation_descriptor` with build visibility. static bool IsMethodBuildAnnotationPresent(const DexFile& dex_file, - const DexFile::AnnotationSetItem& annotation_set, + const AnnotationSetItem& annotation_set, const char* annotation_descriptor, jclass annotation_class) { for (uint32_t i = 0; i < annotation_set.size_; ++i) { - const DexFile::AnnotationItem* annotation_item = dex_file.GetAnnotationItem(&annotation_set, i); + const AnnotationItem* annotation_item = dex_file.GetAnnotationItem(&annotation_set, i); if (!IsVisibilityCompatible(annotation_item->visibility_, DexFile::kDexVisibilityBuild)) { continue; } @@ -1283,9 +1284,9 @@ static bool IsMethodBuildAnnotationPresent(const DexFile& dex_file, } uint32_t GetNativeMethodAnnotationAccessFlags(const DexFile& dex_file, - const DexFile::ClassDef& class_def, + const dex::ClassDef& class_def, uint32_t method_index) { - const DexFile::AnnotationSetItem* annotation_set = + const dex::AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(dex_file, class_def, method_index); if (annotation_set == nullptr) { return 0u; @@ -1312,7 +1313,7 @@ uint32_t GetNativeMethodAnnotationAccessFlags(const DexFile& dex_file, ObjPtr<mirror::Object> GetAnnotationForClass(Handle<mirror::Class> klass, Handle<mirror::Class> annotation_class) { ClassData data(klass); - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); + const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); if (annotation_set == nullptr) { return nullptr; } @@ -1324,17 +1325,17 @@ ObjPtr<mirror::Object> GetAnnotationForClass(Handle<mirror::Class> klass, ObjPtr<mirror::ObjectArray<mirror::Object>> GetAnnotationsForClass(Handle<mirror::Class> klass) { ClassData data(klass); - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); + const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); return ProcessAnnotationSet(data, annotation_set, DexFile::kDexVisibilityRuntime); } ObjPtr<mirror::ObjectArray<mirror::Class>> GetDeclaredClasses(Handle<mirror::Class> klass) { ClassData data(klass); - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); + const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); if (annotation_set == nullptr) { return nullptr; } - const DexFile::AnnotationItem* annotation_item = + const AnnotationItem* annotation_item = SearchAnnotationSet(data.GetDexFile(), annotation_set, "Ldalvik/annotation/MemberClasses;", DexFile::kDexVisibilitySystem); if (annotation_item == nullptr) { @@ -1355,11 +1356,11 @@ ObjPtr<mirror::ObjectArray<mirror::Class>> GetDeclaredClasses(Handle<mirror::Cla ObjPtr<mirror::Class> GetDeclaringClass(Handle<mirror::Class> klass) { ClassData data(klass); - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); + const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); if (annotation_set == nullptr) { return nullptr; } - const DexFile::AnnotationItem* annotation_item = + const AnnotationItem* annotation_item = SearchAnnotationSet(data.GetDexFile(), annotation_set, "Ldalvik/annotation/EnclosingClass;", DexFile::kDexVisibilitySystem); if (annotation_item == nullptr) { @@ -1382,11 +1383,11 @@ ObjPtr<mirror::Class> GetEnclosingClass(Handle<mirror::Class> klass) { return declaring_class; } ClassData data(klass); - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); + const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); if (annotation_set == nullptr) { return nullptr; } - const DexFile::AnnotationItem* annotation_item = + const AnnotationItem* annotation_item = SearchAnnotationSet(data.GetDexFile(), annotation_set, "Ldalvik/annotation/EnclosingMethod;", @@ -1423,11 +1424,11 @@ ObjPtr<mirror::Class> GetEnclosingClass(Handle<mirror::Class> klass) { ObjPtr<mirror::Object> GetEnclosingMethod(Handle<mirror::Class> klass) { ClassData data(klass); - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); + const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); if (annotation_set == nullptr) { return nullptr; } - const DexFile::AnnotationItem* annotation_item = + const AnnotationItem* annotation_item = SearchAnnotationSet(data.GetDexFile(), annotation_set, "Ldalvik/annotation/EnclosingMethod;", @@ -1441,11 +1442,11 @@ ObjPtr<mirror::Object> GetEnclosingMethod(Handle<mirror::Class> klass) { bool GetInnerClass(Handle<mirror::Class> klass, /*out*/ ObjPtr<mirror::String>* name) { ClassData data(klass); - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); + const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); if (annotation_set == nullptr) { return false; } - const DexFile::AnnotationItem* annotation_item = SearchAnnotationSet( + const AnnotationItem* annotation_item = SearchAnnotationSet( data.GetDexFile(), annotation_set, "Ldalvik/annotation/InnerClass;", @@ -1476,11 +1477,11 @@ bool GetInnerClass(Handle<mirror::Class> klass, /*out*/ ObjPtr<mirror::String>* bool GetInnerClassFlags(Handle<mirror::Class> klass, uint32_t* flags) { ClassData data(klass); - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); + const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); if (annotation_set == nullptr) { return false; } - const DexFile::AnnotationItem* annotation_item = + const AnnotationItem* annotation_item = SearchAnnotationSet(data.GetDexFile(), annotation_set, "Ldalvik/annotation/InnerClass;", DexFile::kDexVisibilitySystem); if (annotation_item == nullptr) { @@ -1509,7 +1510,7 @@ bool GetInnerClassFlags(Handle<mirror::Class> klass, uint32_t* flags) { ObjPtr<mirror::ObjectArray<mirror::String>> GetSignatureAnnotationForClass( Handle<mirror::Class> klass) { ClassData data(klass); - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); + const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); if (annotation_set == nullptr) { return nullptr; } @@ -1526,12 +1527,12 @@ const char* GetSourceDebugExtension(Handle<mirror::Class> klass) { } ClassData data(klass); - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); + const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); if (annotation_set == nullptr) { return nullptr; } - const DexFile::AnnotationItem* annotation_item = SearchAnnotationSet( + const AnnotationItem* annotation_item = SearchAnnotationSet( data.GetDexFile(), annotation_set, "Ldalvik/annotation/SourceDebugExtension;", @@ -1562,11 +1563,11 @@ const char* GetSourceDebugExtension(Handle<mirror::Class> klass) { bool IsClassAnnotationPresent(Handle<mirror::Class> klass, Handle<mirror::Class> annotation_class) { ClassData data(klass); - const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); + const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data); if (annotation_set == nullptr) { return false; } - const DexFile::AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet( + const AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet( data, annotation_set, DexFile::kDexVisibilityRuntime, annotation_class); return annotation_item != nullptr; } diff --git a/runtime/dex/dex_file_annotations.h b/runtime/dex/dex_file_annotations.h index bde7891091..3625cee3d4 100644 --- a/runtime/dex/dex_file_annotations.h +++ b/runtime/dex/dex_file_annotations.h @@ -18,7 +18,6 @@ #define ART_RUNTIME_DEX_DEX_FILE_ANNOTATIONS_H_ #include "dex/dex_file.h" - #include "handle.h" #include "mirror/dex_cache.h" #include "mirror/object_array.h" @@ -84,7 +83,7 @@ bool IsMethodAnnotationPresent(ArtMethod* method, // @dalvik.annotation.optimization.CriticalNative with build visibility. // If yes, return the associated access flags, i.e. kAccFastNative or kAccCriticalNative. uint32_t GetNativeMethodAnnotationAccessFlags(const DexFile& dex_file, - const DexFile::ClassDef& class_def, + const dex::ClassDef& class_def, uint32_t method_index); // Class annotations. @@ -124,7 +123,7 @@ class RuntimeEncodedStaticFieldValueIterator : public EncodedStaticFieldValueIte RuntimeEncodedStaticFieldValueIterator(Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, ClassLinker* linker, - const DexFile::ClassDef& class_def) + const dex::ClassDef& class_def) REQUIRES_SHARED(Locks::mutator_lock_) : EncodedStaticFieldValueIterator(*dex_cache->GetDexFile(), class_def), dex_cache_(dex_cache), diff --git a/runtime/dex_to_dex_decompiler.cc b/runtime/dex_to_dex_decompiler.cc index aff9b47a79..d078d6f438 100644 --- a/runtime/dex_to_dex_decompiler.cc +++ b/runtime/dex_to_dex_decompiler.cc @@ -32,7 +32,7 @@ namespace optimizer { class DexDecompiler { public: DexDecompiler(const DexFile& dex_file, - const DexFile::CodeItem& code_item, + const dex::CodeItem& code_item, const ArrayRef<const uint8_t>& quickened_info, bool decompile_return_instruction) : code_item_accessor_(dex_file, &code_item), @@ -194,7 +194,7 @@ bool DexDecompiler::Decompile() { } bool ArtDecompileDEX(const DexFile& dex_file, - const DexFile::CodeItem& code_item, + const dex::CodeItem& code_item, const ArrayRef<const uint8_t>& quickened_info, bool decompile_return_instruction) { if (quickened_info.size() == 0 && !decompile_return_instruction) { diff --git a/runtime/dex_to_dex_decompiler.h b/runtime/dex_to_dex_decompiler.h index 93711d17db..4b6b0f707a 100644 --- a/runtime/dex_to_dex_decompiler.h +++ b/runtime/dex_to_dex_decompiler.h @@ -18,9 +18,15 @@ #define ART_RUNTIME_DEX_TO_DEX_DECOMPILER_H_ #include "base/array_ref.h" -#include "dex/dex_file.h" namespace art { + +class DexFile; + +namespace dex { +struct CodeItem; +} // namespace dex + namespace optimizer { // "Decompile", that is unquicken, the code item provided, given the @@ -30,7 +36,7 @@ namespace optimizer { // consistent with DexToDexCompiler, but we should really change it to // DexFile::CodeItem*. bool ArtDecompileDEX(const DexFile& dex_file, - const DexFile::CodeItem& code_item, + const dex::CodeItem& code_item, const ArrayRef<const uint8_t>& quickened_data, bool decompile_return_instruction); diff --git a/runtime/hidden_api.cc b/runtime/hidden_api.cc index e0939ddbdb..c146daa809 100644 --- a/runtime/hidden_api.cc +++ b/runtime/hidden_api.cc @@ -98,7 +98,7 @@ MemberSignature::MemberSignature(ArtMethod* method) { MemberSignature::MemberSignature(const ClassAccessor::Field& field) { const DexFile& dex_file = field.GetDexFile(); - const DexFile::FieldId& field_id = dex_file.GetFieldId(field.GetIndex()); + const dex::FieldId& field_id = dex_file.GetFieldId(field.GetIndex()); class_name_ = dex_file.GetFieldDeclaringClassDescriptor(field_id); member_name_ = dex_file.GetFieldName(field_id); type_signature_ = dex_file.GetFieldTypeDescriptor(field_id); @@ -107,7 +107,7 @@ MemberSignature::MemberSignature(const ClassAccessor::Field& field) { MemberSignature::MemberSignature(const ClassAccessor::Method& method) { const DexFile& dex_file = method.GetDexFile(); - const DexFile::MethodId& method_id = dex_file.GetMethodId(method.GetIndex()); + const dex::MethodId& method_id = dex_file.GetMethodId(method.GetIndex()); class_name_ = dex_file.GetMethodDeclaringClassDescriptor(method_id); member_name_ = dex_file.GetMethodName(method_id); type_signature_ = dex_file.GetMethodSignature(method_id).ToString(); @@ -282,14 +282,14 @@ static ALWAYS_INLINE uint32_t GetMemberDexIndex(ArtMethod* method) } static void VisitMembers(const DexFile& dex_file, - const DexFile::ClassDef& class_def, + const dex::ClassDef& class_def, const std::function<void(const ClassAccessor::Field&)>& fn_visit) { ClassAccessor accessor(dex_file, class_def, /* parse_hiddenapi_class_data= */ true); accessor.VisitFields(fn_visit, fn_visit); } static void VisitMembers(const DexFile& dex_file, - const DexFile::ClassDef& class_def, + const dex::ClassDef& class_def, const std::function<void(const ClassAccessor::Method&)>& fn_visit) { ClassAccessor accessor(dex_file, class_def, /* parse_hiddenapi_class_data= */ true); accessor.VisitMethods(fn_visit, fn_visit); @@ -317,7 +317,7 @@ uint32_t GetDexFlags(T* member) REQUIRES_SHARED(Locks::mutator_lock_) { if (LIKELY(original_dex == nullptr)) { // Class is not redefined. Find the class def, iterate over its members and // find the entry corresponding to this `member`. - const DexFile::ClassDef* class_def = declaring_class->GetClassDef(); + const dex::ClassDef* class_def = declaring_class->GetClassDef(); if (class_def == nullptr) { flags = kNoDexFlags; } else { @@ -338,7 +338,7 @@ uint32_t GetDexFlags(T* member) REQUIRES_SHARED(Locks::mutator_lock_) { // to access a hidden member of a JVMTI-redefined class. uint16_t class_def_idx = ext->GetPreRedefineClassDefIndex(); DCHECK_NE(class_def_idx, DexFile::kDexNoIndex16); - const DexFile::ClassDef& original_class_def = original_dex->GetClassDef(class_def_idx); + const dex::ClassDef& original_class_def = original_dex->GetClassDef(class_def_idx); MemberSignature member_signature(member); auto fn_visit = [&](const AccessorType& dex_member) { MemberSignature cur_signature(dex_member); diff --git a/runtime/imtable-inl.h b/runtime/imtable-inl.h index 93346f6151..21e3eb1f23 100644 --- a/runtime/imtable-inl.h +++ b/runtime/imtable-inl.h @@ -46,7 +46,7 @@ inline void ImTable::GetImtHashComponents(ArtMethod* method, } const DexFile* dex_file = method->GetDexFile(); - const DexFile::MethodId& method_id = dex_file->GetMethodId(method->GetDexMethodIndex()); + const dex::MethodId& method_id = dex_file->GetMethodId(method->GetDexMethodIndex()); // Class descriptor for the class component. *class_hash = ComputeModifiedUtf8Hash(dex_file->GetMethodDeclaringClassDescriptor(method_id)); @@ -54,7 +54,7 @@ inline void ImTable::GetImtHashComponents(ArtMethod* method, // Method name for the method component. *name_hash = ComputeModifiedUtf8Hash(dex_file->GetMethodName(method_id)); - const DexFile::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id); + const dex::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id); // Read the proto for the signature component. uint32_t tmp = ComputeModifiedUtf8Hash( @@ -63,10 +63,10 @@ inline void ImTable::GetImtHashComponents(ArtMethod* method, // Mix in the argument types. // Note: we could consider just using the shorty. This would be faster, at the price of // potential collisions. - const DexFile::TypeList* param_types = dex_file->GetProtoParameters(proto_id); + const dex::TypeList* param_types = dex_file->GetProtoParameters(proto_id); if (param_types != nullptr) { for (size_t i = 0; i != param_types->Size(); ++i) { - const DexFile::TypeItem& type = param_types->GetTypeItem(i); + const dex::TypeItem& type = param_types->GetTypeItem(i); tmp = 31 * tmp + ComputeModifiedUtf8Hash( dex_file->GetTypeDescriptor(dex_file->GetTypeId(type.type_idx_))); } diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc index e52a1c90d3..7a40ab431f 100644 --- a/runtime/interpreter/interpreter_common.cc +++ b/runtime/interpreter/interpreter_common.cc @@ -1168,7 +1168,7 @@ static ObjPtr<mirror::MethodType> BuildCallSiteForBootstrapMethod(Thread* self, const DexFile* dex_file, uint32_t call_site_idx) REQUIRES_SHARED(Locks::mutator_lock_) { - const DexFile::CallSiteIdItem& csi = dex_file->GetCallSiteId(call_site_idx); + const dex::CallSiteIdItem& csi = dex_file->GetCallSiteId(call_site_idx); CallSiteArrayValueIterator it(*dex_file, csi); DCHECK_GE(it.Size(), 1u); @@ -1223,7 +1223,7 @@ static ObjPtr<mirror::CallSite> InvokeBootstrapMethod(Thread* self, static constexpr size_t kMandatoryArgumentsCount = 3; ArtMethod* referrer = shadow_frame.GetMethod(); const DexFile* dex_file = referrer->GetDexFile(); - const DexFile::CallSiteIdItem& csi = dex_file->GetCallSiteId(call_site_idx); + const dex::CallSiteIdItem& csi = dex_file->GetCallSiteId(call_site_idx); CallSiteArrayValueIterator it(*dex_file, csi); if (it.Size() < kMandatoryArgumentsCount) { ThrowBootstrapMethodError("Truncated bootstrap arguments (%zu < %zu)", @@ -1637,7 +1637,7 @@ static inline bool DoCallCommon(ArtMethod* called_method, // We need to do runtime check on reference assignment. We need to load the shorty // to get the exact type of each reference argument. - const DexFile::TypeList* params = method->GetParameterTypeList(); + const dex::TypeList* params = method->GetParameterTypeList(); uint32_t shorty_len = 0; const char* shorty = method->GetShorty(&shorty_len); diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h index d1896e6b08..6366035a4c 100644 --- a/runtime/interpreter/interpreter_common.h +++ b/runtime/interpreter/interpreter_common.h @@ -621,7 +621,7 @@ void ArtInterpreterToCompiledCodeBridge(Thread* self, static inline bool IsStringInit(const DexFile* dex_file, uint32_t method_idx) REQUIRES_SHARED(Locks::mutator_lock_) { - const DexFile::MethodId& method_id = dex_file->GetMethodId(method_idx); + const dex::MethodId& method_id = dex_file->GetMethodId(method_idx); const char* class_name = dex_file->StringByTypeIdx(method_id.class_idx_); const char* method_name = dex_file->GetMethodName(method_id); // Instead of calling ResolveMethod() which has suspend point and can trigger diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index 679ca43e98..bdad412350 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -825,7 +825,7 @@ inline bool Class::DescriptorEquals(const char* match) { return ProxyDescriptorEquals(match); } else { const DexFile& dex_file = GetDexFile(); - const DexFile::TypeId& type_id = dex_file.GetTypeId(GetClassDef()->class_idx_); + const dex::TypeId& type_id = dex_file.GetTypeId(GetClassDef()->class_idx_); return strcmp(dex_file.GetTypeDescriptor(type_id), match) == 0; } } @@ -899,7 +899,7 @@ inline uint32_t Class::NumDirectInterfaces() { ObjectArray<Class>* interfaces = GetProxyInterfaces(); return interfaces != nullptr ? interfaces->GetLength() : 0; } else { - const DexFile::TypeList* interfaces = GetInterfaceTypeList(); + const dex::TypeList* interfaces = GetInterfaceTypeList(); if (interfaces == nullptr) { return 0; } else { diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc index c5ed1bf4dd..515394ab18 100644 --- a/runtime/mirror/class.cc +++ b/runtime/mirror/class.cc @@ -493,7 +493,7 @@ ArtMethod* Class::FindInterfaceMethod(ObjPtr<DexCache> dex_cache, PointerSize pointer_size) { // We always search by name and signature, ignoring the type index in the MethodId. const DexFile& dex_file = *dex_cache->GetDexFile(); - const DexFile::MethodId& method_id = dex_file.GetMethodId(dex_method_idx); + const dex::MethodId& method_id = dex_file.GetMethodId(dex_method_idx); StringPiece name = dex_file.StringDataByIdx(method_id.name_idx_); const Signature signature = dex_file.GetMethodSignature(method_id); return FindInterfaceMethod(name, signature, pointer_size); @@ -620,7 +620,7 @@ ArtMethod* Class::FindClassMethod(ObjPtr<DexCache> dex_cache, } // If not found, we need to search by name and signature. const DexFile& dex_file = *dex_cache->GetDexFile(); - const DexFile::MethodId& method_id = dex_file.GetMethodId(dex_method_idx); + const dex::MethodId& method_id = dex_file.GetMethodId(dex_method_idx); const Signature signature = dex_file.GetMethodSignature(method_id); StringPiece name; // Delay strlen() until actually needed. // If we do not have a dex_cache match, try to find the declared method in this class now. @@ -651,7 +651,7 @@ ArtMethod* Class::FindClassMethod(ObjPtr<DexCache> dex_cache, // Matching dex_cache. We cannot compare the `dex_method_idx` anymore because // the type index differs, so compare the name index and proto index. for (ArtMethod& method : declared_methods) { - const DexFile::MethodId& cmp_method_id = dex_file.GetMethodId(method.GetDexMethodIndex()); + const dex::MethodId& cmp_method_id = dex_file.GetMethodId(method.GetDexMethodIndex()); if (cmp_method_id.name_idx_ == method_id.name_idx_ && cmp_method_id.proto_idx_ == method_id.proto_idx_) { candidate_method = &method; @@ -1005,7 +1005,7 @@ const char* Class::GetDescriptor(std::string* storage) { return storage->c_str(); } else { const DexFile& dex_file = GetDexFile(); - const DexFile::TypeId& type_id = dex_file.GetTypeId(GetClassDef()->class_idx_); + const dex::TypeId& type_id = dex_file.GetTypeId(GetClassDef()->class_idx_); return dex_file.GetTypeDescriptor(type_id); } } @@ -1018,7 +1018,7 @@ const char* Class::GetArrayDescriptor(std::string* storage) { return storage->c_str(); } -const DexFile::ClassDef* Class::GetClassDef() { +const dex::ClassDef* Class::GetClassDef() { uint16_t class_def_idx = GetDexClassDefIndex(); if (class_def_idx == DexFile::kDexNoIndex16) { return nullptr; @@ -1086,7 +1086,7 @@ ObjPtr<Class> Class::GetCommonSuperClass(Handle<Class> klass) { const char* Class::GetSourceFile() { const DexFile& dex_file = GetDexFile(); - const DexFile::ClassDef* dex_class_def = GetClassDef(); + const dex::ClassDef* dex_class_def = GetClassDef(); if (dex_class_def == nullptr) { // Generated classes have no class def. return nullptr; @@ -1103,8 +1103,8 @@ std::string Class::GetLocation() { return "generated class"; } -const DexFile::TypeList* Class::GetInterfaceTypeList() { - const DexFile::ClassDef* class_def = GetClassDef(); +const dex::TypeList* Class::GetInterfaceTypeList() { + const dex::ClassDef* class_def = GetClassDef(); if (class_def == nullptr) { return nullptr; } @@ -1247,7 +1247,7 @@ uint32_t Class::Depth() { dex::TypeIndex Class::FindTypeIndexInOtherDexFile(const DexFile& dex_file) { std::string temp; - const DexFile::TypeId* type_id = dex_file.FindTypeId(GetDescriptor(&temp)); + const dex::TypeId* type_id = dex_file.FindTypeId(GetDescriptor(&temp)); return (type_id == nullptr) ? dex::TypeIndex() : dex_file.GetIndexForTypeId(*type_id); } diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index d5aa514432..8e392bcd77 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -24,7 +24,7 @@ #include "base/stride_iterator.h" #include "class_flags.h" #include "class_status.h" -#include "dex/dex_file.h" +#include "dex/dex_file_structs.h" #include "dex/dex_file_types.h" #include "dex/modifiers.h" #include "dex/primitive.h" @@ -40,6 +40,7 @@ namespace art { class ArtField; class ArtMethod; struct ClassOffsets; +class DexFile; template<class T> class Handle; enum InvokeType : uint32_t; template<typename T> class LengthPrefixedArray; @@ -1133,7 +1134,7 @@ class MANAGED Class final : public Object { bool DescriptorEquals(const char* match) REQUIRES_SHARED(Locks::mutator_lock_); - const DexFile::ClassDef* GetClassDef() REQUIRES_SHARED(Locks::mutator_lock_); + const dex::ClassDef* GetClassDef() REQUIRES_SHARED(Locks::mutator_lock_); ALWAYS_INLINE uint32_t NumDirectInterfaces() REQUIRES_SHARED(Locks::mutator_lock_); @@ -1156,7 +1157,7 @@ class MANAGED Class final : public Object { const DexFile& GetDexFile() REQUIRES_SHARED(Locks::mutator_lock_); - const DexFile::TypeList* GetInterfaceTypeList() REQUIRES_SHARED(Locks::mutator_lock_); + const dex::TypeList* GetInterfaceTypeList() REQUIRES_SHARED(Locks::mutator_lock_); // Asserts we are initialized or initializing in the given thread. void AssertInitializedOrInitializingInThread(Thread* self) diff --git a/runtime/mirror/dex_cache_test.cc b/runtime/mirror/dex_cache_test.cc index 36c5ae2ab9..f7c1c02325 100644 --- a/runtime/mirror/dex_cache_test.cc +++ b/runtime/mirror/dex_cache_test.cc @@ -146,8 +146,8 @@ TEST_F(DexCacheMethodHandlesTest, TestResolvedMethodTypes) { Handle<mirror::DexCache> dex_cache = hs.NewHandle( class_linker_->FindDexCache(Thread::Current(), dex_file)); - const DexFile::MethodId& method1_id = dex_file.GetMethodId(method1->GetDexMethodIndex()); - const DexFile::MethodId& method2_id = dex_file.GetMethodId(method2->GetDexMethodIndex()); + const dex::MethodId& method1_id = dex_file.GetMethodId(method1->GetDexMethodIndex()); + const dex::MethodId& method2_id = dex_file.GetMethodId(method2->GetDexMethodIndex()); Handle<mirror::MethodType> method1_type = hs.NewHandle( class_linker_->ResolveMethodType(soa.Self(), method1_id.proto_idx_, diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc index d8c7b1db30..f4b8ba5908 100644 --- a/runtime/mirror/object_test.cc +++ b/runtime/mirror/object_test.cc @@ -364,16 +364,16 @@ TEST_F(ObjectTest, StaticFieldFromCode) { Handle<Class> klass = hs.NewHandle(class_linker_->FindClass(soa.Self(), "LStaticsFromCode;", loader)); ArtMethod* clinit = klass->FindClassInitializer(kRuntimePointerSize); - const DexFile::TypeId* klass_type_id = dex_file->FindTypeId("LStaticsFromCode;"); + const dex::TypeId* klass_type_id = dex_file->FindTypeId("LStaticsFromCode;"); ASSERT_TRUE(klass_type_id != nullptr); - const DexFile::TypeId* type_type_id = dex_file->FindTypeId("Ljava/lang/Object;"); + const dex::TypeId* type_type_id = dex_file->FindTypeId("Ljava/lang/Object;"); ASSERT_TRUE(type_type_id != nullptr); - const DexFile::StringId* name_str_id = dex_file->FindStringId("s0"); + const dex::StringId* name_str_id = dex_file->FindStringId("s0"); ASSERT_TRUE(name_str_id != nullptr); - const DexFile::FieldId* field_id = dex_file->FindFieldId( + const dex::FieldId* field_id = dex_file->FindFieldId( *klass_type_id, *name_str_id, *type_type_id); ASSERT_TRUE(field_id != nullptr); uint32_t field_idx = dex_file->GetIndexForFieldId(*field_id); diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc index 1da91b089d..52482b736d 100644 --- a/runtime/native/dalvik_system_DexFile.cc +++ b/runtime/native/dalvik_system_DexFile.cc @@ -383,7 +383,7 @@ static jclass DexFile_defineClassNative(JNIEnv* env, const std::string descriptor(DotToDescriptor(class_name.c_str())); const size_t hash(ComputeModifiedUtf8Hash(descriptor.c_str())); for (auto& dex_file : dex_files) { - const DexFile::ClassDef* dex_class_def = + const dex::ClassDef* dex_class_def = OatDexFile::FindClassDef(*dex_file, descriptor.c_str(), hash); if (dex_class_def != nullptr) { ScopedObjectAccess soa(env); @@ -440,7 +440,7 @@ static jobjectArray DexFile_getClassNameList(JNIEnv* env, jclass, jobject cookie std::set<const char*, CharPointerComparator> descriptors; for (auto& dex_file : dex_files) { for (size_t i = 0; i < dex_file->NumClassDefs(); ++i) { - const DexFile::ClassDef& class_def = dex_file->GetClassDef(i); + const dex::ClassDef& class_def = dex_file->GetClassDef(i); const char* descriptor = dex_file->GetClassDescriptor(class_def); descriptors.insert(descriptor); } diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc index 892d4cc9e1..d705d5f8c0 100644 --- a/runtime/native/dalvik_system_VMRuntime.cc +++ b/runtime/native/dalvik_system_VMRuntime.cc @@ -413,7 +413,7 @@ static void PreloadDexCachesResolveField(ObjPtr<mirror::DexCache> dex_cache, return; // The entry already contains some ArtField. } const DexFile* dex_file = dex_cache->GetDexFile(); - const DexFile::FieldId& field_id = dex_file->GetFieldId(field_idx); + const dex::FieldId& field_id = dex_file->GetFieldId(field_idx); ObjPtr<mirror::Class> klass = Runtime::Current()->GetClassLinker()->LookupResolvedType( field_id.class_idx_, dex_cache, /* class_loader= */ nullptr); if (klass == nullptr) { @@ -439,7 +439,7 @@ static void PreloadDexCachesResolveMethod(ObjPtr<mirror::DexCache> dex_cache, ui return; // The entry already contains some ArtMethod. } const DexFile* dex_file = dex_cache->GetDexFile(); - const DexFile::MethodId& method_id = dex_file->GetMethodId(method_idx); + const dex::MethodId& method_id = dex_file->GetMethodId(method_idx); ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); ObjPtr<mirror::Class> klass = class_linker->LookupResolvedType( diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc index 612a4b33b1..d022c3b631 100644 --- a/runtime/native/java_lang_Class.cc +++ b/runtime/native/java_lang_Class.cc @@ -220,7 +220,7 @@ static jobjectArray Class_getInterfacesInternal(JNIEnv* env, jobject javaThis) { return soa.AddLocalReference<jobjectArray>(klass->GetProxyInterfaces()->Clone(soa.Self())); } - const DexFile::TypeList* iface_list = klass->GetInterfaceTypeList(); + const dex::TypeList* iface_list = klass->GetInterfaceTypeList(); if (iface_list == nullptr) { return nullptr; } diff --git a/runtime/native/java_lang_reflect_Executable.cc b/runtime/native/java_lang_reflect_Executable.cc index ada0a64608..2ce56b5153 100644 --- a/runtime/native/java_lang_reflect_Executable.cc +++ b/runtime/native/java_lang_reflect_Executable.cc @@ -275,8 +275,8 @@ static jint Executable_compareMethodParametersInternal(JNIEnv* env, this_method = this_method->GetInterfaceMethodIfProxy(kRuntimePointerSize); other_method = other_method->GetInterfaceMethodIfProxy(kRuntimePointerSize); - const DexFile::TypeList* this_list = this_method->GetParameterTypeList(); - const DexFile::TypeList* other_list = other_method->GetParameterTypeList(); + const dex::TypeList* this_list = this_method->GetParameterTypeList(); + const dex::TypeList* other_list = other_method->GetParameterTypeList(); if (this_list == other_list) { return 0; @@ -298,9 +298,9 @@ static jint Executable_compareMethodParametersInternal(JNIEnv* env, } for (int32_t i = 0; i < this_size; ++i) { - const DexFile::TypeId& lhs = this_method->GetDexFile()->GetTypeId( + const dex::TypeId& lhs = this_method->GetDexFile()->GetTypeId( this_list->GetTypeItem(i).type_idx_); - const DexFile::TypeId& rhs = other_method->GetDexFile()->GetTypeId( + const dex::TypeId& rhs = other_method->GetDexFile()->GetTypeId( other_list->GetTypeItem(i).type_idx_); uint32_t lhs_len, rhs_len; @@ -343,7 +343,7 @@ static jobjectArray Executable_getParameterTypesInternal(JNIEnv* env, jobject ja ArtMethod* method = ArtMethod::FromReflectedMethod(soa, javaMethod); method = method->GetInterfaceMethodIfProxy(kRuntimePointerSize); - const DexFile::TypeList* params = method->GetParameterTypeList(); + const dex::TypeList* params = method->GetParameterTypeList(); if (params == nullptr) { return nullptr; } @@ -378,7 +378,7 @@ static jint Executable_getParameterCountInternal(JNIEnv* env, jobject javaMethod ArtMethod* method = ArtMethod::FromReflectedMethod(soa, javaMethod); method = method->GetInterfaceMethodIfProxy(kRuntimePointerSize); - const DexFile::TypeList* params = method->GetParameterTypeList(); + const dex::TypeList* params = method->GetParameterTypeList(); return (params == nullptr) ? 0 : params->Size(); } diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc index de4826f417..f4a8c50a26 100644 --- a/runtime/oat_file.cc +++ b/runtime/oat_file.cc @@ -48,7 +48,9 @@ #include "base/unix_file/fd_file.h" #include "base/utils.h" #include "dex/art_dex_file_loader.h" +#include "dex/dex_file.h" #include "dex/dex_file_loader.h" +#include "dex/dex_file_structs.h" #include "dex/dex_file_types.h" #include "dex/standard_dex_file.h" #include "dex/type_lookup_table.h" @@ -1831,13 +1833,13 @@ OatFile::OatClass OatDexFile::GetOatClass(uint16_t class_def_index) const { reinterpret_cast<const OatMethodOffsets*>(methods_pointer)); } -const DexFile::ClassDef* OatDexFile::FindClassDef(const DexFile& dex_file, - const char* descriptor, - size_t hash) { +const dex::ClassDef* OatDexFile::FindClassDef(const DexFile& dex_file, + const char* descriptor, + size_t hash) { const OatDexFile* oat_dex_file = dex_file.GetOatDexFile(); DCHECK_EQ(ComputeModifiedUtf8Hash(descriptor), hash); bool used_lookup_table = false; - const DexFile::ClassDef* lookup_table_classdef = nullptr; + const dex::ClassDef* lookup_table_classdef = nullptr; if (LIKELY((oat_dex_file != nullptr) && oat_dex_file->GetTypeLookupTable().Valid())) { used_lookup_table = true; const uint32_t class_def_idx = oat_dex_file->GetTypeLookupTable().Lookup(descriptor, hash); @@ -1854,10 +1856,10 @@ const DexFile::ClassDef* OatDexFile::FindClassDef(const DexFile& dex_file, DCHECK(!used_lookup_table); return nullptr; } - const DexFile::TypeId* type_id = dex_file.FindTypeId(descriptor); + const dex::TypeId* type_id = dex_file.FindTypeId(descriptor); if (type_id != nullptr) { dex::TypeIndex type_idx = dex_file.GetIndexForTypeId(*type_id); - const DexFile::ClassDef* found_class_def = dex_file.FindClassDef(type_idx); + const dex::ClassDef* found_class_def = dex_file.FindClassDef(type_idx); if (kIsDebugBuild && used_lookup_table) { DCHECK_EQ(found_class_def, lookup_table_classdef); } diff --git a/runtime/oat_file.h b/runtime/oat_file.h index ab6e62db97..3e9c01f9c2 100644 --- a/runtime/oat_file.h +++ b/runtime/oat_file.h @@ -29,7 +29,6 @@ #include "base/tracking_safe_map.h" #include "class_status.h" #include "compiler_filter.h" -#include "dex/dex_file.h" #include "dex/dex_file_layout.h" #include "dex/type_lookup_table.h" #include "dex/utf.h" @@ -40,6 +39,7 @@ namespace art { class BitVector; +class DexFile; class ElfFile; class DexLayoutSections; template <class MirrorType> class GcRoot; @@ -50,6 +50,10 @@ class OatMethodOffsets; class OatQuickMethodHeader; class VdexFile; +namespace dex { +struct ClassDef; +} // namespace dex + namespace gc { namespace collector { class DummyOatFile; @@ -500,9 +504,9 @@ class OatDexFile final { // Looks up a class definition by its class descriptor. Hash must be // ComputeModifiedUtf8Hash(descriptor). - static const DexFile::ClassDef* FindClassDef(const DexFile& dex_file, - const char* descriptor, - size_t hash); + static const dex::ClassDef* FindClassDef(const DexFile& dex_file, + const char* descriptor, + size_t hash); // Madvise the dex file based on the state we are moving to. static void MadviseDexFile(const DexFile& dex_file, MadviseState state); diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc index 9552ca33f1..5aa1ea2593 100644 --- a/runtime/oat_file_manager.cc +++ b/runtime/oat_file_manager.cc @@ -186,7 +186,7 @@ class TypeIndexInfo { static BitVector GenerateTypeIndexes(const DexFile* dex_file) { BitVector type_indexes(/*start_bits=*/0, /*expandable=*/true, Allocator::GetMallocAllocator()); for (uint16_t i = 0; i < dex_file->NumClassDefs(); ++i) { - const DexFile::ClassDef& class_def = dex_file->GetClassDef(i); + const dex::ClassDef& class_def = dex_file->GetClassDef(i); uint16_t type_idx = class_def.class_idx_.index_; type_indexes.SetBit(type_idx); } diff --git a/runtime/reflection.cc b/runtime/reflection.cc index 80118365f0..dfd7e64a08 100644 --- a/runtime/reflection.cc +++ b/runtime/reflection.cc @@ -226,7 +226,7 @@ class ArgArray { ArtMethod* m, Thread* self) REQUIRES_SHARED(Locks::mutator_lock_) { - const DexFile::TypeList* classes = m->GetParameterTypeList(); + const dex::TypeList* classes = m->GetParameterTypeList(); // Set receiver if non-null (method is not static) if (receiver != nullptr) { Append(receiver); @@ -367,7 +367,7 @@ class ArgArray { void CheckMethodArguments(JavaVMExt* vm, ArtMethod* m, uint32_t* args) REQUIRES_SHARED(Locks::mutator_lock_) { - const DexFile::TypeList* params = m->GetParameterTypeList(); + const dex::TypeList* params = m->GetParameterTypeList(); if (params == nullptr) { return; // No arguments so nothing to check. } @@ -461,7 +461,7 @@ ALWAYS_INLINE bool CheckArgsForInvokeMethod(ArtMethod* np_method, ObjPtr<mirror::ObjectArray<mirror::Object>> objects) REQUIRES_SHARED(Locks::mutator_lock_) { - const DexFile::TypeList* classes = np_method->GetParameterTypeList(); + const dex::TypeList* classes = np_method->GetParameterTypeList(); uint32_t classes_size = (classes == nullptr) ? 0 : classes->Size(); uint32_t arg_count = (objects == nullptr) ? 0 : objects->GetLength(); if (UNLIKELY(arg_count != classes_size)) { diff --git a/runtime/runtime_callbacks.cc b/runtime/runtime_callbacks.cc index bf74816f24..da13eb8070 100644 --- a/runtime/runtime_callbacks.cc +++ b/runtime/runtime_callbacks.cc @@ -205,14 +205,14 @@ void RuntimeCallbacks::ClassPreDefine(const char* descriptor, Handle<mirror::Class> temp_class, Handle<mirror::ClassLoader> loader, const DexFile& initial_dex_file, - const DexFile::ClassDef& initial_class_def, + const dex::ClassDef& initial_class_def, /*out*/DexFile const** final_dex_file, - /*out*/DexFile::ClassDef const** final_class_def) { + /*out*/dex::ClassDef const** final_class_def) { DexFile const* current_dex_file = &initial_dex_file; - DexFile::ClassDef const* current_class_def = &initial_class_def; + dex::ClassDef const* current_class_def = &initial_class_def; for (ClassLoadCallback* cb : class_callbacks_) { DexFile const* new_dex_file = nullptr; - DexFile::ClassDef const* new_class_def = nullptr; + dex::ClassDef const* new_class_def = nullptr; cb->ClassPreDefine(descriptor, temp_class, loader, diff --git a/runtime/runtime_callbacks.h b/runtime/runtime_callbacks.h index 32ee3aa3b6..41d552ae44 100644 --- a/runtime/runtime_callbacks.h +++ b/runtime/runtime_callbacks.h @@ -22,11 +22,14 @@ #include "base/array_ref.h" #include "base/locks.h" #include "base/macros.h" -#include "dex/dex_file.h" #include "handle.h" namespace art { +namespace dex { +struct ClassDef; +} // namespace dex + namespace mirror { class Class; class ClassLoader; @@ -35,6 +38,7 @@ class Object; class ArtMethod; class ClassLoadCallback; +class DexFile; class Thread; class MethodCallback; class Monitor; @@ -183,9 +187,9 @@ class RuntimeCallbacks { Handle<mirror::Class> temp_class, Handle<mirror::ClassLoader> loader, const DexFile& initial_dex_file, - const DexFile::ClassDef& initial_class_def, + const dex::ClassDef& initial_class_def, /*out*/DexFile const** final_dex_file, - /*out*/DexFile::ClassDef const** final_class_def) + /*out*/dex::ClassDef const** final_class_def) REQUIRES_SHARED(Locks::mutator_lock_); void AddMethodCallback(MethodCallback* cb) REQUIRES(Locks::mutator_lock_); diff --git a/runtime/runtime_callbacks_test.cc b/runtime/runtime_callbacks_test.cc index d08be72402..df06a9fafd 100644 --- a/runtime/runtime_callbacks_test.cc +++ b/runtime/runtime_callbacks_test.cc @@ -257,9 +257,9 @@ class ClassLoadCallbackRuntimeCallbacksTest : public RuntimeCallbacksTest { Handle<mirror::Class> klass ATTRIBUTE_UNUSED, Handle<mirror::ClassLoader> class_loader ATTRIBUTE_UNUSED, const DexFile& initial_dex_file, - const DexFile::ClassDef& initial_class_def ATTRIBUTE_UNUSED, + const dex::ClassDef& initial_class_def ATTRIBUTE_UNUSED, /*out*/DexFile const** final_dex_file ATTRIBUTE_UNUSED, - /*out*/DexFile::ClassDef const** final_class_def ATTRIBUTE_UNUSED) override + /*out*/dex::ClassDef const** final_class_def ATTRIBUTE_UNUSED) override REQUIRES_SHARED(Locks::mutator_lock_) { const std::string& location = initial_dex_file.GetLocation(); std::string event = diff --git a/runtime/transaction_test.cc b/runtime/transaction_test.cc index 3d9afa0f15..69ded3dd3f 100644 --- a/runtime/transaction_test.cc +++ b/runtime/transaction_test.cc @@ -489,7 +489,7 @@ TEST_F(TransactionTest, ResolveString) { // Go search the dex file to find the string id of our string. static const char* kResolvedString = "ResolvedString"; - const DexFile::StringId* string_id = dex_file->FindStringId(kResolvedString); + const dex::StringId* string_id = dex_file->FindStringId(kResolvedString); ASSERT_TRUE(string_id != nullptr); dex::StringIndex string_idx = dex_file->GetIndexForStringId(*string_id); ASSERT_TRUE(string_idx.IsValid()); diff --git a/runtime/vdex_file.cc b/runtime/vdex_file.cc index f24711a4a1..72c42b9ee4 100644 --- a/runtime/vdex_file.cc +++ b/runtime/vdex_file.cc @@ -281,12 +281,12 @@ void VdexFile::UnquickenDexFile(const DexFile& target_dex_file, return; } // Make sure to not unquicken the same code item multiple times. - std::unordered_set<const DexFile::CodeItem*> unquickened_code_item; + std::unordered_set<const dex::CodeItem*> unquickened_code_item; CompactOffsetTable::Accessor accessor(GetQuickenInfoOffsetTable(source_dex_begin, quickening_info)); for (ClassAccessor class_accessor : target_dex_file.GetClasses()) { for (const ClassAccessor::Method& method : class_accessor.GetMethods()) { - const DexFile::CodeItem* code_item = method.GetCodeItem(); + const dex::CodeItem* code_item = method.GetCodeItem(); if (code_item != nullptr && unquickened_code_item.emplace(code_item).second) { const uint32_t offset = accessor.GetOffset(method.GetIndex()); // Offset being 0 means not quickened. diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index 0b33a0b3c0..167982124c 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -158,7 +158,7 @@ FailureKind MethodVerifier::VerifyClass(Thread* self, bool early_failure = false; std::string failure_message; const DexFile& dex_file = klass->GetDexFile(); - const DexFile::ClassDef* class_def = klass->GetClassDef(); + const dex::ClassDef* class_def = klass->GetClassDef(); ObjPtr<mirror::Class> super = klass->GetSuperClass(); std::string temp; if (super == nullptr && strcmp("Ljava/lang/Object;", klass->GetDescriptor(&temp)) != 0) { @@ -210,7 +210,7 @@ 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 dex::ClassDef& class_def, CompilerCallbacks* callbacks, bool allow_soft_failures, HardFailLogMode log_level, @@ -319,8 +319,8 @@ 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::CodeItem* code_item, + const dex::ClassDef& class_def, + const dex::CodeItem* code_item, ArtMethod* method, uint32_t method_access_flags, CompilerCallbacks* callbacks, @@ -462,8 +462,8 @@ 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::CodeItem* code_item, + const dex::ClassDef& class_def, + const dex::CodeItem* code_item, ArtMethod* method, uint32_t method_access_flags, uint32_t api_level) { @@ -500,8 +500,8 @@ 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::CodeItem* code_item, + const dex::ClassDef& class_def, + const dex::CodeItem* code_item, uint32_t dex_method_idx, ArtMethod* method, uint32_t method_access_flags, @@ -602,7 +602,7 @@ void MethodVerifier::FindLocksAtDexPc() { bool MethodVerifier::Verify() { // Some older code doesn't correctly mark constructors as such. Test for this case by looking at // the name. - const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_); + const dex::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_); const char* method_name = dex_file_->StringDataByIdx(method_id.name_idx_); bool instance_constructor_by_name = strcmp("<init>", method_name) == 0; bool static_constructor_by_name = strcmp("<clinit>", method_name) == 0; @@ -917,7 +917,7 @@ bool MethodVerifier::ScanTryCatchBlocks() { return true; } const uint32_t insns_size = code_item_accessor_.InsnsSizeInCodeUnits(); - for (const DexFile::TryItem& try_item : code_item_accessor_.TryItems()) { + for (const dex::TryItem& try_item : code_item_accessor_.TryItems()) { const uint32_t start = try_item.start_addr_; const uint32_t end = start + try_item.insn_count_; if ((start >= end) || (start >= insns_size) || (end > insns_size)) { @@ -1637,7 +1637,7 @@ bool MethodVerifier::SetTypesFromSignature() { cur_arg++; } - const DexFile::ProtoId& proto_id = + const dex::ProtoId& proto_id = dex_file_->GetMethodPrototype(dex_file_->GetMethodId(dex_method_idx_)); DexFileParameterIterator iterator(*dex_file_, proto_id); @@ -1876,7 +1876,7 @@ bool MethodVerifier::CodeFlowVerifyMethod() { // Returns the index of the first final instance field of the given class, or kDexNoIndex if there // is no such field. static uint32_t GetFirstFinalInstanceFieldIndex(const DexFile& dex_file, dex::TypeIndex type_idx) { - const DexFile::ClassDef* class_def = dex_file.FindClassDef(type_idx); + const dex::ClassDef* class_def = dex_file.FindClassDef(type_idx); DCHECK(class_def != nullptr); ClassAccessor accessor(dex_file, *class_def); for (const ClassAccessor::Field& field : accessor.GetInstanceFields()) { @@ -2885,7 +2885,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { } if (return_type == nullptr) { uint32_t method_idx = GetMethodIdxOfInvoke(inst); - const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx); + const dex::MethodId& method_id = dex_file_->GetMethodId(method_idx); dex::TypeIndex return_type_idx = dex_file_->GetProtoId(method_id.proto_idx_).return_type_idx_; const char* descriptor = dex_file_->StringByTypeIdx(return_type_idx); @@ -2908,7 +2908,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { const RegType* return_type = nullptr; if (called_method == nullptr) { uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); - const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx); + const dex::MethodId& method_id = dex_file_->GetMethodId(method_idx); is_constructor = strcmp("<init>", dex_file_->StringDataByIdx(method_id.name_idx_)) == 0; dex::TypeIndex return_type_idx = dex_file_->GetProtoId(method_id.proto_idx_).return_type_idx_; @@ -2986,7 +2986,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { const char* descriptor; if (called_method == nullptr) { uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); - const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx); + const dex::MethodId& method_id = dex_file_->GetMethodId(method_idx); dex::TypeIndex return_type_idx = dex_file_->GetProtoId(method_id.proto_idx_).return_type_idx_; descriptor = dex_file_->StringByTypeIdx(return_type_idx); @@ -3041,7 +3041,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { const char* descriptor; if (abs_method == nullptr) { uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); - const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx); + const dex::MethodId& method_id = dex_file_->GetMethodId(method_idx); dex::TypeIndex return_type_idx = dex_file_->GetProtoId(method_id.proto_idx_).return_type_idx_; descriptor = dex_file_->StringByTypeIdx(return_type_idx); @@ -3106,7 +3106,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { // method handle produced by step 1. The dex file verifier has checked ranges for // the first three arguments and CheckCallSite has checked the method handle type. const dex::ProtoIndex proto_idx = dex_file_->GetProtoIndexForCallSite(call_site_idx); - const DexFile::ProtoId& proto_id = dex_file_->GetProtoId(proto_idx); + const dex::ProtoId& proto_id = dex_file_->GetProtoId(proto_idx); DexFileParameterIterator param_it(*dex_file_, proto_id); // Treat method as static as it has yet to be determined. VerifyInvocationArgsFromIterator(¶m_it, inst, METHOD_STATIC, is_range, nullptr); @@ -3497,7 +3497,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { */ if ((opcode_flags & Instruction::kThrow) != 0 && GetInstructionFlags(work_insn_idx_).IsInTry()) { bool has_catch_all_handler = false; - const DexFile::TryItem* try_item = code_item_accessor_.FindTryItem(work_insn_idx_); + const dex::TryItem* try_item = code_item_accessor_.FindTryItem(work_insn_idx_); CHECK(try_item != nullptr); CatchHandlerIterator iterator(code_item_accessor_, *try_item); @@ -3749,7 +3749,7 @@ const RegType& MethodVerifier::GetCaughtExceptionType() { ArtMethod* MethodVerifier::ResolveMethodAndCheckAccess( uint32_t dex_method_idx, MethodType method_type) { - const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx); + const dex::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx); const RegType& klass_type = ResolveClass<CheckAccess::kYes>(method_id.class_idx_); if (klass_type.IsConflict()) { std::string append(" in attempt to access method "); @@ -4093,7 +4093,7 @@ bool MethodVerifier::CheckCallSite(uint32_t call_site_idx) { } // Check method handle kind is valid. - const DexFile::MethodHandleItem& mh = dex_file_->GetMethodHandle(index[0]); + const dex::MethodHandleItem& mh = dex_file_->GetMethodHandle(index[0]); if (mh.method_handle_type_ != static_cast<uint16_t>(DexFile::MethodHandleType::kInvokeStatic)) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Call site #" << call_site_idx << " argument 0 method handle type is not InvokeStatic: " @@ -4125,7 +4125,7 @@ class MethodParamListDescriptorIterator { private: ArtMethod* res_method_; size_t pos_; - const DexFile::TypeList* params_; + const dex::TypeList* params_; const size_t params_size_; }; @@ -4231,7 +4231,7 @@ bool MethodVerifier::CheckSignaturePolymorphicMethod(ArtMethod* method) { return false; } - const DexFile::TypeList* types = method->GetParameterTypeList(); + const dex::TypeList* types = method->GetParameterTypeList(); if (types->Size() != 1) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Signature polymorphic method has too many arguments " << types->Size() << " != 1"; @@ -4553,7 +4553,7 @@ void MethodVerifier::VerifyAPut(const Instruction* inst, } ArtField* MethodVerifier::GetStaticField(int field_idx) { - const DexFile::FieldId& field_id = dex_file_->GetFieldId(field_idx); + const dex::FieldId& field_id = dex_file_->GetFieldId(field_idx); // Check access to class const RegType& klass_type = ResolveClass<CheckAccess::kYes>(field_id.class_idx_); if (klass_type.IsConflict()) { // bad class @@ -4596,7 +4596,7 @@ ArtField* MethodVerifier::GetStaticField(int field_idx) { } ArtField* MethodVerifier::GetInstanceField(const RegType& obj_type, int field_idx) { - const DexFile::FieldId& field_id = dex_file_->GetFieldId(field_idx); + const dex::FieldId& field_id = dex_file_->GetFieldId(field_idx); // Check access to class. const RegType& klass_type = ResolveClass<CheckAccess::kYes>(field_id.class_idx_); if (klass_type.IsConflict()) { @@ -4756,7 +4756,7 @@ void MethodVerifier::VerifyISFieldAccess(const Instruction* inst, const RegType& // // Note: see b/34966607. This and above may be changed in the future. if (kAccType == FieldAccessType::kAccPut) { - const DexFile::FieldId& field_id = dex_file_->GetFieldId(field_idx); + const dex::FieldId& field_id = dex_file_->GetFieldId(field_idx); const char* field_class_descriptor = dex_file_->GetFieldDeclaringClassDescriptor(field_id); const RegType* field_class_type = ®_types_.FromDescriptor(GetClassLoader(), field_class_descriptor, @@ -4772,7 +4772,7 @@ void MethodVerifier::VerifyISFieldAccess(const Instruction* inst, const RegType& } } if (field_type == nullptr) { - const DexFile::FieldId& field_id = dex_file_->GetFieldId(field_idx); + const dex::FieldId& field_id = dex_file_->GetFieldId(field_idx); const char* descriptor = dex_file_->GetFieldTypeDescriptor(field_id); field_type = ®_types_.FromDescriptor(GetClassLoader(), descriptor, false); } @@ -4935,8 +4935,8 @@ const RegType& MethodVerifier::GetMethodReturnType() { } } if (return_type_ == nullptr) { - const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_); - const DexFile::ProtoId& proto_id = dex_file_->GetMethodPrototype(method_id); + const dex::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_); + const dex::ProtoId& proto_id = dex_file_->GetMethodPrototype(method_id); dex::TypeIndex return_type_idx = proto_id.return_type_idx_; const char* descriptor = dex_file_->GetTypeDescriptor(dex_file_->GetTypeId(return_type_idx)); return_type_ = ®_types_.FromDescriptor(GetClassLoader(), descriptor, false); @@ -4947,7 +4947,7 @@ const RegType& MethodVerifier::GetMethodReturnType() { const RegType& MethodVerifier::GetDeclaringClass() { if (declaring_class_ == nullptr) { - const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_); + const dex::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_); const char* descriptor = dex_file_->GetTypeDescriptor(dex_file_->GetTypeId(method_id.class_idx_)); if (method_being_verified_ != nullptr) { diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h index eef22807ec..c178df05a4 100644 --- a/runtime/verifier/method_verifier.h +++ b/runtime/verifier/method_verifier.h @@ -26,7 +26,6 @@ #include "base/scoped_arena_containers.h" #include "base/value_object.h" #include "dex/code_item_accessors.h" -#include "dex/dex_file.h" #include "dex/dex_file_types.h" #include "dex/method_reference.h" #include "handle.h" @@ -39,11 +38,17 @@ namespace art { class ClassLinker; class CompilerCallbacks; +class DexFile; class Instruction; struct ReferenceMap2Visitor; class Thread; class VariableIndentationOutputStream; +namespace dex { +struct ClassDef; +struct CodeItem; +} // namespace dex + namespace mirror { class DexCache; } // namespace mirror @@ -107,7 +112,7 @@ class MethodVerifier { const DexFile* dex_file, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, - const DexFile::ClassDef& class_def, + const dex::ClassDef& class_def, CompilerCallbacks* callbacks, bool allow_soft_failures, HardFailLogMode log_level, @@ -121,8 +126,8 @@ class MethodVerifier { const DexFile* dex_file, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, - const DexFile::ClassDef& class_def, - const DexFile::CodeItem* code_item, ArtMethod* method, + const dex::ClassDef& class_def, + const dex::CodeItem* code_item, ArtMethod* method, uint32_t method_access_flags, uint32_t api_level) REQUIRES_SHARED(Locks::mutator_lock_); @@ -238,8 +243,8 @@ class MethodVerifier { const DexFile* dex_file, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, - const DexFile::ClassDef& class_def, - const DexFile::CodeItem* code_item, + const dex::ClassDef& class_def, + const dex::CodeItem* code_item, uint32_t method_idx, ArtMethod* method, uint32_t access_flags, @@ -297,8 +302,8 @@ class MethodVerifier { const DexFile* dex_file, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> class_loader, - const DexFile::ClassDef& class_def_idx, - const DexFile::CodeItem* code_item, + const dex::ClassDef& class_def_idx, + const dex::CodeItem* code_item, ArtMethod* method, uint32_t method_access_flags, CompilerCallbacks* callbacks, @@ -716,7 +721,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& class_def_; // The class def of the declaring class of the method. + const dex::ClassDef& class_def_; // The class def of the declaring class of the method. const CodeItemDataAccessor code_item_accessor_; const RegType* declaring_class_; // Lazily computed reg type of the method's declaring class. // Instruction widths and flags, one entry per code unit. diff --git a/runtime/verifier/method_verifier_test.cc b/runtime/verifier/method_verifier_test.cc index 7519257cae..36890a6382 100644 --- a/runtime/verifier/method_verifier_test.cc +++ b/runtime/verifier/method_verifier_test.cc @@ -57,7 +57,7 @@ class MethodVerifierTest : public CommonRuntimeTest { REQUIRES_SHARED(Locks::mutator_lock_) { // Verify all the classes defined in this file for (size_t i = 0; i < dex.NumClassDefs(); i++) { - const DexFile::ClassDef& class_def = dex.GetClassDef(i); + const dex::ClassDef& class_def = dex.GetClassDef(i); const char* descriptor = dex.GetClassDescriptor(class_def); VerifyClass(descriptor); } diff --git a/runtime/verifier/verifier_deps.cc b/runtime/verifier/verifier_deps.cc index d346a95e82..bdcadd9fa6 100644 --- a/runtime/verifier/verifier_deps.cc +++ b/runtime/verifier/verifier_deps.cc @@ -99,9 +99,9 @@ dex::StringIndex VerifierDeps::GetClassDescriptorStringId(const DexFile& dex_fil DCHECK(dex_cache != nullptr) << klass->PrettyClass(); if (dex_cache->GetDexFile() == &dex_file) { // FindStringId is slow, try to go through the class def if we have one. - const DexFile::ClassDef* class_def = klass->GetClassDef(); + const dex::ClassDef* class_def = klass->GetClassDef(); DCHECK(class_def != nullptr) << klass->PrettyClass(); - const DexFile::TypeId& type_id = dex_file.GetTypeId(class_def->class_idx_); + const dex::TypeId& type_id = dex_file.GetTypeId(class_def->class_idx_); if (kIsDebugBuild) { std::string temp; CHECK_EQ(GetIdFromString(dex_file, klass->GetDescriptor(&temp)), type_id.descriptor_idx_); @@ -119,9 +119,9 @@ static dex::StringIndex TryGetClassDescriptorStringId(const DexFile& dex_file, ObjPtr<mirror::Class> klass) REQUIRES_SHARED(Locks::mutator_lock_) { if (!klass->IsArrayClass()) { - const DexFile::TypeId& type_id = dex_file.GetTypeId(type_idx); + const dex::TypeId& type_id = dex_file.GetTypeId(type_idx); const DexFile& klass_dex = klass->GetDexFile(); - const DexFile::TypeId& klass_type_id = klass_dex.GetTypeId(klass->GetClassDef()->class_idx_); + const dex::TypeId& klass_type_id = klass_dex.GetTypeId(klass->GetClassDef()->class_idx_); if (strcmp(dex_file.GetTypeDescriptor(type_id), klass_dex.GetTypeDescriptor(klass_type_id)) == 0) { return type_id.descriptor_idx_; @@ -201,7 +201,7 @@ static bool FindExistingStringId(const std::vector<std::string>& strings, } dex::StringIndex VerifierDeps::GetIdFromString(const DexFile& dex_file, const std::string& str) { - const DexFile::StringId* string_id = dex_file.FindStringId(str.c_str()); + const dex::StringId* string_id = dex_file.FindStringId(str.c_str()); if (string_id != nullptr) { // String is in the DEX file. Return its ID. return dex_file.GetIndexForStringId(*string_id); @@ -805,7 +805,7 @@ void VerifierDeps::Dump(VariableIndentationOutputStream* vios) const { } for (const FieldResolution& entry : dep.second->fields_) { - const DexFile::FieldId& field_id = dex_file.GetFieldId(entry.GetDexFieldIndex()); + const dex::FieldId& field_id = dex_file.GetFieldId(entry.GetDexFieldIndex()); vios->Stream() << dex_file.GetFieldDeclaringClassDescriptor(field_id) << "->" << dex_file.GetFieldName(field_id) << ":" @@ -823,7 +823,7 @@ void VerifierDeps::Dump(VariableIndentationOutputStream* vios) const { } for (const MethodResolution& method : dep.second->methods_) { - const DexFile::MethodId& method_id = dex_file.GetMethodId(method.GetDexMethodIndex()); + const dex::MethodId& method_id = dex_file.GetMethodId(method.GetDexMethodIndex()); vios->Stream() << dex_file.GetMethodDeclaringClassDescriptor(method_id) << "->" << dex_file.GetMethodName(method_id) @@ -949,7 +949,7 @@ bool VerifierDeps::VerifyClasses(Handle<mirror::ClassLoader> class_loader, } static std::string GetFieldDescription(const DexFile& dex_file, uint32_t index) { - const DexFile::FieldId& field_id = dex_file.GetFieldId(index); + const dex::FieldId& field_id = dex_file.GetFieldId(index); return std::string(dex_file.GetFieldDeclaringClassDescriptor(field_id)) + "->" + dex_file.GetFieldName(field_id) @@ -965,7 +965,7 @@ bool VerifierDeps::VerifyFields(Handle<mirror::ClassLoader> class_loader, // and have the same recorded flags. ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); for (const auto& entry : fields) { - const DexFile::FieldId& field_id = dex_file.GetFieldId(entry.GetDexFieldIndex()); + const dex::FieldId& field_id = dex_file.GetFieldId(entry.GetDexFieldIndex()); StringPiece name(dex_file.StringDataByIdx(field_id.name_idx_)); StringPiece type(dex_file.StringDataByIdx(dex_file.GetTypeId(field_id.type_idx_).descriptor_idx_)); // Only use field_id.class_idx_ when the entry is unresolved, which is rare. @@ -1011,7 +1011,7 @@ bool VerifierDeps::VerifyFields(Handle<mirror::ClassLoader> class_loader, } static std::string GetMethodDescription(const DexFile& dex_file, uint32_t index) { - const DexFile::MethodId& method_id = dex_file.GetMethodId(index); + const dex::MethodId& method_id = dex_file.GetMethodId(index); return std::string(dex_file.GetMethodDeclaringClassDescriptor(method_id)) + "->" + dex_file.GetMethodName(method_id) @@ -1026,7 +1026,7 @@ bool VerifierDeps::VerifyMethods(Handle<mirror::ClassLoader> class_loader, PointerSize pointer_size = class_linker->GetImagePointerSize(); for (const auto& entry : methods) { - const DexFile::MethodId& method_id = dex_file.GetMethodId(entry.GetDexMethodIndex()); + const dex::MethodId& method_id = dex_file.GetMethodId(entry.GetDexMethodIndex()); const char* name = dex_file.GetMethodName(method_id); const Signature signature = dex_file.GetMethodSignature(method_id); |
