Commit 03df22f
committed
refactor: drop register_wrapper callback — JS owns the wrapper ref
After the pointer-keyed cache simplification, Swift's _<Class>_wrapperRefs
map existed only so release_wrapper could find the retained JS ref to
release. But JS's strong Map<pointer, wrapper> already keeps the wrapper
alive for as long as Swift needs it. Swift doesn't need its own strong
reference to the JS wrapper at all.
Removed:
- Wasm export bjs_<Class>_register_wrapper(pointer, jsRef)
- Swift per-class global _<Class>_wrapperRefs
- JS-side swift.memory.retain(obj) + register_wrapper callback on miss
- Swift-side _swift_js_release_ref() call in release_wrapper
Release thunk simplifies to:
guard _<Class>_identityTable.remove(pointer) != nil else { return }
Unmanaged<Class>.fromOpaque(pointer).release()
Invariants preserved: === identity, Swift heap-object lifetime (retain on
miss balanced by release in release_wrapper), wrapper survives GC while
reachable via the strong Map, array-element identity.
Performance impact (500k iters, median ms, swift mode only):
v2 v3 delta vs v2 vs pointer (1924)
passBothWaysRoundtrip 28 27 -4%
getPoolRepeated_100 34 34 parity
swiftCreatesObject 592 347 -41% -82%
churnObjects 438 332 -24% -58%
Miss path is now faster than the 'none' baseline (347 vs 507 ms) — the
wasm-callback savings on each fresh wrapper compound: one fewer cross-
boundary call per allocation. 165/165 tests green.1 parent cb04d8c commit 03df22f
8 files changed
Lines changed: 28 additions & 193 deletions
File tree
- Benchmarks/Sources/Generated
- Plugins/BridgeJS
- Sources
- BridgeJSCore
- BridgeJSLink
- Tests/BridgeJSToolTests/__Snapshots__
- BridgeJSCodegenTests
- BridgeJSLinkTests
- Tests
- BridgeJSIdentityTests/Generated
- BridgeJSSwiftIdentityTests/Generated
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1817 | 1817 | | |
1818 | 1818 | | |
1819 | 1819 | | |
1820 | | - | |
1821 | | - | |
1822 | 1820 | | |
1823 | 1821 | | |
1824 | 1822 | | |
| |||
1956 | 1954 | | |
1957 | 1955 | | |
1958 | 1956 | | |
1959 | | - | |
1960 | | - | |
1961 | | - | |
1962 | | - | |
1963 | | - | |
1964 | | - | |
1965 | | - | |
1966 | | - | |
1967 | | - | |
1968 | | - | |
1969 | 1957 | | |
1970 | 1958 | | |
1971 | 1959 | | |
1972 | 1960 | | |
1973 | | - | |
1974 | | - | |
| 1961 | + | |
1975 | 1962 | | |
1976 | | - | |
1977 | 1963 | | |
1978 | 1964 | | |
1979 | 1965 | | |
| |||
2019 | 2005 | | |
2020 | 2006 | | |
2021 | 2007 | | |
2022 | | - | |
2023 | | - | |
2024 | 2008 | | |
2025 | 2009 | | |
2026 | 2010 | | |
| |||
2107 | 2091 | | |
2108 | 2092 | | |
2109 | 2093 | | |
2110 | | - | |
2111 | | - | |
2112 | | - | |
2113 | | - | |
2114 | | - | |
2115 | | - | |
2116 | | - | |
2117 | | - | |
2118 | | - | |
2119 | | - | |
2120 | 2094 | | |
2121 | 2095 | | |
2122 | 2096 | | |
2123 | 2097 | | |
2124 | | - | |
2125 | | - | |
| 2098 | + | |
2126 | 2099 | | |
2127 | | - | |
2128 | 2100 | | |
2129 | 2101 | | |
2130 | 2102 | | |
| |||
2170 | 2142 | | |
2171 | 2143 | | |
2172 | 2144 | | |
2173 | | - | |
2174 | | - | |
2175 | 2145 | | |
2176 | 2146 | | |
2177 | 2147 | | |
| |||
2225 | 2195 | | |
2226 | 2196 | | |
2227 | 2197 | | |
2228 | | - | |
2229 | | - | |
2230 | | - | |
2231 | | - | |
2232 | | - | |
2233 | | - | |
2234 | | - | |
2235 | | - | |
2236 | | - | |
2237 | | - | |
2238 | 2198 | | |
2239 | 2199 | | |
2240 | 2200 | | |
2241 | 2201 | | |
2242 | | - | |
2243 | | - | |
| 2202 | + | |
2244 | 2203 | | |
2245 | | - | |
2246 | 2204 | | |
2247 | 2205 | | |
2248 | 2206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
711 | 711 | | |
712 | 712 | | |
713 | 713 | | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
721 | 718 | | |
722 | 719 | | |
723 | 720 | | |
724 | 721 | | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | 722 | | |
729 | 723 | | |
730 | 724 | | |
| |||
766 | 760 | | |
767 | 761 | | |
768 | 762 | | |
769 | | - | |
770 | | - | |
771 | | - | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
772 | 767 | | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | 768 | | |
787 | 769 | | |
788 | 770 | | |
| |||
791 | 773 | | |
792 | 774 | | |
793 | 775 | | |
794 | | - | |
795 | | - | |
| 776 | + | |
796 | 777 | | |
797 | | - | |
798 | 778 | | |
799 | 779 | | |
800 | 780 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2060 | 2060 | | |
2061 | 2061 | | |
2062 | 2062 | | |
2063 | | - | |
| 2063 | + | |
2064 | 2064 | | |
2065 | | - | |
2066 | | - | |
2067 | | - | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
2068 | 2071 | | |
2069 | 2072 | | |
2070 | 2073 | | |
| |||
2081 | 2084 | | |
2082 | 2085 | | |
2083 | 2086 | | |
2084 | | - | |
2085 | | - | |
2086 | | - | |
2087 | | - | |
2088 | 2087 | | |
2089 | 2088 | | |
2090 | 2089 | | |
| |||
2100 | 2099 | | |
2101 | 2100 | | |
2102 | 2101 | | |
| 2102 | + | |
| 2103 | + | |
2103 | 2104 | | |
2104 | | - | |
2105 | | - | |
2106 | 2105 | | |
2107 | 2106 | | |
2108 | 2107 | | |
| |||
Lines changed: 1 addition & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | 3 | | |
6 | 4 | | |
7 | 5 | | |
| |||
55 | 53 | | |
56 | 54 | | |
57 | 55 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | 56 | | |
69 | 57 | | |
70 | 58 | | |
71 | 59 | | |
72 | | - | |
73 | | - | |
| 60 | + | |
74 | 61 | | |
75 | | - | |
76 | 62 | | |
77 | 63 | | |
78 | 64 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | | - | |
320 | | - | |
321 | 319 | | |
322 | 320 | | |
323 | 321 | | |
| |||
Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/IdentityModeSwiftClass.js
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
285 | | - | |
286 | 284 | | |
287 | 285 | | |
288 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
467 | | - | |
468 | | - | |
469 | 467 | | |
470 | 468 | | |
471 | 469 | | |
| |||
552 | 550 | | |
553 | 551 | | |
554 | 552 | | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | 553 | | |
566 | 554 | | |
567 | 555 | | |
568 | 556 | | |
569 | | - | |
570 | | - | |
| 557 | + | |
571 | 558 | | |
572 | | - | |
573 | 559 | | |
574 | 560 | | |
575 | 561 | | |
| |||
615 | 601 | | |
616 | 602 | | |
617 | 603 | | |
618 | | - | |
619 | | - | |
620 | 604 | | |
621 | 605 | | |
622 | 606 | | |
| |||
670 | 654 | | |
671 | 655 | | |
672 | 656 | | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | 657 | | |
684 | 658 | | |
685 | 659 | | |
686 | 660 | | |
687 | | - | |
688 | | - | |
| 661 | + | |
689 | 662 | | |
690 | | - | |
691 | 663 | | |
692 | 664 | | |
693 | 665 | | |
| |||
733 | 705 | | |
734 | 706 | | |
735 | 707 | | |
736 | | - | |
737 | | - | |
738 | 708 | | |
739 | 709 | | |
740 | 710 | | |
| |||
788 | 758 | | |
789 | 759 | | |
790 | 760 | | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | 761 | | |
802 | 762 | | |
803 | 763 | | |
804 | 764 | | |
805 | | - | |
806 | | - | |
| 765 | + | |
807 | 766 | | |
808 | | - | |
809 | 767 | | |
810 | 768 | | |
811 | 769 | | |
| |||
0 commit comments