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

Unified Diff: src/promise.js

Issue 266533003: Reland "Trigger exception debug event for promises at the throw site." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix Created 6 years, 8 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
« src/debug.cc ('K') | « src/mirror-debugger.js ('k') | src/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/promise.js
diff --git a/src/promise.js b/src/promise.js
index 60c836c9e6de63c087a318a45dfb181c19e7d217..f3140a1be445e61831e9e7aa7913c465e268f4f9 100644
--- a/src/promise.js
+++ b/src/promise.js
@@ -35,10 +35,13 @@ function Promise(resolver) {
throw MakeTypeError('resolver_not_a_function', [resolver]);
var promise = PromiseInit(this);
try {
+ %DebugPromiseHandlePrologue(function() { return promise });
resolver(function(x) { PromiseResolve(promise, x) },
function(r) { PromiseReject(promise, r) });
} catch (e) {
PromiseReject(promise, e);
+ } finally {
+ %DebugPromiseHandleEpilogue();
}
}
@@ -161,6 +164,11 @@ function PromiseEnqueue(value, tasks) {
function PromiseHandle(value, handler, deferred) {
try {
+ %DebugPromiseHandlePrologue(
+ function() {
+ var queue = GET_PRIVATE(deferred.promise, promiseOnReject);
+ return (queue && queue.length == 0) ? deferred.promise : UNDEFINED;
+ });
var result = handler(value);
if (result === deferred.promise)
throw MakeTypeError('promise_cyclic', [result]);
@@ -169,21 +177,14 @@ function PromiseHandle(value, handler, deferred) {
else
deferred.resolve(result);
} catch (exception) {
- var uncaught = false;
- var reject_queue = GET_PRIVATE(deferred.promise, promiseOnReject);
- if (reject_queue && reject_queue.length == 0) {
- // The deferred promise may get a reject handler attached later.
- // For now, we consider the exception to be (for the moment) uncaught.
- uncaught = true;
- }
try {
+ %DebugPromiseHandlePrologue(function() { return deferred.promise });
deferred.reject(exception);
- } catch (e) {
- // The reject handler can only throw for a custom deferred promise.
- // We consider the original exception to be uncaught.
- uncaught = true;
+ } catch (e) { } finally {
+ %DebugPromiseHandleEpilogue();
}
- if (uncaught) %DebugPendingExceptionInPromise(exception, deferred.promise);
+ } finally {
+ %DebugPromiseHandleEpilogue();
}
}
@@ -321,14 +322,6 @@ function GetPromiseStatus(promise) {
return GET_PRIVATE(promise, promiseStatus);
}
-function GetPromiseOnResolve(promise) {
- return GET_PRIVATE(promise, promiseOnResolve);
-}
-
-function GetPromiseOnReject(promise) {
- return GET_PRIVATE(promise, promiseOnReject);
-}
-
function GetPromiseValue(promise) {
return GET_PRIVATE(promise, promiseValue);
}
« src/debug.cc ('K') | « src/mirror-debugger.js ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698