Bug 1539132 - Part 3: Update spec references for async-functions. r=arai
authorAndré Bargull <andre.bargull@gmail.com>
Wed, 03 Apr 2019 20:02:08 +0000
changeset 467956 33a0651129668ca0ef3749cb66e68560d6555c32
parent 467955 784e5f703238541bed18b9bce044db695db41fc7
child 467957 ef5b0d01d900190f3fcad092cba34c7d1e0dda5b
push id112667
push useraiakab@mozilla.com
push dateThu, 04 Apr 2019 16:12:45 +0000
treeherdermozilla-inbound@230bb363f2f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1539132
milestone68.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 1539132 - Part 3: Update spec references for async-functions. r=arai Differential Revision: https://phabricator.services.mozilla.com/D25570
js/src/vm/AsyncFunction.cpp
--- a/js/src/vm/AsyncFunction.cpp
+++ b/js/src/vm/AsyncFunction.cpp
@@ -59,21 +59,19 @@ bool GlobalObject::initAsyncFunction(JSC
   global->setReservedSlot(ASYNC_FUNCTION, ObjectValue(*asyncFunction));
   global->setReservedSlot(ASYNC_FUNCTION_PROTO,
                           ObjectValue(*asyncFunctionProto));
   return true;
 }
 
 enum class ResumeKind { Normal, Throw };
 
-// Async Functions proposal 2.2 steps 3.f, 3.g.
-// Async Functions proposal 2.2 steps 3.d-e, 3.g.
-// Implemented in js/src/builtin/Promise.cpp
-
-// Async Functions proposal 2.2 steps 3-8, 2.4 steps 2-7, 2.5 steps 2-7.
+// ES2020 draft rev a09fc232c137800dbf51b6204f37fdede4ba1646
+// 6.2.3.1.1 Await Fulfilled Functions
+// 6.2.3.1.2 Await Rejected Functions
 static bool AsyncFunctionResume(JSContext* cx,
                                 Handle<AsyncFunctionGeneratorObject*> generator,
                                 ResumeKind kind, HandleValue valueOrReason) {
   // We're enqueuing the promise job for Await before suspending the execution
   // of the async function. So when either the debugger or OOM errors terminate
   // the execution after JSOP_ASYNCAWAIT, but before JSOP_AWAIT, we're in an
   // inconsistent state, because we don't have a resume index set and therefore
   // don't know where to resume the async function. Return here in that case.
@@ -126,36 +124,29 @@ static bool AsyncFunctionResume(JSContex
   MOZ_ASSERT_IF(generator->isClosed(), generatorOrValue.isObject());
   MOZ_ASSERT_IF(generator->isClosed(),
                 &generatorOrValue.toObject() == resultPromise);
   MOZ_ASSERT_IF(!generator->isClosed(), generator->isAfterAwait());
 
   return true;
 }
 
-// Async Functions proposal 2.3 steps 1-8.
-// Implemented in js/src/builtin/Promise.cpp
-
-// Async Functions proposal 2.4.
+// ES2020 draft rev a09fc232c137800dbf51b6204f37fdede4ba1646
+// 6.2.3.1.1 Await Fulfilled Functions
 MOZ_MUST_USE bool js::AsyncFunctionAwaitedFulfilled(
     JSContext* cx, Handle<AsyncFunctionGeneratorObject*> generator,
     HandleValue value) {
-  // Step 1 (implicit).
-
-  // Steps 2-7.
   return AsyncFunctionResume(cx, generator, ResumeKind::Normal, value);
 }
 
-// Async Functions proposal 2.5.
+// ES2020 draft rev a09fc232c137800dbf51b6204f37fdede4ba1646
+// 6.2.3.1.2 Await Rejected Functions
 MOZ_MUST_USE bool js::AsyncFunctionAwaitedRejected(
     JSContext* cx, Handle<AsyncFunctionGeneratorObject*> generator,
     HandleValue reason) {
-  // Step 1 (implicit).
-
-  // Step 2-7.
   return AsyncFunctionResume(cx, generator, ResumeKind::Throw, reason);
 }
 
 JSObject* js::AsyncFunctionResolve(
     JSContext* cx, Handle<AsyncFunctionGeneratorObject*> generator,
     HandleValue valueOrReason, AsyncFunctionResolveKind resolveKind) {
   Rooted<PromiseObject*> promise(cx, generator->promise());
   if (resolveKind == AsyncFunctionResolveKind::Fulfill) {