Compare commits

...
Author SHA1 Message Date
N0zoM1z0 b9e4b5fa4a revert: restore withdrawn receiver growth branch
Restore the contributor tree after the prepared maintenance follow-up was inadvertently pushed following PR closure. Keep all original and maintenance commits in history; no force push or main change.
2026-10-10 18:15:03 +08:00
N0zoM1z0 7ca5f2d8a0 test(javascript): retain semantics in receiver growth measurements 2026-10-10 18:10:06 +08:00
N0zoM1z0 555877b438 chore: integrate public receiver regression coverage 2026-10-10 18:10:05 +08:00
Kaoru0822andClaude Opus 5.5 afcf3afea1 test(javascript): check #1495 growth rate instead of wall time
The #1495 regression test required 2,000 receiver calls to finish within
2 s. CI shards run with v8 coverage on slower runners: the test took 1.9 s
on #1517's run and 3.2-3.6 s on main afterwards, failing every PR.

It now compares the fastest of two runs at 1,600 and 400 calls. That
ratio is about 5-6x for the fix, with or without coverage, and about
13-14x for the quadratic code before #1517, so the bound of 10 holds on
any runner while still catching the regression.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 09:44:54 +00:00
2 changed files with 28 additions and 32 deletions
@@ -628,22 +628,35 @@ describe("results of methods on an escaped receiver", () => {
});
});
it("keeps a shared result uncertain across a wide escaped receiver (#1495)", () => {
const count = 2000;
const methods = Array.from(
{ length: count },
(_, index) => `m${index}() { return shared; },`,
).join(" ");
const calls = Array.from(
{ length: count },
(_, index) => `box.m${index}().p${index} = ${index};`,
).join(" ");
const value = resultValue(
`const shared = { token: "TOKEN" }; const box = { ${methods} }; ${calls} return [shared.token];`,
);
expect(value).toMatchObject({
it("expands a receiver's methods once rather than once per call (#1495)", () => {
const receiverCalls = (count: number) => {
const methods = Array.from(
{ length: count },
(_, index) => `m${index}() { return shared; },`,
).join(" ");
const calls = Array.from(
{ length: count },
(_, index) => `box.m${index}().p${index} = ${index};`,
).join(" ");
return `const shared = { token: "TOKEN" }; const box = { ${methods} }; ${calls} return [shared.token];`;
};
const fastest = (body: string) =>
Math.min(
...[0, 1].map(() => {
const start = performance.now();
resultValue(body);
return performance.now() - start;
}),
);
resultValue(receiverCalls(100));
// Compare growth rather than wall time, which depends on the runner and on
// coverage instrumentation. Four times the calls costs about 5-6x here;
// re-expanding every method per call cost about 13-14x.
const ratio = fastest(receiverCalls(1600)) / fastest(receiverCalls(400));
expect(ratio).toBeLessThan(10);
expect(resultValue(receiverCalls(400))).toMatchObject({
status: "array",
items: [{ value: { status: "unknown" } }],
});
}, 30000);
}, 60000);
});
@@ -47,10 +47,6 @@ const writes = {
constructor:
"function Box() { return shared; } const t = new Box(); t.x = 2;",
callback: "const get = () => shared; [0].forEach(() => { get().x = 2; });",
wideMethods: `const box = { ${Array.from(
{ length: 64 },
(_, index) => `m${index}() { return shared; }`,
).join(", ")} }; box.m0().x = 2; box.m63().other = 3;`,
};
const source = [
...Object.entries(writes).map(
@@ -65,8 +61,6 @@ const source = [
"export function unused(){ const shared = {x: 1}; const get = () => shared; get(); return shared.x; }",
"export function nestedCallable(){ const shared = {x: 1}; const get = () => { const inner = () => shared; return {x: 0}; }; get().x = 2; return shared.x; }",
"export function unrelated(){ const shared = {x: 1}; const other = {x: 9}; const get = () => shared; get().x = 2; return other.x; }",
"export function receiverDistinctScopes(){ const shared = {x: 1}; const box = {outer(){ return shared; }, inner(){ const shared = {x: 9}; return shared; }, noop(){}}; box.noop(); return {outer: shared.x, inner: box.inner().x}; }",
"export function receiverDistinctPaths(){ const parent = {left: {x: 1}, right: {x: 9}, keep: 7}; const box = {left(){ return parent.left; }, right(){ return parent.right; }, noop(){}}; box.noop(); return {left: parent.left.x, right: parent.right.x, keep: parent.keep}; }",
].join("\n");
const assertReturns = (fields: JavaScriptReturnFields): void => {
@@ -97,17 +91,6 @@ const assertReturns = (fields: JavaScriptReturnFields): void => {
expect(fields("unrelated")).toContainEqual(
expect.objectContaining({ path: "", state: "literal", value: 9 }),
);
for (const path of ["/outer", "/inner"])
expect(fields("receiverDistinctScopes")).toContainEqual(
expect.objectContaining({ path, state: "unknown" }),
);
for (const path of ["/left", "/right"])
expect(fields("receiverDistinctPaths")).toContainEqual(
expect.objectContaining({ path, state: "unknown" }),
);
expect(fields("receiverDistinctPaths")).toContainEqual(
expect.objectContaining({ path: "/keep", state: "literal", value: 7 }),
);
};
cliTest(