summaryrefslogtreecommitdiffstats
path: root/js/src/frontend/SharedContext.h
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/frontend/SharedContext.h')
-rw-r--r--js/src/frontend/SharedContext.h27
1 files changed, 22 insertions, 5 deletions
diff --git a/js/src/frontend/SharedContext.h b/js/src/frontend/SharedContext.h
index 013444690..8a5f6c0bd 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,21 @@ 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 needsIteratorResult() const {
+ return isStarGenerator();
+ }
+
bool isAsync() const { return asyncKind() == AsyncFunction; }
bool isArrow() const { return function()->isArrow(); }
@@ -560,7 +573,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 +668,11 @@ SharedContext::asModuleContext()
inline bool
SharedContext::allBindingsClosedOver()
{
- return bindingsAccessedDynamically() || (isFunctionBox() && asFunctionBox()->isGenerator());
+ return bindingsAccessedDynamically() ||
+ (isFunctionBox() &&
+ (asFunctionBox()->isStarGenerator() ||
+ asFunctionBox()->isLegacyGenerator() ||
+ asFunctionBox()->isAsync()));
}
} // namespace frontend