Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Unified Diff: src/debug/debug.cc

Issue 2655253004: [inspector] introduced stepIntoAsync for chained callbacks (Closed)
Patch Set: addressed Yang's comment Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/debug/debug.cc
diff --git a/src/debug/debug.cc b/src/debug/debug.cc
index adf3659c68fdf560f267037772bf9baa38efd747..60259c5ccd95b3b1af38b528267460b040f413e4 100644
--- a/src/debug/debug.cc
+++ b/src/debug/debug.cc
@@ -1928,9 +1928,6 @@ void ResetPromiseHandle(const v8::WeakCallbackInfo<void>& info) {
// different stacks from direct Promise use, but we save and restore a
// stack once for all reactions.
//
-// If this isn't a case of async function, we return false, otherwise
-// we set the correct id and return true.
-//
// TODO(littledan): Improve this case.
int GetReferenceAsyncTaskId(Isolate* isolate, Handle<JSPromise> promise) {
Handle<Symbol> handled_by_symbol =
@@ -1951,19 +1948,44 @@ int GetReferenceAsyncTaskId(Isolate* isolate, Handle<JSPromise> promise) {
}
return Handle<Smi>::cast(async_task_id)->value();
}
+
+bool IsPromiseAllOrRaceFrame(JavaScriptFrame* frame) {
+ if (!frame->HasInlinedFrames()) {
Yang 2017/01/30 19:40:33 We can remove this check. GetFunctions should work
kozy 2017/02/15 01:00:54 Done.
+ return frame->function()->shared()->is_promise_all_or_race();
+ }
+ List<SharedFunctionInfo*> raw_shareds;
+ frame->GetFunctions(&raw_shareds);
+ for (int i = 0; i < raw_shareds.length(); ++i) {
+ if (raw_shareds[i]->is_promise_all_or_race()) return true;
+ }
+ return false;
+}
+
} // namespace
+bool Debug::IsBreakablePromiseCreated() {
+ // Promise.all and Promise.race implementations use .then internally,
+ // we don't need to break on these call.
+ JavaScriptFrameIterator it(isolate_);
+ while (!it.done()) {
+ if (IsPromiseAllOrRaceFrame(it.frame())) return false;
+ it.Advance();
+ }
+ return true;
+}
+
void Debug::RunPromiseHook(PromiseHookType type, Handle<JSPromise> promise,
Handle<Object> parent) {
if (!debug_delegate_) return;
int id = GetReferenceAsyncTaskId(isolate_, promise);
switch (type) {
case PromiseHookType::kInit:
- debug_delegate_->PromiseEventOccurred(
- debug::kDebugPromiseCreated, id,
+ debug_delegate_->PromiseCreatedEvent(
+ id,
parent->IsJSPromise() ? GetReferenceAsyncTaskId(
isolate_, Handle<JSPromise>::cast(parent))
- : 0);
+ : 0,
+ IsBreakablePromiseCreated());
return;
case PromiseHookType::kResolve:
// We can't use this hook because it's called before promise object will
@@ -2044,7 +2066,7 @@ void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id) {
if (in_debug_scope() || ignore_events()) return;
if (debug_delegate_) {
- debug_delegate_->PromiseEventOccurred(type, id, 0);
+ debug_delegate_->PromiseEventOccurred(type, id);
if (!non_inspector_listener_exists()) return;
}
« no previous file with comments | « src/debug/debug.h ('k') | src/debug/debug-interface.h » ('j') | src/inspector/v8-debugger.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698