Repository navigation
Commit 76ebdd1
`await Promise.all([...])` silently evaporated — no output, exit code 0 — when
the input promises were settled through executor-captured resolvers invoked from
a loop:
const ps = Array.from({length: 100}, () => new Promise(r => resolvers.push(r)));
const all = Promise.all(ps);
for (let i = 0; i < 100; i++) resolvers[i](i);
const r = await all; // never resumes
The promise machinery was not at fault. `Promise.all` is not even required to
reproduce: the defect is that `arr[i](x)` — a call whose callee is a computed
member with a *numeric* key — was a silent no-op inside an `async` function.
Codegen's `try_lower_index_get_call` bails out to the array element-call lowering
only when `is_numeric_expr` proves the index numeric; otherwise the call goes to
`js_native_call_method_value` (the #321 dynamic-key `this`-binding path). Inside
an async function it can never prove it: the async-to-generator transform turns
every body local into a boxed mutable capture typed `Any`, so the loop counter
reads back untyped. `js_native_call_method_value` then ran the key through
`js_to_property_key`, which canonicalizes the index to the string "3", and handed
that to the dispatch tower — which resolves by METHOD NAME (own-field scan +
prototype/class-id chain). An Array's ELEMENT storage is none of those, so the
lookup missed, `undefined` came back, and the call vanished. The loop resolved
nothing; `await all` waited on a promise nobody would ever settle; the event loop
drained and the process exited 0.
The 8-vs-9 threshold in the report is the loop unroller: at a low trip count the
indices const-fold to literals, which codegen *can* prove numeric.
Fix: per spec `obj[k](...)` is Get(obj, k) then Call — the property read wins.
For a numeric key, resolve the element/own value through
`js_object_get_index_polymorphic` first and invoke it when the key names
something. Fall through to the name tower when it names nothing, so a
numerically-named vtable method (`class C { 3() {} }`) keeps its dispatch, and
`this` stays bound either way.
Fixture asserts exit code as well as stdout — the failure mode is a silent exit 0.
Co-authored-by: Ralph Küpper <ralph@skelpo.com>
1 parent 108bdf2 commit 76ebdd1
2 files changed
Lines changed: 152 additions & 0 deletions
File tree
- crates/perry-runtime/src/object
- test-files
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
229 | 246 | | |
230 | 247 | | |
231 | 248 | | |
| |||
339 | 356 | | |
340 | 357 | | |
341 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
342 | 392 | | |
343 | 393 | | |
344 | 394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
0 commit comments