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

Unified Diff: src/promise.js

Issue 150103012: Revert "Implement Microtask Delivery Queue" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 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
« no previous file with comments | « src/object-observe.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 552ce3df30a6ae2cf0d7e2f78195a58334972cd1..db7863f8098f686cab2fc4545eab1429165797fc 100644
--- a/src/promise.js
+++ b/src/promise.js
@@ -173,29 +173,37 @@ function PromiseCatch(onReject) {
}
function PromiseEnqueue(value, tasks) {
- RunMicrotasks.queue.push(function() {
- for (var i = 0; i < tasks.length; i += 2) {
- PromiseHandle(value, tasks[i], tasks[i + 1])
- }
- });
-
+ promiseEvents.push(value, tasks);
%SetMicrotaskPending(true);
}
-function PromiseHandle(value, handler, deferred) {
- try {
- var result = handler(value);
- if (result === deferred.promise)
- throw MakeTypeError('promise_cyclic', [result]);
- else if (IsPromise(result))
- result.chain(deferred.resolve, deferred.reject);
- else
- deferred.resolve(result);
- } catch(e) {
- // TODO(rossberg): perhaps log uncaught exceptions below.
- try { deferred.reject(e) } catch(e) {}
+function PromiseMicrotaskRunner() {
+ var events = promiseEvents;
+ if (events.length > 0) {
+ promiseEvents = new InternalArray;
+ for (var i = 0; i < events.length; i += 2) {
+ var value = events[i];
+ var tasks = events[i + 1];
+ for (var j = 0; j < tasks.length; j += 2) {
+ var handler = tasks[j];
+ var deferred = tasks[j + 1];
+ try {
+ var result = handler(value);
+ if (result === deferred.promise)
+ throw MakeTypeError('promise_cyclic', [result]);
+ else if (IsPromise(result))
+ result.chain(deferred.resolve, deferred.reject);
+ else
+ deferred.resolve(result);
+ } catch(e) {
+ // TODO(rossberg): perhaps log uncaught exceptions below.
+ try { deferred.reject(e) } catch(e) {}
+ }
+ }
+ }
}
}
+RunMicrotasks.runners.push(PromiseMicrotaskRunner);
// Multi-unwrapped chaining with thenable coercion.
« no previous file with comments | « src/object-observe.js ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698