Bug 1534392 - Part 1: Update step numbers in comments to match current draft spec. r=anba
☠☠ backed out by 00919ccaa29f ☠ ☠
authorJason Orendorff <jorendorff@mozilla.com>
Tue, 12 Mar 2019 20:48:57 +0000
changeset 521604 47e570e51385
parent 521603 356a982f5ba4
child 521605 4c52efb1430f
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)
reviewersanba
bugs1534392
milestone67.0a1
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
Bug 1534392 - Part 1: Update step numbers in comments to match current draft spec. r=anba The new steps are official since <https://github.com/tc39/ecma262/pull/1250> landed. (Some of these step numbers change again in the next commit.) Differential Revision: https://phabricator.services.mozilla.com/D23029
js/src/builtin/Promise.cpp
--- a/js/src/builtin/Promise.cpp
+++ b/js/src/builtin/Promise.cpp
@@ -3544,56 +3544,53 @@ 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-3 and 10, or
-// similar.
+// 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.
 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());
 
-  // 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.
+  // Step 2: Let promise be ? PromiseResolve(%Promise%, « value »).
   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 4-9 of the spec create onFulfilled and onRejected functions.
+  // Steps 3-8 of the spec create onFulfilled and onRejected functions.
+
+  // Step 9: Perform ! PerformPromiseThen(promise, onFulfilled, onRejected).
   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(
@@ -3796,34 +3793,33 @@ 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);
   }
 
-  // Steps 7-9 (reordered).
-  // Step 7: Let steps be the algorithm steps defined in Async-from-Sync
+  // Steps 6-8 (reordered).
+  // Step 6: 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.
+  // Step 7: Let onFulfilled be CreateBuiltinFunction(steps, « [[Done]] »).
+  // Step 8: Set onFulfilled.[[Done]] to done.
   RootedValue onFulfilled(
       cx,
       Int32Value(done ? PromiseHandlerAsyncFromSyncIteratorValueUnwrapDone
                       : PromiseHandlerAsyncFromSyncIteratorValueUnwrapNotDone));
   RootedValue onRejected(cx, Int32Value(PromiseHandlerThrower));
 
   // These steps are identical to some steps in Await; we have a utility
   // function InternalAwait() that implements the idiom.
   //
-  // 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).
+  // Step 5: Let valueWrapper be ? PromiseResolve(%Promise%, « value »).
+  // Step 9: Perform ! PerformPromiseThen(valueWrapper, onFulfilled,
+  //                                      undefined, promiseCapability).
   auto extra = [](Handle<PromiseReactionRecord*> reaction) {};
   if (!InternalAwait(cx, value, resultPromise, onFulfilled, onRejected,
                      extra)) {
     return false;
   }
 
   // Step 11: Return promiseCapability.[[Promise]].
   args.rval().setObject(*resultPromise);
@@ -3989,44 +3985,43 @@ 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.4: Let stepsFulfilled be the algorithm steps defined in
+          // Step 10.b.i.3: Let stepsFulfilled be the algorithm steps defined in
           //                AsyncGeneratorResumeNext Return Processor Fulfilled
           //                Functions.
-          // Step 10.b.i.5: Let onFulfilled be CreateBuiltinFunction(
+          // Step 10.b.i.4: Let onFulfilled be CreateBuiltinFunction(
           //                stepsFulfilled, « [[Generator]] »).
-          // Step 10.b.i.6: Set onFulfilled.[[Generator]] to generator.
-          // Step 10.b.i.7: Let stepsRejected be the algorithm steps defined in
+          // Step 10.b.i.5: Set onFulfilled.[[Generator]] to generator.
+          // Step 10.b.i.6: Let stepsRejected be the algorithm steps defined in
           //                AsyncGeneratorResumeNext Return Processor Rejected
           //                Functions.
-          // Step 10.b.i.8: Let onRejected be CreateBuiltinFunction(
+          // Step 10.b.i.7: Let onRejected be CreateBuiltinFunction(
           //                stepsRejected, « [[Generator]] »).
-          // Step 10.b.i.9: Set onRejected.[[Generator]] to generator.
+          // Step 10.b.i.8: 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.
           //
-          // 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.
+          // 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.
           auto extra = [&](Handle<PromiseReactionRecord*> reaction) {
             reaction->setIsAsyncGenerator(unwrappedGenerator);
           };
           return InternalAwait(cx, value, nullptr, onFulfilled, onRejected,
                                extra);
         }
 
         // Step 10.b.ii: Else,