diff options
| -rw-r--r-- | runtime/class_linker.cc | 13 | ||||
| -rw-r--r-- | runtime/debugger.cc | 6 | ||||
| -rw-r--r-- | runtime/native/dalvik_system_ZygoteHooks.cc | 1 | ||||
| -rw-r--r-- | runtime/runtime.cc | 1 | ||||
| -rw-r--r-- | runtime/runtime.h | 11 |
5 files changed, 26 insertions, 6 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index d0a784dfc9..d8e309d57e 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -2722,13 +2722,18 @@ bool ClassLinker::ShouldUseInterpreterEntrypoint(ArtMethod* method, const void* return true; } - if (runtime->UseJit() && runtime->GetJit()->JitAtFirstUse()) { - // The force JIT uses the interpreter entry point to execute the JIT. - return true; + if (runtime->IsNativeDebuggable()) { + DCHECK(runtime->UseJit() && runtime->GetJit()->JitAtFirstUse()); + // If we are doing native debugging, ignore application's AOT code, + // since we want to JIT it with extra stackmaps for native debugging. + // On the other hand, keep all AOT code from the boot image, since the + // blocking JIT would results in non-negligible performance impact. + return !runtime->GetHeap()->IsInBootImageOatFile(quick_code); } if (Dbg::IsDebuggerActive()) { - // Boot image classes are AOT-compiled as non-debuggable. + // Boot image classes may be AOT-compiled as non-debuggable. + // This is not suitable for the Java debugger, so ignore the AOT code. return runtime->GetHeap()->IsInBootImageOatFile(quick_code); } diff --git a/runtime/debugger.cc b/runtime/debugger.cc index bc6589380c..c375bba4c3 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -622,9 +622,11 @@ void Dbg::GoActive() { } Runtime* runtime = Runtime::Current(); - // Since boot image code is AOT compiled as not debuggable, we need to patch + // Since boot image code may be AOT compiled as not debuggable, we need to patch // entry points of methods in boot image to interpreter bridge. - if (!runtime->GetInstrumentation()->IsForcedInterpretOnly()) { + // However, the performance cost of this is non-negligible during native-debugging due to the + // forced JIT, so we keep the AOT code in that case in exchange for limited native debugging. + if (!runtime->GetInstrumentation()->IsForcedInterpretOnly() && !runtime->IsNativeDebuggable()) { ScopedObjectAccess soa(self); UpdateEntryPointsClassVisitor visitor(runtime->GetInstrumentation()); runtime->GetClassLinker()->VisitClasses(&visitor); diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc index 65002dfaba..887eee0455 100644 --- a/runtime/native/dalvik_system_ZygoteHooks.cc +++ b/runtime/native/dalvik_system_ZygoteHooks.cc @@ -121,6 +121,7 @@ static void EnableDebugFeatures(uint32_t debug_flags) { if ((debug_flags & DEBUG_NATIVE_DEBUGGABLE) != 0) { runtime->AddCompilerOption("--debuggable"); runtime->AddCompilerOption("--generate-debug-info"); + runtime->SetNativeDebuggable(true); debug_flags &= ~DEBUG_NATIVE_DEBUGGABLE; } diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 901f2f5527..5284c9377e 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -203,6 +203,7 @@ Runtime::Runtime() implicit_suspend_checks_(false), no_sig_chain_(false), is_native_bridge_loaded_(false), + is_native_debuggable_(false), zygote_max_failed_boots_(0), experimental_flags_(ExperimentalFlags::kNone), oat_file_manager_(nullptr), diff --git a/runtime/runtime.h b/runtime/runtime.h index aebfad7989..36ad7f1087 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -583,6 +583,14 @@ class Runtime { bool IsDebuggable() const; + bool IsNativeDebuggable() const { + return is_native_debuggable_; + } + + void SetNativeDebuggable(bool value) { + is_native_debuggable_ = value; + } + // Returns the build fingerprint, if set. Otherwise an empty string is returned. std::string GetFingerprint() { return fingerprint_; @@ -804,6 +812,9 @@ class Runtime { // that there's no native bridge. bool is_native_bridge_loaded_; + // Whether we are running under native debugger. + bool is_native_debuggable_; + // The maximum number of failed boots we allow before pruning the dalvik cache // and trying again. This option is only inspected when we're running as a // zygote. |