diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2019-12-13 20:59:32 -0500 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2019-12-17 06:25:25 -0500 |
commit | d0d9a4f43dbd58c694c706b17996157fede20bdf (patch) | |
tree | db9e4dce1b1c92b477720f1eba9a9ec04b3f8e2d /js/src/vm/AsyncFunction.cpp | |
parent | 79b5eb14bc5f8495d20147957cda5f4e5fc8186a (diff) | |
download | UXP-d0d9a4f43dbd58c694c706b17996157fede20bdf.tar UXP-d0d9a4f43dbd58c694c706b17996157fede20bdf.tar.gz UXP-d0d9a4f43dbd58c694c706b17996157fede20bdf.tar.lz UXP-d0d9a4f43dbd58c694c706b17996157fede20bdf.tar.xz UXP-d0d9a4f43dbd58c694c706b17996157fede20bdf.zip |
Bug 1316098 - Optimize out result object allocation for await/return in async function.
Tag #1287
Diffstat (limited to 'js/src/vm/AsyncFunction.cpp')
-rw-r--r-- | js/src/vm/AsyncFunction.cpp | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/js/src/vm/AsyncFunction.cpp b/js/src/vm/AsyncFunction.cpp index be7a36ecc..2bcec5465 100644 --- a/js/src/vm/AsyncFunction.cpp +++ b/js/src/vm/AsyncFunction.cpp @@ -171,22 +171,14 @@ AsyncFunctionResume(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleV : cx->names().StarGeneratorThrow; FixedInvokeArgs<1> args(cx); args[0].set(valueOrReason); - RootedValue result(cx); - if (!CallSelfHostedFunction(cx, funName, generatorVal, args, &result)) - return AsyncFunctionThrown(cx, resultPromise); - - RootedObject resultObj(cx, &result.toObject()); - RootedValue doneVal(cx); RootedValue value(cx); - if (!GetProperty(cx, resultObj, resultObj, cx->names().done, &doneVal)) - return false; - if (!GetProperty(cx, resultObj, resultObj, cx->names().value, &value)) - return false; + if (!CallSelfHostedFunction(cx, funName, generatorVal, args, &value)) + return AsyncFunctionThrown(cx, resultPromise); - if (doneVal.toBoolean()) - return AsyncFunctionReturned(cx, resultPromise, value); + if (generatorVal.toObject().as<GeneratorObject>().isAfterAwait()) + return AsyncFunctionAwait(cx, resultPromise, value); - return AsyncFunctionAwait(cx, resultPromise, value); + return AsyncFunctionReturned(cx, resultPromise, value); } // Async Functions proposal 2.2 steps 3-8. @@ -242,9 +234,3 @@ js::IsWrappedAsyncFunction(JSFunction* fun) { return fun->maybeNative() == WrappedAsyncFunction; } - -MOZ_MUST_USE bool -js::CheckAsyncResumptionValue(JSContext* cx, HandleValue v) -{ - return CheckStarGeneratorResumptionValue(cx, v); -} |