From fffbee4d158259633ec7b7f712eaf75be86bd4e5 Mon Sep 17 00:00:00 2001 From: Tamas Berghammer Date: Fri, 15 Jan 2016 13:09:34 +0000 Subject: Report types loaded during init to the native debugger The runtime loads a lot of type before it creates the jit from the boot image and from hard coded source code (e.g. primitive arrays). This change emits type information for these types after the jit has been created. At the same time we remove the type info generation that happens during AOT compilation because that type information can be modified by a class loader at runtime. Change-Id: Ie5b3b3df9d01c7200a1f670a98d9cbee796234e9 --- compiler/elf_writer_debug.cc | 46 +++++++++----------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) (limited to 'compiler/elf_writer_debug.cc') diff --git a/compiler/elf_writer_debug.cc b/compiler/elf_writer_debug.cc index 4eb1ca2f03..3e64762096 100644 --- a/compiler/elf_writer_debug.cc +++ b/compiler/elf_writer_debug.cc @@ -1243,26 +1243,8 @@ class DebugLineWriter { std::vector debug_line_patches; }; -// Get all types loaded by the runtime. -static std::vector GetLoadedRuntimeTypes() SHARED_REQUIRES(Locks::mutator_lock_) { - std::vector result; - class CollectClasses : public ClassVisitor { - public: - virtual bool Visit(mirror::Class* klass) { - classes_->push_back(klass); - return true; - } - std::vector* classes_; - }; - CollectClasses visitor; - visitor.classes_ = &result; - Runtime::Current()->GetClassLinker()->VisitClasses(&visitor); - return result; -} - template static void WriteDebugSections(ElfBuilder* builder, - bool write_loaded_runtime_types, const ArrayRef& method_infos) { // Group the methods into compilation units based on source file. std::vector compilation_units; @@ -1291,19 +1273,12 @@ static void WriteDebugSections(ElfBuilder* builder, } // Write .debug_info section. - if (!compilation_units.empty() || write_loaded_runtime_types) { + if (!compilation_units.empty()) { DebugInfoWriter info_writer(builder); info_writer.Start(); for (const auto& compilation_unit : compilation_units) { info_writer.WriteCompilationUnit(compilation_unit); } - if (write_loaded_runtime_types) { - Thread* self = Thread::Current(); - // The lock prevents the classes being moved by the GC. - ReaderMutexLock mu(self, *Locks::mutator_lock_); - std::vector types = GetLoadedRuntimeTypes(); - info_writer.WriteTypes(ArrayRef(types.data(), types.size())); - } info_writer.End(); } } @@ -1370,7 +1345,6 @@ void WriteDebugSymbols(ElfBuilder* builder, template void WriteDebugInfo(ElfBuilder* builder, - bool write_loaded_runtime_types, const ArrayRef& method_infos, CFIFormat cfi_format) { // Add methods to .symtab. @@ -1378,7 +1352,7 @@ void WriteDebugInfo(ElfBuilder* builder, // Generate CFI (stack unwinding information). WriteCFISection(builder, method_infos, cfi_format); // Write DWARF .debug_* sections. - WriteDebugSections(builder, write_loaded_runtime_types, method_infos); + WriteDebugSections(builder, method_infos); } template @@ -1391,7 +1365,6 @@ static ArrayRef WriteDebugElfFileForMethodInternal( std::unique_ptr> builder(new ElfBuilder(isa, &out)); builder->Start(); WriteDebugInfo(builder.get(), - false, ArrayRef(&method_info, 1), DW_DEBUG_FRAME_FORMAT); builder->End(); @@ -1413,8 +1386,8 @@ ArrayRef WriteDebugElfFileForMethod(const dwarf::MethodDebugInfo& } template -static ArrayRef WriteDebugElfFileForClassInternal(const InstructionSet isa, - mirror::Class* type) +static ArrayRef WriteDebugElfFileForClassesInternal( + const InstructionSet isa, const ArrayRef& types) SHARED_REQUIRES(Locks::mutator_lock_) { std::vector buffer; buffer.reserve(KB); @@ -1424,7 +1397,7 @@ static ArrayRef WriteDebugElfFileForClassInternal(const Instructi DebugInfoWriter info_writer(builder.get()); info_writer.Start(); - info_writer.WriteTypes(ArrayRef(&type, 1)); + info_writer.WriteTypes(types); info_writer.End(); builder->End(); @@ -1436,23 +1409,22 @@ static ArrayRef WriteDebugElfFileForClassInternal(const Instructi return ArrayRef(result, buffer.size()); } -ArrayRef WriteDebugElfFileForClass(const InstructionSet isa, mirror::Class* type) { +ArrayRef WriteDebugElfFileForClasses(const InstructionSet isa, + const ArrayRef& types) { if (Is64BitInstructionSet(isa)) { - return WriteDebugElfFileForClassInternal(isa, type); + return WriteDebugElfFileForClassesInternal(isa, types); } else { - return WriteDebugElfFileForClassInternal(isa, type); + return WriteDebugElfFileForClassesInternal(isa, types); } } // Explicit instantiations template void WriteDebugInfo( ElfBuilder* builder, - bool write_loaded_runtime_types, const ArrayRef& method_infos, CFIFormat cfi_format); template void WriteDebugInfo( ElfBuilder* builder, - bool write_loaded_runtime_types, const ArrayRef& method_infos, CFIFormat cfi_format); -- cgit v1.2.3-59-g8ed1b