Commit 4ee183b
authored
[wasm-split] Remove unnecessary trampolines for ref.func initializers (WebAssembly#8443)
When a global is exclusively used by a secondary module and thus moved
to that module, and its initializer has a `(ref.func $func)`, we used to
create a trampoline and export it from the primary module in all cases,
even in the case that the function is in the same secondary module. This
now only avoids creating a trampoline when the function is already in
the same secondary module.
To do this, we now skip scanning global initializers in
`indirectReferencesToSecondaryFunctions`, and selectively create
trampolines only when needed in `shareImportableItems`.
The running time of `wasm-split` hasn't really changed with this PR,
compared to the previous PR WebAssembly#8442 (~25s range in acx_gallery).
WebAssembly#8441, WebAssembly#8442, and this PR combined reduce the size of the primary module
of acx_gallery by 45.4%.
---
`wasm-objdump -h` result:
- Before (WebAssembly#8442)
```
Type start=0x0000000c end=0x00035d44 (size=0x00035d38) count: 11185
Import start=0x00035d48 end=0x00132efc (size=0x000fd1b4) count: 32642
Function start=0x00132f00 end=0x00145dac (size=0x00012eac) count: 62890
Table start=0x00145daf end=0x001498ea (size=0x00003b3b) count: 2921
Tag start=0x001498ec end=0x001498f0 (size=0x00000004) count: 1
Global start=0x001498f4 end=0x00289e60 (size=0x0014056c) count: 47728
Export start=0x00289e64 end=0x002e99c1 (size=0x0005fb5d) count: 35861
Start start=0x002e99c3 end=0x002e99c5 (size=0x00000002) start: 828
Elem start=0x002e99c9 end=0x0035380c (size=0x00069e43) count: 12303
DataCount start=0x0035380e end=0x0035380f (size=0x00000001) count: 1
Code start=0x00353814 end=0x005830e5 (size=0x0022f8d1) count: 62890
Data start=0x005830e9 end=0x005a2c76 (size=0x0001fb8d) count: 1
```
- After (This PR)
```
Type start=0x0000000c end=0x00035d38 (size=0x00035d2c) count: 11185
Import start=0x00035d3c end=0x00132ef0 (size=0x000fd1b4) count: 32642
Function start=0x00132ef4 end=0x001436cc (size=0x000107d8) count: 53001
Table start=0x001436cf end=0x0014720a (size=0x00003b3b) count: 2921
Tag start=0x0014720c end=0x00147210 (size=0x00000004) count: 1
Global start=0x00147214 end=0x00287b75 (size=0x00140961) count: 47728
Export start=0x00287b79 end=0x002d41ce (size=0x0004c655) count: 25972
Start start=0x002d41d0 end=0x002d41d2 (size=0x00000002) start: 828
Elem start=0x002d41d6 end=0x00336c36 (size=0x00062a60) count: 12303
DataCount start=0x00336c38 end=0x00336c39 (size=0x00000001) count: 1
Code start=0x00336c3e end=0x0053dbdd (size=0x00206f9f) count: 53001
Data start=0x0053dbe1 end=0x0055d76e (size=0x0001fb8d) count: 1
```1 parent 0e2ee37 commit 4ee183b
File tree
3 files changed
+84
-35
lines changed- src/ir
- test/lit/wasm-split
3 files changed
+84
-35
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
631 | 632 | | |
632 | 633 | | |
633 | 634 | | |
634 | | - | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
635 | 654 | | |
636 | 655 | | |
637 | 656 | | |
| |||
1055 | 1074 | | |
1056 | 1075 | | |
1057 | 1076 | | |
1058 | | - | |
1059 | | - | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
1060 | 1081 | | |
1061 | | - | |
1062 | | - | |
| 1082 | + | |
1063 | 1083 | | |
1064 | 1084 | | |
1065 | 1085 | | |
1066 | 1086 | | |
1067 | 1087 | | |
1068 | | - | |
1069 | | - | |
1070 | | - | |
1071 | | - | |
| 1088 | + | |
| 1089 | + | |
1072 | 1090 | | |
1073 | 1091 | | |
1074 | 1092 | | |
| |||
1168 | 1186 | | |
1169 | 1187 | | |
1170 | 1188 | | |
1171 | | - | |
| 1189 | + | |
1172 | 1190 | | |
1173 | | - | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
1174 | 1217 | | |
1175 | 1218 | | |
1176 | | - | |
1177 | | - | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
1181 | 1225 | | |
1182 | 1226 | | |
1183 | | - | |
| 1227 | + | |
1184 | 1228 | | |
1185 | 1229 | | |
1186 | 1230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
| 6 | + | |
| 7 | + | |
9 | 8 | | |
10 | 9 | | |
11 | | - | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
| 13 | + | |
16 | 14 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 15 | + | |
| 16 | + | |
22 | 17 | | |
| 18 | + | |
23 | 19 | | |
24 | | - | |
25 | | - | |
26 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
37 | 42 | | |
38 | 43 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
0 commit comments