Skip to content

Pool Proxy trap argument arrays#2675

Merged
lahma merged 1 commit into
sebastienros:mainfrom
lahma:proxy-pooled-trap-args
Jul 13, 2026
Merged

Pool Proxy trap argument arrays#2675
lahma merged 1 commit into
sebastienros:mainfrom
lahma:proxy-pooled-trap-args

Conversation

@lahma

@lahma lahma commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #2674. CallTrap now rents the trap argument array from JsValueArrayPool and returns it after the call — the same rent/call/return contract as the interpreter call sites (JintCallExpression), with JsArguments.Materialize protecting arrays captured by the callee.

The set trap takes four arguments (target, key, value, receiver), so the pool gains a size-4 bucket. Bonus: the two existing RentArray(4)/ReturnArray sites in IntrinsicTypedArrayPrototype (sort comparers etc.) start actually pooling — until now size-4 rents always allocated and returns were silent no-ops.

ProxyBenchmark, control vs change on the same base commit (time flat within run noise; allocation is the win):

Lane Allocated
TrapGet 4,689 KB → 1.3 KB
TrapHas 3,908 KB → 1.3 KB
TrapSet 8,275 KB → 2,806 KB (−66%)
ApplyTrap 25,143 KB → 20,455 KB (−19%)
ConstructTrap 3,048 KB → 2,579 KB (−15%)
Forward lanes unchanged (untouched by this PR)

Verification: full test262 suite green (99,429 passed / 0 failed), full Jint.Tests + PublicInterface green, ProxyTests 43/43.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EsHuKuE4UihKZp5HYapDHE

CallTrap now rents the trap argument array from the engine's
JsValueArrayPool and returns it after the call, following the
interpreter call-site pattern (no finally: an exception lets the array
fall to the GC, and JsArguments.Materialize protects arrays captured by
the callee).

The set trap needs four arguments (target, key, value, receiver), so
the pool gains a size-4 bucket. Two existing size-4 rent/return sites
in IntrinsicTypedArrayPrototype start benefiting as well - until now
RentArray(4) always allocated and ReturnArray(4) was a silent no-op.

ProxyBenchmark on the same base commit (control vs this change): time
flat within run noise, allocations on trapped operations drop to the
JS-call floor:

| Lane          | Allocated                    |
|-------------- |-----------------------------:|
| TrapGet       | 4,689 KB -> 1.3 KB           |
| TrapHas       | 3,908 KB -> 1.3 KB           |
| TrapSet       | 8,275 KB -> 2,806 KB (-66%)  |
| ApplyTrap     | 25,143 KB -> 20,455 KB (-19%)|
| ConstructTrap | 3,048 KB -> 2,579 KB (-15%)  |
| OwnKeysTrap   | -313 KB                      |

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EsHuKuE4UihKZp5HYapDHE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant