Bug 1343481 - Part 1: Remove {JSFunction,JSScript,LazyScript}.isGenerator() method.

Tag #1287
This commit is contained in:
Gaming4JC 2019-12-01 13:34:22 -05:00 • committed by Roy Tam
commit 7eb5d46c11
22 changed files with 133 additions and 64 deletions

View file

@ -3422,10 +3422,10 @@ ASTSerializer::function(ParseNode* pn, ASTType type, MutableHandleValue dst)
RootedFunction func(cx, pn->pn_funbox->function()); RootedFunction func(cx, pn->pn_funbox->function());
GeneratorStyle generatorStyle = GeneratorStyle generatorStyle =
pn->pn_funbox->isGenerator() pn->pn_funbox->isStarGenerator()
? (pn->pn_funbox->isLegacyGenerator() ? GeneratorStyle::ES6
? GeneratorStyle::Legacy : pn->pn_funbox->isLegacyGenerator()
: GeneratorStyle::ES6) ? GeneratorStyle::Legacy
: GeneratorStyle::None; : GeneratorStyle::None;
bool isAsync = pn->pn_funbox->isAsync(); bool isAsync = pn->pn_funbox->isAsync();

View file

@ -389,7 +389,10 @@ class BytecodeEmitter::EmitterScope : public Nestable<BytecodeEmitter::EmitterSc
nextFrameSlot_ = bi.nextFrameSlot(); nextFrameSlot_ = bi.nextFrameSlot();
if (nextFrameSlot_ > bce->maxFixedSlots) if (nextFrameSlot_ > bce->maxFixedSlots)
bce->maxFixedSlots = nextFrameSlot_; 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); bce->maxFixedSlots == 0);
} }
@ -4783,7 +4786,9 @@ BytecodeEmitter::isRunOnceLambda()
FunctionBox* funbox = sc->asFunctionBox(); FunctionBox* funbox = sc->asFunctionBox();
return !funbox->argumentsHasLocalBinding() && return !funbox->argumentsHasLocalBinding() &&
!funbox->isGenerator() && !funbox->isStarGenerator() &&
!funbox->isLegacyGenerator() &&
!funbox->isAsync() &&
!funbox->function()->explicitName(); !funbox->function()->explicitName();
} }
@ -8478,11 +8483,11 @@ BytecodeEmitter::emitReturn(ParseNode* pn)
*/ */
ptrdiff_t top = offset(); ptrdiff_t top = offset();
bool isGenerator = sc->isFunctionBox() && sc->asFunctionBox()->isGenerator(); bool needsFinalYield = sc->isFunctionBox() && sc->asFunctionBox()->needsFinalYield();
bool isDerivedClassConstructor = bool isDerivedClassConstructor =
sc->isFunctionBox() && sc->asFunctionBox()->isDerivedClassConstructor(); sc->isFunctionBox() && sc->asFunctionBox()->isDerivedClassConstructor();
if (!emit1((isGenerator || isDerivedClassConstructor) ? JSOP_SETRVAL : JSOP_RETURN)) if (!emit1((needsFinalYield || isDerivedClassConstructor) ? JSOP_SETRVAL : JSOP_RETURN))
return false; return false;
// Make sure that we emit this before popping the blocks in prepareForNonLocalJump, // Make sure that we emit this before popping the blocks in prepareForNonLocalJump,
@ -8497,7 +8502,7 @@ BytecodeEmitter::emitReturn(ParseNode* pn)
if (!nle.prepareForNonLocalJumpToOutermost()) if (!nle.prepareForNonLocalJumpToOutermost())
return false; return false;
if (isGenerator) { if (needsFinalYield) {
// We know that .generator is on the function scope, as we just exited // We know that .generator is on the function scope, as we just exited
// all nested scopes. // all nested scopes.
NameLocation loc = NameLocation loc =
@ -10313,7 +10318,7 @@ BytecodeEmitter::emitFunctionBody(ParseNode* funBody)
if (!emitTree(funBody)) if (!emitTree(funBody))
return false; return false;
if (funbox->isGenerator()) { if (funbox->needsFinalYield()) {
// If we fall off the end of a generator, do a final yield. // If we fall off the end of a generator, do a final yield.
if (funbox->isStarGenerator() && !emitPrepareIteratorResult()) if (funbox->isStarGenerator() && !emitPrepareIteratorResult())
return false; return false;
@ -10321,7 +10326,7 @@ BytecodeEmitter::emitFunctionBody(ParseNode* funBody)
if (!emit1(JSOP_UNDEFINED)) if (!emit1(JSOP_UNDEFINED))
return false; return false;
if (sc->asFunctionBox()->isStarGenerator() && !emitFinishIteratorResult(true)) if (funbox->isStarGenerator() && !emitFinishIteratorResult(true))
return false; return false;
if (!emit1(JSOP_SETRVAL)) if (!emit1(JSOP_SETRVAL))

View file

@ -2720,7 +2720,7 @@ Parser<ParseHandler>::functionBody(InHandling inHandling, YieldHandling yieldHan
break; break;
} }
if (pc->isGenerator()) { if (pc->needsDotGeneratorName()) {
MOZ_ASSERT_IF(!pc->isAsync(), type == StatementListBody); MOZ_ASSERT_IF(!pc->isAsync(), type == StatementListBody);
if (!declareDotGeneratorName()) if (!declareDotGeneratorName())
return null(); return null();

View file

@ -496,10 +496,6 @@ class ParseContext : public Nestable<ParseContext>
return sc_->isFunctionBox() ? sc_->asFunctionBox()->generatorKind() : NotGenerator; return sc_->isFunctionBox() ? sc_->asFunctionBox()->generatorKind() : NotGenerator;
} }
bool isGenerator() const {
return generatorKind() != NotGenerator;
}
bool isLegacyGenerator() const { bool isLegacyGenerator() const {
return generatorKind() == LegacyGenerator; return generatorKind() == LegacyGenerator;
} }
@ -512,6 +508,10 @@ class ParseContext : public Nestable<ParseContext>
return sc_->isFunctionBox() && sc_->asFunctionBox()->isAsync(); return sc_->isFunctionBox() && sc_->asFunctionBox()->isAsync();
} }
bool needsDotGeneratorName() const {
return isStarGenerator() || isLegacyGenerator() || isAsync();
}
FunctionAsyncKind asyncKind() const { FunctionAsyncKind asyncKind() const {
return isAsync() ? AsyncFunction : SyncFunction; return isAsync() ? AsyncFunction : SyncFunction;
} }
@ -818,7 +818,9 @@ class ParserBase : public StrictModeGetter
// whether it's prohibited due to strictness, JS version, or occurrence // whether it's prohibited due to strictness, JS version, or occurrence
// inside a star generator. // inside a star generator.
bool yieldExpressionsSupported() { 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(); } virtual bool strictMode() { return pc->sc()->strict(); }

View file

@ -520,7 +520,9 @@ class FunctionBox : public ObjectBox, public SharedContext
return hasExtensibleScope() || return hasExtensibleScope() ||
needsHomeObject() || needsHomeObject() ||
isDerivedClassConstructor() || isDerivedClassConstructor() ||
isGenerator(); isStarGenerator() ||
isLegacyGenerator() ||
isAsync();
} }
bool hasExtraBodyVarScope() const { bool hasExtraBodyVarScope() const {
@ -531,7 +533,7 @@ class FunctionBox : public ObjectBox, public SharedContext
bool needsExtraBodyVarEnvironmentRegardlessOfBindings() const { bool needsExtraBodyVarEnvironmentRegardlessOfBindings() const {
MOZ_ASSERT(hasParameterExprs); MOZ_ASSERT(hasParameterExprs);
return hasExtensibleScope() || isGenerator(); return hasExtensibleScope() || needsDotGeneratorName();
} }
bool isLikelyConstructorWrapper() const { bool isLikelyConstructorWrapper() const {
@ -539,10 +541,17 @@ class FunctionBox : public ObjectBox, public SharedContext
} }
GeneratorKind generatorKind() const { return GeneratorKindFromBits(generatorKindBits_); } GeneratorKind generatorKind() const { return GeneratorKindFromBits(generatorKindBits_); }
bool isGenerator() const { return generatorKind() != NotGenerator; }
bool isLegacyGenerator() const { return generatorKind() == LegacyGenerator; } bool isLegacyGenerator() const { return generatorKind() == LegacyGenerator; }
bool isStarGenerator() const { return generatorKind() == StarGenerator; } bool isStarGenerator() const { return generatorKind() == StarGenerator; }
FunctionAsyncKind asyncKind() const { return AsyncKindFromBits(asyncKindBits_); } 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 isAsync() const { return asyncKind() == AsyncFunction; }
bool isArrow() const { return function()->isArrow(); } 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 // A generator kind can be set at initialization, or when "yield" is
// first seen. In both cases the transition can only happen from // first seen. In both cases the transition can only happen from
// NotGenerator. // NotGenerator.
MOZ_ASSERT(!isGenerator()); MOZ_ASSERT(!isStarGenerator() && !isLegacyGenerator());
generatorKindBits_ = GeneratorKindAsBits(kind); generatorKindBits_ = GeneratorKindAsBits(kind);
} }
@ -655,7 +664,11 @@ SharedContext::asModuleContext()
inline bool inline bool
SharedContext::allBindingsClosedOver() SharedContext::allBindingsClosedOver()
{ {
return bindingsAccessedDynamically() || (isFunctionBox() && asFunctionBox()->isGenerator()); return bindingsAccessedDynamically() ||
(isFunctionBox() &&
(asFunctionBox()->isStarGenerator() ||
asFunctionBox()->isLegacyGenerator() ||
asFunctionBox()->isAsync()));
} }
} // namespace frontend } // namespace frontend

View file

@ -2320,7 +2320,9 @@ IonCompile(JSContext* cx, JSScript* script,
static bool static bool
CheckFrame(JSContext* cx, BaselineFrame* frame) CheckFrame(JSContext* cx, BaselineFrame* frame)
{ {
MOZ_ASSERT(!frame->script()->isGenerator()); MOZ_ASSERT(!frame->script()->isStarGenerator());
MOZ_ASSERT(!frame->script()->isLegacyGenerator());
MOZ_ASSERT(!frame->script()->isAsync());
MOZ_ASSERT(!frame->isDebuggerEvalFrame()); MOZ_ASSERT(!frame->isDebuggerEvalFrame());
MOZ_ASSERT(!frame->isEvalFrame()); MOZ_ASSERT(!frame->isEvalFrame());
@ -2351,11 +2353,16 @@ CheckScript(JSContext* cx, JSScript* script, bool osr)
return false; return false;
} }
if (script->isGenerator()) { if (script->isStarGenerator() || script->isLegacyGenerator()) {
TrackAndSpewIonAbort(cx, script, "generator script"); TrackAndSpewIonAbort(cx, script, "generator script");
return false; return false;
} }
if (script->isAsync()) {
TrackAndSpewIonAbort(cx, script, "async script");
return false;
}
if (script->hasNonSyntacticScope() && !script->functionNonDelazifying()) { if (script->hasNonSyntacticScope() && !script->functionNonDelazifying()) {
// Support functions with a non-syntactic global scope but not other // Support functions with a non-syntactic global scope but not other
// scripts. For global scripts, IonBuilder currently uses the global // scripts. For global scripts, IonBuilder currently uses the global

View file

@ -4402,8 +4402,14 @@ jit::AnalyzeArgumentsUsage(JSContext* cx, JSScript* scriptArg)
// direct eval is present. // direct eval is present.
// //
// FIXME: Don't build arguments for ES6 generator expressions. // FIXME: Don't build arguments for ES6 generator expressions.
if (scriptArg->isDebuggee() || script->isGenerator() || script->bindingsAccessedDynamically()) if (scriptArg->isDebuggee() ||
script->isStarGenerator() ||
script->isLegacyGenerator() ||
script->isAsync() ||
script->bindingsAccessedDynamically())
{
return true; return true;
}
if (!jit::IsIonEnabled(cx)) if (!jit::IsIonEnabled(cx))
return true; return true;

View file

@ -131,7 +131,11 @@ IsFunctionInStrictMode(JSFunction* fun)
static bool static bool
IsNewerTypeFunction(JSFunction* fun) { IsNewerTypeFunction(JSFunction* fun) {
return fun->isArrow() || fun->isGenerator() || fun->isAsync() || fun->isMethod(); return fun->isArrow() ||
fun->isStarGenerator() ||
fun->isLegacyGenerator() ||
fun->isAsync() ||
fun->isMethod();
} }
// Beware: this function can be invoked on *any* function! That includes // Beware: this function can be invoked on *any* function! That includes
@ -442,8 +446,12 @@ fun_resolve(JSContext* cx, HandleObject obj, HandleId id, bool* resolvedp)
* - Arrow functions * - Arrow functions
* - Function.prototype * - Function.prototype
*/ */
if (fun->isBuiltin() || (!fun->isConstructor() && !fun->isGenerator())) if (fun->isBuiltin())
return true; return true;
if (!fun->isConstructor()) {
if (!fun->isStarGenerator() && !fun->isLegacyGenerator() && !fun->isAsync())
return true;
}
if (!ResolveInterpretedFunctionPrototype(cx, fun, id)) if (!ResolveInterpretedFunctionPrototype(cx, fun, id))
return false; return false;
@ -1556,7 +1564,7 @@ fun_isGenerator(JSContext* cx, unsigned argc, Value* vp)
return true; return true;
} }
args.rval().setBoolean(fun->isGenerator()); args.rval().setBoolean(fun->isStarGenerator() || fun->isLegacyGenerator());
return true; return true;
} }

View file

@ -146,7 +146,9 @@ class JSFunction : public js::NativeObject
MOZ_ASSERT_IF(nonLazyScript()->funHasExtensibleScope() || MOZ_ASSERT_IF(nonLazyScript()->funHasExtensibleScope() ||
nonLazyScript()->needsHomeObject() || nonLazyScript()->needsHomeObject() ||
nonLazyScript()->isDerivedClassConstructor() || nonLazyScript()->isDerivedClassConstructor() ||
isGenerator(), isStarGenerator() ||
isLegacyGenerator() ||
isAsync(),
nonLazyScript()->bodyScope()->hasEnvironment()); nonLazyScript()->bodyScope()->hasEnvironment());
return nonLazyScript()->bodyScope()->hasEnvironment(); return nonLazyScript()->bodyScope()->hasEnvironment();
@ -501,8 +503,6 @@ class JSFunction : public js::NativeObject
return js::NotGenerator; return js::NotGenerator;
} }
bool isGenerator() const { return generatorKind() != js::NotGenerator; }
bool isLegacyGenerator() const { return generatorKind() == js::LegacyGenerator; } bool isLegacyGenerator() const { return generatorKind() == js::LegacyGenerator; }
bool isStarGenerator() const { return generatorKind() == js::StarGenerator; } bool isStarGenerator() const { return generatorKind() == js::StarGenerator; }
@ -513,9 +513,9 @@ class JSFunction : public js::NativeObject
bool isAsync() const { bool isAsync() const {
if (isInterpretedLazy()) if (isInterpretedLazy())
return lazyScript()->asyncKind() == js::AsyncFunction; return lazyScript()->isAsync();
if (hasScript()) if (hasScript())
return nonLazyScript()->asyncKind() == js::AsyncFunction; return nonLazyScript()->isAsync();
return false; return false;
} }

View file

@ -3917,7 +3917,9 @@ JSScript::argumentsOptimizationFailed(JSContext* cx, HandleScript script)
if (script->needsArgsObj()) if (script->needsArgsObj())
return true; return true;
MOZ_ASSERT(!script->isGenerator()); MOZ_ASSERT(!script->isStarGenerator());
MOZ_ASSERT(!script->isLegacyGenerator());
MOZ_ASSERT(!script->isAsync());
script->needsArgsObj_ = true; script->needsArgsObj_ = true;

View file

@ -1327,13 +1327,12 @@ class JSScript : public js::gc::TenuredCell
js::GeneratorKind generatorKind() const { js::GeneratorKind generatorKind() const {
return js::GeneratorKindFromBits(generatorKindBits_); return js::GeneratorKindFromBits(generatorKindBits_);
} }
bool isGenerator() const { return generatorKind() != js::NotGenerator; }
bool isLegacyGenerator() const { return generatorKind() == js::LegacyGenerator; } bool isLegacyGenerator() const { return generatorKind() == js::LegacyGenerator; }
bool isStarGenerator() const { return generatorKind() == js::StarGenerator; } bool isStarGenerator() const { return generatorKind() == js::StarGenerator; }
void setGeneratorKind(js::GeneratorKind kind) { void setGeneratorKind(js::GeneratorKind kind) {
// A script only gets its generator kind set as part of initialization, // A script only gets its generator kind set as part of initialization,
// so it can only transition from not being a generator. // so it can only transition from not being a generator.
MOZ_ASSERT(!isGenerator()); MOZ_ASSERT(!isStarGenerator() && !isLegacyGenerator());
generatorKindBits_ = GeneratorKindAsBits(kind); generatorKindBits_ = GeneratorKindAsBits(kind);
} }
@ -1341,6 +1340,10 @@ class JSScript : public js::gc::TenuredCell
return isAsync_ ? js::AsyncFunction : js::SyncFunction; return isAsync_ ? js::AsyncFunction : js::SyncFunction;
} }
bool isAsync() const {
return isAsync_;
}
void setAsyncKind(js::FunctionAsyncKind kind) { void setAsyncKind(js::FunctionAsyncKind kind) {
isAsync_ = kind == js::AsyncFunction; isAsync_ = kind == js::AsyncFunction;
} }
@ -1493,7 +1496,8 @@ class JSScript : public js::gc::TenuredCell
bool isRelazifiable() const { bool isRelazifiable() const {
return (selfHosted() || lazyScript) && !hasInnerFunctions_ && !types_ && return (selfHosted() || lazyScript) && !hasInnerFunctions_ && !types_ &&
!isGenerator() && !hasBaselineScript() && !hasAnyIonScript() && !isStarGenerator() && !isLegacyGenerator() && !isAsync() &&
!hasBaselineScript() && !hasAnyIonScript() &&
!isDefaultClassConstructor() && !isDefaultClassConstructor() &&
!doNotRelazify_; !doNotRelazify_;
} }
@ -1695,7 +1699,7 @@ class JSScript : public js::gc::TenuredCell
bool hasObjects() const { return hasArray(OBJECTS); } bool hasObjects() const { return hasArray(OBJECTS); }
bool hasTrynotes() const { return hasArray(TRYNOTES); } bool hasTrynotes() const { return hasArray(TRYNOTES); }
bool hasScopeNotes() const { return hasArray(SCOPENOTES); } bool hasScopeNotes() const { return hasArray(SCOPENOTES); }
bool hasYieldOffsets() const { return isGenerator(); } bool hasYieldOffsets() const { return isStarGenerator() || isLegacyGenerator() || isAsync(); }
#define OFF(fooOff, hasFoo, t) (fooOff() + (hasFoo() ? sizeof(t) : 0)) #define OFF(fooOff, hasFoo, t) (fooOff() + (hasFoo() ? sizeof(t) : 0))
@ -2112,8 +2116,6 @@ class LazyScript : public gc::TenuredCell
GeneratorKind generatorKind() const { return GeneratorKindFromBits(p_.generatorKindBits); } GeneratorKind generatorKind() const { return GeneratorKindFromBits(p_.generatorKindBits); }
bool isGenerator() const { return generatorKind() != NotGenerator; }
bool isLegacyGenerator() const { return generatorKind() == LegacyGenerator; } bool isLegacyGenerator() const { return generatorKind() == LegacyGenerator; }
bool isStarGenerator() const { return generatorKind() == StarGenerator; } bool isStarGenerator() const { return generatorKind() == StarGenerator; }
@ -2121,7 +2123,7 @@ class LazyScript : public gc::TenuredCell
void setGeneratorKind(GeneratorKind kind) { void setGeneratorKind(GeneratorKind kind) {
// A script only gets its generator kind set as part of initialization, // A script only gets its generator kind set as part of initialization,
// so it can only transition from NotGenerator. // so it can only transition from NotGenerator.
MOZ_ASSERT(!isGenerator()); MOZ_ASSERT(!isStarGenerator() && !isLegacyGenerator());
// Legacy generators cannot currently be lazy. // Legacy generators cannot currently be lazy.
MOZ_ASSERT(kind != LegacyGenerator); MOZ_ASSERT(kind != LegacyGenerator);
p_.generatorKindBits = GeneratorKindAsBits(kind); p_.generatorKindBits = GeneratorKindAsBits(kind);
@ -2131,6 +2133,10 @@ class LazyScript : public gc::TenuredCell
return p_.isAsync ? AsyncFunction : SyncFunction; return p_.isAsync ? AsyncFunction : SyncFunction;
} }
bool isAsync() const {
return p_.isAsync;
}
void setAsyncKind(FunctionAsyncKind kind) { void setAsyncKind(FunctionAsyncKind kind) {
p_.isAsync = kind == AsyncFunction; p_.isAsync = kind == AsyncFunction;
} }

View file

@ -53,9 +53,8 @@ function asyncFunDecl(id, params, body) {
params: params, params: params,
defaults: [], defaults: [],
body: body, body: body,
generator: true, generator: false,
async: true, async: true });
style: "es6" });
} }
function varDecl(decls) { function varDecl(decls) {
return Pattern({ type: "VariableDeclaration", declarations: decls, kind: "var" }); return Pattern({ type: "VariableDeclaration", declarations: decls, kind: "var" });
@ -181,9 +180,8 @@ function asyncFunExpr(id, args, body) {
id: id, id: id,
params: args, params: args,
body: body, body: body,
generator: true, generator: false,
async: true, async: true });
style: "es6" });
} }
function arrowExpr(args, body) { function arrowExpr(args, body) {
return Pattern({ type: "ArrowFunctionExpression", return Pattern({ type: "ArrowFunctionExpression",
@ -194,10 +192,9 @@ function asyncArrowExpr(isExpression, args, body) {
return Pattern({ type: "ArrowFunctionExpression", return Pattern({ type: "ArrowFunctionExpression",
params: args, params: args,
body: body, body: body,
generator: true, generator: false,
async: true, async: true,
expression: isExpression, expression: isExpression });
style: "es6" });
} }
function metaProperty(meta, property) { function metaProperty(meta, property) {

View file

@ -7356,7 +7356,8 @@ DebuggerFrame::getEnvironment(JSContext* cx, HandleDebuggerFrame frame,
/* static */ bool /* static */ bool
DebuggerFrame::getIsGenerator(HandleDebuggerFrame frame) DebuggerFrame::getIsGenerator(HandleDebuggerFrame frame)
{ {
return DebuggerFrame::getReferent(frame).script()->isGenerator(); return DebuggerFrame::getReferent(frame).script()->isStarGenerator() ||
DebuggerFrame::getReferent(frame).script()->isLegacyGenerator();
} }
/* static */ bool /* static */ bool

View file

@ -2448,7 +2448,9 @@ DebugEnvironments::addDebugEnvironment(JSContext* cx, const EnvironmentIter& ei,
MOZ_ASSERT(cx->compartment() == debugEnv->compartment()); MOZ_ASSERT(cx->compartment() == debugEnv->compartment());
// Generators should always have environments. // Generators should always have environments.
MOZ_ASSERT_IF(ei.scope().is<FunctionScope>(), MOZ_ASSERT_IF(ei.scope().is<FunctionScope>(),
!ei.scope().as<FunctionScope>().canonicalFunction()->isGenerator()); !ei.scope().as<FunctionScope>().canonicalFunction()->isStarGenerator() &&
!ei.scope().as<FunctionScope>().canonicalFunction()->isLegacyGenerator() &&
!ei.scope().as<FunctionScope>().canonicalFunction()->isAsync());
if (!CanUseDebugEnvironmentMaps(cx)) if (!CanUseDebugEnvironmentMaps(cx))
return true; return true;
@ -2594,8 +2596,11 @@ DebugEnvironments::onPopCall(JSContext* cx, AbstractFramePtr frame)
if (!frame.environmentChain()->is<CallObject>()) if (!frame.environmentChain()->is<CallObject>())
return; return;
if (frame.callee()->isGenerator()) if (frame.callee()->isStarGenerator() || frame.callee()->isLegacyGenerator() ||
frame.callee()->isAsync())
{
return; return;
}
CallObject& callobj = frame.environmentChain()->as<CallObject>(); CallObject& callobj = frame.environmentChain()->as<CallObject>();
envs->liveEnvs.remove(&callobj); envs->liveEnvs.remove(&callobj);
@ -2726,8 +2731,13 @@ DebugEnvironments::updateLiveEnvironments(JSContext* cx)
if (frame.environmentChain()->compartment() != cx->compartment()) if (frame.environmentChain()->compartment() != cx->compartment())
continue; continue;
if (frame.isFunctionFrame() && frame.callee()->isGenerator()) if (frame.isFunctionFrame()) {
continue; if (frame.callee()->isStarGenerator() || frame.callee()->isLegacyGenerator() ||
frame.callee()->isAsync())
{
continue;
}
}
if (!frame.isDebuggee()) if (!frame.isDebuggee())
continue; continue;
@ -2882,7 +2892,8 @@ GetDebugEnvironmentForMissing(JSContext* cx, const EnvironmentIter& ei)
if (ei.scope().is<FunctionScope>()) { if (ei.scope().is<FunctionScope>()) {
RootedFunction callee(cx, ei.scope().as<FunctionScope>().canonicalFunction()); RootedFunction callee(cx, ei.scope().as<FunctionScope>().canonicalFunction());
// Generators should always reify their scopes. // Generators should always reify their scopes.
MOZ_ASSERT(!callee->isGenerator()); MOZ_ASSERT(!callee->isStarGenerator() && !callee->isLegacyGenerator() &&
!callee->isAsync());
JS::ExposeObjectToActiveJS(callee); JS::ExposeObjectToActiveJS(callee);
Rooted<CallObject*> callobj(cx, CallObject::createHollowForDebug(cx, callee)); Rooted<CallObject*> callobj(cx, CallObject::createHollowForDebug(cx, callee));

View file

@ -19,7 +19,8 @@ using namespace js;
JSObject* JSObject*
GeneratorObject::create(JSContext* cx, AbstractFramePtr frame) GeneratorObject::create(JSContext* cx, AbstractFramePtr frame)
{ {
MOZ_ASSERT(frame.script()->isGenerator()); MOZ_ASSERT(frame.script()->isStarGenerator() || frame.script()->isLegacyGenerator() ||
frame.script()->isAsync());
MOZ_ASSERT(frame.script()->nfixed() == 0); MOZ_ASSERT(frame.script()->nfixed() == 0);
Rooted<GlobalObject*> global(cx, cx->global()); Rooted<GlobalObject*> global(cx, cx->global());

View file

@ -184,7 +184,7 @@ ObjectGroup::useSingletonForNewObject(JSContext* cx, JSScript* script, jsbytecod
* Sub2 lets us continue to distinguish the two subclasses and any extra * Sub2 lets us continue to distinguish the two subclasses and any extra
* properties added to those prototype objects. * properties added to those prototype objects.
*/ */
if (script->isGenerator()) if (script->isStarGenerator() || script->isLegacyGenerator() || script->isAsync())
return false; return false;
if (JSOp(*pc) != JSOP_NEW) if (JSOp(*pc) != JSOP_NEW)
return false; return false;

View file

@ -41,7 +41,10 @@ probes::EnterScript(JSContext* cx, JSScript* script, JSFunction* maybeFun,
if (rt->spsProfiler.enabled()) { if (rt->spsProfiler.enabled()) {
if (!rt->spsProfiler.enter(cx, script, maybeFun)) if (!rt->spsProfiler.enter(cx, script, maybeFun))
return false; return false;
MOZ_ASSERT_IF(!fp->script()->isGenerator(), !fp->hasPushedSPSFrame()); MOZ_ASSERT_IF(!fp->script()->isStarGenerator() &&
!fp->script()->isLegacyGenerator() &&
!fp->script()->isAsync(),
!fp->hasPushedSPSFrame());
fp->setPushedSPSFrame(); fp->setPushedSPSFrame();
} }

View file

@ -3113,7 +3113,8 @@ JSRuntime::cloneSelfHostedFunctionScript(JSContext* cx, HandlePropertyName name,
return false; return false;
// JSFunction::generatorKind can't handle lazy self-hosted functions, so we make sure there // JSFunction::generatorKind can't handle lazy self-hosted functions, so we make sure there
// aren't any. // aren't any.
MOZ_ASSERT(!sourceFun->isGenerator()); MOZ_ASSERT(!sourceFun->isStarGenerator() && !sourceFun->isLegacyGenerator() &&
!sourceFun->isAsync());
MOZ_ASSERT(targetFun->isExtended()); MOZ_ASSERT(targetFun->isExtended());
MOZ_ASSERT(targetFun->isInterpretedLazy()); MOZ_ASSERT(targetFun->isInterpretedLazy());
MOZ_ASSERT(targetFun->isSelfHostedBuiltin()); MOZ_ASSERT(targetFun->isSelfHostedBuiltin());

View file

@ -335,7 +335,7 @@ InterpreterStack::resumeGeneratorCallFrame(JSContext* cx, InterpreterRegs& regs,
HandleFunction callee, HandleValue newTarget, HandleFunction callee, HandleValue newTarget,
HandleObject envChain) HandleObject envChain)
{ {
MOZ_ASSERT(callee->isGenerator()); MOZ_ASSERT(callee->isStarGenerator() || callee->isLegacyGenerator() || callee->isAsync());
RootedScript script(cx, JSFunction::getOrCreateScript(cx, callee)); RootedScript script(cx, JSFunction::getOrCreateScript(cx, callee));
InterpreterFrame* prev = regs.fp(); InterpreterFrame* prev = regs.fp();
jsbytecode* prevpc = regs.pc; jsbytecode* prevpc = regs.pc;

View file

@ -270,7 +270,9 @@ InterpreterFrame::epilogue(JSContext* cx, jsbytecode* pc)
UnwindAllEnvironmentsInFrame(cx, ei); UnwindAllEnvironmentsInFrame(cx, ei);
if (isFunctionFrame()) { if (isFunctionFrame()) {
if (!callee().isGenerator() && if (!callee().isStarGenerator() &&
!callee().isLegacyGenerator() &&
!callee().isAsync() &&
isConstructing() && isConstructing() &&
thisArgument().isObject() && thisArgument().isObject() &&
returnValue().isPrimitive()) returnValue().isPrimitive())

View file

@ -693,7 +693,8 @@ class InterpreterFrame
} }
void resumeGeneratorFrame(JSObject* envChain) { void resumeGeneratorFrame(JSObject* envChain) {
MOZ_ASSERT(script()->isGenerator()); MOZ_ASSERT(script()->isStarGenerator() || script()->isLegacyGenerator() ||
script()->isAsync());
MOZ_ASSERT(isFunctionFrame()); MOZ_ASSERT(isFunctionFrame());
flags_ |= HAS_INITIAL_ENV; flags_ |= HAS_INITIAL_ENV;
envChain_ = envChain; envChain_ = envChain;

View file

@ -8608,9 +8608,12 @@ EstablishPreconditions(ExclusiveContext* cx, AsmJSParser& parser)
break; break;
} }
if (parser.pc->isGenerator()) if (parser.pc->isStarGenerator() || parser.pc->isLegacyGenerator())
return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by generator context"); return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by generator context");
if (parser.pc->isAsync())
return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by async context");
if (parser.pc->isArrowFunction()) if (parser.pc->isArrowFunction())
return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by arrow function context"); return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by arrow function context");