From 9163aaebb670bd87e6ef71beaf24999c926217eb Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sun, 1 Dec 2019 13:34:22 -0500 Subject: Bug 1343481 - Part 1: Remove {JSFunction,JSScript,LazyScript}.isGenerator() method. Tag #1287 --- js/src/jsscript.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/src/jsscript.cpp') diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index fc7438e3b..6f5284a3b 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -3917,7 +3917,9 @@ JSScript::argumentsOptimizationFailed(JSContext* cx, HandleScript script) if (script->needsArgsObj()) return true; - MOZ_ASSERT(!script->isGenerator()); + MOZ_ASSERT(!script->isStarGenerator()); + MOZ_ASSERT(!script->isLegacyGenerator()); + MOZ_ASSERT(!script->isAsync()); script->needsArgsObj_ = true; -- cgit v1.2.3 From f07d5707c77e73031b6921faac165ca7f8d577c6 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sun, 1 Dec 2019 18:44:06 -0500 Subject: Bug 1343481 - Part 2: Stop using StarGegerator for async function. Tag #1287 --- js/src/jsscript.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src/jsscript.cpp') diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index 6f5284a3b..eb74a1ec6 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -3188,7 +3188,7 @@ CloneInnerInterpretedFunction(JSContext* cx, HandleScope enclosingScope, HandleF { /* NB: Keep this in sync with XDRInterpretedFunction. */ RootedObject cloneProto(cx); - if (srcFun->isStarGenerator()) { + if (srcFun->isStarGenerator() || srcFun->isAsync()) { cloneProto = GlobalObject::getOrCreateStarGeneratorFunctionPrototype(cx, cx->global()); if (!cloneProto) return nullptr; -- cgit v1.2.3 From 3a3de55aadd9d3a2aafc3638c7a9b0c23584cef4 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sun, 1 Dec 2019 19:14:11 -0500 Subject: Bug 1343481 - Part 3: Add JSOP_AWAIT and rename {yieldIndex,yieldOffset} to {yieldAndAwaitIndex,yieldAndAwaitOffset}. Tag #1287 --- js/src/jsscript.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'js/src/jsscript.cpp') diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index eb74a1ec6..bdd411d04 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -402,8 +402,8 @@ js::XDRScript(XDRState* xdr, HandleScope scriptEnclosingScope, HandleScrip ntrynotes = script->trynotes()->length; if (script->hasScopeNotes()) nscopenotes = script->scopeNotes()->length; - if (script->hasYieldOffsets()) - nyieldoffsets = script->yieldOffsets().length(); + if (script->hasYieldAndAwaitOffsets()) + nyieldoffsets = script->yieldAndAwaitOffsets().length(); nTypeSets = script->nTypeSets(); funLength = script->funLength(); @@ -902,7 +902,7 @@ js::XDRScript(XDRState* xdr, HandleScope scriptEnclosingScope, HandleScrip } for (i = 0; i < nyieldoffsets; ++i) { - uint32_t* offset = &script->yieldOffsets()[i]; + uint32_t* offset = &script->yieldAndAwaitOffsets()[i]; if (!xdr->codeUint32(offset)) return false; } @@ -2456,7 +2456,7 @@ ScriptDataSize(uint32_t nscopes, uint32_t nconsts, uint32_t nobjects, if (nscopenotes != 0) size += sizeof(ScopeNoteArray) + nscopenotes * sizeof(ScopeNote); if (nyieldoffsets != 0) - size += sizeof(YieldOffsetArray) + nyieldoffsets * sizeof(uint32_t); + size += sizeof(YieldAndAwaitOffsetArray) + nyieldoffsets * sizeof(uint32_t); return size; } @@ -2558,10 +2558,10 @@ JSScript::partiallyInit(ExclusiveContext* cx, HandleScript script, uint32_t nsco cursor += sizeof(ScopeNoteArray); } - YieldOffsetArray* yieldOffsets = nullptr; + YieldAndAwaitOffsetArray* yieldAndAwaitOffsets = nullptr; if (nyieldoffsets != 0) { - yieldOffsets = reinterpret_cast(cursor); - cursor += sizeof(YieldOffsetArray); + yieldAndAwaitOffsets = reinterpret_cast(cursor); + cursor += sizeof(YieldAndAwaitOffsetArray); } if (nconsts != 0) { @@ -2602,8 +2602,8 @@ JSScript::partiallyInit(ExclusiveContext* cx, HandleScript script, uint32_t nsco } if (nyieldoffsets != 0) { - yieldOffsets->init(reinterpret_cast(cursor), nyieldoffsets); - size_t vectorSize = nyieldoffsets * sizeof(script->yieldOffsets()[0]); + yieldAndAwaitOffsets->init(reinterpret_cast(cursor), nyieldoffsets); + size_t vectorSize = nyieldoffsets * sizeof(script->yieldAndAwaitOffsets()[0]); #ifdef DEBUG memset(cursor, 0, vectorSize); #endif @@ -2623,10 +2623,10 @@ JSScript::initFunctionPrototype(ExclusiveContext* cx, Handle script, uint32_t numObjects = 0; uint32_t numTryNotes = 0; uint32_t numScopeNotes = 0; - uint32_t numYieldOffsets = 0; + uint32_t numYieldAndAwaitOffsets = 0; uint32_t numTypeSets = 0; if (!partiallyInit(cx, script, numScopes, numConsts, numObjects, numTryNotes, - numScopeNotes, numYieldOffsets, numTypeSets)) + numScopeNotes, numYieldAndAwaitOffsets, numTypeSets)) { return false; } @@ -2739,7 +2739,7 @@ JSScript::fullyInitFromEmitter(ExclusiveContext* cx, HandleScript script, Byteco if (!partiallyInit(cx, script, bce->scopeList.length(), bce->constList.length(), bce->objectList.length, bce->tryNoteList.length(), bce->scopeNoteList.length(), - bce->yieldOffsetList.length(), bce->typesetCount)) + bce->yieldAndAwaitOffsetList.length(), bce->typesetCount)) { return false; } @@ -2794,8 +2794,8 @@ JSScript::fullyInitFromEmitter(ExclusiveContext* cx, HandleScript script, Byteco // Copy yield offsets last, as the generator kind is set in // initFromFunctionBox. - if (bce->yieldOffsetList.length() != 0) - bce->yieldOffsetList.finish(script->yieldOffsets(), prologueLength); + if (bce->yieldAndAwaitOffsetList.length() != 0) + bce->yieldAndAwaitOffsetList.finish(script->yieldAndAwaitOffsets(), prologueLength); #ifdef DEBUG script->assertValidJumpTargets(); @@ -3242,7 +3242,7 @@ js::detail::CopyScript(JSContext* cx, HandleScript src, HandleScript dst, uint32_t nscopes = src->scopes()->length; uint32_t ntrynotes = src->hasTrynotes() ? src->trynotes()->length : 0; uint32_t nscopenotes = src->hasScopeNotes() ? src->scopeNotes()->length : 0; - uint32_t nyieldoffsets = src->hasYieldOffsets() ? src->yieldOffsets().length() : 0; + uint32_t nyieldoffsets = src->hasYieldAndAwaitOffsets() ? src->yieldAndAwaitOffsets().length() : 0; /* Script data */ @@ -3380,8 +3380,10 @@ js::detail::CopyScript(JSContext* cx, HandleScript src, HandleScript dst, dst->trynotes()->vector = Rebase(dst, src, src->trynotes()->vector); if (nscopenotes != 0) dst->scopeNotes()->vector = Rebase(dst, src, src->scopeNotes()->vector); - if (nyieldoffsets != 0) - dst->yieldOffsets().vector_ = Rebase(dst, src, src->yieldOffsets().vector_); + if (nyieldoffsets != 0) { + dst->yieldAndAwaitOffsets().vector_ = + Rebase(dst, src, src->yieldAndAwaitOffsets().vector_); + } /* * Function delazification assumes that their script does not have a -- cgit v1.2.3