Bug 679939 part 3. Add a CompileOptions flag for indicating that the script should be compiled runOnce. r=luke

This commit is contained in:
Boris Zbarsky 2015-04-01 12:05:28 -04:00
parent 96ca1664a7
commit 458bf125e5
3 changed files with 8 additions and 0 deletions

View File

@ -537,6 +537,8 @@ CompileFunctionBody(JSContext* cx, MutableHandleFunction fun, const ReadOnlyComp
const AutoNameVector& formals, SourceBufferHolder& srcBuf,
HandleObject enclosingStaticScope, GeneratorKind generatorKind)
{
MOZ_ASSERT(!options.isRunOnce);
js::TraceLoggerThread* logger = js::TraceLoggerForMainThread(cx->runtime());
js::TraceLoggerEvent event(logger, TraceLogger_AnnotateScripts, options);
js::AutoTraceLog scriptLogger(logger, event);

View File

@ -3403,6 +3403,7 @@ class JS_FRIEND_API(ReadOnlyCompileOptions)
column(0),
compileAndGo(false),
hasPollutedGlobalScope(false),
isRunOnce(false),
forEval(false),
noScriptRval(false),
selfHostingMode(false),
@ -3443,6 +3444,8 @@ class JS_FRIEND_API(ReadOnlyCompileOptions)
unsigned column;
bool compileAndGo;
bool hasPollutedGlobalScope;
// isRunOnce only applies to non-function scripts.
bool isRunOnce;
bool forEval;
bool noScriptRval;
bool selfHostingMode;
@ -3535,6 +3538,7 @@ class JS_FRIEND_API(OwningCompileOptions) : public ReadOnlyCompileOptions
OwningCompileOptions& setColumn(unsigned c) { column = c; return *this; }
OwningCompileOptions& setCompileAndGo(bool cng) { compileAndGo = cng; return *this; }
OwningCompileOptions& setHasPollutedScope(bool p) { hasPollutedGlobalScope = p; return *this; }
OwningCompileOptions& setIsRunOnce(bool once) { isRunOnce = once; return *this; }
OwningCompileOptions& setForEval(bool eval) { forEval = eval; return *this; }
OwningCompileOptions& setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; }
OwningCompileOptions& setSelfHostingMode(bool shm) { selfHostingMode = shm; return *this; }
@ -3619,6 +3623,7 @@ class MOZ_STACK_CLASS JS_FRIEND_API(CompileOptions) : public ReadOnlyCompileOpti
CompileOptions& setColumn(unsigned c) { column = c; return *this; }
CompileOptions& setCompileAndGo(bool cng) { compileAndGo = cng; return *this; }
CompileOptions& setHasPollutedScope(bool p) { hasPollutedGlobalScope = p; return *this; }
CompileOptions& setIsRunOnce(bool once) { isRunOnce = once; return *this; }
CompileOptions& setForEval(bool eval) { forEval = eval; return *this; }
CompileOptions& setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; }
CompileOptions& setSelfHostingMode(bool shm) { selfHostingMode = shm; return *this; }

View File

@ -2416,6 +2416,7 @@ JSScript::Create(ExclusiveContext* cx, HandleObject enclosingScope, bool savedCa
script->hasPollutedGlobalScope_ = options.hasPollutedGlobalScope;
script->selfHosted_ = options.selfHostingMode;
script->noScriptRval_ = options.noScriptRval;
script->treatAsRunOnce_ = options.isRunOnce;
script->version = options.version;
MOZ_ASSERT(script->getVersion() == options.version); // assert that no overflow occurred