Bug 1629721 - Remove BytecodeEmitter::runOnceLambda helper. r=mgaudet

Instead rely on consistent definitions of the TreatAsRunOnce flag on the
SharedContext. Also simplify the BCE::check{RunOnce,Singleton}Context
accessors. Note that the TreatAsRunOnce flag indicates the script is expected
to run-once, but the BCE also checks for isInLoop to decide if current
bytecode location within the script should still be considered run-once.

Differential Revision: https://phabricator.services.mozilla.com/D70780

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ted Campbell 2020-04-15 22:07:34 +00:00
Родитель b5951c4ebc
Коммит 9636c3ba3e
2 изменённых файлов: 4 добавлений и 15 удалений

Просмотреть файл

@ -1535,12 +1535,12 @@ bool BytecodeEmitter::isInLoop() {
return findInnermostNestableControl<LoopControl>();
}
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);

Просмотреть файл

@ -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,