mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix another bug with getChildScripts: the relevant bit on JSScript was being set after the newScript hook was called. Set it beforehand instead.
This commit is contained in:
parent
5b32744353
commit
d8af4ff3e4
17
js/src/jit-test/tests/debug/Script-getChildScripts-04.js
Normal file
17
js/src/jit-test/tests/debug/Script-getChildScripts-04.js
Normal file
@ -0,0 +1,17 @@
|
||||
// script.getChildScripts() works correctly during the newScript hook.
|
||||
// (A bug had it including the script for the calling function.)
|
||||
|
||||
var g = newGlobal('new-compartment');
|
||||
g.eval("function h(a) { eval(a); }");
|
||||
|
||||
var dbg = Debugger(g);
|
||||
var arr, kscript;
|
||||
dbg.hooks = {
|
||||
newScript: function (script) { arr = script.getChildScripts(); },
|
||||
debuggerHandler: function (frame) { kscript = frame.callee.script; }
|
||||
};
|
||||
|
||||
g.h("function k(a) { debugger; return a + 1; } k(-1);");
|
||||
assertEq(kscript instanceof Debugger.Script, true);
|
||||
assertEq(arr.length, 1);
|
||||
assertEq(arr[0], kscript);
|
@ -6,6 +6,8 @@ var seen = WeakMap();
|
||||
var hits = 0;
|
||||
dbg.hooks = {
|
||||
newScript: function (s) {
|
||||
// Exceptions thrown from newScript are swept under the rug, but they
|
||||
// will at least prevent hits from being the expected number.
|
||||
assertEq(s instanceof Debugger.Script, true);
|
||||
assertEq(!seen.has(s), true);
|
||||
seen.set(s, true);
|
||||
@ -13,6 +15,8 @@ dbg.hooks = {
|
||||
}
|
||||
};
|
||||
|
||||
dbg.uncaughtExceptionHook = function () { hits = -999; };
|
||||
|
||||
// eval code
|
||||
hits = 0;
|
||||
assertEq(g.eval("2 + 2"), 4);
|
||||
|
@ -13,6 +13,8 @@ dbg.hooks = {
|
||||
}
|
||||
};
|
||||
|
||||
dbg.uncaughtExceptionHook = function () { hits = -999; };
|
||||
|
||||
function test(f) {
|
||||
hits = 0;
|
||||
f();
|
||||
|
@ -958,13 +958,10 @@ Compiler::compileScript(JSContext *cx, JSObject *scopeChain, StackFrame *callerF
|
||||
tokenStream.setStrictMode();
|
||||
}
|
||||
|
||||
/*
|
||||
* If funbox is non-null after we create the new script, callerFrame->fun
|
||||
* was saved in the 0th object table entry.
|
||||
*/
|
||||
JSObjectBox *funbox;
|
||||
funbox = NULL;
|
||||
|
||||
#ifdef DEBUG
|
||||
bool savedCallerFun;
|
||||
savedCallerFun = false;
|
||||
#endif
|
||||
if (tcflags & TCF_COMPILE_N_GO) {
|
||||
if (source) {
|
||||
/*
|
||||
@ -983,12 +980,15 @@ Compiler::compileScript(JSContext *cx, JSObject *scopeChain, StackFrame *callerF
|
||||
* function captured in case it refers to an upvar, and someone
|
||||
* wishes to decompile it while it's running.
|
||||
*/
|
||||
funbox = parser.newObjectBox(FUN_OBJECT(callerFrame->fun()));
|
||||
JSObjectBox *funbox = parser.newObjectBox(FUN_OBJECT(callerFrame->fun()));
|
||||
if (!funbox)
|
||||
goto out;
|
||||
funbox->emitLink = cg.objectList.lastbox;
|
||||
cg.objectList.lastbox = funbox;
|
||||
cg.objectList.length++;
|
||||
#ifdef DEBUG
|
||||
savedCallerFun = true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1111,8 +1111,7 @@ Compiler::compileScript(JSContext *cx, JSObject *scopeChain, StackFrame *callerF
|
||||
if (!script)
|
||||
goto out;
|
||||
|
||||
if (funbox)
|
||||
script->savedCallerFun = true;
|
||||
JS_ASSERT(script->savedCallerFun == savedCallerFun);
|
||||
|
||||
{
|
||||
AutoShapeRooter shapeRoot(cx, script->bindings.lastShape());
|
||||
|
@ -1291,8 +1291,12 @@ JSScript::NewScriptFromCG(JSContext *cx, JSCodeGenerator *cg)
|
||||
script->hasSharps = true;
|
||||
if (cg->flags & TCF_STRICT_MODE_CODE)
|
||||
script->strictModeCode = true;
|
||||
if (cg->flags & TCF_COMPILE_N_GO)
|
||||
if (cg->flags & TCF_COMPILE_N_GO) {
|
||||
script->compileAndGo = true;
|
||||
const StackFrame *fp = cg->parser->callerFrame;
|
||||
if (fp && fp->isFunctionFrame())
|
||||
script->savedCallerFun = true;
|
||||
}
|
||||
if (cg->callsEval())
|
||||
script->usesEval = true;
|
||||
if (cg->flags & TCF_FUN_USES_ARGUMENTS)
|
||||
|
Loading…
Reference in New Issue
Block a user