From 05520836366d86ead722612942cc099b0ffc3809 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 1 Apr 2015 12:05:29 -0400 Subject: [PATCH] Bug 679939 part 5. Stop using the compileAndGo script flag in the bytecode emitter. r=luke --- js/src/frontend/BytecodeEmitter.cpp | 17 ++++++++++------- js/src/frontend/BytecodeEmitter.h | 4 ++++ js/src/vm/Xdr.h | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index d4870457bb2..e878553795c 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -1680,7 +1680,7 @@ BytecodeEmitter::bindNameToSlotHelper(ParseNode* pn) if (dn->pn_cookie.isFree()) { if (evalCaller) { - MOZ_ASSERT(script->compileAndGo()); + MOZ_ASSERT(script->treatAsRunOnce() || sc->isFunctionBox()); /* * Don't generate upvars on the left side of a for loop. See @@ -2073,12 +2073,18 @@ BytecodeEmitter::isInLoop() bool BytecodeEmitter::checkSingletonContext() { - if (!script->compileAndGo() || sc->isFunctionBox() || isInLoop()) + if (!script->treatAsRunOnce() || sc->isFunctionBox() || isInLoop()) return false; hasSingletons = true; return true; } +bool +BytecodeEmitter::checkRunOnceContext() +{ + return checkSingletonContext() || (!isInLoop() && isRunOnceLambda()); +} + bool BytecodeEmitter::needsImplicitThis() { @@ -5194,10 +5200,7 @@ BytecodeEmitter::emitFunction(ParseNode* pn, bool needsProto) * make a deep clone of its contents. */ if (fun->isInterpreted()) { - bool singleton = - script->compileAndGo() && - fun->isInterpreted() && - (checkSingletonContext() || (!isInLoop() && isRunOnceLambda())); + bool singleton = checkRunOnceContext(); if (!JSFunction::setTypeForScriptedFunction(cx, fun, singleton)) return false; @@ -6088,7 +6091,7 @@ BytecodeEmitter::emitCallOrNew(ParseNode* pn) * will just cause the inner scripts to be repeatedly cloned. */ MOZ_ASSERT(!emittingRunOnceLambda); - if (checkSingletonContext() || (!isInLoop() && isRunOnceLambda())) { + if (checkRunOnceContext()) { emittingRunOnceLambda = true; if (!emitTree(pn2)) return false; diff --git a/js/src/frontend/BytecodeEmitter.h b/js/src/frontend/BytecodeEmitter.h index 4e8dacf1ac9..0a0c95889d2 100644 --- a/js/src/frontend/BytecodeEmitter.h +++ b/js/src/frontend/BytecodeEmitter.h @@ -248,6 +248,10 @@ struct BytecodeEmitter bool isInLoop(); bool checkSingletonContext(); + // Check whether our function is in a run-once context (a toplevel + // run-one script or a run-once lambda). + bool checkRunOnceContext(); + bool needsImplicitThis(); void tellDebuggerAboutCompiledScript(ExclusiveContext* cx); diff --git a/js/src/vm/Xdr.h b/js/src/vm/Xdr.h index 840efda8c7e..ce5be503d24 100644 --- a/js/src/vm/Xdr.h +++ b/js/src/vm/Xdr.h @@ -29,7 +29,7 @@ namespace js { * * https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode */ -static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 270; +static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 271; static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND);