Commit fef5580
committed
BridgeJS: Support non-ConvertibleToJSValue async exported return types
Async exported functions previously required a return type conforming to
ConvertibleToJSValue, because the thunk wrapped the body in JSPromise.async
and lowered the result via .jsValue. Types like @js structs and enums have no
.jsValue, so async functions could not return them.
Settle every async exported return through a new _bjs_makePromise intrinsic
instead: the thunk creates a JS Promise synchronously, then resolves or rejects
it from a Task using generated Promise_resolve_<mangled> / Promise_reject thunks
that lower the value through the regular imported-parameter ABI. This replaces
the JSPromise.async / .jsValue path entirely, unifying async return codegen on
a single path.
Covers all bridged types and their compositions: @js struct, raw-value and case
enums, their Optionals, Arrays, and Dictionaries, alongside the existing
ConvertibleToJSValue types and Void. Stack-using parameters are hoisted and
lifted in the thunk before the deferred Task runs, so the shared bridge stack is
drained synchronously. Async returns of types that cannot be lowered through the
imported-parameter ABI (associated-value enums, protocols, namespace enums) are
diagnosed rather than miscompiled.
The resolve/reject settlers are stashed on the Promise under a Symbol to avoid
clashing with its fields.1 parent be3b300 commit fef5580
66 files changed
Lines changed: 3888 additions & 167 deletions
File tree
- Plugins
- BridgeJS
- Sources
- BridgeJSCore
- BridgeJSLink
- BridgeJSSkeleton
- Tests/BridgeJSToolTests
- Inputs/MacroSwift
- __Snapshots__
- BridgeJSCodegenTests
- BridgeJSLinkTests
- PackageToJS/Templates
- Sources/JavaScriptKit
- Tests/BridgeJSRuntimeTests
- Generated
- JavaScript
- JavaScript
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 123 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
93 | 103 | | |
94 | 104 | | |
95 | 105 | | |
96 | 106 | | |
97 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
98 | 164 | | |
99 | 165 | | |
100 | 166 | | |
| |||
104 | 170 | | |
105 | 171 | | |
106 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
107 | 179 | | |
108 | 180 | | |
109 | 181 | | |
| |||
200 | 272 | | |
201 | 273 | | |
202 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
203 | 278 | | |
204 | 279 | | |
205 | 280 | | |
| |||
244 | 319 | | |
245 | 320 | | |
246 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
247 | 338 | | |
248 | 339 | | |
249 | 340 | | |
| |||
293 | 384 | | |
294 | 385 | | |
295 | 386 | | |
296 | | - | |
297 | | - | |
| 387 | + | |
298 | 388 | | |
299 | 389 | | |
300 | 390 | | |
| |||
328 | 418 | | |
329 | 419 | | |
330 | 420 | | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
331 | 430 | | |
332 | 431 | | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
345 | 435 | | |
346 | | - | |
| 436 | + | |
| 437 | + | |
347 | 438 | | |
348 | | - | |
349 | | - | |
| 439 | + | |
350 | 440 | | |
351 | 441 | | |
352 | 442 | | |
| |||
506 | 596 | | |
507 | 597 | | |
508 | 598 | | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
509 | 613 | | |
510 | 614 | | |
| 615 | + | |
511 | 616 | | |
512 | 617 | | |
513 | 618 | | |
| |||
551 | 656 | | |
552 | 657 | | |
553 | 658 | | |
| 659 | + | |
554 | 660 | | |
555 | 661 | | |
556 | 662 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 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 | + | |
| 392 | + | |
359 | 393 | | |
360 | 394 | | |
361 | 395 | | |
| |||
526 | 560 | | |
527 | 561 | | |
528 | 562 | | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
529 | 596 | | |
530 | 597 | | |
531 | 598 | | |
| |||
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1027 | 1027 | | |
1028 | 1028 | | |
1029 | 1029 | | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
1030 | 1054 | | |
1031 | 1055 | | |
1032 | 1056 | | |
| |||
1584 | 1608 | | |
1585 | 1609 | | |
1586 | 1610 | | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
1587 | 1630 | | |
1588 | 1631 | | |
1589 | 1632 | | |
| |||
0 commit comments