diff --git a/dom/base/nsScriptLoader.cpp b/dom/base/nsScriptLoader.cpp index bc442e3623e6..ef07a422103b 100644 --- a/dom/base/nsScriptLoader.cpp +++ b/dom/base/nsScriptLoader.cpp @@ -1074,6 +1074,7 @@ nsScriptLoader::FillCompileOptionsForRequest(const AutoJSAPI &jsapi, aOptions->setFileAndLine(aRequest->mURL.get(), aRequest->mLineNo); aOptions->setVersion(JSVersion(aRequest->mJSVersion)); aOptions->setCompileAndGo(JS_IsGlobalObject(aScopeChain)); + aOptions->setIsRunOnce(true); // We only need the setNoScriptRval bit when compiling off-thread here, since // otherwise nsJSUtils::EvaluateString will set it up for us. aOptions->setNoScriptRval(true); diff --git a/js/src/builtin/Eval.cpp b/js/src/builtin/Eval.cpp index 4c3f94750704..22557d742099 100644 --- a/js/src/builtin/Eval.cpp +++ b/js/src/builtin/Eval.cpp @@ -334,6 +334,7 @@ EvalKernel(JSContext* cx, const CallArgs& args, EvalType evalType, AbstractFrame options.setFileAndLine(filename, 1) .setCompileAndGo(true) .setHasPollutedScope(hasPollutedGlobalScope) + .setIsRunOnce(true) .setForEval(true) .setNoScriptRval(false) .setMutedErrors(mutedErrors) @@ -418,6 +419,7 @@ js::DirectEvalStringFromIon(JSContext* cx, .setCompileAndGo(true) .setHasPollutedScope(HasPollutedScopeChain(scopeobj) || callerScript->hasPollutedGlobalScope()) + .setIsRunOnce(true) .setForEval(true) .setNoScriptRval(false) .setMutedErrors(mutedErrors) diff --git a/js/src/jit-test/lib/bytecode-cache.js b/js/src/jit-test/lib/bytecode-cache.js index b382cb1eae96..5825d31f8d04 100644 --- a/js/src/jit-test/lib/bytecode-cache.js +++ b/js/src/jit-test/lib/bytecode-cache.js @@ -11,9 +11,11 @@ function evalWithCache(code, ctx) { if (!("global" in ctx)) ctx.global = newGlobal(); - // ... and by default enable compileAndGo. + // ... and by default enable compileAndGo and isRunOnce if (!("compileAndGo" in ctx)) ctx.compileAndGo = true; + if (!("isRunOnce" in ctx)) + ctx.isRunOnce = true; // Fetch the verification function from the evaluation context. This function // is used to assert the state of the script/function after each run of the diff --git a/js/src/jit-test/tests/SIMD/bug1121299.js b/js/src/jit-test/tests/SIMD/bug1121299.js index c610e5b9615c..edb43427f25d 100644 --- a/js/src/jit-test/tests/SIMD/bug1121299.js +++ b/js/src/jit-test/tests/SIMD/bug1121299.js @@ -27,5 +27,6 @@ function test_2() { } test_2(); evaluate("test_2(); test_2();", { - compileAndGo: true + compileAndGo: true, + isRunOnce: true, }); diff --git a/js/src/jit-test/tests/TypedObject/bug1004527.js b/js/src/jit-test/tests/TypedObject/bug1004527.js index 934b528bb0b1..bded0f663a4a 100644 --- a/js/src/jit-test/tests/TypedObject/bug1004527.js +++ b/js/src/jit-test/tests/TypedObject/bug1004527.js @@ -5,4 +5,5 @@ var { ArrayType, StructType, uint32 } = TypedObject; var L = 1024; var Matrix = uint32.array(L, 2); var matrix = new Matrix(); -evaluate("for (var i = 0; i < L; i++) matrix[i][0] = (function d() {});", { compileAndGo : true }); +evaluate("for (var i = 0; i < L; i++) matrix[i][0] = (function d() {});", + { compileAndGo : true, isRunOnce: true }); diff --git a/js/src/jit-test/tests/basic/bug1024786.js b/js/src/jit-test/tests/basic/bug1024786.js index 95add49195e8..2f0df0d33b5d 100644 --- a/js/src/jit-test/tests/basic/bug1024786.js +++ b/js/src/jit-test/tests/basic/bug1024786.js @@ -61,5 +61,6 @@ evaluate("function f(){\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",({ fileName: null, lineNumber: 42, - compileAndGo: 9 + compileAndGo: 9, + isRunOnce: 9, })) diff --git a/js/src/jit-test/tests/basic/bug1057571.js b/js/src/jit-test/tests/basic/bug1057571.js index b56c81fda3f2..0167a253b0b7 100644 --- a/js/src/jit-test/tests/basic/bug1057571.js +++ b/js/src/jit-test/tests/basic/bug1057571.js @@ -9,6 +9,7 @@ evalWithCache(test, {}); function evalWithCache(code, ctx) { code = cacheEntry(code); ctx.compileAndGo = true; + ctx.isRunOnce = true; var res1 = evaluate(code, Object.create(ctx, {saveBytecode: { value: true } })); var res2 = evaluate(code, Object.create(ctx, {loadBytecode: { value: true }, saveBytecode: { value: true } })); } diff --git a/js/src/jit-test/tests/basic/bug1061534.js b/js/src/jit-test/tests/basic/bug1061534.js index 62a79c99a126..2bc242d2b110 100644 --- a/js/src/jit-test/tests/basic/bug1061534.js +++ b/js/src/jit-test/tests/basic/bug1061534.js @@ -11,4 +11,4 @@ function evalWithCache(code, ctx) { if (typeof assertThrowsInstanceOf === 'undefined') { var assertThrowsInstanceOf = function assertThrowsInstanceOf(f, ctor, msg) {}; } -evaluate('evaluate(\'assertThrowsInstanceOf(function () {}, ["jak", "ms"]);\', { noScriptRval : true, compileAndGo : true })'); +evaluate('evaluate(\'assertThrowsInstanceOf(function () {}, ["jak", "ms"]);\', { noScriptRval : true, compileAndGo : true, isRunOnce: true })'); diff --git a/js/src/jit-test/tests/debug/bug1106164.js b/js/src/jit-test/tests/debug/bug1106164.js index 8159f1efa386..8b5581200c3d 100644 --- a/js/src/jit-test/tests/debug/bug1106164.js +++ b/js/src/jit-test/tests/debug/bug1106164.js @@ -14,4 +14,4 @@ evaluate("\ }\ }\ }\ -", { noScriptRval : true, compileAndGo : true }); +", { noScriptRval : true, compileAndGo : true, isRunOnce: true }); diff --git a/js/src/jit-test/tests/debug/bug1107913.js b/js/src/jit-test/tests/debug/bug1107913.js index b212cf337a13..fc85fcca8e4c 100644 --- a/js/src/jit-test/tests/debug/bug1107913.js +++ b/js/src/jit-test/tests/debug/bug1107913.js @@ -4,4 +4,4 @@ var g = newGlobal(); g.parent = this; g.eval("new Debugger(parent).onExceptionUnwind = function () {};"); Object.preventExtensions(this); -evaluate("function testcase() { }", { noScriptRval : true, compileAndGo : true }); +evaluate("function testcase() { }", { noScriptRval : true, compileAndGo : true, isRunOnce: true }); diff --git a/js/src/jit-test/tests/debug/bug1108556.js b/js/src/jit-test/tests/debug/bug1108556.js index d0961f8f7624..b540b9ea1ef0 100644 --- a/js/src/jit-test/tests/debug/bug1108556.js +++ b/js/src/jit-test/tests/debug/bug1108556.js @@ -7,4 +7,4 @@ evaluate('\ var fe="v";\ for (i=0; String.fromCharCode(0x004E); i++)\ fe += fe;\ -', { compileAndGo : true }); +', { compileAndGo : true, isRunOnce: true }); diff --git a/js/src/jit-test/tests/debug/bug1118878.js b/js/src/jit-test/tests/debug/bug1118878.js index 3dc4e361ab28..2c6c6a0a4984 100644 --- a/js/src/jit-test/tests/debug/bug1118878.js +++ b/js/src/jit-test/tests/debug/bug1118878.js @@ -8,4 +8,4 @@ var evalInFrame = (function (global) { var completion = frame.eval(code); }; })(this); -evaluate("for (var k in 'xxx') (function g() { Math.atan2(42); evalInFrame((0), (''), true); })();", { noScriptRval : true, compileAndGo : true }); +evaluate("for (var k in 'xxx') (function g() { Math.atan2(42); evalInFrame((0), (''), true); })();", { noScriptRval : true, compileAndGo : true, isRunOnce : true }); diff --git a/js/src/jit-test/tests/gc/bug-1016016.js b/js/src/jit-test/tests/gc/bug-1016016.js index 78b9d6b0e9d6..77ab38b32aa6 100644 --- a/js/src/jit-test/tests/gc/bug-1016016.js +++ b/js/src/jit-test/tests/gc/bug-1016016.js @@ -11,5 +11,5 @@ newGlobal();\ ''.addDebuggee(g1);\ "); function loadFile(lfVarx) { - evaluate(lfVarx, { noScriptRval : true, compileAndGo : true }); + evaluate(lfVarx, { noScriptRval : true, compileAndGo : true, isRunOnce : true }); } diff --git a/js/src/jit-test/tests/ion/bug1006899.js b/js/src/jit-test/tests/ion/bug1006899.js index 38956f6fc323..0be111a95e9b 100644 --- a/js/src/jit-test/tests/ion/bug1006899.js +++ b/js/src/jit-test/tests/ion/bug1006899.js @@ -15,4 +15,4 @@ var { ArrayType, StructType, uint32 } = TypedObject;\ var matrix = new Matrix();\ for (var i = 0; i < L; i++)\ matrix[i][0] = x;\ -", { compileAndGo : true }); +", { compileAndGo : true, isRunOnce : true }); diff --git a/js/src/jit-test/tests/ion/bug984830.js b/js/src/jit-test/tests/ion/bug984830.js index fac11697cd26..7e4997e95c34 100644 --- a/js/src/jit-test/tests/ion/bug984830.js +++ b/js/src/jit-test/tests/ion/bug984830.js @@ -12,4 +12,5 @@ Engineer.prototype = new WorkerBee(); var pat = new Engineer(); getTestCaseResult(pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype); getTestCaseResult(InstanceOf(pat, Engineer)); -evaluate("getTestCaseResult( Object.prototype.__proto__ );", { compileAndGo: true }); +evaluate("getTestCaseResult( Object.prototype.__proto__ );", + { compileAndGo: true, isRunOnce: true }); diff --git a/js/src/jit-test/tests/profiler/bug1140643.js b/js/src/jit-test/tests/profiler/bug1140643.js index b826cb7e35c3..f01637f4fe2d 100644 --- a/js/src/jit-test/tests/profiler/bug1140643.js +++ b/js/src/jit-test/tests/profiler/bug1140643.js @@ -10,5 +10,5 @@ for (var i = 0; i < 2; i++) {\ gcparam("maxBytes", gcparam("gcBytes") + (1)*1024); newGlobal("same-compartment"); function loadFile(lfVarx) { - evaluate(lfVarx, { noScriptRval : true, compileAndGo : true }); + evaluate(lfVarx, { noScriptRval : true, compileAndGo : true, isRunOnce : true }); } diff --git a/js/src/jit-test/tests/symbol/toNumber-2.js b/js/src/jit-test/tests/symbol/toNumber-2.js index 9f1f59cede6a..3c0e65dd416d 100644 --- a/js/src/jit-test/tests/symbol/toNumber-2.js +++ b/js/src/jit-test/tests/symbol/toNumber-2.js @@ -11,4 +11,4 @@ try { } catch (exc1) {} eq(.1, .1); var sym = Symbol("method"); -evaluate("f(test, sym, 0)", {compileAndGo: true}); +evaluate("f(test, sym, 0)", {compileAndGo: true, isRunOnce:true}); diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 8937de65da12..0db35ee9707f 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -4024,9 +4024,7 @@ CompileFunction(JSContext* cx, const ReadOnlyCompileOptions& optionsArg, return false; // Make sure to handle cases when we have a polluted scopechain. - OwningCompileOptions options(cx); - if (!options.copy(cx, optionsArg)) - return false; + CompileOptions options(cx, optionsArg); if (!enclosingDynamicScope->is()) options.setHasPollutedScope(true); @@ -4204,6 +4202,7 @@ Evaluate(JSContext* cx, HandleObject scope, const ReadOnlyCompileOptions& option options.setCompileAndGo(scope->is()); options.setHasPollutedScope(!scope->is()); + options.setIsRunOnce(true); SourceCompressionTask sct(cx); RootedScript script(cx, frontend::CompileScript(cx, &cx->tempLifoAlloc(), scope, NullPtr(), NullPtr(), options, diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index aeee5f4be789..c3572188d170 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -451,6 +451,7 @@ RunFile(JSContext* cx, const char* filename, FILE* file, bool compileOnly) .setUTF8(true) .setFileAndLine(filename, 1) .setCompileAndGo(true) + .setIsRunOnce(true) .setNoScriptRval(true); gGotError = false; @@ -482,6 +483,7 @@ EvalAndPrint(JSContext* cx, const char* bytes, size_t length, options.setIntroductionType("js shell interactive") .setUTF8(true) .setCompileAndGo(true) + .setIsRunOnce(true) .setFileAndLine("typein", lineno); RootedScript script(cx); if (!JS::Compile(cx, options, bytes, length, &script)) @@ -866,6 +868,7 @@ LoadScript(JSContext* cx, unsigned argc, jsval* vp, bool scriptRelative) opts.setIntroductionType("js shell load") .setUTF8(true) .setCompileAndGo(true) + .setIsRunOnce(true) .setNoScriptRval(true); RootedScript script(cx); RootedValue unused(cx); @@ -907,6 +910,11 @@ ParseCompileOptions(JSContext* cx, CompileOptions& options, HandleObject opts, if (!v.isUndefined()) options.setCompileAndGo(ToBoolean(v)); + if (!JS_GetProperty(cx, opts, "isRunOnce", &v)) + return false; + if (!v.isUndefined()) + options.setIsRunOnce(ToBoolean(v)); + if (!JS_GetProperty(cx, opts, "noScriptRval", &v)) return false; if (!v.isUndefined()) @@ -1485,6 +1493,7 @@ Run(JSContext* cx, unsigned argc, jsval* vp) options.setIntroductionType("js shell run") .setFileAndLine(filename.ptr(), 1) .setCompileAndGo(true) + .setIsRunOnce(true) .setNoScriptRval(true); if (!JS_CompileUCScript(cx, ucbuf, buflen, options, &script)) return false; @@ -2377,6 +2386,7 @@ DisassFile(JSContext* cx, unsigned argc, jsval* vp) .setUTF8(true) .setFileAndLine(filename.ptr(), 1) .setCompileAndGo(true) + .setIsRunOnce(true) .setNoScriptRval(true); if (!JS::Compile(cx, options, filename.ptr(), &script)) @@ -2803,7 +2813,8 @@ WorkerMain(void* arg) JS::CompileOptions options(cx); options.setFileAndLine("", 1) - .setCompileAndGo(true); + .setCompileAndGo(true) + .setIsRunOnce(true); RootedScript script(cx); if (!JS::Compile(cx, options, input->chars, input->length, &script)) @@ -3248,6 +3259,7 @@ Compile(JSContext* cx, unsigned argc, jsval* vp) options.setIntroductionType("js shell compile") .setFileAndLine("", 1) .setCompileAndGo(true) + .setIsRunOnce(true) .setNoScriptRval(true); RootedScript script(cx); const char16_t* chars = stableChars.twoByteRange().start().get(); @@ -3480,6 +3492,7 @@ OffThreadCompileScript(JSContext* cx, unsigned argc, jsval* vp) // These option settings must override whatever the caller requested. options.setCompileAndGo(true) + .setIsRunOnce(true) .setSourceIsLazy(false); // We assume the caller wants caching if at all possible, ignoring @@ -4517,6 +4530,7 @@ static const JSFunctionSpecWithHelp shell_functions[] = { " Evaluate code as though it were the contents of a file.\n" " options is an optional object that may have these properties:\n" " compileAndGo: use the compile-and-go compiler option (default: true)\n" +" isRunOnce: use the isRunOnce compiler option (default: false)\n" " noScriptRval: use the no-script-rval compiler option (default: false)\n" " fileName: filename for error messages and debug info\n" " lineNumber: starting line number for error messages and debug info\n" diff --git a/js/src/tests/ecma_5/extensions/misplaced-inconsistent-directive.js b/js/src/tests/ecma_5/extensions/misplaced-inconsistent-directive.js index 9b4c7a28e570..a7deb8140824 100644 --- a/js/src/tests/ecma_5/extensions/misplaced-inconsistent-directive.js +++ b/js/src/tests/ecma_5/extensions/misplaced-inconsistent-directive.js @@ -23,7 +23,7 @@ options("werror"); function evaluateNoRval(code) { - evaluate(code, { compileAndGo: true, noScriptRval: true }); + evaluate(code, { compileAndGo: true, isRunOnce: true, noScriptRval: true }); } function expectSyntaxError(code) diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 473a799077c5..71d9240e79de 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -6150,6 +6150,7 @@ EvaluateInEnv(JSContext* cx, Handle env, HandleValue thisv, AbstractFrameP CompileOptions options(cx); options.setCompileAndGo(true) .setHasPollutedScope(true) + .setIsRunOnce(true) .setForEval(true) .setNoScriptRval(false) .setFileAndLine(filename, lineno) diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index 5efcee45dff2..ffe5cd8488a5 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -340,7 +340,8 @@ Load(JSContext* cx, unsigned argc, jsval* vp) JS::CompileOptions options(cx); options.setUTF8(true) .setFileAndLine(filename.ptr(), 1) - .setCompileAndGo(true); + .setCompileAndGo(true) + .setIsRunOnce(true); JS::Rooted script(cx); JS::Rooted global(cx, JS::CurrentGlobalOrNull(cx)); JS::Compile(cx, options, file, &script); @@ -835,7 +836,8 @@ ProcessFile(JSContext* cx, const char* filename, FILE* file, bool forceTTY) JS::CompileOptions options(cx); options.setUTF8(true) .setFileAndLine(filename, 1) - .setCompileAndGo(true); + .setCompileAndGo(true) + .setIsRunOnce(true); if (JS::Compile(cx, options, file, &script) && !compileOnly) (void)JS_ExecuteScript(cx, script, &result); JS_EndRequest(cx); @@ -871,7 +873,8 @@ ProcessFile(JSContext* cx, const char* filename, FILE* file, bool forceTTY) JS_ClearPendingException(cx); JS::CompileOptions options(cx); options.setFileAndLine("typein", startline) - .setCompileAndGo(true); + .setCompileAndGo(true) + .setIsRunOnce(true); if (JS_CompileScript(cx, buffer, strlen(buffer), options, &script)) { JSErrorReporter older;