From 9636c3ba3eb900950fe8f57c75c0a697c698327d Mon Sep 17 00:00:00 2001 From: Ted Campbell Date: Wed, 15 Apr 2020 22:07:34 +0000 Subject: [PATCH] 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 --- js/src/frontend/BytecodeEmitter.cpp | 17 ++++------------- js/src/frontend/BytecodeEmitter.h | 2 -- 2 files changed, 4 insertions(+), 15 deletions(-) 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,