summaryrefslogtreecommitdiff
path: root/js/src/jsfun.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jsfun.cpp')
-rw-r--r--js/src/jsfun.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp
index 9d54fef780..65d44cba7a 100644
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -523,7 +523,7 @@ js::XDRInterpretedFunction(XDRState<mode>* xdr, HandleScope enclosingScope,
{
enum FirstWordFlag {
HasAtom = 0x1,
- IsStarGenerator = 0x2,
+ HasStarGeneratorProto = 0x2,
IsLazy = 0x4,
HasSingletonType = 0x8
};
@@ -552,8 +552,8 @@ js::XDRInterpretedFunction(XDRState<mode>* xdr, HandleScope enclosingScope,
if (fun->explicitName() || fun->hasCompileTimeName() || fun->hasGuessedAtom())
firstword |= HasAtom;
- if (fun->isStarGenerator())
- firstword |= IsStarGenerator;
+ if (fun->isStarGenerator() || fun->isAsync())
+ firstword |= HasStarGeneratorProto;
if (fun->isInterpretedLazy()) {
// Encode a lazy script.
@@ -589,7 +589,7 @@ js::XDRInterpretedFunction(XDRState<mode>* xdr, HandleScope enclosingScope,
if (mode == XDR_DECODE) {
RootedObject proto(cx);
- if (firstword & IsStarGenerator) {
+ if (firstword & HasStarGeneratorProto) {
proto = GlobalObject::getOrCreateStarGeneratorFunctionPrototype(cx, cx->global());
if (!proto)
return false;
@@ -1596,8 +1596,6 @@ FunctionConstructor(JSContext* cx, const CallArgs& args, GeneratorKind generator
bool isStarGenerator = generatorKind == StarGenerator;
bool isAsync = asyncKind == AsyncFunction;
MOZ_ASSERT(generatorKind != LegacyGenerator);
- MOZ_ASSERT_IF(isAsync, isStarGenerator);
- MOZ_ASSERT_IF(!isStarGenerator, !isAsync);
RootedScript maybeScript(cx);
const char* filename;
@@ -1709,7 +1707,7 @@ FunctionConstructor(JSContext* cx, const CallArgs& args, GeneratorKind generator
// Step 4.d, use %Generator% as the fallback prototype.
// Also use %Generator% for the unwrapped function of async functions.
- if (!proto && isStarGenerator) {
+ if (!proto && (isStarGenerator || isAsync)) {
proto = GlobalObject::getOrCreateStarGeneratorFunctionPrototype(cx, global);
if (!proto)
return false;
@@ -1777,7 +1775,7 @@ js::AsyncFunctionConstructor(JSContext* cx, unsigned argc, Value* vp)
else
newTarget = &args.callee();
- if (!FunctionConstructor(cx, args, StarGenerator, AsyncFunction))
+ if (!FunctionConstructor(cx, args, NotGenerator, AsyncFunction))
return false;
// ES2017, draft rev 0f10dba4ad18de92d47d421f378233a2eae8f077
@@ -1973,7 +1971,7 @@ NewFunctionClone(JSContext* cx, HandleFunction fun, NewObjectKind newKind,
gc::AllocKind allocKind, HandleObject proto)
{
RootedObject cloneProto(cx, proto);
- if (!proto && fun->isStarGenerator()) {
+ if (!proto && (fun->isStarGenerator() || fun->isAsync())) {
cloneProto = GlobalObject::getOrCreateStarGeneratorFunctionPrototype(cx, cx->global());
if (!cloneProto)
return nullptr;