1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-28 21:02:07 +00:00

LibJS: Only update anonymous function names when necessary

Previously we would generate function names for anonymous functions
on every AssignmentExpression, even if we weren't assigning a function.

We were also setting names of anonymous functions in arrays, which is
apparently a SpiderMonkey specific behavior not supported by V8, JSC
or required by ECMA262. This patch removes that behavior.

This is a huge performance improvement on the CanvasCycle demo! :^)
This commit is contained in:
Andreas Kling 2021-03-21 17:14:20 +01:00
parent f89c479358
commit dc8817638e
2 changed files with 13 additions and 33 deletions

View file

@ -21,9 +21,9 @@ test("function assigned to variable", () => {
test("functions in array assigned to variable", () => {
const arr = [function () {}, function () {}, function () {}];
expect(arr[0].name).toBe("arr");
expect(arr[1].name).toBe("arr");
expect(arr[2].name).toBe("arr");
expect(arr[0].name).toBe("");
expect(arr[1].name).toBe("");
expect(arr[2].name).toBe("");
});
test("functions in objects", () => {
@ -48,10 +48,3 @@ test("names of native functions", () => {
expect((console.debug.name = "warn")).toBe("warn");
expect(console.debug.name).toBe("debug");
});
test("cyclic members should not cause infinite recursion (#3471)", () => {
let a = [() => 4];
a[1] = a;
a = a;
expect(a[0].name).toBe("a");
});