mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 679939 part 6. Drop function-cloning uses of compileAndGo, since it no longer affects the bytecode. r=luke
This commit is contained in:
parent
0552083636
commit
b951e4c3f3
@ -1,28 +1,24 @@
|
||||
var g = newGlobal();
|
||||
|
||||
function cloneableFunction(body) {
|
||||
return evaluate("(function () { " + body + " })", {compileAndGo: false});
|
||||
}
|
||||
|
||||
g.f = cloneableFunction('return function(x) { return x };');
|
||||
g.f = new Function('return function(x) { return x };');
|
||||
assertEq(g.eval("clone(f)()(9)"), 9);
|
||||
|
||||
g.f = cloneableFunction('return function(x) { let(y = x+1) { return y } };');
|
||||
g.f = new Function('return function(x) { let(y = x+1) { return y } };');
|
||||
assertEq(g.eval("clone(f)()(9)"), 10);
|
||||
|
||||
g.f = cloneableFunction('return function(x) { let(y = x, z = 1) { return y+z } };');
|
||||
g.f = new Function('return function(x) { let(y = x, z = 1) { return y+z } };');
|
||||
assertEq(g.eval("clone(f)()(9)"), 10);
|
||||
|
||||
g.f = cloneableFunction('return function(x) { return x.search(/ponies/) };');
|
||||
g.f = new Function('return function(x) { return x.search(/ponies/) };');
|
||||
assertEq(g.eval("clone(f)()('123ponies')"), 3);
|
||||
|
||||
g.f = cloneableFunction('return function(x,y) { return x.search(/a/) + y.search(/b/) };');
|
||||
g.f = new Function('return function(x,y) { return x.search(/a/) + y.search(/b/) };');
|
||||
assertEq(g.eval("clone(f)()('12a','foo')"), 1);
|
||||
|
||||
g.f = cloneableFunction('return [function(x) x+2, function(y) let(z=y+1) z];');
|
||||
g.f = new Function('return [function(x) x+2, function(y) let(z=y+1) z];');
|
||||
assertEq(g.eval("let ([f,g] = clone(f)()) f(g(4))"), 7);
|
||||
|
||||
g.f = cloneableFunction('return function(x) { switch(x) { case "a": return "b"; case null: return "c" } };');
|
||||
g.f = new Function('return function(x) { switch(x) { case "a": return "b"; case null: return "c" } };');
|
||||
assertEq(g.eval("clone(f)()('a')"), "b");
|
||||
assertEq(g.eval("clone(f)()(null)"), "c");
|
||||
assertEq(g.eval("clone(f)()(3)"), undefined);
|
||||
|
@ -6,9 +6,7 @@ function assertWithMessage(got, expected, message) {
|
||||
assertEq(message + ": " + got, message + ": " + expected);
|
||||
}
|
||||
|
||||
// Create our test func via "evaluate" so it won't be compileAndGo and
|
||||
// we can clone it.
|
||||
evaluate(`function testFunc() {
|
||||
function testFunc() {
|
||||
assertWithMessage(checkNameLookup(), "local", "nameLookup");
|
||||
assertWithMessage(checkThisBinding(), "local", "thisBinding");
|
||||
|
||||
@ -20,7 +18,7 @@ evaluate(`function testFunc() {
|
||||
assertWithMessage(checkNameLookup(), "local", "nameLookup" + reason);
|
||||
assertWithMessage(checkThisBinding(), "local", "thisBinding" + reason);
|
||||
})();
|
||||
}`, { compileAndGo: false });
|
||||
}
|
||||
|
||||
var obj = {
|
||||
checkNameLookup: function() {
|
||||
|
@ -3250,7 +3250,7 @@ IsFunctionCloneable(HandleFunction fun, HandleObject dynamicScope)
|
||||
return false;
|
||||
}
|
||||
|
||||
return !fun->nonLazyScript()->compileAndGo() || dynamicScope->is<GlobalObject>();
|
||||
return true;
|
||||
}
|
||||
|
||||
static JSObject*
|
||||
|
@ -2564,14 +2564,6 @@ Clone(JSContext* cx, unsigned argc, jsval* vp)
|
||||
funobj = JS_GetFunctionObject(fun);
|
||||
}
|
||||
}
|
||||
if (funobj->compartment() != cx->compartment()) {
|
||||
JSFunction* fun = &funobj->as<JSFunction>();
|
||||
if (fun->hasScript() && fun->nonLazyScript()->compileAndGo()) {
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
|
||||
"function", "compile-and-go");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length() > 1) {
|
||||
if (!JS_ValueToObject(cx, args[1], &parent))
|
||||
|
Loading…
Reference in New Issue
Block a user