diff options
Diffstat (limited to 'runtime/runtime.cc')
| -rw-r--r-- | runtime/runtime.cc | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 69dcfebcb1..48efbe5413 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -106,7 +106,6 @@ #include "native/dalvik_system_VMStack.h" #include "native/dalvik_system_ZygoteHooks.h" #include "native/java_lang_Class.h" -#include "native/java_lang_DexCache.h" #include "native/java_lang_Object.h" #include "native/java_lang_String.h" #include "native/java_lang_StringFactory.h" @@ -114,6 +113,7 @@ #include "native/java_lang_Thread.h" #include "native/java_lang_Throwable.h" #include "native/java_lang_VMClassLoader.h" +#include "native/java_lang_Void.h" #include "native/java_lang_invoke_MethodHandleImpl.h" #include "native/java_lang_ref_FinalizerReference.h" #include "native/java_lang_ref_Reference.h" @@ -285,6 +285,13 @@ Runtime::~Runtime() { LOG(WARNING) << "Current thread not detached in Runtime shutdown"; } + if (jit_ != nullptr) { + // Stop the profile saver thread before marking the runtime as shutting down. + // The saver will try to dump the profiles before being sopped and that + // requires holding the mutator lock. + jit_->StopProfileSaver(); + } + { ScopedTrace trace2("Wait for shutdown cond"); MutexLock mu(self, *Locks::runtime_shutdown_lock_); @@ -326,8 +333,6 @@ Runtime::~Runtime() { // Delete thread pool before the thread list since we don't want to wait forever on the // JIT compiler threads. jit_->DeleteThreadPool(); - // Similarly, stop the profile saver thread before deleting the thread list. - jit_->StopProfileSaver(); } // TODO Maybe do some locking. @@ -801,11 +806,11 @@ void Runtime::InitNonZygoteOrPostFork( // before fork aren't attributed to an app. heap_->ResetGcPerformanceInfo(); - - if (!is_system_server && + // We may want to collect profiling samples for system server, but we never want to JIT there. + if ((!is_system_server || !jit_options_->UseJitCompilation()) && !safe_mode_ && (jit_options_->UseJitCompilation() || jit_options_->GetSaveProfilingInfo()) && - jit_.get() == nullptr) { + jit_ == nullptr) { // Note that when running ART standalone (not zygote, nor zygote fork), // the jit may have already been created. CreateJit(); @@ -1538,7 +1543,6 @@ void Runtime::RegisterRuntimeNativeMethods(JNIEnv* env) { register_dalvik_system_VMStack(env); register_dalvik_system_ZygoteHooks(env); register_java_lang_Class(env); - register_java_lang_DexCache(env); register_java_lang_Object(env); register_java_lang_invoke_MethodHandleImpl(env); register_java_lang_ref_FinalizerReference(env); @@ -1556,6 +1560,7 @@ void Runtime::RegisterRuntimeNativeMethods(JNIEnv* env) { register_java_lang_Thread(env); register_java_lang_Throwable(env); register_java_lang_VMClassLoader(env); + register_java_lang_Void(env); register_java_util_concurrent_atomic_AtomicLong(env); register_libcore_util_CharsetUtils(env); register_org_apache_harmony_dalvik_ddmc_DdmServer(env); @@ -1961,9 +1966,7 @@ void Runtime::SetCalleeSaveMethod(ArtMethod* method, CalleeSaveType type) { } void Runtime::RegisterAppInfo(const std::vector<std::string>& code_paths, - const std::string& profile_output_filename, - const std::string& foreign_dex_profile_path, - const std::string& app_dir) { + const std::string& profile_output_filename) { if (jit_.get() == nullptr) { // We are not JITing. Nothing to do. return; @@ -1985,18 +1988,7 @@ void Runtime::RegisterAppInfo(const std::vector<std::string>& code_paths, return; } - jit_->StartProfileSaver(profile_output_filename, - code_paths, - foreign_dex_profile_path, - app_dir); -} - -void Runtime::NotifyDexLoaded(const std::string& dex_location) { - VLOG(profiler) << "Notify dex loaded: " << dex_location; - // We know that if the ProfileSaver is started then we can record profile information. - if (ProfileSaver::IsStarted()) { - ProfileSaver::NotifyDexUse(dex_location); - } + jit_->StartProfileSaver(profile_output_filename, code_paths); } // Transaction support. @@ -2163,6 +2155,19 @@ void Runtime::CreateJit() { jit_.reset(jit::Jit::Create(jit_options_.get(), &error_msg)); if (jit_.get() == nullptr) { LOG(WARNING) << "Failed to create JIT " << error_msg; + return; + } + + // In case we have a profile path passed as a command line argument, + // register the current class path for profiling now. Note that we cannot do + // this before we create the JIT and having it here is the most convenient way. + // This is used when testing profiles with dalvikvm command as there is no + // framework to register the dex files for profiling. + if (jit_options_->GetSaveProfilingInfo() && + !jit_options_->GetProfileSaverOptions().GetProfilePath().empty()) { + std::vector<std::string> dex_filenames; + Split(class_path_string_, ':', &dex_filenames); + RegisterAppInfo(dex_filenames, jit_options_->GetProfileSaverOptions().GetProfilePath()); } } |