summaryrefslogtreecommitdiffstats
path: root/js/src/jsfun.cpp
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-12-01 18:44:06 -0500
committerGaming4JC <g4jc@hyperbola.info>2019-12-17 06:25:23 -0500
commitf07d5707c77e73031b6921faac165ca7f8d577c6 (patch)
tree0ecbf325bbefb73bee1dce56dac494620b461fb2 /js/src/jsfun.cpp
parent9163aaebb670bd87e6ef71beaf24999c926217eb (diff)
downloadUXP-f07d5707c77e73031b6921faac165ca7f8d577c6.tar
UXP-f07d5707c77e73031b6921faac165ca7f8d577c6.tar.gz
UXP-f07d5707c77e73031b6921faac165ca7f8d577c6.tar.lz
UXP-f07d5707c77e73031b6921faac165ca7f8d577c6.tar.xz
UXP-f07d5707c77e73031b6921faac165ca7f8d577c6.zip
Bug 1343481 - Part 2: Stop using StarGegerator for async function.
Tag #1287
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 9d54fef78..65d44cba7 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;