Commit f67f4fa
committed
[wasm-split] Split globals' ref.func dependencies
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 moves those functions referred to by `ref.func`s to the secondary
module, as long as they don't have uses anywhere else.
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 #8442 (~25s range in acx_gallery).
#8441, #8442, and this PR combined reduce the size of the primary
module by 46.6%.
---
`wasm-objdump -h` result:
- Before (#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=0x00289e65 end=0x004977fe (size=0x0020d999) count: 35861
Start start=0x00497800 end=0x00497802 (size=0x00000002) start: 828
Elem start=0x00497806 end=0x00501649 (size=0x00069e43) count: 12303
DataCount start=0x0050164b end=0x0050164c (size=0x00000001) count: 1
Code start=0x00501651 end=0x00730f22 (size=0x0022f8d1) count: 62890
Data start=0x00730f26 end=0x00750ab3 (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=0x002e703f (size=0x0005f4c6) count: 25972
Start start=0x002e7041 end=0x002e7043 (size=0x00000002) start: 828
Elem start=0x002e7047 end=0x00349aa7 (size=0x00062a60) count: 12303
DataCount start=0x00349aa9 end=0x00349aaa (size=0x00000001) count: 1
Code start=0x00349aaf end=0x00550a4e (size=0x00206f9f) count: 53001
Data start=0x00550a52 end=0x005705df (size=0x0001fb8d) count: 1
```
We can see while the size of the function and the code sections have
decreased, the big gains come from the decrease of the export section,
which can contain long function names.1 parent 3d7d1f4 commit f67f4fa
File tree
3 files changed
+56
-24
lines changed- src/ir
- test/lit/wasm-split
3 files changed
+56
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
630 | 631 | | |
631 | 632 | | |
632 | 633 | | |
633 | | - | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
634 | 653 | | |
635 | 654 | | |
636 | 655 | | |
| |||
1157 | 1176 | | |
1158 | 1177 | | |
1159 | 1178 | | |
1160 | | - | |
| 1179 | + | |
1161 | 1180 | | |
1162 | | - | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
1163 | 1204 | | |
1164 | 1205 | | |
1165 | | - | |
1166 | | - | |
1167 | | - | |
1168 | | - | |
1169 | | - | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
1170 | 1212 | | |
1171 | 1213 | | |
1172 | | - | |
| 1214 | + | |
1173 | 1215 | | |
1174 | 1216 | | |
1175 | 1217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 15 | + | |
26 | 16 | | |
27 | 17 | | |
28 | 18 | | |
| |||
| 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