diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index 46386ee8782b..437684ac7634 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -1535,12 +1535,12 @@ bool BytecodeEmitter::isInLoop() { return findInnermostNestableControl(); } -bool BytecodeEmitter::checkSingletonContext() { - return sc->treatAsRunOnce() && !sc->isFunctionBox() && !isInLoop(); +bool BytecodeEmitter::checkRunOnceContext() { + return sc->treatAsRunOnce() && !isInLoop(); } -bool BytecodeEmitter::checkRunOnceContext() { - return checkSingletonContext() || (!isInLoop() && isRunOnceLambda()); +bool BytecodeEmitter::checkSingletonContext() { + return sc->isTopLevelContext() && checkRunOnceContext(); } bool BytecodeEmitter::needsImplicitThis() { @@ -2190,15 +2190,6 @@ MOZ_NEVER_INLINE bool BytecodeEmitter::emitSwitch(SwitchStatement* switchStmt) { return true; } -bool BytecodeEmitter::isRunOnceLambda() { - if (emitterMode == LazyFunction) { - return sc->treatAsRunOnce(); - } - - return parent && parent->emittingRunOnceLambda && - !sc->asFunctionBox()->shouldSuppressRunOnce(); -} - bool BytecodeEmitter::allocateResumeIndex(BytecodeOffset offset, uint32_t* resumeIndex) { static constexpr uint32_t MaxResumeIndex = BitMask(24); diff --git a/js/src/frontend/BytecodeEmitter.h b/js/src/frontend/BytecodeEmitter.h index 8111827357f9..d00d886da481 100644 --- a/js/src/frontend/BytecodeEmitter.h +++ b/js/src/frontend/BytecodeEmitter.h @@ -142,8 +142,6 @@ struct MOZ_STACK_CLASS BytecodeEmitter { // True while emitting a lambda which is only expected to run once. bool emittingRunOnceLambda = false; - bool isRunOnceLambda(); - enum EmitterMode { Normal,