Backed out 2 changesets (bug 1534392) for failing in ecma262-issue-1461.js CLOSED TREE
authorNoemi Erli <nerli@mozilla.com>
Wed, 13 Mar 2019 00:43:31 +0200
changeset 521613 00919ccaa29fbb72e5dec48903197acdb26ead0d
parent 521612 7f47a4e7c43fcbe886d181df931d082b10f9a36f
child 521614 3e9b5b700a9d49cce14b1636df6f2096876bb616
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1534392
milestone67.0a1
backs out4c52efb1430f4b71a272998add34b63e53b00210
47e570e513851c5e4a7b930af82ad9de21e0bb22
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 2 changesets (bug 1534392) for failing in ecma262-issue-1461.js CLOSED TREE Backed out changeset 4c52efb1430f (bug 1534392) Backed out changeset 47e570e51385 (bug 1534392)
js/src/builtin/Promise.cpp
js/src/tests/non262/async-functions/ecma262-issue-1461.js
--- a/js/src/builtin/Promise.cpp
+++ b/js/src/builtin/Promise.cpp
@@ -3544,53 +3544,56 @@ MOZ_MUST_USE bool js::AsyncFunctionThrow
 // 25.7.5.1 AsyncFunctionStart, steps 3.d-e, 3.g.
 MOZ_MUST_USE bool js::AsyncFunctionReturned(
     JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value) {
   return ResolvePromiseInternal(cx, resultPromise, value);
 }
 
 // https://tc39.github.io/ecma262/#await
 //
-// Helper function that performs 6.2.3.1 Await(promise) steps 2 and 9.
-// The same steps are also used in a few other places in the spec.
+// Helper function that performs 6.2.3.1 Await(promise) steps 2-3 and 10, or
+// similar.
 template <typename T>
 static MOZ_MUST_USE bool InternalAwait(JSContext* cx, HandleValue value,
                                        HandleObject resultPromise,
                                        HandleValue onFulfilled,
                                        HandleValue onRejected, T extraStep) {
   MOZ_ASSERT(onFulfilled.isInt32());
   MOZ_ASSERT(onRejected.isInt32());
 
-  // Step 2: Let promise be ? PromiseResolve(%Promise%, « value »).
+  // The proposal <https://github.com/tc39/ecma262/pull/1250>
+  // replaces steps 2-3 with the following updated step:
+  // Step 2: Let promise be ? PromiseResolve(« value »).
+  // Step 3 is deleted.
   RootedObject promise(cx, PromiseObject::unforgeableResolve(cx, value));
   if (!promise) {
     return false;
   }
 
   // This downcast is safe because unforgeableResolve either returns `value`
   // (only if it is already a possibly-wrapped promise) or creates a new
   // promise using the Promise constructor.
   Rooted<PromiseObject*> unwrappedPromise(
       cx, UnwrapAndDowncastObject<PromiseObject>(cx, promise));
   if (!unwrappedPromise) {
     return false;
   }
 
-  // Steps 3-8 of the spec create onFulfilled and onRejected functions.
-
-  // Step 9: Perform ! PerformPromiseThen(promise, onFulfilled, onRejected).
+  // Steps 4-9 of the spec create onFulfilled and onRejected functions.
   Rooted<PromiseCapability> resultCapability(cx);
   resultCapability.promise().set(resultPromise);
   Rooted<PromiseReactionRecord*> reaction(
       cx, NewReactionRecord(cx, resultCapability, onFulfilled, onRejected,
                             IncumbentGlobalObject::Yes));
   if (!reaction) {
     return false;
   }
   extraStep(reaction);
+
+  // Step 10: Perform ! PerformPromiseThen(promise, onFulfilled, onRejected).
   return PerformPromiseThenWithReaction(cx, unwrappedPromise, reaction);
 }
 
 // https://tc39.github.io/ecma262/#await
 //
 // 6.2.3.1 Await(promise) steps 2-10 when the running execution context is
 // evaluating an `await` expression in an async function.
 MOZ_MUST_USE JSObject* js::AsyncFunctionAwait(
@@ -3793,41 +3796,38 @@ bool js::AsyncFromSyncIteratorMethod(JSC
 
   // Step 3: Let value be IteratorValue(result).
   // Step 4: IfAbruptRejectPromise(value, promiseCapability).
   RootedValue value(cx);
   if (!GetProperty(cx, resultObj, resultObj, cx->names().value, &value)) {
     return AbruptRejectPromise(cx, args, resultPromise, nullptr);
   }
 
-  // Step numbers below include the changes in
-  // <https://github.com/tc39/ecma262/pull/1470>, which inserted a new step 6.
-  //
   // Steps 7-9 (reordered).
   // Step 7: Let steps be the algorithm steps defined in Async-from-Sync
   //         Iterator Value Unwrap Functions.
   // Step 8: Let onFulfilled be CreateBuiltinFunction(steps, « [[Done]] »).
   // Step 9: Set onFulfilled.[[Done]] to done.
   RootedValue onFulfilled(
       cx,
       Int32Value(done ? PromiseHandlerAsyncFromSyncIteratorValueUnwrapDone
                       : PromiseHandlerAsyncFromSyncIteratorValueUnwrapNotDone));
   RootedValue onRejected(cx, Int32Value(PromiseHandlerThrower));
 
-  // Steps 5 and 10 are identical to some steps in Await; we have a utility
+  // These steps are identical to some steps in Await; we have a utility
   // function InternalAwait() that implements the idiom.
   //
-  // Step 5: Let valueWrapper be PromiseResolve(%Promise%, « value »).
-  // Step 6: IfAbruptRejectPromise(valueWrapper, promiseCapability).
+  // Steps 5-6, as amended by <https://github.com/tc39/ecma262/pull/1250>:
+  //      Let valueWrapper be ? PromiseResolve(« value »).
   // Step 10: Perform ! PerformPromiseThen(valueWrapper, onFulfilled,
-  //                                      undefined, promiseCapability).
+  //                                       undefined, promiseCapability).
   auto extra = [](Handle<PromiseReactionRecord*> reaction) {};
   if (!InternalAwait(cx, value, resultPromise, onFulfilled, onRejected,
                      extra)) {
-    return AbruptRejectPromise(cx, args, resultPromise, nullptr);
+    return false;
   }
 
   // Step 11: Return promiseCapability.[[Promise]].
   args.rval().setObject(*resultPromise);
   return true;
 }
 
 enum class ResumeNextKind { Enqueue, Reject, Resolve };
@@ -3989,43 +3989,44 @@ static MOZ_MUST_USE bool AsyncGeneratorR
 
         // Step 10.b.i: If completion.[[Type]] is return, then
         if (completionKind == CompletionKind::Return) {
           // Step 10.b.i.1: Set generator.[[AsyncGeneratorState]] to
           //                "awaiting-return".
           unwrappedGenerator->setAwaitingReturn();
 
           // (reordered)
-          // Step 10.b.i.3: Let stepsFulfilled be the algorithm steps defined in
+          // Step 10.b.i.4: Let stepsFulfilled be the algorithm steps defined in
           //                AsyncGeneratorResumeNext Return Processor Fulfilled
           //                Functions.
-          // Step 10.b.i.4: Let onFulfilled be CreateBuiltinFunction(
+          // Step 10.b.i.5: Let onFulfilled be CreateBuiltinFunction(
           //                stepsFulfilled, « [[Generator]] »).
-          // Step 10.b.i.5: Set onFulfilled.[[Generator]] to generator.
-          // Step 10.b.i.6: Let stepsRejected be the algorithm steps defined in
+          // Step 10.b.i.6: Set onFulfilled.[[Generator]] to generator.
+          // Step 10.b.i.7: Let stepsRejected be the algorithm steps defined in
           //                AsyncGeneratorResumeNext Return Processor Rejected
           //                Functions.
-          // Step 10.b.i.7: Let onRejected be CreateBuiltinFunction(
+          // Step 10.b.i.8: Let onRejected be CreateBuiltinFunction(
           //                stepsRejected, « [[Generator]] »).
-          // Step 10.b.i.8: Set onRejected.[[Generator]] to generator.
+          // Step 10.b.i.9: Set onRejected.[[Generator]] to generator.
           static constexpr int32_t ResumeNextReturnFulfilled =
               PromiseHandlerAsyncGeneratorResumeNextReturnFulfilled;
           static constexpr int32_t ResumeNextReturnRejected =
               PromiseHandlerAsyncGeneratorResumeNextReturnRejected;
           RootedValue onFulfilled(cx, Int32Value(ResumeNextReturnFulfilled));
           RootedValue onRejected(cx, Int32Value(ResumeNextReturnRejected));
 
           // These steps are nearly identical to some steps in Await;
           // InternalAwait() implements the idiom.
           //
-          // Step 10.b.i.2: Let promise be ? PromiseResolve(%Promise%,
-          //                « _completion_.[[Value]] »).
-          // Step 10.b.i.9: Perform ! PerformPromiseThen(promise, onFulfilled,
-          //                                             onRejected).
-          // Step 10.b.i.10: Return undefined.
+          // Steps 10.b.i.2-3, as amended by
+          // <https://github.com/tc39/ecma262/pull/1250>:
+          //      Let promise be ? PromiseResolve(« _completion_.[[Value]] »).
+          // Step 10.b.i.10: Perform ! PerformPromiseThen(promise, onFulfilled,
+          //                                              onRejected).
+          // Step 10.b.i.11: Return undefined.
           auto extra = [&](Handle<PromiseReactionRecord*> reaction) {
             reaction->setIsAsyncGenerator(unwrappedGenerator);
           };
           return InternalAwait(cx, value, nullptr, onFulfilled, onRejected,
                                extra);
         }
 
         // Step 10.b.ii: Else,
deleted file mode 100644
--- a/js/src/tests/non262/async-functions/ecma262-issue-1461.js
+++ /dev/null
@@ -1,25 +0,0 @@
-// <https://github.com/tc39/ecma262/pull/1470> changes a detail of
-// error-handling in %AsyncFromSyncIteratorPrototype% methods. This test is
-// based on a comment in the thread where the issue was first reported,
-// <https://github.com/tc39/ecma262/issues/1461#issuecomment-468602852>
-
-let log = [];
-
-{
-  async function f() {
-    var p = Promise.resolve(0);
-    Object.defineProperty(p, "constructor", {get() { throw "hi" }});
-    for await (var x of [p]);
-  }
-  Promise.resolve(0)
-         .then(() => log.push("tick 1"))
-         .then(() => log.push("tick 2"))
-         .then(() => log.push("tick 3"));
-  f().catch(exc => log.push(exc));
-}
-
-drainJobQueue();
-assertEq(log.join(), "tick 1,tick 2,hi,tick 3");
-
-if (typeof reportCompare === 'function')
-  reportCompare(0, 0);