Commit 223e32b
Ralph
fix(runtime): #5844 — Proxy trap dispatch fixes across getOwnPropertyDescriptor, has, set, and setPrototypeOf
Fixes 12 of 33 test262 built-ins/Proxy failures, zero regressions
(verified against built-ins/Proxy, built-ins/Object, built-ins/Reflect,
language/expressions/in — 219/219/3132/101/15 pass respectively).
Root causes, all variations on "a Proxy is a small registered id, not a
real heap pointer, and several generic object-machinery code paths
either mis-treated it as one or never checked for it at all":
- js_reflect_get_own_property_descriptor: the missing-trap fallback read
the target's descriptor via the raw ObjectHeader path even when the
target was itself a Proxy; now recurses through the Reflect entry
point so a chain of trap-less proxies forwards correctly.
- ordinary_has_property (the `in` operator's prototype-chain walk) and
its array-fast-path counterpart didn't recognize a Proxy sitting in
the recorded `[[Prototype]]` chain, silently returning false (or
reading garbage) instead of dispatching the proxy's `has` trap.
- ordinary_set_with_receiver's prototype-chain walk had the same gap on
the write side, and `js_proxy_set`/`Reflect.set` didn't thread a
distinct `receiver` through to the trap when a Proxy was reached via
a prototype hop rather than as the direct assignment target.
- Object.create(proto) and Object.setPrototypeOf(obj, proto) rejected a
Proxy `proto` argument outright (their "is this an object" checks
don't recognize the small registered id), and Object.create had no
path to record a Proxy prototype at all — it can't be modeled via the
synthetic-class-id machinery used for real prototype objects, so route
it through the same static-prototype side table setPrototypeOf uses.
- Object.setPrototypeOf's cycle-detection walk called
`[[GetPrototypeOf]]` unconditionally while probing the candidate
prototype's chain, including on a Proxy — invoking its trap as an
unrelated side effect of cycle-safety bookkeeping (OrdinarySetPrototypeOf
step 7.b.ii.1 says to stop the walk there instead).
Also fixed, found while debugging the above with a fresh (Proxy-free)
repro: the cycle-detection loop's Floyd's tortoise-and-hare walk only
guarded `tortoise` against an already-null position before advancing;
`hare` (which steps twice per iteration) had no equivalent guard, so a
2-hop-to-null prototype chain re-advanced an already-null `hare` and
threw "Cannot convert undefined or null to object" on a plain, entirely
ordinary `Object.setPrototypeOf({}, {foo: 1})`.
Refs #5844.1 parent 4def199 commit 223e32b
6 files changed
Lines changed: 158 additions & 42 deletions
File tree
- crates/perry-runtime/src
- object
- field_get_set
- object_ops
- proxy
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1368 | 1368 | | |
1369 | 1369 | | |
1370 | 1370 | | |
| 1371 | + | |
1371 | 1372 | | |
1372 | 1373 | | |
1373 | 1374 | | |
| |||
Lines changed: 59 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
298 | 310 | | |
299 | 311 | | |
300 | 312 | | |
| |||
329 | 341 | | |
330 | 342 | | |
331 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
332 | 362 | | |
333 | 363 | | |
334 | 364 | | |
| |||
353 | 383 | | |
354 | 384 | | |
355 | 385 | | |
356 | | - | |
357 | | - | |
358 | | - | |
| 386 | + | |
| 387 | + | |
359 | 388 | | |
360 | 389 | | |
361 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
362 | 401 | | |
363 | 402 | | |
364 | 403 | | |
| |||
497 | 536 | | |
498 | 537 | | |
499 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
500 | 556 | | |
501 | 557 | | |
502 | 558 | | |
| |||
Lines changed: 25 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
| |||
208 | 209 | | |
209 | 210 | | |
210 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
211 | 223 | | |
212 | 224 | | |
213 | 225 | | |
| |||
227 | 239 | | |
228 | 240 | | |
229 | 241 | | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
235 | 252 | | |
236 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
237 | 256 | | |
238 | 257 | | |
239 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
54 | 75 | | |
55 | 76 | | |
56 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
711 | 711 | | |
712 | 712 | | |
713 | 713 | | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
714 | 729 | | |
715 | 730 | | |
716 | 731 | | |
| |||
740 | 755 | | |
741 | 756 | | |
742 | 757 | | |
| 758 | + | |
743 | 759 | | |
744 | 760 | | |
745 | 761 | | |
746 | 762 | | |
747 | 763 | | |
748 | 764 | | |
749 | 765 | | |
750 | | - | |
| 766 | + | |
751 | 767 | | |
752 | 768 | | |
753 | 769 | | |
| |||
765 | 781 | | |
766 | 782 | | |
767 | 783 | | |
768 | | - | |
| 784 | + | |
769 | 785 | | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
784 | 799 | | |
785 | 800 | | |
786 | 801 | | |
| |||
799 | 814 | | |
800 | 815 | | |
801 | 816 | | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | | - | |
813 | | - | |
814 | | - | |
815 | | - | |
816 | 817 | | |
817 | 818 | | |
818 | 819 | | |
| |||
1331 | 1332 | | |
1332 | 1333 | | |
1333 | 1334 | | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
1334 | 1347 | | |
1335 | 1348 | | |
1336 | 1349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
351 | 357 | | |
352 | 358 | | |
353 | 359 | | |
| |||
0 commit comments