Chromium Code Reviews| Index: src/debug/debug.cc |
| diff --git a/src/debug/debug.cc b/src/debug/debug.cc |
| index 0bdc22596c1cf06c428f3b0d32f1f5c4a526cdea..d6acd7fd26097fc2e1cabc4ef301a8dffbb6b75f 100644 |
| --- a/src/debug/debug.cc |
| +++ b/src/debug/debug.cc |
| @@ -815,7 +815,7 @@ void Debug::ClearAllBreakPoints() { |
| } |
| void Debug::FloodWithOneShot(Handle<SharedFunctionInfo> shared) { |
| - if (!shared->IsSubjectToDebugging() || IsBlackboxed(shared)) return; |
| + if (IsBlackboxed(shared)) return; |
| // Make sure the function is compiled and has set up the debug info. |
| if (!EnsureDebugInfo(shared)) return; |
| Handle<DebugInfo> debug_info(shared->GetDebugInfo()); |
| @@ -960,7 +960,7 @@ void Debug::PrepareStepOnThrow() { |
| } |
| Handle<SharedFunctionInfo> info( |
| summaries[i].AsJavaScript().function()->shared()); |
| - if (!info->IsSubjectToDebugging() || IsBlackboxed(info)) continue; |
|
dgozman
2017/03/09 23:04:01
Let's do a separate patch for this.
kozy
2017/03/10 03:14:54
Done.
|
| + if (IsBlackboxed(info)) continue; |
| FloodWithOneShot(info); |
| return; |
| } |
| @@ -1055,7 +1055,7 @@ void Debug::PrepareStep(StepAction step_action) { |
| in_current_frame = false; |
| continue; |
| } |
| - if (!info->IsSubjectToDebugging() || IsBlackboxed(info)) continue; |
| + if (IsBlackboxed(info)) continue; |
| FloodWithOneShot(info); |
| thread_local_.target_frame_count_ = current_frame_count; |
| return; |
| @@ -1732,28 +1732,26 @@ v8::Local<v8::Context> GetDebugEventContext(Isolate* isolate) { |
| } // anonymous namespace |
| bool Debug::IsExceptionBlackboxed(bool uncaught) { |
| - JavaScriptFrameIterator it(isolate_); |
| - if (it.done()) return false; |
| - // Uncaught exception is blackboxed if all current frames are blackboxed, |
| - // caught exception if top frame is blackboxed. |
| - bool is_top_frame_blackboxed = IsFrameBlackboxed(it.frame()); |
| + bool is_top_frame_blackboxed = IsTopFrameBlackboxed(); |
| if (!uncaught || !is_top_frame_blackboxed) return is_top_frame_blackboxed; |
| return AllFramesOnStackAreBlackboxed(); |
| } |
| bool Debug::IsFrameBlackboxed(JavaScriptFrame* frame) { |
| HandleScope scope(isolate_); |
| - if (!frame->HasInlinedFrames()) { |
|
dgozman
2017/03/09 23:04:00
Together with this.
kozy
2017/03/10 03:14:54
Done.
|
| - Handle<SharedFunctionInfo> shared(frame->function()->shared(), isolate_); |
| - return IsBlackboxed(shared); |
| - } |
| List<Handle<SharedFunctionInfo>> infos; |
| frame->GetFunctions(&infos); |
| - for (const auto& info : infos) |
| + for (const auto& info : infos) { |
| if (!IsBlackboxed(info)) return false; |
| + } |
| return true; |
| } |
| +bool Debug::IsTopFrameBlackboxed() { |
| + StackTraceFrameIterator it(isolate_); |
| + return !it.done() ? IsFrameBlackboxed(it.javascript_frame()) : true; |
| +} |
| + |
| void Debug::OnException(Handle<Object> exception, Handle<Object> promise) { |
| // We cannot generate debug events when JS execution is disallowed. |
| // TODO(5530): Reenable debug events within DisallowJSScopes once relevant |
| @@ -1970,22 +1968,20 @@ debug::Location GetDebugLocation(Handle<Script> script, int source_position) { |
| } // namespace |
| bool Debug::IsBlackboxed(Handle<SharedFunctionInfo> shared) { |
| - if (!debug_delegate_) return false; |
| + if (!debug_delegate_) return !shared->IsSubjectToDebugging(); |
| if (!shared->computed_debug_is_blackboxed()) { |
| - bool is_blackboxed = false; |
| - if (shared->script()->IsScript()) { |
| + bool is_blackboxed = !shared->IsSubjectToDebugging(); |
| + if (!is_blackboxed) { |
| SuppressDebug while_processing(this); |
| HandleScope handle_scope(isolate_); |
| PostponeInterruptsScope no_interrupts(isolate_); |
| DisableBreak no_recursive_break(this); |
| Handle<Script> script(Script::cast(shared->script())); |
| - if (script->type() == i::Script::TYPE_NORMAL) { |
| - debug::Location start = |
| - GetDebugLocation(script, shared->start_position()); |
| - debug::Location end = GetDebugLocation(script, shared->end_position()); |
| - is_blackboxed = debug_delegate_->IsFunctionBlackboxed( |
| - ToApiHandle<debug::Script>(script), start, end); |
| - } |
| + debug::Location start = |
| + GetDebugLocation(script, shared->start_position()); |
| + debug::Location end = GetDebugLocation(script, shared->end_position()); |
| + is_blackboxed = debug_delegate_->IsFunctionBlackboxed( |
| + ToApiHandle<debug::Script>(script), start, end); |
| } |
| shared->set_debug_is_blackboxed(is_blackboxed); |
| shared->set_computed_debug_is_blackboxed(true); |
| @@ -1996,7 +1992,6 @@ bool Debug::IsBlackboxed(Handle<SharedFunctionInfo> shared) { |
| bool Debug::AllFramesOnStackAreBlackboxed() { |
| HandleScope scope(isolate_); |
| for (StackTraceFrameIterator it(isolate_); !it.done(); it.Advance()) { |
| - if (!it.is_javascript()) continue; |
| if (!IsFrameBlackboxed(it.javascript_frame())) return false; |
| } |
| return true; |
| @@ -2019,7 +2014,6 @@ void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id, |
| it.Advance(); |
| created_by_user = |
| !it.done() && |
| - it.frame()->function()->shared()->IsSubjectToDebugging() && |
| !IsFrameBlackboxed(it.frame()); |
| } |
| debug_delegate_->PromiseEventOccurred( |
| @@ -2131,8 +2125,7 @@ MaybeHandle<Object> Debug::Call(Handle<Object> fun, Handle<Object> data) { |
| argv); |
| } |
| - |
| -void Debug::HandleDebugBreak() { |
| +void Debug::HandleDebugBreak(IgnoreBreakMode ignore_break_mode) { |
| // Initialize LiveEdit. |
| LiveEdit::InitializeThreadLocal(this); |
| // Ignore debug break during bootstrapping. |
| @@ -2153,7 +2146,10 @@ void Debug::HandleDebugBreak() { |
| // Don't stop in builtin and blackboxed functions. |
| Handle<SharedFunctionInfo> shared(JSFunction::cast(fun)->shared(), |
| isolate_); |
| - if (!shared->IsSubjectToDebugging() || IsBlackboxed(shared)) { |
| + bool ignore_break = ignore_break_mode == kTopFrameBlackboxed |
| + ? IsFrameBlackboxed(it.frame()) |
| + : AllFramesOnStackAreBlackboxed(); |
| + if (ignore_break) { |
| // Inspector uses pause on next statement for asynchronous breakpoints. |
| // When breakpoint is fired we try to break on first not blackboxed |
| // statement. To achieve this goal we need to deoptimize current |
| @@ -2161,7 +2157,9 @@ void Debug::HandleDebugBreak() { |
| // to be able to break on not blackboxed function call. |
| // TODO(yangguo): introduce break_on_function_entry since current |
| // implementation is slow. |
| - Deoptimizer::DeoptimizeFunction(JSFunction::cast(fun)); |
| + if (isolate_->stack_guard()->CheckDebugBreak()) { |
| + Deoptimizer::DeoptimizeFunction(JSFunction::cast(fun)); |
| + } |
| return; |
| } |
| JSGlobalObject* global = |