Reviewers: Yang,

Description:
Harden internal uses of .chain

[email protected]
BUG=

Please review this at https://codereview.chromium.org/212553009/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+8, -6 lines):
  M src/promise.js
  M test/mjsunit/es6/promises.js


Index: src/promise.js
diff --git a/src/promise.js b/src/promise.js
index 9937f0ced70f32d9bb6fc162be8194e9712aa996..5a834bd7afb20f569dc1a0216869df3e1519f504 100644
--- a/src/promise.js
+++ b/src/promise.js
@@ -170,7 +170,7 @@ function PromiseChain(onResolve, onReject) { // a.k.a. flatMap
 }

 function PromiseCatch(onReject) {
-  return this.chain(UNDEFINED, onReject);
+  return this.then(UNDEFINED, onReject);
 }

 function PromiseEnqueue(value, tasks) {
@@ -189,7 +189,7 @@ function PromiseHandle(value, handler, deferred) {
     if (result === deferred.promise)
       throw MakeTypeError('promise_cyclic', [result]);
     else if (IsPromise(result))
-      result.chain(deferred.resolve, deferred.reject);
+ %_CallFunction(result, deferred.resolve, deferred.reject, PromiseChain);
     else
       deferred.resolve(result);
   } catch(e) {
@@ -208,13 +208,15 @@ function PromiseThen(onResolve, onReject) {
     IS_NULL_OR_UNDEFINED(onReject) ? PromiseIdRejectHandler : onReject;
   var that = this;
   var constructor = this.constructor;
-  return this.chain(
+  return %_CallFunction(
+    this,
     function(x) {
       x = PromiseCoerce(constructor, x);
       return x === that ? onReject(MakeTypeError('promise_cyclic', [x])) :
              IsPromise(x) ? x.then(onResolve, onReject) : onResolve(x);
     },
-    onReject
+    onReject,
+    PromiseChain
   );
 }

Index: test/mjsunit/es6/promises.js
diff --git a/test/mjsunit/es6/promises.js b/test/mjsunit/es6/promises.js
index 48b96f626f2ef2d9be3de9263d89885fd3dd3bb8..ba5a306f84a23ecee98f11ddb1b1991afd394f1e 100644
--- a/test/mjsunit/es6/promises.js
+++ b/test/mjsunit/es6/promises.js
@@ -790,11 +790,11 @@ function assertAsyncDone(iteration) {

   log = ""
   Promise.all([11, Promise.accept(12), 13, MyPromise.accept(14), 15, 16])
-  assertTrue(log === "nx14cn", "subclass/all/arg")
+  assertTrue(log === "nx14n", "subclass/all/arg")

   log = ""
   MyPromise.all([21, Promise.accept(22), 23, MyPromise.accept(24), 25, 26])
- assertTrue(log === "nx24nnx21cnnx23cncnnx25cnnx26cn", "subclass/all/self")
+  assertTrue(log === "nx24nnx21nnx23nnnx25nnx26n", "subclass/all/self")
 })();




--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to