diff options
Diffstat (limited to 'compiler')
27 files changed, 97 insertions, 84 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc index 72afb985c0..07c73c9a20 100644 --- a/compiler/common_compiler_test.cc +++ b/compiler/common_compiler_test.cc @@ -264,7 +264,7 @@ void CommonCompilerTest::CompileMethod(ArtMethod* method) { Handle<mirror::DexCache> dex_cache(hs.NewHandle(method->GetDexCache())); Handle<mirror::ClassLoader> h_class_loader = hs.NewHandle( self->DecodeJObject(class_loader)->AsClassLoader()); - const DexFile::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset()); + const dex::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset()); std::vector<const DexFile*> dex_files; dex_files.push_back(dex_file); diff --git a/compiler/compiler.cc b/compiler/compiler.cc index 646040fd9d..54da446e6d 100644 --- a/compiler/compiler.cc +++ b/compiler/compiler.cc @@ -21,6 +21,7 @@ #include "base/macros.h" #include "base/utils.h" #include "dex/code_item_accessors-inl.h" +#include "dex/dex_file.h" #include "driver/compiler_driver.h" #include "optimizing/optimizing_compiler.h" @@ -39,7 +40,7 @@ Compiler* Compiler::Create(CompilerDriver* driver, Compiler::Kind kind) { } } -bool Compiler::IsPathologicalCase(const DexFile::CodeItem& code_item, +bool Compiler::IsPathologicalCase(const dex::CodeItem& code_item, uint32_t method_idx, const DexFile& dex_file) { /* diff --git a/compiler/compiler.h b/compiler/compiler.h index 8c07773f4c..8a67724de0 100644 --- a/compiler/compiler.h +++ b/compiler/compiler.h @@ -19,10 +19,13 @@ #include "base/mutex.h" #include "base/os.h" -#include "dex/dex_file.h" +#include "dex/invoke_type.h" namespace art { +namespace dex { +struct CodeItem; +} // namespace dex namespace jit { class JitCodeCache; class JitLogger; @@ -35,6 +38,7 @@ class DexCache; class ArtMethod; class CompilerDriver; class CompiledMethod; +class DexFile; template<class T> class Handle; class OatWriter; class Thread; @@ -54,7 +58,7 @@ class Compiler { virtual bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file) const = 0; - virtual CompiledMethod* Compile(const DexFile::CodeItem* code_item, + virtual CompiledMethod* Compile(const dex::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, @@ -102,7 +106,7 @@ class Compiler { // Returns whether the method to compile is such a pathological case that // it's not worth compiling. - static bool IsPathologicalCase(const DexFile::CodeItem& code_item, + static bool IsPathologicalCase(const dex::CodeItem& code_item, uint32_t method_idx, const DexFile& dex_file); diff --git a/compiler/debug/elf_debug_info_writer.h b/compiler/debug/elf_debug_info_writer.h index bb550b3060..a63f241f53 100644 --- a/compiler/debug/elf_debug_info_writer.h +++ b/compiler/debug/elf_debug_info_writer.h @@ -152,9 +152,9 @@ class ElfCompilationUnitWriter { DCHECK(mi->dex_file != nullptr); const DexFile* dex = mi->dex_file; CodeItemDebugInfoAccessor accessor(*dex, mi->code_item, mi->dex_method_index); - const DexFile::MethodId& dex_method = dex->GetMethodId(mi->dex_method_index); - const DexFile::ProtoId& dex_proto = dex->GetMethodPrototype(dex_method); - const DexFile::TypeList* dex_params = dex->GetProtoParameters(dex_proto); + const dex::MethodId& dex_method = dex->GetMethodId(mi->dex_method_index); + const dex::ProtoId& dex_proto = dex->GetMethodPrototype(dex_method); + const dex::TypeList* dex_params = dex->GetProtoParameters(dex_proto); const char* dex_class_desc = dex->GetMethodDeclaringClassDescriptor(dex_method); const bool is_static = (mi->access_flags & kAccStatic) != 0; diff --git a/compiler/debug/elf_debug_writer.cc b/compiler/debug/elf_debug_writer.cc index 0f2d73e5aa..16f163b085 100644 --- a/compiler/debug/elf_debug_writer.cc +++ b/compiler/debug/elf_debug_writer.cc @@ -54,7 +54,7 @@ void WriteDebugInfo(linker::ElfBuilder<ElfTypes>* builder, WriteCFISection(builder, debug_info.compiled_methods, cfi_format, write_oat_patches); // Group the methods into compilation units based on class. - std::unordered_map<const DexFile::ClassDef*, ElfCompilationUnit> class_to_compilation_unit; + std::unordered_map<const dex::ClassDef*, ElfCompilationUnit> class_to_compilation_unit; for (const MethodDebugInfo& mi : debug_info.compiled_methods) { if (mi.dex_file != nullptr) { auto& dex_class_def = mi.dex_file->GetClassDef(mi.class_def_index); diff --git a/compiler/debug/method_debug_info.h b/compiler/debug/method_debug_info.h index 729c403f00..152db6eaf0 100644 --- a/compiler/debug/method_debug_info.h +++ b/compiler/debug/method_debug_info.h @@ -32,7 +32,7 @@ struct MethodDebugInfo { size_t class_def_index; uint32_t dex_method_index; uint32_t access_flags; - const DexFile::CodeItem* code_item; + const dex::CodeItem* code_item; InstructionSet isa; bool deduped; bool is_native_debuggable; diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc index cf52dd9cf3..23ce37ef1a 100644 --- a/compiler/dex/dex_to_dex_compiler.cc +++ b/compiler/dex/dex_to_dex_compiler.cc @@ -505,7 +505,7 @@ void DexToDexCompiler::CompilationState::CompileInvokeVirtual(Instruction* inst, } CompiledMethod* DexToDexCompiler::CompileMethod( - const DexFile::CodeItem* code_item, + const dex::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type ATTRIBUTE_UNUSED, uint16_t class_def_idx, @@ -627,11 +627,11 @@ CompiledMethod* DexToDexCompiler::CompileMethod( void DexToDexCompiler::SetDexFiles(const std::vector<const DexFile*>& dex_files) { // Record what code items are already seen to detect when multiple methods have the same code // item. - std::unordered_set<const DexFile::CodeItem*> seen_code_items; + std::unordered_set<const dex::CodeItem*> seen_code_items; for (const DexFile* dex_file : dex_files) { for (ClassAccessor accessor : dex_file->GetClasses()) { for (const ClassAccessor::Method& method : accessor.GetMethods()) { - const DexFile::CodeItem* code_item = method.GetCodeItem(); + const dex::CodeItem* code_item = method.GetCodeItem(); // Detect the shared code items. if (!seen_code_items.insert(code_item).second) { shared_code_items_.insert(code_item); @@ -646,7 +646,7 @@ void DexToDexCompiler::UnquickenConflictingMethods() { MutexLock mu(Thread::Current(), lock_); size_t unquicken_count = 0; for (const auto& pair : shared_code_item_quicken_info_) { - const DexFile::CodeItem* code_item = pair.first; + const dex::CodeItem* code_item = pair.first; const QuickenState& state = pair.second; CHECK_GE(state.methods_.size(), 1u); if (state.conflict_) { diff --git a/compiler/dex/dex_to_dex_compiler.h b/compiler/dex/dex_to_dex_compiler.h index 7253488f79..78309ae7ac 100644 --- a/compiler/dex/dex_to_dex_compiler.h +++ b/compiler/dex/dex_to_dex_compiler.h @@ -23,7 +23,6 @@ #include "base/bit_vector.h" #include "base/mutex.h" -#include "dex/dex_file.h" #include "dex/invoke_type.h" #include "dex/method_reference.h" #include "handle.h" @@ -34,6 +33,11 @@ namespace art { class CompiledMethod; class CompilerDriver; class DexCompilationUnit; +class DexFile; + +namespace dex { +struct CodeItem; +} // namespace dex namespace mirror { class ClassLoader; @@ -50,7 +54,7 @@ class DexToDexCompiler { explicit DexToDexCompiler(CompilerDriver* driver); - CompiledMethod* CompileMethod(const DexFile::CodeItem* code_item, + CompiledMethod* CompileMethod(const dex::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, @@ -105,9 +109,9 @@ class DexToDexCompiler { std::unordered_map<const DexFile*, BitVector> should_quicken_; // Guarded by lock_ during writing, accessed without a lock during quickening. // This is safe because no thread is adding to the shared code items during the quickening phase. - std::unordered_set<const DexFile::CodeItem*> shared_code_items_; + std::unordered_set<const dex::CodeItem*> shared_code_items_; // Blacklisted code items are unquickened in UnquickenConflictingMethods. - std::unordered_map<const DexFile::CodeItem*, QuickenState> shared_code_item_quicken_info_ + std::unordered_map<const dex::CodeItem*, QuickenState> shared_code_item_quicken_info_ GUARDED_BY(lock_); // Number of added code items. size_t num_code_items_ GUARDED_BY(lock_) = 0u; diff --git a/compiler/dex/inline_method_analyser.cc b/compiler/dex/inline_method_analyser.cc index ba2ebd99a0..b0f025d092 100644 --- a/compiler/dex/inline_method_analyser.cc +++ b/compiler/dex/inline_method_analyser.cc @@ -511,7 +511,7 @@ bool InlineMethodAnalyser::AnalyseMethodCode(const CodeItemDataAccessor* code_it } bool InlineMethodAnalyser::IsSyntheticAccessor(MethodReference ref) { - const DexFile::MethodId& method_id = ref.dex_file->GetMethodId(ref.index); + const dex::MethodId& method_id = ref.dex_file->GetMethodId(ref.index); const char* method_name = ref.dex_file->GetMethodName(method_id); // javac names synthetic accessors "access$nnn", // jack names them "-getN", "-putN", "-wrapN". diff --git a/compiler/driver/compiler_driver-inl.h b/compiler/driver/compiler_driver-inl.h index 63dcb4664c..ec2e38bc7f 100644 --- a/compiler/driver/compiler_driver-inl.h +++ b/compiler/driver/compiler_driver-inl.h @@ -57,7 +57,7 @@ inline ObjPtr<mirror::Class> CompilerDriver::ResolveCompilingMethodsClass( const DexCompilationUnit* mUnit) { DCHECK_EQ(dex_cache->GetDexFile(), mUnit->GetDexFile()); DCHECK_EQ(class_loader.Get(), mUnit->GetClassLoader().Get()); - const DexFile::MethodId& referrer_method_id = + const dex::MethodId& referrer_method_id = mUnit->GetDexFile()->GetMethodId(mUnit->GetDexMethodIndex()); return ResolveClass(soa, dex_cache, class_loader, referrer_method_id.class_idx_, mUnit); } diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 36beb5927a..e440eec735 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -344,7 +344,7 @@ void CompilerDriver::CompileAll(jobject class_loader, static optimizer::DexToDexCompiler::CompilationLevel GetDexToDexCompilationLevel( Thread* self, const CompilerDriver& driver, Handle<mirror::ClassLoader> class_loader, - const DexFile& dex_file, const DexFile::ClassDef& class_def) + const DexFile& dex_file, const dex::ClassDef& class_def) REQUIRES_SHARED(Locks::mutator_lock_) { // When the dex file is uncompressed in the APK, we do not generate a copy in the .vdex // file. As a result, dex2oat will map the dex file read-only, and we only need to check @@ -389,7 +389,7 @@ static optimizer::DexToDexCompiler::CompilationLevel GetDexToDexCompilationLevel const CompilerDriver& driver, jobject jclass_loader, const DexFile& dex_file, - const DexFile::ClassDef& class_def) { + const dex::ClassDef& class_def) { ScopedObjectAccess soa(self); StackHandleScope<1> hs(soa.Self()); Handle<mirror::ClassLoader> class_loader( @@ -416,7 +416,7 @@ template <typename CompileFn> static void CompileMethodHarness( Thread* self, CompilerDriver* driver, - const DexFile::CodeItem* code_item, + const dex::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, @@ -465,7 +465,7 @@ static void CompileMethodHarness( static void CompileMethodDex2Dex( Thread* self, CompilerDriver* driver, - const DexFile::CodeItem* code_item, + const dex::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, @@ -476,7 +476,7 @@ static void CompileMethodDex2Dex( Handle<mirror::DexCache> dex_cache) { auto dex_2_dex_fn = [](Thread* self ATTRIBUTE_UNUSED, CompilerDriver* driver, - const DexFile::CodeItem* code_item, + const dex::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, @@ -527,7 +527,7 @@ static void CompileMethodDex2Dex( static void CompileMethodQuick( Thread* self, CompilerDriver* driver, - const DexFile::CodeItem* code_item, + const dex::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, @@ -539,7 +539,7 @@ static void CompileMethodQuick( auto quick_fn = []( Thread* self, CompilerDriver* driver, - const DexFile::CodeItem* code_item, + const dex::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, @@ -650,7 +650,7 @@ void CompilerDriver::CompileOne(Thread* self, uint32_t method_idx, uint32_t access_flags, InvokeType invoke_type, - const DexFile::CodeItem* code_item, + const dex::CodeItem* code_item, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> h_class_loader) { // Can we run DEX-to-DEX compiler on this class ? @@ -1125,7 +1125,7 @@ void CompilerDriver::LoadImageClasses(TimingLogger* timings, ScopedNullHandle<mirror::ClassLoader>()) : nullptr; if (klass == nullptr) { - const DexFile::TypeId& type_id = dex_file->GetTypeId(exception_type_idx); + const dex::TypeId& type_id = dex_file->GetTypeId(exception_type_idx); const char* descriptor = dex_file->GetTypeDescriptor(type_id); LOG(FATAL) << "Failed to resolve class " << descriptor; } @@ -1596,7 +1596,7 @@ class ResolveClassFieldsAndMethodsVisitor : public CompilationVisitor { // needs it, here we try to resolve fields and methods used in class // definitions, since many of them many never be referenced by // generated code. - const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index); + const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index); ScopedObjectAccess soa(self); StackHandleScope<2> hs(soa.Self()); Handle<mirror::ClassLoader> class_loader( @@ -1898,7 +1898,7 @@ class VerifyClassVisitor : public CompilationVisitor { ScopedTrace trace(__FUNCTION__); ScopedObjectAccess soa(Thread::Current()); const DexFile& dex_file = *manager_->GetDexFile(); - const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index); + const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index); const char* descriptor = dex_file.GetClassDescriptor(class_def); ClassLinker* class_linker = manager_->GetClassLinker(); jobject jclass_loader = manager_->GetClassLoader(); @@ -2032,7 +2032,7 @@ class SetVerifiedClassVisitor : public CompilationVisitor { ScopedTrace trace(__FUNCTION__); ScopedObjectAccess soa(Thread::Current()); const DexFile& dex_file = *manager_->GetDexFile(); - const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index); + const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index); const char* descriptor = dex_file.GetClassDescriptor(class_def); ClassLinker* class_linker = manager_->GetClassLinker(); jobject jclass_loader = manager_->GetClassLoader(); @@ -2097,8 +2097,8 @@ class InitializeClassVisitor : public CompilationVisitor { ScopedTrace trace(__FUNCTION__); jobject jclass_loader = manager_->GetClassLoader(); const DexFile& dex_file = *manager_->GetDexFile(); - const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index); - const DexFile::TypeId& class_type_id = dex_file.GetTypeId(class_def.class_idx_); + const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index); + const dex::TypeId& class_type_id = dex_file.GetTypeId(class_def.class_idx_); const char* descriptor = dex_file.StringDataByIdx(class_type_id.descriptor_idx_); ScopedObjectAccess soa(Thread::Current()); @@ -2122,8 +2122,8 @@ class InitializeClassVisitor : public CompilationVisitor { void TryInitializeClass(Handle<mirror::Class> klass, Handle<mirror::ClassLoader>& class_loader) REQUIRES_SHARED(Locks::mutator_lock_) { const DexFile& dex_file = klass->GetDexFile(); - const DexFile::ClassDef* class_def = klass->GetClassDef(); - const DexFile::TypeId& class_type_id = dex_file.GetTypeId(class_def->class_idx_); + const dex::ClassDef* class_def = klass->GetClassDef(); + const dex::TypeId& class_type_id = dex_file.GetTypeId(class_def->class_idx_); const char* descriptor = dex_file.StringDataByIdx(class_type_id.descriptor_idx_); ScopedObjectAccessUnchecked soa(Thread::Current()); StackHandleScope<3> hs(soa.Self()); @@ -2278,7 +2278,7 @@ class InitializeClassVisitor : public CompilationVisitor { StackHandleScope<1> hs(Thread::Current()); Handle<mirror::DexCache> dex_cache = hs.NewHandle(klass->GetDexCache()); - const DexFile::ClassDef* class_def = klass->GetClassDef(); + const dex::ClassDef* class_def = klass->GetClassDef(); ClassLinker* class_linker = manager_->GetClassLinker(); // Check encoded final field values for strings and intern. @@ -2320,7 +2320,7 @@ class InitializeClassVisitor : public CompilationVisitor { self->ClearException(); return false; } - const DexFile::TypeList* types = m->GetParameterTypeList(); + const dex::TypeList* types = m->GetParameterTypeList(); if (types != nullptr) { for (uint32_t i = 0; i < types->Size(); ++i) { dex::TypeIndex param_type_idx = types->GetTypeItem(i).type_idx_; @@ -2575,7 +2575,7 @@ static void CompileDexFile(CompilerDriver* driver, ClassLinker* class_linker = context.GetClassLinker(); jobject jclass_loader = context.GetClassLoader(); ClassReference ref(&dex_file, class_def_index); - const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index); + const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index); ClassAccessor accessor(dex_file, class_def_index); CompilerDriver* const driver = context.GetCompiler(); // Skip compiling classes with generic verifier failures since they will still fail at runtime diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 025a632a8e..6f8ec125bc 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -36,7 +36,6 @@ #include "class_status.h" #include "compiler.h" #include "dex/class_reference.h" -#include "dex/dex_file.h" #include "dex/dex_file_types.h" #include "dex/dex_to_dex_compiler.h" #include "dex/method_reference.h" @@ -47,6 +46,10 @@ namespace art { +namespace dex { +struct CodeItem; +} // namespace dex + namespace mirror { class Class; class DexCache; @@ -62,6 +65,7 @@ class BitVector; class CompiledMethod; class CompilerOptions; class DexCompilationUnit; +class DexFile; template<class T> class Handle; struct InlineIGetIPutData; class InstructionSetFeatures; @@ -127,7 +131,7 @@ class CompilerDriver { uint32_t method_idx, uint32_t access_flags, InvokeType invoke_type, - const DexFile::CodeItem* code_item, + const dex::CodeItem* code_item, Handle<mirror::DexCache> dex_cache, Handle<mirror::ClassLoader> h_class_loader) REQUIRES(!Locks::mutator_lock_); diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc index b9241292ee..e73d0724c9 100644 --- a/compiler/driver/compiler_driver_test.cc +++ b/compiler/driver/compiler_driver_test.cc @@ -80,7 +80,7 @@ class CompilerDriverTest : public CommonCompilerTest { void MakeDexFileExecutable(jobject class_loader, const DexFile& dex_file) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); 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); ScopedObjectAccess soa(Thread::Current()); StackHandleScope<1> hs(soa.Self()); diff --git a/compiler/driver/dex_compilation_unit.cc b/compiler/driver/dex_compilation_unit.cc index e5a6f0e177..0d0f074917 100644 --- a/compiler/driver/dex_compilation_unit.cc +++ b/compiler/driver/dex_compilation_unit.cc @@ -30,7 +30,7 @@ namespace art { DexCompilationUnit::DexCompilationUnit(Handle<mirror::ClassLoader> class_loader, ClassLinker* class_linker, const DexFile& dex_file, - const DexFile::CodeItem* code_item, + const dex::CodeItem* code_item, uint16_t class_def_idx, uint32_t method_idx, uint32_t access_flags, diff --git a/compiler/driver/dex_compilation_unit.h b/compiler/driver/dex_compilation_unit.h index 757f0e7695..f68d93f0cb 100644 --- a/compiler/driver/dex_compilation_unit.h +++ b/compiler/driver/dex_compilation_unit.h @@ -39,7 +39,7 @@ class DexCompilationUnit : public DeletableArenaObject<kArenaAllocMisc> { DexCompilationUnit(Handle<mirror::ClassLoader> class_loader, ClassLinker* class_linker, const DexFile& dex_file, - const DexFile::CodeItem* code_item, + const dex::CodeItem* code_item, uint16_t class_def_idx, uint32_t method_idx, uint32_t access_flags, @@ -67,17 +67,17 @@ class DexCompilationUnit : public DeletableArenaObject<kArenaAllocMisc> { return dex_method_idx_; } - const DexFile::CodeItem* GetCodeItem() const { + const dex::CodeItem* GetCodeItem() const { return code_item_; } const char* GetShorty() const { - const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_); + const dex::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_); return dex_file_->GetMethodShorty(method_id); } const char* GetShorty(uint32_t* shorty_len) const { - const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_); + const dex::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_); return dex_file_->GetMethodShorty(method_id, shorty_len); } @@ -165,7 +165,7 @@ class DexCompilationUnit : public DeletableArenaObject<kArenaAllocMisc> { const DexFile* const dex_file_; - const DexFile::CodeItem* const code_item_; + const dex::CodeItem* const code_item_; const uint16_t class_def_idx_; const uint32_t dex_method_idx_; const uint32_t access_flags_; diff --git a/compiler/exception_test.cc b/compiler/exception_test.cc index f0f179ca14..d5ceafeac9 100644 --- a/compiler/exception_test.cc +++ b/compiler/exception_test.cc @@ -135,8 +135,8 @@ TEST_F(ExceptionTest, FindCatchHandler) { ASSERT_EQ(2u, accessor.TriesSize()); ASSERT_NE(0u, accessor.InsnsSizeInCodeUnits()); - const DexFile::TryItem& t0 = accessor.TryItems().begin()[0]; - const DexFile::TryItem& t1 = accessor.TryItems().begin()[1]; + const dex::TryItem& t0 = accessor.TryItems().begin()[0]; + const dex::TryItem& t1 = accessor.TryItems().begin()[1]; EXPECT_LE(t0.start_addr_, t1.start_addr_); { CatchHandlerIterator iter(accessor, 4 /* Dex PC in the first try block */); diff --git a/compiler/optimizing/block_builder.cc b/compiler/optimizing/block_builder.cc index d1ccbee5f5..3672cce4c5 100644 --- a/compiler/optimizing/block_builder.cc +++ b/compiler/optimizing/block_builder.cc @@ -68,7 +68,7 @@ bool HBasicBlockBuilder::CreateBranchTargets() { // places where the program might fall through into/out of the a block and // where TryBoundary instructions will be inserted later. Other edges which // enter/exit the try blocks are a result of branches/switches. - for (const DexFile::TryItem& try_item : code_item_accessor_.TryItems()) { + for (const dex::TryItem& try_item : code_item_accessor_.TryItems()) { uint32_t dex_pc_start = try_item.start_addr_; uint32_t dex_pc_end = dex_pc_start + try_item.insn_count_; MaybeCreateBlockAt(dex_pc_start); @@ -222,9 +222,9 @@ void HBasicBlockBuilder::ConnectBasicBlocks() { } // Returns the TryItem stored for `block` or nullptr if there is no info for it. -static const DexFile::TryItem* GetTryItem( +static const dex::TryItem* GetTryItem( HBasicBlock* block, - const ScopedArenaSafeMap<uint32_t, const DexFile::TryItem*>& try_block_info) { + const ScopedArenaSafeMap<uint32_t, const dex::TryItem*>& try_block_info) { auto iterator = try_block_info.find(block->GetBlockId()); return (iterator == try_block_info.end()) ? nullptr : iterator->second; } @@ -235,7 +235,7 @@ static const DexFile::TryItem* GetTryItem( // for a handler. static void LinkToCatchBlocks(HTryBoundary* try_boundary, const CodeItemDataAccessor& accessor, - const DexFile::TryItem* try_item, + const dex::TryItem* try_item, const ScopedArenaSafeMap<uint32_t, HBasicBlock*>& catch_blocks) { for (CatchHandlerIterator it(accessor.GetCatchHandlerData(try_item->handler_off_)); it.HasNext(); @@ -279,7 +279,7 @@ void HBasicBlockBuilder::InsertTryBoundaryBlocks() { // Keep a map of all try blocks and their respective TryItems. We do not use // the block's pointer but rather its id to ensure deterministic iteration. - ScopedArenaSafeMap<uint32_t, const DexFile::TryItem*> try_block_info( + ScopedArenaSafeMap<uint32_t, const dex::TryItem*> try_block_info( std::less<uint32_t>(), local_allocator_->Adapter(kArenaAllocGraphBuilder)); // Obtain TryItem information for blocks with throwing instructions, and split @@ -295,7 +295,7 @@ void HBasicBlockBuilder::InsertTryBoundaryBlocks() { // loop for synchronized blocks. if (ContainsElement(throwing_blocks_, block)) { // Try to find a TryItem covering the block. - const DexFile::TryItem* try_item = code_item_accessor_.FindTryItem(block->GetDexPc()); + const dex::TryItem* try_item = code_item_accessor_.FindTryItem(block->GetDexPc()); if (try_item != nullptr) { // Block throwing and in a TryItem. Store the try block information. try_block_info.Put(block->GetBlockId(), try_item); @@ -348,7 +348,7 @@ void HBasicBlockBuilder::InsertTryBoundaryBlocks() { // that all predecessors are relinked to. This preserves loop headers (b/23895756). for (const auto& entry : try_block_info) { uint32_t block_id = entry.first; - const DexFile::TryItem* try_item = entry.second; + const dex::TryItem* try_item = entry.second; HBasicBlock* try_block = graph_->GetBlocks()[block_id]; for (HBasicBlock* predecessor : try_block->GetPredecessors()) { if (GetTryItem(predecessor, try_block_info) != try_item) { @@ -367,7 +367,7 @@ void HBasicBlockBuilder::InsertTryBoundaryBlocks() { // the successor is not in the same TryItem. for (const auto& entry : try_block_info) { uint32_t block_id = entry.first; - const DexFile::TryItem* try_item = entry.second; + const dex::TryItem* try_item = entry.second; HBasicBlock* try_block = graph_->GetBlocks()[block_id]; // NOTE: Do not use iterators because SplitEdge would invalidate them. for (size_t i = 0, e = try_block->GetSuccessors().size(); i < e; ++i) { diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc index 04e0cc4bdd..9e2f5cd508 100644 --- a/compiler/optimizing/code_generator.cc +++ b/compiler/optimizing/code_generator.cc @@ -987,7 +987,7 @@ static void CheckCovers(uint32_t dex_pc, // dex branch instructions. static void CheckLoopEntriesCanBeUsedForOsr(const HGraph& graph, const CodeInfo& code_info, - const DexFile::CodeItem& code_item) { + const dex::CodeItem& code_item) { if (graph.HasTryCatch()) { // One can write loops through try/catch, which we do not support for OSR anyway. return; @@ -1029,7 +1029,7 @@ static void CheckLoopEntriesCanBeUsedForOsr(const HGraph& graph, } } -ScopedArenaVector<uint8_t> CodeGenerator::BuildStackMaps(const DexFile::CodeItem* code_item) { +ScopedArenaVector<uint8_t> CodeGenerator::BuildStackMaps(const dex::CodeItem* code_item) { ScopedArenaVector<uint8_t> stack_map = GetStackMapStream()->Encode(); if (kIsDebugBuild && code_item != nullptr) { CheckLoopEntriesCanBeUsedForOsr(*graph_, CodeInfo(stack_map.data()), *code_item); diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h index 39966ff8ea..f70ecb612d 100644 --- a/compiler/optimizing/code_generator.h +++ b/compiler/optimizing/code_generator.h @@ -349,7 +349,7 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> { void AddSlowPath(SlowPathCode* slow_path); - ScopedArenaVector<uint8_t> BuildStackMaps(const DexFile::CodeItem* code_item_for_osr_check); + ScopedArenaVector<uint8_t> BuildStackMaps(const dex::CodeItem* code_item_for_osr_check); size_t GetNumberOfJitRoots() const; // Fills the `literals` array with literals collected during code generation. diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc index 07966207f7..2a7bbcb72f 100644 --- a/compiler/optimizing/graph_visualizer.cc +++ b/compiler/optimizing/graph_visualizer.cc @@ -393,7 +393,7 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor { void VisitLoadMethodType(HLoadMethodType* load_method_type) override { StartAttributeStream("load_kind") << "RuntimeCall"; const DexFile& dex_file = load_method_type->GetDexFile(); - const DexFile::ProtoId& proto_id = dex_file.GetProtoId(load_method_type->GetProtoIndex()); + const dex::ProtoId& proto_id = dex_file.GetProtoId(load_method_type->GetProtoIndex()); StartAttributeStream("method_type") << dex_file.GetProtoSignature(proto_id); } diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index 854228beb9..8440e9aa4c 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -1756,7 +1756,7 @@ bool HInliner::TryBuildAndInlineHelper(HInvoke* invoke_instruction, HInstruction** return_replacement) { DCHECK(!(resolved_method->IsStatic() && receiver_type.IsValid())); ScopedObjectAccess soa(Thread::Current()); - const DexFile::CodeItem* code_item = resolved_method->GetCodeItem(); + const dex::CodeItem* code_item = resolved_method->GetCodeItem(); const DexFile& callee_dex_file = *resolved_method->GetDexFile(); uint32_t method_index = resolved_method->GetDexMethodIndex(); CodeItemDebugInfoAccessor code_item_accessor(resolved_method->DexInstructionDebugInfo()); @@ -2027,7 +2027,7 @@ bool HInliner::TryBuildAndInlineHelper(HInvoke* invoke_instruction, } void HInliner::RunOptimizations(HGraph* callee_graph, - const DexFile::CodeItem* code_item, + const dex::CodeItem* code_item, const DexCompilationUnit& dex_compilation_unit) { // Note: if the outermost_graph_ is being compiled OSR, we should not run any // optimization that could lead to a HDeoptimize. The following optimizations do not. @@ -2112,7 +2112,7 @@ bool HInliner::ArgumentTypesMoreSpecific(HInvoke* invoke_instruction, ArtMethod* // Iterate over the list of parameter types and test whether any of the // actual inputs has a more specific reference type than the type declared in // the signature. - const DexFile::TypeList* param_list = resolved_method->GetParameterTypeList(); + const dex::TypeList* param_list = resolved_method->GetParameterTypeList(); for (size_t param_idx = 0, input_idx = resolved_method->IsStatic() ? 0 : 1, e = (param_list == nullptr ? 0 : param_list->Size()); diff --git a/compiler/optimizing/inliner.h b/compiler/optimizing/inliner.h index 8ac2163a94..efd4c74079 100644 --- a/compiler/optimizing/inliner.h +++ b/compiler/optimizing/inliner.h @@ -99,7 +99,7 @@ class HInliner : public HOptimization { // Run simple optimizations on `callee_graph`. void RunOptimizations(HGraph* callee_graph, - const DexFile::CodeItem* code_item, + const dex::CodeItem* code_item, const DexCompilationUnit& dex_compilation_unit) REQUIRES_SHARED(Locks::mutator_lock_); diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index b6ef2b614f..5e7b57523f 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -559,7 +559,7 @@ void HInstructionBuilder::InitializeParameters() { uint16_t locals_index = graph_->GetNumberOfLocalVRegs(); uint16_t parameter_index = 0; - const DexFile::MethodId& referrer_method_id = + const dex::MethodId& referrer_method_id = dex_file_->GetMethodId(dex_compilation_unit_->GetDexMethodIndex()); if (!dex_compilation_unit_->IsStatic()) { // Add the implicit 'this' argument, not expressed in the signature. @@ -576,8 +576,8 @@ void HInstructionBuilder::InitializeParameters() { DCHECK(current_this_parameter_ == nullptr); } - const DexFile::ProtoId& proto = dex_file_->GetMethodPrototype(referrer_method_id); - const DexFile::TypeList* arg_types = dex_file_->GetProtoParameters(proto); + const dex::ProtoId& proto = dex_file_->GetMethodPrototype(referrer_method_id); + const dex::TypeList* arg_types = dex_file_->GetProtoParameters(proto); for (int i = 0, shorty_pos = 1; i < number_of_parameters; i++) { HParameterValue* parameter = new (allocator_) HParameterValue( *dex_file_, @@ -1515,7 +1515,7 @@ bool HInstructionBuilder::HandleStringInit(HInvoke* invoke, } static DataType::Type GetFieldAccessType(const DexFile& dex_file, uint16_t field_index) { - const DexFile::FieldId& field_id = dex_file.GetFieldId(field_index); + const dex::FieldId& field_id = dex_file.GetFieldId(field_index); const char* type = dex_file.GetFieldTypeDescriptor(field_id); return DataType::FromShorty(type[0]); } @@ -3143,7 +3143,7 @@ ObjPtr<mirror::Class> HInstructionBuilder::LookupResolvedType( ObjPtr<mirror::Class> HInstructionBuilder::LookupReferrerClass() const { // TODO: Cache the result in a Handle<mirror::Class>. - const DexFile::MethodId& method_id = + const dex::MethodId& method_id = dex_compilation_unit_->GetDexFile()->GetMethodId(dex_compilation_unit_->GetDexMethodIndex()); return LookupResolvedType(method_id.class_idx_, *dex_compilation_unit_); } diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index e9a2f96798..f7c16d1d02 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -689,7 +689,7 @@ HCurrentMethod* HGraph::GetCurrentMethod() { } const char* HGraph::GetMethodName() const { - const DexFile::MethodId& method_id = dex_file_.GetMethodId(method_idx_); + const dex::MethodId& method_id = dex_file_.GetMethodId(method_idx_); return dex_file_.GetMethodName(method_id); } diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index a8fa370993..3b34e8d0f6 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -272,7 +272,7 @@ class OptimizingCompiler final : public Compiler { bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file) const override; - CompiledMethod* Compile(const DexFile::CodeItem* code_item, + CompiledMethod* Compile(const dex::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, @@ -370,7 +370,7 @@ class OptimizingCompiler final : public Compiler { CompiledMethod* Emit(ArenaAllocator* allocator, CodeVectorAllocator* code_allocator, CodeGenerator* codegen, - const DexFile::CodeItem* item) const; + const dex::CodeItem* item) const; // Try compiling a method and return the code generator used for // compiling it. @@ -760,7 +760,7 @@ static ArenaVector<linker::LinkerPatch> EmitAndSortLinkerPatches(CodeGenerator* CompiledMethod* OptimizingCompiler::Emit(ArenaAllocator* allocator, CodeVectorAllocator* code_allocator, CodeGenerator* codegen, - const DexFile::CodeItem* code_item_for_osr_check) const { + const dex::CodeItem* code_item_for_osr_check) const { ArenaVector<linker::LinkerPatch> linker_patches = EmitAndSortLinkerPatches(codegen); ScopedArenaVector<uint8_t> stack_map = codegen->BuildStackMaps(code_item_for_osr_check); @@ -799,7 +799,7 @@ CodeGenerator* OptimizingCompiler::TryCompile(ArenaAllocator* allocator, InstructionSet instruction_set = compiler_options.GetInstructionSet(); const DexFile& dex_file = *dex_compilation_unit.GetDexFile(); uint32_t method_idx = dex_compilation_unit.GetDexMethodIndex(); - const DexFile::CodeItem* code_item = dex_compilation_unit.GetCodeItem(); + const dex::CodeItem* code_item = dex_compilation_unit.GetCodeItem(); // Always use the Thumb-2 assembler: some runtime functionality // (like implicit stack overflow checks) assume Thumb-2. @@ -1033,7 +1033,7 @@ CodeGenerator* OptimizingCompiler::TryCompileIntrinsic( return codegen.release(); } -CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item, +CompiledMethod* OptimizingCompiler::Compile(const dex::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, @@ -1254,7 +1254,7 @@ bool OptimizingCompiler::JitCompile(Thread* self, const DexFile* dex_file = method->GetDexFile(); const uint16_t class_def_idx = method->GetClassDefIndex(); - const DexFile::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset()); + const dex::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset()); const uint32_t method_idx = method->GetDexMethodIndex(); const uint32_t access_flags = method->GetAccessFlags(); diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h index 4e376b1c57..e5f694109a 100644 --- a/compiler/optimizing/optimizing_unit_test.h +++ b/compiler/optimizing/optimizing_unit_test.h @@ -155,7 +155,7 @@ class OptimizingUnitTestHelper { void* aligned_data = GetAllocator()->Alloc(code_item_size); memcpy(aligned_data, &data[0], code_item_size); CHECK_ALIGNED(aligned_data, StandardDexFile::CodeItem::kAlignment); - const DexFile::CodeItem* code_item = reinterpret_cast<const DexFile::CodeItem*>(aligned_data); + const dex::CodeItem* code_item = reinterpret_cast<const dex::CodeItem*>(aligned_data); { ScopedObjectAccess soa(Thread::Current()); diff --git a/compiler/verifier_deps_test.cc b/compiler/verifier_deps_test.cc index c00f848f3a..092e931944 100644 --- a/compiler/verifier_deps_test.cc +++ b/compiler/verifier_deps_test.cc @@ -147,7 +147,7 @@ class VerifierDepsTest : public CommonCompilerTest { hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader_))); Handle<mirror::DexCache> dex_cache_handle(hs.NewHandle(klass_Main_->GetDexCache())); - const DexFile::ClassDef* class_def = klass_Main_->GetClassDef(); + const dex::ClassDef* class_def = klass_Main_->GetClassDef(); ClassAccessor accessor(*primary_dex_file_, *class_def); bool has_failures = true; @@ -228,7 +228,7 @@ class VerifierDepsTest : public CommonCompilerTest { for (const DexFile* dex_file : dex_files_) { const std::set<dex::TypeIndex>& unverified_classes = deps.GetUnverifiedClasses(*dex_file); for (uint32_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); cls.Assign(class_linker_->FindClass(soa.Self(), descriptor, class_loader_handle)); if (cls == nullptr) { @@ -250,7 +250,7 @@ class VerifierDepsTest : public CommonCompilerTest { } bool HasUnverifiedClass(const std::string& cls, const DexFile& dex_file) { - const DexFile::TypeId* type_id = dex_file.FindTypeId(cls.c_str()); + const dex::TypeId* type_id = dex_file.FindTypeId(cls.c_str()); DCHECK(type_id != nullptr); dex::TypeIndex index = dex_file.GetIndexForTypeId(*type_id); for (const auto& dex_dep : verifier_deps_->dex_deps_) { @@ -329,7 +329,7 @@ class VerifierDepsTest : public CommonCompilerTest { continue; } - const DexFile::FieldId& field_id = dex_dep.first->GetFieldId(entry.GetDexFieldIndex()); + const dex::FieldId& field_id = dex_dep.first->GetFieldId(entry.GetDexFieldIndex()); std::string actual_klass = dex_dep.first->StringByTypeIdx(field_id.class_idx_); if (expected_klass != actual_klass) { @@ -381,7 +381,7 @@ class VerifierDepsTest : public CommonCompilerTest { continue; } - const DexFile::MethodId& method_id = dex_dep.first->GetMethodId(entry.GetDexMethodIndex()); + const dex::MethodId& method_id = dex_dep.first->GetMethodId(entry.GetDexMethodIndex()); std::string actual_klass = dex_dep.first->StringByTypeIdx(method_id.class_idx_); if (expected_klass != actual_klass) { |