Commit 3106ca5
committed
Allow the createWasm function to use async/await where possible
The advantage if using `await` in the cases where we can is that it
avoids the generation or wrapper function for each export.
So instead of
```
var wasmExport = createWasm(); // returns empty object
...
var malloc = ((..) => (malloc = wasmExports['malloc'])()
```
We can just generate:
```
var wasmExport = createWasm(); // returns empty object
...
var malloc = wasmExports['malloc'];
```
This only currently works in MODULARIZE mode where the code is running
inside a factory function. Otherwise it would end up using
top-level-await.
One wrinkle here is that this is not currently supported when closure is
enabled because we run closure only on the contents of the factory
function so closure ends up seeing this as a top level await when its
not.1 parent 399a077 commit 3106ca5
File tree
5 files changed
+42
-51
lines changed- src
- test
- tools
5 files changed
+42
-51
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1036 | 1036 | | |
1037 | 1037 | | |
1038 | 1038 | | |
1039 | | - | |
| 1039 | + | |
1040 | 1040 | | |
1041 | 1041 | | |
1042 | 1042 | | |
1043 | | - | |
| 1043 | + | |
1044 | 1044 | | |
1045 | 1045 | | |
1046 | 1046 | | |
| |||
1076 | 1076 | | |
1077 | 1077 | | |
1078 | 1078 | | |
1079 | | - | |
1080 | | - | |
| 1079 | + | |
1081 | 1080 | | |
1082 | 1081 | | |
1083 | 1082 | | |
| |||
1095 | 1094 | | |
1096 | 1095 | | |
1097 | 1096 | | |
1098 | | - | |
| 1097 | + | |
1099 | 1098 | | |
1100 | 1099 | | |
1101 | 1100 | | |
1102 | | - | |
| 1101 | + | |
1103 | 1102 | | |
1104 | 1103 | | |
1105 | 1104 | | |
1106 | 1105 | | |
1107 | | - | |
| 1106 | + | |
1108 | 1107 | | |
1109 | 1108 | | |
1110 | 1109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4795 | 4795 | | |
4796 | 4796 | | |
4797 | 4797 | | |
4798 | | - | |
4799 | | - | |
4800 | | - | |
4801 | | - | |
4802 | | - | |
4803 | | - | |
4804 | | - | |
4805 | | - | |
4806 | | - | |
4807 | | - | |
4808 | | - | |
4809 | | - | |
4810 | | - | |
4811 | | - | |
4812 | | - | |
4813 | | - | |
4814 | | - | |
4815 | | - | |
4816 | | - | |
4817 | | - | |
4818 | | - | |
4819 | | - | |
| 4798 | + | |
| 4799 | + | |
| 4800 | + | |
| 4801 | + | |
| 4802 | + | |
| 4803 | + | |
| 4804 | + | |
| 4805 | + | |
| 4806 | + | |
| 4807 | + | |
| 4808 | + | |
| 4809 | + | |
| 4810 | + | |
4820 | 4811 | | |
4821 | 4812 | | |
4822 | 4813 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
893 | 893 | | |
894 | 894 | | |
895 | 895 | | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
896 | 904 | | |
897 | 905 | | |
898 | 906 | | |
| |||
932 | 940 | | |
933 | 941 | | |
934 | 942 | | |
935 | | - | |
| 943 | + | |
936 | 944 | | |
937 | 945 | | |
938 | 946 | | |
| |||
998 | 1006 | | |
999 | 1007 | | |
1000 | 1008 | | |
1001 | | - | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
1002 | 1014 | | |
1003 | 1015 | | |
1004 | 1016 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2379 | 2379 | | |
2380 | 2380 | | |
2381 | 2381 | | |
2382 | | - | |
2383 | | - | |
2384 | | - | |
2385 | | - | |
2386 | | - | |
2387 | | - | |
2388 | | - | |
2389 | | - | |
2390 | | - | |
2391 | | - | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
2392 | 2386 | | |
2393 | 2387 | | |
2394 | | - | |
| 2388 | + | |
2395 | 2389 | | |
2396 | 2390 | | |
2397 | 2391 | | |
2398 | 2392 | | |
2399 | | - | |
| 2393 | + | |
2400 | 2394 | | |
2401 | | - | |
2402 | | - | |
2403 | | - | |
| 2395 | + | |
2404 | 2396 | | |
2405 | 2397 | | |
2406 | 2398 | | |
| |||
2410 | 2402 | | |
2411 | 2403 | | |
2412 | 2404 | | |
2413 | | - | |
2414 | | - | |
2415 | | - | |
2416 | | - | |
| 2405 | + | |
2417 | 2406 | | |
2418 | 2407 | | |
2419 | 2408 | | |
| |||
0 commit comments