From f6c4178aa70c5adc3d4ccdba02dae6b88b08197c Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Mon, 30 Jun 2014 11:12:42 +0000 Subject: [PATCH] Introduce debug events for promises. R=aandrey@chromium.org, rossberg@chromium.org BUG=v8:3093 LOG=Y Review URL: https://codereview.chromium.org/357603005 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22086 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- include/v8-debug.h | 3 +- src/debug-debugger.js | 29 ++++++++++++++++++- src/debug.cc | 26 +++++++++++++++++ src/debug.h | 3 ++ src/promise.js | 5 ++++ src/runtime.cc | 9 ++++++ src/runtime.h | 1 + test/mjsunit/es6/debug-promises-new-event.js | 40 +++++++++++++++++++++++++++ test/mjsunit/runtime-gen/debugpromiseevent.js | 5 ++++ tools/generate-runtime-tests.py | 6 ++-- 10 files changed, 122 insertions(+), 5 deletions(-) create mode 100644 test/mjsunit/es6/debug-promises-new-event.js create mode 100644 test/mjsunit/runtime-gen/debugpromiseevent.js diff --git a/include/v8-debug.h b/include/v8-debug.h index 90d8544..dceb997 100644 --- a/include/v8-debug.h +++ b/include/v8-debug.h @@ -20,7 +20,8 @@ enum DebugEvent { BeforeCompile = 4, AfterCompile = 5, CompileError = 6, - BreakForCommand = 7 + PromiseEvent = 7, + BreakForCommand = 8 }; diff --git a/src/debug-debugger.js b/src/debug-debugger.js index 5de8292..8afac2e 100644 --- a/src/debug-debugger.js +++ b/src/debug-debugger.js @@ -19,7 +19,8 @@ Debug.DebugEvent = { Break: 1, NewFunction: 3, BeforeCompile: 4, AfterCompile: 5, - CompileError: 6 }; + CompileError: 6, + PromiseEvent: 7 }; // Types of exceptions that can be broken upon. Debug.ExceptionBreak = { Caught : 0, @@ -1199,6 +1200,32 @@ function MakeScriptObject_(script, include_source) { } +function MakePromiseEvent(event_data) { + if (event_data.type = "new Promise") { + return new NewPromiseEvent(event_data); + } +} + + +function PromiseGetter() { + return MakeMirror(this.promise_); +} + + +function NewPromiseEvent(event_data) { + this.resolver_ = event_data.resolver; + this.promise_ = event_data.promise; +} + + +NewPromiseEvent.prototype.promise = PromiseGetter; + + +NewPromiseEvent.prototype.resolver = function() { + return MakeMirror(this.resolver_); +} + + function DebugCommandProcessor(exec_state, opt_is_running) { this.exec_state_ = exec_state; this.running_ = opt_is_running || false; diff --git a/src/debug.cc b/src/debug.cc index d99e6f5..a081127 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -2544,6 +2544,13 @@ MaybeHandle Debug::MakeCompileEvent(Handle