Skip to content

Commit

Permalink
Simplify createWasm. NFC
Browse files Browse the repository at this point in the history
I have no idea who this seems to be a minor code size regression.
  • Loading branch information
sbc100 committed Dec 19, 2024
1 parent 971d4f6 commit b03368d
Show file tree
Hide file tree
Showing 64 changed files with 69 additions and 83 deletions.
26 changes: 6 additions & 20 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,6 @@ function abort(what) {
/** @suppress {checkTypes} */
var e = new WebAssembly.RuntimeError(what);

#if MODULARIZE
readyPromiseReject(e);
#endif
// Throw the error whether or not MODULARIZE is set because abort is used
// in code paths apart from instantiation where an exception is expected
// to be thrown when abort is called.
Expand Down Expand Up @@ -1059,9 +1056,8 @@ function getWasmImports() {
return Module['instantiateWasm'](info, receiveInstance);
} catch(e) {
err(`Module.instantiateWasm callback failed with error: ${e}`);
#if MODULARIZE
// If instantiation fails, reject the module ready promise.
readyPromiseReject(e);
#if WASM_ASYNC_COMPILATION
return Promise.reject(e);
#else
return false;
#endif
Expand Down Expand Up @@ -1090,22 +1086,12 @@ function getWasmImports() {
#if RUNTIME_DEBUG
dbg('asynchronously preparing wasm');
#endif
#if MODULARIZE
try {
#endif
var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
var exports = receiveInstantiationResult(result);
var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
var exports = receiveInstantiationResult(result);
#if LOAD_SOURCE_MAP
receiveSourceMapJSON(await getSourceMapAsync());
#endif
return exports;
#if MODULARIZE
} catch (e) {
// If instantiation fails, reject the module ready promise.
readyPromiseReject(e);
return Promise.reject(e);
}
receiveSourceMapJSON(await getSourceMapAsync());
#endif
return exports;
#else // WASM_ASYNC_COMPILATION
var result = instantiateSync(wasmBinaryFile, info);
#if PTHREADS || MAIN_MODULE
Expand Down
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8351
8360
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20343
20358
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8334
8341
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20311
20326
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9356
9363
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24112
24127
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except_wasm.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8321
8329
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except_wasm.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20236
20251
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8321
8329
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20236
20251
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_lto.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8347
8354
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_lto.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20367
20382
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_mangle.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9359
9368
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_mangle.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24112
24127
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_noexcept.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8351
8360
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_noexcept.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20343
20358
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3651
3658
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7910
7925
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_js_fs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7654
7662
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_js_fs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18838
18853
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2882
2887
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6198
6213
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8012
8021
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O0.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
21588
21603
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2694
2701
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6899
6914
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2357
2364
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4831
4846
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O3.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2296
2303
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O3.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4753
4768
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_Os.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2296
2303
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_Os.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4753
4768
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_Oz.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2279
2287
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_Oz.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4720
4735
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_dylink.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6028
6032
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_dylink.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13317
13332
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1681
1686
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3633
3648
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2296
2303
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4753
4768
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1873
1880
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3996
4011
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1912
1919
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4044
4059
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2327
2334
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4888
4903
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3_grow.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2476
2485
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3_grow.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5172
5188
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2177
2184
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4581
4596
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3_standalone.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2140
2147
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3_standalone.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4513
4528
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1898
1905
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4043
4058
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1912
1919
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4044
4059
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1912
1919
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4044
4059
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_esm.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1509
1480
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_esm.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3157
3090
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
53888
53894
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size_no_asserts.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
29087
29093
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size_strict.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
52671
52665

0 comments on commit b03368d

Please sign in to comment.