diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/common_compiler_test.cc | 2 | ||||
| -rw-r--r-- | compiler/dex/quick/quick_cfi_test.cc | 4 | ||||
| -rw-r--r-- | compiler/dex/quick/x86/quick_assemble_x86_test.cc | 4 | ||||
| -rw-r--r-- | compiler/driver/compiled_method_storage_test.cc | 2 | ||||
| -rw-r--r-- | compiler/driver/compiler_driver.cc | 3 | ||||
| -rw-r--r-- | compiler/driver/compiler_driver.h | 11 | ||||
| -rw-r--r-- | compiler/driver/compiler_options.cc | 16 | ||||
| -rw-r--r-- | compiler/driver/compiler_options.h | 15 | ||||
| -rw-r--r-- | compiler/elf_writer_debug.cc | 63 | ||||
| -rw-r--r-- | compiler/elf_writer_debug.h | 4 | ||||
| -rw-r--r-- | compiler/elf_writer_quick.cc | 2 | ||||
| -rw-r--r-- | compiler/jit/jit_compiler.cc | 19 | ||||
| -rw-r--r-- | compiler/linker/relative_patcher_test.h | 2 | ||||
| -rw-r--r-- | compiler/oat_test.cc | 2 | ||||
| -rw-r--r-- | compiler/optimizing/inliner.cc | 8 | ||||
| -rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 6 |
16 files changed, 84 insertions, 79 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc index b5fd1e074f..9594dce029 100644 --- a/compiler/common_compiler_test.cc +++ b/compiler/common_compiler_test.cc @@ -204,8 +204,6 @@ void CommonCompilerTest::CreateCompilerDriver(Compiler::Kind kind, InstructionSe 2, true, true, - "", - false, timer_.get(), -1, /* dex_to_oat_map */ nullptr, diff --git a/compiler/dex/quick/quick_cfi_test.cc b/compiler/dex/quick/quick_cfi_test.cc index 12568a4ad4..c5df134493 100644 --- a/compiler/dex/quick/quick_cfi_test.cc +++ b/compiler/dex/quick/quick_cfi_test.cc @@ -69,6 +69,8 @@ class QuickCFITest : public CFITest { false, nullptr, nullptr, + false, + "", false); VerificationResults verification_results(&compiler_options); DexFileToMethodInlinerMap method_inliner_map; @@ -88,8 +90,6 @@ class QuickCFITest : public CFITest { 0, false, false, - "", - false, 0, -1, nullptr, diff --git a/compiler/dex/quick/x86/quick_assemble_x86_test.cc b/compiler/dex/quick/x86/quick_assemble_x86_test.cc index b39fe4da4f..d63878d6b9 100644 --- a/compiler/dex/quick/x86/quick_assemble_x86_test.cc +++ b/compiler/dex/quick/x86/quick_assemble_x86_test.cc @@ -52,6 +52,8 @@ class QuickAssembleX86TestBase : public testing::Test { false, nullptr, nullptr, + false, + "", false)); verification_results_.reset(new VerificationResults(compiler_options_.get())); method_inliner_map_.reset(new DexFileToMethodInlinerMap()); @@ -69,8 +71,6 @@ class QuickAssembleX86TestBase : public testing::Test { 0, false, false, - "", - false, 0, -1, nullptr, diff --git a/compiler/driver/compiled_method_storage_test.cc b/compiler/driver/compiled_method_storage_test.cc index f18fa67ea5..2e2d1f99f3 100644 --- a/compiler/driver/compiled_method_storage_test.cc +++ b/compiler/driver/compiled_method_storage_test.cc @@ -41,8 +41,6 @@ TEST(CompiledMethodStorage, Deduplicate) { 1u, false, false, - "", - false, nullptr, -1, nullptr, diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 043bd93bd7..138863ac38 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -345,7 +345,6 @@ CompilerDriver::CompilerDriver( std::unordered_set<std::string>* compiled_classes, std::unordered_set<std::string>* compiled_methods, size_t thread_count, bool dump_stats, bool dump_passes, - const std::string& dump_cfg_file_name, bool dump_cfg_append, CumulativeLogger* timer, int swap_fd, const std::unordered_map<const DexFile*, const char*>* dex_to_oat_map, const ProfileCompilationInfo* profile_compilation_info) @@ -370,8 +369,6 @@ CompilerDriver::CompilerDriver( stats_(new AOTCompilationStats), dump_stats_(dump_stats), dump_passes_(dump_passes), - dump_cfg_file_name_(dump_cfg_file_name), - dump_cfg_append_(dump_cfg_append), timings_logger_(timer), compiler_context_(nullptr), support_boot_image_fixup_(instruction_set != kMips && instruction_set != kMips64), diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 17b2f5e98d..6a2f7bfd4e 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -95,7 +95,6 @@ class CompilerDriver { std::unordered_set<std::string>* compiled_classes, std::unordered_set<std::string>* compiled_methods, size_t thread_count, bool dump_stats, bool dump_passes, - const std::string& dump_cfg_file_name, bool dump_cfg_append, CumulativeLogger* timer, int swap_fd, const std::unordered_map<const DexFile*, const char*>* dex_to_oat_map, const ProfileCompilationInfo* profile_compilation_info); @@ -423,14 +422,6 @@ class CompilerDriver { return dump_passes_; } - const std::string& GetDumpCfgFileName() const { - return dump_cfg_file_name_; - } - - bool GetDumpCfgAppend() const { - return dump_cfg_append_; - } - CumulativeLogger* GetTimingsLogger() const { return timings_logger_; } @@ -668,8 +659,6 @@ class CompilerDriver { bool dump_stats_; const bool dump_passes_; - const std::string dump_cfg_file_name_; - const bool dump_cfg_append_; CumulativeLogger* const timings_logger_; diff --git a/compiler/driver/compiler_options.cc b/compiler/driver/compiler_options.cc index 385f34a9f9..2644528e56 100644 --- a/compiler/driver/compiler_options.cc +++ b/compiler/driver/compiler_options.cc @@ -44,7 +44,9 @@ CompilerOptions::CompilerOptions() verbose_methods_(nullptr), pass_manager_options_(), abort_on_hard_verifier_failure_(false), - init_failure_output_(nullptr) { + init_failure_output_(nullptr), + dump_cfg_file_name_(""), + dump_cfg_append_(false) { } CompilerOptions::~CompilerOptions() { @@ -71,7 +73,9 @@ CompilerOptions::CompilerOptions(CompilerFilter compiler_filter, bool compile_pic, const std::vector<std::string>* verbose_methods, std::ostream* init_failure_output, - bool abort_on_hard_verifier_failure + bool abort_on_hard_verifier_failure, + const std::string& dump_cfg_file_name, + bool dump_cfg_append ) : // NOLINT(whitespace/parens) compiler_filter_(compiler_filter), huge_method_threshold_(huge_method_threshold), @@ -94,7 +98,9 @@ CompilerOptions::CompilerOptions(CompilerFilter compiler_filter, verbose_methods_(verbose_methods), pass_manager_options_(), abort_on_hard_verifier_failure_(abort_on_hard_verifier_failure), - init_failure_output_(init_failure_output) { + init_failure_output_(init_failure_output), + dump_cfg_file_name_(dump_cfg_file_name), + dump_cfg_append_(dump_cfg_append) { } void CompilerOptions::ParseHugeMethodMax(const StringPiece& option, UsageFn Usage) { @@ -238,6 +244,10 @@ bool CompilerOptions::ParseCompilerOption(const StringPiece& option, UsageFn Usa ParsePassOptions(option, Usage); } else if (option.starts_with("--dump-init-failures=")) { ParseDumpInitFailures(option, Usage); + } else if (option.starts_with("--dump-cfg=")) { + dump_cfg_file_name_ = option.substr(strlen("--dump-cfg=")).data(); + } else if (option.starts_with("--dump-cfg-append")) { + dump_cfg_append_ = true; } else { // Option not recognized. return false; diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h index f14bdc4a2f..d47fc2ad4b 100644 --- a/compiler/driver/compiler_options.h +++ b/compiler/driver/compiler_options.h @@ -83,7 +83,9 @@ class CompilerOptions FINAL { bool compile_pic, const std::vector<std::string>* verbose_methods, std::ostream* init_failure_output, - bool abort_on_hard_verifier_failure); + bool abort_on_hard_verifier_failure, + const std::string& dump_cfg_file_name, + bool dump_cfg_append); CompilerFilter GetCompilerFilter() const { return compiler_filter_; @@ -224,6 +226,14 @@ class CompilerOptions FINAL { bool ParseCompilerOption(const StringPiece& option, UsageFn Usage); + const std::string& GetDumpCfgFileName() const { + return dump_cfg_file_name_; + } + + bool GetDumpCfgAppend() const { + return dump_cfg_append_; + } + private: void ParseDumpInitFailures(const StringPiece& option, UsageFn Usage); void ParsePassOptions(const StringPiece& option, UsageFn Usage); @@ -273,6 +283,9 @@ class CompilerOptions FINAL { // Log initialization of initialization failures to this stream if not null. std::unique_ptr<std::ostream> init_failure_output_; + std::string dump_cfg_file_name_; + bool dump_cfg_append_; + friend class Dex2Oat; DISALLOW_COPY_AND_ASSIGN(CompilerOptions); diff --git a/compiler/elf_writer_debug.cc b/compiler/elf_writer_debug.cc index dd50f69b71..3e64762096 100644 --- a/compiler/elf_writer_debug.cc +++ b/compiler/elf_writer_debug.cc @@ -653,6 +653,21 @@ class DebugInfoWriter { info_.EndTag(); // DW_TAG_member. } + if (type->IsStringClass()) { + // Emit debug info about an artifical class member for java.lang.String which represents + // the first element of the data stored in a string instance. Consumers of the debug + // info will be able to read the content of java.lang.String based on the count (real + // field) and based on the location of this data member. + info_.StartTag(DW_TAG_member); + WriteName("value"); + // We don't support fields with C like array types so we just say its type is java char. + WriteLazyType("C"); // char. + info_.WriteUdata(DW_AT_data_member_location, + mirror::String::ValueOffset().Uint32Value()); + info_.WriteSdata(DW_AT_accessibility, DW_ACCESS_private); + info_.EndTag(); // DW_TAG_member. + } + EndClassTag(desc); } } @@ -883,6 +898,8 @@ class DebugInfoWriter { info_.EndTag(); } else { // Primitive types. + DCHECK_EQ(desc.size(), 1u); + const char* name; uint32_t encoding; uint32_t byte_size; @@ -1226,26 +1243,8 @@ class DebugLineWriter { std::vector<uintptr_t> debug_line_patches; }; -// Get all types loaded by the runtime. -static std::vector<mirror::Class*> GetLoadedRuntimeTypes() SHARED_REQUIRES(Locks::mutator_lock_) { - std::vector<mirror::Class*> result; - class CollectClasses : public ClassVisitor { - public: - virtual bool Visit(mirror::Class* klass) { - classes_->push_back(klass); - return true; - } - std::vector<mirror::Class*>* classes_; - }; - CollectClasses visitor; - visitor.classes_ = &result; - Runtime::Current()->GetClassLinker()->VisitClasses(&visitor); - return result; -} - template<typename ElfTypes> static void WriteDebugSections(ElfBuilder<ElfTypes>* builder, - bool write_loaded_runtime_types, const ArrayRef<const MethodDebugInfo>& method_infos) { // Group the methods into compilation units based on source file. std::vector<CompilationUnit> compilation_units; @@ -1274,19 +1273,12 @@ static void WriteDebugSections(ElfBuilder<ElfTypes>* builder, } // Write .debug_info section. - if (!compilation_units.empty() || write_loaded_runtime_types) { + if (!compilation_units.empty()) { DebugInfoWriter<ElfTypes> 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<mirror::Class*> types = GetLoadedRuntimeTypes(); - info_writer.WriteTypes(ArrayRef<mirror::Class*>(types.data(), types.size())); - } info_writer.End(); } } @@ -1353,7 +1345,6 @@ void WriteDebugSymbols(ElfBuilder<ElfTypes>* builder, template <typename ElfTypes> void WriteDebugInfo(ElfBuilder<ElfTypes>* builder, - bool write_loaded_runtime_types, const ArrayRef<const MethodDebugInfo>& method_infos, CFIFormat cfi_format) { // Add methods to .symtab. @@ -1361,7 +1352,7 @@ void WriteDebugInfo(ElfBuilder<ElfTypes>* 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 <typename ElfTypes> @@ -1374,7 +1365,6 @@ static ArrayRef<const uint8_t> WriteDebugElfFileForMethodInternal( std::unique_ptr<ElfBuilder<ElfTypes>> builder(new ElfBuilder<ElfTypes>(isa, &out)); builder->Start(); WriteDebugInfo(builder.get(), - false, ArrayRef<const MethodDebugInfo>(&method_info, 1), DW_DEBUG_FRAME_FORMAT); builder->End(); @@ -1396,8 +1386,8 @@ ArrayRef<const uint8_t> WriteDebugElfFileForMethod(const dwarf::MethodDebugInfo& } template <typename ElfTypes> -static ArrayRef<const uint8_t> WriteDebugElfFileForClassInternal(const InstructionSet isa, - mirror::Class* type) +static ArrayRef<const uint8_t> WriteDebugElfFileForClassesInternal( + const InstructionSet isa, const ArrayRef<mirror::Class*>& types) SHARED_REQUIRES(Locks::mutator_lock_) { std::vector<uint8_t> buffer; buffer.reserve(KB); @@ -1407,7 +1397,7 @@ static ArrayRef<const uint8_t> WriteDebugElfFileForClassInternal(const Instructi DebugInfoWriter<ElfTypes> info_writer(builder.get()); info_writer.Start(); - info_writer.WriteTypes(ArrayRef<mirror::Class*>(&type, 1)); + info_writer.WriteTypes(types); info_writer.End(); builder->End(); @@ -1419,23 +1409,22 @@ static ArrayRef<const uint8_t> WriteDebugElfFileForClassInternal(const Instructi return ArrayRef<const uint8_t>(result, buffer.size()); } -ArrayRef<const uint8_t> WriteDebugElfFileForClass(const InstructionSet isa, mirror::Class* type) { +ArrayRef<const uint8_t> WriteDebugElfFileForClasses(const InstructionSet isa, + const ArrayRef<mirror::Class*>& types) { if (Is64BitInstructionSet(isa)) { - return WriteDebugElfFileForClassInternal<ElfTypes64>(isa, type); + return WriteDebugElfFileForClassesInternal<ElfTypes64>(isa, types); } else { - return WriteDebugElfFileForClassInternal<ElfTypes32>(isa, type); + return WriteDebugElfFileForClassesInternal<ElfTypes32>(isa, types); } } // Explicit instantiations template void WriteDebugInfo<ElfTypes32>( ElfBuilder<ElfTypes32>* builder, - bool write_loaded_runtime_types, const ArrayRef<const MethodDebugInfo>& method_infos, CFIFormat cfi_format); template void WriteDebugInfo<ElfTypes64>( ElfBuilder<ElfTypes64>* builder, - bool write_loaded_runtime_types, const ArrayRef<const MethodDebugInfo>& method_infos, CFIFormat cfi_format); diff --git a/compiler/elf_writer_debug.h b/compiler/elf_writer_debug.h index 91da00f97a..e4bc856c5e 100644 --- a/compiler/elf_writer_debug.h +++ b/compiler/elf_writer_debug.h @@ -32,13 +32,13 @@ struct MethodDebugInfo; template <typename ElfTypes> void WriteDebugInfo(ElfBuilder<ElfTypes>* builder, - bool write_loaded_runtime_types, const ArrayRef<const MethodDebugInfo>& method_infos, CFIFormat cfi_format); ArrayRef<const uint8_t> WriteDebugElfFileForMethod(const dwarf::MethodDebugInfo& method_info); -ArrayRef<const uint8_t> WriteDebugElfFileForClass(const InstructionSet isa, mirror::Class* type) +ArrayRef<const uint8_t> WriteDebugElfFileForClasses(const InstructionSet isa, + const ArrayRef<mirror::Class*>& types) SHARED_REQUIRES(Locks::mutator_lock_); } // namespace dwarf diff --git a/compiler/elf_writer_quick.cc b/compiler/elf_writer_quick.cc index a67f3bd1a9..7b1bdd72e5 100644 --- a/compiler/elf_writer_quick.cc +++ b/compiler/elf_writer_quick.cc @@ -152,7 +152,7 @@ template <typename ElfTypes> void ElfWriterQuick<ElfTypes>::WriteDebugInfo( const ArrayRef<const dwarf::MethodDebugInfo>& method_infos) { if (compiler_options_->GetGenerateDebugInfo()) { - dwarf::WriteDebugInfo(builder_.get(), /* write_types */ true, method_infos, kCFIFormat); + dwarf::WriteDebugInfo(builder_.get(), method_infos, kCFIFormat); } } diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc index bc51ed6e6a..3a3275a5f4 100644 --- a/compiler/jit/jit_compiler.cc +++ b/compiler/jit/jit_compiler.cc @@ -28,6 +28,8 @@ #include "dex/quick_compiler_callbacks.h" #include "driver/compiler_driver.h" #include "driver/compiler_options.h" +#include "elf_writer_debug.h" +#include "jit/debugger_interface.h" #include "jit/jit.h" #include "jit/jit_code_cache.h" #include "oat_file-inl.h" @@ -65,6 +67,17 @@ extern "C" bool jit_compile_method(void* handle, ArtMethod* method, Thread* self return jit_compiler->CompileMethod(self, method); } +extern "C" void jit_types_loaded(void* handle, mirror::Class** types, size_t count) + SHARED_REQUIRES(Locks::mutator_lock_) { + auto* jit_compiler = reinterpret_cast<JitCompiler*>(handle); + DCHECK(jit_compiler != nullptr); + if (jit_compiler->GetCompilerOptions()->GetGenerateDebugInfo()) { + const ArrayRef<mirror::Class*> types_array(types, count); + ArrayRef<const uint8_t> elf_file = dwarf::WriteDebugElfFileForClasses(kRuntimeISA, types_array); + CreateJITCodeEntry(std::unique_ptr<const uint8_t[]>(elf_file.data()), elf_file.size()); + } +} + // Callers of this method assume it has NO_RETURN. NO_RETURN static void Usage(const char* fmt, ...) { va_list ap; @@ -97,7 +110,9 @@ JitCompiler::JitCompiler() : total_time_(0) { /* pic */ true, // TODO: Support non-PIC in optimizing. /* verbose_methods */ nullptr, /* init_failure_output */ nullptr, - /* abort_on_hard_verifier_failure */ false)); + /* abort_on_hard_verifier_failure */ false, + /* dump_cfg_file_name */ "", + /* dump_cfg_append */ false)); for (const std::string& argument : Runtime::Current()->GetCompilerOptions()) { compiler_options_->ParseCompilerOption(argument, Usage); } @@ -153,8 +168,6 @@ JitCompiler::JitCompiler() : total_time_(0) { /* thread_count */ 1, /* dump_stats */ false, /* dump_passes */ false, - /* dump_cfg_file_name */ "", - /* dump_cfg_append */ false, cumulative_logger_.get(), /* swap_fd */ -1, /* dex to oat map */ nullptr, diff --git a/compiler/linker/relative_patcher_test.h b/compiler/linker/relative_patcher_test.h index b10cc3534c..bf8e786f64 100644 --- a/compiler/linker/relative_patcher_test.h +++ b/compiler/linker/relative_patcher_test.h @@ -47,7 +47,7 @@ class RelativePatcherTest : public testing::Test { driver_(&compiler_options_, &verification_results_, &inliner_map_, Compiler::kQuick, instruction_set, nullptr, false, nullptr, nullptr, nullptr, 1u, - false, false, "", false, nullptr, -1, nullptr, nullptr), + false, false, nullptr, -1, nullptr, nullptr), error_msg_(), instruction_set_(instruction_set), features_(InstructionSetFeatures::FromVariant(instruction_set, variant, &error_msg_)), diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc index 9f7ffa5ace..7a2b74ed88 100644 --- a/compiler/oat_test.cc +++ b/compiler/oat_test.cc @@ -117,8 +117,6 @@ class OatTest : public CommonCompilerTest { 2, true, true, - "", - false, timer_.get(), -1, nullptr, diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index 293282edbb..20c4f1f698 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -356,12 +356,12 @@ bool HInliner::TryInlineMonomorphicCall(HInvoke* invoke_instruction, compare, invoke_instruction->GetDexPc()); // TODO: Extend reference type propagation to understand the guard. if (cursor != nullptr) { - bb_cursor->InsertInstructionAfter(load_class, cursor); + bb_cursor->InsertInstructionAfter(field_get, cursor); } else { - bb_cursor->InsertInstructionBefore(load_class, bb_cursor->GetFirstInstruction()); + bb_cursor->InsertInstructionBefore(field_get, bb_cursor->GetFirstInstruction()); } - bb_cursor->InsertInstructionAfter(field_get, load_class); - bb_cursor->InsertInstructionAfter(compare, field_get); + bb_cursor->InsertInstructionAfter(load_class, field_get); + bb_cursor->InsertInstructionAfter(compare, load_class); bb_cursor->InsertInstructionAfter(deoptimize, compare); deoptimize->CopyEnvironmentFrom(invoke_instruction->GetEnvironment()); diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index bb840eabdd..2b44b64c00 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -127,7 +127,7 @@ class PassObserver : public ValueObject { timing_logger_enabled_(compiler_driver->GetDumpPasses()), timing_logger_(timing_logger_enabled_ ? GetMethodName() : "", true, true), disasm_info_(graph->GetArena()), - visualizer_enabled_(!compiler_driver->GetDumpCfgFileName().empty()), + visualizer_enabled_(!compiler_driver->GetCompilerOptions().GetDumpCfgFileName().empty()), visualizer_(visualizer_output, graph, *codegen), graph_in_bad_state_(false) { if (timing_logger_enabled_ || visualizer_enabled_) { @@ -358,13 +358,13 @@ void OptimizingCompiler::Init() { // Enable C1visualizer output. Must be done in Init() because the compiler // driver is not fully initialized when passed to the compiler's constructor. CompilerDriver* driver = GetCompilerDriver(); - const std::string cfg_file_name = driver->GetDumpCfgFileName(); + const std::string cfg_file_name = driver->GetCompilerOptions().GetDumpCfgFileName(); if (!cfg_file_name.empty()) { CHECK_EQ(driver->GetThreadCount(), 1U) << "Graph visualizer requires the compiler to run single-threaded. " << "Invoke the compiler with '-j1'."; std::ios_base::openmode cfg_file_mode = - driver->GetDumpCfgAppend() ? std::ofstream::app : std::ofstream::out; + driver->GetCompilerOptions().GetDumpCfgAppend() ? std::ofstream::app : std::ofstream::out; visualizer_output_.reset(new std::ofstream(cfg_file_name, cfg_file_mode)); } if (driver->GetDumpStats()) { |