diff options
| author | 2016-01-18 14:47:32 +0000 | |
|---|---|---|
| committer | 2016-01-18 14:47:32 +0000 | |
| commit | 0e78aedf507512abcb730851025547645cd48c9c (patch) | |
| tree | 05b9ae8b23be722cf8c2a6a979cc3706437ecf71 /runtime | |
| parent | 55380bbe098bace4375d77a2b77d05ef88dfe6f6 (diff) | |
| parent | fffbee4d158259633ec7b7f712eaf75be86bd4e5 (diff) | |
Merge "Report types loaded during init to the native debugger"
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/jit/jit.cc | 30 | ||||
| -rw-r--r-- | runtime/jit/jit.h | 6 | ||||
| -rw-r--r-- | runtime/runtime.cc | 3 |
3 files changed, 32 insertions, 7 deletions
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc index 2a89077388..5c9dab2f38 100644 --- a/runtime/jit/jit.cc +++ b/runtime/jit/jit.cc @@ -127,11 +127,11 @@ bool Jit::LoadCompiler(std::string* error_msg) { *error_msg = "JIT couldn't find jit_compile_method entry point"; return false; } - jit_type_loaded_ = reinterpret_cast<void (*)(void*, mirror::Class*)>( - dlsym(jit_library_handle_, "jit_type_loaded")); - if (jit_type_loaded_ == nullptr) { + jit_types_loaded_ = reinterpret_cast<void (*)(void*, mirror::Class**, size_t)>( + dlsym(jit_library_handle_, "jit_types_loaded")); + if (jit_types_loaded_ == nullptr) { dlclose(jit_library_handle_); - *error_msg = "JIT couldn't find jit_type_loaded entry point"; + *error_msg = "JIT couldn't find jit_types_loaded entry point"; return false; } CompilerCallbacks* callbacks = nullptr; @@ -224,8 +224,26 @@ void Jit::CreateInstrumentationCache(size_t compile_threshold, size_t warmup_thr void Jit::NewTypeLoadedIfUsingJit(mirror::Class* type) { jit::Jit* jit = Runtime::Current()->GetJit(); if (jit != nullptr && jit->generate_debug_info_) { - DCHECK(jit->jit_type_loaded_ != nullptr); - jit->jit_type_loaded_(jit->jit_compiler_handle_, type); + DCHECK(jit->jit_types_loaded_ != nullptr); + jit->jit_types_loaded_(jit->jit_compiler_handle_, &type, 1); + } +} + +void Jit::DumpTypeInfoForLoadedTypes(ClassLinker* linker) { + struct CollectClasses : public ClassVisitor { + bool Visit(mirror::Class* klass) override { + classes_.push_back(klass); + return true; + } + std::vector<mirror::Class*> classes_; + }; + + if (generate_debug_info_) { + ScopedObjectAccess so(Thread::Current()); + + CollectClasses visitor; + linker->VisitClasses(&visitor); + jit_types_loaded_(jit_compiler_handle_, visitor.classes_.data(), visitor.classes_.size()); } } diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h index 443ebe8025..429edf65a6 100644 --- a/runtime/jit/jit.h +++ b/runtime/jit/jit.h @@ -82,6 +82,10 @@ class Jit { static void NewTypeLoadedIfUsingJit(mirror::Class* type) SHARED_REQUIRES(Locks::mutator_lock_); + // If debug info generation is turned on then write the type information for types already loaded + // into the specified class linker to the jit debug interface, + void DumpTypeInfoForLoadedTypes(ClassLinker* linker); + private: Jit(); bool LoadCompiler(std::string* error_msg); @@ -92,7 +96,7 @@ class Jit { void* (*jit_load_)(CompilerCallbacks**, bool*); void (*jit_unload_)(void*); bool (*jit_compile_method_)(void*, ArtMethod*, Thread*); - void (*jit_type_loaded_)(void*, mirror::Class*); + void (*jit_types_loaded_)(void*, mirror::Class**, size_t count); // Performance monitoring. bool dump_info_on_shutdown_; diff --git a/runtime/runtime.cc b/runtime/runtime.cc index c4694ee291..1101acdf61 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -1881,6 +1881,9 @@ void Runtime::CreateJit() { jit_->CreateInstrumentationCache(jit_options_->GetCompileThreshold(), jit_options_->GetWarmupThreshold()); jit_->CreateThreadPool(); + + // Notify native debugger about the classes already loaded before the creation of the jit. + jit_->DumpTypeInfoForLoadedTypes(GetClassLinker()); } else { LOG(WARNING) << "Failed to create JIT " << error_msg; } |