summaryrefslogtreecommitdiffstats
path: root/js/src/frontend
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-12-01 13:34:22 -0500
committerGaming4JC <g4jc@hyperbola.info>2019-12-17 06:25:23 -0500
commit9163aaebb670bd87e6ef71beaf24999c926217eb (patch)
tree48bc403ef6b3349b749b0c38c1e94818b0734274 /js/src/frontend
parent1fd726c6b04faacbb49c525ec733d9419ab65a84 (diff)
downloadUXP-9163aaebb670bd87e6ef71beaf24999c926217eb.tar
UXP-9163aaebb670bd87e6ef71beaf24999c926217eb.tar.gz
UXP-9163aaebb670bd87e6ef71beaf24999c926217eb.tar.lz
UXP-9163aaebb670bd87e6ef71beaf24999c926217eb.tar.xz
UXP-9163aaebb670bd87e6ef71beaf24999c926217eb.zip
Bug 1343481 - Part 1: Remove {JSFunction,JSScript,LazyScript}.isGenerator() method.
Tag #1287
Diffstat (limited to 'js/src/frontend')
-rw-r--r--js/src/frontend/BytecodeEmitter.cpp19
-rw-r--r--js/src/frontend/Parser.cpp2
-rw-r--r--js/src/frontend/Parser.h12
-rw-r--r--js/src/frontend/SharedContext.h23
4 files changed, 38 insertions, 18 deletions
diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp
index 309d6c290..4dc4914dc 100644
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -389,7 +389,10 @@ class BytecodeEmitter::EmitterScope : public Nestable<BytecodeEmitter::EmitterSc
nextFrameSlot_ = bi.nextFrameSlot();
if (nextFrameSlot_ > bce->maxFixedSlots)
bce->maxFixedSlots = nextFrameSlot_;
- MOZ_ASSERT_IF(bce->sc->isFunctionBox() && bce->sc->asFunctionBox()->isGenerator(),
+ MOZ_ASSERT_IF(bce->sc->isFunctionBox() &&
+ (bce->sc->asFunctionBox()->isStarGenerator() ||
+ bce->sc->asFunctionBox()->isLegacyGenerator() ||
+ bce->sc->asFunctionBox()->isAsync()),
bce->maxFixedSlots == 0);
}
@@ -4783,7 +4786,9 @@ BytecodeEmitter::isRunOnceLambda()
FunctionBox* funbox = sc->asFunctionBox();
return !funbox->argumentsHasLocalBinding() &&
- !funbox->isGenerator() &&
+ !funbox->isStarGenerator() &&
+ !funbox->isLegacyGenerator() &&
+ !funbox->isAsync() &&
!funbox->function()->explicitName();
}
@@ -8478,11 +8483,11 @@ BytecodeEmitter::emitReturn(ParseNode* pn)
*/
ptrdiff_t top = offset();
- bool isGenerator = sc->isFunctionBox() && sc->asFunctionBox()->isGenerator();
+ bool needsFinalYield = sc->isFunctionBox() && sc->asFunctionBox()->needsFinalYield();
bool isDerivedClassConstructor =
sc->isFunctionBox() && sc->asFunctionBox()->isDerivedClassConstructor();
- if (!emit1((isGenerator || isDerivedClassConstructor) ? JSOP_SETRVAL : JSOP_RETURN))
+ if (!emit1((needsFinalYield || isDerivedClassConstructor) ? JSOP_SETRVAL : JSOP_RETURN))
return false;
// Make sure that we emit this before popping the blocks in prepareForNonLocalJump,
@@ -8497,7 +8502,7 @@ BytecodeEmitter::emitReturn(ParseNode* pn)
if (!nle.prepareForNonLocalJumpToOutermost())
return false;
- if (isGenerator) {
+ if (needsFinalYield) {
// We know that .generator is on the function scope, as we just exited
// all nested scopes.
NameLocation loc =
@@ -10312,7 +10317,7 @@ BytecodeEmitter::emitFunctionBody(ParseNode* funBody)
if (!emitTree(funBody))
return false;
- if (funbox->isGenerator()) {
+ if (funbox->needsFinalYield()) {
// If we fall off the end of a generator, do a final yield.
if (funbox->isStarGenerator() && !emitPrepareIteratorResult())
return false;
@@ -10320,7 +10325,7 @@ BytecodeEmitter::emitFunctionBody(ParseNode* funBody)
if (!emit1(JSOP_UNDEFINED))
return false;
- if (sc->asFunctionBox()->isStarGenerator() && !emitFinishIteratorResult(true))
+ if (funbox->isStarGenerator() && !emitFinishIteratorResult(true))
return false;
if (!emit1(JSOP_SETRVAL))
diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp
index 0c279591f..64b1f22c2 100644
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -2720,7 +2720,7 @@ Parser<ParseHandler>::functionBody(InHandling inHandling, YieldHandling yieldHan
break;
}
- if (pc->isGenerator()) {
+ if (pc->needsDotGeneratorName()) {
MOZ_ASSERT_IF(!pc->isAsync(), type == StatementListBody);
if (!declareDotGeneratorName())
return null();
diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h
index 88d2dad18..33fe345d6 100644
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -496,10 +496,6 @@ class ParseContext : public Nestable<ParseContext>
return sc_->isFunctionBox() ? sc_->asFunctionBox()->generatorKind() : NotGenerator;
}
- bool isGenerator() const {
- return generatorKind() != NotGenerator;
- }
-
bool isLegacyGenerator() const {
return generatorKind() == LegacyGenerator;
}
@@ -512,6 +508,10 @@ class ParseContext : public Nestable<ParseContext>
return sc_->isFunctionBox() && sc_->asFunctionBox()->isAsync();
}
+ bool needsDotGeneratorName() const {
+ return isStarGenerator() || isLegacyGenerator() || isAsync();
+ }
+
FunctionAsyncKind asyncKind() const {
return isAsync() ? AsyncFunction : SyncFunction;
}
@@ -818,7 +818,9 @@ class ParserBase : public StrictModeGetter
// whether it's prohibited due to strictness, JS version, or occurrence
// inside a star generator.
bool yieldExpressionsSupported() {
- return (versionNumber() >= JSVERSION_1_7 || pc->isGenerator()) && !pc->isAsync();
+ return (versionNumber() >= JSVERSION_1_7 && !pc->isAsync()) ||
+ pc->isStarGenerator() ||
+ pc->isLegacyGenerator();
}
virtual bool strictMode() { return pc->sc()->strict(); }
diff --git a/js/src/frontend/SharedContext.h b/js/src/frontend/SharedContext.h
index 013444690..5766c135a 100644
--- a/js/src/frontend/SharedContext.h
+++ b/js/src/frontend/SharedContext.h
@@ -520,7 +520,9 @@ class FunctionBox : public ObjectBox, public SharedContext
return hasExtensibleScope() ||
needsHomeObject() ||
isDerivedClassConstructor() ||
- isGenerator();
+ isStarGenerator() ||
+ isLegacyGenerator() ||
+ isAsync();
}
bool hasExtraBodyVarScope() const {
@@ -531,7 +533,7 @@ class FunctionBox : public ObjectBox, public SharedContext
bool needsExtraBodyVarEnvironmentRegardlessOfBindings() const {
MOZ_ASSERT(hasParameterExprs);
- return hasExtensibleScope() || isGenerator();
+ return hasExtensibleScope() || needsDotGeneratorName();
}
bool isLikelyConstructorWrapper() const {
@@ -539,10 +541,17 @@ class FunctionBox : public ObjectBox, public SharedContext
}
GeneratorKind generatorKind() const { return GeneratorKindFromBits(generatorKindBits_); }
- bool isGenerator() const { return generatorKind() != NotGenerator; }
bool isLegacyGenerator() const { return generatorKind() == LegacyGenerator; }
bool isStarGenerator() const { return generatorKind() == StarGenerator; }
FunctionAsyncKind asyncKind() const { return AsyncKindFromBits(asyncKindBits_); }
+
+ bool needsFinalYield() const {
+ return isStarGenerator() || isLegacyGenerator() || isAsync();
+ }
+ bool needsDotGeneratorName() const {
+ return isStarGenerator() || isLegacyGenerator() || isAsync();
+ }
+
bool isAsync() const { return asyncKind() == AsyncFunction; }
bool isArrow() const { return function()->isArrow(); }
@@ -560,7 +569,7 @@ class FunctionBox : public ObjectBox, public SharedContext
// A generator kind can be set at initialization, or when "yield" is
// first seen. In both cases the transition can only happen from
// NotGenerator.
- MOZ_ASSERT(!isGenerator());
+ MOZ_ASSERT(!isStarGenerator() && !isLegacyGenerator());
generatorKindBits_ = GeneratorKindAsBits(kind);
}
@@ -655,7 +664,11 @@ SharedContext::asModuleContext()
inline bool
SharedContext::allBindingsClosedOver()
{
- return bindingsAccessedDynamically() || (isFunctionBox() && asFunctionBox()->isGenerator());
+ return bindingsAccessedDynamically() ||
+ (isFunctionBox() &&
+ (asFunctionBox()->isStarGenerator() ||
+ asFunctionBox()->isLegacyGenerator() ||
+ asFunctionBox()->isAsync()));
}
} // namespace frontend