mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 679939 part 4. Set the isRunOnce compile flag as needed. r=luke
This commit is contained in:
parent
b7e994b551
commit
dbe0249159
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -27,5 +27,6 @@ function test_2() {
|
||||
}
|
||||
test_2();
|
||||
evaluate("test_2(); test_2();", {
|
||||
compileAndGo: true
|
||||
compileAndGo: true,
|
||||
isRunOnce: true,
|
||||
});
|
||||
|
@ -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 });
|
||||
|
@ -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,
|
||||
}))
|
||||
|
@ -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 } }));
|
||||
}
|
||||
|
@ -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 })');
|
||||
|
@ -14,4 +14,4 @@ evaluate("\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
", { noScriptRval : true, compileAndGo : true });
|
||||
", { noScriptRval : true, compileAndGo : true, isRunOnce: true });
|
||||
|
@ -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 });
|
||||
|
@ -7,4 +7,4 @@ evaluate('\
|
||||
var fe="v";\
|
||||
for (i=0; String.fromCharCode(0x004E); i++)\
|
||||
fe += fe;\
|
||||
', { compileAndGo : true });
|
||||
', { compileAndGo : true, isRunOnce: true });
|
||||
|
@ -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 });
|
||||
|
@ -11,5 +11,5 @@ newGlobal();\
|
||||
''.addDebuggee(g1);\
|
||||
");
|
||||
function loadFile(lfVarx) {
|
||||
evaluate(lfVarx, { noScriptRval : true, compileAndGo : true });
|
||||
evaluate(lfVarx, { noScriptRval : true, compileAndGo : true, isRunOnce : true });
|
||||
}
|
||||
|
@ -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 });
|
||||
|
@ -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 });
|
||||
|
@ -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 });
|
||||
}
|
||||
|
@ -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});
|
||||
|
@ -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<GlobalObject>())
|
||||
options.setHasPollutedScope(true);
|
||||
|
||||
@ -4204,6 +4202,7 @@ Evaluate(JSContext* cx, HandleObject scope, const ReadOnlyCompileOptions& option
|
||||
|
||||
options.setCompileAndGo(scope->is<GlobalObject>());
|
||||
options.setHasPollutedScope(!scope->is<GlobalObject>());
|
||||
options.setIsRunOnce(true);
|
||||
SourceCompressionTask sct(cx);
|
||||
RootedScript script(cx, frontend::CompileScript(cx, &cx->tempLifoAlloc(),
|
||||
scope, NullPtr(), NullPtr(), options,
|
||||
|
@ -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("<string>", 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("<string>", 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"
|
||||
|
@ -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)
|
||||
|
@ -6150,6 +6150,7 @@ EvaluateInEnv(JSContext* cx, Handle<Env*> env, HandleValue thisv, AbstractFrameP
|
||||
CompileOptions options(cx);
|
||||
options.setCompileAndGo(true)
|
||||
.setHasPollutedScope(true)
|
||||
.setIsRunOnce(true)
|
||||
.setForEval(true)
|
||||
.setNoScriptRval(false)
|
||||
.setFileAndLine(filename, lineno)
|
||||
|
@ -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<JSScript*> script(cx);
|
||||
JS::Rooted<JSObject*> 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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user