From 46b04c2b8008755373546ca1a8f9947b8b7a9baf Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 4 Dec 2024 10:00:20 -0800 Subject: [PATCH 001/132] Remove redundant call to `.then()` on `Promise.resolve()`. NFC (#23067) IIUC this should not be an observable change. --- src/preamble.js | 2 +- test/other/codesize/test_codesize_cxx_ctors1.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors1.jssize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.jssize | 2 +- test/other/codesize/test_codesize_cxx_except.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.jssize | 2 +- test/other/codesize/test_codesize_cxx_mangle.gzsize | 2 +- test/other/codesize/test_codesize_cxx_mangle.jssize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.gzsize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.jssize | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.gzsize | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.jssize | 2 +- test/other/codesize/test_codesize_files_js_fs.gzsize | 2 +- test/other/codesize/test_codesize_files_js_fs.jssize | 2 +- test/other/codesize/test_codesize_files_wasmfs.gzsize | 2 +- test/other/codesize/test_codesize_files_wasmfs.jssize | 2 +- test/other/codesize/test_codesize_hello_O0.gzsize | 2 +- test/other/codesize/test_codesize_hello_O0.jssize | 2 +- test/other/codesize/test_codesize_hello_O1.gzsize | 2 +- test/other/codesize/test_codesize_hello_O1.jssize | 2 +- test/other/codesize/test_codesize_hello_O2.gzsize | 2 +- test/other/codesize/test_codesize_hello_O2.jssize | 2 +- test/other/codesize/test_codesize_hello_O3.gzsize | 2 +- test/other/codesize/test_codesize_hello_O3.jssize | 2 +- test/other/codesize/test_codesize_hello_Os.gzsize | 2 +- test/other/codesize/test_codesize_hello_Os.jssize | 2 +- test/other/codesize/test_codesize_hello_Oz.gzsize | 2 +- test/other/codesize/test_codesize_hello_Oz.jssize | 2 +- test/other/codesize/test_codesize_hello_dylink.gzsize | 2 +- test/other/codesize/test_codesize_hello_dylink.jssize | 2 +- test/other/codesize/test_codesize_hello_export_nothing.gzsize | 2 +- test/other/codesize/test_codesize_hello_export_nothing.jssize | 2 +- test/other/codesize/test_codesize_hello_wasmfs.gzsize | 2 +- test/other/codesize/test_codesize_hello_wasmfs.jssize | 2 +- test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize | 2 +- test/other/codesize/test_codesize_libcxxabi_message_O3.jssize | 2 +- .../test_codesize_libcxxabi_message_O3_standalone.gzsize | 2 +- .../test_codesize_libcxxabi_message_O3_standalone.jssize | 2 +- test/other/codesize/test_codesize_mem_O3.gzsize | 2 +- test/other/codesize/test_codesize_mem_O3.jssize | 2 +- test/other/codesize/test_codesize_mem_O3_grow.jssize | 2 +- test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize | 2 +- test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize | 2 +- test/other/codesize/test_codesize_mem_O3_standalone.gzsize | 2 +- test/other/codesize/test_codesize_mem_O3_standalone.jssize | 2 +- test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize | 2 +- test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize | 2 +- test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize | 2 +- test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize | 2 +- .../codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize | 2 +- .../codesize/test_codesize_mem_O3_standalone_narg_flto.jssize | 2 +- test/other/test_unoptimized_code_size.js.size | 2 +- test/other/test_unoptimized_code_size_no_asserts.js.size | 2 +- test/other/test_unoptimized_code_size_strict.js.size | 2 +- 61 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/preamble.js b/src/preamble.js index d924c4ab9f8a2..0d0d1146f26df 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -663,7 +663,7 @@ function getBinaryPromise(binaryFile) { #endif // Otherwise, getBinarySync should be able to get it synchronously - return Promise.resolve().then(() => getBinarySync(binaryFile)); + return Promise.resolve(getBinarySync(binaryFile)); } #if LOAD_SOURCE_MAP diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 888760ce9982e..4e26446bdb1ec 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8432 +8430 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index 84cd635d055dc..fce4efecd0e4f 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20676 +20665 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index e8724d9258281..925f351390343 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8416 +8413 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 62bcecc9e8083..16feda3b88c11 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20644 +20633 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index cb220b866d699..380229091ad8b 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9453 +9449 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 413092af6ade8..780418e62df3e 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24519 +24508 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index c0ca874647665..899815faa3442 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8399 +8395 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index eb359bf8228eb..fa7f30ddaefe4 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20570 +20559 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index c0ca874647665..899815faa3442 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8399 +8395 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index eb359bf8228eb..fa7f30ddaefe4 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20570 +20559 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 9604c9f1829be..790892a48d82c 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8329 +8326 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 570a495f908e8..0a30372ca06d5 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20254 +20243 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index f46a8bcc794f2..350dca048931f 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9460 +9457 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 413092af6ade8..780418e62df3e 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24519 +24508 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 888760ce9982e..4e26446bdb1ec 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8432 +8430 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index 84cd635d055dc..fce4efecd0e4f 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20676 +20665 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize index 4a45c385de208..8a5fbb7712474 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize @@ -1 +1 @@ -3895 +3893 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.jssize b/test/other/codesize/test_codesize_cxx_wasmfs.jssize index 4a63574e4a00e..513551775cadd 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.jssize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.jssize @@ -1 +1 @@ -8691 +8680 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index 37b5ad19256b9..baae27d0ac518 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7569 +7565 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index fa3be2030d496..eb9943349b327 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18585 +18574 diff --git a/test/other/codesize/test_codesize_files_wasmfs.gzsize b/test/other/codesize/test_codesize_files_wasmfs.gzsize index 02089ff0b983b..aeaee565f9610 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_files_wasmfs.gzsize @@ -1 +1 @@ -2989 +2985 diff --git a/test/other/codesize/test_codesize_files_wasmfs.jssize b/test/other/codesize/test_codesize_files_wasmfs.jssize index d928f1e433d22..21faf3262f93b 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.jssize +++ b/test/other/codesize/test_codesize_files_wasmfs.jssize @@ -1 +1 @@ -6327 +6316 diff --git a/test/other/codesize/test_codesize_hello_O0.gzsize b/test/other/codesize/test_codesize_hello_O0.gzsize index 21424ac54ff74..a3006f77bfce6 100644 --- a/test/other/codesize/test_codesize_hello_O0.gzsize +++ b/test/other/codesize/test_codesize_hello_O0.gzsize @@ -1 +1 @@ -8040 +8037 diff --git a/test/other/codesize/test_codesize_hello_O0.jssize b/test/other/codesize/test_codesize_hello_O0.jssize index 9e6f15369d6f3..eae6175bae62d 100644 --- a/test/other/codesize/test_codesize_hello_O0.jssize +++ b/test/other/codesize/test_codesize_hello_O0.jssize @@ -1 +1 @@ -21408 +21395 diff --git a/test/other/codesize/test_codesize_hello_O1.gzsize b/test/other/codesize/test_codesize_hello_O1.gzsize index c1fe14e0295ce..681f6fefb05e3 100644 --- a/test/other/codesize/test_codesize_hello_O1.gzsize +++ b/test/other/codesize/test_codesize_hello_O1.gzsize @@ -1 +1 @@ -2818 +2814 diff --git a/test/other/codesize/test_codesize_hello_O1.jssize b/test/other/codesize/test_codesize_hello_O1.jssize index 331d936bc2012..dd544fe523cf2 100644 --- a/test/other/codesize/test_codesize_hello_O1.jssize +++ b/test/other/codesize/test_codesize_hello_O1.jssize @@ -1 +1 @@ -7025 +7012 diff --git a/test/other/codesize/test_codesize_hello_O2.gzsize b/test/other/codesize/test_codesize_hello_O2.gzsize index ff7f50a6d7109..445f349d2a0d7 100644 --- a/test/other/codesize/test_codesize_hello_O2.gzsize +++ b/test/other/codesize/test_codesize_hello_O2.gzsize @@ -1 +1 @@ -2498 +2497 diff --git a/test/other/codesize/test_codesize_hello_O2.jssize b/test/other/codesize/test_codesize_hello_O2.jssize index f61405c38790b..4ef41da9c4e8b 100644 --- a/test/other/codesize/test_codesize_hello_O2.jssize +++ b/test/other/codesize/test_codesize_hello_O2.jssize @@ -1 +1 @@ -5036 +5025 diff --git a/test/other/codesize/test_codesize_hello_O3.gzsize b/test/other/codesize/test_codesize_hello_O3.gzsize index 94c0c0eb6b8d3..1dd2b4139edbc 100644 --- a/test/other/codesize/test_codesize_hello_O3.gzsize +++ b/test/other/codesize/test_codesize_hello_O3.gzsize @@ -1 +1 @@ -2418 +2414 diff --git a/test/other/codesize/test_codesize_hello_O3.jssize b/test/other/codesize/test_codesize_hello_O3.jssize index 2fe2a2bc84df4..d05b84d011247 100644 --- a/test/other/codesize/test_codesize_hello_O3.jssize +++ b/test/other/codesize/test_codesize_hello_O3.jssize @@ -1 +1 @@ -4882 +4871 diff --git a/test/other/codesize/test_codesize_hello_Os.gzsize b/test/other/codesize/test_codesize_hello_Os.gzsize index 94c0c0eb6b8d3..1dd2b4139edbc 100644 --- a/test/other/codesize/test_codesize_hello_Os.gzsize +++ b/test/other/codesize/test_codesize_hello_Os.gzsize @@ -1 +1 @@ -2418 +2414 diff --git a/test/other/codesize/test_codesize_hello_Os.jssize b/test/other/codesize/test_codesize_hello_Os.jssize index 2fe2a2bc84df4..d05b84d011247 100644 --- a/test/other/codesize/test_codesize_hello_Os.jssize +++ b/test/other/codesize/test_codesize_hello_Os.jssize @@ -1 +1 @@ -4882 +4871 diff --git a/test/other/codesize/test_codesize_hello_Oz.gzsize b/test/other/codesize/test_codesize_hello_Oz.gzsize index 2f097f031198d..e5d3207a3d6f0 100644 --- a/test/other/codesize/test_codesize_hello_Oz.gzsize +++ b/test/other/codesize/test_codesize_hello_Oz.gzsize @@ -1 +1 @@ -2397 +2394 diff --git a/test/other/codesize/test_codesize_hello_Oz.jssize b/test/other/codesize/test_codesize_hello_Oz.jssize index c8db55238c8e5..436a6f19c62de 100644 --- a/test/other/codesize/test_codesize_hello_Oz.jssize +++ b/test/other/codesize/test_codesize_hello_Oz.jssize @@ -1 +1 @@ -4849 +4838 diff --git a/test/other/codesize/test_codesize_hello_dylink.gzsize b/test/other/codesize/test_codesize_hello_dylink.gzsize index 152cf0a87a84f..9c0b82b6a7627 100644 --- a/test/other/codesize/test_codesize_hello_dylink.gzsize +++ b/test/other/codesize/test_codesize_hello_dylink.gzsize @@ -1 +1 @@ -6298 +6297 diff --git a/test/other/codesize/test_codesize_hello_dylink.jssize b/test/other/codesize/test_codesize_hello_dylink.jssize index 6ca7a20bfb1f4..325502d1fc6b4 100644 --- a/test/other/codesize/test_codesize_hello_dylink.jssize +++ b/test/other/codesize/test_codesize_hello_dylink.jssize @@ -1 +1 @@ -13867 +13856 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.gzsize b/test/other/codesize/test_codesize_hello_export_nothing.gzsize index 1351198febbf9..288be4285a70c 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.gzsize +++ b/test/other/codesize/test_codesize_hello_export_nothing.gzsize @@ -1 +1 @@ -1762 +1760 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.jssize b/test/other/codesize/test_codesize_hello_export_nothing.jssize index 3dc49aa04aae0..e86e9f7fda107 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.jssize +++ b/test/other/codesize/test_codesize_hello_export_nothing.jssize @@ -1 +1 @@ -3733 +3722 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.gzsize b/test/other/codesize/test_codesize_hello_wasmfs.gzsize index 94c0c0eb6b8d3..1dd2b4139edbc 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_hello_wasmfs.gzsize @@ -1 +1 @@ -2418 +2414 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.jssize b/test/other/codesize/test_codesize_hello_wasmfs.jssize index 2fe2a2bc84df4..d05b84d011247 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.jssize +++ b/test/other/codesize/test_codesize_hello_wasmfs.jssize @@ -1 +1 @@ -4882 +4871 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize index 22c92a24f4a53..e67fcb2e19a0b 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize @@ -1 +1 @@ -1971 +1970 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize index a6813d6cb29fd..784d3a886670a 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize @@ -1 +1 @@ -4110 +4099 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize index 24155b8b48cba..af1b4b39888c2 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize @@ -1 +1 @@ -2006 +2003 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize index 8b49a4492ddcf..1e3e300877006 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize @@ -1 +1 @@ -4157 +4146 diff --git a/test/other/codesize/test_codesize_mem_O3.gzsize b/test/other/codesize/test_codesize_mem_O3.gzsize index 51d5790fa9f86..6d92b9495f826 100644 --- a/test/other/codesize/test_codesize_mem_O3.gzsize +++ b/test/other/codesize/test_codesize_mem_O3.gzsize @@ -1 +1 @@ -2434 +2431 diff --git a/test/other/codesize/test_codesize_mem_O3.jssize b/test/other/codesize/test_codesize_mem_O3.jssize index 19320f4b34e76..b06d635af4c41 100644 --- a/test/other/codesize/test_codesize_mem_O3.jssize +++ b/test/other/codesize/test_codesize_mem_O3.jssize @@ -1 +1 @@ -5024 +5013 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.jssize b/test/other/codesize/test_codesize_mem_O3_grow.jssize index 59a265c26452e..fa33584388b49 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow.jssize @@ -1 +1 @@ -5306 +5295 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize index 1724e23e2d5fa..869c6c230177d 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize @@ -1 +1 @@ -2276 +2273 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize index b9dafcc314664..b698f5e622c21 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize @@ -1 +1 @@ -4713 +4702 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize index f80488fd5ce7c..137c70ae46487 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize @@ -1 +1 @@ -2242 +2239 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_standalone.jssize index 4fbccb1a0a505..5becefaad6486 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.jssize @@ -1 +1 @@ -4643 +4632 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize index 7e1ef81cc649b..ef0a2ad63226b 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize @@ -1 +1 @@ -1990 +1987 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize index 2b0a18cec8ad2..5d4a7710efc0f 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize @@ -1 +1 @@ -4161 +4150 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize index 24155b8b48cba..af1b4b39888c2 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize @@ -1 +1 @@ -2006 +2003 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize index 8b49a4492ddcf..1e3e300877006 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize @@ -1 +1 @@ -4157 +4146 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize index 24155b8b48cba..af1b4b39888c2 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize @@ -1 +1 @@ -2006 +2003 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize index 8b49a4492ddcf..1e3e300877006 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize @@ -1 +1 @@ -4157 +4146 diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index a9702b35fe87e..6dbbbc2f07ed9 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -54957 +54944 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index 478cd0ea98e0c..878b3a1ba2167 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -30611 +30598 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index 93cc7231065b7..45c473ad78361 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -53753 +53740 From 41eb941baae04cfaf4267e44285101551c2c9c0d Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Wed, 4 Dec 2024 20:28:26 +0100 Subject: [PATCH 002/132] Restore changelog entry mistakenly removed in #23017. NFC (#23071) --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index edefea9330cfc..3ae469aec7456 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -24,6 +24,7 @@ See docs/process.md for more on how version tagging works. 3.1.73 - 11/28/24 ----------------- - libunwind was updated to LLVM 19.1.4. (#22394) +- mimalloc was updated to 2.1.7. (#21548) 3.1.72 - 11/19/24 ----------------- From 81b7179adf7eb0774880dfa62293c2cacad99470 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 4 Dec 2024 20:56:23 +0100 Subject: [PATCH 003/132] Add nodefs readdir handling for directories that contain exotic entries (#22925) Resolves #22924. --- src/library_syscall.js | 19 ++++++++++++++----- test/fs/test_nodefs_readdir.out | 13 +++++++++++++ test/fs/test_nodefs_readdir.wasm2js.out | 12 ++++++++++++ test/fs/test_nodefs_readdir.wasmfs.out | 14 ++++++++++++++ test/test_core.py | 12 +++++++++++- 5 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 test/fs/test_nodefs_readdir.out create mode 100644 test/fs/test_nodefs_readdir.wasm2js.out create mode 100644 test/fs/test_nodefs_readdir.wasmfs.out diff --git a/src/library_syscall.js b/src/library_syscall.js index fde42e8a48428..3e857b344d141 100644 --- a/src/library_syscall.js +++ b/src/library_syscall.js @@ -695,9 +695,9 @@ var SyscallsLibrary = { var pos = 0; var off = FS.llseek(stream, 0, {{{ cDefs.SEEK_CUR }}}); - var idx = Math.floor(off / struct_size); - - while (idx < stream.getdents.length && pos + struct_size <= count) { + var startIdx = Math.floor(off / struct_size); + var endIdx = Math.min(stream.getdents.length, startIdx + Math.floor(count/struct_size)) + for (var idx = startIdx; idx < endIdx; idx++) { var id; var type; var name = stream.getdents[idx]; @@ -711,7 +711,17 @@ var SyscallsLibrary = { type = 4; // DT_DIR } else { - var child = FS.lookupNode(stream.node, name); + var child; + try { + child = FS.lookupNode(stream.node, name); + } catch (e) { + // If the entry is not a directory, file, or symlink, nodefs + // lookupNode will raise EINVAL. Skip these and continue. + if (e?.errno === {{{ cDefs.EINVAL }}}) { + continue; + } + throw e; + } id = child.id; type = FS.isChrdev(child.mode) ? 2 : // DT_CHR, character device. FS.isDir(child.mode) ? 4 : // DT_DIR, directory. @@ -727,7 +737,6 @@ var SyscallsLibrary = { {{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_type, 'type', 'i8') }}}; stringToUTF8(name, dirp + pos + {{{ C_STRUCTS.dirent.d_name }}}, 256); pos += struct_size; - idx += 1; } FS.llseek(stream, idx * struct_size, {{{ cDefs.SEEK_SET }}}); return pos; diff --git a/test/fs/test_nodefs_readdir.out b/test/fs/test_nodefs_readdir.out new file mode 100644 index 0000000000000..293d117dc7251 --- /dev/null +++ b/test/fs/test_nodefs_readdir.out @@ -0,0 +1,13 @@ +listing contents of dir=/ +. +.. +tmp +home +dev +proc +listing contents of dir=/working +existing +stdout +test_nodefs_readdir.js +test_nodefs_readdir.wasm +success diff --git a/test/fs/test_nodefs_readdir.wasm2js.out b/test/fs/test_nodefs_readdir.wasm2js.out new file mode 100644 index 0000000000000..cc2268c8bcb8a --- /dev/null +++ b/test/fs/test_nodefs_readdir.wasm2js.out @@ -0,0 +1,12 @@ +listing contents of dir=/ +. +.. +tmp +home +dev +proc +listing contents of dir=/working +existing +stdout +test_nodefs_readdir.js +success diff --git a/test/fs/test_nodefs_readdir.wasmfs.out b/test/fs/test_nodefs_readdir.wasmfs.out new file mode 100644 index 0000000000000..bf8f2ad9fa60a --- /dev/null +++ b/test/fs/test_nodefs_readdir.wasmfs.out @@ -0,0 +1,14 @@ +listing contents of dir=/ +. +.. +dev +tmp +listing contents of dir=/working +. +.. +existing +named_pipe +stdout +test_nodefs_readdir.js +test_nodefs_readdir.wasm +success diff --git a/test/test_core.py b/test/test_core.py index fd18476c6ccea..7511815c00a8e 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5779,14 +5779,24 @@ def test_fs_nodefs_nofollow(self): self.emcc_args += ['-lnodefs.js'] self.do_runf('fs/test_nodefs_nofollow.c', 'success') + @crossplatform @requires_node def test_fs_nodefs_readdir(self): # externally setup an existing folder structure: existing/a if self.get_setting('WASMFS'): self.set_setting('FORCE_FILESYSTEM') + if not WINDOWS: + # Add an entry that isn't a directory, file, or link to test that we handle + # it correctly. + os.mkfifo('named_pipe') os.makedirs('existing/a') self.emcc_args += ['-lnodefs.js'] - self.do_runf('fs/test_nodefs_readdir.c', 'success') + suffix = '' + if self.get_setting('WASMFS'): + suffix = '.wasmfs' + elif self.is_wasm2js(): + suffix = ".wasm2js" + self.do_run_in_out_file_test('fs/test_nodefs_readdir.c', out_suffix=suffix) @requires_node @crossplatform From f52638627348b3f94911893bd05425d3ac8a384e Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 4 Dec 2024 22:12:59 +0100 Subject: [PATCH 004/132] Handle trailing % in strftime (#23045) "In glibc a trailing % in strftime() acts like printf, ie it's a literal %". This is breaking some Python tests. I've applied the patch suggested here: https://www.openwall.com/lists/musl/2022/12/19/2 --- system/lib/libc/README.md | 1 + system/lib/libc/musl/src/time/strftime.c | 6 ++++++ test/other/test_strftime.c | 3 +++ 3 files changed, 10 insertions(+) diff --git a/system/lib/libc/README.md b/system/lib/libc/README.md index 895524e6f309c..0094e8a96dfe7 100644 --- a/system/lib/libc/README.md +++ b/system/lib/libc/README.md @@ -12,6 +12,7 @@ Some changes have been made to the version that was taken from upstream, includi * Switch to using the wasi `fd_write` syscall instead of `writev`. * Simplify stdout stream handling: do not support seeking, terminal handling, etc., as it just increases code size and Emscripten doesn't have those features anyhow. * Setting `_POSIX_REALTIME_SIGNALS` and `_POSIX_SPAWN` macros to -1, to exclude unsupported functions. + * Handling trailing % in `strftime` and `wcsftime` format strings. Copy log.c and log2.c from earlier version of musl which result in smaller binary size since they do not rely data tables in log_data.c and log2_data.c. diff --git a/system/lib/libc/musl/src/time/strftime.c b/system/lib/libc/musl/src/time/strftime.c index c40246dbb0fa3..59d609ba92245 100644 --- a/system/lib/libc/musl/src/time/strftime.c +++ b/system/lib/libc/musl/src/time/strftime.c @@ -226,7 +226,13 @@ size_t __strftime_l(char *restrict s, size_t n, const char *restrict f, const st s[l] = 0; return l; } +#ifdef __EMSCRIPTEN__ + // Handle trailing % by outputting a % rather than returning 0. Ideally + // this 6 character change could be upstreamed into musl... + if (*f != '%' || !f[1]) { +#else if (*f != '%') { +#endif s[l++] = *f; continue; } diff --git a/test/other/test_strftime.c b/test/other/test_strftime.c index 9f14e177c9e9b..26a388ba54b87 100644 --- a/test/other/test_strftime.c +++ b/test/other/test_strftime.c @@ -307,5 +307,8 @@ int main() { size = strftime(s, sizeof(s), "%Ec", &tm); TEST(!cmp(s, "Mon Dec 17 00:00:00 2018"), "strftime test #36a", s); + size = strftime(s, sizeof(s), "trailing %", &tm); + TEST((size == 10), "strftime test #37", s); + TEST(!cmp(s, "trailing %"), "strftime test #37", s); return 0; } From 44d51c874f020cea34aac4e23989db245cff7c5b Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 4 Dec 2024 22:15:22 +0100 Subject: [PATCH 005/132] Ruff rules for comprehensions, performance, and simplicity (#23040) Only in the `tools/` directory apply ruff rules for comprehensions, performance, and simplicity. * https://docs.astral.sh/ruff * https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4 * https://docs.astral.sh/ruff/rules/#perflint-perf * https://docs.astral.sh/ruff/rules/#flake8-simplify-sim This pull request was roughly created via the command: `ruff --select=C4,PERF,Q,SIM --ignore=SIM108,SIM300 lint.flake8-quotes.inline-quotes=single --fix --unsafe-fixes` --- tools/building.py | 17 ++++++++--------- tools/colored_logger.py | 4 +--- tools/determinism_checker.py | 2 +- tools/emcoverage.py | 5 ++--- tools/emdump.py | 8 ++++---- tools/emscripten.py | 22 +++++++--------------- tools/experimental/reproduceriter.py | 2 +- tools/file_packager.py | 5 +---- tools/js_optimizer.py | 4 +--- tools/link.py | 17 ++++++++--------- tools/maint/check_struct_info.py | 2 +- tools/maint/gen_sig_info.py | 17 +++++++---------- tools/maint/gen_struct_info.py | 12 ++++++------ tools/ports/__init__.py | 15 ++++++--------- tools/ports/sdl2_image.py | 3 +-- tools/shared.py | 5 ++--- tools/system_libs.py | 2 +- tools/toolchain_profiler.py | 2 +- tools/webassembly.py | 13 +++---------- tools/webidl_binder.py | 5 +---- 20 files changed, 63 insertions(+), 99 deletions(-) diff --git a/tools/building.py b/tools/building.py index c070e540636f1..1110f1dfb7bf7 100644 --- a/tools/building.py +++ b/tools/building.py @@ -114,7 +114,7 @@ def side_module_external_deps(external_symbols): sym = demangle_c_symbol_name(sym) if sym in external_symbols: deps = deps.union(external_symbols[sym]) - return sorted(list(deps)) + return sorted(deps) def create_stub_object(external_symbols): @@ -184,12 +184,11 @@ def lld_flags_for_executable(external_symbols): c_exports += side_module_external_deps(external_symbols) for export in c_exports: if settings.ERROR_ON_UNDEFINED_SYMBOLS: - cmd.append('--export=' + export) + cmd.append(f'--export={export}') else: - cmd.append('--export-if-defined=' + export) + cmd.append(f'--export-if-defined={export}') - for e in settings.EXPORT_IF_DEFINED: - cmd.append('--export-if-defined=' + e) + cmd.extend(f'--export-if-defined={e}' for e in settings.EXPORT_IF_DEFINED) if settings.RELOCATABLE: cmd.append('--experimental-pic') @@ -749,10 +748,10 @@ def minify_wasm_js(js_file, wasm_file, expensive_optimizations, debug_info): def is_internal_global(name): - internal_start_stop_symbols = set(['__start_em_asm', '__stop_em_asm', - '__start_em_js', '__stop_em_js', - '__start_em_lib_deps', '__stop_em_lib_deps', - '__em_lib_deps']) + internal_start_stop_symbols = {'__start_em_asm', '__stop_em_asm', + '__start_em_js', '__stop_em_js', + '__start_em_lib_deps', '__stop_em_lib_deps', + '__em_lib_deps'} internal_prefixes = ('__em_js__', '__em_lib_deps') return name in internal_start_stop_symbols or any(name.startswith(p) for p in internal_prefixes) diff --git a/tools/colored_logger.py b/tools/colored_logger.py index c891a616bb576..2802415a1ae55 100644 --- a/tools/colored_logger.py +++ b/tools/colored_logger.py @@ -99,9 +99,7 @@ def add_coloring_to_emit_ansi(fn): # add methods we need to the class def new(*args): levelno = args[1].levelno - if levelno >= 50: - color = '\x1b[31m' # red - elif levelno >= 40: + if levelno >= 40: color = '\x1b[31m' # red elif levelno >= 30: color = '\x1b[33m' # yellow diff --git a/tools/determinism_checker.py b/tools/determinism_checker.py index 952cdd9f8a625..03c63a52640c3 100644 --- a/tools/determinism_checker.py +++ b/tools/determinism_checker.py @@ -24,7 +24,7 @@ def run(): def write(data, subdir): if not os.path.exists(subdir): os.mkdir(subdir) - for relevant_file in data.keys(): + for relevant_file in data: Path(os.path.join(subdir, relevant_file)).write_text(data[relevant_file]) diff --git a/tools/emcoverage.py b/tools/emcoverage.py index d7d906d092de2..55d9d4aebd173 100755 --- a/tools/emcoverage.py +++ b/tools/emcoverage.py @@ -37,6 +37,7 @@ from glob import glob import coverage.cmdline # type: ignore +import contextlib SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -62,10 +63,8 @@ def main(): if sys.argv[1] in ('html', 'report', 'xml'): old_argv = sys.argv sys.argv = ['coverage', 'combine'] + glob(os.path.join(store, '*')) - try: + with contextlib.suppress(SystemExit): coverage.cmdline.main() - except SystemExit: - pass sys.argv = old_argv + ['-i'] return coverage.cmdline.main() diff --git a/tools/emdump.py b/tools/emdump.py index dd2c4cfb41517..089d2a288df4a 100755 --- a/tools/emdump.py +++ b/tools/emdump.py @@ -162,8 +162,8 @@ def merge_entry_to_existing(existing_data, new_entry, total_source_set_size): name = new_entry['unminified_name'] if name in existing_data: ex = existing_data[name] - num_times_occurs_1 = ex['num_times_occurs'] if 'num_times_occurs' in ex else 1 - num_times_occurs_2 = new_entry['num_times_occurs'] if 'num_times_occurs' in new_entry else 1 + num_times_occurs_1 = ex.get('num_times_occurs', 1) + num_times_occurs_2 = new_entry.get('num_times_occurs', 1) existing_data[name] = { 'lines': ex['lines'] + new_entry['lines'], 'bytes': ex['bytes'] + new_entry['bytes'], @@ -212,7 +212,7 @@ def analyze_javascript_file_contents(filename, file_contents, total_source_set_s if asm_start >= 0: asm_start_brace = file_contents.rfind('{', 0, asm_start) if asm_start_brace >= 0: - asm_end_brace = brace_map[asm_start_brace] if asm_start_brace in brace_map else file_len + asm_end_brace = brace_map.get(asm_start_brace, file_len) func_pos = -1 var_pos = -1 @@ -516,7 +516,7 @@ def print_symbol_info(data, total_source_set_size): continue if options.only_common and (not e['in_set_1'] or not e['in_set_2']): continue - prev_bytes = e['prev_bytes'] if 'prev_bytes' in e else 0 + prev_bytes = e.get('prev_bytes', 0) if max(e['bytes'], prev_bytes) < options.filter_size: continue if e['bytes'] == prev_bytes and options.only_changes: diff --git a/tools/emscripten.py b/tools/emscripten.py index a3e3fc4cd7046..9566ace8b95a0 100644 --- a/tools/emscripten.py +++ b/tools/emscripten.py @@ -225,7 +225,7 @@ def set_memory(static_bump): def report_missing_exports_wasm_only(metadata): if diagnostics.is_enabled('undefined'): - defined_symbols = set(asmjs_mangle(e) for e in metadata.all_exports) + defined_symbols = {asmjs_mangle(e) for e in metadata.all_exports} missing = set(settings.USER_EXPORTS) - defined_symbols for symbol in sorted(missing): diagnostics.warning('undefined', f'undefined exported symbol: "{symbol}"') @@ -235,7 +235,7 @@ def report_missing_exports(js_symbols): if diagnostics.is_enabled('undefined'): # Report any symbol that was explicitly exported but is present neither # as a native function nor as a JS library function. - defined_symbols = set(asmjs_mangle(e) for e in settings.WASM_EXPORTS).union(js_symbols) + defined_symbols = {asmjs_mangle(e) for e in settings.WASM_EXPORTS}.union(js_symbols) missing = set(settings.USER_EXPORTS) - defined_symbols for symbol in sorted(missing): diagnostics.warning('undefined', f'undefined exported symbol: "{symbol}"') @@ -699,15 +699,12 @@ def create_asm_consts(metadata): asm_consts = {} for addr, const in metadata.em_asm_consts.items(): body = trim_asm_const_body(const) - args = [] max_arity = 16 arity = 0 for i in range(max_arity): - if ('$' + str(i)) in const: + if f'${i}' in const: arity = i + 1 - for i in range(arity): - args.append('$' + str(i)) - args = ', '.join(args) + args = ', '.join(f'${i}' for i in range(arity)) if 'arguments' in body: # arrow functions don't bind `arguments` so we have to use # the old function syntax in this case @@ -717,8 +714,7 @@ def create_asm_consts(metadata): if settings.RELOCATABLE: addr += settings.GLOBAL_BASE asm_consts[addr] = func - asm_consts = [(key, value) for key, value in asm_consts.items()] - asm_consts.sort() + asm_consts = sorted(asm_consts.items()) return asm_consts @@ -836,10 +832,8 @@ def add_standard_wasm_imports(send_items_map): def create_sending(metadata, library_symbols): # Map of wasm imports to mangled/external/JS names - send_items_map = {} + send_items_map = {name: name for name in metadata.invoke_funcs} - for name in metadata.invoke_funcs: - send_items_map[name] = name for name in metadata.imports: if name in metadata.em_js_funcs: send_items_map[name] = name @@ -903,9 +897,7 @@ def install_wrapper(sym): # pthread_self and _emscripten_proxy_execute_task_queue are currently called in some # cases after the runtime has exited. # TODO: Look into removing these, and improving our robustness around thread termination. - if sym in ('__trap', 'pthread_self', '_emscripten_proxy_execute_task_queue'): - return False - return True + return sym not in {'__trap', 'pthread_self', '_emscripten_proxy_execute_task_queue'} for name, types in function_exports.items(): nargs = len(types.params) diff --git a/tools/experimental/reproduceriter.py b/tools/experimental/reproduceriter.py index 3d47bf895ed7c..2813a83b28896 100644 --- a/tools/experimental/reproduceriter.py +++ b/tools/experimental/reproduceriter.py @@ -125,7 +125,7 @@ window_location = sys.argv[4] if len(sys.argv) >= 5 else '' on_idle = sys.argv[5] if len(sys.argv) >= 6 else '' -shell = not not window_location +shell = bool(window_location) dirs_to_drop = 0 if not os.path.dirname(first_js) else len(os.path.dirname(first_js).split('/')) diff --git a/tools/file_packager.py b/tools/file_packager.py index 5c48543588d16..123462418bd44 100755 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -172,10 +172,7 @@ def should_ignore(fullname): if has_hidden_attribute(fullname): return True - for p in excluded_patterns: - if fnmatch.fnmatch(fullname, p): - return True - return False + return any(fnmatch.fnmatch(fullname, p) for p in excluded_patterns) def add(mode, rootpathsrc, rootpathdst): diff --git a/tools/js_optimizer.py b/tools/js_optimizer.py index f201ee9edfb04..d7a158b338ea3 100755 --- a/tools/js_optimizer.py +++ b/tools/js_optimizer.py @@ -330,9 +330,7 @@ def write_chunk(chunk, i): with ToolchainProfiler.profile_block('sort_or_concat'): # sort functions by size, to make diffing easier and to improve aot times - funcses = [] - for out_file in filenames: - funcses.append(split_funcs(utils.read_file(out_file))) + funcses = [split_funcs(utils.read_file(out_file)) for out_file in filenames] funcs = [item for sublist in funcses for item in sublist] funcses = None if not os.environ.get('EMCC_NO_OPT_SORT'): diff --git a/tools/link.py b/tools/link.py index ed1a42d54a7da..dbd5e80967d2c 100644 --- a/tools/link.py +++ b/tools/link.py @@ -166,7 +166,7 @@ def will_metadce(): def setup_environment_settings(): # Environment setting based on user input environments = settings.ENVIRONMENT.split(',') - if any([x for x in environments if x not in VALID_ENVIRONMENTS]): + if any(x for x in environments if x not in VALID_ENVIRONMENTS): exit_with_error(f'Invalid environment specified in "ENVIRONMENT": {settings.ENVIRONMENT}. Should be one of: {",".join(VALID_ENVIRONMENTS)}') settings.ENVIRONMENT_MAY_BE_WEB = not settings.ENVIRONMENT or 'web' in environments @@ -216,8 +216,8 @@ def get_js_sym_info(): # and can contain full paths to temporary files. skip_settings = {'PRE_JS_FILES', 'POST_JS_FILES'} input_files = [json.dumps(settings.external_dict(skip_keys=skip_settings), sort_keys=True, indent=2)] - for jslib in sorted(glob.glob(utils.path_from_root('src') + '/library*.js')): - input_files.append(read_file(jslib)) + jslibs = glob.glob(utils.path_from_root('src') + '/library*.js') + input_files.extend(read_file(jslib) for jslib in sorted(jslibs)) for jslib in settings.JS_LIBRARIES: if not os.path.isabs(jslib): jslib = utils.path_from_root('src', jslib) @@ -622,7 +622,7 @@ def check_browser_versions(): if settings.LEGACY_VM_SUPPORT: # Default all browser versions to zero - for key in min_version_settings.keys(): + for key in min_version_settings: default_setting(key, 0) for key, oldest in min_version_settings.items(): @@ -964,9 +964,8 @@ def phase_linker_setup(options, state, newargs): if settings.MINIMAL_RUNTIME_STREAMING_WASM_COMPILATION and settings.MINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATION: exit_with_error('MINIMAL_RUNTIME_STREAMING_WASM_COMPILATION and MINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATION are mutually exclusive!') - if options.emrun: - if settings.MINIMAL_RUNTIME: - exit_with_error('--emrun is not compatible with MINIMAL_RUNTIME') + if options.emrun and settings.MINIMAL_RUNTIME: + exit_with_error('--emrun is not compatible with MINIMAL_RUNTIME') if options.use_closure_compiler: settings.USE_CLOSURE_COMPILER = 1 @@ -2939,7 +2938,7 @@ def process_dynamic_libs(dylibs, lib_dirs): dylibs += extras for dylib in dylibs: exports = webassembly.get_exports(dylib) - exports = set(e.name for e in exports) + exports = {e.name for e in exports} # EM_JS function are exports with a special prefix. We need to strip # this prefix to get the actual symbol name. For the main module, this # is handled by extract_metadata.py. @@ -2953,7 +2952,7 @@ def process_dynamic_libs(dylibs, lib_dirs): # TODO(sbc): Integrate with metadata.invoke_funcs that comes from the # main module to avoid creating new invoke functions at runtime. imports = set(imports) - imports = set(i for i in imports if not i.startswith('invoke_')) + imports = {i for i in imports if not i.startswith('invoke_')} weak_imports = webassembly.get_weak_imports(dylib) strong_imports = sorted(imports.difference(weak_imports)) logger.debug('Adding symbols requirements from `%s`: %s', dylib, imports) diff --git a/tools/maint/check_struct_info.py b/tools/maint/check_struct_info.py index 373f7e04c32bd..9b56823b1bb06 100755 --- a/tools/maint/check_struct_info.py +++ b/tools/maint/check_struct_info.py @@ -32,7 +32,7 @@ def check_structs(info): def check_defines(info): - for define in info['defines'].keys(): + for define in info['defines']: key = r'cDefs\.' + define + r'\>' # grep --quiet ruturns 0 when there is a match if subprocess.run(['git', 'grep', '--quiet', key], check=False).returncode != 0: diff --git a/tools/maint/gen_sig_info.py b/tools/maint/gen_sig_info.py index b9548b35f241d..742fbf2db2585 100755 --- a/tools/maint/gen_sig_info.py +++ b/tools/maint/gen_sig_info.py @@ -181,9 +181,7 @@ def ignore_symbol(s, cxx): 'stackSave', 'stackRestore', 'stackAlloc', 'getTempRet0', 'setTempRet0', }: return True - if cxx and s in ('__asctime_r') or s.startswith('__cxa_find_matching_catch'): - return True - return False + return cxx and s == '__asctime_r' or s.startswith('__cxa_find_matching_catch') def create_c_file(filename, symbol_list, header): @@ -263,7 +261,7 @@ def update_line(l): def remove_sigs(sig_info): print("removing __sig attributes ...") - to_remove = [f'{sym}__sig:' for sym in sig_info.keys()] + to_remove = [f'{sym}__sig:' for sym in sig_info] def strip_line(l): l = l.strip() @@ -362,12 +360,11 @@ def extract_sig_info(sig_info, extra_settings=None, extra_cflags=None, cxx=False assert sym in sig_info64 sig64 = sig_info64[sym] sig_string = functype_to_str(sig32, sig64) - if sym in sig_info: - if sig_info[sym] != sig_string: - print(sym) - print(sig_string) - print(sig_info[sym]) - assert sig_info[sym] == sig_string + if sym in sig_info and sig_info[sym] != sig_string: + print(sym) + print(sig_string) + print(sig_info[sym]) + assert sig_info[sym] == sig_string sig_info[sym] = sig_string diff --git a/tools/maint/gen_struct_info.py b/tools/maint/gen_struct_info.py index 7506de47ed7d5..70754f35d1b9d 100755 --- a/tools/maint/gen_struct_info.py +++ b/tools/maint/gen_struct_info.py @@ -205,8 +205,8 @@ def gen_inspect_code(path, struct, code): def generate_c_code(headers): code = ['#include ', '#include '] - for header in headers: - code.append('#include "' + header['name'] + '"') + + code.extend(f'''#include "{header['name']}"''' for header in headers) code.append('int main() {') c_descent('structs', code) @@ -220,13 +220,13 @@ def generate_c_code(headers): for name, type_ in header['defines'].items(): # Add the necessary python type, if missing. if '%' not in type_: - if type_[-1] in ('d', 'i', 'u'): + if type_[-1] in {'d', 'i', 'u'}: # integer type_ = 'i%' + type_ - elif type_[-1] in ('f', 'F', 'e', 'E', 'g', 'G'): + elif type_[-1] in {'f', 'F', 'e', 'E', 'g', 'G'}: # float type_ = 'f%' + type_ - elif type_[-1] in ('x', 'X', 'a', 'A', 'c', 's'): + elif type_[-1] in {'x', 'X', 'a', 'A', 'c', 's'}: # hexadecimal or string type_ = 's%' + type_ @@ -343,7 +343,7 @@ def parse_json(path): data = [data] for item in data: - for key in item.keys(): + for key in item: if key not in ['file', 'defines', 'structs']: raise 'Unexpected key in json file: %s' % key diff --git a/tools/ports/__init__.py b/tools/ports/__init__.py index 40b2fa8d42d1a..c2d47ba6e96e2 100644 --- a/tools/ports/__init__.py +++ b/tools/ports/__init__.py @@ -116,10 +116,10 @@ def get_all_files_under(dirname): def dir_is_newer(dir_a, dir_b): assert os.path.exists(dir_a) assert os.path.exists(dir_b) - files_a = [(x, os.path.getmtime(x)) for x in get_all_files_under(dir_a)] - files_b = [(x, os.path.getmtime(x)) for x in get_all_files_under(dir_b)] - newest_a = max([f for f in files_a], key=lambda f: f[1]) - newest_b = max([f for f in files_b], key=lambda f: f[1]) + files_a = ((x, os.path.getmtime(x)) for x in get_all_files_under(dir_a)) + files_b = ((x, os.path.getmtime(x)) for x in get_all_files_under(dir_b)) + newest_a = max(files_a, key=lambda f: f[1]) + newest_b = max(files_b, key=lambda f: f[1]) logger.debug('newest_a: %s %s', *newest_a) logger.debug('newest_b: %s %s', *newest_b) return newest_a[1] > newest_b[1] @@ -326,10 +326,7 @@ def unpack(): utils.write_file(marker, url + '\n') def up_to_date(): - if os.path.exists(marker): - if utils.read_file(marker).strip() == url: - return True - return False + return os.path.exists(marker) and utils.read_file(marker).strip() == url # before acquiring the lock we have an early out if the port already exists if up_to_date(): @@ -372,7 +369,7 @@ def write_file(filename, contents): class OrderedSet: """Partial implementation of OrderedSet. Just enough for what we need here.""" def __init__(self, items): - self.dict = dict() + self.dict = {} for i in items: self.dict[i] = True diff --git a/tools/ports/sdl2_image.py b/tools/ports/sdl2_image.py index 70fa1499a4240..e36344eeddc21 100644 --- a/tools/ports/sdl2_image.py +++ b/tools/ports/sdl2_image.py @@ -66,8 +66,7 @@ def create(final): formats = get_formats(settings) - for fmt in formats: - flags.append('-DLOAD_' + fmt.upper()) + flags.extend(f'-DLOAD_{fmt.upper()}' for fmt in formats) if 'png' in formats: flags += ['-sUSE_LIBPNG'] diff --git a/tools/shared.py b/tools/shared.py index ea92f9f8fb469..b6cc824a0f020 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -47,6 +47,7 @@ from . import filelock from . import utils from .settings import settings +import contextlib DEBUG_SAVE = DEBUG or int(os.environ.get('EMCC_DEBUG_SAVE', '0')) @@ -493,10 +494,8 @@ def sanity_is_correct(): # We can't simply check for the existence of sanity_file and then read from # it here because we don't hold the cache lock yet and some other process # could clear the cache between checking for, and reading from, the file. - try: + with contextlib.suppress(Exception): sanity_data = utils.read_file(sanity_file) - except Exception: - pass if sanity_data == expected: logger.debug(f'sanity file up-to-date: {sanity_file}') # Even if the sanity file is up-to-date we still run the checks diff --git a/tools/system_libs.py b/tools/system_libs.py index 29d1a68f6ae36..582d19ba21148 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -502,7 +502,7 @@ def build_objects(self, build_dir): case_insensitive = is_case_insensitive(build_dir) for src in self.get_files(): ext = shared.suffix(src) - if ext in ('.s', '.S', '.c'): + if ext in {'.s', '.S', '.c'}: cmd = shared.EMCC else: cmd = shared.EMXX diff --git a/tools/toolchain_profiler.py b/tools/toolchain_profiler.py index 92ecd2a8c5eb2..0bfc1c8d7121a 100644 --- a/tools/toolchain_profiler.py +++ b/tools/toolchain_profiler.py @@ -152,7 +152,7 @@ def escape_string(arg): @staticmethod def escape_args(args): - return map(lambda arg: ToolchainProfiler.escape_string(arg), args) + return [ToolchainProfiler.escape_string(arg) for arg in args] @staticmethod def record_process_start(write_log_entry=True): diff --git a/tools/webassembly.py b/tools/webassembly.py index 4d846a7006fde..898d33e35b997 100644 --- a/tools/webassembly.py +++ b/tools/webassembly.py @@ -292,15 +292,11 @@ def get_types(self): type_form = self.read_byte() assert type_form == 0x60 - params = [] num_params = self.read_uleb() - for _ in range(num_params): - params.append(self.read_type()) + params = [self.read_type() for _ in range(num_params)] - returns = [] num_returns = self.read_uleb() - for _ in range(num_returns): - returns.append(self.read_type()) + returns = [self.read_type() for _ in range(num_returns)] types.append(FuncType(params, returns)) @@ -524,10 +520,7 @@ def get_function_types(self): self.seek(function_section.offset) num_types = self.read_uleb() - func_types = [] - for _ in range(num_types): - func_types.append(self.read_uleb()) - return func_types + return [self.read_uleb() for _ in range(num_types)] def has_name_section(self): return self.get_custom_section('name') is not None diff --git a/tools/webidl_binder.py b/tools/webidl_binder.py index e5ccd2a52655f..b8a152608a324 100644 --- a/tools/webidl_binder.py +++ b/tools/webidl_binder.py @@ -454,10 +454,7 @@ def is_ptr_arg(i): return (t.isArray() or t.isAny() or t.isString() or t.isObject() or t.isInterface()) for i, (js_arg, arg) in enumerate(zip(args, all_args)): - if i >= min_args: - optional = True - else: - optional = False + optional = i >= min_args do_default = False # Filter out arguments we don't know how to parse. Fast casing only common cases. compatible_arg = isinstance(arg, Dummy) or (isinstance(arg, WebIDL.IDLArgument) and arg.optional is False) From d833c39be4bdc83b5947181de6b46ec563e4a6ff Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Wed, 4 Dec 2024 13:27:09 -0800 Subject: [PATCH 006/132] [tsgen] Ignore checking library types when generating TS definitions. (#23019) We don't need to validate other types when generating definitions since they may be in bad state. Fixes #22996 --- tools/emscripten.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/emscripten.py b/tools/emscripten.py index 9566ace8b95a0..65584d17e0144 100644 --- a/tools/emscripten.py +++ b/tools/emscripten.py @@ -651,7 +651,11 @@ def create_tsd_exported_runtime_methods(metadata): tsc = [tsc] else: tsc = shared.get_npm_cmd('tsc') - cmd = tsc + ['--outFile', tsc_output_file, '--declaration', '--emitDeclarationOnly', '--allowJs', js_doc_file] + cmd = tsc + ['--outFile', tsc_output_file, + '--skipLibCheck', # Avoid checking any of the user's types e.g. node_modules/@types. + '--declaration', + '--emitDeclarationOnly', + '--allowJs', js_doc_file] shared.check_call(cmd, cwd=path_from_root()) return utils.read_file(tsc_output_file) From bb2a7f02c41dd5defcd6fdfdcc7c462269b33bf8 Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Wed, 4 Dec 2024 13:28:25 -0800 Subject: [PATCH 007/132] [tsgen] Make commonjs module output compatible with tsc. (#22988) This enables commonjs modules to be imported into TypeScript using the same syntax as ESM modules e.g. `import moduleFactory from './embind_tsgen.js';` --- test/other/embind_tsgen_main.ts | 51 +++++++++++++++++++-------------- test/test_other.py | 19 ++++++------ tools/link.py | 7 +++-- 3 files changed, 46 insertions(+), 31 deletions(-) diff --git a/test/other/embind_tsgen_main.ts b/test/other/embind_tsgen_main.ts index a3a39683245af..8b4588e85643c 100644 --- a/test/other/embind_tsgen_main.ts +++ b/test/other/embind_tsgen_main.ts @@ -1,30 +1,39 @@ // Example TS program that consumes the emscripten-generated module to to // illustrate how the type definitions are used and test they are workings as // expected. -import moduleFactory from './embind_tsgen.mjs'; -const module = await moduleFactory(); +// The imported file will either be an ES module or a CommonJS module depending +// on the test. +import moduleFactory from './embind_tsgen.js'; -// Test a few variations of passing value_objects with strings. -module.setValObj({ - bar: module.Bar.valueOne, - string: "ABCD", - callback: () => {} -}); +// Async IIFE is required for TSC with commonjs modules. This is not needed for +// ESM output since top level await can be used. +(async function() { -module.setValObj({ - bar: module.Bar.valueOne, - string: new Int8Array([65, 66, 67, 68]), - callback: () => {} -}); + const module = await moduleFactory(); -const valObj = module.getValObj(); -// TODO: remove the cast below when better definitions are generated for value -// objects. -const valString : string = valObj.string as string; + // Test a few variations of passing value_objects with strings. + module.setValObj({ + bar: module.Bar.valueOne, + string: "ABCD", + callback: () => {} + }); -// Ensure nonnull pointers do no need a cast or nullptr check to use. -const obj = module.getNonnullPointer(); -obj.delete(); + module.setValObj({ + bar: module.Bar.valueOne, + string: new Int8Array([65, 66, 67, 68]), + callback: () => {} + }); -console.log('ts ran'); + const valObj = module.getValObj(); + // TODO: remove the cast below when better definitions are generated for value + // objects. + const valString : string = valObj.string as string; + + // Ensure nonnull pointers do no need a cast or nullptr check to use. + const obj = module.getNonnullPointer(); + obj.delete(); + + console.log('ts ran'); + +})(); diff --git a/test/test_other.py b/test/test_other.py index a509a9f7ed590..a8a8316f074c6 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -3397,21 +3397,24 @@ def test_jspi_add_function(self): self.do_runf('other/test_jspi_add_function.c', 'done') @parameterized({ - '': [[]], - 'with_jsgen': [['-sEMBIND_AOT']] + 'commonjs': [['-sMODULARIZE'], ['--module', 'commonjs', '--moduleResolution', 'node']], + 'esm': [['-sEXPORT_ES6'], ['--module', 'NodeNext', '--moduleResolution', 'nodenext']], + 'esm_with_jsgen': [['-sEXPORT_ES6', '-sEMBIND_AOT'], ['--module', 'NodeNext', '--moduleResolution', 'nodenext']] }) - def test_embind_tsgen(self, opts): + def test_embind_tsgen_end_to_end(self, opts, tsc_opts): # Check that TypeScript generation works and that the program is runs as # expected. self.emcc(test_file('other/embind_tsgen.cpp'), - ['-o', 'embind_tsgen.mjs', '-lembind', '--emit-tsd', 'embind_tsgen.d.ts'] + opts) + ['-o', 'embind_tsgen.js', '-lembind', '--emit-tsd', 'embind_tsgen.d.ts'] + opts) # Test that the output compiles with a TS file that uses the defintions. shutil.copyfile(test_file('other/embind_tsgen_main.ts'), 'main.ts') - # A package file with type=module is needed to enabled ES modules in TSC and - # also run the output JS file as a module in node. - shutil.copyfile(test_file('other/embind_tsgen_package.json'), 'package.json') - cmd = shared.get_npm_cmd('tsc') + ['embind_tsgen.d.ts', 'main.ts', '--module', 'NodeNext', '--moduleResolution', 'nodenext'] + if '-sEXPORT_ES6' in opts: + # A package file with type=module is needed to enabled ES modules in TSC and + # also run the output JS file as a module in node. + shutil.copyfile(test_file('other/embind_tsgen_package.json'), 'package.json') + + cmd = shared.get_npm_cmd('tsc') + ['embind_tsgen.d.ts', 'main.ts', '--target', 'es2021'] + tsc_opts shared.check_call(cmd) actual = read_file('embind_tsgen.d.ts') self.assertFileContents(test_file('other/embind_tsgen_module.d.ts'), actual) diff --git a/tools/link.py b/tools/link.py index dbd5e80967d2c..88f16036f7b92 100644 --- a/tools/link.py +++ b/tools/link.py @@ -2486,9 +2486,12 @@ def modularize(): src += 'export default %s;\n' % settings.EXPORT_NAME elif not settings.MINIMAL_RUNTIME: src += '''\ -if (typeof exports === 'object' && typeof module === 'object') +if (typeof exports === 'object' && typeof module === 'object') { module.exports = %(EXPORT_NAME)s; -else if (typeof define === 'function' && define['amd']) + // This default export looks redundant, but it allows TS to import this + // commonjs style module. + module.exports.default = %(EXPORT_NAME)s; +} else if (typeof define === 'function' && define['amd']) define([], () => %(EXPORT_NAME)s); ''' % {'EXPORT_NAME': settings.EXPORT_NAME} From cd4c6a4c70adf20a5e293a9cc90c1a865f305654 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 4 Dec 2024 22:56:38 +0100 Subject: [PATCH 008/132] JS file system: distinguish between atime, mtime, and ctime (#22998) This improves posix compliance of the file system. --- ChangeLog.md | 2 ++ src/library_fs.js | 10 ++++++---- src/library_lz4.js | 17 ++++++++--------- src/library_memfs.js | 30 ++++++++++++++---------------- src/library_nodefs.js | 7 ++++--- src/library_noderawfs.js | 8 ++++---- src/library_proxyfs.js | 7 ++++--- src/library_syscall.js | 11 +++++------ src/library_tty.js | 4 ++-- src/library_workerfs.js | 17 ++++++++--------- test/fs/test_fs_js_api.c | 7 ------- test/stat/test_chmod.c | 9 +++++++++ test/utime/test_futimens.c | 6 ------ test/utime/test_utime.c | 4 ++-- 14 files changed, 68 insertions(+), 71 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 3ae469aec7456..cc2a2ed3151c5 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -25,6 +25,8 @@ See docs/process.md for more on how version tagging works. ----------------- - libunwind was updated to LLVM 19.1.4. (#22394) - mimalloc was updated to 2.1.7. (#21548) +- The file system was updated to independently track atime, mtime and ctime + instead of using the same time for all three. (#22998) 3.1.72 - 11/19/24 ----------------- diff --git a/src/library_fs.js b/src/library_fs.js index 575bf8feaac6b..3bfa8f2675477 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -146,6 +146,7 @@ FS.staticInit(); this.name = name; this.mode = mode; this.rdev = rdev; + this.atime = this.mtime = this.ctime = Date.now(); } get read() { return (this.mode & this.readMode) === this.readMode; @@ -943,7 +944,7 @@ FS.staticInit(); } node.node_ops.setattr(node, { mode: (mode & {{{ cDefs.S_IALLUGO }}}) | (node.mode & ~{{{ cDefs.S_IALLUGO }}}), - timestamp: Date.now() + ctime: Date.now() }); }, lchmod(path, mode) { @@ -1016,7 +1017,8 @@ FS.staticInit(); var lookup = FS.lookupPath(path, { follow: true }); var node = lookup.node; node.node_ops.setattr(node, { - timestamp: Math.max(atime, mtime) + atime: atime, + mtime: mtime }); }, open(path, flags, mode = 0o666) { @@ -1618,7 +1620,7 @@ FS.staticInit(); buffer[offset+i] = result; } if (bytesRead) { - stream.node.timestamp = Date.now(); + stream.node.atime = Date.now(); } return bytesRead; }, @@ -1631,7 +1633,7 @@ FS.staticInit(); } } if (length) { - stream.node.timestamp = Date.now(); + stream.node.mtime = stream.node.ctime = Date.now(); } return i; } diff --git a/src/library_lz4.js b/src/library_lz4.js index 061af9faf72a7..d989d99322009 100644 --- a/src/library_lz4.js +++ b/src/library_lz4.js @@ -70,7 +70,7 @@ addToLibrary({ node.mode = mode; node.node_ops = LZ4.node_ops; node.stream_ops = LZ4.stream_ops; - node.timestamp = (mtime || new Date).getTime(); + this.atime = this.mtime = this.ctime = (mtime || new Date).getTime(); assert(LZ4.FILE_MODE !== LZ4.DIR_MODE); if (mode === LZ4.FILE_MODE) { node.size = contents.end - contents.start; @@ -95,19 +95,18 @@ addToLibrary({ gid: 0, rdev: 0, size: node.size, - atime: new Date(node.timestamp), - mtime: new Date(node.timestamp), - ctime: new Date(node.timestamp), + atime: new Date(node.atime), + mtime: new Date(node.mtime), + ctime: new Date(node.ctime), blksize: 4096, blocks: Math.ceil(node.size / 4096), }; }, setattr(node, attr) { - if (attr.mode !== undefined) { - node.mode = attr.mode; - } - if (attr.timestamp !== undefined) { - node.timestamp = attr.timestamp; + for (const key of ['mode', 'atime', 'mtime', 'ctime']) { + if (attr[key]) { + node[key] = attr[key]; + } } }, lookup(parent, name) { diff --git a/src/library_memfs.js b/src/library_memfs.js index b4beccd08aadf..35597c99056b5 100644 --- a/src/library_memfs.js +++ b/src/library_memfs.js @@ -92,11 +92,11 @@ addToLibrary({ node.node_ops = MEMFS.ops_table.chrdev.node; node.stream_ops = MEMFS.ops_table.chrdev.stream; } - node.timestamp = Date.now(); + node.atime = node.mtime = node.ctime = Date.now(); // add the new node to the parent if (parent) { parent.contents[name] = node; - parent.timestamp = node.timestamp; + parent.atime = parent.mtime = parent.ctime = node.atime; } return node; }, @@ -161,9 +161,9 @@ addToLibrary({ } else { attr.size = 0; } - attr.atime = new Date(node.timestamp); - attr.mtime = new Date(node.timestamp); - attr.ctime = new Date(node.timestamp); + attr.atime = new Date(node.atime); + attr.mtime = new Date(node.mtime); + attr.ctime = new Date(node.ctime); // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize), // but this is not required by the standard. attr.blksize = 4096; @@ -171,11 +171,10 @@ addToLibrary({ return attr; }, setattr(node, attr) { - if (attr.mode !== undefined) { - node.mode = attr.mode; - } - if (attr.timestamp !== undefined) { - node.timestamp = attr.timestamp; + for (const key of ["mode", "atime", "mtime", "ctime"]) { + if (attr[key]) { + node[key] = attr[key]; + } } if (attr.size !== undefined) { MEMFS.resizeFileStorage(node, attr.size); @@ -207,14 +206,13 @@ addToLibrary({ } // do the internal rewiring delete old_node.parent.contents[old_node.name]; - old_node.parent.timestamp = Date.now() - old_node.name = new_name; new_dir.contents[new_name] = old_node; - new_dir.timestamp = old_node.parent.timestamp; + old_node.name = new_name; + new_dir.ctime = new_dir.mtime = old_node.parent.ctime = old_node.parent.mtime = Date.now(); }, unlink(parent, name) { delete parent.contents[name]; - parent.timestamp = Date.now(); + parent.ctime = parent.mtime = Date.now(); }, rmdir(parent, name) { var node = FS.lookupNode(parent, name); @@ -222,7 +220,7 @@ addToLibrary({ throw new FS.ErrnoError({{{ cDefs.ENOTEMPTY }}}); } delete parent.contents[name]; - parent.timestamp = Date.now(); + parent.ctime = parent.mtime = Date.now(); }, readdir(node) { var entries = ['.', '..']; @@ -282,7 +280,7 @@ addToLibrary({ if (!length) return 0; var node = stream.node; - node.timestamp = Date.now(); + node.mtime = node.ctime = Date.now(); if (buffer.subarray && (!node.contents || node.contents.subarray)) { // This write is from a typed array to a typed array? if (canOwn) { diff --git a/src/library_nodefs.js b/src/library_nodefs.js index 6d0544c8527cc..846a930c15c48 100644 --- a/src/library_nodefs.js +++ b/src/library_nodefs.js @@ -166,9 +166,10 @@ addToLibrary({ // update the common node structure mode as well node.mode = attr.mode; } - if (attr.timestamp !== undefined) { - var date = new Date(attr.timestamp); - fs.utimesSync(path, date, date); + if (attr.atime || attr.mtime) { + var atime = attr.atime && new Date(attr.atime); + var mtime = attr.mtime && new Date(attr.mtime); + fs.utimesSync(path, atime, mtime); } if (attr.size !== undefined) { fs.truncateSync(path, attr.size); diff --git a/src/library_noderawfs.js b/src/library_noderawfs.js index 55b9e97a4c716..6c622d15078e5 100644 --- a/src/library_noderawfs.js +++ b/src/library_noderawfs.js @@ -112,13 +112,13 @@ addToLibrary({ fs.ftruncateSync(stream.nfd, len); }, utime(path, atime, mtime) { - // -1 here for atime or mtime means UTIME_OMIT was passed. Since node + // null here for atime or mtime means UTIME_OMIT was passed. Since node // doesn't support this concept we need to first find the existing // timestamps in order to preserve them. - if (atime == -1 || mtime == -1) { + if ((atime === null) || (mtime === null)) { var st = fs.statSync(path); - if (atime == -1) atime = st.atimeMs; - if (mtime == -1) mtime = st.mtimeMs; + atime ||= st.atimeMs; + mtime ||= st.mtimeMs; } fs.utimesSync(path, atime/1000, mtime/1000); }, diff --git a/src/library_proxyfs.js b/src/library_proxyfs.js index c98fe3755eadd..6a2a9d35efe49 100644 --- a/src/library_proxyfs.js +++ b/src/library_proxyfs.js @@ -63,9 +63,10 @@ addToLibrary({ // update the common node structure mode as well node.mode = attr.mode; } - if (attr.timestamp !== undefined) { - var date = new Date(attr.timestamp); - node.mount.opts.fs.utime(path, date, date); + if (attr.atime || attr.mtime) { + var atime = new Date(attr.atime || attr.mtime); + var mtime = new Date(attr.mtime || attr.atime); + node.mount.opts.fs.utime(path, atime, mtime); } if (attr.size !== undefined) { node.mount.opts.fs.truncate(path, attr.size); diff --git a/src/library_syscall.js b/src/library_syscall.js index 3e857b344d141..821014a4af10f 100644 --- a/src/library_syscall.js +++ b/src/library_syscall.js @@ -968,7 +968,7 @@ var SyscallsLibrary = { if (nanoseconds == {{{ cDefs.UTIME_NOW }}}) { atime = now; } else if (nanoseconds == {{{ cDefs.UTIME_OMIT }}}) { - atime = -1; + atime = null; } else { atime = (seconds*1000) + (nanoseconds/(1000*1000)); } @@ -978,15 +978,14 @@ var SyscallsLibrary = { if (nanoseconds == {{{ cDefs.UTIME_NOW }}}) { mtime = now; } else if (nanoseconds == {{{ cDefs.UTIME_OMIT }}}) { - mtime = -1; + mtime = null; } else { mtime = (seconds*1000) + (nanoseconds/(1000*1000)); } } - // -1 here means UTIME_OMIT was passed. FS.utime tables the max of these - // two values and sets the timestamp to that single value. If both were - // set to UTIME_OMIT then we can skip the call completely. - if (mtime != -1 || atime != -1) { + // null here means UTIME_OMIT was passed. If both were set to UTIME_OMIT then + // we can skip the call completely. + if ((mtime ?? atime) !== null) { FS.utime(path, atime, mtime); } return 0; diff --git a/src/library_tty.js b/src/library_tty.js index 28c1d5232d5a7..6889cf157588a 100644 --- a/src/library_tty.js +++ b/src/library_tty.js @@ -79,7 +79,7 @@ addToLibrary({ buffer[offset+i] = result; } if (bytesRead) { - stream.node.timestamp = Date.now(); + stream.node.atime = Date.now(); } return bytesRead; }, @@ -95,7 +95,7 @@ addToLibrary({ throw new FS.ErrnoError({{{ cDefs.EIO }}}); } if (length) { - stream.node.timestamp = Date.now(); + stream.node.mtime = stream.node.ctime = Date.now(); } return i; } diff --git a/src/library_workerfs.js b/src/library_workerfs.js index 28020bfac7e4d..b5245d201f181 100644 --- a/src/library_workerfs.js +++ b/src/library_workerfs.js @@ -57,7 +57,7 @@ addToLibrary({ node.mode = mode; node.node_ops = WORKERFS.node_ops; node.stream_ops = WORKERFS.stream_ops; - node.timestamp = (mtime || new Date).getTime(); + node.atime = node.mtime = node.ctime = (mtime || new Date).getTime(); assert(WORKERFS.FILE_MODE !== WORKERFS.DIR_MODE); if (mode === WORKERFS.FILE_MODE) { node.size = contents.size; @@ -82,19 +82,18 @@ addToLibrary({ gid: 0, rdev: 0, size: node.size, - atime: new Date(node.timestamp), - mtime: new Date(node.timestamp), - ctime: new Date(node.timestamp), + atime: new Date(node.atime), + mtime: new Date(node.mtime), + ctime: new Date(node.ctime), blksize: 4096, blocks: Math.ceil(node.size / 4096), }; }, setattr(node, attr) { - if (attr.mode !== undefined) { - node.mode = attr.mode; - } - if (attr.timestamp !== undefined) { - node.timestamp = attr.timestamp; + for (const key of ["mode", "atime", "mtime", "ctime"]) { + if (attr[key]) { + node[key] = attr[key]; + } } }, lookup(parent, name) { diff --git a/test/fs/test_fs_js_api.c b/test/fs/test_fs_js_api.c index ecd50cbdd799e..e5e58acff801f 100644 --- a/test/fs/test_fs_js_api.c +++ b/test/fs/test_fs_js_api.c @@ -439,17 +439,10 @@ void test_fs_utime() { assert(utimeStats.st_atime == 10); assert(utimeStats.st_atim.tv_sec == 10); - // WasmFS correctly sets both times, but the legacy API sets both times to the max of atime and mtime - // and does not correctly handle nanseconds. -#if WASMFS assert(utimeStats.st_atim.tv_nsec == 500000000); assert(utimeStats.st_mtime == 8); assert(utimeStats.st_mtim.tv_sec == 8); -#else - assert(utimeStats.st_mtime == 10); - assert(utimeStats.st_mtim.tv_sec == 10); -#endif remove("utimetest"); } diff --git a/test/stat/test_chmod.c b/test/stat/test_chmod.c index 995408147e791..b9428255efdbf 100644 --- a/test/stat/test_chmod.c +++ b/test/stat/test_chmod.c @@ -45,6 +45,7 @@ void cleanup() { void test() { int err; int lastctime; + int lastmtime; struct stat s; // @@ -54,6 +55,7 @@ void test() { memset(&s, 0, sizeof s); stat("file", &s); lastctime = s.st_ctime; + lastmtime = s.st_mtime; sleep(1); // do the actual chmod @@ -64,11 +66,13 @@ void test() { stat("file", &s); assert(s.st_mode == (S_IWUSR | S_IFREG)); assert(s.st_ctime != lastctime); + assert(s.st_mtime == lastmtime); // // fchmod a file // lastctime = s.st_ctime; + lastmtime = s.st_mtime; sleep(1); err = fchmod(open("file", O_WRONLY), S_IXUSR); @@ -78,11 +82,13 @@ void test() { stat("file", &s); assert(s.st_mode == (S_IXUSR | S_IFREG)); assert(s.st_ctime != lastctime); + assert(s.st_mtime == lastmtime); // // fchmodat a file // lastctime = s.st_ctime; + lastmtime = s.st_mtime; sleep(1); err = fchmodat(AT_FDCWD, "otherfile", S_IXUSR, 0); assert(!err); @@ -91,6 +97,7 @@ void test() { stat("otherfile", &s); assert(s.st_mode == (S_IXUSR | S_IFREG)); assert(s.st_ctime != lastctime); + assert(s.st_mtime == lastmtime); // // chmod a folder @@ -99,6 +106,7 @@ void test() { memset(&s, 0, sizeof s); stat("folder", &s); lastctime = s.st_ctime; + lastmtime = s.st_mtime; sleep(1); // do the actual chmod @@ -108,6 +116,7 @@ void test() { stat("folder", &s); assert(s.st_mode == (S_IWUSR | S_IXUSR | S_IFDIR)); assert(s.st_ctime != lastctime); + assert(s.st_mtime == lastmtime); #ifndef WASMFS // TODO https://github.com/emscripten-core/emscripten/issues/15948 lstat("file-link", &s); diff --git a/test/utime/test_futimens.c b/test/utime/test_futimens.c index 562e957f071d4..d42f635fa43d6 100644 --- a/test/utime/test_futimens.c +++ b/test/utime/test_futimens.c @@ -105,12 +105,6 @@ void test() { err = futimens(fd, newtimes); assert(!err); -#if defined(__EMSCRIPTEN__) && !defined(WASMFS) && !defined(NODERAWFS) - // The original emscripten FS (in JS) only supports a single timestamp so both - // mtime and atime will always be the same. - times[0].tv_sec = 42; - times[0].tv_nsec = 88; -#endif times[1].tv_sec = 42; times[1].tv_nsec = 88; check_times(fd, times, 0); diff --git a/test/utime/test_utime.c b/test/utime/test_utime.c index ab6a1a245a192..836735bb19909 100644 --- a/test/utime/test_utime.c +++ b/test/utime/test_utime.c @@ -27,7 +27,7 @@ void test() { // currently, the most recent timestamp is shared for atime, // ctime and mtime. using unique values for each in the test // will fail - struct utimbuf t = {1000000000, 1000000000}; + struct utimbuf t = {1000000000, 2000000000}; errno = 0; int rv = utime("writeable", &t); @@ -54,7 +54,7 @@ void test() { // write permissions aren't checked when setting node // attributes unless the user uid isn't the owner (so - // therefor, this should work fine) + // therefore, this should work fine) rv = utime("unwriteable", &t); assert(rv == 0); assert(!errno); From 161573c8262ca8106084cd4d08dd3e0186fda517 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 4 Dec 2024 14:20:22 -0800 Subject: [PATCH 009/132] Use encodeURIComponent in browser_reporting. NFC (#23075) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While working on a separate change I ran into issues where chrome was refusing to fetch a report_result and this fixed the issue. It seems that the angle brackets in the backtrace after my PR were the issue: Before: ``` exception:fetch is not a function / TypeError: fetch is not a function at readAsync (https://b2607f8….proxy.googlers.com/a.out.js:284:12) at getBinaryPromise (https://b2607f8….proxy.googlers.com/a.out.js:774:12) at instantiateArrayBuffer (https://b2607f8….proxy.googlers.com/a.out.js:786:10) at instantiateAsync (https://b2607f8….proxy.googlers.com/a.out.js:832:10) at createWasm (https://b2607f8….proxy.googlers.com/a.out.js:909:3) at https://b2607f8….proxy.googlers.com/a.out.js:5310:19 ``` After: ``` exception:fetch is not a function / TypeError: fetch is not a function at readAsync (https://b2607f8….proxy.googlers.com/a.out.js:294:12) at getBinaryPromise (https://b2607f8….proxy.googlers.com/a.out.js:818:12) at https://b2607f8….proxy.googlers.com/a.out.js:831:5 at new Promise () at instantiateArrayBuffer (https://b2607f8….proxy.googlers.com/a.out.js:830:10) at instantiateAsync (https://b2607f8….proxy.googlers.com/a.out.js:881:10) at createWasm (https://b2607f8….proxy.googlers.com/a.out.js:958:3) at https://b2607f8….proxy.googlers.com/a.out.js:5368:19 ``` --- test/browser_reporting.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/browser_reporting.js b/test/browser_reporting.js index 7fedae09e9725..f651b8b1092ea 100644 --- a/test/browser_reporting.js +++ b/test/browser_reporting.js @@ -14,7 +14,7 @@ function reportResultToServer(result, port) { out(`RESULT: ${result}`); } else { let doFetch = typeof origFetch != 'undefined' ? origFetch : fetch; - doFetch(`http://localhost:${port}/report_result?${result}`).then(() => { + doFetch(`http://localhost:${port}/report_result?${encodeURIComponent(result)}`).then(() => { if (typeof window === 'object' && window && hasModule && !Module['pageThrewException']) { /* for easy debugging, don't close window on failure */ window.close(); @@ -24,7 +24,7 @@ function reportResultToServer(result, port) { } function sendFileToServer(filename, contents) { - fetch(`http://localhost:8888/?file=${filename}`, {method: "POST", body: contents}); + fetch(`http://localhost:8888/?file=${encodeURIComponent(filename)}`, {method: "POST", body: contents}); } /** @@ -39,7 +39,7 @@ function reportErrorToServer(message) { if (typeof ENVIRONMENT_IS_NODE !== 'undefined' && ENVIRONMENT_IS_NODE) { err(message); } else { - fetch(encodeURI(`http://localhost:8888?stderr=${message}`)); + fetch(`http://localhost:8888?stderr=${encodeURIComponent(message)}`); } } From 1a6c21ef2ad141d28d4c3c8d287f84f8fc1b53b7 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 4 Dec 2024 14:28:37 -0800 Subject: [PATCH 010/132] Rebaseline codesize expectations. NFC --- test/other/codesize/test_codesize_cxx_ctors1.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors1.jssize | 2 +- test/other/codesize/test_codesize_cxx_ctors1.size | 2 +- test/other/codesize/test_codesize_cxx_ctors2.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.jssize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.size | 2 +- test/other/codesize/test_codesize_cxx_except.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except.jssize | 2 +- test/other/codesize/test_codesize_cxx_except.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.size | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.jssize | 2 +- test/other/codesize/test_codesize_cxx_lto.size | 2 +- test/other/codesize/test_codesize_cxx_mangle.gzsize | 2 +- test/other/codesize/test_codesize_cxx_mangle.jssize | 2 +- test/other/codesize/test_codesize_cxx_mangle.size | 2 +- test/other/codesize/test_codesize_cxx_noexcept.gzsize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.jssize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.size | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.size | 2 +- test/other/codesize/test_codesize_files_js_fs.gzsize | 2 +- test/other/codesize/test_codesize_files_js_fs.jssize | 2 +- 27 files changed, 27 insertions(+), 27 deletions(-) diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 4e26446bdb1ec..737757b6409f6 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8430 +8479 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index fce4efecd0e4f..ca87a75eb9c1a 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20665 +20708 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.size b/test/other/codesize/test_codesize_cxx_ctors1.size index b1fe06290a34c..67d610a7db4b8 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.size +++ b/test/other/codesize/test_codesize_cxx_ctors1.size @@ -1 +1 @@ -129273 +129276 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index 925f351390343..357af50996d0e 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8413 +8462 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 16feda3b88c11..84cd635d055dc 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20633 +20676 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.size b/test/other/codesize/test_codesize_cxx_ctors2.size index bc779b76c6b0f..8649e524047b6 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.size +++ b/test/other/codesize/test_codesize_cxx_ctors2.size @@ -1 +1 @@ -128719 +128722 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 380229091ad8b..5f3277f4dd40a 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9449 +9504 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 780418e62df3e..9c1c07ddc17d1 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24508 +24551 diff --git a/test/other/codesize/test_codesize_cxx_except.size b/test/other/codesize/test_codesize_cxx_except.size index 4101c1e3f43f1..276e7d93de41a 100644 --- a/test/other/codesize/test_codesize_cxx_except.size +++ b/test/other/codesize/test_codesize_cxx_except.size @@ -1 +1 @@ -171403 +171406 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index 899815faa3442..88ab2a149bf9a 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8395 +8447 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index fa7f30ddaefe4..6129f6408774a 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20559 +20602 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.size b/test/other/codesize/test_codesize_cxx_except_wasm.size index 0e8e746a6a881..0053d027ae5a6 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm.size @@ -1 +1 @@ -142523 +142526 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index 899815faa3442..88ab2a149bf9a 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8395 +8447 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index fa7f30ddaefe4..6129f6408774a 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20559 +20602 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size index aefb6600602e5..1c842906f1e3e 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size @@ -1 +1 @@ -145110 +145113 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 790892a48d82c..4c40b3f47ef26 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8326 +8377 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 0a30372ca06d5..4aba8455d95b6 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20243 +20286 diff --git a/test/other/codesize/test_codesize_cxx_lto.size b/test/other/codesize/test_codesize_cxx_lto.size index 50da10dc1ab23..f7d77bf63d1d7 100644 --- a/test/other/codesize/test_codesize_cxx_lto.size +++ b/test/other/codesize/test_codesize_cxx_lto.size @@ -1 +1 @@ -121982 +121985 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index 350dca048931f..8f0fc0c298e67 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9457 +9506 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 780418e62df3e..9c1c07ddc17d1 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24508 +24551 diff --git a/test/other/codesize/test_codesize_cxx_mangle.size b/test/other/codesize/test_codesize_cxx_mangle.size index 586adb4028ee1..234bba9899039 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.size +++ b/test/other/codesize/test_codesize_cxx_mangle.size @@ -1 +1 @@ -232914 +232917 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 4e26446bdb1ec..737757b6409f6 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8430 +8479 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index fce4efecd0e4f..ca87a75eb9c1a 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20665 +20708 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.size b/test/other/codesize/test_codesize_cxx_noexcept.size index ff65c81fe6324..4357180d28887 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.size +++ b/test/other/codesize/test_codesize_cxx_noexcept.size @@ -1 +1 @@ -132080 +132083 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.size b/test/other/codesize/test_codesize_cxx_wasmfs.size index 8577c65274f9b..206a908899546 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.size +++ b/test/other/codesize/test_codesize_cxx_wasmfs.size @@ -1 +1 @@ -169523 +169526 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index baae27d0ac518..3d81e9f241428 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7565 +7615 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index eb9943349b327..bba22d7ceab8d 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18574 +18617 From 5122e40ea137201f430e5c427c312778f68a19d3 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 4 Dec 2024 15:37:48 -0800 Subject: [PATCH 011/132] Convert instantiateAsync form callbacks to promises. NFC (#23066) I'll hoping to follow up with a conversion to using `await` here. The code size changes seem to be mostly a wash with some tests improving and others regressing by a few bytes. --- src/library_async.js | 4 +- src/preamble.js | 157 +++++++++--------- .../codesize/test_codesize_cxx_ctors1.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors1.jssize | 2 +- .../codesize/test_codesize_cxx_ctors2.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors2.jssize | 2 +- .../codesize/test_codesize_cxx_except.gzsize | 2 +- .../codesize/test_codesize_cxx_except.jssize | 2 +- .../test_codesize_cxx_except_wasm.gzsize | 2 +- .../test_codesize_cxx_except_wasm.jssize | 2 +- ...est_codesize_cxx_except_wasm_exnref.gzsize | 2 +- ...est_codesize_cxx_except_wasm_exnref.jssize | 2 +- .../codesize/test_codesize_cxx_lto.gzsize | 2 +- .../codesize/test_codesize_cxx_lto.jssize | 2 +- .../codesize/test_codesize_cxx_mangle.gzsize | 2 +- .../codesize/test_codesize_cxx_mangle.jssize | 2 +- .../test_codesize_cxx_noexcept.gzsize | 2 +- .../test_codesize_cxx_noexcept.jssize | 2 +- .../codesize/test_codesize_cxx_wasmfs.gzsize | 2 +- .../codesize/test_codesize_cxx_wasmfs.jssize | 2 +- .../codesize/test_codesize_files_js_fs.gzsize | 2 +- .../codesize/test_codesize_files_js_fs.jssize | 2 +- .../test_codesize_files_wasmfs.gzsize | 2 +- .../test_codesize_files_wasmfs.jssize | 2 +- .../codesize/test_codesize_hello_O0.gzsize | 2 +- .../codesize/test_codesize_hello_O0.jssize | 2 +- .../codesize/test_codesize_hello_O1.gzsize | 2 +- .../codesize/test_codesize_hello_O1.jssize | 2 +- .../codesize/test_codesize_hello_O2.gzsize | 2 +- .../codesize/test_codesize_hello_O2.jssize | 2 +- .../codesize/test_codesize_hello_O3.gzsize | 2 +- .../codesize/test_codesize_hello_O3.jssize | 2 +- .../codesize/test_codesize_hello_Os.gzsize | 2 +- .../codesize/test_codesize_hello_Os.jssize | 2 +- .../codesize/test_codesize_hello_Oz.gzsize | 2 +- .../codesize/test_codesize_hello_Oz.jssize | 2 +- .../test_codesize_hello_dylink.gzsize | 2 +- .../test_codesize_hello_dylink.jssize | 2 +- .../test_codesize_hello_export_nothing.gzsize | 2 +- .../test_codesize_hello_export_nothing.jssize | 2 +- .../test_codesize_hello_wasmfs.gzsize | 2 +- .../test_codesize_hello_wasmfs.jssize | 2 +- .../test_codesize_libcxxabi_message_O3.gzsize | 2 +- .../test_codesize_libcxxabi_message_O3.jssize | 2 +- ...ize_libcxxabi_message_O3_standalone.gzsize | 2 +- ...ize_libcxxabi_message_O3_standalone.jssize | 2 +- .../codesize/test_codesize_mem_O3.gzsize | 2 +- .../codesize/test_codesize_mem_O3.jssize | 2 +- .../codesize/test_codesize_mem_O3_grow.gzsize | 2 +- .../codesize/test_codesize_mem_O3_grow.jssize | 2 +- ...est_codesize_mem_O3_grow_standalone.gzsize | 2 +- ...est_codesize_mem_O3_grow_standalone.jssize | 2 +- .../test_codesize_mem_O3_standalone.gzsize | 2 +- .../test_codesize_mem_O3_standalone.jssize | 2 +- ...test_codesize_mem_O3_standalone_lib.gzsize | 2 +- ...test_codesize_mem_O3_standalone_lib.jssize | 2 +- ...est_codesize_mem_O3_standalone_narg.gzsize | 2 +- ...est_codesize_mem_O3_standalone_narg.jssize | 2 +- ...odesize_mem_O3_standalone_narg_flto.gzsize | 2 +- ...odesize_mem_O3_standalone_narg_flto.jssize | 2 +- .../codesize/test_codesize_minimal_64.gzsize | 2 +- .../codesize/test_codesize_minimal_64.jssize | 2 +- .../codesize/test_codesize_minimal_O0.gzsize | 2 +- .../codesize/test_codesize_minimal_O0.jssize | 2 +- .../codesize/test_codesize_minimal_O1.gzsize | 2 +- .../codesize/test_codesize_minimal_O1.jssize | 2 +- .../codesize/test_codesize_minimal_O2.gzsize | 2 +- .../codesize/test_codesize_minimal_O2.jssize | 2 +- .../codesize/test_codesize_minimal_O3.gzsize | 2 +- .../codesize/test_codesize_minimal_O3.jssize | 2 +- .../codesize/test_codesize_minimal_Os.gzsize | 2 +- .../codesize/test_codesize_minimal_Os.jssize | 2 +- .../test_codesize_minimal_Oz-ctors.gzsize | 2 +- .../test_codesize_minimal_Oz-ctors.jssize | 2 +- .../codesize/test_codesize_minimal_Oz.gzsize | 2 +- .../codesize/test_codesize_minimal_Oz.jssize | 2 +- .../test_codesize_minimal_pthreads.gzsize | 2 +- .../test_codesize_minimal_pthreads.jssize | 2 +- .../test_codesize_minimal_wasmfs.gzsize | 2 +- .../test_codesize_minimal_wasmfs.jssize | 2 +- test/other/test_unoptimized_code_size.js.size | 2 +- ...t_unoptimized_code_size_no_asserts.js.size | 2 +- .../test_unoptimized_code_size_strict.js.size | 2 +- test/test_other.py | 1 + 84 files changed, 164 insertions(+), 160 deletions(-) diff --git a/src/library_async.js b/src/library_async.js index 8d694439e147c..a3fbc151cb76f 100644 --- a/src/library_async.js +++ b/src/library_async.js @@ -520,9 +520,7 @@ addToLibrary({ var imports = {'primary': wasmExports}; // Replace '.wasm' suffix with '.deferred.wasm'. var deferred = wasmBinaryFile.slice(0, -5) + '.deferred.wasm'; - await new Promise((resolve) => { - instantiateAsync(null, deferred, imports, resolve); - }); + await instantiateAsync(null, deferred, imports); }, $Fibers__deps: ['$Asyncify', 'emscripten_stack_set_limits', '$stackRestore'], diff --git a/src/preamble.js b/src/preamble.js index 0d0d1146f26df..23ee003bb5592 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -771,54 +771,56 @@ function resetPrototype(constructor, attrs) { #endif #if WASM_ASYNC_COMPILATION -function instantiateArrayBuffer(binaryFile, imports, receiver) { +function instantiateArrayBuffer(binaryFile, imports) { #if USE_OFFSET_CONVERTER var savedBinary; #endif - return getBinaryPromise(binaryFile).then((binary) => { + return new Promise((resolve, reject) => { + getBinaryPromise(binaryFile).then((binary) => { #if USE_OFFSET_CONVERTER - savedBinary = binary; + savedBinary = binary; #endif - return WebAssembly.instantiate(binary, imports); + return WebAssembly.instantiate(binary, imports); #if USE_OFFSET_CONVERTER - }).then((instance) => { - // wasmOffsetConverter needs to be assigned before calling the receiver - // (receiveInstantiationResult). See comments below in instantiateAsync. - wasmOffsetConverter = new WasmOffsetConverter(savedBinary, instance.module); - return instance; + }).then((instance) => { + // wasmOffsetConverter needs to be assigned before calling resolve. + // See comments below in instantiateAsync. + wasmOffsetConverter = new WasmOffsetConverter(savedBinary, instance.module); + return instance; #endif - }).then(receiver, (reason) => { - err(`failed to asynchronously prepare wasm: ${reason}`); + }).then(resolve, (reason) => { + err(`failed to asynchronously prepare wasm: ${reason}`); #if WASM == 2 #if ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL - if (typeof location != 'undefined') { -#endif - // WebAssembly compilation failed, try running the JS fallback instead. - var search = location.search; - if (search.indexOf('_rwasm=0') < 0) { - location.href += (search ? search + '&' : '?') + '_rwasm=0'; - // Return here to avoid calling abort() below. The application - // still has a chance to start successfully do we don't want to - // trigger onAbort or onExit handlers. - return; - } + if (typeof location != 'undefined') { +#endif + // WebAssembly compilation failed, try running the JS fallback instead. + var search = location.search; + if (search.indexOf('_rwasm=0') < 0) { + location.href += (search ? search + '&' : '?') + '_rwasm=0'; + // Return here to avoid calling abort() below. The application + // still has a chance to start successfully do we don't want to + // trigger onAbort or onExit handlers. + return; + } #if ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL - } + } #endif #endif // WASM == 2 #if ASSERTIONS - // Warn on some common problems. - if (isFileURI(wasmBinaryFile)) { - err(`warning: Loading from a file URI (${wasmBinaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`); - } + // Warn on some common problems. + if (isFileURI(wasmBinaryFile)) { + err(`warning: Loading from a file URI (${wasmBinaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`); + } #endif - abort(reason); + abort(reason); + }); }); } -function instantiateAsync(binary, binaryFile, imports, callback) { +function instantiateAsync(binary, binaryFile, imports) { #if !SINGLE_FILE if (!binary && typeof WebAssembly.instantiateStreaming == 'function' && @@ -837,56 +839,59 @@ function instantiateAsync(binary, binaryFile, imports, callback) { !ENVIRONMENT_IS_NODE && #endif typeof fetch == 'function') { - return fetch(binaryFile, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}).then((response) => { - // Suppress closure warning here since the upstream definition for - // instantiateStreaming only allows Promise rather than - // an actual Response. - // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure is fixed. - /** @suppress {checkTypes} */ - var result = WebAssembly.instantiateStreaming(response, imports); + return new Promise((resolve) => { + fetch(binaryFile, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}).then((response) => { + // Suppress closure warning here since the upstream definition for + // instantiateStreaming only allows Promise rather than + // an actual Response. + // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure is fixed. + /** @suppress {checkTypes} */ + var result = WebAssembly.instantiateStreaming(response, imports); #if USE_OFFSET_CONVERTER - // We need the wasm binary for the offset converter. Clone the response - // in order to get its arrayBuffer (cloning should be more efficient - // than doing another entire request). - // (We must clone the response now in order to use it later, as if we - // try to clone it asynchronously lower down then we will get a - // "response was already consumed" error.) - var clonedResponsePromise = response.clone().arrayBuffer(); -#endif - - return result.then( -#if !USE_OFFSET_CONVERTER - callback, + // We need the wasm binary for the offset converter. Clone the response + // in order to get its arrayBuffer (cloning should be more efficient + // than doing another entire request). + // (We must clone the response now in order to use it later, as if we + // try to clone it asynchronously lower down then we will get a + // "response was already consumed" error.) + var clonedResponsePromise = response.clone().arrayBuffer(); +#endif + + result.then( +#if USE_OFFSET_CONVERTER + (instantiationResult) => { + // When using the offset converter, we must interpose here. First, + // the instantiation result must arrive (if it fails, the error + // handling later down will handle it). Once it arrives, we can + // initialize the offset converter. And only then is it valid to + // call receiveInstantiationResult, as that function will use the + // offset converter (in the case of pthreads, it will create the + // pthreads and send them the offsets along with the wasm instance). + + clonedResponsePromise.then((arrayBufferResult) => { + wasmOffsetConverter = new WasmOffsetConverter(new Uint8Array(arrayBufferResult), instantiationResult.module); + resolve(instantiationResult); + }, + (reason) => err(`failed to initialize offset-converter: ${reason}`) + ); + }, #else - function(instantiationResult) { - // When using the offset converter, we must interpose here. First, - // the instantiation result must arrive (if it fails, the error - // handling later down will handle it). Once it arrives, we can - // initialize the offset converter. And only then is it valid to - // call receiveInstantiationResult, as that function will use the - // offset converter (in the case of pthreads, it will create the - // pthreads and send them the offsets along with the wasm instance). - - clonedResponsePromise.then((arrayBufferResult) => { - wasmOffsetConverter = new WasmOffsetConverter(new Uint8Array(arrayBufferResult), instantiationResult.module); - callback(instantiationResult); - }, - (reason) => err(`failed to initialize offset-converter: ${reason}`) - ); - }, -#endif - function(reason) { - // We expect the most common failure cause to be a bad MIME type for the binary, - // in which case falling back to ArrayBuffer instantiation should work. - err(`wasm streaming compile failed: ${reason}`); - err('falling back to ArrayBuffer instantiation'); - return instantiateArrayBuffer(binaryFile, imports, callback); - }); + resolve, +#endif + (reason) => { + // We expect the most common failure cause to be a bad MIME type for the binary, + // in which case falling back to ArrayBuffer instantiation should work. + err(`wasm streaming compile failed: ${reason}`); + err('falling back to ArrayBuffer instantiation'); + return resolve(instantiateArrayBuffer(binaryFile, imports)); + } + ); + }); }); } #endif - return instantiateArrayBuffer(binaryFile, imports, callback); + return instantiateArrayBuffer(binaryFile, imports); } #endif // WASM_ASYNC_COMPILATION @@ -1097,12 +1102,12 @@ function createWasm() { #if RUNTIME_DEBUG dbg('asynchronously preparing wasm'); #endif + instantiateAsync(wasmBinary, wasmBinaryFile, info).then(receiveInstantiationResult) #if MODULARIZE // If instantiation fails, reject the module ready promise. - instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject); -#else - instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult); + .catch(readyPromiseReject) #endif + ; #if LOAD_SOURCE_MAP getSourceMapPromise().then(receiveSourceMapJSON); #endif diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 737757b6409f6..8da928c5d2d53 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8479 +8484 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index ca87a75eb9c1a..c522ee597bbbe 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20708 +20746 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index 357af50996d0e..e480013c31d9e 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8462 +8467 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 84cd635d055dc..79cb58b0bde97 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20676 +20714 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 5f3277f4dd40a..44339efbd26d2 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9504 +9507 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 9c1c07ddc17d1..f98373a5e5f87 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24551 +24589 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index 88ab2a149bf9a..b4742a2b4cad8 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8447 +8449 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index 6129f6408774a..827efd3e1a277 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20602 +20640 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index 88ab2a149bf9a..b4742a2b4cad8 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8447 +8449 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index 6129f6408774a..827efd3e1a277 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20602 +20640 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 4c40b3f47ef26..c71bb725b3810 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8377 +8379 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 4aba8455d95b6..7aeee87e01016 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20286 +20324 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index 8f0fc0c298e67..ba03e9d4fd59f 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9506 +9510 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 9c1c07ddc17d1..f98373a5e5f87 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24551 +24589 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 737757b6409f6..8da928c5d2d53 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8479 +8484 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index ca87a75eb9c1a..c522ee597bbbe 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20708 +20746 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize index 8a5fbb7712474..b2c038c3bdd06 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize @@ -1 +1 @@ -3893 +3900 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.jssize b/test/other/codesize/test_codesize_cxx_wasmfs.jssize index 513551775cadd..203dde511d62d 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.jssize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.jssize @@ -1 +1 @@ -8680 +8718 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index 3d81e9f241428..d388efbc70aa0 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7615 +7622 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index bba22d7ceab8d..82ba21cc38d84 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18617 +18655 diff --git a/test/other/codesize/test_codesize_files_wasmfs.gzsize b/test/other/codesize/test_codesize_files_wasmfs.gzsize index aeaee565f9610..ce89b3e410a0f 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_files_wasmfs.gzsize @@ -1 +1 @@ -2985 +2992 diff --git a/test/other/codesize/test_codesize_files_wasmfs.jssize b/test/other/codesize/test_codesize_files_wasmfs.jssize index 21faf3262f93b..394a86d56efde 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.jssize +++ b/test/other/codesize/test_codesize_files_wasmfs.jssize @@ -1 +1 @@ -6316 +6354 diff --git a/test/other/codesize/test_codesize_hello_O0.gzsize b/test/other/codesize/test_codesize_hello_O0.gzsize index a3006f77bfce6..64595bbb74d9a 100644 --- a/test/other/codesize/test_codesize_hello_O0.gzsize +++ b/test/other/codesize/test_codesize_hello_O0.gzsize @@ -1 +1 @@ -8037 +8054 diff --git a/test/other/codesize/test_codesize_hello_O0.jssize b/test/other/codesize/test_codesize_hello_O0.jssize index eae6175bae62d..e81ba058fadf7 100644 --- a/test/other/codesize/test_codesize_hello_O0.jssize +++ b/test/other/codesize/test_codesize_hello_O0.jssize @@ -1 +1 @@ -21395 +21488 diff --git a/test/other/codesize/test_codesize_hello_O1.gzsize b/test/other/codesize/test_codesize_hello_O1.gzsize index 681f6fefb05e3..b3a37ac4b74ed 100644 --- a/test/other/codesize/test_codesize_hello_O1.gzsize +++ b/test/other/codesize/test_codesize_hello_O1.gzsize @@ -1 +1 @@ -2814 +2825 diff --git a/test/other/codesize/test_codesize_hello_O1.jssize b/test/other/codesize/test_codesize_hello_O1.jssize index dd544fe523cf2..64aee72ade65d 100644 --- a/test/other/codesize/test_codesize_hello_O1.jssize +++ b/test/other/codesize/test_codesize_hello_O1.jssize @@ -1 +1 @@ -7012 +7111 diff --git a/test/other/codesize/test_codesize_hello_O2.gzsize b/test/other/codesize/test_codesize_hello_O2.gzsize index 445f349d2a0d7..ea908ff33b176 100644 --- a/test/other/codesize/test_codesize_hello_O2.gzsize +++ b/test/other/codesize/test_codesize_hello_O2.gzsize @@ -1 +1 @@ -2497 +2503 diff --git a/test/other/codesize/test_codesize_hello_O2.jssize b/test/other/codesize/test_codesize_hello_O2.jssize index 4ef41da9c4e8b..bcdfe2d406799 100644 --- a/test/other/codesize/test_codesize_hello_O2.jssize +++ b/test/other/codesize/test_codesize_hello_O2.jssize @@ -1 +1 @@ -5025 +5063 diff --git a/test/other/codesize/test_codesize_hello_O3.gzsize b/test/other/codesize/test_codesize_hello_O3.gzsize index 1dd2b4139edbc..7914187fc0a88 100644 --- a/test/other/codesize/test_codesize_hello_O3.gzsize +++ b/test/other/codesize/test_codesize_hello_O3.gzsize @@ -1 +1 @@ -2414 +2416 diff --git a/test/other/codesize/test_codesize_hello_O3.jssize b/test/other/codesize/test_codesize_hello_O3.jssize index d05b84d011247..278937feb69f9 100644 --- a/test/other/codesize/test_codesize_hello_O3.jssize +++ b/test/other/codesize/test_codesize_hello_O3.jssize @@ -1 +1 @@ -4871 +4909 diff --git a/test/other/codesize/test_codesize_hello_Os.gzsize b/test/other/codesize/test_codesize_hello_Os.gzsize index 1dd2b4139edbc..7914187fc0a88 100644 --- a/test/other/codesize/test_codesize_hello_Os.gzsize +++ b/test/other/codesize/test_codesize_hello_Os.gzsize @@ -1 +1 @@ -2414 +2416 diff --git a/test/other/codesize/test_codesize_hello_Os.jssize b/test/other/codesize/test_codesize_hello_Os.jssize index d05b84d011247..278937feb69f9 100644 --- a/test/other/codesize/test_codesize_hello_Os.jssize +++ b/test/other/codesize/test_codesize_hello_Os.jssize @@ -1 +1 @@ -4871 +4909 diff --git a/test/other/codesize/test_codesize_hello_Oz.gzsize b/test/other/codesize/test_codesize_hello_Oz.gzsize index e5d3207a3d6f0..38ac9c5946d9c 100644 --- a/test/other/codesize/test_codesize_hello_Oz.gzsize +++ b/test/other/codesize/test_codesize_hello_Oz.gzsize @@ -1 +1 @@ -2394 +2398 diff --git a/test/other/codesize/test_codesize_hello_Oz.jssize b/test/other/codesize/test_codesize_hello_Oz.jssize index 436a6f19c62de..c4fa14144238e 100644 --- a/test/other/codesize/test_codesize_hello_Oz.jssize +++ b/test/other/codesize/test_codesize_hello_Oz.jssize @@ -1 +1 @@ -4838 +4876 diff --git a/test/other/codesize/test_codesize_hello_dylink.gzsize b/test/other/codesize/test_codesize_hello_dylink.gzsize index 9c0b82b6a7627..6b25ae66921df 100644 --- a/test/other/codesize/test_codesize_hello_dylink.gzsize +++ b/test/other/codesize/test_codesize_hello_dylink.gzsize @@ -1 +1 @@ -6297 +6304 diff --git a/test/other/codesize/test_codesize_hello_dylink.jssize b/test/other/codesize/test_codesize_hello_dylink.jssize index 325502d1fc6b4..82142080ff89b 100644 --- a/test/other/codesize/test_codesize_hello_dylink.jssize +++ b/test/other/codesize/test_codesize_hello_dylink.jssize @@ -1 +1 @@ -13856 +13894 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.gzsize b/test/other/codesize/test_codesize_hello_export_nothing.gzsize index 288be4285a70c..adb88b75522e4 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.gzsize +++ b/test/other/codesize/test_codesize_hello_export_nothing.gzsize @@ -1 +1 @@ -1760 +1772 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.jssize b/test/other/codesize/test_codesize_hello_export_nothing.jssize index e86e9f7fda107..db606a3345d7f 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.jssize +++ b/test/other/codesize/test_codesize_hello_export_nothing.jssize @@ -1 +1 @@ -3722 +3760 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.gzsize b/test/other/codesize/test_codesize_hello_wasmfs.gzsize index 1dd2b4139edbc..7914187fc0a88 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_hello_wasmfs.gzsize @@ -1 +1 @@ -2414 +2416 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.jssize b/test/other/codesize/test_codesize_hello_wasmfs.jssize index d05b84d011247..278937feb69f9 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.jssize +++ b/test/other/codesize/test_codesize_hello_wasmfs.jssize @@ -1 +1 @@ -4871 +4909 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize index e67fcb2e19a0b..90e525730040d 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize @@ -1 +1 @@ -1970 +1977 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize index 784d3a886670a..6816d34c5a813 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize @@ -1 +1 @@ -4099 +4137 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize index af1b4b39888c2..e355f6dc2c905 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize @@ -1 +1 @@ -2003 +2013 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize index 1e3e300877006..5255d8eda08aa 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize @@ -1 +1 @@ -4146 +4184 diff --git a/test/other/codesize/test_codesize_mem_O3.gzsize b/test/other/codesize/test_codesize_mem_O3.gzsize index 6d92b9495f826..dcce86ad24c95 100644 --- a/test/other/codesize/test_codesize_mem_O3.gzsize +++ b/test/other/codesize/test_codesize_mem_O3.gzsize @@ -1 +1 @@ -2431 +2438 diff --git a/test/other/codesize/test_codesize_mem_O3.jssize b/test/other/codesize/test_codesize_mem_O3.jssize index b06d635af4c41..e0fd17de85ac5 100644 --- a/test/other/codesize/test_codesize_mem_O3.jssize +++ b/test/other/codesize/test_codesize_mem_O3.jssize @@ -1 +1 @@ -5013 +5051 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.gzsize b/test/other/codesize/test_codesize_mem_O3_grow.gzsize index f5f09cbbb8f59..11346f5d69b07 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow.gzsize @@ -1 +1 @@ -2578 +2582 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.jssize b/test/other/codesize/test_codesize_mem_O3_grow.jssize index fa33584388b49..66ff790e932f6 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow.jssize @@ -1 +1 @@ -5295 +5333 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize index 869c6c230177d..20c65f21df41d 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize @@ -1 +1 @@ -2273 +2279 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize index b698f5e622c21..383fa505c5afe 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize @@ -1 +1 @@ -4702 +4740 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize index 137c70ae46487..c29e53f81ddfb 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize @@ -1 +1 @@ -2239 +2248 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_standalone.jssize index 5becefaad6486..ae6d064561fe5 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.jssize @@ -1 +1 @@ -4632 +4670 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize index ef0a2ad63226b..44173d5cb77fe 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize @@ -1 +1 @@ -1987 +1996 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize index 5d4a7710efc0f..a4ca075180c97 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize @@ -1 +1 @@ -4150 +4188 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize index af1b4b39888c2..e355f6dc2c905 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize @@ -1 +1 @@ -2003 +2013 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize index 1e3e300877006..5255d8eda08aa 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize @@ -1 +1 @@ -4146 +4184 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize index af1b4b39888c2..e355f6dc2c905 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize @@ -1 +1 @@ -2003 +2013 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize index 1e3e300877006..5255d8eda08aa 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize @@ -1 +1 @@ -4146 +4184 diff --git a/test/other/codesize/test_codesize_minimal_64.gzsize b/test/other/codesize/test_codesize_minimal_64.gzsize index 641d5f59ecacf..f768f5839707f 100644 --- a/test/other/codesize/test_codesize_minimal_64.gzsize +++ b/test/other/codesize/test_codesize_minimal_64.gzsize @@ -1 +1 @@ -1524 +1535 diff --git a/test/other/codesize/test_codesize_minimal_64.jssize b/test/other/codesize/test_codesize_minimal_64.jssize index 9af21432425ab..b860fd703a3de 100644 --- a/test/other/codesize/test_codesize_minimal_64.jssize +++ b/test/other/codesize/test_codesize_minimal_64.jssize @@ -1 +1 @@ -3179 +3216 diff --git a/test/other/codesize/test_codesize_minimal_O0.gzsize b/test/other/codesize/test_codesize_minimal_O0.gzsize index 55f59784d48b1..0590e000d1be1 100644 --- a/test/other/codesize/test_codesize_minimal_O0.gzsize +++ b/test/other/codesize/test_codesize_minimal_O0.gzsize @@ -1 +1 @@ -6570 +6584 diff --git a/test/other/codesize/test_codesize_minimal_O0.jssize b/test/other/codesize/test_codesize_minimal_O0.jssize index 5ef3302d75df9..406ffb9d96d4c 100644 --- a/test/other/codesize/test_codesize_minimal_O0.jssize +++ b/test/other/codesize/test_codesize_minimal_O0.jssize @@ -1 +1 @@ -17544 +17637 diff --git a/test/other/codesize/test_codesize_minimal_O1.gzsize b/test/other/codesize/test_codesize_minimal_O1.gzsize index 4f6811f469b22..8caa513e2687d 100644 --- a/test/other/codesize/test_codesize_minimal_O1.gzsize +++ b/test/other/codesize/test_codesize_minimal_O1.gzsize @@ -1 +1 @@ -1597 +1608 diff --git a/test/other/codesize/test_codesize_minimal_O1.jssize b/test/other/codesize/test_codesize_minimal_O1.jssize index 1f6788945a43a..a91ca4c6b7bb5 100644 --- a/test/other/codesize/test_codesize_minimal_O1.jssize +++ b/test/other/codesize/test_codesize_minimal_O1.jssize @@ -1 +1 @@ -3726 +3823 diff --git a/test/other/codesize/test_codesize_minimal_O2.gzsize b/test/other/codesize/test_codesize_minimal_O2.gzsize index 4b7816b5720e5..ac48d993bb8a5 100644 --- a/test/other/codesize/test_codesize_minimal_O2.gzsize +++ b/test/other/codesize/test_codesize_minimal_O2.gzsize @@ -1 +1 @@ -1452 +1462 diff --git a/test/other/codesize/test_codesize_minimal_O2.jssize b/test/other/codesize/test_codesize_minimal_O2.jssize index 049730c1f78a4..abe0cf822d59c 100644 --- a/test/other/codesize/test_codesize_minimal_O2.jssize +++ b/test/other/codesize/test_codesize_minimal_O2.jssize @@ -1 +1 @@ -2884 +2921 diff --git a/test/other/codesize/test_codesize_minimal_O3.gzsize b/test/other/codesize/test_codesize_minimal_O3.gzsize index 06cf2f9c460e0..b322e68302d81 100644 --- a/test/other/codesize/test_codesize_minimal_O3.gzsize +++ b/test/other/codesize/test_codesize_minimal_O3.gzsize @@ -1 +1 @@ -1417 +1427 diff --git a/test/other/codesize/test_codesize_minimal_O3.jssize b/test/other/codesize/test_codesize_minimal_O3.jssize index 28520983963f1..8afc5d50c386e 100644 --- a/test/other/codesize/test_codesize_minimal_O3.jssize +++ b/test/other/codesize/test_codesize_minimal_O3.jssize @@ -1 +1 @@ -2834 +2871 diff --git a/test/other/codesize/test_codesize_minimal_Os.gzsize b/test/other/codesize/test_codesize_minimal_Os.gzsize index 06cf2f9c460e0..b322e68302d81 100644 --- a/test/other/codesize/test_codesize_minimal_Os.gzsize +++ b/test/other/codesize/test_codesize_minimal_Os.gzsize @@ -1 +1 @@ -1417 +1427 diff --git a/test/other/codesize/test_codesize_minimal_Os.jssize b/test/other/codesize/test_codesize_minimal_Os.jssize index 28520983963f1..8afc5d50c386e 100644 --- a/test/other/codesize/test_codesize_minimal_Os.jssize +++ b/test/other/codesize/test_codesize_minimal_Os.jssize @@ -1 +1 @@ -2834 +2871 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize index 08507bb20953a..19ef72cd81422 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize @@ -1 +1 @@ -1409 +1419 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize index eebd44e48e8dd..47f06d4699cd1 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize @@ -1 +1 @@ -2819 +2856 diff --git a/test/other/codesize/test_codesize_minimal_Oz.gzsize b/test/other/codesize/test_codesize_minimal_Oz.gzsize index 06cf2f9c460e0..b322e68302d81 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz.gzsize @@ -1 +1 @@ -1417 +1427 diff --git a/test/other/codesize/test_codesize_minimal_Oz.jssize b/test/other/codesize/test_codesize_minimal_Oz.jssize index 28520983963f1..8afc5d50c386e 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz.jssize @@ -1 +1 @@ -2834 +2871 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.gzsize b/test/other/codesize/test_codesize_minimal_pthreads.gzsize index 31a1f807b4325..e824891ca6709 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.gzsize +++ b/test/other/codesize/test_codesize_minimal_pthreads.gzsize @@ -1 +1 @@ -4218 +4226 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.jssize b/test/other/codesize/test_codesize_minimal_pthreads.jssize index 5eb0c72aab653..8aae358324bf1 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.jssize +++ b/test/other/codesize/test_codesize_minimal_pthreads.jssize @@ -1 +1 @@ -8696 +8734 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize index 06cf2f9c460e0..b322e68302d81 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize @@ -1 +1 @@ -1417 +1427 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.jssize b/test/other/codesize/test_codesize_minimal_wasmfs.jssize index 28520983963f1..8afc5d50c386e 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.jssize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.jssize @@ -1 +1 @@ -2834 +2871 diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index 6dbbbc2f07ed9..3047c693644af 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -54944 +55052 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index 878b3a1ba2167..5b0b3eb9613cd 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -30598 +30698 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index 45c473ad78361..3e047c18b238a 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -53740 +53848 diff --git a/test/test_other.py b/test/test_other.py index a8a8316f074c6..6af58d3722262 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -4922,6 +4922,7 @@ def test(expected, opts): # legacy + disabling wasm works test('hello, world!', ['-sLEGACY_VM_SUPPORT', '-sWASM=0']) + @crossplatform def test_on_abort(self): expected_output = 'Module.onAbort was called' From f021c07d3b3fb17dd823e56594896f8e7e54f5eb Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 5 Dec 2024 01:08:22 +0100 Subject: [PATCH 012/132] Make readdir on /proc/self/fd work (#23073) --- src/library_fs.js | 9 +++++++++ test/fs/test_proc_self_fd.c | 2 -- test/fs/test_proc_self_fd.out | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/library_fs.js b/src/library_fs.js index 3bfa8f2675477..d83505db879a7 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -1393,6 +1393,9 @@ FS.staticInit(); FS.mount({ mount() { var node = FS.createNode(proc_self, 'fd', {{{ cDefs.S_IFDIR | 0o777 }}}, {{{ cDefs.S_IXUGO }}}); + node.stream_ops = { + llseek: MEMFS.stream_ops.llseek, + }; node.node_ops = { lookup(parent, name) { var fd = +name; @@ -1401,9 +1404,15 @@ FS.staticInit(); parent: null, mount: { mountpoint: 'fake' }, node_ops: { readlink: () => stream.path }, + id: fd + 1, }; ret.parent = ret; // make it look like a simple root node return ret; + }, + readdir() { + return Array.from(FS.streams.entries()) + .filter(([k, v]) => v) + .map(([k, v]) => k.toString()); } }; return node; diff --git a/test/fs/test_proc_self_fd.c b/test/fs/test_proc_self_fd.c index 13ff19c1ae3ca..582725693f45e 100644 --- a/test/fs/test_proc_self_fd.c +++ b/test/fs/test_proc_self_fd.c @@ -14,8 +14,6 @@ int main(int argc, char* argv[]) { struct dirent *entry; while ((entry = readdir(d))) { printf("entry: %s\n", entry->d_name); - printf("unexpected success reading directory!"); - return 1; } closedir(d); diff --git a/test/fs/test_proc_self_fd.out b/test/fs/test_proc_self_fd.out index 2c53cdf6b16f2..0d8d377ed7488 100644 --- a/test/fs/test_proc_self_fd.out +++ b/test/fs/test_proc_self_fd.out @@ -1,2 +1,6 @@ +entry: 0 +entry: 1 +entry: 2 +entry: 3 fd0: /dev/tty done From a17177639019d5456033537cee81450428499e37 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 4 Dec 2024 16:17:27 -0800 Subject: [PATCH 013/132] Rebaseline codesize expectations. NFC --- test/other/codesize/test_codesize_cxx_ctors1.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors1.jssize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.jssize | 2 +- test/other/codesize/test_codesize_cxx_except.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.jssize | 2 +- test/other/codesize/test_codesize_cxx_mangle.gzsize | 2 +- test/other/codesize/test_codesize_cxx_mangle.jssize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.gzsize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.jssize | 2 +- test/other/codesize/test_codesize_files_js_fs.gzsize | 2 +- test/other/codesize/test_codesize_files_js_fs.jssize | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 8da928c5d2d53..bb8f89dd9b373 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8484 +8534 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index c522ee597bbbe..136b674031567 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20746 +20856 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index e480013c31d9e..f6eb0bf4d3019 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8467 +8518 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 79cb58b0bde97..d55f09ef1f4c5 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20714 +20824 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 44339efbd26d2..8c22ca2a0d9bb 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9507 +9563 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index f98373a5e5f87..4024e9f7afaa1 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24589 +24699 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index b4742a2b4cad8..b28927a921976 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8449 +8500 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index 827efd3e1a277..229ccce462f7b 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20640 +20750 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index b4742a2b4cad8..b28927a921976 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8449 +8500 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index 827efd3e1a277..229ccce462f7b 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20640 +20750 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index c71bb725b3810..888760ce9982e 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8379 +8432 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 7aeee87e01016..5af65416d58f7 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20324 +20434 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index ba03e9d4fd59f..b686067ce3b9b 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9510 +9564 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index f98373a5e5f87..4024e9f7afaa1 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24589 +24699 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 8da928c5d2d53..bb8f89dd9b373 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8484 +8534 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index c522ee597bbbe..136b674031567 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20746 +20856 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index d388efbc70aa0..f652e57d21720 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7622 +7674 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index 82ba21cc38d84..44bd1d26a1359 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18655 +18765 From a335879f283a7d309438e346dcf0459054926ca6 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 4 Dec 2024 16:27:09 -0800 Subject: [PATCH 014/132] Move changelog entry from #22998. NFC (#23079) --- ChangeLog.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index cc2a2ed3151c5..13cacf0c6e90c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -20,13 +20,13 @@ See docs/process.md for more on how version tagging works. 3.1.74 (in development) ----------------------- +- The file system was updated to independently track atime, mtime and ctime + instead of using the same time for all three. (#22998) 3.1.73 - 11/28/24 ----------------- - libunwind was updated to LLVM 19.1.4. (#22394) - mimalloc was updated to 2.1.7. (#21548) -- The file system was updated to independently track atime, mtime and ctime - instead of using the same time for all three. (#22998) 3.1.72 - 11/19/24 ----------------- From 78c968b0f9f670caf437eac24d715e885b29b275 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 4 Dec 2024 16:40:08 -0800 Subject: [PATCH 015/132] Bump minimum supported chrome version from 32 to 33 (#23077) This allows us to remove the promise polyfill: https://caniuse.com/promises --- ChangeLog.md | 1 + .../tools_reference/settings_reference.rst | 2 +- src/polyfill/promise.js | 274 ------------------ src/settings.js | 2 +- src/shell.js | 8 - test/test_other.py | 25 +- tools/feature_matrix.py | 2 +- 7 files changed, 5 insertions(+), 309 deletions(-) delete mode 100644 src/polyfill/promise.js diff --git a/ChangeLog.md b/ChangeLog.md index 13cacf0c6e90c..39938f12e5a7a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -22,6 +22,7 @@ See docs/process.md for more on how version tagging works. ----------------------- - The file system was updated to independently track atime, mtime and ctime instead of using the same time for all three. (#22998) +- The minimum supported chrome version was bumped from 32 to 33. (#23077) 3.1.73 - 11/28/24 ----------------- diff --git a/site/source/docs/tools_reference/settings_reference.rst b/site/source/docs/tools_reference/settings_reference.rst index b8a971f917e71..902920c03c9b4 100644 --- a/site/source/docs/tools_reference/settings_reference.rst +++ b/site/source/docs/tools_reference/settings_reference.rst @@ -2939,7 +2939,7 @@ This setting also applies to modern Chromium-based Edge, which shares version numbers with Chrome. Chrome 85 was released on 2020-08-25. MAX_INT (0x7FFFFFFF, or -1) specifies that target is not supported. -Minimum supported value is 32, which was released on 2014-01-04. +Minimum supported value is 33, which was released on 2014-02-18. Default value: 85 diff --git a/src/polyfill/promise.js b/src/polyfill/promise.js deleted file mode 100644 index 461be88333461..0000000000000 --- a/src/polyfill/promise.js +++ /dev/null @@ -1,274 +0,0 @@ -// Promise polyfill from https://github.com/taylorhakes/promise-polyfill -// License: -//============================================================================== -// Copyright (c) 2014 Taylor Hakes -// Copyright (c) 2014 Forbes Lindesay -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -//============================================================================== - -#if !POLYFILL -#error "this file should never be included unless POLYFILL is set" -#endif - -/** @suppress{duplicate} This is already defined in from Closure's built-in - externs.zip//es6.js, Closure should not yell when seeing this again. */ -var Promise = (function() { - function noop() {} - - // Polyfill for Function.prototype.bind - function bind(fn, thisArg) { - return function() { - fn.apply(thisArg, arguments); - }; - } - - /** - * @constructor - * @param {Function} fn - */ - function Promise(fn) { - if (!(this instanceof Promise)) - throw new TypeError('Promises must be constructed via new'); - if (typeof fn != 'function') throw new TypeError('not a function'); - /** @type {!number} */ - this._state = 0; - /** @type {!boolean} */ - this._handled = false; - /** @type {Promise|undefined} */ - this._value = undefined; - /** @type {!Array} */ - this._deferreds = []; - - doResolve(fn, this); - } - - function handle(self, deferred) { - while (self._state === 3) { - self = self._value; - } - if (self._state === 0) { - self._deferreds.push(deferred); - return; - } - self._handled = true; - Promise._immediateFn(function() { - var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected; - if (cb === null) { - (self._state === 1 ? resolve : reject)(deferred.promise, self._value); - return; - } - var ret; - try { - ret = cb(self._value); - } catch (e) { - reject(deferred.promise, e); - return; - } - resolve(deferred.promise, ret); - }); - } - - function resolve(self, newValue) { - try { - // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure - if (newValue === self) - throw new TypeError('A promise cannot be resolved with itself.'); - if ( - newValue && - (typeof newValue == 'object' || typeof newValue == 'function') - ) { - var then = newValue.then; - if (newValue instanceof Promise) { - self._state = 3; - self._value = newValue; - finale(self); - return; - } else if (typeof then == 'function') { - doResolve(bind(then, newValue), self); - return; - } - } - self._state = 1; - self._value = newValue; - finale(self); - } catch (e) { - reject(self, e); - } - } - - function reject(self, newValue) { - self._state = 2; - self._value = newValue; - finale(self); - } - - function finale(self) { - if (self._state === 2 && self._deferreds.length === 0) { - Promise._immediateFn(function() { - if (!self._handled) { - Promise._unhandledRejectionFn(self._value); - } - }); - } - - for (var i = 0, len = self._deferreds.length; i < len; i++) { - handle(self, self._deferreds[i]); - } - self._deferreds = null; - } - - /** - * @constructor - */ - function Handler(onFulfilled, onRejected, promise) { - this.onFulfilled = typeof onFulfilled == 'function' ? onFulfilled : null; - this.onRejected = typeof onRejected == 'function' ? onRejected : null; - this.promise = promise; - } - - /** - * Take a potentially misbehaving resolver function and make sure - * onFulfilled and onRejected are only called once. - * - * Makes no guarantees about asynchrony. - */ - function doResolve(fn, self) { - var done = false; - try { - fn( - function(value) { - if (done) return; - done = true; - resolve(self, value); - }, - function(reason) { - if (done) return; - done = true; - reject(self, reason); - } - ); - } catch (ex) { - if (done) return; - done = true; - reject(self, ex); - } - } - - Promise.prototype['catch'] = function(onRejected) { - return this.then(null, onRejected); - }; - - Promise.prototype.then = function(onFulfilled, onRejected) { - // @ts-ignore - var prom = new this.constructor(noop); - - handle(this, new Handler(onFulfilled, onRejected, prom)); - return prom; - }; - - Promise.all = function(arr) { - return new Promise(function(resolve, reject) { - if (!Array.isArray(arr)) { - return reject(new TypeError('Promise.all accepts an array')); - } - - var args = Array.prototype.slice.call(arr); - if (args.length === 0) return resolve([]); - var remaining = args.length; - - function res(i, val) { - try { - if (val && (typeof val == 'object' || typeof val == 'function')) { - var then = val.then; - if (typeof then == 'function') { - then.call( - val, - function(val) { - res(i, val); - }, - reject - ); - return; - } - } - args[i] = val; - if (--remaining === 0) { - resolve(args); - } - } catch (ex) { - reject(ex); - } - } - - for (var i = 0; i < args.length; i++) { - res(i, args[i]); - } - }); - }; - - Promise.resolve = function(value) { - if (value && typeof value == 'object' && value.constructor == Promise) { - return value; - } - - return new Promise(function(resolve) { - resolve(value); - }); - }; - - Promise.reject = function(value) { - return new Promise(function(resolve, reject) { - reject(value); - }); - }; - - Promise.race = function(arr) { - return new Promise(function(resolve, reject) { - if (!Array.isArray(arr)) { - return reject(new TypeError('Promise.race accepts an array')); - } - - for (var i = 0, len = arr.length; i < len; i++) { - Promise.resolve(arr[i]).then(resolve, reject); - } - }); - }; - - // Use polyfill for setImmediate for performance gains - Promise._immediateFn = - // @ts-ignore - (typeof setImmediate == 'function' && - function(fn) { - // @ts-ignore - setImmediate(fn); - }) || - function(fn) { - setTimeout(fn, 0); // XXX EMSCRIPTEN: just use setTimeout - }; - - Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) { - if (typeof console != 'undefined' && console) { - console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console - } - }; - - return Promise; -})(); - diff --git a/src/settings.js b/src/settings.js index e009a98c907e7..6df46f5572693 100644 --- a/src/settings.js +++ b/src/settings.js @@ -1919,7 +1919,7 @@ var MIN_SAFARI_VERSION = 140100; // numbers with Chrome. // Chrome 85 was released on 2020-08-25. // MAX_INT (0x7FFFFFFF, or -1) specifies that target is not supported. -// Minimum supported value is 32, which was released on 2014-01-04. +// Minimum supported value is 33, which was released on 2014-02-18. // [link] var MIN_CHROME_VERSION = 85; diff --git a/src/shell.js b/src/shell.js index 6d4b2431b247f..d25aeb85bcee8 100644 --- a/src/shell.js +++ b/src/shell.js @@ -34,14 +34,6 @@ var Module = typeof {{{ EXPORT_NAME }}} != 'undefined' ? {{{ EXPORT_NAME }}} : { #endif // USE_CLOSURE_COMPILER #if POLYFILL -#if ((MAYBE_WASM2JS && WASM != 2) || MODULARIZE) && (MIN_CHROME_VERSION < 33 || MIN_FIREFOX_VERSION < 29 || MIN_SAFARI_VERSION < 80000) -// Include a Promise polyfill for legacy browsers. This is needed either for -// wasm2js, where we polyfill the wasm API which needs Promises, or when using -// modularize which creates a Promise for when the module is ready. -// See https://caniuse.com/#feat=promises -#include "polyfill/promise.js" -#endif - #if MIN_CHROME_VERSION < 45 || MIN_FIREFOX_VERSION < 34 || MIN_SAFARI_VERSION < 90000 // See https://caniuse.com/mdn-javascript_builtins_object_assign #include "polyfill/objassign.js" diff --git a/test/test_other.py b/test/test_other.py index 6af58d3722262..dfdff53977072 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -12427,29 +12427,6 @@ def test_standalone_syscalls(self): for engine in config.WASM_ENGINES: self.assertContained(expected, self.run_js('test.wasm', engine)) - @parameterized({ - 'wasm2js': (['-sWASM=0'],), - 'modularize': (['-sMODULARIZE', '--extern-post-js', test_file('modularize_post_js.js')],), - }) - def test_promise_polyfill(self, constant_args): - def test(args, expect_fail): - # legacy browsers may lack Promise, which wasm2js depends on. see what - # happens when we kill the global Promise function. - self.run_process([EMCC, test_file('hello_world.c')] + constant_args + args) - js = read_file('a.out.js') - create_file('a.out.js', 'Promise = undefined;\n' + js) - return self.run_js('a.out.js', assert_returncode=NON_ZERO if expect_fail else 0) - - # we fail without legacy support - test([], expect_fail=True) - - # but work with it - output = test(['-sLEGACY_VM_SUPPORT'], expect_fail=False) - self.assertContained('hello, world!', output) - - # unless we explicitly disable polyfills - test(['-sLEGACY_VM_SUPPORT', '-sNO_POLYFILL'], expect_fail=True) - @parameterized({ '': ([],), 'assertions': (['-sASSERTIONS'],), @@ -15265,7 +15242,7 @@ def test_no_extra_output(self): def test_browser_too_old(self): err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sMIN_CHROME_VERSION=10']) - self.assertContained('emcc: error: MIN_CHROME_VERSION older than 32 is not supported', err) + self.assertContained('emcc: error: MIN_CHROME_VERSION older than 33 is not supported', err) def test_js_only_settings(self): err = self.run_process([EMCC, test_file('hello_world.c'), '-o', 'foo.wasm', '-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=emscripten_get_heap_max'], stderr=PIPE).stderr diff --git a/tools/feature_matrix.py b/tools/feature_matrix.py index 53ee6f66ce716..0757724ccf7e7 100644 --- a/tools/feature_matrix.py +++ b/tools/feature_matrix.py @@ -18,7 +18,7 @@ # Oldest support browser versions. These have been set somewhat # arbitrarily for now. # TODO(sbc): Design a of policy for managing these values. -OLDEST_SUPPORTED_CHROME = 32 +OLDEST_SUPPORTED_CHROME = 33 OLDEST_SUPPORTED_FIREFOX = 34 OLDEST_SUPPORTED_SAFARI = 90000 # 10.19.0 is the oldest version of node that we do any testing with. From a6ecc86b430dd26a2f8af73c0808d73cb9211d15 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 4 Dec 2024 20:50:16 -0800 Subject: [PATCH 016/132] Cleanup test_remove. NFC (#23081) - Convert to C. - Move to `test/stdio` This test was originally added in c008b1129 and is not specific to C++ cstdio and was the only file in this directory. Also remove the cleanup code. See #23003. --- .../test_remove.cpp => stdio/test_remove.c} | 26 ++++++------------- test/{cstdio => stdio}/test_remove.out | 0 test/test_core.py | 2 +- 3 files changed, 9 insertions(+), 19 deletions(-) rename test/{cstdio/test_remove.cpp => stdio/test_remove.c} (71%) rename test/{cstdio => stdio}/test_remove.out (100%) diff --git a/test/cstdio/test_remove.cpp b/test/stdio/test_remove.c similarity index 71% rename from test/cstdio/test_remove.cpp rename to test/stdio/test_remove.c index 6ed3e3be86c27..8fecf120f4d0b 100644 --- a/test/cstdio/test_remove.cpp +++ b/test/stdio/test_remove.c @@ -5,8 +5,7 @@ #include #include -#include -#include +#include #include #include #include @@ -30,38 +29,29 @@ void setup() { mkdir("dir/subdir", 0777); } -void cleanup() { - // make sure we get it all regardless of anything failing - unlink("file"); - unlink("dir/file"); - rmdir("dir/subdir"); - rmdir("dir"); -} - void test() { int err; - - err = std::remove("dir/file"); + + err = remove("dir/file"); assert(!err); - err = std::remove("file"); + err = remove("file"); assert(!err); // should fail, folder is not empty - err = std::remove("dir"); + err = remove("dir"); assert(err); - err = std::remove("dir/subdir"); + err = remove("dir/subdir"); assert(!err); - err = std::remove("dir"); + err = remove("dir"); assert(!err); - std::cout << "success\n"; + printf("success\n"); } int main() { - atexit(cleanup); setup(); test(); return 0; diff --git a/test/cstdio/test_remove.out b/test/stdio/test_remove.out similarity index 100% rename from test/cstdio/test_remove.out rename to test/stdio/test_remove.out diff --git a/test/test_core.py b/test/test_core.py index 7511815c00a8e..76fe5992ee3dc 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -1697,7 +1697,7 @@ def test_rename(self): self.do_run_in_out_file_test('stdio/test_rename.c') def test_remove(self): - self.do_run_in_out_file_test('cstdio/test_remove.cpp') + self.do_run_in_out_file_test('stdio/test_remove.c') def test_alloca_stack(self): self.do_core_test('test_alloca_stack.c') From c60dcfe4c57f8f3a667a12fabc88b6bda4a523ee Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 5 Dec 2024 17:58:44 +0100 Subject: [PATCH 017/132] When opening broken symlink with O_CREAT, create file at target (#23002) If we open a broken symlink with `O_CREAT` we should create a new file as the target of the symlink. Fixes: #23001. --- src/library_fs.js | 29 +++++++++++------ test/test_core.py | 4 +++ test/unistd/test_unistd_write_broken_link.c | 31 +++++++++++++++++++ test/unistd/test_unistd_write_broken_link.out | 6 ++++ test/wasmfs/wasmfs_open.c | 4 --- 5 files changed, 61 insertions(+), 13 deletions(-) create mode 100644 test/unistd/test_unistd_write_broken_link.c create mode 100644 test/unistd/test_unistd_write_broken_link.out diff --git a/src/library_fs.js b/src/library_fs.js index d83505db879a7..87ff6daaa810d 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -193,8 +193,18 @@ FS.staticInit(); break; } - current = FS.lookupNode(current, parts[i]); current_path = PATH.join2(current_path, parts[i]); + try { + current = FS.lookupNode(current, parts[i]); + } catch (e) { + // if noent_okay is true, suppress a ENOENT in the last component + // and return an object with an undefined node. This is needed for + // resolving symlinks in the path when creating a file. + if ((e?.errno === {{{ cDefs.ENOENT }}}) && islast && opts.noent_okay) { + return { path: current_path }; + } + throw e; + } // jump to the mount's root node if this is a mountpoint if (FS.isMountpoint(current) && (!islast || opts.follow_mount)) { @@ -1036,14 +1046,15 @@ FS.staticInit(); node = path; } else { path = PATH.normalize(path); - try { - var lookup = FS.lookupPath(path, { - follow: !(flags & {{{ cDefs.O_NOFOLLOW }}}) - }); - node = lookup.node; - } catch (e) { - // ignore - } + // noent_okay makes it so that if the final component of the path + // doesn't exist, lookupPath returns `node: undefined`. `path` will be + // updated to point to the target of all symlinks. + var lookup = FS.lookupPath(path, { + follow: !(flags & {{{ cDefs.O_NOFOLLOW }}}), + noent_okay: true + }); + node = lookup.node; + path = lookup.path; } // perhaps we need to create the node var created = false; diff --git a/test/test_core.py b/test/test_core.py index 76fe5992ee3dc..25e032ec69a79 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -6105,6 +6105,10 @@ def test_unistd_links(self, args, nodefs): self.do_run_in_out_file_test('unistd/links.c', emcc_args=args) + @also_with_noderawfs + def test_unistd_write_broken_link(self): + self.do_run_in_out_file_test('unistd/test_unistd_write_broken_link.c') + @no_windows('Skipping NODEFS test, since it would require administrative privileges.') @requires_node def test_unistd_symlink_on_nodefs(self): diff --git a/test/unistd/test_unistd_write_broken_link.c b/test/unistd/test_unistd_write_broken_link.c new file mode 100644 index 0000000000000..1c119a6e45a7e --- /dev/null +++ b/test/unistd/test_unistd_write_broken_link.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include + + +int main() { + int res = symlink("link_target", "link_source"); + printf("link result: %d\n", res); + int src_fd = open("link_source", O_CREAT | O_WRONLY, 0777); + printf("source_fd: %d, errno: %d %s\n", src_fd, errno, strerror(errno)); + write(src_fd, "abc", 3); + close(src_fd); + { + int target_fd = open("link_target", O_RDONLY); + printf("target_fd: %d, errno: %d %s\n", target_fd, errno, strerror(errno)); + char buf[10]; + read(target_fd, buf, 10); + printf("buf: '%s'\n", buf); + close(target_fd); + } + { + int target_fd = open("link_source", O_RDONLY); + printf("target_fd: %d, errno: %d %s\n", target_fd, errno, strerror(errno)); + char buf[10]; + read(target_fd, buf, 10); + printf("buf: '%s'\n", buf); + close(target_fd); + } +} diff --git a/test/unistd/test_unistd_write_broken_link.out b/test/unistd/test_unistd_write_broken_link.out new file mode 100644 index 0000000000000..6f5a9e3ea3183 --- /dev/null +++ b/test/unistd/test_unistd_write_broken_link.out @@ -0,0 +1,6 @@ +link result: 0 +source_fd: 3, errno: 0 No error information +target_fd: 3, errno: 0 No error information +buf: 'abc' +target_fd: 3, errno: 0 No error information +buf: 'abc' diff --git a/test/wasmfs/wasmfs_open.c b/test/wasmfs/wasmfs_open.c index eb8454f1ccd0a..ac95cbd066746 100644 --- a/test/wasmfs/wasmfs_open.c +++ b/test/wasmfs/wasmfs_open.c @@ -89,11 +89,7 @@ int main() { int fd5 = open("/dev/stdout/foo", O_RDWR); printf("Errno: %s\n", strerror(errno)); // Both errors are valid, but in WasmFS, ENOTDIR is returned first. -#ifdef WASMFS assert(errno == ENOTDIR); -#else - assert(errno == ENOENT); -#endif errno = 0; // Attempt to open and write to the root directory. From c028edb335f3035a3f32c5d459d587ea723da24c Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 5 Dec 2024 19:46:08 +0100 Subject: [PATCH 018/132] Fix renaming a file on top of an existing file in memfs and nodefs (#23074) --- src/library_memfs.js | 16 ++++---- src/library_nodefs.js | 3 ++ test/fs/test_fs_rename_on_existing.c | 55 ++++++++++++++++++++++++++++ test/test_core.py | 10 +++++ 4 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 test/fs/test_fs_rename_on_existing.c diff --git a/src/library_memfs.js b/src/library_memfs.js index 35597c99056b5..61fe2ab8b8db6 100644 --- a/src/library_memfs.js +++ b/src/library_memfs.js @@ -191,18 +191,18 @@ addToLibrary({ return MEMFS.createNode(parent, name, mode, dev); }, rename(old_node, new_dir, new_name) { - // if we're overwriting a directory at new_name, make sure it's empty. - if (FS.isDir(old_node.mode)) { - var new_node; - try { - new_node = FS.lookupNode(new_dir, new_name); - } catch (e) { - } - if (new_node) { + var new_node; + try { + new_node = FS.lookupNode(new_dir, new_name); + } catch (e) {} + if (new_node) { + if (FS.isDir(old_node.mode)) { + // if we're overwriting a directory at new_name, make sure it's empty. for (var i in new_node.contents) { throw new FS.ErrnoError({{{ cDefs.ENOTEMPTY }}}); } } + FS.hashRemoveNode(new_node); } // do the internal rewiring delete old_node.parent.contents[old_node.name]; diff --git a/src/library_nodefs.js b/src/library_nodefs.js index 846a930c15c48..5570bcc68f5c8 100644 --- a/src/library_nodefs.js +++ b/src/library_nodefs.js @@ -197,6 +197,9 @@ addToLibrary({ rename(oldNode, newDir, newName) { var oldPath = NODEFS.realPath(oldNode); var newPath = PATH.join2(NODEFS.realPath(newDir), newName); + try { + FS.unlink(newPath); + } catch(e) {} NODEFS.tryFSOperation(() => fs.renameSync(oldPath, newPath)); oldNode.name = newName; }, diff --git a/test/fs/test_fs_rename_on_existing.c b/test/fs/test_fs_rename_on_existing.c new file mode 100644 index 0000000000000..8c32bc3ed1b49 --- /dev/null +++ b/test/fs/test_fs_rename_on_existing.c @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#if defined(__EMSCRIPTEN__) +#include +#endif + +void makedir(const char *dir) { + int rtn = mkdir(dir, 0777); + assert(rtn == 0); +} + +void changedir(const char *dir) { + int rtn = chdir(dir); + assert(rtn == 0); +} + +static void create_file(const char *path, const char *buffer) { + printf("creating: %s\n", path); + int fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0666); + printf("error: %s\n", strerror(errno)); + assert(fd >= 0); + + int err = write(fd, buffer, sizeof(char) * strlen(buffer)); + assert(err == (sizeof(char) * strlen(buffer))); + + close(fd); +} + + +void setup() { +#if defined(__EMSCRIPTEN__) && defined(NODEFS) + makedir("working"); + EM_ASM(FS.mount(NODEFS, { root: '.' }, 'working')); + changedir("working"); +#endif +} + +int main() { + setup(); + create_file("a", "abc"); + create_file("b", "xyz"); + assert(rename("a", "b") == 0); + assert(unlink("b") == 0); + create_file("b", "xyz"); + printf("success\n"); +} diff --git a/test/test_core.py b/test/test_core.py index 25e032ec69a79..521edb501411a 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5935,6 +5935,16 @@ def test_fs_64bit(self): self.set_setting('FORCE_FILESYSTEM') self.do_runf('fs/test_64bit.c', 'success') + @parameterized({ + '': ([],), + 'nodefs': (['-DNODEFS', '-lnodefs.js'],), + 'noderawfs': (['-sNODERAWFS'],) + }) + def test_fs_rename_on_existing(self, args): + if self.get_setting('WASMFS'): + self.set_setting('FORCE_FILESYSTEM') + self.do_runf('fs/test_fs_rename_on_existing.c', 'success', emcc_args=args) + def test_sigalrm(self): self.do_runf('test_sigalrm.c', 'Received alarm!') self.set_setting('EXIT_RUNTIME') From b95a669ca26deb0e8ea7edfa8823d02dd4eb7b2c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 5 Dec 2024 10:47:53 -0800 Subject: [PATCH 019/132] Remove path.normalize from node file reading code. NFC (#23087) I don't see any reason to perform normalization here. The file read operations will happily accept relative paths and resolve them internally. --- src/node_shell_read.js | 7 +++---- test/other/codesize/test_codesize_cxx_ctors1.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors1.jssize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.jssize | 2 +- test/other/codesize/test_codesize_cxx_except.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.jssize | 2 +- .../codesize/test_codesize_cxx_except_wasm_exnref.gzsize | 2 +- .../codesize/test_codesize_cxx_except_wasm_exnref.jssize | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.jssize | 2 +- test/other/codesize/test_codesize_cxx_mangle.gzsize | 2 +- test/other/codesize/test_codesize_cxx_mangle.jssize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.gzsize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.jssize | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.gzsize | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.jssize | 2 +- test/other/codesize/test_codesize_files_js_fs.gzsize | 2 +- test/other/codesize/test_codesize_files_js_fs.jssize | 2 +- test/other/codesize/test_codesize_files_wasmfs.gzsize | 2 +- test/other/codesize/test_codesize_files_wasmfs.jssize | 2 +- test/other/codesize/test_codesize_hello_O0.gzsize | 2 +- test/other/codesize/test_codesize_hello_O0.jssize | 2 +- test/other/codesize/test_codesize_hello_O1.gzsize | 2 +- test/other/codesize/test_codesize_hello_O1.jssize | 2 +- test/other/codesize/test_codesize_hello_O2.gzsize | 2 +- test/other/codesize/test_codesize_hello_O2.jssize | 2 +- test/other/codesize/test_codesize_hello_O3.gzsize | 2 +- test/other/codesize/test_codesize_hello_O3.jssize | 2 +- test/other/codesize/test_codesize_hello_Os.gzsize | 2 +- test/other/codesize/test_codesize_hello_Os.jssize | 2 +- test/other/codesize/test_codesize_hello_Oz.gzsize | 2 +- test/other/codesize/test_codesize_hello_Oz.jssize | 2 +- test/other/codesize/test_codesize_hello_dylink.gzsize | 2 +- test/other/codesize/test_codesize_hello_dylink.jssize | 2 +- .../codesize/test_codesize_hello_export_nothing.gzsize | 2 +- .../codesize/test_codesize_hello_export_nothing.jssize | 2 +- test/other/codesize/test_codesize_hello_wasmfs.gzsize | 2 +- test/other/codesize/test_codesize_hello_wasmfs.jssize | 2 +- .../codesize/test_codesize_libcxxabi_message_O3.gzsize | 2 +- .../codesize/test_codesize_libcxxabi_message_O3.jssize | 2 +- .../test_codesize_libcxxabi_message_O3_standalone.gzsize | 2 +- .../test_codesize_libcxxabi_message_O3_standalone.jssize | 2 +- test/other/codesize/test_codesize_mem_O3.gzsize | 2 +- test/other/codesize/test_codesize_mem_O3.jssize | 2 +- test/other/codesize/test_codesize_mem_O3_grow.gzsize | 2 +- test/other/codesize/test_codesize_mem_O3_grow.jssize | 2 +- .../codesize/test_codesize_mem_O3_grow_standalone.gzsize | 2 +- .../codesize/test_codesize_mem_O3_grow_standalone.jssize | 2 +- test/other/codesize/test_codesize_mem_O3_standalone.gzsize | 2 +- test/other/codesize/test_codesize_mem_O3_standalone.jssize | 2 +- .../codesize/test_codesize_mem_O3_standalone_lib.gzsize | 2 +- .../codesize/test_codesize_mem_O3_standalone_lib.jssize | 2 +- .../codesize/test_codesize_mem_O3_standalone_narg.gzsize | 2 +- .../codesize/test_codesize_mem_O3_standalone_narg.jssize | 2 +- .../test_codesize_mem_O3_standalone_narg_flto.gzsize | 2 +- .../test_codesize_mem_O3_standalone_narg_flto.jssize | 2 +- test/other/codesize/test_codesize_minimal_64.gzsize | 2 +- test/other/codesize/test_codesize_minimal_64.jssize | 2 +- test/other/codesize/test_codesize_minimal_O0.gzsize | 2 +- test/other/codesize/test_codesize_minimal_O0.jssize | 2 +- test/other/codesize/test_codesize_minimal_O1.gzsize | 2 +- test/other/codesize/test_codesize_minimal_O1.jssize | 2 +- test/other/codesize/test_codesize_minimal_O2.gzsize | 2 +- test/other/codesize/test_codesize_minimal_O2.jssize | 2 +- test/other/codesize/test_codesize_minimal_O3.gzsize | 2 +- test/other/codesize/test_codesize_minimal_O3.jssize | 2 +- test/other/codesize/test_codesize_minimal_Os.gzsize | 2 +- test/other/codesize/test_codesize_minimal_Os.jssize | 2 +- test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize | 2 +- test/other/codesize/test_codesize_minimal_Oz-ctors.jssize | 2 +- test/other/codesize/test_codesize_minimal_Oz.gzsize | 2 +- test/other/codesize/test_codesize_minimal_Oz.jssize | 2 +- test/other/codesize/test_codesize_minimal_pthreads.gzsize | 2 +- test/other/codesize/test_codesize_minimal_pthreads.jssize | 2 +- test/other/codesize/test_codesize_minimal_wasmfs.gzsize | 2 +- test/other/codesize/test_codesize_minimal_wasmfs.jssize | 2 +- test/other/test_unoptimized_code_size.js.size | 2 +- test/other/test_unoptimized_code_size_no_asserts.js.size | 2 +- test/other/test_unoptimized_code_size_strict.js.size | 2 +- 82 files changed, 84 insertions(+), 85 deletions(-) diff --git a/src/node_shell_read.js b/src/node_shell_read.js index 46a736659bae4..942c72a1ceed7 100644 --- a/src/node_shell_read.js +++ b/src/node_shell_read.js @@ -5,9 +5,8 @@ */ readBinary = (filename) => { - // We need to re-wrap `file://` strings to URLs. Normalizing isn't - // necessary in that case, the path should already be absolute. - filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename); + // We need to re-wrap `file://` strings to URLs. + filename = isFileURI(filename) ? new URL(filename) : filename; var ret = fs.readFileSync(filename); #if ASSERTIONS assert(ret.buffer); @@ -17,7 +16,7 @@ readBinary = (filename) => { readAsync = (filename, binary = true) => { // See the comment in the `readBinary` function. - filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename); + filename = isFileURI(filename) ? new URL(filename) : filename; return new Promise((resolve, reject) => { fs.readFile(filename, binary ? undefined : 'utf8', (err, data) => { if (err) reject(err); diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index bb8f89dd9b373..a3306a1eba603 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8534 +8520 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index 136b674031567..e9373d8c0ce03 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20856 +20825 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index f6eb0bf4d3019..f120f9cdd2497 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8518 +8504 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index d55f09ef1f4c5..08594e77eba0c 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20824 +20793 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 8c22ca2a0d9bb..b904669893b1e 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9563 +9550 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 4024e9f7afaa1..dcd4fe3683135 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24699 +24668 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index b28927a921976..4d6a5c2242ae0 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8500 +8489 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index 229ccce462f7b..d1282591a3cf3 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20750 +20718 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index b28927a921976..4d6a5c2242ae0 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8500 +8489 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index 229ccce462f7b..d1282591a3cf3 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20750 +20718 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 888760ce9982e..b29f7395cb69c 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8432 +8417 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 5af65416d58f7..d01decaf4e1d8 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20434 +20403 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index b686067ce3b9b..98dde3ad81fdf 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9564 +9552 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 4024e9f7afaa1..dcd4fe3683135 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24699 +24668 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index bb8f89dd9b373..a3306a1eba603 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8534 +8520 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index 136b674031567..e9373d8c0ce03 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20856 +20825 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize index b2c038c3bdd06..8b6eff0e70854 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize @@ -1 +1 @@ -3900 +3887 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.jssize b/test/other/codesize/test_codesize_cxx_wasmfs.jssize index 203dde511d62d..4e605f38b5b82 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.jssize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.jssize @@ -1 +1 @@ -8718 +8687 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index f652e57d21720..c02621465977d 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7674 +7657 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index 44bd1d26a1359..2511513b8dfca 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18765 +18734 diff --git a/test/other/codesize/test_codesize_files_wasmfs.gzsize b/test/other/codesize/test_codesize_files_wasmfs.gzsize index ce89b3e410a0f..9870e4a2f07e9 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_files_wasmfs.gzsize @@ -1 +1 @@ -2992 +2984 diff --git a/test/other/codesize/test_codesize_files_wasmfs.jssize b/test/other/codesize/test_codesize_files_wasmfs.jssize index 394a86d56efde..8c77918b2ffbe 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.jssize +++ b/test/other/codesize/test_codesize_files_wasmfs.jssize @@ -1 +1 @@ -6354 +6324 diff --git a/test/other/codesize/test_codesize_hello_O0.gzsize b/test/other/codesize/test_codesize_hello_O0.gzsize index 64595bbb74d9a..052dc9241b3db 100644 --- a/test/other/codesize/test_codesize_hello_O0.gzsize +++ b/test/other/codesize/test_codesize_hello_O0.gzsize @@ -1 +1 @@ -8054 +8042 diff --git a/test/other/codesize/test_codesize_hello_O0.jssize b/test/other/codesize/test_codesize_hello_O0.jssize index e81ba058fadf7..1f1ac91c270cf 100644 --- a/test/other/codesize/test_codesize_hello_O0.jssize +++ b/test/other/codesize/test_codesize_hello_O0.jssize @@ -1 +1 @@ -21488 +21457 diff --git a/test/other/codesize/test_codesize_hello_O1.gzsize b/test/other/codesize/test_codesize_hello_O1.gzsize index b3a37ac4b74ed..c1fe14e0295ce 100644 --- a/test/other/codesize/test_codesize_hello_O1.gzsize +++ b/test/other/codesize/test_codesize_hello_O1.gzsize @@ -1 +1 @@ -2825 +2818 diff --git a/test/other/codesize/test_codesize_hello_O1.jssize b/test/other/codesize/test_codesize_hello_O1.jssize index 64aee72ade65d..68df7255b64b5 100644 --- a/test/other/codesize/test_codesize_hello_O1.jssize +++ b/test/other/codesize/test_codesize_hello_O1.jssize @@ -1 +1 @@ -7111 +7080 diff --git a/test/other/codesize/test_codesize_hello_O2.gzsize b/test/other/codesize/test_codesize_hello_O2.gzsize index ea908ff33b176..59780dc7b1e42 100644 --- a/test/other/codesize/test_codesize_hello_O2.gzsize +++ b/test/other/codesize/test_codesize_hello_O2.gzsize @@ -1 +1 @@ -2503 +2492 diff --git a/test/other/codesize/test_codesize_hello_O2.jssize b/test/other/codesize/test_codesize_hello_O2.jssize index bcdfe2d406799..08400af305374 100644 --- a/test/other/codesize/test_codesize_hello_O2.jssize +++ b/test/other/codesize/test_codesize_hello_O2.jssize @@ -1 +1 @@ -5063 +5032 diff --git a/test/other/codesize/test_codesize_hello_O3.gzsize b/test/other/codesize/test_codesize_hello_O3.gzsize index 7914187fc0a88..1475ea901925a 100644 --- a/test/other/codesize/test_codesize_hello_O3.gzsize +++ b/test/other/codesize/test_codesize_hello_O3.gzsize @@ -1 +1 @@ -2416 +2404 diff --git a/test/other/codesize/test_codesize_hello_O3.jssize b/test/other/codesize/test_codesize_hello_O3.jssize index 278937feb69f9..94166f8c0392a 100644 --- a/test/other/codesize/test_codesize_hello_O3.jssize +++ b/test/other/codesize/test_codesize_hello_O3.jssize @@ -1 +1 @@ -4909 +4878 diff --git a/test/other/codesize/test_codesize_hello_Os.gzsize b/test/other/codesize/test_codesize_hello_Os.gzsize index 7914187fc0a88..1475ea901925a 100644 --- a/test/other/codesize/test_codesize_hello_Os.gzsize +++ b/test/other/codesize/test_codesize_hello_Os.gzsize @@ -1 +1 @@ -2416 +2404 diff --git a/test/other/codesize/test_codesize_hello_Os.jssize b/test/other/codesize/test_codesize_hello_Os.jssize index 278937feb69f9..94166f8c0392a 100644 --- a/test/other/codesize/test_codesize_hello_Os.jssize +++ b/test/other/codesize/test_codesize_hello_Os.jssize @@ -1 +1 @@ -4909 +4878 diff --git a/test/other/codesize/test_codesize_hello_Oz.gzsize b/test/other/codesize/test_codesize_hello_Oz.gzsize index 38ac9c5946d9c..1b4f1c3480a9e 100644 --- a/test/other/codesize/test_codesize_hello_Oz.gzsize +++ b/test/other/codesize/test_codesize_hello_Oz.gzsize @@ -1 +1 @@ -2398 +2386 diff --git a/test/other/codesize/test_codesize_hello_Oz.jssize b/test/other/codesize/test_codesize_hello_Oz.jssize index c4fa14144238e..b226a38b01177 100644 --- a/test/other/codesize/test_codesize_hello_Oz.jssize +++ b/test/other/codesize/test_codesize_hello_Oz.jssize @@ -1 +1 @@ -4876 +4845 diff --git a/test/other/codesize/test_codesize_hello_dylink.gzsize b/test/other/codesize/test_codesize_hello_dylink.gzsize index 6b25ae66921df..dcea0b8b886f4 100644 --- a/test/other/codesize/test_codesize_hello_dylink.gzsize +++ b/test/other/codesize/test_codesize_hello_dylink.gzsize @@ -1 +1 @@ -6304 +6294 diff --git a/test/other/codesize/test_codesize_hello_dylink.jssize b/test/other/codesize/test_codesize_hello_dylink.jssize index 82142080ff89b..180ee9baf7ffc 100644 --- a/test/other/codesize/test_codesize_hello_dylink.jssize +++ b/test/other/codesize/test_codesize_hello_dylink.jssize @@ -1 +1 @@ -13894 +13863 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.gzsize b/test/other/codesize/test_codesize_hello_export_nothing.gzsize index adb88b75522e4..4f5ed40394465 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.gzsize +++ b/test/other/codesize/test_codesize_hello_export_nothing.gzsize @@ -1 +1 @@ -1772 +1763 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.jssize b/test/other/codesize/test_codesize_hello_export_nothing.jssize index db606a3345d7f..a30e882a02394 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.jssize +++ b/test/other/codesize/test_codesize_hello_export_nothing.jssize @@ -1 +1 @@ -3760 +3732 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.gzsize b/test/other/codesize/test_codesize_hello_wasmfs.gzsize index 7914187fc0a88..1475ea901925a 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_hello_wasmfs.gzsize @@ -1 +1 @@ -2416 +2404 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.jssize b/test/other/codesize/test_codesize_hello_wasmfs.jssize index 278937feb69f9..94166f8c0392a 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.jssize +++ b/test/other/codesize/test_codesize_hello_wasmfs.jssize @@ -1 +1 @@ -4909 +4878 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize index 90e525730040d..ec3cc3d4023f1 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize @@ -1 +1 @@ -1977 +1969 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize index 6816d34c5a813..b055ba9e6e1c9 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize @@ -1 +1 @@ -4137 +4109 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize index e355f6dc2c905..8bd1af11bf283 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize @@ -1 +1 @@ -2013 +2000 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize index 5255d8eda08aa..694d7725287cb 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize @@ -1 +1 @@ -4184 +4156 diff --git a/test/other/codesize/test_codesize_mem_O3.gzsize b/test/other/codesize/test_codesize_mem_O3.gzsize index dcce86ad24c95..633e99ca46b94 100644 --- a/test/other/codesize/test_codesize_mem_O3.gzsize +++ b/test/other/codesize/test_codesize_mem_O3.gzsize @@ -1 +1 @@ -2438 +2427 diff --git a/test/other/codesize/test_codesize_mem_O3.jssize b/test/other/codesize/test_codesize_mem_O3.jssize index e0fd17de85ac5..27f45130113cd 100644 --- a/test/other/codesize/test_codesize_mem_O3.jssize +++ b/test/other/codesize/test_codesize_mem_O3.jssize @@ -1 +1 @@ -5051 +5020 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.gzsize b/test/other/codesize/test_codesize_mem_O3_grow.gzsize index 11346f5d69b07..58923f84404f7 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow.gzsize @@ -1 +1 @@ -2582 +2571 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.jssize b/test/other/codesize/test_codesize_mem_O3_grow.jssize index 66ff790e932f6..0211f87ad8a6c 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow.jssize @@ -1 +1 @@ -5333 +5302 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize index 20c65f21df41d..edf372fd24bbb 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize @@ -1 +1 @@ -2279 +2266 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize index 383fa505c5afe..de4ba040ae5f1 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize @@ -1 +1 @@ -4740 +4710 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize index c29e53f81ddfb..0e4a28666b93f 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize @@ -1 +1 @@ -2248 +2235 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_standalone.jssize index ae6d064561fe5..f201ebe0c4417 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.jssize @@ -1 +1 @@ -4670 +4640 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize index 44173d5cb77fe..ef0a2ad63226b 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize @@ -1 +1 @@ -1996 +1987 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize index a4ca075180c97..c1a5f9617ccae 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize @@ -1 +1 @@ -4188 +4160 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize index e355f6dc2c905..8bd1af11bf283 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize @@ -1 +1 @@ -2013 +2000 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize index 5255d8eda08aa..694d7725287cb 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize @@ -1 +1 @@ -4184 +4156 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize index e355f6dc2c905..8bd1af11bf283 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize @@ -1 +1 @@ -2013 +2000 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize index 5255d8eda08aa..694d7725287cb 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize @@ -1 +1 @@ -4184 +4156 diff --git a/test/other/codesize/test_codesize_minimal_64.gzsize b/test/other/codesize/test_codesize_minimal_64.gzsize index f768f5839707f..d2a3f6303bde7 100644 --- a/test/other/codesize/test_codesize_minimal_64.gzsize +++ b/test/other/codesize/test_codesize_minimal_64.gzsize @@ -1 +1 @@ -1535 +1523 diff --git a/test/other/codesize/test_codesize_minimal_64.jssize b/test/other/codesize/test_codesize_minimal_64.jssize index b860fd703a3de..21e99126c5165 100644 --- a/test/other/codesize/test_codesize_minimal_64.jssize +++ b/test/other/codesize/test_codesize_minimal_64.jssize @@ -1 +1 @@ -3216 +3188 diff --git a/test/other/codesize/test_codesize_minimal_O0.gzsize b/test/other/codesize/test_codesize_minimal_O0.gzsize index 0590e000d1be1..26d97f396bfab 100644 --- a/test/other/codesize/test_codesize_minimal_O0.gzsize +++ b/test/other/codesize/test_codesize_minimal_O0.gzsize @@ -1 +1 @@ -6584 +6571 diff --git a/test/other/codesize/test_codesize_minimal_O0.jssize b/test/other/codesize/test_codesize_minimal_O0.jssize index 406ffb9d96d4c..4705c7d0c2aad 100644 --- a/test/other/codesize/test_codesize_minimal_O0.jssize +++ b/test/other/codesize/test_codesize_minimal_O0.jssize @@ -1 +1 @@ -17637 +17606 diff --git a/test/other/codesize/test_codesize_minimal_O1.gzsize b/test/other/codesize/test_codesize_minimal_O1.gzsize index 8caa513e2687d..f70509d547b9a 100644 --- a/test/other/codesize/test_codesize_minimal_O1.gzsize +++ b/test/other/codesize/test_codesize_minimal_O1.gzsize @@ -1 +1 @@ -1608 +1601 diff --git a/test/other/codesize/test_codesize_minimal_O1.jssize b/test/other/codesize/test_codesize_minimal_O1.jssize index a91ca4c6b7bb5..ff743c815089f 100644 --- a/test/other/codesize/test_codesize_minimal_O1.jssize +++ b/test/other/codesize/test_codesize_minimal_O1.jssize @@ -1 +1 @@ -3823 +3795 diff --git a/test/other/codesize/test_codesize_minimal_O2.gzsize b/test/other/codesize/test_codesize_minimal_O2.gzsize index ac48d993bb8a5..4b7816b5720e5 100644 --- a/test/other/codesize/test_codesize_minimal_O2.gzsize +++ b/test/other/codesize/test_codesize_minimal_O2.gzsize @@ -1 +1 @@ -1462 +1452 diff --git a/test/other/codesize/test_codesize_minimal_O2.jssize b/test/other/codesize/test_codesize_minimal_O2.jssize index abe0cf822d59c..a8eeb4fcda930 100644 --- a/test/other/codesize/test_codesize_minimal_O2.jssize +++ b/test/other/codesize/test_codesize_minimal_O2.jssize @@ -1 +1 @@ -2921 +2893 diff --git a/test/other/codesize/test_codesize_minimal_O3.gzsize b/test/other/codesize/test_codesize_minimal_O3.gzsize index b322e68302d81..b03a71123e693 100644 --- a/test/other/codesize/test_codesize_minimal_O3.gzsize +++ b/test/other/codesize/test_codesize_minimal_O3.gzsize @@ -1 +1 @@ -1427 +1416 diff --git a/test/other/codesize/test_codesize_minimal_O3.jssize b/test/other/codesize/test_codesize_minimal_O3.jssize index 8afc5d50c386e..4f552a2c600bc 100644 --- a/test/other/codesize/test_codesize_minimal_O3.jssize +++ b/test/other/codesize/test_codesize_minimal_O3.jssize @@ -1 +1 @@ -2871 +2843 diff --git a/test/other/codesize/test_codesize_minimal_Os.gzsize b/test/other/codesize/test_codesize_minimal_Os.gzsize index b322e68302d81..b03a71123e693 100644 --- a/test/other/codesize/test_codesize_minimal_Os.gzsize +++ b/test/other/codesize/test_codesize_minimal_Os.gzsize @@ -1 +1 @@ -1427 +1416 diff --git a/test/other/codesize/test_codesize_minimal_Os.jssize b/test/other/codesize/test_codesize_minimal_Os.jssize index 8afc5d50c386e..4f552a2c600bc 100644 --- a/test/other/codesize/test_codesize_minimal_Os.jssize +++ b/test/other/codesize/test_codesize_minimal_Os.jssize @@ -1 +1 @@ -2871 +2843 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize index 19ef72cd81422..a11d586ce91d1 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize @@ -1 +1 @@ -1419 +1407 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize index 47f06d4699cd1..45c22531f7d6c 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize @@ -1 +1 @@ -2856 +2828 diff --git a/test/other/codesize/test_codesize_minimal_Oz.gzsize b/test/other/codesize/test_codesize_minimal_Oz.gzsize index b322e68302d81..b03a71123e693 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz.gzsize @@ -1 +1 @@ -1427 +1416 diff --git a/test/other/codesize/test_codesize_minimal_Oz.jssize b/test/other/codesize/test_codesize_minimal_Oz.jssize index 8afc5d50c386e..4f552a2c600bc 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz.jssize @@ -1 +1 @@ -2871 +2843 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.gzsize b/test/other/codesize/test_codesize_minimal_pthreads.gzsize index e824891ca6709..0f12704884a5d 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.gzsize +++ b/test/other/codesize/test_codesize_minimal_pthreads.gzsize @@ -1 +1 @@ -4226 +4208 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.jssize b/test/other/codesize/test_codesize_minimal_pthreads.jssize index 8aae358324bf1..db6dfb1df8651 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.jssize +++ b/test/other/codesize/test_codesize_minimal_pthreads.jssize @@ -1 +1 @@ -8734 +8703 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize index b322e68302d81..b03a71123e693 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize @@ -1 +1 @@ -1427 +1416 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.jssize b/test/other/codesize/test_codesize_minimal_wasmfs.jssize index 8afc5d50c386e..4f552a2c600bc 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.jssize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.jssize @@ -1 +1 @@ -2871 +2843 diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index 3047c693644af..48f4d8dcae999 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -55052 +54928 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index 5b0b3eb9613cd..3926438285887 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -30698 +30574 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index 3e047c18b238a..5c3cf64221739 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -53848 +53724 From 0732751ea3dc688dd0e7517b66a853f55e3d80d2 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 5 Dec 2024 12:10:35 -0800 Subject: [PATCH 020/132] Optimize library_nodepath.js. NFC (#23086) --- src/closure-externs/node-externs.js | 12 ++++++++++++ src/library_nodepath.js | 20 ++++++++++---------- src/library_noderawfs.js | 2 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/closure-externs/node-externs.js b/src/closure-externs/node-externs.js index ce995014c3179..b7a0e6049fa9f 100644 --- a/src/closure-externs/node-externs.js +++ b/src/closure-externs/node-externs.js @@ -119,3 +119,15 @@ fs.Stats.prototype.mtimeMs; * @type {number} */ fs.Stats.prototype.ctimeMs; + +/** + * @param {string} p + * @return {boolean} + * @nosideeffects + */ +path.isAbsolute; + +/** + * @type {Object.} + */ +path.posix; diff --git a/src/library_nodepath.js b/src/library_nodepath.js index c42820f36e289..09d4c48a4662a 100644 --- a/src/library_nodepath.js +++ b/src/library_nodepath.js @@ -12,14 +12,14 @@ // operations. Hence, using `nodePath` should be safe here. addToLibrary({ - $PATH: { - isAbs: (path) => nodePath['isAbsolute'](path), - normalize: (path) => nodePath['normalize'](path), - dirname: (path) => nodePath['dirname'](path), - basename: (path) => nodePath['basename'](path), - join: (...args) => nodePath['join'](...args), - join2: (l, r) => nodePath['join'](l, r), - }, + $PATH: `{ + isAbs: nodePath.isAbsolute, + normalize: nodePath.normalize, + dirname: nodePath.dirname, + basename: nodePath.basename, + join: nodePath.join, + join2: nodePath.join, + }`, // The FS-using parts are split out into a separate object, so simple path // usage does not require the FS. $PATH_FS__deps: ['$FS'], @@ -27,8 +27,8 @@ addToLibrary({ $PATH_FS: { resolve: (...paths) => { paths.unshift(FS.cwd()); - return nodePath['posix']['resolve'](...paths); + return nodePath.posix.resolve(...paths); }, - relative: (from, to) => nodePath['posix']['relative'](from || FS.cwd(), to || FS.cwd()), + relative: (from, to) => nodePath.posix.relative(from || FS.cwd(), to || FS.cwd()), } }); diff --git a/src/library_noderawfs.js b/src/library_noderawfs.js index 6c622d15078e5..81ab16962a89c 100644 --- a/src/library_noderawfs.js +++ b/src/library_noderawfs.js @@ -40,7 +40,7 @@ addToLibrary({ }, lookupPath(path, opts = {}) { if (opts.parent) { - path = nodePath.dirname(path); + path = PATH.dirname(path); } var st = fs.lstatSync(path); var mode = NODEFS.getMode(path); From 58d444124557b15ebcde097b5c0a388a265d6c40 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 5 Dec 2024 12:21:03 -0800 Subject: [PATCH 021/132] Micro-optimize memfs readdir. NFC (#23076) --- src/library_memfs.js | 6 +----- test/other/codesize/test_codesize_cxx_ctors1.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors1.jssize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.jssize | 2 +- test/other/codesize/test_codesize_cxx_except.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.jssize | 2 +- .../codesize/test_codesize_cxx_except_wasm_exnref.gzsize | 2 +- .../codesize/test_codesize_cxx_except_wasm_exnref.jssize | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.jssize | 2 +- test/other/codesize/test_codesize_cxx_mangle.gzsize | 2 +- test/other/codesize/test_codesize_cxx_mangle.jssize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.gzsize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.jssize | 2 +- test/other/codesize/test_codesize_files_js_fs.gzsize | 2 +- test/other/codesize/test_codesize_files_js_fs.jssize | 2 +- 19 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/library_memfs.js b/src/library_memfs.js index 61fe2ab8b8db6..09a994f7f5b3e 100644 --- a/src/library_memfs.js +++ b/src/library_memfs.js @@ -223,11 +223,7 @@ addToLibrary({ parent.ctime = parent.mtime = Date.now(); }, readdir(node) { - var entries = ['.', '..']; - for (var key of Object.keys(node.contents)) { - entries.push(key); - } - return entries; + return ['.', '..', ...Object.keys(node.contents)]; }, symlink(parent, newname, oldpath) { var node = MEMFS.createNode(parent, newname, 0o777 | {{{ cDefs.S_IFLNK }}}, 0); diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index a3306a1eba603..7c6cfdff74039 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8520 +8577 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index e9373d8c0ce03..61dd2a4a752ed 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20825 +20952 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index f120f9cdd2497..5c5a56aa23907 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8504 +8561 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 08594e77eba0c..946332105fd69 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20793 +20920 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index b904669893b1e..f4cac6ae1ed21 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9550 +9610 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index dcd4fe3683135..1972d66211f85 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24668 +24795 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index 4d6a5c2242ae0..addbd0d396de9 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8489 +8551 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index d1282591a3cf3..f1ed501dc449f 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20718 +20845 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index 4d6a5c2242ae0..addbd0d396de9 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8489 +8551 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index d1282591a3cf3..f1ed501dc449f 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20718 +20845 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index b29f7395cb69c..1ff8b32916c6a 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8417 +8480 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index d01decaf4e1d8..e9bde91a32c7d 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20403 +20531 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index 98dde3ad81fdf..c14a51b4e8394 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9552 +9615 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index dcd4fe3683135..1972d66211f85 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24668 +24795 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index a3306a1eba603..7c6cfdff74039 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8520 +8577 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index e9373d8c0ce03..61dd2a4a752ed 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20825 +20952 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index c02621465977d..5bfda2af7c553 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7657 +7717 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index 2511513b8dfca..b132bf3ee0efe 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18734 +18861 From 3dff04cd868b95659989c36681378832fa9bc9b7 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 5 Dec 2024 13:34:43 -0800 Subject: [PATCH 022/132] [test] Avoid seeding random number generators with time. NFC (#23050) Using the current time to seed the random number generator in tests will make them non-determinisitic. Simply using the default seed or seeding with a fixed value seem fine all of these test cases. --- test/benchmark/benchmark_utf16.cpp | 1 - test/benchmark/benchmark_utf8.c | 3 -- test/code_size/random_printf_wasm.json | 8 +-- test/code_size/random_printf_wasm2js.json | 8 +-- test/core/test_emmalloc.c | 1 - test/core/test_rand.c | 42 +++++++++++++++ test/core/test_rand.out | 21 ++++++++ test/fetch/test_fetch_idb_store.c | 1 - test/fetch/test_fetch_idb_store.cpp | 1 - test/hello_random_printf.c | 2 +- test/malloc_bench.c | 1 - test/pthread/test_pthread_barrier.cpp | 1 - test/test_core.py | 63 +---------------------- test/test_memset_alignment.c | 2 - test/webaudio/audioworklet.c | 2 - 15 files changed, 73 insertions(+), 84 deletions(-) create mode 100644 test/core/test_rand.c create mode 100644 test/core/test_rand.out diff --git a/test/benchmark/benchmark_utf16.cpp b/test/benchmark/benchmark_utf16.cpp index ad17747a7964a..8d33d6129782e 100644 --- a/test/benchmark/benchmark_utf16.cpp +++ b/test/benchmark/benchmark_utf16.cpp @@ -54,7 +54,6 @@ unsigned short *randomString(int len) { } int main() { - srand(time(NULL)); double t = 0; double t2 = emscripten_get_now(); for(int i = 0; i < 10; ++i) { diff --git a/test/benchmark/benchmark_utf8.c b/test/benchmark/benchmark_utf8.c index 38a93b25902db..378a59e5ae673 100644 --- a/test/benchmark/benchmark_utf8.c +++ b/test/benchmark/benchmark_utf8.c @@ -54,9 +54,6 @@ char *randomString(int len) { } int main() { - time_t seed = time(NULL); - printf("Random seed: %lld\n", seed); - srand(seed); double t = 0; double t2 = emscripten_get_now(); for (int i = 0; i < 100000; ++i) { diff --git a/test/code_size/random_printf_wasm.json b/test/code_size/random_printf_wasm.json index 2a9f84036e46f..8548e41737392 100644 --- a/test/code_size/random_printf_wasm.json +++ b/test/code_size/random_printf_wasm.json @@ -1,6 +1,6 @@ { - "a.html": 12686, - "a.html.gz": 6930, - "total": 12686, - "total_gz": 6930 + "a.html": 12597, + "a.html.gz": 6882, + "total": 12597, + "total_gz": 6882 } diff --git a/test/code_size/random_printf_wasm2js.json b/test/code_size/random_printf_wasm2js.json index 7fa7980b7d20b..b3fe0c465524e 100644 --- a/test/code_size/random_printf_wasm2js.json +++ b/test/code_size/random_printf_wasm2js.json @@ -1,6 +1,6 @@ { - "a.html": 17266, - "a.html.gz": 7515, - "total": 17266, - "total_gz": 7515 + "a.html": 17195, + "a.html.gz": 7478, + "total": 17195, + "total_gz": 7478 } diff --git a/test/core/test_emmalloc.c b/test/core/test_emmalloc.c index 6af556beec5d1..58bf5aa1bb140 100644 --- a/test/core/test_emmalloc.c +++ b/test/core/test_emmalloc.c @@ -178,7 +178,6 @@ void randoms() { for (int i = 0; i < BINS; i++) { bins[i] = NULL; } - srandom(1337101); for (int i = 0; i < RANDOM_ITERS; i++) { unsigned int r = random(); int alloc = r & 1; diff --git a/test/core/test_rand.c b/test/core/test_rand.c new file mode 100644 index 0000000000000..cd5fccf5c47e6 --- /dev/null +++ b/test/core/test_rand.c @@ -0,0 +1,42 @@ +#include +#include +#include +#include + +int main() { + // We need RAND_MAX to be a bitmask (power of 2 minus 1). This assertion will + // error if RAND_MAX ever changes, so we don't miss that. + assert(RAND_MAX == 0x7fffffff); + + srand(0xdeadbeef); + for (int i = 0; i < 10; ++i) { + printf("%d\n", rand()); + } + + unsigned int seed = 0xdeadbeef; + for (int i = 0; i < 10; ++i) { + printf("%d\n", rand_r(&seed)); + } + + bool haveEvenAndOdd = true; + for (int i = 1; i <= 30; ++i) { + int mask = 1 << i; + if (mask > RAND_MAX) break; + bool haveEven = false; + bool haveOdd = false; + for (int j = 0; j < 1000 && (!haveEven || !haveOdd); ++j) { + if ((rand() & mask) == 0) { + haveEven = true; + } else { + haveOdd = true; + } + } + haveEvenAndOdd = haveEvenAndOdd && haveEven && haveOdd; + } + + if (haveEvenAndOdd) { + printf("Have even and odd!\n"); + } + + return 0; +} diff --git a/test/core/test_rand.out b/test/core/test_rand.out new file mode 100644 index 0000000000000..0cd26bd9c6bae --- /dev/null +++ b/test/core/test_rand.out @@ -0,0 +1,21 @@ +490242850 +2074599277 +1480056542 +1912638067 +931112055 +2110392489 +2053422194 +1614832492 +216117595 +174823244 +760368382 +602359081 +1121118963 +1291018924 +1608306807 +352705809 +958258461 +1182561381 +114276303 +1481323674 +Have even and odd! diff --git a/test/fetch/test_fetch_idb_store.c b/test/fetch/test_fetch_idb_store.c index 2ab526f5ee827..62f38e29bc9e8 100644 --- a/test/fetch/test_fetch_idb_store.c +++ b/test/fetch/test_fetch_idb_store.c @@ -38,7 +38,6 @@ int main() { // Create data uint8_t *data = (uint8_t*)malloc(10240); - srand(time(NULL)); for(int i = 0; i < 10240; ++i) data[i] = (uint8_t)rand(); persistFileToIndexedDB("outputfile.dat", data, 10240); diff --git a/test/fetch/test_fetch_idb_store.cpp b/test/fetch/test_fetch_idb_store.cpp index baa4ff22c5da2..46ff2f5f499de 100644 --- a/test/fetch/test_fetch_idb_store.cpp +++ b/test/fetch/test_fetch_idb_store.cpp @@ -21,7 +21,6 @@ int main() strcpy(attr.requestMethod, "EM_IDB_STORE"); attr.attributes = EMSCRIPTEN_FETCH_REPLACE | EMSCRIPTEN_FETCH_SYNCHRONOUS | EMSCRIPTEN_FETCH_PERSIST_FILE; uint8_t *data = (uint8_t*)malloc(TEST_SIZE); - srand(time(NULL)); for(int i = 0; i < TEST_SIZE; ++i) data[i] = (uint8_t)rand() | 0x40; attr.requestData = (char *)data; diff --git a/test/hello_random_printf.c b/test/hello_random_printf.c index dbefa3333c356..87166bd13dc12 100644 --- a/test/hello_random_printf.c +++ b/test/hello_random_printf.c @@ -4,7 +4,7 @@ #include int main() { - srand(time(NULL)); + srand(0); printf("hello: a random string: %s, an integer: %d, a float: %f. Time now: %f\n", emscripten_random() > 0.5 ? "test" : "test2", diff --git a/test/malloc_bench.c b/test/malloc_bench.c index 91c536aeb7f21..078df4e47eedf 100644 --- a/test/malloc_bench.c +++ b/test/malloc_bench.c @@ -29,7 +29,6 @@ const bool USE_MEMORY = true; const bool USE_SHIFTS = false; void randoms() { - srandom(1); size_t before = (size_t)sbrk(0); double sum_sbrk = 0; size_t max_sbrk = before; diff --git a/test/pthread/test_pthread_barrier.cpp b/test/pthread/test_pthread_barrier.cpp index cb397a90a9eba..76201e7da1d07 100644 --- a/test/pthread/test_pthread_barrier.cpp +++ b/test/pthread/test_pthread_barrier.cpp @@ -57,7 +57,6 @@ int main(int argc, char **argv) // Create the matrix and compute the expected result. int expectedTotalSum = 0; - srand(time(NULL)); for(int i = 0; i < N; ++i) for(int j = 0; j < N; ++j) { diff --git a/test/test_core.py b/test/test_core.py index 521edb501411a..2163d969cffc1 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5155,68 +5155,7 @@ def test_random(self): self.do_run(src, '956867869') def test_rand(self): - src = r'''#include -#include -#include -int main() -{ - // we need RAND_MAX to be a bitmask (power of 2 minus 1). this assertions guarantees - // if RAND_MAX changes the test failure will focus attention on that issue here. - assert(RAND_MAX == 0x7fffffff); - - srand(0xdeadbeef); - for(int i = 0; i < 10; ++i) - printf("%d\n", rand()); - - unsigned int seed = 0xdeadbeef; - for(int i = 0; i < 10; ++i) - printf("%d\n", rand_r(&seed)); - - bool haveEvenAndOdd = true; - for(int i = 1; i <= 30; ++i) - { - int mask = 1 << i; - if (mask > RAND_MAX) break; - bool haveEven = false; - bool haveOdd = false; - for(int j = 0; j < 1000 && (!haveEven || !haveOdd); ++j) - { - if ((rand() & mask) == 0) - haveEven = true; - else - haveOdd = true; - } - haveEvenAndOdd = haveEvenAndOdd && haveEven && haveOdd; - } - if (haveEvenAndOdd) - printf("Have even and odd!\n"); - - return 0; -} -''' - expected = '''490242850 -2074599277 -1480056542 -1912638067 -931112055 -2110392489 -2053422194 -1614832492 -216117595 -174823244 -760368382 -602359081 -1121118963 -1291018924 -1608306807 -352705809 -958258461 -1182561381 -114276303 -1481323674 -Have even and odd! -''' - self.do_run(src, expected) + self.do_core_test('test_rand.c') def test_strtod(self): self.do_core_test('test_strtod.c') diff --git a/test/test_memset_alignment.c b/test/test_memset_alignment.c index 8402f7661786b..c116a89a41a06 100644 --- a/test/test_memset_alignment.c +++ b/test/test_memset_alignment.c @@ -58,8 +58,6 @@ void test_copysize(int copySize) { } int main() { - srand(time(NULL)); - for (int copySize = 0; copySize < 128; ++copySize) { test_copysize(copySize); } diff --git a/test/webaudio/audioworklet.c b/test/webaudio/audioworklet.c index 4169475ff62b8..9b4bdd8a3dd60 100644 --- a/test/webaudio/audioworklet.c +++ b/test/webaudio/audioworklet.c @@ -124,8 +124,6 @@ void WebAudioWorkletThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, bool s uint8_t wasmAudioWorkletStack[4096]; int main() { - srand(time(NULL)); - assert(!emscripten_current_thread_is_audio_worklet()); // Create an audio context From e16230e4c8a2367a5fda0d5e822b5e2e28f6c9b9 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 6 Dec 2024 18:53:54 +0100 Subject: [PATCH 023/132] Fix path resolution for symlinks (#23072) If `/a/link` is a symlink to directory `/b/c` then `/a/link/..` should be resolved to `/b/c/..` which is `/b`. Currently, we cancel out `link/..` to get `/a`. The problem is that we apply `PATH_FS.resolve` and `PATH_FS.normalize` to paths. These functions cancel `..` incorrectly. This at least partially handles the situation. `lookupPath` is modified to avoid calls that call `PATH_FS.normalize()`. We check that `mkdir`, `open`, `stat`, `truncate`, and `chmod` now work correctly. --- src/library_fs.js | 20 +++++++--- src/library_syscall.js | 6 +-- test/fs/test_fs_symlink_resolution.c | 57 ++++++++++++++++++++++++++++ test/test_core.py | 14 +++++++ test/wasmfs/wasmfs_mkdir.c | 4 -- 5 files changed, 87 insertions(+), 14 deletions(-) create mode 100644 test/fs/test_fs_symlink_resolution.c diff --git a/src/library_fs.js b/src/library_fs.js index 87ff6daaa810d..68c53ad670bb5 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -172,15 +172,17 @@ FS.staticInit(); // paths // lookupPath(path, opts = {}) { - path = PATH_FS.resolve(path); - if (!path) return { path: '', node: null }; opts.follow_mount ??= true + if (!PATH.isAbs(path)) { + path = FS.cwd() + '/' + path; + } + // limit max consecutive symlinks to 40 (SYMLOOP_MAX). linkloop: for (var nlinks = 0; nlinks < 40; nlinks++) { // split the absolute path - var parts = path.split('/').filter((p) => !!p); + var parts = path.split('/').filter((p) => !!p && (p !== '.')); // start at the root var current = FS.root; @@ -193,6 +195,12 @@ FS.staticInit(); break; } + if (parts[i] === '..') { + current_path = PATH.dirname(current_path); + current = current.parent; + continue; + } + current_path = PATH.join2(current_path, parts[i]); try { current = FS.lookupNode(current, parts[i]); @@ -218,7 +226,10 @@ FS.staticInit(); throw new FS.ErrnoError({{{ cDefs.ENOSYS }}}); } var link = current.node_ops.readlink(current); - path = PATH_FS.resolve(PATH.dirname(current_path), link, ...parts.slice(i + 1)); + if (!PATH.isAbs(link)) { + link = PATH.dirname(current_path) + '/' + link; + } + path = link + '/' + parts.slice(i + 1).join('/'); continue linkloop; } } @@ -1045,7 +1056,6 @@ FS.staticInit(); if (typeof path == 'object') { node = path; } else { - path = PATH.normalize(path); // noent_okay makes it so that if the final component of the path // doesn't exist, lookupPath returns `node: undefined`. `path` will be // updated to point to the target of all symlinks. diff --git a/src/library_syscall.js b/src/library_syscall.js index 821014a4af10f..80e616408bac6 100644 --- a/src/library_syscall.js +++ b/src/library_syscall.js @@ -38,7 +38,7 @@ var SyscallsLibrary = { } return dir; } - return PATH.join2(dir, path); + return dir + '/' + path; }, doStat(func, path, buf) { @@ -833,10 +833,6 @@ var SyscallsLibrary = { __syscall_mkdirat: (dirfd, path, mode) => { path = SYSCALLS.getStr(path); path = SYSCALLS.calculateAt(dirfd, path); - // remove a trailing slash, if one - /a/b/ has basename of '', but - // we want to create b in the context of this function - path = PATH.normalize(path); - if (path[path.length-1] === '/') path = path.substr(0, path.length-1); FS.mkdir(path, mode, 0); return 0; }, diff --git a/test/fs/test_fs_symlink_resolution.c b/test/fs/test_fs_symlink_resolution.c new file mode 100644 index 0000000000000..1c6d88c63a6ec --- /dev/null +++ b/test/fs/test_fs_symlink_resolution.c @@ -0,0 +1,57 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(__EMSCRIPTEN__) +#include "emscripten.h" +#endif + +void makedir(const char *dir) { + int rtn = mkdir(dir, 0777); + assert(rtn == 0); +} + +void changedir(const char *dir) { + int rtn = chdir(dir); + assert(rtn == 0); +} + +static void create_file(const char *path) { + printf("creating: %s\n", path); + int fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0777); + assert(fd >= 0); + + close(fd); +} + +void setup() { +#if defined(__EMSCRIPTEN__) && defined(NODEFS) + makedir("working"); + EM_ASM(FS.mount(NODEFS, { root: '.' }, 'working')); + changedir("working"); +#endif + makedir("a"); + makedir("b"); + makedir("b/c"); + symlink("../b/c", "a/link"); +} + + +int main() { + setup(); + create_file("a/link/../x.txt"); + struct stat statBuf; + assert(stat("a/link/../x.txt", &statBuf) == 0); + assert(stat("b/x.txt", &statBuf) == 0); + makedir("a/link/../d"); + assert(stat("a/link/../d", &statBuf) == 0); + assert(stat("b/d", &statBuf) == 0); + + assert(truncate("a/link/../x.txt", 0) == 0); + assert(chmod("a/link/../x.txt", 0777) == 0); + printf("success\n"); +} diff --git a/test/test_core.py b/test/test_core.py index 2163d969cffc1..7d5382042306f 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5874,6 +5874,20 @@ def test_fs_64bit(self): self.set_setting('FORCE_FILESYSTEM') self.do_runf('fs/test_64bit.c', 'success') + @requires_node + @parameterized({ + '': ([],), + 'nodefs': (['-DNODEFS', '-lnodefs.js'],), + 'noderawfs': (['-sNODERAWFS'],), + }) + def test_fs_symlink_resolution(self, args): + nodefs = '-DNODEFS' in args or '-sNODERAWFS' in args + if self.get_setting('WASMFS'): + if nodefs: + self.skipTest('NODEFS in WasmFS') + self.set_setting('FORCE_FILESYSTEM') + self.do_runf('fs/test_fs_symlink_resolution.c', 'success', emcc_args=args) + @parameterized({ '': ([],), 'nodefs': (['-DNODEFS', '-lnodefs.js'],), diff --git a/test/wasmfs/wasmfs_mkdir.c b/test/wasmfs/wasmfs_mkdir.c index 830cdadfcd24b..536499a4bba75 100644 --- a/test/wasmfs/wasmfs_mkdir.c +++ b/test/wasmfs/wasmfs_mkdir.c @@ -66,11 +66,7 @@ int main() { // Try to make the root directory. errno = 0; mkdir("/", 0777); -#ifdef WASMFS assert(errno == EEXIST); -#else - assert(errno == EINVAL); -#endif // Try to make a directory that exists already. errno = 0; From fb14f6d9fc2b00fea36af0f5ca4e996f61520b8f Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Fri, 6 Dec 2024 11:10:36 -0800 Subject: [PATCH 024/132] Disable test_fs_enotdir on Windows (#23095) This seems to be another instance of #8882 where errno values don't match. This could be "fixed" by making the error check a little looser if we care about the behavior of NODERAWFS on Windows. For now just disable to unblock the rollers. --- test/test_core.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_core.py b/test/test_core.py index 7d5382042306f..bce85d9e98f32 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5781,6 +5781,8 @@ def test_fs_write(self): def test_fs_emptyPath(self): self.do_run_in_out_file_test('fs/test_emptyPath.c') + @no_windows('https://github.com/emscripten-core/emscripten/issues/8882') + @crossplatform @also_with_noderawfs def test_fs_enotdir(self): self.do_run_in_out_file_test('fs/test_enotdir.c') From b48aedd4b794a90d65dc4d2303db753ec6e85029 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 6 Dec 2024 20:31:32 +0100 Subject: [PATCH 025/132] PEP 621: Migrate .coveragerc and .mypy.ini into pyproject.toml (#23089) https://peps.python.org/pep-0621 Migrate settings from `.coveragerc` and `.mypy.ini` into `pyproject.toml` using [ini2toml](https://pypi.org/project/ini2toml) to do the file conversion and running [pyproject-fmt](https://pypi.org/project/pyproject-fmt) to format the results. ```bash ini2toml .mypy.ini > pyproject.toml ini2toml .coveragerc >> pyproject.toml pyproject-fmt pyproject.toml git add pyproject.toml git rm .coveragerc git rm .mypy.ini ``` --- .coveragerc | 7 ------- .mypy.ini | 16 ---------------- pyproject.toml | 35 +++++++++++++++++++++++++++++++++++ requirements-dev.txt | 2 +- 4 files changed, 36 insertions(+), 24 deletions(-) delete mode 100644 .coveragerc delete mode 100644 .mypy.ini create mode 100644 pyproject.toml diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index e8ca40a3d059c..0000000000000 --- a/.coveragerc +++ /dev/null @@ -1,7 +0,0 @@ -[run] -source = . -omit = ./test/* - ./third_party/* - ./tools/emcoverage.py - test.py - diff --git a/.mypy.ini b/.mypy.ini deleted file mode 100644 index 9bbc785692470..0000000000000 --- a/.mypy.ini +++ /dev/null @@ -1,16 +0,0 @@ -[mypy] -mypy_path = third_party/,third_party/ply,third_party/websockify -files = . -exclude = (?x)( - cache | - third_party | - conf\.py | - emrun\.py | - site/source/_themes/ | - tools/scons/site_scons/site_tools/emscripten/__init__\.py | - site/source/get_wiki\.py | - test/parse_benchmark_output\.py - ) - -[mypy-tools.create_dom_pk_codes,tools.webidl_binder,tools.toolchain_profiler,tools.filelock,tools.find_bigvars,leb128,ply.*] -ignore_errors = True diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000000..38bf2a5e67beb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,35 @@ +[tool.coverage.run] +source = [ "." ] +omit = [ + "./test/*", + "./third_party/*", + "./tools/emcoverage.py", + "test.py", +] + +[tool.mypy] +mypy_path = "third_party/,third_party/ply,third_party/websockify" +files = [ "." ] +exclude = ''' +(?x)( +cache | +third_party | +conf\.py | +emrun\.py | +site/source/_themes/ | +tools/scons/site_scons/site_tools/emscripten/__init__\.py | +site/source/get_wiki\.py | +test/parse_benchmark_output\.py +)''' + +[[tool.mypy.overrides]] +module = [ + "tools.create_dom_pk_codes", + "tools.webidl_binder", + "tools.toolchain_profiler", + "tools.filelock", + "tools.find_bigvars", + "leb128", + "ply.*", +] +ignore_errors = true diff --git a/requirements-dev.txt b/requirements-dev.txt index 4e0ddc450aecd..c67851c37317d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,7 +7,7 @@ flake8==5.0.4 flake8-bugbear==22.9.23 flake8-unused-arguments==0.0.11 -coverage==5.5 +coverage[toml]==5.5 mypy==0.971 types-requests==2.27.14 unittest-xml-reporting==3.1.0 From cefc9de5205b7a59dfe767efaf909c781cd41348 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 6 Dec 2024 12:05:36 -0800 Subject: [PATCH 026/132] Add emscripten_builtin_realloc (#23091) Also improve testing for allocator wrapping. Fixes: #23080 --- system/include/emscripten/heap.h | 1 + system/lib/dlmalloc.c | 1 + system/lib/emmalloc.c | 1 + system/lib/mimalloc/src/alloc-override.c | 1 + test/core/test_wrap_malloc.c | 15 ++++++++++++++- test/test_core.py | 10 ++++++++-- tools/system_libs.py | 2 +- 7 files changed, 27 insertions(+), 4 deletions(-) diff --git a/system/include/emscripten/heap.h b/system/include/emscripten/heap.h index 0bd56cdbb32db..26041d6be2be2 100644 --- a/system/include/emscripten/heap.h +++ b/system/include/emscripten/heap.h @@ -46,6 +46,7 @@ size_t emscripten_get_heap_max(void); // dlmalloc and emmalloc. void *emscripten_builtin_memalign(size_t alignment, size_t size); void *emscripten_builtin_malloc(size_t size); +void *emscripten_builtin_realloc(void *ptr, size_t size); void *emscripten_builtin_calloc(size_t nmemb, size_t size); void emscripten_builtin_free(void *ptr); diff --git a/system/lib/dlmalloc.c b/system/lib/dlmalloc.c index f55ff649cfefb..5c4de3fe03c89 100644 --- a/system/lib/dlmalloc.c +++ b/system/lib/dlmalloc.c @@ -6082,6 +6082,7 @@ int mspace_mallopt(int param_number, int value) { // This allows an easy mechanism for hooking into memory allocation. #if defined(__EMSCRIPTEN__) && !ONLY_MSPACES extern __typeof(malloc) emscripten_builtin_malloc __attribute__((alias("dlmalloc"))); +extern __typeof(realloc) emscripten_builtin_realloc __attribute__((alias("dlrealloc"))); extern __typeof(calloc) emscripten_builtin_calloc __attribute__((alias("dlcalloc"))); extern __typeof(free) emscripten_builtin_free __attribute__((alias("dlfree"))); extern __typeof(memalign) emscripten_builtin_memalign __attribute__((alias("dlmemalign"))); diff --git a/system/lib/emmalloc.c b/system/lib/emmalloc.c index 940335c37cf5e..6c794b3f3e880 100644 --- a/system/lib/emmalloc.c +++ b/system/lib/emmalloc.c @@ -1113,6 +1113,7 @@ void *emmalloc_aligned_realloc_uninitialized(void *ptr, size_t alignment, size_t void *emmalloc_realloc(void *ptr, size_t size) { return emmalloc_aligned_realloc(ptr, MALLOC_ALIGNMENT, size); } +EMMALLOC_ALIAS(emscripten_builtin_realloc, emmalloc_realloc); EMMALLOC_ALIAS(__libc_realloc, emmalloc_realloc); EMMALLOC_ALIAS(realloc, emmalloc_realloc); diff --git a/system/lib/mimalloc/src/alloc-override.c b/system/lib/mimalloc/src/alloc-override.c index e326ea7b4b051..ded7a101de9f2 100644 --- a/system/lib/mimalloc/src/alloc-override.c +++ b/system/lib/mimalloc/src/alloc-override.c @@ -298,6 +298,7 @@ mi_decl_weak int reallocarr(void* p, size_t count, size_t size) { return mi_r #ifdef __EMSCRIPTEN__ // emscripten adds some more on top of WASI void* emscripten_builtin_malloc(size_t size) MI_FORWARD1(mi_malloc, size) + void* emscripten_builtin_realloc(void* p, size_t size) MI_FORWARD2(mi_realloc, p, size) void* emscripten_builtin_free(void* p) MI_FORWARD0(mi_free, p) void* emscripten_builtin_memalign(size_t alignment, size_t size) { return mi_memalign(alignment, size); } void* emscripten_builtin_calloc(size_t nmemb, size_t size) MI_FORWARD2(mi_calloc, nmemb, size) diff --git a/test/core/test_wrap_malloc.c b/test/core/test_wrap_malloc.c index 97d3fd2ec1fe9..be58ffa2ae917 100644 --- a/test/core/test_wrap_malloc.c +++ b/test/core/test_wrap_malloc.c @@ -11,6 +11,7 @@ static int totalAllocs; static int totalFrees; +static int totalReallocs; void *malloc(size_t size) { ++totalAllocs; @@ -19,6 +20,13 @@ void *malloc(size_t size) { return ptr; } +void *realloc(void* ptr, size_t size) { + ++totalReallocs; + ptr = emscripten_builtin_realloc(ptr, size); + emscripten_console_logf("Reallocated %zu bytes, got %p. %d pointers re-allocated total.", size, ptr, totalReallocs); + return ptr; +} + void free(void *ptr) { ++totalFrees; emscripten_builtin_free(ptr); @@ -39,9 +47,14 @@ int main() { free(ptr); } + void* ptr = malloc(50); + ptr = realloc(ptr, 50); + emscripten_console_logf("totalAllocs: %d", totalAllocs); emscripten_console_logf("totalFrees: %d", totalFrees); - assert(totalAllocs == 20); + emscripten_console_logf("totalReallocs: %d", totalReallocs); + assert(totalAllocs == 21); + assert(totalReallocs == 1); assert(totalFrees == 20); emscripten_console_logf("OK."); return 0; diff --git a/test/test_core.py b/test/test_core.py index bce85d9e98f32..551d3d41e0e4d 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -8610,8 +8610,14 @@ def test_mallinfo(self): @no_asan('cannot replace malloc/free with ASan') @no_lsan('cannot replace malloc/free with LSan') - def test_wrap_malloc(self): - self.do_runf('core/test_wrap_malloc.c', 'OK.') + @parameterized({ + '': ([],), + 'emmalloc': (['-sMALLOC=emmalloc'],), + # FIXME(https://github.com/emscripten-core/emscripten/issues/23090) + # 'mimalloc': (['-sMALLOC=mimalloc'],), + }) + def test_wrap_malloc(self, args): + self.do_runf('core/test_wrap_malloc.c', 'OK.', emcc_args=args) def test_environment(self): self.set_setting('ASSERTIONS') diff --git a/tools/system_libs.py b/tools/system_libs.py index 582d19ba21148..e6bbf1c3435b1 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -1721,7 +1721,7 @@ class libmalloc(MTLibrary): def __init__(self, **kwargs): self.malloc = kwargs.pop('malloc') if self.malloc not in ('dlmalloc', 'emmalloc', 'emmalloc-debug', 'emmalloc-memvalidate', 'emmalloc-verbose', 'emmalloc-memvalidate-verbose', 'mimalloc', 'none'): - raise Exception('malloc must be one of "emmalloc[-debug|-memvalidate][-verbose]", "dlmalloc" or "none", see settings.js') + raise Exception('malloc must be one of "emmalloc[-debug|-memvalidate][-verbose]", "mimalloc", "dlmalloc" or "none", see settings.js') self.is_tracing = kwargs.pop('is_tracing') self.memvalidate = kwargs.pop('memvalidate') From 7342ee809ac4bcff958d61ac327530ed4b6eaf38 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 6 Dec 2024 12:06:27 -0800 Subject: [PATCH 027/132] Cleanup some filesystem tests. NFC (#23088) There were a couple of old tests in `test/filesystem`. This change modes them to `test/fs` and improves them. --- test/filesystem/bad_lookup.cpp | 106 ------------------ test/fs/test_fs_bad_lookup.c | 81 +++++++++++++ test/fs/test_fs_base.c | 4 + .../{filesystem/src.js => fs/test_fs_base.js} | 0 .../output.txt => fs/test_fs_base.out} | 1 + .../test_fs_dev_random.c} | 1 + test/test_browser.py | 4 +- test/test_core.py | 6 +- test/test_other.py | 12 +- 9 files changed, 101 insertions(+), 114 deletions(-) delete mode 100644 test/filesystem/bad_lookup.cpp create mode 100644 test/fs/test_fs_bad_lookup.c create mode 100644 test/fs/test_fs_base.c rename test/{filesystem/src.js => fs/test_fs_base.js} (100%) rename test/{filesystem/output.txt => fs/test_fs_base.out} (99%) rename test/{filesystem/test_dev_random.c => fs/test_fs_dev_random.c} (96%) diff --git a/test/filesystem/bad_lookup.cpp b/test/filesystem/bad_lookup.cpp deleted file mode 100644 index ebe55de3b1648..0000000000000 --- a/test/filesystem/bad_lookup.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2014 The Emscripten Authors. All rights reserved. -// Emscripten is available under two separate licenses, the MIT license and the -// University of Illinois/NCSA Open Source License. Both these licenses can be -// found in the LICENSE file. - -#include -#include -#include -#include -#include - -#include -#include -#include - -using std::endl; - -//============================================================================ -// :: Helpers - -namespace -{ - //-------------------------------------------------------------------------- - // Helper to create an empty file with the given path. - void touch(const std::string& path, const mode_t mode) - { - std::cout - << "Touching file: " << path << " with mode=" << std::oct << mode - << std::dec << endl; - - const int fd = ::open(path.c_str(), O_CREAT | O_WRONLY, mode); - if (fd == -1) { - const int error = errno; - std::cout - << "Failed to touch file using open: " << path << "; errno=" << error - << ";" << std::strerror(error) << endl; - } - else { - ::close(fd); - } - } - - //-------------------------------------------------------------------------- - // Stats the given path and prints the mode. Returns true if the path - // exists; false otherwise. - bool exists(const std::string& path) - { - struct ::stat path_stat; - if (::lstat(path.c_str(), &path_stat) != 0) { - const int error = errno; - if (error == ENOENT) { - // Only bother logging if something other than the path not existing - // went wrong. - std::cout - << "Failed to lstat path: " << path << "; errno=" << error << "; " - << std::strerror(error) << endl; - } - return false; - } - - std::cout - << std::oct << "Mode for path=" << path << ": " << path_stat.st_mode - << std::dec << endl; - return true; - } -} - -//============================================================================ -// :: Entry Point - -int main() -{ - touch("file1", 0667); - if (not exists("file1")) { - std::cout << "Failed to create path: file1" << endl; - return 1; - } - if (exists("file1/dir")) { - std::cout << "Path should not exists: file1/dir" << endl; - return 1; - } - - touch("file2", 0676); - if (not exists("file2")) { - std::cout << "Failed to create path: file2" << endl; - return 1; - } - if (exists("file2/dir")) { - std::cout << "Path should not exists: file2/dir" << endl; - return 1; - } - - touch("file3", 0766); - if (not exists("file3")) { - std::cout << "Failed to create path: file3" << endl; - return 1; - } - if (exists("file3/dir")) { - std::cout << "Path should not exists: file3/dir" << endl; - return 1; - } - - std::cout << "ok." << endl; - return 0; -} - diff --git a/test/fs/test_fs_bad_lookup.c b/test/fs/test_fs_bad_lookup.c new file mode 100644 index 0000000000000..690798bfc138a --- /dev/null +++ b/test/fs/test_fs_bad_lookup.c @@ -0,0 +1,81 @@ +// Copyright 2014 The Emscripten Authors. All rights reserved. +// Emscripten is available under two separate licenses, the MIT license and the +// University of Illinois/NCSA Open Source License. Both these licenses can be +// found in the LICENSE file. + +#include +#include +#include +#include +#include +#include +#include + +//-------------------------------------------------------------------------- +// Helper to create an empty file with the given path. +void touch(const char* path, const mode_t mode) { + printf("Touching file: %s with mode=%o\n", path, mode); + + int fd = open(path, O_CREAT | O_WRONLY, mode); + if (fd == -1) { + int error = errno; + printf("Failed to touch file using open: %s; %s\n", path, strerror(errno)); + } else { + close(fd); + } +} + +//-------------------------------------------------------------------------- +// Stats the given path and prints the mode. Returns true if the path +// exists; false otherwise. +bool exists(const char* path) { + struct stat path_stat; + if (lstat(path, &path_stat) != 0) { + int error = errno; + if (error == ENOENT) { + // Only bother logging if something other than the path not existing + // went wrong. + printf("Failed to lstat path: %s; %s", path, strerror(error)); + } + return false; + } + + printf("Mode for path=%s: %o\n", path, path_stat.st_mode); + return true; +} + +int main() { + touch("file1", 0667); + if (!exists("file1")) { + printf("Failed to create path: file1\n"); + return 1; + } + if (exists("file1/dir")) { + printf("Path should not exists: file1/dir\n"); + return 1; + } + + touch("file2", 0676); + if (!exists("file2")) { + printf("Failed to create path: file2\n"); + return 1; + } + if (exists("file2/dir")) { + printf("Path should not exists: file2/dir\n"); + return 1; + } + + touch("file3", 0766); + if (!exists("file3")) { + printf("Failed to create path: file3\n"); + return 1; + } + if (exists("file3/dir")) { + printf("Path should not exists: file3/dir\n"); + return 1; + } + + printf("ok.\n"); + return 0; +} + diff --git a/test/fs/test_fs_base.c b/test/fs/test_fs_base.c new file mode 100644 index 0000000000000..da1f7462626f6 --- /dev/null +++ b/test/fs/test_fs_base.c @@ -0,0 +1,4 @@ +int main() { + // Nothing to do here. Test is written in JS. See test/fs/test_fs_base.js. + return 0; +} diff --git a/test/filesystem/src.js b/test/fs/test_fs_base.js similarity index 100% rename from test/filesystem/src.js rename to test/fs/test_fs_base.js diff --git a/test/filesystem/output.txt b/test/fs/test_fs_base.out similarity index 99% rename from test/filesystem/output.txt rename to test/fs/test_fs_base.out index c0ec00cf1059f..ac6b96ee0c110 100644 --- a/test/filesystem/output.txt +++ b/test/fs/test_fs_base.out @@ -195,3 +195,4 @@ parentExists: false parentPath: null parentObject.contents: null + diff --git a/test/filesystem/test_dev_random.c b/test/fs/test_fs_dev_random.c similarity index 96% rename from test/filesystem/test_dev_random.c rename to test/fs/test_fs_dev_random.c index e8b1d98497dd7..4200f0bdc8139 100644 --- a/test/filesystem/test_dev_random.c +++ b/test/fs/test_fs_dev_random.c @@ -22,5 +22,6 @@ int main() { assert(nread == byte_count); fclose(fp); + printf("success\n"); return 0; } diff --git a/test/test_browser.py b/test/test_browser.py index 89b7edbaa6740..b044613ef296e 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -812,8 +812,8 @@ def test(): # test() @also_with_wasmfs - def test_dev_random(self): - self.btest_exit('filesystem/test_dev_random.c') + def test_fs_dev_random(self): + self.btest_exit('fs/test_fs_dev_random.c') def test_sdl_swsurface(self): self.btest_exit('test_sdl_swsurface.c', args=['-lSDL', '-lGL']) diff --git a/test/test_core.py b/test/test_core.py index 551d3d41e0e4d..09aaa129b6ffd 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5674,10 +5674,8 @@ def test_istream(self): def test_fs_base(self): self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', ['$FS']) - self.add_pre_run(read_file(test_file('filesystem/src.js'))) - src = 'int main() {return 0;}\n' - expected = read_file(test_file('filesystem/output.txt')) - self.do_run(src, expected) + self.add_pre_run(read_file(test_file('fs/test_fs_base.js'))) + self.do_run_in_out_file_test('fs/test_fs_base.c') @also_with_noderawfs @is_slow_test diff --git a/test/test_other.py b/test/test_other.py index dfdff53977072..7e0e11ffb7a17 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -6097,8 +6097,16 @@ class time_iterator { ''') self.run_process([EMXX, 'src.cpp', '-O2', '-sSAFE_HEAP']) - def test_bad_lookup(self): - self.do_runf(path_from_root('test/filesystem/bad_lookup.cpp'), expected_output='ok') + @also_with_wasmfs + @also_with_noderawfs + @crossplatform + def test_fs_bad_lookup(self): + self.do_runf(path_from_root('test/fs/test_fs_bad_lookup.c'), expected_output='ok') + + @also_with_wasmfs + @also_with_noderawfs + def test_fs_dev_random(self): + self.do_runf('fs/test_fs_dev_random.c', 'success') @parameterized({ 'none': [{'EMCC_FORCE_STDLIBS': None}, False], From c1878d19adc42f311200e4ef6a1cc418253ff788 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Fri, 6 Dec 2024 15:10:46 -0800 Subject: [PATCH 028/132] Skip symlink tests on Windows (#23097) Followup to #23072 --- test/test_core.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/test_core.py b/test/test_core.py index 09aaa129b6ffd..9e62f056f3bf9 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5875,6 +5875,7 @@ def test_fs_64bit(self): self.do_runf('fs/test_64bit.c', 'success') @requires_node + @crossplatform @parameterized({ '': ([],), 'nodefs': (['-DNODEFS', '-lnodefs.js'],), @@ -5882,6 +5883,8 @@ def test_fs_64bit(self): }) def test_fs_symlink_resolution(self, args): nodefs = '-DNODEFS' in args or '-sNODERAWFS' in args + if nodefs and WINDOWS: + self.skipTest('No symlinks on Windows') if self.get_setting('WASMFS'): if nodefs: self.skipTest('NODEFS in WasmFS') From d1c208f2c0f8433719296917d7f4508ef9ee2a20 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 6 Dec 2024 15:35:43 -0800 Subject: [PATCH 029/132] Rebaseline codesize expectations. NFC --- test/other/codesize/test_codesize_cxx_ctors1.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors1.jssize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.jssize | 2 +- test/other/codesize/test_codesize_cxx_except.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.jssize | 2 +- test/other/codesize/test_codesize_cxx_mangle.gzsize | 2 +- test/other/codesize/test_codesize_cxx_mangle.jssize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.gzsize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.jssize | 2 +- test/other/codesize/test_codesize_files_js_fs.gzsize | 2 +- test/other/codesize/test_codesize_files_js_fs.jssize | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 7c6cfdff74039..be861f0f5dbdd 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8577 +8619 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index 61dd2a4a752ed..d86ed240bc135 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20952 +21051 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index 5c5a56aa23907..bbf1fc2d92fce 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8561 +8603 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 946332105fd69..42a346084b727 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20920 +21019 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index f4cac6ae1ed21..eebec2e1f1497 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9610 +9650 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 1972d66211f85..1d41e2883f28f 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24795 +24894 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index addbd0d396de9..2bf75798c8ef6 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8551 +8591 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index f1ed501dc449f..ee75dd26fc8b8 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20845 +20944 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index addbd0d396de9..2bf75798c8ef6 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8551 +8591 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index f1ed501dc449f..ee75dd26fc8b8 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20845 +20944 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 1ff8b32916c6a..f6eb0bf4d3019 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8480 +8518 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index e9bde91a32c7d..34df5ecdebb22 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20531 +20630 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index c14a51b4e8394..eb571b08cf512 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9615 +9654 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 1972d66211f85..1d41e2883f28f 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24795 +24894 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 7c6cfdff74039..be861f0f5dbdd 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8577 +8619 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index 61dd2a4a752ed..d86ed240bc135 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20952 +21051 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index 5bfda2af7c553..e0fa4b755cc40 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7717 +7755 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index b132bf3ee0efe..886a74523bd6e 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18861 +18958 From 44dc320e0e2562632473f4fc9797f5a2661e953f Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Fri, 6 Dec 2024 15:45:52 -0800 Subject: [PATCH 030/132] Disable new clang warning in libicu (#23099) Clang now has a warning -Warray-compare which triggers in this library. --- tools/ports/icu.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/ports/icu.py b/tools/ports/icu.py index 0cd4de23ccc2b..530122f3e18c2 100644 --- a/tools/ports/icu.py +++ b/tools/ports/icu.py @@ -39,6 +39,8 @@ def build_lib(lib_output, lib_src, other_includes, build_flags): # TODO: investigate why this is needed and remove '-Wno-macro-redefined', '-Wno-deprecated-declarations', + '-Wno-array-compare', + '-Wno-unknown-warning-option', # usage of 'using namespace icu' is deprecated: icu v61 '-DU_USING_ICU_NAMESPACE=0', # make explicit inclusion of utf header: ref utf.h From f13066337482fc0aacc5b8ed05063dae3990a655 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Sat, 7 Dec 2024 10:33:06 -0800 Subject: [PATCH 031/132] Cleanup test_offset_converter. NFC (#23098) - Using zero return code for success. - Run test both with and without pthreads. --- test/browser/test_offset_converter.c | 15 ++++++++++----- test/test_browser.py | 8 ++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/test/browser/test_offset_converter.c b/test/browser/test_offset_converter.c index 0862e56d6bdae..06fe565d2ee8b 100644 --- a/test/browser/test_offset_converter.c +++ b/test/browser/test_offset_converter.c @@ -1,21 +1,26 @@ +#include #include #include -void *get_pc(void) { return __builtin_return_address(0); } +void *get_pc(void) { + return __builtin_return_address(0); +} -int magic_test_function(void) { +void magic_test_function(void) { int result = EM_ASM_INT({ function report(x) { - fetch(encodeURI('http://localhost:8888?stdout=' + x)); + out(x); + fetch('http://localhost:8888?stdout=' + encodeURIComponent(x)); } report('magic_test_function: input=' + $0); var converted = wasmOffsetConverter.getName($0); report('magic_test_function: converted=' + converted); return converted == 'magic_test_function'; }, get_pc()); - return result; + assert(result); } int main(void) { - return magic_test_function(); + magic_test_function(); + return 0; } diff --git a/test/test_browser.py b/test/test_browser.py index b044613ef296e..6143486e91fa8 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -4948,8 +4948,12 @@ def test_minimal_runtime_loader_shell(self, args): def test_minimal_runtime_hello_world(self, args): self.btest_exit('small_hello_world.c', args=args + ['-sMINIMAL_RUNTIME']) - def test_offset_converter(self, *args): - self.btest_exit('test_offset_converter.c', assert_returncode=1, args=['-sUSE_OFFSET_CONVERTER', '-gsource-map', '-sPROXY_TO_PTHREAD', '-pthread']) + @parameterized({ + '': ([],), + 'pthread': (['-sPROXY_TO_PTHREAD', '-pthread'],) + }) + def test_offset_converter(self, args): + self.btest_exit('test_offset_converter.c', args=['-sUSE_OFFSET_CONVERTER', '-gsource-map'] + args) # Tests emscripten_unwind_to_js_event_loop() behavior def test_emscripten_unwind_to_js_event_loop(self, *args): From 1ddef047f8c88bb5f4241c82ff715ec1f0cc65bd Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Sat, 7 Dec 2024 11:28:14 -0800 Subject: [PATCH 032/132] Simplify asyncLoad. NFC (#23100) Turns out non of the callers were relying the adding of the run dependencies here. There are 4 call sites total: - emscripten_async_wget_data: Explicitly sets noRunDep - emscripten_wget_data: Explicitly sets noRunDep - loadDynamicLibrary: The outer loadDylibs already has an explicit calls to addRunDependency/removeRunDependency. - FS_createPreloadedFile: Already has an explicit calls to addRunDependency/removeRunDependency. --- src/library.js | 6 +----- src/library_async.js | 2 +- src/library_wget.js | 2 +- test/other/codesize/test_codesize_hello_dylink.gzsize | 2 +- test/other/codesize/test_codesize_hello_dylink.jssize | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/library.js b/src/library.js index de40788604bf9..132de3c2910b0 100644 --- a/src/library.js +++ b/src/library.js @@ -2181,18 +2181,14 @@ addToLibrary({ return x.startsWith('dynCall_') ? x : '_' + x; }, - $asyncLoad__docs: '/** @param {boolean=} noRunDep */', - $asyncLoad: (url, noRunDep) => { + $asyncLoad: (url) => { return new Promise((resolve, reject) => { - var dep = !noRunDep ? getUniqueRunDependency(`al ${url}`) : ''; - if (dep) addRunDependency(dep); readAsync(url).then( (arrayBuffer) => { #if ASSERTIONS assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`); #endif resolve(new Uint8Array(arrayBuffer)); - if (dep) removeRunDependency(dep); }, reject); }); }, diff --git a/src/library_async.js b/src/library_async.js index a3fbc151cb76f..9327bc3b495ff 100644 --- a/src/library_async.js +++ b/src/library_async.js @@ -471,7 +471,7 @@ addToLibrary({ emscripten_wget_data: (url, pbuffer, pnum, perror) => { return Asyncify.handleSleep((wakeUp) => { /* no need for run dependency, this is async but will not do any prepare etc. step */ - asyncLoad(UTF8ToString(url), /*noRunDep=*/true).then((byteArray) => { + asyncLoad(UTF8ToString(url)).then((byteArray) => { // can only allocate the buffer after the wakeUp, not during an asyncing var buffer = _malloc(byteArray.length); // must be freed by caller! HEAPU8.set(byteArray, buffer); diff --git a/src/library_wget.js b/src/library_wget.js index fe6416a7391f0..279913d0e19b4 100644 --- a/src/library_wget.js +++ b/src/library_wget.js @@ -65,7 +65,7 @@ var LibraryWget = { emscripten_async_wget_data: (url, userdata, onload, onerror) => { {{{ runtimeKeepalivePush() }}} /* no need for run dependency, this is async but will not do any prepare etc. step */ - asyncLoad(UTF8ToString(url), /*noRunDep=*/true).then((byteArray) => { + asyncLoad(UTF8ToString(url)).then((byteArray) => { {{{ runtimeKeepalivePop() }}} callUserCallback(() => { var buffer = _malloc(byteArray.length); diff --git a/test/other/codesize/test_codesize_hello_dylink.gzsize b/test/other/codesize/test_codesize_hello_dylink.gzsize index dcea0b8b886f4..473dc4cba135f 100644 --- a/test/other/codesize/test_codesize_hello_dylink.gzsize +++ b/test/other/codesize/test_codesize_hello_dylink.gzsize @@ -1 +1 @@ -6294 +6276 diff --git a/test/other/codesize/test_codesize_hello_dylink.jssize b/test/other/codesize/test_codesize_hello_dylink.jssize index 180ee9baf7ffc..153b68e34d9a0 100644 --- a/test/other/codesize/test_codesize_hello_dylink.jssize +++ b/test/other/codesize/test_codesize_hello_dylink.jssize @@ -1 +1 @@ -13863 +13831 From c08204e56de44a66763ed58c161622850b1da91a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Sat, 7 Dec 2024 11:29:44 -0800 Subject: [PATCH 033/132] Fix for flakiness in socket tests. NFC (#23103) In #22987 I added a new veriant of the test_nodejs_sockets_echo test and chose the next consecutive port number, but it seems that each test ends up using two ports numbers so this could conflicted with the tests that were using both the previous and next number in the sequence (59164 and 59166). --- test/test_sockets.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_sockets.py b/test/test_sockets.py index cce737ad12de5..53081075a6e28 100644 --- a/test/test_sockets.py +++ b/test/test_sockets.py @@ -285,7 +285,7 @@ def test_enet(self): 'native': [WebsockifyServerHarness, 59160, ['-DTEST_DGRAM=0']], 'tcp': [CompiledServerHarness, 59162, ['-DTEST_DGRAM=0']], 'udp': [CompiledServerHarness, 59164, ['-DTEST_DGRAM=1']], - 'pthread': [CompiledServerHarness, 59165, ['-pthread', '-sPROXY_TO_PTHREAD']], + 'pthread': [CompiledServerHarness, 59166, ['-pthread', '-sPROXY_TO_PTHREAD']], }) def test_nodejs_sockets_echo(self, harness_class, port, args): if harness_class == WebsockifyServerHarness and common.EMTEST_LACKS_NATIVE_CLANG: @@ -304,12 +304,12 @@ def test_nodejs_sockets_echo_subprotocol(self): # Test against a Websockified server with compile time configured WebSocket subprotocol. We use a Websockified # server because as long as the subprotocol list contains binary it will configure itself to accept binary # This test also checks that the connect url contains the correct subprotocols. - with WebsockifyServerHarness(test_file('sockets/test_sockets_echo_server.c'), [], 59166): - self.run_process([EMCC, '-Werror', test_file('sockets/test_sockets_echo_client.c'), '-o', 'client.js', '-sSOCKET_DEBUG', '-sWEBSOCKET_SUBPROTOCOL="base64, binary"', '-DSOCKK=59166']) + with WebsockifyServerHarness(test_file('sockets/test_sockets_echo_server.c'), [], 59168): + self.run_process([EMCC, '-Werror', test_file('sockets/test_sockets_echo_client.c'), '-o', 'client.js', '-sSOCKET_DEBUG', '-sWEBSOCKET_SUBPROTOCOL="base64, binary"', '-DSOCKK=59168']) out = self.run_js('client.js') self.assertContained('do_msg_read: read 14 bytes', out) - self.assertContained(['connect: ws://127.0.0.1:59166, base64,binary', 'connect: ws://127.0.0.1:59166/, base64,binary'], out) + self.assertContained(['connect: ws://127.0.0.1:59168, base64,binary', 'connect: ws://127.0.0.1:59168/, base64,binary'], out) @requires_native_clang def test_nodejs_sockets_echo_subprotocol_runtime(self): From 19345a7607224c9b1c3612dfd106b1aca69cb560 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 9 Dec 2024 17:42:26 +0100 Subject: [PATCH 034/132] Python lint: Use ruff instead of flake8. NFC (#23085) https://docs.astral.sh/ruff is an extremely fast Python linter and code formatter, written in Rust. With over 800 linting rules, ruff can be used to replace [Flake8](https://pypi.org/project/flake8/) (plus dozens of plugins), [Black](https://github.com/psf/black), [isort](https://pypi.org/project/isort/), [pydocstyle](https://pypi.org/project/pydocstyle/), [pyupgrade](https://pypi.org/project/pyupgrade/), [autoflake](https://pypi.org/project/autoflake/), and more, all while executing tens or hundreds of times faster than any individual tool. --- .circleci/config.yml | 6 +-- .flake8 | 19 ---------- docs/process.md | 6 +-- em-config.py | 2 +- emcc.py | 12 +++++- emrun.py | 10 ++++- emsymbolizer.py | 4 +- pyproject.toml | 67 +++++++++++++++++++++++++++++++++ requirements-dev.txt | 6 +-- test/benchmark/benchmark_sse.py | 4 +- test/runner.py | 6 +-- tools/file_packager.py | 10 ++++- tools/link.py | 10 ++++- tools/webidl_binder.py | 10 ++++- 14 files changed, 127 insertions(+), 45 deletions(-) delete mode 100644 .flake8 diff --git a/.circleci/config.yml b/.circleci/config.yml index c0536063facaa..5c5844c7e8c63 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -419,12 +419,12 @@ jobs: - run: make -C site text - run: tools/maint/check_emcc_help_text.py - run: make -C site html - flake8: + ruff: executor: bionic steps: - checkout - pip-install - - run: python3 -m flake8 --show-source --statistics + - run: ruff check mypy: executor: bionic steps: @@ -970,7 +970,7 @@ jobs: workflows: build-test: jobs: - - flake8 + - ruff - mypy - eslint - build-docs diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 865ca1e004956..0000000000000 --- a/.flake8 +++ /dev/null @@ -1,19 +0,0 @@ -[flake8] -ignore = E111,E114,E501,E261,E266,E121,E402,E241,W504,E741,B011,B023,U101 -exclude = - ./node_modules/, # third-party code - ./third_party/, # third-party code - ./tools/filelock.py, # third-party code - ./tools/scons/, # third-party code - ./test/third_party/, # third-party code - ./site/source/conf.py, - ./site/source/_themes/, - ./system/lib/, # system libraries - ./cache/, # download/built content - .git -# The ports plugins have a lot of unused imports because -# they need to implement the specific plugin APIs -per-file-ignores = - ./tools/ports/*.py: U100 - ./test/*.py: U100 - ./tools/toolchain_profiler.py: U100 diff --git a/docs/process.md b/docs/process.md index 0c3b23b1062d7..f1bf04a714a11 100644 --- a/docs/process.md +++ b/docs/process.md @@ -55,8 +55,8 @@ pre-processor. See [`.clang-format`][clang-format] for more details. ### Python Code We generally follow the pep8 standard with the major exception that we use 2 -spaces for indentation. `flake8` is run on all PRs to ensure that python code -conforms to this style. See [`.flake8`][flake8] for more details. +spaces for indentation. `ruff` is run on all PRs to ensure that Python code +conforms to this style. See [`pyproject.toml`][pyproject.toml] for more details. #### Static Type Checking @@ -304,7 +304,7 @@ To update our libraries to a newer musl release: [emsdk_tags]: https://github.com/emscripten-core/emsdk/tags [emscripten_tags]: https://github.com/emscripten-core/emscripten/tags [clang-format]: https://github.com/emscripten-core/emscripten/blob/main/.clang-format -[flake8]: https://github.com/emscripten-core/emscripten/blob/main/.flake8 +[pyproject.toml]: https://github.com/emscripten-core/emscripten/blob/main/pyproject.toml [mypy]: https://github.com/emscripten-core/emscripten/blob/main/.mypy [update_docs]: https://github.com/emscripten-core/emscripten/blob/main/tools/maint/update_docs.py [llvm_repo]: https://github.com/llvm/llvm-project diff --git a/em-config.py b/em-config.py index 2708d18ca6dd2..bcbd9abe1cf8d 100755 --- a/em-config.py +++ b/em-config.py @@ -24,7 +24,7 @@ def main(): not re.match(r"^[\w\W_][\w\W_\d]*$", sys.argv[1]) or \ not hasattr(config, sys.argv[1]): print('Usage: em-config VAR_NAME', file=sys.stderr) - exit(1) + sys.exit(1) print(getattr(config, sys.argv[1])) return 0 diff --git a/emcc.py b/emcc.py index dfe088e7b75c0..7f30d13cdc058 100644 --- a/emcc.py +++ b/emcc.py @@ -1023,7 +1023,7 @@ def get_clang_command_asm(): if state.mode == Mode.PCH: inputs = [i[1] for i in input_files] for header in inputs: - if not shared.suffix(header) in HEADER_ENDINGS: + if shared.suffix(header) not in HEADER_ENDINGS: exit_with_error(f'cannot mix precompiled headers with non-header inputs: {inputs} : {header}') cmd = get_clang_command() + inputs if options.output_file: @@ -1127,7 +1127,15 @@ def version_string(): return f'emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) {utils.EMSCRIPTEN_VERSION}{revision_suffix}' -def parse_args(newargs): +def parse_args(newargs): # noqa: C901, PLR0912, PLR0915 + """Future modifications should consider refactoring to reduce complexity. + + * The McCabe cyclomatiic complexity is currently 117 vs 10 recommended. + * There are currently 115 branches vs 12 recommended. + * There are currently 302 statements vs 50 recommended. + + To revalidate these numbers, run `ruff check --select=C901,PLR091`. + """ options = EmccOptions() settings_changes = [] user_js_defines = [] diff --git a/emrun.py b/emrun.py index 90812813b4d48..0d33218c2d747 100644 --- a/emrun.py +++ b/emrun.py @@ -1583,7 +1583,15 @@ def parse_args(args): return parser.parse_args(args) -def run(args): +def run(args): # noqa: C901, PLR0912, PLR0915 + """Future modifications should consider refactoring to reduce complexity. + + * The McCabe cyclomatiic complexity is currently 74 vs 10 recommended. + * There are currently 86 branches vs 12 recommended. + * There are currently 202 statements vs 50 recommended. + + To revalidate these numbers, run `ruff check --select=C901,PLR091`. + """ global browser_process, browser_exe, processname_killed_atexit, emrun_options, emrun_not_enabled_nag_printed options = emrun_options = parse_args(args) diff --git a/emsymbolizer.py b/emsymbolizer.py index 1a9cf27f25d56..7ba3b951c852b 100755 --- a/emsymbolizer.py +++ b/emsymbolizer.py @@ -121,10 +121,8 @@ def parse(self, filename): self.version = source_map_json['version'] self.sources = source_map_json['sources'] - vlq_map = {} chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' - for i, c in enumerate(chars): - vlq_map[c] = i + vlq_map = {c: i for i, c in enumerate(chars)} def decodeVLQ(string): result = [] diff --git a/pyproject.toml b/pyproject.toml index 38bf2a5e67beb..f4c62aacb8f16 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,70 @@ +[tool.ruff] +exclude = [ + "./cache/", + "./node_modules/", + "./site/source/_themes/", + "./site/source/conf.py", + "./system/lib/", + "./test/third_party/", + "./third_party/", + "./tools/filelock.py", + "./tools/scons/", + ".git", +] + +lint.select = [ + "ARG", + "ASYNC", + "B", + "C90", + "E", + "F", + "PERF", + "PL", + "W", + "YTT", +] + +lint.ignore = [ + "ARG001", + "ARG002", + "ARG005", + "B006", + "B011", + "B018", + "B023", + "B026", + "B904", + "E402", + "E501", + "E721", + "E741", + "PERF203", + "PERF401", + "PLR1704", + "PLR1714", + "PLR5501", + "PLW0602", + "PLW0603", + "PLW1510", + "PLW2901", +] + +lint.per-file-ignores."emrun.py" = [ "PLE0704" ] + +lint.mccabe.max-complexity = 48 # Recommended: 10 + +lint.pylint.allow-magic-value-types = [ + "bytes", + "float", + "int", + "str", +] +lint.pylint.max-args = 15 # Recommended: 5 +lint.pylint.max-branches = 49 # Recommended: 12 +lint.pylint.max-returns = 16 # Recommended: 6 +lint.pylint.max-statements = 142 # Recommended: 50 + [tool.coverage.run] source = [ "." ] omit = [ diff --git a/requirements-dev.txt b/requirements-dev.txt index c67851c37317d..6fea74921d9df 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,14 +1,12 @@ # TODO(sbc): switch to using Pipenv since it seems like that way to go # these day managing python deps. -# These requirements are only needed for developers who want to run flake8 on +# These requirements are only needed for developers who want to run ruff on # the codebase and generate docs using Sphinx, not for users of emscripten. # Install with `pip3 install -r requirements-dev.txt` -flake8==5.0.4 -flake8-bugbear==22.9.23 -flake8-unused-arguments==0.0.11 coverage[toml]==5.5 mypy==0.971 +ruff==0.8.2 types-requests==2.27.14 unittest-xml-reporting==3.1.0 diff --git a/test/benchmark/benchmark_sse.py b/test/benchmark/benchmark_sse.py index 28b75dbbd8200..65f296c1dafce 100644 --- a/test/benchmark/benchmark_sse.py +++ b/test/benchmark/benchmark_sse.py @@ -134,14 +134,14 @@ def format_comparison(a, b): total_time_html_scalar = 0 total_time_html_simd = 0 - for chart_name in charts_native.keys(): + for chart_name, chart_native_results in charts_native.items(): # Extract data for each chart. categories = [] nativeScalarResults = [] nativeSimdResults = [] htmlScalarResults = [] htmlSimdResults = [] - native_results = charts_native[chart_name] + native_results = chart_native_results wasm_results = charts_html[chart_name] textual_results_native = '

' textual_results_html = '

' diff --git a/test/runner.py b/test/runner.py index 9808181e224be..5896fe4f15b9e 100755 --- a/test/runner.py +++ b/test/runner.py @@ -106,7 +106,7 @@ def check_js_engines(): working_engines = [e for e in config.JS_ENGINES if jsrun.check_engine(e)] if len(working_engines) < len(config.JS_ENGINES): print('Not all the JS engines in JS_ENGINES appears to work.') - exit(1) + sys.exit(1) if common.EMTEST_ALL_ENGINES: print('(using ALL js engines)') @@ -311,11 +311,9 @@ def load_test_suites(args, modules, start_at, repeat): def flattened_tests(loaded_tests): tests = [] for subsuite in loaded_tests: - for test in subsuite: - tests.append(test) + tests.extend(subsuite) return tests - def suite_for_module(module, tests): suite_supported = module.__name__ in ('test_core', 'test_other', 'test_posixtest') if not common.EMTEST_SAVE_DIR and not shared.DEBUG: diff --git a/tools/file_packager.py b/tools/file_packager.py index 123462418bd44..f2e2c7729fd01 100755 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -354,7 +354,15 @@ def generate_object_file(data_files): shared.check_call(cmd) -def main(): +def main(): # noqa: C901, PLR0912, PLR0915 + """Future modifications should consider refactoring to reduce complexity. + + * The McCabe cyclomatiic complexity is currently 60 vs 10 recommended. + * There are currently 63 branches vs 12 recommended. + * There are currently 151 statements vs 50 recommended. + + To revalidate these numbers, run `ruff check --select=C901,PLR091`. + """ if len(sys.argv) == 1: err('''Usage: file_packager TARGET [--preload A [B..]] [--embed C [D..]] [--exclude E [F..]]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--indexedDB-name=EM_PRELOAD_CACHE] [--separate-metadata] [--lz4] [--use-preload-plugins] [--no-node] See the source for more details.''') diff --git a/tools/link.py b/tools/link.py index 88f16036f7b92..cc90247085fb6 100644 --- a/tools/link.py +++ b/tools/link.py @@ -631,7 +631,15 @@ def check_browser_versions(): @ToolchainProfiler.profile_block('linker_setup') -def phase_linker_setup(options, state, newargs): +def phase_linker_setup(options, state, newargs): # noqa: C901, PLR0912, PLR0915 + """Future modifications should consider refactoring to reduce complexity. + + * The McCabe cyclomatiic complexity is currently 251 vs 10 recommended. + * There are currently 262 branches vs 12 recommended. + * There are currently 578 statements vs 50 recommended. + + To revalidate these numbers, run `ruff check --select=C901,PLR091`. + """ system_libpath = '-L' + str(cache.get_lib_dir(absolute=True)) state.append_link_flag(system_libpath) diff --git a/tools/webidl_binder.py b/tools/webidl_binder.py index b8a152608a324..2e54f792d58f8 100644 --- a/tools/webidl_binder.py +++ b/tools/webidl_binder.py @@ -386,10 +386,18 @@ def type_to_cdec(raw): return ret + '*' -def render_function(class_name, func_name, sigs, return_type, non_pointer, +def render_function(class_name, func_name, sigs, return_type, non_pointer, # noqa: C901, PLR0912, PLR0915 copy, operator, constructor, is_static, func_scope, call_content=None, const=False, array_attribute=False, bind_to=None): + """Future modifications should consider refactoring to reduce complexity. + + * The McCabe cyclomatiic complexity is currently 67 vs 10 recommended. + * There are currently 79 branches vs 12 recommended. + * There are currently 195 statements vs 50 recommended. + + To revalidate these numbers, run `ruff check --select=C901,PLR091`. + """ legacy_mode = CHECKS not in ['ALL', 'FAST'] all_checks = CHECKS == 'ALL' From 1604c82a04594b0dbf0c3660f8a9b511d57fdc9d Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 9 Dec 2024 12:52:05 -0800 Subject: [PATCH 035/132] Error on `--emrun` with `EXIT_RUNTIME=0` (#23096) The emrun post.js file depend on `addOnExit` to report the exit of the program. We were already forcing `-sEXIT_RUNTIME` but this adds an error if the user tries to explicitly disable it. --- tools/link.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/link.py b/tools/link.py index cc90247085fb6..d008759220c09 100644 --- a/tools/link.py +++ b/tools/link.py @@ -664,7 +664,11 @@ def phase_linker_setup(options, state, newargs): # noqa: C901, PLR0912, PLR0915 if options.emrun: options.pre_js.append(utils.path_from_root('src/emrun_prejs.js')) options.post_js.append(utils.path_from_root('src/emrun_postjs.js')) + if settings.MINIMAL_RUNTIME: + exit_with_error('--emrun is not compatible with MINIMAL_RUNTIME') # emrun mode waits on program exit + if user_settings.get('EXIT_RUNTIME') == '0': + exit_with_error('--emrun is not compatible with EXIT_RUNTIME=0') settings.EXIT_RUNTIME = 1 if options.cpu_profiler: @@ -972,9 +976,6 @@ def phase_linker_setup(options, state, newargs): # noqa: C901, PLR0912, PLR0915 if settings.MINIMAL_RUNTIME_STREAMING_WASM_COMPILATION and settings.MINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATION: exit_with_error('MINIMAL_RUNTIME_STREAMING_WASM_COMPILATION and MINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATION are mutually exclusive!') - if options.emrun and settings.MINIMAL_RUNTIME: - exit_with_error('--emrun is not compatible with MINIMAL_RUNTIME') - if options.use_closure_compiler: settings.USE_CLOSURE_COMPILER = 1 From 03c29b2a9a8ecdd60f99dac74e0a89d5a61a17c1 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 9 Dec 2024 13:25:09 -0800 Subject: [PATCH 036/132] Cleanup test_modularize_init_error. NFC (#23105) - Use browser_reporting.js directly. - Delete redundant unhandledrejection handler. browser_reporting handles this already. --- test/test_browser.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/test/test_browser.py b/test/test_browser.py index 6143486e91fa8..b5a6b97d93611 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -3342,9 +3342,10 @@ def test_modularize(self, opts): self.run_browser('a.html', '/report_result?0') def test_modularize_network_error(self): - browser_reporting_js_path = test_file('browser_reporting.js') - self.compile_btest('browser_test_hello_world.c', ['-sMODULARIZE', '-sEXPORT_NAME="createModule"', '--extern-pre-js', browser_reporting_js_path], reporting=Reporting.NONE) + self.compile_btest('browser_test_hello_world.c', ['-sMODULARIZE', '-sEXPORT_NAME=createModule'], reporting=Reporting.NONE) + shutil.copy(test_file('browser_reporting.js'), '.') create_file('a.html', ''' + - ''' % self.port) + ''' % self.PORT) cmd = [EMCC, test_file('hello_world_worker.c'), '-o', 'worker.js'] + self.get_emcc_args() if file_data: @@ -1671,7 +1671,7 @@ def test_chunked_synchronous_xhr(self): - """ % (worker_filename, self.port)) + """ % (worker_filename, self.PORT)) create_file('worker_prejs.js', r""" Module.arguments = ["/bigfile"]; @@ -1688,7 +1688,7 @@ def test_chunked_synchronous_xhr(self): data = os.urandom(10 * chunkSize + 1) # 10 full chunks and one 1 byte chunk checksum = zlib.adler32(data) & 0xffffffff # Python 2 compatibility: force bigint - server = multiprocessing.Process(target=test_chunked_synchronous_xhr_server, args=(True, chunkSize, data, checksum, self.port)) + server = multiprocessing.Process(target=test_chunked_synchronous_xhr_server, args=(True, chunkSize, data, checksum, self.PORT)) server.start() # block until the server is actually ready @@ -2422,7 +2422,7 @@ def test_runtime_misuse(self): doCwrapCall(200); doDirectCall(300); } - ''' % self.port + ''' % self.PORT create_file('pre_runtime.js', r''' Module.onRuntimeInitialized = myJSCallback; @@ -2569,7 +2569,7 @@ def test_html5_core(self, opts): window.disableErrorReporting = true; window.addEventListener('error', (event) => { if (!event.message.includes('exception:fullscreen error')) { - report_error(event); + reportTopLevelError(event); } }); ''') From ea874233bbef6a24ca1d3caaafb422d8cdfabdea Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 10 Dec 2024 10:36:26 -0800 Subject: [PATCH 043/132] Rebaseline codesize expectations. NFC --- test/code_size/embind_hello_wasm.json | 8 ++++---- test/code_size/embind_val_wasm.json | 8 ++++---- test/code_size/hello_webgl2_wasm.json | 8 ++++---- test/code_size/hello_webgl2_wasm2js.json | 8 ++++---- test/code_size/hello_webgl_wasm.json | 8 ++++---- test/code_size/hello_webgl_wasm2js.json | 8 ++++---- test/code_size/random_printf_wasm.json | 8 ++++---- test/code_size/random_printf_wasm2js.json | 8 ++++---- test/other/codesize/test_codesize_cxx_ctors1.size | 2 +- test/other/codesize/test_codesize_cxx_ctors2.size | 2 +- test/other/codesize/test_codesize_cxx_except.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.size | 2 +- .../codesize/test_codesize_cxx_except_wasm_exnref.size | 2 +- test/other/codesize/test_codesize_cxx_lto.size | 2 +- test/other/codesize/test_codesize_cxx_mangle.size | 2 +- test/other/codesize/test_codesize_cxx_noexcept.size | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.size | 2 +- test/other/codesize/test_codesize_files_wasmfs.exports | 8 ++++---- test/other/codesize/test_codesize_files_wasmfs.funcs | 3 --- test/other/codesize/test_codesize_files_wasmfs.gzsize | 2 +- test/other/codesize/test_codesize_files_wasmfs.imports | 5 ++--- test/other/codesize/test_codesize_files_wasmfs.jssize | 2 +- test/other/codesize/test_codesize_files_wasmfs.sent | 5 ++--- test/other/codesize/test_codesize_files_wasmfs.size | 2 +- test/other/codesize/test_codesize_hello_O0.size | 2 +- test/other/codesize/test_codesize_hello_O1.size | 2 +- test/other/codesize/test_codesize_minimal_O0.size | 2 +- test/other/codesize/test_codesize_minimal_O1.size | 2 +- test/other/codesize/test_codesize_minimal_pthreads.size | 2 +- test/other/test_unoptimized_code_size.wasm.size | 2 +- .../other/test_unoptimized_code_size_no_asserts.wasm.size | 2 +- test/other/test_unoptimized_code_size_strict.wasm.size | 2 +- 32 files changed, 60 insertions(+), 65 deletions(-) diff --git a/test/code_size/embind_hello_wasm.json b/test/code_size/embind_hello_wasm.json index f3b1d73bc6bec..37ad4ea025cd1 100644 --- a/test/code_size/embind_hello_wasm.json +++ b/test/code_size/embind_hello_wasm.json @@ -3,8 +3,8 @@ "a.html.gz": 380, "a.js": 9718, "a.js.gz": 4291, - "a.wasm": 7728, - "a.wasm.gz": 3502, - "total": 17998, - "total_gz": 8173 + "a.wasm": 7626, + "a.wasm.gz": 3444, + "total": 17896, + "total_gz": 8115 } diff --git a/test/code_size/embind_val_wasm.json b/test/code_size/embind_val_wasm.json index 9af792edee31e..fd9aaec726cc2 100644 --- a/test/code_size/embind_val_wasm.json +++ b/test/code_size/embind_val_wasm.json @@ -3,8 +3,8 @@ "a.html.gz": 380, "a.js": 6849, "a.js.gz": 2947, - "a.wasm": 9568, - "a.wasm.gz": 4911, - "total": 16969, - "total_gz": 8238 + "a.wasm": 9506, + "a.wasm.gz": 4872, + "total": 16907, + "total_gz": 8199 } diff --git a/test/code_size/hello_webgl2_wasm.json b/test/code_size/hello_webgl2_wasm.json index bf14a6e1a53c9..c944949a29c8c 100644 --- a/test/code_size/hello_webgl2_wasm.json +++ b/test/code_size/hello_webgl2_wasm.json @@ -3,8 +3,8 @@ "a.html.gz": 328, "a.js": 4532, "a.js.gz": 2315, - "a.wasm": 10402, - "a.wasm.gz": 6704, - "total": 15388, - "total_gz": 9347 + "a.wasm": 10377, + "a.wasm.gz": 6694, + "total": 15363, + "total_gz": 9337 } diff --git a/test/code_size/hello_webgl2_wasm2js.json b/test/code_size/hello_webgl2_wasm2js.json index 88cc365f6f5f7..62c056051c215 100644 --- a/test/code_size/hello_webgl2_wasm2js.json +++ b/test/code_size/hello_webgl2_wasm2js.json @@ -1,8 +1,8 @@ { "a.html": 346, "a.html.gz": 262, - "a.js": 22200, - "a.js.gz": 11582, - "total": 22546, - "total_gz": 11844 + "a.js": 22232, + "a.js.gz": 11612, + "total": 22578, + "total_gz": 11874 } diff --git a/test/code_size/hello_webgl_wasm.json b/test/code_size/hello_webgl_wasm.json index b20428e2fed64..f9432eddd1985 100644 --- a/test/code_size/hello_webgl_wasm.json +++ b/test/code_size/hello_webgl_wasm.json @@ -3,8 +3,8 @@ "a.html.gz": 328, "a.js": 4070, "a.js.gz": 2158, - "a.wasm": 10402, - "a.wasm.gz": 6704, - "total": 14926, - "total_gz": 9190 + "a.wasm": 10377, + "a.wasm.gz": 6694, + "total": 14901, + "total_gz": 9180 } diff --git a/test/code_size/hello_webgl_wasm2js.json b/test/code_size/hello_webgl_wasm2js.json index bc0dfe84d64a8..01af46e9951c2 100644 --- a/test/code_size/hello_webgl_wasm2js.json +++ b/test/code_size/hello_webgl_wasm2js.json @@ -1,8 +1,8 @@ { "a.html": 346, "a.html.gz": 262, - "a.js": 21726, - "a.js.gz": 11415, - "total": 22072, - "total_gz": 11677 + "a.js": 21758, + "a.js.gz": 11442, + "total": 22104, + "total_gz": 11704 } diff --git a/test/code_size/random_printf_wasm.json b/test/code_size/random_printf_wasm.json index 8548e41737392..3b0a3c6494de1 100644 --- a/test/code_size/random_printf_wasm.json +++ b/test/code_size/random_printf_wasm.json @@ -1,6 +1,6 @@ { - "a.html": 12597, - "a.html.gz": 6882, - "total": 12597, - "total_gz": 6882 + "a.html": 12589, + "a.html.gz": 6888, + "total": 12589, + "total_gz": 6888 } diff --git a/test/code_size/random_printf_wasm2js.json b/test/code_size/random_printf_wasm2js.json index b3fe0c465524e..335e5aa2294d8 100644 --- a/test/code_size/random_printf_wasm2js.json +++ b/test/code_size/random_printf_wasm2js.json @@ -1,6 +1,6 @@ { - "a.html": 17195, - "a.html.gz": 7478, - "total": 17195, - "total_gz": 7478 + "a.html": 17246, + "a.html.gz": 7510, + "total": 17246, + "total_gz": 7510 } diff --git a/test/other/codesize/test_codesize_cxx_ctors1.size b/test/other/codesize/test_codesize_cxx_ctors1.size index 67d610a7db4b8..0abcbf920f536 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.size +++ b/test/other/codesize/test_codesize_cxx_ctors1.size @@ -1 +1 @@ -129276 +128890 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.size b/test/other/codesize/test_codesize_cxx_ctors2.size index 8649e524047b6..77cd041ba9afb 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.size +++ b/test/other/codesize/test_codesize_cxx_ctors2.size @@ -1 +1 @@ -128722 +128302 diff --git a/test/other/codesize/test_codesize_cxx_except.size b/test/other/codesize/test_codesize_cxx_except.size index 276e7d93de41a..caf2ab90b0cf5 100644 --- a/test/other/codesize/test_codesize_cxx_except.size +++ b/test/other/codesize/test_codesize_cxx_except.size @@ -1 +1 @@ -171406 +171023 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.size b/test/other/codesize/test_codesize_cxx_except_wasm.size index 0053d027ae5a6..ccbed055ad10f 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm.size @@ -1 +1 @@ -142526 +142151 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size index 1c842906f1e3e..1e4b02eaea0f0 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size @@ -1 +1 @@ -145113 +144738 diff --git a/test/other/codesize/test_codesize_cxx_lto.size b/test/other/codesize/test_codesize_cxx_lto.size index f7d77bf63d1d7..5cf7ff329aeb0 100644 --- a/test/other/codesize/test_codesize_cxx_lto.size +++ b/test/other/codesize/test_codesize_cxx_lto.size @@ -1 +1 @@ -121985 +121835 diff --git a/test/other/codesize/test_codesize_cxx_mangle.size b/test/other/codesize/test_codesize_cxx_mangle.size index 234bba9899039..eed6548e69424 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.size +++ b/test/other/codesize/test_codesize_cxx_mangle.size @@ -1 +1 @@ -232917 +232546 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.size b/test/other/codesize/test_codesize_cxx_noexcept.size index 4357180d28887..fcdf3f0fb5f09 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.size +++ b/test/other/codesize/test_codesize_cxx_noexcept.size @@ -1 +1 @@ -132083 +131701 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.size b/test/other/codesize/test_codesize_cxx_wasmfs.size index 206a908899546..7793aed3bb3ed 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.size +++ b/test/other/codesize/test_codesize_cxx_wasmfs.size @@ -1 +1 @@ -169526 +169030 diff --git a/test/other/codesize/test_codesize_files_wasmfs.exports b/test/other/codesize/test_codesize_files_wasmfs.exports index 1b3d6ede9e560..b64e135c8e3cf 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.exports +++ b/test/other/codesize/test_codesize_files_wasmfs.exports @@ -1,4 +1,4 @@ -q (memory) -r (__wasm_call_ctors) -s (main) -t (__indirect_function_table) +p (memory) +q (__wasm_call_ctors) +r (main) +s (__indirect_function_table) diff --git a/test/other/codesize/test_codesize_files_wasmfs.funcs b/test/other/codesize/test_codesize_files_wasmfs.funcs index c13be46f97079..1fec0a5640720 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.funcs +++ b/test/other/codesize/test_codesize_files_wasmfs.funcs @@ -22,8 +22,6 @@ $__cxxabiv1::__vmi_class_type_info::has_unambiguous_public_base\28__cxxabiv1::__ $__cxxabiv1::__vmi_class_type_info::search_above_dst\28__cxxabiv1::__dynamic_cast_info*\2c\20void\20const*\2c\20void\20const*\2c\20int\2c\20bool\29\20const $__cxxabiv1::__vmi_class_type_info::search_below_dst\28__cxxabiv1::__dynamic_cast_info*\2c\20void\20const*\2c\20int\2c\20bool\29\20const $__lockfile -$__memcpy -$__memset $__pthread_mutex_lock $__throw_bad_alloc_shim\28\29 $__unlockfile @@ -38,7 +36,6 @@ $fflush $is_equal\28std::type_info\20const*\2c\20std::type_info\20const*\2c\20bool\29 $main $memcmp -$memmove $operator\20delete\28void*\29 $operator\20new\28unsigned\20long\29 $pthread_mutex_init diff --git a/test/other/codesize/test_codesize_files_wasmfs.gzsize b/test/other/codesize/test_codesize_files_wasmfs.gzsize index 31958abcd5ee2..a4fe1614722ba 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_files_wasmfs.gzsize @@ -1 +1 @@ -2959 +2941 diff --git a/test/other/codesize/test_codesize_files_wasmfs.imports b/test/other/codesize/test_codesize_files_wasmfs.imports index 74ec884c2cde4..519a7e0d06403 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.imports +++ b/test/other/codesize/test_codesize_files_wasmfs.imports @@ -11,6 +11,5 @@ j (_wasmfs_get_preloaded_child_path) k (_wasmfs_get_num_preloaded_files) l (_wasmfs_get_num_preloaded_dirs) m (_wasmfs_copy_preloaded_file_data) -n (_emscripten_memcpy_js) -o (_abort_js) -p (random_get) +n (_abort_js) +o (random_get) diff --git a/test/other/codesize/test_codesize_files_wasmfs.jssize b/test/other/codesize/test_codesize_files_wasmfs.jssize index f6561f6d44455..83aaf27e746bc 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.jssize +++ b/test/other/codesize/test_codesize_files_wasmfs.jssize @@ -1 +1 @@ -6277 +6244 diff --git a/test/other/codesize/test_codesize_files_wasmfs.sent b/test/other/codesize/test_codesize_files_wasmfs.sent index 74ec884c2cde4..519a7e0d06403 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.sent +++ b/test/other/codesize/test_codesize_files_wasmfs.sent @@ -11,6 +11,5 @@ j (_wasmfs_get_preloaded_child_path) k (_wasmfs_get_num_preloaded_files) l (_wasmfs_get_num_preloaded_dirs) m (_wasmfs_copy_preloaded_file_data) -n (_emscripten_memcpy_js) -o (_abort_js) -p (random_get) +n (_abort_js) +o (random_get) diff --git a/test/other/codesize/test_codesize_files_wasmfs.size b/test/other/codesize/test_codesize_files_wasmfs.size index 8dbc1b508195f..246d6dcce2d30 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.size +++ b/test/other/codesize/test_codesize_files_wasmfs.size @@ -1 +1 @@ -51157 +49889 diff --git a/test/other/codesize/test_codesize_hello_O0.size b/test/other/codesize/test_codesize_hello_O0.size index b55e8eb4cd221..c2551efd9da3d 100644 --- a/test/other/codesize/test_codesize_hello_O0.size +++ b/test/other/codesize/test_codesize_hello_O0.size @@ -1 +1 @@ -14531 +14544 diff --git a/test/other/codesize/test_codesize_hello_O1.size b/test/other/codesize/test_codesize_hello_O1.size index 48c6e93066ff9..b86f0690ffbed 100644 --- a/test/other/codesize/test_codesize_hello_O1.size +++ b/test/other/codesize/test_codesize_hello_O1.size @@ -1 +1 @@ -2535 +2552 diff --git a/test/other/codesize/test_codesize_minimal_O0.size b/test/other/codesize/test_codesize_minimal_O0.size index 37cdd416f157a..7f9d7e97a5258 100644 --- a/test/other/codesize/test_codesize_minimal_O0.size +++ b/test/other/codesize/test_codesize_minimal_O0.size @@ -1 +1 @@ -975 +992 diff --git a/test/other/codesize/test_codesize_minimal_O1.size b/test/other/codesize/test_codesize_minimal_O1.size index 100000a67875f..25685cf6b3219 100644 --- a/test/other/codesize/test_codesize_minimal_O1.size +++ b/test/other/codesize/test_codesize_minimal_O1.size @@ -1 +1 @@ -376 +393 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.size b/test/other/codesize/test_codesize_minimal_pthreads.size index 6dc04c8da057f..0a5bf4b2a51ac 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.size +++ b/test/other/codesize/test_codesize_minimal_pthreads.size @@ -1 +1 @@ -19491 +19487 diff --git a/test/other/test_unoptimized_code_size.wasm.size b/test/other/test_unoptimized_code_size.wasm.size index b55e8eb4cd221..c2551efd9da3d 100644 --- a/test/other/test_unoptimized_code_size.wasm.size +++ b/test/other/test_unoptimized_code_size.wasm.size @@ -1 +1 @@ -14531 +14544 diff --git a/test/other/test_unoptimized_code_size_no_asserts.wasm.size b/test/other/test_unoptimized_code_size_no_asserts.wasm.size index a65dc9b14619a..89916bd925f25 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.wasm.size +++ b/test/other/test_unoptimized_code_size_no_asserts.wasm.size @@ -1 +1 @@ -11724 +11737 diff --git a/test/other/test_unoptimized_code_size_strict.wasm.size b/test/other/test_unoptimized_code_size_strict.wasm.size index b55e8eb4cd221..c2551efd9da3d 100644 --- a/test/other/test_unoptimized_code_size_strict.wasm.size +++ b/test/other/test_unoptimized_code_size_strict.wasm.size @@ -1 +1 @@ -14531 +14544 From af2da320fe31d435595d021292b4af6b55c24656 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 10 Dec 2024 13:35:09 -0800 Subject: [PATCH 044/132] Use async/await instead of promises for wasm loading. NFC (#23068) These get lowered away by babel when targetting older engines. Followup to #23066, with code size savings. --- ChangeLog.md | 3 + src/preamble.js | 187 ++++++++---------- .../codesize/test_codesize_cxx_ctors1.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors1.jssize | 2 +- .../codesize/test_codesize_cxx_ctors2.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors2.jssize | 2 +- .../codesize/test_codesize_cxx_except.gzsize | 2 +- .../codesize/test_codesize_cxx_except.jssize | 2 +- .../test_codesize_cxx_except_wasm.gzsize | 2 +- .../test_codesize_cxx_except_wasm.jssize | 2 +- ...est_codesize_cxx_except_wasm_exnref.gzsize | 2 +- ...est_codesize_cxx_except_wasm_exnref.jssize | 2 +- .../codesize/test_codesize_cxx_lto.gzsize | 2 +- .../codesize/test_codesize_cxx_lto.jssize | 2 +- .../codesize/test_codesize_cxx_mangle.gzsize | 2 +- .../codesize/test_codesize_cxx_mangle.jssize | 2 +- .../test_codesize_cxx_noexcept.gzsize | 2 +- .../test_codesize_cxx_noexcept.jssize | 2 +- .../codesize/test_codesize_cxx_wasmfs.gzsize | 2 +- .../codesize/test_codesize_cxx_wasmfs.jssize | 2 +- .../codesize/test_codesize_files_js_fs.gzsize | 2 +- .../codesize/test_codesize_files_js_fs.jssize | 2 +- .../test_codesize_files_wasmfs.gzsize | 2 +- .../test_codesize_files_wasmfs.jssize | 2 +- .../codesize/test_codesize_hello_O0.gzsize | 2 +- .../codesize/test_codesize_hello_O0.jssize | 2 +- .../codesize/test_codesize_hello_O1.gzsize | 2 +- .../codesize/test_codesize_hello_O1.jssize | 2 +- .../codesize/test_codesize_hello_O2.gzsize | 2 +- .../codesize/test_codesize_hello_O2.jssize | 2 +- .../codesize/test_codesize_hello_O3.gzsize | 2 +- .../codesize/test_codesize_hello_O3.jssize | 2 +- .../codesize/test_codesize_hello_Os.gzsize | 2 +- .../codesize/test_codesize_hello_Os.jssize | 2 +- .../codesize/test_codesize_hello_Oz.gzsize | 2 +- .../codesize/test_codesize_hello_Oz.jssize | 2 +- .../test_codesize_hello_dylink.gzsize | 2 +- .../test_codesize_hello_dylink.jssize | 2 +- .../test_codesize_hello_export_nothing.gzsize | 2 +- .../test_codesize_hello_export_nothing.jssize | 2 +- .../test_codesize_hello_wasmfs.gzsize | 2 +- .../test_codesize_hello_wasmfs.jssize | 2 +- .../test_codesize_libcxxabi_message_O3.gzsize | 2 +- .../test_codesize_libcxxabi_message_O3.jssize | 2 +- ...ize_libcxxabi_message_O3_standalone.gzsize | 2 +- ...ize_libcxxabi_message_O3_standalone.jssize | 2 +- .../codesize/test_codesize_mem_O3.gzsize | 2 +- .../codesize/test_codesize_mem_O3.jssize | 2 +- .../codesize/test_codesize_mem_O3_grow.gzsize | 2 +- .../codesize/test_codesize_mem_O3_grow.jssize | 2 +- ...est_codesize_mem_O3_grow_standalone.gzsize | 2 +- ...est_codesize_mem_O3_grow_standalone.jssize | 2 +- .../test_codesize_mem_O3_standalone.gzsize | 2 +- .../test_codesize_mem_O3_standalone.jssize | 2 +- ...test_codesize_mem_O3_standalone_lib.gzsize | 2 +- ...test_codesize_mem_O3_standalone_lib.jssize | 2 +- ...est_codesize_mem_O3_standalone_narg.gzsize | 2 +- ...est_codesize_mem_O3_standalone_narg.jssize | 2 +- ...odesize_mem_O3_standalone_narg_flto.gzsize | 2 +- ...odesize_mem_O3_standalone_narg_flto.jssize | 2 +- .../codesize/test_codesize_minimal_64.gzsize | 2 +- .../codesize/test_codesize_minimal_64.jssize | 2 +- .../codesize/test_codesize_minimal_O0.gzsize | 2 +- .../codesize/test_codesize_minimal_O0.jssize | 2 +- .../codesize/test_codesize_minimal_O1.gzsize | 2 +- .../codesize/test_codesize_minimal_O1.jssize | 2 +- .../codesize/test_codesize_minimal_O2.gzsize | 2 +- .../codesize/test_codesize_minimal_O2.jssize | 2 +- .../codesize/test_codesize_minimal_O3.gzsize | 2 +- .../codesize/test_codesize_minimal_O3.jssize | 2 +- .../codesize/test_codesize_minimal_Os.gzsize | 2 +- .../codesize/test_codesize_minimal_Os.jssize | 2 +- .../test_codesize_minimal_Oz-ctors.gzsize | 2 +- .../test_codesize_minimal_Oz-ctors.jssize | 2 +- .../codesize/test_codesize_minimal_Oz.gzsize | 2 +- .../codesize/test_codesize_minimal_Oz.jssize | 2 +- .../test_codesize_minimal_pthreads.gzsize | 2 +- .../test_codesize_minimal_pthreads.jssize | 2 +- .../test_codesize_minimal_wasmfs.gzsize | 2 +- .../test_codesize_minimal_wasmfs.jssize | 2 +- test/other/test_unoptimized_code_size.js.size | 2 +- ...t_unoptimized_code_size_no_asserts.js.size | 2 +- .../test_unoptimized_code_size_strict.js.size | 2 +- test/test_browser.py | 2 +- test/test_other.py | 33 ++-- tools/emscripten.py | 5 +- 86 files changed, 193 insertions(+), 199 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 39938f12e5a7a..c38e5207ea6f1 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -23,6 +23,9 @@ See docs/process.md for more on how version tagging works. - The file system was updated to independently track atime, mtime and ctime instead of using the same time for all three. (#22998) - The minimum supported chrome version was bumped from 32 to 33. (#23077) +- Emscripten-generated code will now use async/await internally when loading + the Wasm module. This will be lowered away by babel when targeting older + browsers. (#23068) 3.1.73 - 11/28/24 ----------------- diff --git a/src/preamble.js b/src/preamble.js index af274a7ac888f..d097c857f89be 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -647,7 +647,7 @@ function getBinarySync(file) { #endif } -function getBinaryPromise(binaryFile) { +async function getWasmBinary(binaryFile) { #if !SINGLE_FILE // If we don't have the binary yet, load it asynchronously using readAsync. if (!wasmBinary @@ -656,16 +656,17 @@ function getBinaryPromise(binaryFile) { #endif ) { // Fetch the binary using readAsync - return readAsync(binaryFile).then( - (response) => new Uint8Array(/** @type{!ArrayBuffer} */(response)), - // Fall back to getBinarySync if readAsync fails - () => getBinarySync(binaryFile) - ); + try { + var response = await readAsync(binaryFile); + return new Uint8Array(response); + } catch { + // Fall back to getBinarySync below; + } } #endif // Otherwise, getBinarySync should be able to get it synchronously - return Promise.resolve(getBinarySync(binaryFile)); + return getBinarySync(binaryFile); } #if LOAD_SOURCE_MAP @@ -773,56 +774,47 @@ function resetPrototype(constructor, attrs) { #endif #if WASM_ASYNC_COMPILATION -function instantiateArrayBuffer(binaryFile, imports) { +async function instantiateArrayBuffer(binaryFile, imports) { + try { + var binary = await getWasmBinary(binaryFile); + var instance = await WebAssembly.instantiate(binary, imports); #if USE_OFFSET_CONVERTER - var savedBinary; + // wasmOffsetConverter needs to be assigned before calling resolve. + // See comments below in instantiateAsync. + wasmOffsetConverter = new WasmOffsetConverter(binary, instance.module); #endif - return new Promise((resolve, reject) => { - getBinaryPromise(binaryFile).then((binary) => { -#if USE_OFFSET_CONVERTER - savedBinary = binary; -#endif - return WebAssembly.instantiate(binary, imports); -#if USE_OFFSET_CONVERTER - }).then((instance) => { - // wasmOffsetConverter needs to be assigned before calling resolve. - // See comments below in instantiateAsync. - wasmOffsetConverter = new WasmOffsetConverter(savedBinary, instance.module); - return instance; -#endif - }).then(resolve, (reason) => { - err(`failed to asynchronously prepare wasm: ${reason}`); - + return instance; + } catch (reason) { + err(`failed to asynchronously prepare wasm: ${reason}`); #if WASM == 2 #if ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL - if (typeof location != 'undefined') { -#endif - // WebAssembly compilation failed, try running the JS fallback instead. - var search = location.search; - if (search.indexOf('_rwasm=0') < 0) { - location.href += (search ? search + '&' : '?') + '_rwasm=0'; - // Return here to avoid calling abort() below. The application - // still has a chance to start successfully do we don't want to - // trigger onAbort or onExit handlers. - return; - } -#if ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL + if (typeof location != 'undefined') { +#endif + // WebAssembly compilation failed, try running the JS fallback instead. + var search = location.search; + if (search.indexOf('_rwasm=0') < 0) { + // Reload the page with the `_rwasm=0` argument + location.href += (search ? search + '&' : '?') + '_rwasm=0'; + // Return a promise that never resolves. We don't want to + // call abort below, or return an error to our caller. + return new Promise(() => {}); } +#if ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL + } #endif #endif // WASM == 2 #if ASSERTIONS - // Warn on some common problems. - if (isFileURI(wasmBinaryFile)) { - err(`warning: Loading from a file URI (${wasmBinaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`); - } + // Warn on some common problems. + if (isFileURI(wasmBinaryFile)) { + err(`warning: Loading from a file URI (${wasmBinaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`); + } #endif - abort(reason); - }); - }); + abort(reason); + } } -function instantiateAsync(binary, binaryFile, imports) { +async function instantiateAsync(binary, binaryFile, imports) { #if !SINGLE_FILE if (!binary && typeof WebAssembly.instantiateStreaming == 'function' && @@ -841,56 +833,41 @@ function instantiateAsync(binary, binaryFile, imports) { !ENVIRONMENT_IS_NODE && #endif typeof fetch == 'function') { - return new Promise((resolve) => { - fetch(binaryFile, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}).then((response) => { - // Suppress closure warning here since the upstream definition for - // instantiateStreaming only allows Promise rather than - // an actual Response. - // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure is fixed. - /** @suppress {checkTypes} */ - var result = WebAssembly.instantiateStreaming(response, imports); - + try { + var response = fetch(binaryFile, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}); #if USE_OFFSET_CONVERTER - // We need the wasm binary for the offset converter. Clone the response - // in order to get its arrayBuffer (cloning should be more efficient - // than doing another entire request). - // (We must clone the response now in order to use it later, as if we - // try to clone it asynchronously lower down then we will get a - // "response was already consumed" error.) - var clonedResponsePromise = response.clone().arrayBuffer(); -#endif - - result.then( + // We need the wasm binary for the offset converter. Clone the response + // in order to get its arrayBuffer (cloning should be more efficient + // than doing another entire request). + // (We must clone the response now in order to use it later, as if we + // try to clone it asynchronously lower down then we will get a + // "response was already consumed" error.) + var clonedResponse = (await response).clone(); +#endif + var instantiationResult = await WebAssembly.instantiateStreaming(response, imports); #if USE_OFFSET_CONVERTER - (instantiationResult) => { - // When using the offset converter, we must interpose here. First, - // the instantiation result must arrive (if it fails, the error - // handling later down will handle it). Once it arrives, we can - // initialize the offset converter. And only then is it valid to - // call receiveInstantiationResult, as that function will use the - // offset converter (in the case of pthreads, it will create the - // pthreads and send them the offsets along with the wasm instance). - - clonedResponsePromise.then((arrayBufferResult) => { - wasmOffsetConverter = new WasmOffsetConverter(new Uint8Array(arrayBufferResult), instantiationResult.module); - resolve(instantiationResult); - }, - (reason) => err(`failed to initialize offset-converter: ${reason}`) - ); - }, -#else - resolve, -#endif - (reason) => { - // We expect the most common failure cause to be a bad MIME type for the binary, - // in which case falling back to ArrayBuffer instantiation should work. - err(`wasm streaming compile failed: ${reason}`); - err('falling back to ArrayBuffer instantiation'); - return resolve(instantiateArrayBuffer(binaryFile, imports)); - } - ); - }); - }); + // When using the offset converter, we must interpose here. First, + // the instantiation result must arrive (if it fails, the error + // handling later down will handle it). Once it arrives, we can + // initialize the offset converter. And only then is it valid to + // call receiveInstantiationResult, as that function will use the + // offset converter (in the case of pthreads, it will create the + // pthreads and send them the offsets along with the wasm instance). + var arrayBufferResult = await clonedResponse.arrayBuffer(); + try { + wasmOffsetConverter = new WasmOffsetConverter(new Uint8Array(arrayBufferResult), instantiationResult.module); + } catch (reason) { + err(`failed to initialize offset-converter: ${reason}`); + } +#endif + return instantiationResult; + } catch (reason) { + // We expect the most common failure cause to be a bad MIME type for the binary, + // in which case falling back to ArrayBuffer instantiation should work. + err(`wasm streaming compile failed: ${reason}`); + err('falling back to ArrayBuffer instantiation'); + // fall back of instantiateArrayBuffer below + }; } #endif return instantiateArrayBuffer(binaryFile, imports); @@ -936,7 +913,7 @@ function getWasmImports() { // Create the wasm instance. // Receives the wasm imports, returns the exports. -function createWasm() { +{{{ asyncIf(WASM_ASYNC_COMPILATION) }}} function createWasm() { // Load the wasm module and create an instance of using native support in the JS engine. // handle a generated wasm instance, receiving its exports and // performing other necessary setup @@ -1104,17 +1081,23 @@ function createWasm() { #if RUNTIME_DEBUG dbg('asynchronously preparing wasm'); #endif - instantiateAsync(wasmBinary, wasmBinaryFile, info).then(receiveInstantiationResult) #if MODULARIZE - // If instantiation fails, reject the module ready promise. - .catch(readyPromiseReject) + try { #endif - ; + var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info); + receiveInstantiationResult(result); #if LOAD_SOURCE_MAP - getSourceMapPromise().then(receiveSourceMapJSON); + receiveSourceMapJSON(await getSourceMapPromise()); #endif - return {}; // no exports yet; we'll fill them in later -#else + return result; +#if MODULARIZE + } catch (e) { + // If instantiation fails, reject the module ready promise. + readyPromiseReject(e); + return; + } +#endif +#else // WASM_ASYNC_COMPILATION var result = instantiateSync(wasmBinaryFile, info); #if PTHREADS || MAIN_MODULE return receiveInstance(result[0], result[1]); @@ -1124,7 +1107,7 @@ function createWasm() { // When the regression is fixed, we can remove this if/else. return receiveInstance(result[0]); #endif -#endif +#endif // WASM_ASYNC_COMPILATION } #if !WASM_BIGINT diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 41c0b94155b12..25b558280e945 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8592 +8576 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index f411f89f35087..f0d741b18ae22 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -21002 +20969 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index b6b3cc1b768f1..3ea5f236f6c35 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8578 +8560 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index f0d741b18ae22..4ef99cdd0785e 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20969 +20937 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 699dbbf52f13f..0fa8352cf2331 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9626 +9614 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 6a720ff726ff1..4a76440f1a1cc 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24845 +24814 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index d9d8063900671..e6ab5d0c9b589 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8562 +8543 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index b8733f59e9281..8b47153f81043 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20895 +20863 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index d9d8063900671..e6ab5d0c9b589 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8562 +8543 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index b8733f59e9281..8b47153f81043 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20895 +20863 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 67e22b94ef20a..732a842aa12a6 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8490 +8475 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 9ebbda6b548c9..c8b5e7421405b 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20580 +20548 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index 4dda8754d31a0..58e0f00ae02c8 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9629 +9613 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 6a720ff726ff1..4a76440f1a1cc 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24845 +24814 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 41c0b94155b12..25b558280e945 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8592 +8576 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index f411f89f35087..f0d741b18ae22 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -21002 +20969 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize index d8d3e7a082033..24a12a49287ba 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize @@ -1 +1 @@ -3865 +3836 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.jssize b/test/other/codesize/test_codesize_cxx_wasmfs.jssize index d870f6684df37..c4ec7c412ff1e 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.jssize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.jssize @@ -1 +1 @@ -8639 +8606 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index edc514e920e03..956717deae581 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7730 +7710 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index b88e32899034b..2314d683d7cb3 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18909 +18876 diff --git a/test/other/codesize/test_codesize_files_wasmfs.gzsize b/test/other/codesize/test_codesize_files_wasmfs.gzsize index a4fe1614722ba..43a5478d767d8 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_files_wasmfs.gzsize @@ -1 +1 @@ -2941 +2915 diff --git a/test/other/codesize/test_codesize_files_wasmfs.jssize b/test/other/codesize/test_codesize_files_wasmfs.jssize index 83aaf27e746bc..5aecb7d32517a 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.jssize +++ b/test/other/codesize/test_codesize_files_wasmfs.jssize @@ -1 +1 @@ -6244 +6214 diff --git a/test/other/codesize/test_codesize_hello_O0.gzsize b/test/other/codesize/test_codesize_hello_O0.gzsize index f436d64e54792..af0a7b0a886ac 100644 --- a/test/other/codesize/test_codesize_hello_O0.gzsize +++ b/test/other/codesize/test_codesize_hello_O0.gzsize @@ -1 +1 @@ -8043 +8034 diff --git a/test/other/codesize/test_codesize_hello_O0.jssize b/test/other/codesize/test_codesize_hello_O0.jssize index 1f1ac91c270cf..0b07ab883de47 100644 --- a/test/other/codesize/test_codesize_hello_O0.jssize +++ b/test/other/codesize/test_codesize_hello_O0.jssize @@ -1 +1 @@ -21457 +21479 diff --git a/test/other/codesize/test_codesize_hello_O1.gzsize b/test/other/codesize/test_codesize_hello_O1.gzsize index 621b7ce5342a6..ece5108dd4bce 100644 --- a/test/other/codesize/test_codesize_hello_O1.gzsize +++ b/test/other/codesize/test_codesize_hello_O1.gzsize @@ -1 +1 @@ -2788 +2785 diff --git a/test/other/codesize/test_codesize_hello_O1.jssize b/test/other/codesize/test_codesize_hello_O1.jssize index 027dd3849dd58..13068939d1a42 100644 --- a/test/other/codesize/test_codesize_hello_O1.jssize +++ b/test/other/codesize/test_codesize_hello_O1.jssize @@ -1 +1 @@ -7021 +7004 diff --git a/test/other/codesize/test_codesize_hello_O2.gzsize b/test/other/codesize/test_codesize_hello_O2.gzsize index 8aa001e241409..51d5790fa9f86 100644 --- a/test/other/codesize/test_codesize_hello_O2.gzsize +++ b/test/other/codesize/test_codesize_hello_O2.gzsize @@ -1 +1 @@ -2462 +2434 diff --git a/test/other/codesize/test_codesize_hello_O2.jssize b/test/other/codesize/test_codesize_hello_O2.jssize index 5a3b1c0e3cc2a..032c246660549 100644 --- a/test/other/codesize/test_codesize_hello_O2.jssize +++ b/test/other/codesize/test_codesize_hello_O2.jssize @@ -1 +1 @@ -4984 +4955 diff --git a/test/other/codesize/test_codesize_hello_O3.gzsize b/test/other/codesize/test_codesize_hello_O3.gzsize index 37a2cebe6b9c9..c4fdb9ba8959b 100644 --- a/test/other/codesize/test_codesize_hello_O3.gzsize +++ b/test/other/codesize/test_codesize_hello_O3.gzsize @@ -1 +1 @@ -2380 +2346 diff --git a/test/other/codesize/test_codesize_hello_O3.jssize b/test/other/codesize/test_codesize_hello_O3.jssize index ddeb3cf88bf70..534d8e6bdcc90 100644 --- a/test/other/codesize/test_codesize_hello_O3.jssize +++ b/test/other/codesize/test_codesize_hello_O3.jssize @@ -1 +1 @@ -4830 +4802 diff --git a/test/other/codesize/test_codesize_hello_Os.gzsize b/test/other/codesize/test_codesize_hello_Os.gzsize index 37a2cebe6b9c9..c4fdb9ba8959b 100644 --- a/test/other/codesize/test_codesize_hello_Os.gzsize +++ b/test/other/codesize/test_codesize_hello_Os.gzsize @@ -1 +1 @@ -2380 +2346 diff --git a/test/other/codesize/test_codesize_hello_Os.jssize b/test/other/codesize/test_codesize_hello_Os.jssize index ddeb3cf88bf70..534d8e6bdcc90 100644 --- a/test/other/codesize/test_codesize_hello_Os.jssize +++ b/test/other/codesize/test_codesize_hello_Os.jssize @@ -1 +1 @@ -4830 +4802 diff --git a/test/other/codesize/test_codesize_hello_Oz.gzsize b/test/other/codesize/test_codesize_hello_Oz.gzsize index 7d945b944dabc..ffcd151c41f04 100644 --- a/test/other/codesize/test_codesize_hello_Oz.gzsize +++ b/test/other/codesize/test_codesize_hello_Oz.gzsize @@ -1 +1 @@ -2359 +2328 diff --git a/test/other/codesize/test_codesize_hello_Oz.jssize b/test/other/codesize/test_codesize_hello_Oz.jssize index f2bb280333202..9f4f637fcdccb 100644 --- a/test/other/codesize/test_codesize_hello_Oz.jssize +++ b/test/other/codesize/test_codesize_hello_Oz.jssize @@ -1 +1 @@ -4797 +4769 diff --git a/test/other/codesize/test_codesize_hello_dylink.gzsize b/test/other/codesize/test_codesize_hello_dylink.gzsize index d18a1e2dd1c2e..e88f7f6787c9d 100644 --- a/test/other/codesize/test_codesize_hello_dylink.gzsize +++ b/test/other/codesize/test_codesize_hello_dylink.gzsize @@ -1 +1 @@ -6246 +6227 diff --git a/test/other/codesize/test_codesize_hello_dylink.jssize b/test/other/codesize/test_codesize_hello_dylink.jssize index 99087d0d64926..a9336124ba7fb 100644 --- a/test/other/codesize/test_codesize_hello_dylink.jssize +++ b/test/other/codesize/test_codesize_hello_dylink.jssize @@ -1 +1 @@ -13767 +13729 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.gzsize b/test/other/codesize/test_codesize_hello_export_nothing.gzsize index 8d937ef32a302..a894381fc572f 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.gzsize +++ b/test/other/codesize/test_codesize_hello_export_nothing.gzsize @@ -1 +1 @@ -1736 +1721 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.jssize b/test/other/codesize/test_codesize_hello_export_nothing.jssize index bb7949a47215f..1e144d1f73aa3 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.jssize +++ b/test/other/codesize/test_codesize_hello_export_nothing.jssize @@ -1 +1 @@ -3687 +3662 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.gzsize b/test/other/codesize/test_codesize_hello_wasmfs.gzsize index 37a2cebe6b9c9..c4fdb9ba8959b 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_hello_wasmfs.gzsize @@ -1 +1 @@ -2380 +2346 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.jssize b/test/other/codesize/test_codesize_hello_wasmfs.jssize index ddeb3cf88bf70..534d8e6bdcc90 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.jssize +++ b/test/other/codesize/test_codesize_hello_wasmfs.jssize @@ -1 +1 @@ -4830 +4802 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize index a60b19c7d3e35..e37d15a094a6b 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize @@ -1 +1 @@ -1942 +1920 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize index 8fd7a8244755f..19e6874d5c5ec 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize @@ -1 +1 @@ -4064 +4040 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize index 144764295069b..b22803ae9b835 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize @@ -1 +1 @@ -1976 +1957 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize index aff4d86fafce6..64c1a80470aad 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize @@ -1 +1 @@ -4111 +4087 diff --git a/test/other/codesize/test_codesize_mem_O3.gzsize b/test/other/codesize/test_codesize_mem_O3.gzsize index 8c88d58d59dbc..37a2cebe6b9c9 100644 --- a/test/other/codesize/test_codesize_mem_O3.gzsize +++ b/test/other/codesize/test_codesize_mem_O3.gzsize @@ -1 +1 @@ -2399 +2380 diff --git a/test/other/codesize/test_codesize_mem_O3.jssize b/test/other/codesize/test_codesize_mem_O3.jssize index ce43cdbca097f..f32a182f1e944 100644 --- a/test/other/codesize/test_codesize_mem_O3.jssize +++ b/test/other/codesize/test_codesize_mem_O3.jssize @@ -1 +1 @@ -4973 +4943 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.gzsize b/test/other/codesize/test_codesize_mem_O3_grow.gzsize index fe534adb03b4b..13c8e99a99bbb 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow.gzsize @@ -1 +1 @@ -2543 +2529 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.jssize b/test/other/codesize/test_codesize_mem_O3_grow.jssize index 651ba07e2d020..c016a774c8a64 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow.jssize @@ -1 +1 @@ -5254 +5228 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize index 137c70ae46487..e60a9452f5c52 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize @@ -1 +1 @@ -2239 +2225 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize index a42fbf5bc5e93..b02620cff6eb4 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize @@ -1 +1 @@ -4663 +4636 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize index b17e4bdb15f56..0ed0ea4a170d1 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize @@ -1 +1 @@ -2208 +2190 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_standalone.jssize index b2b760360bf47..835fe1beea0f2 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.jssize @@ -1 +1 @@ -4593 +4566 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize index adf4269e68338..6e371fb2389ae 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize @@ -1 +1 @@ -1960 +1944 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize index 5535a4d07c950..64c1a80470aad 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize @@ -1 +1 @@ -4115 +4087 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize index 144764295069b..b22803ae9b835 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize @@ -1 +1 @@ -1976 +1957 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize index aff4d86fafce6..64c1a80470aad 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize @@ -1 +1 @@ -4111 +4087 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize index 144764295069b..b22803ae9b835 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize @@ -1 +1 @@ -1976 +1957 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize index aff4d86fafce6..64c1a80470aad 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize @@ -1 +1 @@ -4111 +4087 diff --git a/test/other/codesize/test_codesize_minimal_64.gzsize b/test/other/codesize/test_codesize_minimal_64.gzsize index 131de0bdc4713..3591ec6784c2f 100644 --- a/test/other/codesize/test_codesize_minimal_64.gzsize +++ b/test/other/codesize/test_codesize_minimal_64.gzsize @@ -1 +1 @@ -1499 +1492 diff --git a/test/other/codesize/test_codesize_minimal_64.jssize b/test/other/codesize/test_codesize_minimal_64.jssize index 518ea7fd5d661..b2858f3749035 100644 --- a/test/other/codesize/test_codesize_minimal_64.jssize +++ b/test/other/codesize/test_codesize_minimal_64.jssize @@ -1 +1 @@ -3143 +3142 diff --git a/test/other/codesize/test_codesize_minimal_O0.gzsize b/test/other/codesize/test_codesize_minimal_O0.gzsize index 26d97f396bfab..bde5b49b5d9d5 100644 --- a/test/other/codesize/test_codesize_minimal_O0.gzsize +++ b/test/other/codesize/test_codesize_minimal_O0.gzsize @@ -1 +1 @@ -6571 +6567 diff --git a/test/other/codesize/test_codesize_minimal_O0.jssize b/test/other/codesize/test_codesize_minimal_O0.jssize index 4705c7d0c2aad..17bded2757b92 100644 --- a/test/other/codesize/test_codesize_minimal_O0.jssize +++ b/test/other/codesize/test_codesize_minimal_O0.jssize @@ -1 +1 @@ -17606 +17513 diff --git a/test/other/codesize/test_codesize_minimal_O1.gzsize b/test/other/codesize/test_codesize_minimal_O1.gzsize index 6fcfa77a477e8..1c631e1e4ce7e 100644 --- a/test/other/codesize/test_codesize_minimal_O1.gzsize +++ b/test/other/codesize/test_codesize_minimal_O1.gzsize @@ -1 +1 @@ -1574 +1568 diff --git a/test/other/codesize/test_codesize_minimal_O1.jssize b/test/other/codesize/test_codesize_minimal_O1.jssize index e4ab713200d2c..c73c83400cc5d 100644 --- a/test/other/codesize/test_codesize_minimal_O1.jssize +++ b/test/other/codesize/test_codesize_minimal_O1.jssize @@ -1 +1 @@ -3739 +3669 diff --git a/test/other/codesize/test_codesize_minimal_O2.gzsize b/test/other/codesize/test_codesize_minimal_O2.gzsize index b322e68302d81..4e6ee1e5ffb6e 100644 --- a/test/other/codesize/test_codesize_minimal_O2.gzsize +++ b/test/other/codesize/test_codesize_minimal_O2.gzsize @@ -1 +1 @@ -1427 +1421 diff --git a/test/other/codesize/test_codesize_minimal_O2.jssize b/test/other/codesize/test_codesize_minimal_O2.jssize index f36482a747146..b36a2e0278445 100644 --- a/test/other/codesize/test_codesize_minimal_O2.jssize +++ b/test/other/codesize/test_codesize_minimal_O2.jssize @@ -1 +1 @@ -2848 +2847 diff --git a/test/other/codesize/test_codesize_minimal_O3.gzsize b/test/other/codesize/test_codesize_minimal_O3.gzsize index f252370658e8f..1aca63ba8cd53 100644 --- a/test/other/codesize/test_codesize_minimal_O3.gzsize +++ b/test/other/codesize/test_codesize_minimal_O3.gzsize @@ -1 +1 @@ -1393 +1386 diff --git a/test/other/codesize/test_codesize_minimal_O3.jssize b/test/other/codesize/test_codesize_minimal_O3.jssize index 3327d2792ed58..9ddd587ee7d83 100644 --- a/test/other/codesize/test_codesize_minimal_O3.jssize +++ b/test/other/codesize/test_codesize_minimal_O3.jssize @@ -1 +1 @@ -2798 +2797 diff --git a/test/other/codesize/test_codesize_minimal_Os.gzsize b/test/other/codesize/test_codesize_minimal_Os.gzsize index f252370658e8f..1aca63ba8cd53 100644 --- a/test/other/codesize/test_codesize_minimal_Os.gzsize +++ b/test/other/codesize/test_codesize_minimal_Os.gzsize @@ -1 +1 @@ -1393 +1386 diff --git a/test/other/codesize/test_codesize_minimal_Os.jssize b/test/other/codesize/test_codesize_minimal_Os.jssize index 3327d2792ed58..9ddd587ee7d83 100644 --- a/test/other/codesize/test_codesize_minimal_Os.jssize +++ b/test/other/codesize/test_codesize_minimal_Os.jssize @@ -1 +1 @@ -2798 +2797 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize index a9b14017bfece..30ed602b91565 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize @@ -1 +1 @@ -1383 +1378 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize index 7ab19b5b480cf..baa5fd743de19 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize @@ -1 +1 @@ -2783 +2782 diff --git a/test/other/codesize/test_codesize_minimal_Oz.gzsize b/test/other/codesize/test_codesize_minimal_Oz.gzsize index f252370658e8f..1aca63ba8cd53 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz.gzsize @@ -1 +1 @@ -1393 +1386 diff --git a/test/other/codesize/test_codesize_minimal_Oz.jssize b/test/other/codesize/test_codesize_minimal_Oz.jssize index 3327d2792ed58..9ddd587ee7d83 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz.jssize @@ -1 +1 @@ -2798 +2797 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.gzsize b/test/other/codesize/test_codesize_minimal_pthreads.gzsize index a4ca075180c97..7223c3c378623 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.gzsize +++ b/test/other/codesize/test_codesize_minimal_pthreads.gzsize @@ -1 +1 @@ -4188 +4177 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.jssize b/test/other/codesize/test_codesize_minimal_pthreads.jssize index 179d18debb431..b26b806a10c6c 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.jssize +++ b/test/other/codesize/test_codesize_minimal_pthreads.jssize @@ -1 +1 @@ -8667 +8656 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize index f252370658e8f..1aca63ba8cd53 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize @@ -1 +1 @@ -1393 +1386 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.jssize b/test/other/codesize/test_codesize_minimal_wasmfs.jssize index 3327d2792ed58..9ddd587ee7d83 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.jssize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.jssize @@ -1 +1 @@ -2798 +2797 diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index 48f4d8dcae999..ba18cec99cb25 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -54928 +54390 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index cec4a3ebfe845..921d6b46a36b7 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -30416 +29886 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index 5c3cf64221739..f49c2da41fbc0 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -53724 +53186 diff --git a/test/test_browser.py b/test/test_browser.py index 91521d09db869..0e8d7edee8a93 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -5519,7 +5519,7 @@ def test(args, expect_fail): if expect_fail: js = read_file('a.out.js') create_file('a.out.js', 'let origFetch = fetch; fetch = undefined;\n' + js) - return self.run_browser('a.out.html', '/report_result?exception:fetch is not a function') + return self.run_browser('a.out.html', '/report_result?abort:both async and sync fetching of the wasm failed') else: return self.run_browser('a.out.html', '/report_result?exit:42') diff --git a/test/test_other.py b/test/test_other.py index dd46dd1df2569..f3e6b7ee59b9a 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -2955,20 +2955,25 @@ def test_m_mm(self): self.assertNotContained('error', proc.stderr) @uses_canonical_tmp - def test_emcc_debug_files(self): - for opts in (0, 1, 2, 3): - for debug in (None, '1', '2'): - print(opts, debug) - if os.path.exists(self.canonical_temp_dir): - shutil.rmtree(self.canonical_temp_dir) - - with env_modify({'EMCC_DEBUG': debug}): - self.run_process([EMCC, test_file('hello_world.c'), '-O' + str(opts)], stderr=PIPE) - if debug is None: - self.assertFalse(os.path.exists(self.canonical_temp_dir)) - else: - print(sorted(os.listdir(self.canonical_temp_dir))) - self.assertExists(os.path.join(self.canonical_temp_dir, 'emcc-03-original.js')) + @parameterized({ + 'O0': ('-O0',), + 'O1': ('-O1',), + 'O2': ('-O2',), + 'O3': ('-O3',), + }) + def test_emcc_debug_files(self, opt): + for debug in (None, '1', '2'): + print('debug =', debug) + if os.path.exists(self.canonical_temp_dir): + shutil.rmtree(self.canonical_temp_dir) + + with env_modify({'EMCC_DEBUG': debug}): + self.run_process([EMCC, test_file('hello_world.c'), opt], stderr=PIPE) + if debug is None: + self.assertFalse(os.path.exists(self.canonical_temp_dir)) + else: + print(sorted(os.listdir(self.canonical_temp_dir))) + self.assertExists(os.path.join(self.canonical_temp_dir, 'emcc-03-original.js')) def test_debuginfo_line_tables_only(self): def test(do_compile): diff --git a/tools/emscripten.py b/tools/emscripten.py index 65584d17e0144..c2d36561d7776 100644 --- a/tools/emscripten.py +++ b/tools/emscripten.py @@ -989,7 +989,10 @@ def create_module(receiving, metadata, global_exports, library_symbols): module.append('var wasmImports = %s;\n' % sending) if not settings.MINIMAL_RUNTIME: - module.append("var wasmExports = createWasm();\n") + if settings.WASM_ASYNC_COMPILATION: + module.append("var wasmExports;\ncreateWasm();\n") + else: + module.append("var wasmExports = createWasm();\n") module.append(receiving) if settings.SUPPORT_LONGJMP == 'emscripten' or not settings.DISABLE_EXCEPTION_CATCHING: From 5c5f5a162a4419e7684daeb050552f84fa76a4e1 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 10 Dec 2024 13:41:52 -0800 Subject: [PATCH 045/132] Rebaseline codesize expectations. NFC --- test/other/codesize/test_codesize_cxx_ctors1.size | 2 +- test/other/codesize/test_codesize_cxx_ctors2.size | 2 +- test/other/codesize/test_codesize_cxx_except.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.size | 2 +- test/other/codesize/test_codesize_cxx_lto.size | 2 +- test/other/codesize/test_codesize_cxx_mangle.size | 2 +- test/other/codesize/test_codesize_cxx_noexcept.size | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.size | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/other/codesize/test_codesize_cxx_ctors1.size b/test/other/codesize/test_codesize_cxx_ctors1.size index 0abcbf920f536..39e3ff9b0fb65 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.size +++ b/test/other/codesize/test_codesize_cxx_ctors1.size @@ -1 +1 @@ -128890 +128834 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.size b/test/other/codesize/test_codesize_cxx_ctors2.size index 77cd041ba9afb..d06418847b136 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.size +++ b/test/other/codesize/test_codesize_cxx_ctors2.size @@ -1 +1 @@ -128302 +128246 diff --git a/test/other/codesize/test_codesize_cxx_except.size b/test/other/codesize/test_codesize_cxx_except.size index caf2ab90b0cf5..82447ae072935 100644 --- a/test/other/codesize/test_codesize_cxx_except.size +++ b/test/other/codesize/test_codesize_cxx_except.size @@ -1 +1 @@ -171023 +170967 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.size b/test/other/codesize/test_codesize_cxx_except_wasm.size index ccbed055ad10f..4066c25867614 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm.size @@ -1 +1 @@ -142151 +142095 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size index 1e4b02eaea0f0..75b837eb3e828 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size @@ -1 +1 @@ -144738 +144682 diff --git a/test/other/codesize/test_codesize_cxx_lto.size b/test/other/codesize/test_codesize_cxx_lto.size index 5cf7ff329aeb0..93b0a7cb1a69e 100644 --- a/test/other/codesize/test_codesize_cxx_lto.size +++ b/test/other/codesize/test_codesize_cxx_lto.size @@ -1 +1 @@ -121835 +121779 diff --git a/test/other/codesize/test_codesize_cxx_mangle.size b/test/other/codesize/test_codesize_cxx_mangle.size index eed6548e69424..5d10eed055c0b 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.size +++ b/test/other/codesize/test_codesize_cxx_mangle.size @@ -1 +1 @@ -232546 +232469 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.size b/test/other/codesize/test_codesize_cxx_noexcept.size index fcdf3f0fb5f09..07f934ebfae51 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.size +++ b/test/other/codesize/test_codesize_cxx_noexcept.size @@ -1 +1 @@ -131701 +131645 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.size b/test/other/codesize/test_codesize_cxx_wasmfs.size index 7793aed3bb3ed..a56b7d63b7818 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.size +++ b/test/other/codesize/test_codesize_cxx_wasmfs.size @@ -1 +1 @@ -169030 +168974 From 98f59c70acf81e69916ac3337b8abcad1544f43f Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 10 Dec 2024 23:11:58 +0100 Subject: [PATCH 046/132] [emmalloc] Fix verbose output (#23069) toString() was undeclared. Fixes a regression introduced in commit 04a0cad. --- system/lib/emmalloc.c | 34 ++++++++++++++++------------------ test/test_core.py | 3 +-- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/system/lib/emmalloc.c b/system/lib/emmalloc.c index 6c794b3f3e880..40cfb5b547d8d 100644 --- a/system/lib/emmalloc.c +++ b/system/lib/emmalloc.c @@ -358,16 +358,16 @@ static void dump_memory_regions() { Region *r = (Region*)root; assert(debug_region_is_consistent(r)); uint8_t *lastRegionEnd = root->endPtr; - MAIN_THREAD_ASYNC_EM_ASM(out('Region block '+ptrToString($0)+' - '+ptrToString($1)+ ' ('+toString(Number($2))+' bytes):'), + MAIN_THREAD_ASYNC_EM_ASM(out('Region block '+ptrToString($0)+' - '+ptrToString($1)+ ' ('+Number($2)+' bytes):'), r, lastRegionEnd, lastRegionEnd-(uint8_t*)r); while ((uint8_t*)r < lastRegionEnd) { - MAIN_THREAD_ASYNC_EM_ASM(out('Region '+ptrToString($0)+', size: '+toString(Number($1))+' ('+($2?"used":"--FREE--")+')'), + MAIN_THREAD_ASYNC_EM_ASM(out('Region '+ptrToString($0)+', size: '+Number($1)+' ('+($2?"used":"--FREE--")+')'), r, r->size, region_ceiling_size(r) == r->size); assert(debug_region_is_consistent(r)); size_t sizeFromCeiling = size_of_region_from_ceiling(r); if (sizeFromCeiling != r->size) { - MAIN_THREAD_ASYNC_EM_ASM(out('Corrupt region! Size marker at the end of the region does not match: '+toString(Number($0))), sizeFromCeiling); + MAIN_THREAD_ASYNC_EM_ASM(out('Corrupt region! Size marker at the end of the region does not match: '+Number($0)), sizeFromCeiling); } if (r->size == 0) { break; @@ -382,7 +382,7 @@ static void dump_memory_regions() { Region *prev = &freeRegionBuckets[i]; Region *fr = freeRegionBuckets[i].next; while (fr != &freeRegionBuckets[i]) { - MAIN_THREAD_ASYNC_EM_ASM(out('In bucket '+$0+', free region '+ptrToString($1)+', size: ' + toString(Number($2)) + ' (size at ceiling: '+toString(Number($3))+'), prev: ' + ptrToString($4) + ', next: ' + ptrToString($5)), + MAIN_THREAD_ASYNC_EM_ASM(out('In bucket '+$0+', free region '+ptrToString($1)+', size: ' + Number($2) + ' (size at ceiling: '+Number($3)+'), prev: ' + ptrToString($4) + ', next: ' + ptrToString($5)), i, fr, fr->size, size_of_region_from_ceiling(fr), fr->prev, fr->next); assert(debug_region_is_consistent(fr)); assert(region_is_free(fr)); @@ -393,7 +393,7 @@ static void dump_memory_regions() { fr = fr->next; } } - MAIN_THREAD_ASYNC_EM_ASM(out('Free bucket index map: ' + toString(Number($0)).toString(2) + ' ' + toString(Number($1)).toString(2)), (uint32_t)(freeRegionBucketsUsed >> 32), (uint32_t)freeRegionBucketsUsed); + MAIN_THREAD_ASYNC_EM_ASM(out('Free bucket index map: ' + Number($0).toString(2) + ' ' + Number($1).toString(2)), (uint32_t)(freeRegionBucketsUsed >> 32), (uint32_t)freeRegionBucketsUsed); MAIN_THREAD_ASYNC_EM_ASM(out("")); } @@ -409,14 +409,14 @@ static int validate_memory_regions() { while (root) { Region *r = (Region*)root; if (!debug_region_is_consistent(r)) { - MAIN_THREAD_ASYNC_EM_ASM(err('Used region '+ptrToString($0)+', size: '+toString(Number($1))+' ('+($2?"used":"--FREE--")+') is corrupt (size markers in the beginning and at the end of the region do not match!)'), + MAIN_THREAD_ASYNC_EM_ASM(err('Used region '+ptrToString($0)+', size: '+Number($1)+' ('+($2?"used":"--FREE--")+') is corrupt (size markers in the beginning and at the end of the region do not match!)'), r, r->size, region_ceiling_size(r) == r->size); return 1; } uint8_t *lastRegionEnd = root->endPtr; while ((uint8_t*)r < lastRegionEnd) { if (!debug_region_is_consistent(r)) { - MAIN_THREAD_ASYNC_EM_ASM(err('Used region '+ptrToString($0)+', size: '+toString(Number($1))+' ('+($2?"used":"--FREE--")+') is corrupt (size markers in the beginning and at the end of the region do not match!)'), + MAIN_THREAD_ASYNC_EM_ASM(err('Used region '+ptrToString($0)+', size: '+Number($1)+' ('+($2?"used":"--FREE--")+') is corrupt (size markers in the beginning and at the end of the region do not match!)'), r, r->size, region_ceiling_size(r) == r->size); return 1; } @@ -432,7 +432,7 @@ static int validate_memory_regions() { Region *fr = freeRegionBuckets[i].next; while (fr != &freeRegionBuckets[i]) { if (!debug_region_is_consistent(fr) || !region_is_free(fr) || fr->prev != prev || fr->next == fr || fr->prev == fr) { - MAIN_THREAD_ASYNC_EM_ASM(out('In bucket '+$0+', free region '+ptrToString($1)+', size: ' + toString(Number($2)) + ' (size at ceiling: '+toString(Number($3))+'), prev: ' + ptrToString($4) + ', next: 0x' + ptrToString($5) + ' is corrupt!'), + MAIN_THREAD_ASYNC_EM_ASM(out('In bucket '+$0+', free region '+ptrToString($1)+', size: ' + Number($2) + ' (size at ceiling: '+Number($3)+'), prev: ' + ptrToString($4) + ', next: 0x' + ptrToString($5) + ' is corrupt!'), i, fr, fr->size, size_of_region_from_ceiling(fr), fr->prev, fr->next); return 1; } @@ -629,7 +629,7 @@ static void *attempt_allocate(Region *freeRegion, size_t alignment, size_t size) #endif #ifdef EMMALLOC_VERBOSE - MAIN_THREAD_ASYNC_EM_ASM(out('attempt_allocate - succeeded allocating memory, region ptr=' + ptrToString($0) + ', align=' + $1 + ', payload size=' + toString(Number($2)) + ' bytes)'), freeRegion, alignment, size); + MAIN_THREAD_ASYNC_EM_ASM(out('attempt_allocate - succeeded allocating memory, region ptr=' + ptrToString($0) + ', align=' + $1 + ', payload size=' + Number($2) + ' bytes)'), freeRegion, alignment, size); #endif return (uint8_t*)freeRegion + sizeof(size_t); @@ -651,15 +651,13 @@ static size_t validate_alloc_size(size_t size) { return validatedSize; } -#ifdef EMMALLOC_VERBOSE EM_JS_DEPS(deps, "$ptrToString"); -#endif static void *allocate_memory(size_t alignment, size_t size) { ASSERT_MALLOC_IS_ACQUIRED(); #ifdef EMMALLOC_VERBOSE - MAIN_THREAD_ASYNC_EM_ASM(out('allocate_memory(align=' + $0 + ', size=' + toString(Number($1)) + ' bytes)'), alignment, size); + MAIN_THREAD_ASYNC_EM_ASM(out('allocate_memory(align=' + $0 + ', size=' + Number($1) + ' bytes)'), alignment, size); #endif #ifdef EMMALLOC_MEMVALIDATE @@ -675,7 +673,7 @@ static void *allocate_memory(size_t alignment, size_t size) { if (size > MAX_ALLOC_SIZE) { #ifdef EMMALLOC_VERBOSE - MAIN_THREAD_ASYNC_EM_ASM(out('Allocation failed: attempted allocation size is too large: ' + toString(Number($0)) + 'bytes! (negative integer wraparound?)'), size); + MAIN_THREAD_ASYNC_EM_ASM(out('Allocation failed: attempted allocation size is too large: ' + Number($0) + 'bytes! (negative integer wraparound?)'), size); #endif return 0; } @@ -930,7 +928,7 @@ static int attempt_region_resize(Region *region, size_t size) { assert(HAS_ALIGNMENT(size, sizeof(size_t))); #ifdef EMMALLOC_VERBOSE - MAIN_THREAD_ASYNC_EM_ASM(out('attempt_region_resize(region=' + ptrToString($0) + ', size=' + toString(Number($1)) + ' bytes)'), region, size); + MAIN_THREAD_ASYNC_EM_ASM(out('attempt_region_resize(region=' + ptrToString($0) + ', size=' + Number($1) + ' bytes)'), region, size); #endif // First attempt to resize this region, if the next region that follows this one @@ -988,7 +986,7 @@ static int acquire_and_attempt_region_resize(Region *region, size_t size) { void *emmalloc_aligned_realloc(void *ptr, size_t alignment, size_t size) { #ifdef EMMALLOC_VERBOSE - MAIN_THREAD_ASYNC_EM_ASM(out('aligned_realloc(ptr=' + ptrToString($0) + ', alignment=' + $1 + ', size=' + toString(Number($2))), ptr, alignment, size); + MAIN_THREAD_ASYNC_EM_ASM(out('aligned_realloc(ptr=' + ptrToString($0) + ', alignment=' + $1 + ', size=' + Number($2)), ptr, alignment, size); #endif if (!ptr) { @@ -1002,7 +1000,7 @@ void *emmalloc_aligned_realloc(void *ptr, size_t alignment, size_t size) { if (size > MAX_ALLOC_SIZE) { #ifdef EMMALLOC_VERBOSE - MAIN_THREAD_ASYNC_EM_ASM(out('Allocation failed: attempted allocation size is too large: ' + toString(Number($0)) + 'bytes! (negative integer wraparound?)'), size); + MAIN_THREAD_ASYNC_EM_ASM(out('Allocation failed: attempted allocation size is too large: ' + Number($0) + 'bytes! (negative integer wraparound?)'), size); #endif return 0; } @@ -1052,7 +1050,7 @@ void *emmalloc_realloc_try(void *ptr, size_t size) { if (size > MAX_ALLOC_SIZE) { #ifdef EMMALLOC_VERBOSE - MAIN_THREAD_ASYNC_EM_ASM(out('Allocation failed: attempted allocation size is too large: ' + toString(Number($0)) + 'bytes! (negative integer wraparound?)'), size); + MAIN_THREAD_ASYNC_EM_ASM(out('Allocation failed: attempted allocation size is too large: ' + Number($0) + 'bytes! (negative integer wraparound?)'), size); #endif return 0; } @@ -1086,7 +1084,7 @@ void *emmalloc_aligned_realloc_uninitialized(void *ptr, size_t alignment, size_t if (size > MAX_ALLOC_SIZE) { #ifdef EMMALLOC_VERBOSE - MAIN_THREAD_ASYNC_EM_ASM(out('Allocation failed: attempted allocation size is too large: ' + toString(Number($0)) + 'bytes! (negative integer wraparound?)'), size); + MAIN_THREAD_ASYNC_EM_ASM(out('Allocation failed: attempted allocation size is too large: ' + Number($0) + 'bytes! (negative integer wraparound?)'), size); #endif return 0; } diff --git a/test/test_core.py b/test/test_core.py index 9e62f056f3bf9..d3fff94c5a8ec 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -797,8 +797,7 @@ def test_mainenv(self): 'memvalidate_verbose': ['-DEMMALLOC_MEMVALIDATE', '-DEMMALLOC_VERBOSE', '-DRANDOM_ITERS=130'], }) def test_emmalloc(self, *args): - if '-DEMMALLOC_VERBOSE' in args and self.is_wasm64(): - self.skipTest('EMMALLOC_VERBOSE is not compatible with wasm64') + self.maybe_closure() # in newer clang+llvm, the internal calls to malloc in emmalloc may be optimized under # the assumption that they are external, so like in system_libs.py where we build # malloc, we need to disable builtin here too From 82182e608bef459be2d2f8d35b5bb24faf6f1d6f Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 10 Dec 2024 15:07:42 -0800 Subject: [PATCH 047/132] Default to -mno-bulk-memory-opt (#23126) This should fix the recent CI failures on the test-node-compat bot. Once #22873 lands this can, of course, be removed. --- emcc.py | 1 + test/code_size/embind_hello_wasm.json | 8 ++++---- test/code_size/embind_val_wasm.json | 8 ++++---- test/code_size/hello_webgl2_wasm.json | 8 ++++---- test/code_size/hello_webgl2_wasm2js.json | 8 ++++---- test/code_size/hello_webgl_wasm.json | 8 ++++---- test/code_size/hello_webgl_wasm2js.json | 8 ++++---- test/code_size/random_printf_wasm.json | 8 ++++---- test/code_size/random_printf_wasm2js.json | 8 ++++---- test/other/codesize/test_codesize_cxx_ctors1.size | 2 +- test/other/codesize/test_codesize_cxx_ctors2.size | 2 +- test/other/codesize/test_codesize_cxx_except.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.size | 2 +- .../codesize/test_codesize_cxx_except_wasm_exnref.size | 2 +- test/other/codesize/test_codesize_cxx_lto.size | 2 +- test/other/codesize/test_codesize_cxx_mangle.size | 2 +- test/other/codesize/test_codesize_cxx_noexcept.size | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.size | 2 +- test/other/codesize/test_codesize_files_wasmfs.exports | 8 ++++---- test/other/codesize/test_codesize_files_wasmfs.funcs | 3 +++ test/other/codesize/test_codesize_files_wasmfs.gzsize | 2 +- test/other/codesize/test_codesize_files_wasmfs.imports | 5 +++-- test/other/codesize/test_codesize_files_wasmfs.jssize | 2 +- test/other/codesize/test_codesize_files_wasmfs.sent | 5 +++-- test/other/codesize/test_codesize_files_wasmfs.size | 2 +- test/other/codesize/test_codesize_hello_O0.size | 2 +- test/other/codesize/test_codesize_hello_O1.size | 2 +- test/other/codesize/test_codesize_minimal_O0.size | 2 +- test/other/codesize/test_codesize_minimal_O1.size | 2 +- test/other/test_unoptimized_code_size.wasm.size | 2 +- .../other/test_unoptimized_code_size_no_asserts.wasm.size | 2 +- test/other/test_unoptimized_code_size_strict.wasm.size | 2 +- 32 files changed, 65 insertions(+), 59 deletions(-) diff --git a/emcc.py b/emcc.py index 7f30d13cdc058..2925985f22f6c 100644 --- a/emcc.py +++ b/emcc.py @@ -391,6 +391,7 @@ def get_clang_flags(user_args): # Bulk memory may be enabled via threads or directly via -s. if not settings.BULK_MEMORY: flags.append('-mno-bulk-memory') + flags.append('-mno-bulk-memory-opt') if '-mnontrapping-fptoint' not in user_args and '-mno-nontrapping-fptoint' not in user_args: flags.append('-mno-nontrapping-fptoint') diff --git a/test/code_size/embind_hello_wasm.json b/test/code_size/embind_hello_wasm.json index 37ad4ea025cd1..f3b1d73bc6bec 100644 --- a/test/code_size/embind_hello_wasm.json +++ b/test/code_size/embind_hello_wasm.json @@ -3,8 +3,8 @@ "a.html.gz": 380, "a.js": 9718, "a.js.gz": 4291, - "a.wasm": 7626, - "a.wasm.gz": 3444, - "total": 17896, - "total_gz": 8115 + "a.wasm": 7728, + "a.wasm.gz": 3502, + "total": 17998, + "total_gz": 8173 } diff --git a/test/code_size/embind_val_wasm.json b/test/code_size/embind_val_wasm.json index fd9aaec726cc2..9af792edee31e 100644 --- a/test/code_size/embind_val_wasm.json +++ b/test/code_size/embind_val_wasm.json @@ -3,8 +3,8 @@ "a.html.gz": 380, "a.js": 6849, "a.js.gz": 2947, - "a.wasm": 9506, - "a.wasm.gz": 4872, - "total": 16907, - "total_gz": 8199 + "a.wasm": 9568, + "a.wasm.gz": 4911, + "total": 16969, + "total_gz": 8238 } diff --git a/test/code_size/hello_webgl2_wasm.json b/test/code_size/hello_webgl2_wasm.json index c944949a29c8c..bf14a6e1a53c9 100644 --- a/test/code_size/hello_webgl2_wasm.json +++ b/test/code_size/hello_webgl2_wasm.json @@ -3,8 +3,8 @@ "a.html.gz": 328, "a.js": 4532, "a.js.gz": 2315, - "a.wasm": 10377, - "a.wasm.gz": 6694, - "total": 15363, - "total_gz": 9337 + "a.wasm": 10402, + "a.wasm.gz": 6704, + "total": 15388, + "total_gz": 9347 } diff --git a/test/code_size/hello_webgl2_wasm2js.json b/test/code_size/hello_webgl2_wasm2js.json index 62c056051c215..88cc365f6f5f7 100644 --- a/test/code_size/hello_webgl2_wasm2js.json +++ b/test/code_size/hello_webgl2_wasm2js.json @@ -1,8 +1,8 @@ { "a.html": 346, "a.html.gz": 262, - "a.js": 22232, - "a.js.gz": 11612, - "total": 22578, - "total_gz": 11874 + "a.js": 22200, + "a.js.gz": 11582, + "total": 22546, + "total_gz": 11844 } diff --git a/test/code_size/hello_webgl_wasm.json b/test/code_size/hello_webgl_wasm.json index f9432eddd1985..b20428e2fed64 100644 --- a/test/code_size/hello_webgl_wasm.json +++ b/test/code_size/hello_webgl_wasm.json @@ -3,8 +3,8 @@ "a.html.gz": 328, "a.js": 4070, "a.js.gz": 2158, - "a.wasm": 10377, - "a.wasm.gz": 6694, - "total": 14901, - "total_gz": 9180 + "a.wasm": 10402, + "a.wasm.gz": 6704, + "total": 14926, + "total_gz": 9190 } diff --git a/test/code_size/hello_webgl_wasm2js.json b/test/code_size/hello_webgl_wasm2js.json index 01af46e9951c2..bc0dfe84d64a8 100644 --- a/test/code_size/hello_webgl_wasm2js.json +++ b/test/code_size/hello_webgl_wasm2js.json @@ -1,8 +1,8 @@ { "a.html": 346, "a.html.gz": 262, - "a.js": 21758, - "a.js.gz": 11442, - "total": 22104, - "total_gz": 11704 + "a.js": 21726, + "a.js.gz": 11415, + "total": 22072, + "total_gz": 11677 } diff --git a/test/code_size/random_printf_wasm.json b/test/code_size/random_printf_wasm.json index 3b0a3c6494de1..8548e41737392 100644 --- a/test/code_size/random_printf_wasm.json +++ b/test/code_size/random_printf_wasm.json @@ -1,6 +1,6 @@ { - "a.html": 12589, - "a.html.gz": 6888, - "total": 12589, - "total_gz": 6888 + "a.html": 12597, + "a.html.gz": 6882, + "total": 12597, + "total_gz": 6882 } diff --git a/test/code_size/random_printf_wasm2js.json b/test/code_size/random_printf_wasm2js.json index 335e5aa2294d8..b3fe0c465524e 100644 --- a/test/code_size/random_printf_wasm2js.json +++ b/test/code_size/random_printf_wasm2js.json @@ -1,6 +1,6 @@ { - "a.html": 17246, - "a.html.gz": 7510, - "total": 17246, - "total_gz": 7510 + "a.html": 17195, + "a.html.gz": 7478, + "total": 17195, + "total_gz": 7478 } diff --git a/test/other/codesize/test_codesize_cxx_ctors1.size b/test/other/codesize/test_codesize_cxx_ctors1.size index 39e3ff9b0fb65..d744c653894ea 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.size +++ b/test/other/codesize/test_codesize_cxx_ctors1.size @@ -1 +1 @@ -128834 +129168 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.size b/test/other/codesize/test_codesize_cxx_ctors2.size index d06418847b136..56759f32a7df5 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.size +++ b/test/other/codesize/test_codesize_cxx_ctors2.size @@ -1 +1 @@ -128246 +128617 diff --git a/test/other/codesize/test_codesize_cxx_except.size b/test/other/codesize/test_codesize_cxx_except.size index 82447ae072935..e531829ac5ef3 100644 --- a/test/other/codesize/test_codesize_cxx_except.size +++ b/test/other/codesize/test_codesize_cxx_except.size @@ -1 +1 @@ -170967 +171298 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.size b/test/other/codesize/test_codesize_cxx_except_wasm.size index 4066c25867614..eb551ef1e63ad 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm.size @@ -1 +1 @@ -142095 +142418 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size index 75b837eb3e828..8ba15fbee382f 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size @@ -1 +1 @@ -144682 +145005 diff --git a/test/other/codesize/test_codesize_cxx_lto.size b/test/other/codesize/test_codesize_cxx_lto.size index 93b0a7cb1a69e..c1283987423eb 100644 --- a/test/other/codesize/test_codesize_cxx_lto.size +++ b/test/other/codesize/test_codesize_cxx_lto.size @@ -1 +1 @@ -121779 +121867 diff --git a/test/other/codesize/test_codesize_cxx_mangle.size b/test/other/codesize/test_codesize_cxx_mangle.size index 5d10eed055c0b..09e3c737b99ac 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.size +++ b/test/other/codesize/test_codesize_cxx_mangle.size @@ -1 +1 @@ -232469 +232786 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.size b/test/other/codesize/test_codesize_cxx_noexcept.size index 07f934ebfae51..602c55bf97bd0 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.size +++ b/test/other/codesize/test_codesize_cxx_noexcept.size @@ -1 +1 @@ -131645 +131975 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.size b/test/other/codesize/test_codesize_cxx_wasmfs.size index a56b7d63b7818..849311107e15f 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.size +++ b/test/other/codesize/test_codesize_cxx_wasmfs.size @@ -1 +1 @@ -168974 +169227 diff --git a/test/other/codesize/test_codesize_files_wasmfs.exports b/test/other/codesize/test_codesize_files_wasmfs.exports index b64e135c8e3cf..1b3d6ede9e560 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.exports +++ b/test/other/codesize/test_codesize_files_wasmfs.exports @@ -1,4 +1,4 @@ -p (memory) -q (__wasm_call_ctors) -r (main) -s (__indirect_function_table) +q (memory) +r (__wasm_call_ctors) +s (main) +t (__indirect_function_table) diff --git a/test/other/codesize/test_codesize_files_wasmfs.funcs b/test/other/codesize/test_codesize_files_wasmfs.funcs index 1fec0a5640720..c13be46f97079 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.funcs +++ b/test/other/codesize/test_codesize_files_wasmfs.funcs @@ -22,6 +22,8 @@ $__cxxabiv1::__vmi_class_type_info::has_unambiguous_public_base\28__cxxabiv1::__ $__cxxabiv1::__vmi_class_type_info::search_above_dst\28__cxxabiv1::__dynamic_cast_info*\2c\20void\20const*\2c\20void\20const*\2c\20int\2c\20bool\29\20const $__cxxabiv1::__vmi_class_type_info::search_below_dst\28__cxxabiv1::__dynamic_cast_info*\2c\20void\20const*\2c\20int\2c\20bool\29\20const $__lockfile +$__memcpy +$__memset $__pthread_mutex_lock $__throw_bad_alloc_shim\28\29 $__unlockfile @@ -36,6 +38,7 @@ $fflush $is_equal\28std::type_info\20const*\2c\20std::type_info\20const*\2c\20bool\29 $main $memcmp +$memmove $operator\20delete\28void*\29 $operator\20new\28unsigned\20long\29 $pthread_mutex_init diff --git a/test/other/codesize/test_codesize_files_wasmfs.gzsize b/test/other/codesize/test_codesize_files_wasmfs.gzsize index 43a5478d767d8..004f50eab1549 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_files_wasmfs.gzsize @@ -1 +1 @@ -2915 +2932 diff --git a/test/other/codesize/test_codesize_files_wasmfs.imports b/test/other/codesize/test_codesize_files_wasmfs.imports index 519a7e0d06403..74ec884c2cde4 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.imports +++ b/test/other/codesize/test_codesize_files_wasmfs.imports @@ -11,5 +11,6 @@ j (_wasmfs_get_preloaded_child_path) k (_wasmfs_get_num_preloaded_files) l (_wasmfs_get_num_preloaded_dirs) m (_wasmfs_copy_preloaded_file_data) -n (_abort_js) -o (random_get) +n (_emscripten_memcpy_js) +o (_abort_js) +p (random_get) diff --git a/test/other/codesize/test_codesize_files_wasmfs.jssize b/test/other/codesize/test_codesize_files_wasmfs.jssize index 5aecb7d32517a..861ef7370fa51 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.jssize +++ b/test/other/codesize/test_codesize_files_wasmfs.jssize @@ -1 +1 @@ -6214 +6247 diff --git a/test/other/codesize/test_codesize_files_wasmfs.sent b/test/other/codesize/test_codesize_files_wasmfs.sent index 519a7e0d06403..74ec884c2cde4 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.sent +++ b/test/other/codesize/test_codesize_files_wasmfs.sent @@ -11,5 +11,6 @@ j (_wasmfs_get_preloaded_child_path) k (_wasmfs_get_num_preloaded_files) l (_wasmfs_get_num_preloaded_dirs) m (_wasmfs_copy_preloaded_file_data) -n (_abort_js) -o (random_get) +n (_emscripten_memcpy_js) +o (_abort_js) +p (random_get) diff --git a/test/other/codesize/test_codesize_files_wasmfs.size b/test/other/codesize/test_codesize_files_wasmfs.size index 246d6dcce2d30..2a3e7ddec4326 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.size +++ b/test/other/codesize/test_codesize_files_wasmfs.size @@ -1 +1 @@ -49889 +50973 diff --git a/test/other/codesize/test_codesize_hello_O0.size b/test/other/codesize/test_codesize_hello_O0.size index c2551efd9da3d..097310b36c5ab 100644 --- a/test/other/codesize/test_codesize_hello_O0.size +++ b/test/other/codesize/test_codesize_hello_O0.size @@ -1 +1 @@ -14544 +14519 diff --git a/test/other/codesize/test_codesize_hello_O1.size b/test/other/codesize/test_codesize_hello_O1.size index b86f0690ffbed..48c6e93066ff9 100644 --- a/test/other/codesize/test_codesize_hello_O1.size +++ b/test/other/codesize/test_codesize_hello_O1.size @@ -1 +1 @@ -2552 +2535 diff --git a/test/other/codesize/test_codesize_minimal_O0.size b/test/other/codesize/test_codesize_minimal_O0.size index 7f9d7e97a5258..37cdd416f157a 100644 --- a/test/other/codesize/test_codesize_minimal_O0.size +++ b/test/other/codesize/test_codesize_minimal_O0.size @@ -1 +1 @@ -992 +975 diff --git a/test/other/codesize/test_codesize_minimal_O1.size b/test/other/codesize/test_codesize_minimal_O1.size index 25685cf6b3219..100000a67875f 100644 --- a/test/other/codesize/test_codesize_minimal_O1.size +++ b/test/other/codesize/test_codesize_minimal_O1.size @@ -1 +1 @@ -393 +376 diff --git a/test/other/test_unoptimized_code_size.wasm.size b/test/other/test_unoptimized_code_size.wasm.size index c2551efd9da3d..097310b36c5ab 100644 --- a/test/other/test_unoptimized_code_size.wasm.size +++ b/test/other/test_unoptimized_code_size.wasm.size @@ -1 +1 @@ -14544 +14519 diff --git a/test/other/test_unoptimized_code_size_no_asserts.wasm.size b/test/other/test_unoptimized_code_size_no_asserts.wasm.size index 89916bd925f25..649c6e5ce3b6a 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.wasm.size +++ b/test/other/test_unoptimized_code_size_no_asserts.wasm.size @@ -1 +1 @@ -11737 +11712 diff --git a/test/other/test_unoptimized_code_size_strict.wasm.size b/test/other/test_unoptimized_code_size_strict.wasm.size index c2551efd9da3d..097310b36c5ab 100644 --- a/test/other/test_unoptimized_code_size_strict.wasm.size +++ b/test/other/test_unoptimized_code_size_strict.wasm.size @@ -1 +1 @@ -14544 +14519 From f36fcb877e047de4d4dd7c8c10056cb46eecb97c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 10 Dec 2024 16:07:22 -0800 Subject: [PATCH 048/132] Add some slack to test_extern_prepost. NFC (#23127) This test started failing on the macOS roller. The js size on this test on my machine is 5006 which is very close the limit of 100 * 50 that this test was checking against. The main change here is to reduce the limit to from 5k (100 * 50) to 2.5k (50 * 50). --- test/test_other.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/test_other.py b/test/test_other.py index f3e6b7ee59b9a..b034bbea1f75b 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -2868,16 +2868,18 @@ def test_extern_prepost(self): # code, so they are the very first and last things, and they are not # minified. js = read_file('a.out.js') - pre = js.index('// I am an external pre.') - post = js.index('// I am an external post.') + js_size = len(js) + print('js_size', js_size) + pre_offset = js.index('// I am an external pre.') + post_offset = js.index('// I am an external post.') # ignore some slack - newlines and other things. we just care about the # big picture here SLACK = 50 - self.assertLess(pre, post) - self.assertLess(pre, SLACK) - self.assertGreater(post, len(js) - SLACK) + self.assertLess(pre_offset, post_offset) + self.assertLess(pre_offset, SLACK) + self.assertGreater(post_offset, js_size - SLACK) # make sure the slack is tiny compared to the whole program - self.assertGreater(len(js), 100 * SLACK) + self.assertGreater(js_size, 50 * SLACK) @parameterized({ 'minifyGlobals': (['minifyGlobals'],), From fb77f78365e7c826caf9e4011c639107a0f14010 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 10 Dec 2024 16:43:21 -0800 Subject: [PATCH 049/132] Remove basic_string from embind (#23070) Only `char`, `wchar`, `char8`, `char16`, and `char32` are valid specializations for `std::basic_string`: https://en.cppreference.com/w/cpp/string/basic_string But libc++ had a base template for `basic_string` that allowed any type to be passed for a long time. It looks there have been several attempts to remove this after which they restored it due to complaints, in chronological order: https://github.com/llvm/llvm-project/commit/aeecef08c385b1e4955155dd649a2d3724463849 https://github.com/llvm/llvm-project/commit/08a0faf4cd32bce6c51027ea9b5ec351747995b4 https://github.com/llvm/llvm-project/commit/e30a148b098d462d0267c479cd9e4783363c2761 https://github.com/llvm/llvm-project/pull/66153 https://github.com/llvm/llvm-project/pull/72694 The last one, https://github.com/llvm/llvm-project/pull/72694, eventually removed it. So `std::basic_string` is not allowed anymore. This removes all uses of `std::basic_string` from embind. This needs to be done to update libc++ to LLVM 19 (#22994). I'm uploading this as a separate PR because this removes a functionality from embind. --- ChangeLog.md | 4 ++++ src/embind/embind.js | 3 +-- system/lib/embind/bind.cpp | 2 -- test/code_size/embind_hello_wasm.json | 12 ++++++------ test/code_size/embind_val_wasm.json | 12 ++++++------ test/embind/embind.test.js | 27 --------------------------- test/embind/embind_test.cpp | 5 ----- 7 files changed, 17 insertions(+), 48 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index c38e5207ea6f1..649ed9e0b344e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -26,6 +26,10 @@ See docs/process.md for more on how version tagging works. - Emscripten-generated code will now use async/await internally when loading the Wasm module. This will be lowered away by babel when targeting older browsers. (#23068) +- Due to the discontinued support for invalid specializations of +- `std::basic_string` (https://github.com/llvm/llvm-project/pull/72694), the + support for `std::basic_string` was removed from embind. + (#23070) 3.1.73 - 11/28/24 ----------------- diff --git a/src/embind/embind.js b/src/embind/embind.js index 64b6fd437d36a..941d9cf54d366 100644 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -496,8 +496,7 @@ var LibraryEmbind = { name = readLatin1String(name); var stdStringIsUTF8 #if EMBIND_STD_STRING_IS_UTF8 - //process only std::string bindings with UTF8 support, in contrast to e.g. std::basic_string - = (name === "std::string"); + = true; #else = false; #endif diff --git a/system/lib/embind/bind.cpp b/system/lib/embind/bind.cpp index e7f17c64631b7..fa32bd173ca4f 100644 --- a/system/lib/embind/bind.cpp +++ b/system/lib/embind/bind.cpp @@ -149,8 +149,6 @@ EMSCRIPTEN_BINDINGS(builtin) { register_float("double"); _embind_register_std_string(TypeID::get(), "std::string"); - _embind_register_std_string( - TypeID>::get(), "std::basic_string"); _embind_register_std_wstring(TypeID::get(), sizeof(wchar_t), "std::wstring"); _embind_register_std_wstring(TypeID::get(), sizeof(char16_t), "std::u16string"); _embind_register_std_wstring(TypeID::get(), sizeof(char32_t), "std::u32string"); diff --git a/test/code_size/embind_hello_wasm.json b/test/code_size/embind_hello_wasm.json index f3b1d73bc6bec..9d622aa122fca 100644 --- a/test/code_size/embind_hello_wasm.json +++ b/test/code_size/embind_hello_wasm.json @@ -1,10 +1,10 @@ { "a.html": 552, "a.html.gz": 380, - "a.js": 9718, - "a.js.gz": 4291, - "a.wasm": 7728, - "a.wasm.gz": 3502, - "total": 17998, - "total_gz": 8173 + "a.js": 9593, + "a.js.gz": 4230, + "a.wasm": 7615, + "a.wasm.gz": 3471, + "total": 17760, + "total_gz": 8081 } diff --git a/test/code_size/embind_val_wasm.json b/test/code_size/embind_val_wasm.json index 9af792edee31e..69ed419b496d4 100644 --- a/test/code_size/embind_val_wasm.json +++ b/test/code_size/embind_val_wasm.json @@ -1,10 +1,10 @@ { "a.html": 552, "a.html.gz": 380, - "a.js": 6849, - "a.js.gz": 2947, - "a.wasm": 9568, - "a.wasm.gz": 4911, - "total": 16969, - "total_gz": 8238 + "a.js": 6724, + "a.js.gz": 2900, + "a.wasm": 9528, + "a.wasm.gz": 4896, + "total": 16804, + "total_gz": 8176 } diff --git a/test/embind/embind.test.js b/test/embind/embind.test.js index 9e17adf6173b7..81afe5b8d7465 100644 --- a/test/embind/embind.test.js +++ b/test/embind/embind.test.js @@ -449,33 +449,6 @@ module({ assert.equal('ABCD', e); }); - test("can pass Uint8Array to std::basic_string", function() { - var e = cm.emval_test_take_and_return_std_basic_string_unsigned_char(new Uint8Array([65, 66, 67, 68])); - assert.equal('ABCD', e); - }); - - test("can pass long string to std::basic_string", function() { - var s = 'this string is long enough to exceed the short string optimization'; - var e = cm.emval_test_take_and_return_std_basic_string_unsigned_char(s); - assert.equal(s, e); - }); - - test("can pass Uint8ClampedArray to std::basic_string", function() { - var e = cm.emval_test_take_and_return_std_basic_string_unsigned_char(new Uint8ClampedArray([65, 66, 67, 68])); - assert.equal('ABCD', e); - }); - - - test("can pass Int8Array to std::basic_string", function() { - var e = cm.emval_test_take_and_return_std_basic_string_unsigned_char(new Int8Array([65, 66, 67, 68])); - assert.equal('ABCD', e); - }); - - test("can pass ArrayBuffer to std::basic_string", function() { - var e = cm.emval_test_take_and_return_std_basic_string_unsigned_char((new Int8Array([65, 66, 67, 68])).buffer); - assert.equal('ABCD', e); - }); - test("can pass string to std::string", function() { var string = stdStringIsUTF8?"aeiáéíαειЖЛФ從獅子€":"ABCD"; diff --git a/test/embind/embind_test.cpp b/test/embind/embind_test.cpp index 3b5d3c9044682..f86349da05856 100644 --- a/test/embind/embind_test.cpp +++ b/test/embind/embind_test.cpp @@ -246,10 +246,6 @@ std::string emval_test_take_and_return_std_string_const_ref(const std::string& s return str; } -std::basic_string emval_test_take_and_return_std_basic_string_unsigned_char(std::basic_string str) { - return str; -} - std::wstring take_and_return_std_wstring(std::wstring str) { return str; } @@ -1914,7 +1910,6 @@ EMSCRIPTEN_BINDINGS(tests) { //function("emval_test_take_and_return_const_char_star", &emval_test_take_and_return_const_char_star); function("emval_test_take_and_return_std_string", &emval_test_take_and_return_std_string); function("emval_test_take_and_return_std_string_const_ref", &emval_test_take_and_return_std_string_const_ref); - function("emval_test_take_and_return_std_basic_string_unsigned_char", &emval_test_take_and_return_std_basic_string_unsigned_char); function("take_and_return_std_wstring", &take_and_return_std_wstring); function("take_and_return_std_u16string", &take_and_return_std_u16string); function("take_and_return_std_u32string", &take_and_return_std_u32string); From 1171adaa21048ba8dc82169b9d79952e8754b201 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Tue, 10 Dec 2024 20:35:04 -0800 Subject: [PATCH 050/132] Fix UB in test_unistd_write_broken_link (#23125) The test was failing under ASan because no null byte was being read from the file, so the strlen inside printf was running off the buffer. It just happened to work on non-ASan because wasm memory is initialized to zero. --- test/unistd/test_unistd_write_broken_link.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/unistd/test_unistd_write_broken_link.c b/test/unistd/test_unistd_write_broken_link.c index 1c119a6e45a7e..014af7860b78f 100644 --- a/test/unistd/test_unistd_write_broken_link.c +++ b/test/unistd/test_unistd_write_broken_link.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -16,7 +17,9 @@ int main() { int target_fd = open("link_target", O_RDONLY); printf("target_fd: %d, errno: %d %s\n", target_fd, errno, strerror(errno)); char buf[10]; - read(target_fd, buf, 10); + memset(buf, 0, 10); + size_t r = read(target_fd, buf, 10); + assert(r == 3); printf("buf: '%s'\n", buf); close(target_fd); } @@ -24,7 +27,9 @@ int main() { int target_fd = open("link_source", O_RDONLY); printf("target_fd: %d, errno: %d %s\n", target_fd, errno, strerror(errno)); char buf[10]; - read(target_fd, buf, 10); + memset(buf, 0, 10); + size_t r = read(target_fd, buf, 10); + assert(r == 3); printf("buf: '%s'\n", buf); close(target_fd); } From 6ec518ae5ac6cd2bee9d14d085fbd444c4715aa2 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 12 Dec 2024 12:38:15 -0800 Subject: [PATCH 051/132] Rebaseline codesize expectations. NFC --- test/code_size/hello_wasm_worker_wasm.json | 4 ++-- test/code_size/hello_webgl2_wasm.json | 4 ++-- test/code_size/hello_webgl2_wasm2js.json | 4 ++-- test/code_size/hello_webgl_wasm.json | 4 ++-- test/code_size/hello_webgl_wasm2js.json | 4 ++-- test/other/codesize/test_codesize_cxx_ctors1.size | 2 +- test/other/codesize/test_codesize_cxx_ctors2.size | 2 +- test/other/codesize/test_codesize_cxx_except.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.size | 2 +- test/other/codesize/test_codesize_cxx_lto.size | 2 +- test/other/codesize/test_codesize_cxx_mangle.size | 2 +- test/other/codesize/test_codesize_cxx_noexcept.size | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.size | 2 +- 14 files changed, 19 insertions(+), 19 deletions(-) diff --git a/test/code_size/hello_wasm_worker_wasm.json b/test/code_size/hello_wasm_worker_wasm.json index 870b7172314c4..70feb27fdb040 100644 --- a/test/code_size/hello_wasm_worker_wasm.json +++ b/test/code_size/hello_wasm_worker_wasm.json @@ -6,7 +6,7 @@ "a.ww.js": 115, "a.ww.js.gz": 127, "a.wasm": 1881, - "a.wasm.gz": 1065, + "a.wasm.gz": 1068, "total": 3279, - "total_gz": 2031 + "total_gz": 2034 } diff --git a/test/code_size/hello_webgl2_wasm.json b/test/code_size/hello_webgl2_wasm.json index bf14a6e1a53c9..13919b590d957 100644 --- a/test/code_size/hello_webgl2_wasm.json +++ b/test/code_size/hello_webgl2_wasm.json @@ -4,7 +4,7 @@ "a.js": 4532, "a.js.gz": 2315, "a.wasm": 10402, - "a.wasm.gz": 6704, + "a.wasm.gz": 6703, "total": 15388, - "total_gz": 9347 + "total_gz": 9346 } diff --git a/test/code_size/hello_webgl2_wasm2js.json b/test/code_size/hello_webgl2_wasm2js.json index 88cc365f6f5f7..d54f14a652c99 100644 --- a/test/code_size/hello_webgl2_wasm2js.json +++ b/test/code_size/hello_webgl2_wasm2js.json @@ -2,7 +2,7 @@ "a.html": 346, "a.html.gz": 262, "a.js": 22200, - "a.js.gz": 11582, + "a.js.gz": 11583, "total": 22546, - "total_gz": 11844 + "total_gz": 11845 } diff --git a/test/code_size/hello_webgl_wasm.json b/test/code_size/hello_webgl_wasm.json index b20428e2fed64..e619b3f3321c3 100644 --- a/test/code_size/hello_webgl_wasm.json +++ b/test/code_size/hello_webgl_wasm.json @@ -4,7 +4,7 @@ "a.js": 4070, "a.js.gz": 2158, "a.wasm": 10402, - "a.wasm.gz": 6704, + "a.wasm.gz": 6703, "total": 14926, - "total_gz": 9190 + "total_gz": 9189 } diff --git a/test/code_size/hello_webgl_wasm2js.json b/test/code_size/hello_webgl_wasm2js.json index bc0dfe84d64a8..a01758dd16374 100644 --- a/test/code_size/hello_webgl_wasm2js.json +++ b/test/code_size/hello_webgl_wasm2js.json @@ -2,7 +2,7 @@ "a.html": 346, "a.html.gz": 262, "a.js": 21726, - "a.js.gz": 11415, + "a.js.gz": 11413, "total": 22072, - "total_gz": 11677 + "total_gz": 11675 } diff --git a/test/other/codesize/test_codesize_cxx_ctors1.size b/test/other/codesize/test_codesize_cxx_ctors1.size index d744c653894ea..0062807e33f12 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.size +++ b/test/other/codesize/test_codesize_cxx_ctors1.size @@ -1 +1 @@ -129168 +129224 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.size b/test/other/codesize/test_codesize_cxx_ctors2.size index 56759f32a7df5..753caed4b4757 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.size +++ b/test/other/codesize/test_codesize_cxx_ctors2.size @@ -1 +1 @@ -128617 +128673 diff --git a/test/other/codesize/test_codesize_cxx_except.size b/test/other/codesize/test_codesize_cxx_except.size index e531829ac5ef3..6f064a664be5b 100644 --- a/test/other/codesize/test_codesize_cxx_except.size +++ b/test/other/codesize/test_codesize_cxx_except.size @@ -1 +1 @@ -171298 +171354 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.size b/test/other/codesize/test_codesize_cxx_except_wasm.size index eb551ef1e63ad..5f03a40ca51b3 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm.size @@ -1 +1 @@ -142418 +142474 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size index 8ba15fbee382f..30087621eb370 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size @@ -1 +1 @@ -145005 +145061 diff --git a/test/other/codesize/test_codesize_cxx_lto.size b/test/other/codesize/test_codesize_cxx_lto.size index c1283987423eb..36e2c6d3c0149 100644 --- a/test/other/codesize/test_codesize_cxx_lto.size +++ b/test/other/codesize/test_codesize_cxx_lto.size @@ -1 +1 @@ -121867 +121923 diff --git a/test/other/codesize/test_codesize_cxx_mangle.size b/test/other/codesize/test_codesize_cxx_mangle.size index 09e3c737b99ac..034475a0e5f36 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.size +++ b/test/other/codesize/test_codesize_cxx_mangle.size @@ -1 +1 @@ -232786 +232863 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.size b/test/other/codesize/test_codesize_cxx_noexcept.size index 602c55bf97bd0..f0ef6f60a1014 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.size +++ b/test/other/codesize/test_codesize_cxx_noexcept.size @@ -1 +1 @@ -131975 +132031 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.size b/test/other/codesize/test_codesize_cxx_wasmfs.size index 849311107e15f..1bc6c4829fc6c 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.size +++ b/test/other/codesize/test_codesize_cxx_wasmfs.size @@ -1 +1 @@ -169227 +169283 From 57fa5e07525b88a256746b2e7a2529ed8d90e214 Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Thu, 12 Dec 2024 13:23:32 -0800 Subject: [PATCH 052/132] [docs] Update docs on closure to match current behavior. (#23142) Closure is not automatically run in -O3 by default. --- docs/emcc.txt | 5 +---- site/source/docs/tools_reference/emcc.rst | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/emcc.txt b/docs/emcc.txt index 560542e38a35f..10b216fde55f2 100644 --- a/docs/emcc.txt +++ b/docs/emcc.txt @@ -252,7 +252,7 @@ Options that are modified or new in *emcc* are listed below: "--closure 0|1|2" [link] Runs the *Closure Compiler*. Possible values are: - * "0": No closure compiler (default in "-O2" and below). + * "0": No closure compiler (default). * "1": Run closure compiler. This greatly reduces the size of the support JavaScript code (everything but the WebAssembly or @@ -277,9 +277,6 @@ Options that are modified or new in *emcc* are listed below: before the closure-compiled code runs, because then it will reuse that variable. - * Closure is only run if JavaScript opts are being done ("-O2" or - above). - "--closure-args=" [link] Pass arguments to the *Closure compiler*. This is an alternative to "EMCC_CLOSURE_ARGS". diff --git a/site/source/docs/tools_reference/emcc.rst b/site/source/docs/tools_reference/emcc.rst index 557eb6daa850a..8f107b8f73255 100644 --- a/site/source/docs/tools_reference/emcc.rst +++ b/site/source/docs/tools_reference/emcc.rst @@ -262,7 +262,7 @@ Options that are modified or new in *emcc* are listed below: [link] Runs the :term:`Closure Compiler`. Possible values are: - - ``0``: No closure compiler (default in ``-O2`` and below). + - ``0``: No closure compiler (default). - ``1``: Run closure compiler. This greatly reduces the size of the support JavaScript code (everything but the WebAssembly or asm.js). Note that this increases compile time significantly. - ``2``: Run closure compiler on *all* the emitted code, even on **asm.js** output in **asm.js** mode. This can further reduce code size, but does prevent a significant amount of **asm.js** optimizations, so it is not recommended unless you want to reduce code size at all costs. @@ -270,7 +270,6 @@ Options that are modified or new in *emcc* are listed below: - Consider using ``-sMODULARIZE`` when using closure, as it minifies globals to names that might conflict with others in the global scope. ``MODULARIZE`` puts all the output into a function (see ``src/settings.js``). - Closure will minify the name of `Module` itself, by default! Using ``MODULARIZE`` will solve that as well. Another solution is to make sure a global variable called `Module` already exists before the closure-compiled code runs, because then it will reuse that variable. - - Closure is only run if JavaScript opts are being done (``-O2`` or above). ``--closure-args=`` [link] From 3502b820c233229db8537aa95b0228e53111e59f Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 12 Dec 2024 14:56:50 -0800 Subject: [PATCH 053/132] Rebaseline test_INCOMING_MODULE_JS_API. NFC (#23145) --- test/other/test_INCOMING_MODULE_JS_API.js.size | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/other/test_INCOMING_MODULE_JS_API.js.size b/test/other/test_INCOMING_MODULE_JS_API.js.size index e89de89279dac..739a6f779a116 100644 --- a/test/other/test_INCOMING_MODULE_JS_API.js.size +++ b/test/other/test_INCOMING_MODULE_JS_API.js.size @@ -1 +1 @@ -4018 +3851 From fe2806024539a236f074ef7f3c6b97a6cad63017 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 12 Dec 2024 14:58:05 -0800 Subject: [PATCH 054/132] Simplify jsmath.c. NFC (#23144) `casttype` is always identical to `type` so is not needed. Also the actual cast operation is never needed since the argument type is always declared correctly. --- system/lib/jsmath.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/system/lib/jsmath.c b/system/lib/jsmath.c index b6a7ff3a80b82..a3f32376a1e53 100644 --- a/system/lib/jsmath.c +++ b/system/lib/jsmath.c @@ -6,13 +6,13 @@ #include #include -#define CALL_JS_1(cname, jsname, type, casttype) \ +#define CALL_JS_1(cname, jsname, type) \ EM_JS(type, JS_##cname, (type x), { return jsname(x) }); \ - type cname(type x) { return JS_##cname((casttype)x); } + type cname(type x) { return JS_##cname(x); } #define CALL_JS_1_TRIPLE(cname, jsname) \ - CALL_JS_1(cname, jsname, double, double) \ - CALL_JS_1(cname##f, jsname, float, float) + CALL_JS_1(cname, jsname, double) \ + CALL_JS_1(cname##f, jsname, float) CALL_JS_1_TRIPLE(cos, Math.cos) CALL_JS_1_TRIPLE(sin, Math.sin) @@ -27,24 +27,24 @@ CALL_JS_1_TRIPLE(fabs, Math.abs) CALL_JS_1_TRIPLE(ceil, Math.ceil) CALL_JS_1_TRIPLE(floor, Math.floor) -#define CALL_JS_2(cname, jsname, type, casttype) \ +#define CALL_JS_2(cname, jsname, type) \ EM_JS(type, JS_##cname, (type x, type y), { return jsname(x, y) }); \ - type cname(type x, type y) { return JS_##cname((casttype)x, (casttype)y); } + type cname(type x, type y) { return JS_##cname(x, y); } #define CALL_JS_2_TRIPLE(cname, jsname) \ - CALL_JS_2(cname, jsname, double, double) \ - CALL_JS_2(cname##f, jsname, float, float) + CALL_JS_2(cname, jsname, double) \ + CALL_JS_2(cname##f, jsname, float) CALL_JS_2_TRIPLE(atan2, Math.atan2) CALL_JS_2_TRIPLE(pow, Math.pow) -#define CALL_JS_1_IMPL(cname, type, casttype, impl) \ +#define CALL_JS_1_IMPL(cname, type, impl) \ EM_JS(type, JS_##cname, (type x), impl); \ - type cname(type x) { return JS_##cname((casttype)x); } + type cname(type x) { return JS_##cname(x); } #define CALL_JS_1_IMPL_TRIPLE(cname, impl) \ - CALL_JS_1_IMPL(cname, double, double, impl) \ - CALL_JS_1_IMPL(cname##f, float, float, impl) + CALL_JS_1_IMPL(cname, double, impl) \ + CALL_JS_1_IMPL(cname##f, float, impl) CALL_JS_1_IMPL_TRIPLE(round, { return x >= 0 ? Math.floor(x + 0.5) : Math.ceil(x - 0.5); From 241ac54b3d026b66fc249f25ea735fa230404220 Mon Sep 17 00:00:00 2001 From: slowriot Date: Thu, 12 Dec 2024 23:17:59 +0000 Subject: [PATCH 055/132] [NFC] Grammar fixes in webaudio comments (#23141) --- system/include/emscripten/webaudio.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/system/include/emscripten/webaudio.h b/system/include/emscripten/webaudio.h index 4ec2882cdce53..624a13538865a 100644 --- a/system/include/emscripten/webaudio.h +++ b/system/include/emscripten/webaudio.h @@ -62,7 +62,7 @@ void emscripten_destroy_web_audio_node(EMSCRIPTEN_WEBAUDIO_T objectHandle); // Create Wasm AudioWorklet thread. Call this function once at application startup to establish an AudioWorkletGlobalScope for your app. // After the scope has been initialized, the given callback will fire. // audioContext: The Web Audio context object to initialize the Wasm AudioWorklet thread on. Each AudioContext can have only one AudioWorklet -// thread running, so do not call this function a multiple times on the same AudioContext. +// thread running, so do not call this function multiple times on the same AudioContext. // stackLowestAddress: The base address for the thread's stack. Must be aligned to 16 bytes. Use e.g. memalign(16, 1024) to allocate a 1KB stack for the thread. // stackSize: The size of the thread's stack. Must be a multiple of 16 bytes. // callback: The callback function that will be run when thread creation either succeeds or fails. @@ -76,8 +76,8 @@ typedef int WEBAUDIO_PARAM_AUTOMATION_RATE; typedef struct WebAudioParamDescriptor { float defaultValue; // Default == 0.0 - float minValue; // Default = -3.4028235e38; - float maxValue; // Default = 3.4028235e38; + float minValue; // Default = -3.4028235e38 + float maxValue; // Default = 3.4028235e38 WEBAUDIO_PARAM_AUTOMATION_RATE automationRate; // Either WEBAUDIO_PARAM_A_RATE or WEBAUDIO_PARAM_K_RATE. Default = WEBAUDIO_PARAM_A_RATE } WebAudioParamDescriptor; @@ -96,7 +96,7 @@ typedef void (*EmscriptenWorkletProcessorCreatedCallback)(EMSCRIPTEN_WEBAUDIO_T void emscripten_create_wasm_audio_worklet_processor_async(EMSCRIPTEN_WEBAUDIO_T audioContext, const WebAudioWorkletProcessorCreateOptions *options, EmscriptenWorkletProcessorCreatedCallback callback, void *userData3); // Returns the number of samples processed per channel in an AudioSampleFrame, fixed at 128 in the Web Audio API 1.0 specification, and valid for the lifetime of the audio context. -// For this to change from the default 128, the context would need creating with a yet unexposed WebAudioWorkletProcessorCreateOptions renderSizeHint, part of the 1.1 Web Audio API. +// For this to change from the default 128, the context would need to be created with a yet unexposed WebAudioWorkletProcessorCreateOptions renderSizeHint, part of the 1.1 Web Audio API. int emscripten_audio_context_quantum_size(EMSCRIPTEN_WEBAUDIO_T audioContext); typedef int EMSCRIPTEN_AUDIO_WORKLET_NODE_T; @@ -148,15 +148,15 @@ bool emscripten_current_thread_is_audio_worklet(void); #define EMSCRIPTEN_AUDIO_MAIN_THREAD 0 -/* emscripten_audio_worklet_function_*: Post a pointer to a C/C++ function to be executed either - on the Audio Worklet thread of the given Web Audio context. Notes: +/* emscripten_audio_worklet_function_*: Post a pointer to a C/C++ function to be executed on the Audio Worklet + thread of the given Web Audio context. Notes: - If running inside an Audio Worklet thread, specify ID EMSCRIPTEN_AUDIO_MAIN_THREAD (== 0) to pass a message from the audio worklet to the main thread. - When specifying non-zero ID, the Audio Context denoted by the ID must have been created by the calling thread. - Passing messages between audio thread and main thread with this family of functions is relatively slow and has a really high latency cost compared to direct coordination using atomics and synchronization primitives like - mutexes and synchronization primitives. Additionally these functions will generate garbage on the JS heap. - Therefore avoid using these functions where performance is critical. */ + mutexes. Additionally these functions will generate garbage on the JS heap. Therefore avoid using these + functions where performance is critical. */ void emscripten_audio_worklet_post_function_v(EMSCRIPTEN_WEBAUDIO_T id, void (*funcPtr)(void)); void emscripten_audio_worklet_post_function_vi(EMSCRIPTEN_WEBAUDIO_T id, void (*funcPtr)(int), int arg0); void emscripten_audio_worklet_post_function_vii(EMSCRIPTEN_WEBAUDIO_T id, void (*funcPtr)(int, int), int arg0, int arg1); From 48504a5be77e9d6b36eb3ad694c27a3231336647 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 12 Dec 2024 15:18:46 -0800 Subject: [PATCH 056/132] [test] Remove EMSCRIPTEN_KEEPALIVE from _ReportResult. NFC (#23119) On the emscripten side we have `reportResultToServer` already. --- test/pthread/call_async_on_main_thread.js | 2 +- test/report_result.c | 4 ++-- test/webaudio/create_webaudio.c | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/test/pthread/call_async_on_main_thread.js b/test/pthread/call_async_on_main_thread.js index e818c320ebaac..0862be67714e9 100644 --- a/test/pthread/call_async_on_main_thread.js +++ b/test/pthread/call_async_on_main_thread.js @@ -7,6 +7,6 @@ addToLibrary({ console.error('This function should be getting called on the main thread!'); } console.log('got ' + param1 + ' ' + param2 + ' ' + param3); - __ReportResult(param1 + param2 * param3); + reportResultToServer(param1 + param2 * param3); } }); diff --git a/test/report_result.c b/test/report_result.c index 7cf7952b33661..6ee2b985358df 100644 --- a/test/report_result.c +++ b/test/report_result.c @@ -21,11 +21,11 @@ extern "C" { #if defined __EMSCRIPTEN__ && !defined EMTEST_NODE -void EMSCRIPTEN_KEEPALIVE _ReportResult(int result) { +void _ReportResult(int result) { EM_ASM(reportResultToServer($0), result); } -void EMSCRIPTEN_KEEPALIVE _MaybeReportResult(int result) { +void _MaybeReportResult(int result) { EM_ASM(maybeReportResultToServer($0), result); } diff --git a/test/webaudio/create_webaudio.c b/test/webaudio/create_webaudio.c index 579c9e7d2ab83..60a21df097dd5 100644 --- a/test/webaudio/create_webaudio.c +++ b/test/webaudio/create_webaudio.c @@ -23,9 +23,7 @@ int main() startButton.onclick = () => { if (audioContext.state != 'running') { audioContext.resume(); -#ifdef REPORT_RESULT - __ReportResult(0); -#endif + reportResultToServer(0); } else { audioContext.suspend(); } From 3b8d3fa97ebbb83e23973ca55015d4ec155486a8 Mon Sep 17 00:00:00 2001 From: Carl Woffenden Date: Fri, 13 Dec 2024 00:24:30 +0100 Subject: [PATCH 057/132] [AUDIO_WORKLET] Fix when compiling with STRICT (#23130) Fix for #22971. This highlights that the AW tests weren't catching this or other issues in the parameterised tests. Running, for example: ``` test/runner browser.test_audio_worklet_strict ``` Passes, but if compiled with the same settings doesn't run. --- tools/link.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/link.py b/tools/link.py index d008759220c09..76b6e521bb8d4 100644 --- a/tools/link.py +++ b/tools/link.py @@ -1403,6 +1403,8 @@ def phase_linker_setup(options, state, newargs): # noqa: C901, PLR0912, PLR0915 # MINIMAL_RUNTIME exports these manually, since this export mechanism is placed # in global scope that is not suitable for MINIMAL_RUNTIME loader. settings.EXPORTED_RUNTIME_METHODS += ['stackSave', 'stackAlloc', 'stackRestore', 'wasmTable'] + # The following symbols need exposing to load and bootstrap the audio worklet: + settings.INCOMING_MODULE_JS_API += ['instantiateWasm', 'wasm', 'wasmMemory'] if settings.FORCE_FILESYSTEM and not settings.MINIMAL_RUNTIME: # when the filesystem is forced, we export by default methods that filesystem usage From d04f14a8102e9c6ba1e0f9f435f36abd16f1587a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 12 Dec 2024 16:15:20 -0800 Subject: [PATCH 058/132] Remove unnecessary functions from jsmath.c. NFC (#23143) See the comments at the top of `emscripten/js_math.h` for why JS versions of these functions are not needed. As a followup I plan to map `jsmath.c` functions to `em_math.h` functions instead of using EM_JS here. See #19284 --- system/include/emscripten/em_math.h | 2 +- system/lib/jsmath.c | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/system/include/emscripten/em_math.h b/system/include/emscripten/em_math.h index 63433bbf31b13..2c44700198b53 100644 --- a/system/include/emscripten/em_math.h +++ b/system/include/emscripten/em_math.h @@ -29,7 +29,7 @@ extern "C" { // Math.ceil -> f32.ceil and f64.ceil (ceil() and ceilf() in math.h) // Math.clz32(x) -> i32.clz and i64.clz (call __builtin_clz() and __builtin_clzll()) // Math.floor -> f32.floor and f64.floor (floor() and floorf() in math.h) -// Math.fround -> f64.promote_f32(f32.demote_f64()) (call double d = (double)(float)someDouble;) +// Math.fround -> f64.promote_f32(f32.demote_f64()) (double d = (double)(float)someDouble;) // Math.imul(x, y) -> i32.mul and i64.mul (directly multiply two signed integers) // Math.min -> f32.min and f64.min (fminf() and fmin() in math.h) // Math.max -> f32.max and f64.max (fmaxf() and fmax() in math.h) diff --git a/system/lib/jsmath.c b/system/lib/jsmath.c index a3f32376a1e53..942437fb6469a 100644 --- a/system/lib/jsmath.c +++ b/system/lib/jsmath.c @@ -23,9 +23,6 @@ CALL_JS_1_TRIPLE(atan, Math.atan) CALL_JS_1_TRIPLE(exp, Math.exp) CALL_JS_1_TRIPLE(log, Math.log) CALL_JS_1_TRIPLE(sqrt, Math.sqrt) -CALL_JS_1_TRIPLE(fabs, Math.abs) -CALL_JS_1_TRIPLE(ceil, Math.ceil) -CALL_JS_1_TRIPLE(floor, Math.floor) #define CALL_JS_2(cname, jsname, type) \ EM_JS(type, JS_##cname, (type x, type y), { return jsname(x, y) }); \ @@ -55,6 +52,3 @@ CALL_JS_1_IMPL_TRIPLE(rint, { } return (x - Math.floor(x) != .5) ? round(x) : round(x / 2) * 2; }) - -double nearbyint(double x) { return rint(x); } -float nearbyintf(float x) { return rintf(x); } From 53c81324624f8cc3d09bc32151831d5d7830ac22 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 12 Dec 2024 16:57:17 -0800 Subject: [PATCH 059/132] Remove polyfills for Fetch and Object.assign (#23118) This change required the minimum supported browser versions to be bumped just a little. --- ChangeLog.md | 6 ++- src/polyfill/fetch.js | 80 -------------------------------------- src/polyfill/objassign.js | 34 ---------------- src/shell.js | 10 ----- src/shell_minimal.js | 7 ---- test/browser_reporting.js | 3 +- test/test_browser.py | 82 --------------------------------------- test/test_other.py | 2 +- tools/feature_matrix.py | 6 +-- 9 files changed, 10 insertions(+), 220 deletions(-) delete mode 100644 src/polyfill/fetch.js delete mode 100644 src/polyfill/objassign.js diff --git a/ChangeLog.md b/ChangeLog.md index 649ed9e0b344e..fde29fc55de81 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -22,7 +22,6 @@ See docs/process.md for more on how version tagging works. ----------------------- - The file system was updated to independently track atime, mtime and ctime instead of using the same time for all three. (#22998) -- The minimum supported chrome version was bumped from 32 to 33. (#23077) - Emscripten-generated code will now use async/await internally when loading the Wasm module. This will be lowered away by babel when targeting older browsers. (#23068) @@ -30,6 +29,11 @@ See docs/process.md for more on how version tagging works. - `std::basic_string` (https://github.com/llvm/llvm-project/pull/72694), the support for `std::basic_string` was removed from embind. (#23070) +- The minimum supported versions of browser engines that we support were updated + to versions that support Promise, Fetch and Object.asign APIs, allowing the + polyfills for these to be removed. Chrome 32 -> 45, Firefox 34 -> 40, Safari + 9.0 -> 10.1. These browser engines version are all over 8 years old now. + (#23077, #23118) 3.1.73 - 11/28/24 ----------------- diff --git a/src/polyfill/fetch.js b/src/polyfill/fetch.js deleted file mode 100644 index 979335699a84e..0000000000000 --- a/src/polyfill/fetch.js +++ /dev/null @@ -1,80 +0,0 @@ -// Fetch polyfill from https://github.com/developit/unfetch -// License: -//============================================================================== -// Copyright (c) 2017 Jason Miller -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -//============================================================================== - -#if !POLYFILL -#error "this file should never be included unless POLYFILL is set" -#endif - -if (typeof globalThis.fetch == 'undefined') { - globalThis.fetch = function (url, options) { - options = options || {}; - return new Promise((resolve, reject) => { - const request = new XMLHttpRequest(); - const keys = []; - const headers = {}; - - request.responseType = 'arraybuffer'; - - const response = () => ({ - ok: ((request.status / 100) | 0) == 2, // 200-299 - statusText: request.statusText, - status: request.status, - url: request.responseURL, - text: () => Promise.resolve(request.responseText), - json: () => Promise.resolve(request.responseText).then(JSON.parse), - blob: () => Promise.resolve(new Blob([request.response])), - arrayBuffer: () => Promise.resolve(request.response), - clone: response, - headers: { - keys: () => keys, - entries: () => keys.map((n) => [n, request.getResponseHeader(n)]), - get: (n) => request.getResponseHeader(n), - has: (n) => request.getResponseHeader(n) != null, - }, - }); - - request.open(options.method || "get", url, true); - - request.onload = () => { - request - .getAllResponseHeaders() - .toLowerCase() - .replace(/^(.+?):/gm, (m, key) => { - headers[key] || keys.push((headers[key] = key)); - }); - resolve(response()); - }; - - request.onerror = reject; - - request.withCredentials = options.credentials == "include"; - - for (const i in options.headers) { - request.setRequestHeader(i, options.headers[i]); - } - - request.send(options.body || null); - }); - } -} diff --git a/src/polyfill/objassign.js b/src/polyfill/objassign.js deleted file mode 100644 index e9aafe02d3274..0000000000000 --- a/src/polyfill/objassign.js +++ /dev/null @@ -1,34 +0,0 @@ -// Object.assign polyfill from: -// https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/js/es6/util/assign.js - -#if !POLYFILL -#error "this file should never be included unless POLYFILL is set" -#endif - -if (typeof Object.assign == 'undefined') { - /** - * Equivalent to the Object.assign() method, but guaranteed to be available for use in code - * generated by the compiler. - * - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign - * - * Copies values of all enumerable own properties from one or more - * sources to the given target object, and returns the target. - * - * @final - * @param {!Object} target The target object onto which to copy. - * @param {...?Object} source The source objects. - * @return {!Object} The target object is returned. - * @suppress {visibility, duplicate, checkTypes} - */ - Object.assign = function(target, source) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; - if (!source) continue; - for (var key in source) { - if (source.hasOwnProperty(key)) target[key] = source[key]; - } - } - return target; - }; -} diff --git a/src/shell.js b/src/shell.js index d25aeb85bcee8..79c4e2b5bb732 100644 --- a/src/shell.js +++ b/src/shell.js @@ -34,20 +34,10 @@ var Module = typeof {{{ EXPORT_NAME }}} != 'undefined' ? {{{ EXPORT_NAME }}} : { #endif // USE_CLOSURE_COMPILER #if POLYFILL -#if MIN_CHROME_VERSION < 45 || MIN_FIREFOX_VERSION < 34 || MIN_SAFARI_VERSION < 90000 -// See https://caniuse.com/mdn-javascript_builtins_object_assign -#include "polyfill/objassign.js" -#endif - #if WASM_BIGINT && MIN_SAFARI_VERSION < 150000 // See https://caniuse.com/mdn-javascript_builtins_bigint64array #include "polyfill/bigint64array.js" #endif - -#if MIN_CHROME_VERSION < 40 || MIN_FIREFOX_VERSION < 39 || MIN_SAFARI_VERSION < 103000 -// See https://caniuse.com/fetch -#include "polyfill/fetch.js" -#endif #endif // POLYFILL #if MODULARIZE diff --git a/src/shell_minimal.js b/src/shell_minimal.js index 3c879ffb9383e..9e8b3039208f0 100644 --- a/src/shell_minimal.js +++ b/src/shell_minimal.js @@ -128,13 +128,6 @@ function ready() { #endif } -#if POLYFILL -// See https://caniuse.com/mdn-javascript_builtins_object_assign -#if MIN_CHROME_VERSION < 45 || MIN_FIREFOX_VERSION < 34 || MIN_SAFARI_VERSION < 90000 -#include "polyfill/objassign.js" -#endif -#endif - #if PTHREADS // MINIMAL_RUNTIME does not support --proxy-to-worker option, so Worker and Pthread environments // coincide. diff --git a/test/browser_reporting.js b/test/browser_reporting.js index 603c29f9b0907..0ba4b90482de6 100644 --- a/test/browser_reporting.js +++ b/test/browser_reporting.js @@ -11,8 +11,7 @@ function reportResultToServer(result) { if ((typeof ENVIRONMENT_IS_NODE !== 'undefined' && ENVIRONMENT_IS_NODE) || (typeof ENVIRONMENT_IS_AUDIO_WORKLET !== 'undefined' && ENVIRONMENT_IS_AUDIO_WORKLET)) { out(`RESULT: ${result}`); } else { - let doFetch = typeof origFetch != 'undefined' ? origFetch : fetch; - doFetch(`${reportingURL}/report_result?${encodeURIComponent(result)}`).then(() => { + fetch(`${reportingURL}/report_result?${encodeURIComponent(result)}`).then(() => { if (typeof window === 'object' && window && hasModule && !Module['pageThrewException']) { /* for easy debugging, don't close window on failure */ window.close(); diff --git a/test/test_browser.py b/test/test_browser.py index 0e8d7edee8a93..135e69d0203b8 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -5445,88 +5445,6 @@ def test_webpack(self, es6): shutil.copy('webpack/src/hello.wasm', 'webpack/dist/') self.run_browser('webpack/dist/index.html', '/report_result?exit:0') - def test_fetch_polyfill_preload(self): - create_file('hello.txt', 'hello, world!') - create_file('main.c', r''' - #include - #include - #include - int main() { - FILE *f = fopen("hello.txt", "r"); - char buf[100]; - fread(buf, 1, 20, f); - buf[20] = 0; - fclose(f); - printf("%s\n", buf); - return 0; - }''') - - create_file('on_window_error_shell.html', r''' - -

-

- - {{{ SCRIPT }}} - - ''') - - def test(args, expect_fail): - self.compile_btest('main.c', ['-sEXIT_RUNTIME', '--preload-file', 'hello.txt', '--shell-file', 'on_window_error_shell.html', '-o', 'a.out.html'] + args) - if expect_fail: - js = read_file('a.out.js') - create_file('a.out.js', 'let origFetch = fetch; fetch = undefined;\n' + js) - return self.run_browser('a.out.html', '/report_result?exception:fetch is not a function') - else: - return self.run_browser('a.out.html', '/report_result?exit:0') - - test([], expect_fail=False) - test([], expect_fail=True) - test(['-sLEGACY_VM_SUPPORT'], expect_fail=False) - test(['-sLEGACY_VM_SUPPORT', '-sNO_POLYFILL'], expect_fail=True) - - @no_wasm64('https://github.com/llvm/llvm-project/issues/98778') - def test_fetch_polyfill_shared_lib(self): - create_file('library.c', r''' - int library_func() { - return 42; - } - ''') - create_file('main.c', r''' - #include - #include - int main() { - void *lib_handle = dlopen("/library.so", RTLD_NOW); - typedef int (*voidfunc)(); - voidfunc x = (voidfunc)dlsym(lib_handle, "library_func"); - return x(); - } - ''') - - self.emcc('library.c', ['-sSIDE_MODULE', '-O2', '-o', 'library.so']) - - def test(args, expect_fail): - self.compile_btest('main.c', ['-fPIC', 'library.so', '-sMAIN_MODULE=2', '-sEXIT_RUNTIME', '-o', 'a.out.html'] + args) - if expect_fail: - js = read_file('a.out.js') - create_file('a.out.js', 'let origFetch = fetch; fetch = undefined;\n' + js) - return self.run_browser('a.out.html', '/report_result?abort:both async and sync fetching of the wasm failed') - else: - return self.run_browser('a.out.html', '/report_result?exit:42') - - test([], expect_fail=True) - test(['-sLEGACY_VM_SUPPORT'], expect_fail=False) - test(['-sLEGACY_VM_SUPPORT', '-sNO_POLYFILL'], expect_fail=True) - class emrun(RunnerCore): def test_emrun_info(self): diff --git a/test/test_other.py b/test/test_other.py index b034bbea1f75b..c1ec01d9177e3 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -15260,7 +15260,7 @@ def test_no_extra_output(self): def test_browser_too_old(self): err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sMIN_CHROME_VERSION=10']) - self.assertContained('emcc: error: MIN_CHROME_VERSION older than 33 is not supported', err) + self.assertContained('emcc: error: MIN_CHROME_VERSION older than 45 is not supported', err) def test_js_only_settings(self): err = self.run_process([EMCC, test_file('hello_world.c'), '-o', 'foo.wasm', '-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=emscripten_get_heap_max'], stderr=PIPE).stderr diff --git a/tools/feature_matrix.py b/tools/feature_matrix.py index 0757724ccf7e7..61c9399dd1aad 100644 --- a/tools/feature_matrix.py +++ b/tools/feature_matrix.py @@ -18,9 +18,9 @@ # Oldest support browser versions. These have been set somewhat # arbitrarily for now. # TODO(sbc): Design a of policy for managing these values. -OLDEST_SUPPORTED_CHROME = 33 -OLDEST_SUPPORTED_FIREFOX = 34 -OLDEST_SUPPORTED_SAFARI = 90000 +OLDEST_SUPPORTED_CHROME = 45 # September 1, 2015 +OLDEST_SUPPORTED_FIREFOX = 40 # August 11, 2015 +OLDEST_SUPPORTED_SAFARI = 101000 # September 20, 2016 # 10.19.0 is the oldest version of node that we do any testing with. # Keep this in sync with the test-node-compat in .circleci/config.yml. OLDEST_SUPPORTED_NODE = 101900 From 5efa98ea244fda9476c88ec304f0f57be675fd88 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 12 Dec 2024 17:37:33 -0800 Subject: [PATCH 060/132] Use `em_math.h` functions in `jsmath.c` (#23147) Unlike the current EM_JS implementations, the `em_math.h` functions map directly to `Math.xxx` without a wrapper function. The other advantage of doing it this way is that we avoid duplicate implementations of all these functions. Fixes: #19284 --- system/lib/jsmath.c | 47 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/system/lib/jsmath.c b/system/lib/jsmath.c index 942437fb6469a..87cbc9b3ce336 100644 --- a/system/lib/jsmath.c +++ b/system/lib/jsmath.c @@ -2,38 +2,37 @@ // See JS_MATH setting in settings.js for details. // -#include +#include +#include #include #include #define CALL_JS_1(cname, jsname, type) \ - EM_JS(type, JS_##cname, (type x), { return jsname(x) }); \ - type cname(type x) { return JS_##cname(x); } - -#define CALL_JS_1_TRIPLE(cname, jsname) \ - CALL_JS_1(cname, jsname, double) \ - CALL_JS_1(cname##f, jsname, float) - -CALL_JS_1_TRIPLE(cos, Math.cos) -CALL_JS_1_TRIPLE(sin, Math.sin) -CALL_JS_1_TRIPLE(tan, Math.tan) -CALL_JS_1_TRIPLE(acos, Math.acos) -CALL_JS_1_TRIPLE(asin, Math.asin) -CALL_JS_1_TRIPLE(atan, Math.atan) -CALL_JS_1_TRIPLE(exp, Math.exp) -CALL_JS_1_TRIPLE(log, Math.log) -CALL_JS_1_TRIPLE(sqrt, Math.sqrt) + type cname(type x) { return (type)emscripten_math_##jsname(x); } + +#define CALL_JS_1_TRIPLE(name) \ + CALL_JS_1(name, name, double) \ + CALL_JS_1(name##f, name, float) + +CALL_JS_1_TRIPLE(cos) +CALL_JS_1_TRIPLE(sin) +CALL_JS_1_TRIPLE(tan) +CALL_JS_1_TRIPLE(acos) +CALL_JS_1_TRIPLE(asin) +CALL_JS_1_TRIPLE(atan) +CALL_JS_1_TRIPLE(exp) +CALL_JS_1_TRIPLE(log) +CALL_JS_1_TRIPLE(sqrt) #define CALL_JS_2(cname, jsname, type) \ - EM_JS(type, JS_##cname, (type x, type y), { return jsname(x, y) }); \ - type cname(type x, type y) { return JS_##cname(x, y); } + type cname(type x, type y) { return (type)emscripten_math_##jsname(x, y); } -#define CALL_JS_2_TRIPLE(cname, jsname) \ - CALL_JS_2(cname, jsname, double) \ - CALL_JS_2(cname##f, jsname, float) +#define CALL_JS_2_TRIPLE(name) \ + CALL_JS_2(name, name, double) \ + CALL_JS_2(name##f, name, float) -CALL_JS_2_TRIPLE(atan2, Math.atan2) -CALL_JS_2_TRIPLE(pow, Math.pow) +CALL_JS_2_TRIPLE(atan2) +CALL_JS_2_TRIPLE(pow) #define CALL_JS_1_IMPL(cname, type, impl) \ EM_JS(type, JS_##cname, (type x), impl); \ From 1092ec30a3fb1d46b1782ff1b4db5094d3d06ae5 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 12 Dec 2024 18:38:53 -0800 Subject: [PATCH 061/132] Use async/await for internal readAsync function. NFC (#23120) Followup to #23104. --- src/closure-externs/node-externs.js | 6 ++++++ src/node_shell_read.js | 15 +++++++-------- src/shell.js | 6 +----- src/web_or_worker_shell_read.js | 14 ++++++-------- .../codesize/test_codesize_cxx_ctors1.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors1.jssize | 2 +- .../codesize/test_codesize_cxx_ctors2.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors2.jssize | 2 +- .../codesize/test_codesize_cxx_except.gzsize | 2 +- .../codesize/test_codesize_cxx_except.jssize | 2 +- .../codesize/test_codesize_cxx_except_wasm.gzsize | 2 +- .../codesize/test_codesize_cxx_except_wasm.jssize | 2 +- .../test_codesize_cxx_except_wasm_exnref.gzsize | 2 +- .../test_codesize_cxx_except_wasm_exnref.jssize | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.jssize | 2 +- .../codesize/test_codesize_cxx_mangle.gzsize | 2 +- .../codesize/test_codesize_cxx_mangle.jssize | 2 +- .../codesize/test_codesize_cxx_noexcept.gzsize | 2 +- .../codesize/test_codesize_cxx_noexcept.jssize | 2 +- .../codesize/test_codesize_cxx_wasmfs.gzsize | 2 +- .../codesize/test_codesize_cxx_wasmfs.jssize | 2 +- .../codesize/test_codesize_files_js_fs.gzsize | 2 +- .../codesize/test_codesize_files_js_fs.jssize | 2 +- .../codesize/test_codesize_files_wasmfs.gzsize | 2 +- .../codesize/test_codesize_files_wasmfs.jssize | 2 +- test/other/codesize/test_codesize_hello_O0.gzsize | 2 +- test/other/codesize/test_codesize_hello_O0.jssize | 2 +- test/other/codesize/test_codesize_hello_O1.gzsize | 2 +- test/other/codesize/test_codesize_hello_O1.jssize | 2 +- test/other/codesize/test_codesize_hello_O2.gzsize | 2 +- test/other/codesize/test_codesize_hello_O2.jssize | 2 +- test/other/codesize/test_codesize_hello_O3.gzsize | 2 +- test/other/codesize/test_codesize_hello_O3.jssize | 2 +- test/other/codesize/test_codesize_hello_Os.gzsize | 2 +- test/other/codesize/test_codesize_hello_Os.jssize | 2 +- test/other/codesize/test_codesize_hello_Oz.gzsize | 2 +- test/other/codesize/test_codesize_hello_Oz.jssize | 2 +- .../codesize/test_codesize_hello_dylink.gzsize | 2 +- .../codesize/test_codesize_hello_dylink.jssize | 2 +- .../test_codesize_hello_export_nothing.gzsize | 2 +- .../test_codesize_hello_export_nothing.jssize | 2 +- .../codesize/test_codesize_hello_wasmfs.gzsize | 2 +- .../codesize/test_codesize_hello_wasmfs.jssize | 2 +- .../test_codesize_libcxxabi_message_O3.gzsize | 2 +- .../test_codesize_libcxxabi_message_O3.jssize | 2 +- ...odesize_libcxxabi_message_O3_standalone.gzsize | 2 +- ...odesize_libcxxabi_message_O3_standalone.jssize | 2 +- test/other/codesize/test_codesize_mem_O3.gzsize | 2 +- test/other/codesize/test_codesize_mem_O3.jssize | 2 +- .../codesize/test_codesize_mem_O3_grow.gzsize | 2 +- .../codesize/test_codesize_mem_O3_grow.jssize | 2 +- .../test_codesize_mem_O3_grow_standalone.gzsize | 2 +- .../test_codesize_mem_O3_grow_standalone.jssize | 2 +- .../test_codesize_mem_O3_standalone.gzsize | 2 +- .../test_codesize_mem_O3_standalone.jssize | 2 +- .../test_codesize_mem_O3_standalone_lib.gzsize | 2 +- .../test_codesize_mem_O3_standalone_lib.jssize | 2 +- .../test_codesize_mem_O3_standalone_narg.gzsize | 2 +- .../test_codesize_mem_O3_standalone_narg.jssize | 2 +- ...st_codesize_mem_O3_standalone_narg_flto.gzsize | 2 +- ...st_codesize_mem_O3_standalone_narg_flto.jssize | 2 +- .../codesize/test_codesize_minimal_64.gzsize | 2 +- .../codesize/test_codesize_minimal_64.jssize | 2 +- .../codesize/test_codesize_minimal_O0.gzsize | 2 +- .../codesize/test_codesize_minimal_O0.jssize | 2 +- .../codesize/test_codesize_minimal_O1.gzsize | 2 +- .../codesize/test_codesize_minimal_O1.jssize | 2 +- .../codesize/test_codesize_minimal_O2.gzsize | 2 +- .../codesize/test_codesize_minimal_O2.jssize | 2 +- .../codesize/test_codesize_minimal_O3.gzsize | 2 +- .../codesize/test_codesize_minimal_O3.jssize | 2 +- .../codesize/test_codesize_minimal_Os.gzsize | 2 +- .../codesize/test_codesize_minimal_Os.jssize | 2 +- .../test_codesize_minimal_Oz-ctors.gzsize | 2 +- .../test_codesize_minimal_Oz-ctors.jssize | 2 +- .../codesize/test_codesize_minimal_Oz.gzsize | 2 +- .../codesize/test_codesize_minimal_Oz.jssize | 2 +- .../test_codesize_minimal_pthreads.gzsize | 2 +- .../test_codesize_minimal_pthreads.jssize | 2 +- .../codesize/test_codesize_minimal_wasmfs.gzsize | 2 +- .../codesize/test_codesize_minimal_wasmfs.jssize | 2 +- test/other/test_INCOMING_MODULE_JS_API.js.size | 2 +- test/other/test_unoptimized_code_size.js.size | 2 +- .../test_unoptimized_code_size_no_asserts.js.size | 2 +- .../test_unoptimized_code_size_strict.js.size | 2 +- 86 files changed, 102 insertions(+), 103 deletions(-) diff --git a/src/closure-externs/node-externs.js b/src/closure-externs/node-externs.js index b7a0e6049fa9f..859658c05b2e5 100644 --- a/src/closure-externs/node-externs.js +++ b/src/closure-externs/node-externs.js @@ -86,6 +86,12 @@ Buffer.from = function(arrayBufferOrString, byteOffsetOrEncoding, length) {}; */ Buffer.alloc = function(size, fill, encoding) {}; +/** + * @return {boolean} + * @nosideeffects + */ +Buffer.isBuffer = function(obj) {}; + /** * @param {number=} start * @param {number=} end diff --git a/src/node_shell_read.js b/src/node_shell_read.js index 942c72a1ceed7..8fafd66b81f36 100644 --- a/src/node_shell_read.js +++ b/src/node_shell_read.js @@ -9,18 +9,17 @@ readBinary = (filename) => { filename = isFileURI(filename) ? new URL(filename) : filename; var ret = fs.readFileSync(filename); #if ASSERTIONS - assert(ret.buffer); + assert(Buffer.isBuffer(ret)); #endif return ret; }; -readAsync = (filename, binary = true) => { +readAsync = async (filename, binary = true) => { // See the comment in the `readBinary` function. filename = isFileURI(filename) ? new URL(filename) : filename; - return new Promise((resolve, reject) => { - fs.readFile(filename, binary ? undefined : 'utf8', (err, data) => { - if (err) reject(err); - else resolve(binary ? data.buffer : data); - }); - }); + var ret = fs.readFileSync(filename, binary ? undefined : 'utf8'); +#if ASSERTIONS + assert(binary ? Buffer.isBuffer(ret) : typeof ret == 'string'); +#endif + return ret; }; diff --git a/src/shell.js b/src/shell.js index 79c4e2b5bb732..0010048cf4e84 100644 --- a/src/shell.js +++ b/src/shell.js @@ -290,11 +290,7 @@ if (ENVIRONMENT_IS_SHELL) { return data; }; - readAsync = (f) => { - return new Promise((resolve, reject) => { - setTimeout(() => resolve(readBinary(f))); - }); - }; + readAsync = async (f) => readBinary(f); globalThis.clearTimeout ??= (id) => {}; diff --git a/src/web_or_worker_shell_read.js b/src/web_or_worker_shell_read.js index fbc97918f2501..e24d858c4f1df 100644 --- a/src/web_or_worker_shell_read.js +++ b/src/web_or_worker_shell_read.js @@ -16,7 +16,7 @@ } #endif - readAsync = (url) => { + readAsync = async (url) => { #if ENVIRONMENT_MAY_BE_WEBVIEW // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url. // See https://github.com/github/fetch/pull/92#issuecomment-140665932 @@ -41,11 +41,9 @@ #elif ASSERTIONS assert(!isFileURI(url), "readAsync does not work with file:// URLs"); #endif - return fetch(url, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}) - .then((response) => { - if (response.ok) { - return response.arrayBuffer(); - } - return Promise.reject(new Error(response.status + ' : ' + response.url)); - }) + var response = await fetch(url, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}); + if (response.ok) { + return response.arrayBuffer(); + } + throw new Error(response.status + ' : ' + response.url); }; diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 25b558280e945..468a6eb07aa8e 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8576 +8545 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index f0d741b18ae22..29e9dfe0d59e0 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20969 +20951 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index 3ea5f236f6c35..e2ce68595ae3b 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8560 +8530 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 4ef99cdd0785e..831b5f96cc534 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20937 +20919 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 0fa8352cf2331..01b52bf830622 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9614 +9579 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 4a76440f1a1cc..a01c450fd72cc 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24814 +24796 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index e6ab5d0c9b589..d0dddc6097c20 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8543 +8508 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index 8b47153f81043..f1ed501dc449f 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20863 +20845 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index e6ab5d0c9b589..d0dddc6097c20 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8543 +8508 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index 8b47153f81043..f1ed501dc449f 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20863 +20845 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 732a842aa12a6..cd0e49aee5b8e 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8475 +8446 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index c8b5e7421405b..92d54f818a532 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20548 +20530 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index 58e0f00ae02c8..a6fba7a88ba19 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9613 +9580 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 4a76440f1a1cc..a01c450fd72cc 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24814 +24796 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 25b558280e945..468a6eb07aa8e 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8576 +8545 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index f0d741b18ae22..29e9dfe0d59e0 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20969 +20951 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize index 24a12a49287ba..39ecd9a41b616 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize @@ -1 +1 @@ -3836 +3807 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.jssize b/test/other/codesize/test_codesize_cxx_wasmfs.jssize index c4ec7c412ff1e..dd1e06021b37c 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.jssize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.jssize @@ -1 +1 @@ -8606 +8588 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index 956717deae581..a3058b5a02fd7 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7710 +7686 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index 2314d683d7cb3..47c3867c42329 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18876 +18858 diff --git a/test/other/codesize/test_codesize_files_wasmfs.gzsize b/test/other/codesize/test_codesize_files_wasmfs.gzsize index 004f50eab1549..3580ad11bdcb0 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_files_wasmfs.gzsize @@ -1 +1 @@ -2932 +2906 diff --git a/test/other/codesize/test_codesize_files_wasmfs.jssize b/test/other/codesize/test_codesize_files_wasmfs.jssize index 861ef7370fa51..a6ea3e034d192 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.jssize +++ b/test/other/codesize/test_codesize_files_wasmfs.jssize @@ -1 +1 @@ -6247 +6229 diff --git a/test/other/codesize/test_codesize_hello_O0.gzsize b/test/other/codesize/test_codesize_hello_O0.gzsize index af0a7b0a886ac..72ac185273c84 100644 --- a/test/other/codesize/test_codesize_hello_O0.gzsize +++ b/test/other/codesize/test_codesize_hello_O0.gzsize @@ -1 +1 @@ -8034 +8021 diff --git a/test/other/codesize/test_codesize_hello_O0.jssize b/test/other/codesize/test_codesize_hello_O0.jssize index 0b07ab883de47..f18a59a99db88 100644 --- a/test/other/codesize/test_codesize_hello_O0.jssize +++ b/test/other/codesize/test_codesize_hello_O0.jssize @@ -1 +1 @@ -21479 +21551 diff --git a/test/other/codesize/test_codesize_hello_O1.gzsize b/test/other/codesize/test_codesize_hello_O1.gzsize index ece5108dd4bce..8061cb7887295 100644 --- a/test/other/codesize/test_codesize_hello_O1.gzsize +++ b/test/other/codesize/test_codesize_hello_O1.gzsize @@ -1 +1 @@ -2785 +2761 diff --git a/test/other/codesize/test_codesize_hello_O1.jssize b/test/other/codesize/test_codesize_hello_O1.jssize index 13068939d1a42..162b0d0c72042 100644 --- a/test/other/codesize/test_codesize_hello_O1.jssize +++ b/test/other/codesize/test_codesize_hello_O1.jssize @@ -1 +1 @@ -7004 +7028 diff --git a/test/other/codesize/test_codesize_hello_O2.gzsize b/test/other/codesize/test_codesize_hello_O2.gzsize index 51d5790fa9f86..1415bc57370d0 100644 --- a/test/other/codesize/test_codesize_hello_O2.gzsize +++ b/test/other/codesize/test_codesize_hello_O2.gzsize @@ -1 +1 @@ -2434 +2408 diff --git a/test/other/codesize/test_codesize_hello_O2.jssize b/test/other/codesize/test_codesize_hello_O2.jssize index 032c246660549..87c7f9ec33478 100644 --- a/test/other/codesize/test_codesize_hello_O2.jssize +++ b/test/other/codesize/test_codesize_hello_O2.jssize @@ -1 +1 @@ -4955 +4937 diff --git a/test/other/codesize/test_codesize_hello_O3.gzsize b/test/other/codesize/test_codesize_hello_O3.gzsize index c4fdb9ba8959b..ed5edbf7f250d 100644 --- a/test/other/codesize/test_codesize_hello_O3.gzsize +++ b/test/other/codesize/test_codesize_hello_O3.gzsize @@ -1 +1 @@ -2346 +2320 diff --git a/test/other/codesize/test_codesize_hello_O3.jssize b/test/other/codesize/test_codesize_hello_O3.jssize index 534d8e6bdcc90..1ab0d2e7606cc 100644 --- a/test/other/codesize/test_codesize_hello_O3.jssize +++ b/test/other/codesize/test_codesize_hello_O3.jssize @@ -1 +1 @@ -4802 +4784 diff --git a/test/other/codesize/test_codesize_hello_Os.gzsize b/test/other/codesize/test_codesize_hello_Os.gzsize index c4fdb9ba8959b..ed5edbf7f250d 100644 --- a/test/other/codesize/test_codesize_hello_Os.gzsize +++ b/test/other/codesize/test_codesize_hello_Os.gzsize @@ -1 +1 @@ -2346 +2320 diff --git a/test/other/codesize/test_codesize_hello_Os.jssize b/test/other/codesize/test_codesize_hello_Os.jssize index 534d8e6bdcc90..1ab0d2e7606cc 100644 --- a/test/other/codesize/test_codesize_hello_Os.jssize +++ b/test/other/codesize/test_codesize_hello_Os.jssize @@ -1 +1 @@ -4802 +4784 diff --git a/test/other/codesize/test_codesize_hello_Oz.gzsize b/test/other/codesize/test_codesize_hello_Oz.gzsize index ffcd151c41f04..ec0da141bd5ab 100644 --- a/test/other/codesize/test_codesize_hello_Oz.gzsize +++ b/test/other/codesize/test_codesize_hello_Oz.gzsize @@ -1 +1 @@ -2328 +2301 diff --git a/test/other/codesize/test_codesize_hello_Oz.jssize b/test/other/codesize/test_codesize_hello_Oz.jssize index 9f4f637fcdccb..8f9d0a47aed00 100644 --- a/test/other/codesize/test_codesize_hello_Oz.jssize +++ b/test/other/codesize/test_codesize_hello_Oz.jssize @@ -1 +1 @@ -4769 +4751 diff --git a/test/other/codesize/test_codesize_hello_dylink.gzsize b/test/other/codesize/test_codesize_hello_dylink.gzsize index e88f7f6787c9d..d665f60e5a1bc 100644 --- a/test/other/codesize/test_codesize_hello_dylink.gzsize +++ b/test/other/codesize/test_codesize_hello_dylink.gzsize @@ -1 +1 @@ -6227 +6198 diff --git a/test/other/codesize/test_codesize_hello_dylink.jssize b/test/other/codesize/test_codesize_hello_dylink.jssize index a9336124ba7fb..b796f1274f259 100644 --- a/test/other/codesize/test_codesize_hello_dylink.jssize +++ b/test/other/codesize/test_codesize_hello_dylink.jssize @@ -1 +1 @@ -13729 +13710 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.gzsize b/test/other/codesize/test_codesize_hello_export_nothing.gzsize index a894381fc572f..9cc2f9d9f7d19 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.gzsize +++ b/test/other/codesize/test_codesize_hello_export_nothing.gzsize @@ -1 +1 @@ -1721 +1694 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.jssize b/test/other/codesize/test_codesize_hello_export_nothing.jssize index 1e144d1f73aa3..46aae8dca64cc 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.jssize +++ b/test/other/codesize/test_codesize_hello_export_nothing.jssize @@ -1 +1 @@ -3662 +3644 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.gzsize b/test/other/codesize/test_codesize_hello_wasmfs.gzsize index c4fdb9ba8959b..ed5edbf7f250d 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_hello_wasmfs.gzsize @@ -1 +1 @@ -2346 +2320 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.jssize b/test/other/codesize/test_codesize_hello_wasmfs.jssize index 534d8e6bdcc90..1ab0d2e7606cc 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.jssize +++ b/test/other/codesize/test_codesize_hello_wasmfs.jssize @@ -1 +1 @@ -4802 +4784 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize index e37d15a094a6b..0cee2745e0db2 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize @@ -1 +1 @@ -1920 +1896 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize index 19e6874d5c5ec..cdfa59eaeb4dc 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize @@ -1 +1 @@ -4040 +4022 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize index b22803ae9b835..fe1d264c3d0c1 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize @@ -1 +1 @@ -1957 +1934 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize index 64c1a80470aad..2332265bcdcf8 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize @@ -1 +1 @@ -4087 +4069 diff --git a/test/other/codesize/test_codesize_mem_O3.gzsize b/test/other/codesize/test_codesize_mem_O3.gzsize index 37a2cebe6b9c9..cf97139540b7d 100644 --- a/test/other/codesize/test_codesize_mem_O3.gzsize +++ b/test/other/codesize/test_codesize_mem_O3.gzsize @@ -1 +1 @@ -2380 +2354 diff --git a/test/other/codesize/test_codesize_mem_O3.jssize b/test/other/codesize/test_codesize_mem_O3.jssize index f32a182f1e944..ba0fcbee92dbe 100644 --- a/test/other/codesize/test_codesize_mem_O3.jssize +++ b/test/other/codesize/test_codesize_mem_O3.jssize @@ -1 +1 @@ -4943 +4925 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.gzsize b/test/other/codesize/test_codesize_mem_O3_grow.gzsize index 13c8e99a99bbb..ea908ff33b176 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow.gzsize @@ -1 +1 @@ -2529 +2503 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.jssize b/test/other/codesize/test_codesize_mem_O3_grow.jssize index c016a774c8a64..3333699ae3fbd 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow.jssize @@ -1 +1 @@ -5228 +5210 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize index e60a9452f5c52..cc50439680514 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize @@ -1 +1 @@ -2225 +2199 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize index b02620cff6eb4..9266adf35c9cd 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize @@ -1 +1 @@ -4636 +4618 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize index 0ed0ea4a170d1..5e7c8b88a0264 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize @@ -1 +1 @@ -2190 +2164 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_standalone.jssize index 835fe1beea0f2..d2a5225519bcd 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.jssize @@ -1 +1 @@ -4566 +4548 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize index 6e371fb2389ae..2ff4149843110 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize @@ -1 +1 @@ -1944 +1921 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize index 64c1a80470aad..2332265bcdcf8 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize @@ -1 +1 @@ -4087 +4069 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize index b22803ae9b835..fe1d264c3d0c1 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize @@ -1 +1 @@ -1957 +1934 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize index 64c1a80470aad..2332265bcdcf8 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize @@ -1 +1 @@ -4087 +4069 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize index b22803ae9b835..fe1d264c3d0c1 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize @@ -1 +1 @@ -1957 +1934 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize index 64c1a80470aad..2332265bcdcf8 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize @@ -1 +1 @@ -4087 +4069 diff --git a/test/other/codesize/test_codesize_minimal_64.gzsize b/test/other/codesize/test_codesize_minimal_64.gzsize index 3591ec6784c2f..6d3656504bfd2 100644 --- a/test/other/codesize/test_codesize_minimal_64.gzsize +++ b/test/other/codesize/test_codesize_minimal_64.gzsize @@ -1 +1 @@ -1492 +1469 diff --git a/test/other/codesize/test_codesize_minimal_64.jssize b/test/other/codesize/test_codesize_minimal_64.jssize index b2858f3749035..b345efadeb220 100644 --- a/test/other/codesize/test_codesize_minimal_64.jssize +++ b/test/other/codesize/test_codesize_minimal_64.jssize @@ -1 +1 @@ -3142 +3124 diff --git a/test/other/codesize/test_codesize_minimal_O0.gzsize b/test/other/codesize/test_codesize_minimal_O0.gzsize index bde5b49b5d9d5..72298135d0b70 100644 --- a/test/other/codesize/test_codesize_minimal_O0.gzsize +++ b/test/other/codesize/test_codesize_minimal_O0.gzsize @@ -1 +1 @@ -6567 +6555 diff --git a/test/other/codesize/test_codesize_minimal_O0.jssize b/test/other/codesize/test_codesize_minimal_O0.jssize index 17bded2757b92..3ae04fb77af32 100644 --- a/test/other/codesize/test_codesize_minimal_O0.jssize +++ b/test/other/codesize/test_codesize_minimal_O0.jssize @@ -1 +1 @@ -17513 +17586 diff --git a/test/other/codesize/test_codesize_minimal_O1.gzsize b/test/other/codesize/test_codesize_minimal_O1.gzsize index 1c631e1e4ce7e..e19b378c27520 100644 --- a/test/other/codesize/test_codesize_minimal_O1.gzsize +++ b/test/other/codesize/test_codesize_minimal_O1.gzsize @@ -1 +1 @@ -1568 +1546 diff --git a/test/other/codesize/test_codesize_minimal_O1.jssize b/test/other/codesize/test_codesize_minimal_O1.jssize index c73c83400cc5d..7f0e18ca00cc8 100644 --- a/test/other/codesize/test_codesize_minimal_O1.jssize +++ b/test/other/codesize/test_codesize_minimal_O1.jssize @@ -1 +1 @@ -3669 +3693 diff --git a/test/other/codesize/test_codesize_minimal_O2.gzsize b/test/other/codesize/test_codesize_minimal_O2.gzsize index 4e6ee1e5ffb6e..12c4d99b46c4d 100644 --- a/test/other/codesize/test_codesize_minimal_O2.gzsize +++ b/test/other/codesize/test_codesize_minimal_O2.gzsize @@ -1 +1 @@ -1421 +1398 diff --git a/test/other/codesize/test_codesize_minimal_O2.jssize b/test/other/codesize/test_codesize_minimal_O2.jssize index b36a2e0278445..1e779f31c3179 100644 --- a/test/other/codesize/test_codesize_minimal_O2.jssize +++ b/test/other/codesize/test_codesize_minimal_O2.jssize @@ -1 +1 @@ -2847 +2829 diff --git a/test/other/codesize/test_codesize_minimal_O3.gzsize b/test/other/codesize/test_codesize_minimal_O3.gzsize index 1aca63ba8cd53..a3c357ffe951c 100644 --- a/test/other/codesize/test_codesize_minimal_O3.gzsize +++ b/test/other/codesize/test_codesize_minimal_O3.gzsize @@ -1 +1 @@ -1386 +1363 diff --git a/test/other/codesize/test_codesize_minimal_O3.jssize b/test/other/codesize/test_codesize_minimal_O3.jssize index 9ddd587ee7d83..2b4ea894fb435 100644 --- a/test/other/codesize/test_codesize_minimal_O3.jssize +++ b/test/other/codesize/test_codesize_minimal_O3.jssize @@ -1 +1 @@ -2797 +2779 diff --git a/test/other/codesize/test_codesize_minimal_Os.gzsize b/test/other/codesize/test_codesize_minimal_Os.gzsize index 1aca63ba8cd53..a3c357ffe951c 100644 --- a/test/other/codesize/test_codesize_minimal_Os.gzsize +++ b/test/other/codesize/test_codesize_minimal_Os.gzsize @@ -1 +1 @@ -1386 +1363 diff --git a/test/other/codesize/test_codesize_minimal_Os.jssize b/test/other/codesize/test_codesize_minimal_Os.jssize index 9ddd587ee7d83..2b4ea894fb435 100644 --- a/test/other/codesize/test_codesize_minimal_Os.jssize +++ b/test/other/codesize/test_codesize_minimal_Os.jssize @@ -1 +1 @@ -2797 +2779 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize index 30ed602b91565..2538e3d648dd5 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize @@ -1 +1 @@ -1378 +1354 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize index baa5fd743de19..057447189685a 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize @@ -1 +1 @@ -2782 +2764 diff --git a/test/other/codesize/test_codesize_minimal_Oz.gzsize b/test/other/codesize/test_codesize_minimal_Oz.gzsize index 1aca63ba8cd53..a3c357ffe951c 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz.gzsize @@ -1 +1 @@ -1386 +1363 diff --git a/test/other/codesize/test_codesize_minimal_Oz.jssize b/test/other/codesize/test_codesize_minimal_Oz.jssize index 9ddd587ee7d83..2b4ea894fb435 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz.jssize @@ -1 +1 @@ -2797 +2779 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.gzsize b/test/other/codesize/test_codesize_minimal_pthreads.gzsize index 7223c3c378623..f3c2b2fc06522 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.gzsize +++ b/test/other/codesize/test_codesize_minimal_pthreads.gzsize @@ -1 +1 @@ -4177 +4163 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.jssize b/test/other/codesize/test_codesize_minimal_pthreads.jssize index b26b806a10c6c..a32df27cb8771 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.jssize +++ b/test/other/codesize/test_codesize_minimal_pthreads.jssize @@ -1 +1 @@ -8656 +8638 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize index 1aca63ba8cd53..a3c357ffe951c 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize @@ -1 +1 @@ -1386 +1363 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.jssize b/test/other/codesize/test_codesize_minimal_wasmfs.jssize index 9ddd587ee7d83..2b4ea894fb435 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.jssize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.jssize @@ -1 +1 @@ -2797 +2779 diff --git a/test/other/test_INCOMING_MODULE_JS_API.js.size b/test/other/test_INCOMING_MODULE_JS_API.js.size index 739a6f779a116..578e3b8be086a 100644 --- a/test/other/test_INCOMING_MODULE_JS_API.js.size +++ b/test/other/test_INCOMING_MODULE_JS_API.js.size @@ -1 +1 @@ -3851 +3780 diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index ba18cec99cb25..4afd342237c00 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -54390 +54298 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index 921d6b46a36b7..16aa1753892c1 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -29886 +29718 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index f49c2da41fbc0..d61957cf8282e 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -53186 +53094 From a8d325cb3574bf8f6dc9d27ef536cd0b78131f84 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 13 Dec 2024 12:00:19 -0800 Subject: [PATCH 062/132] Rebaseline test_small_js_flags. NFC (#23156) Also convert to `check_expected_size_in_file` which allows this test to be updated via `--rebaseline` This change shows the incremental progress we've been making on code size recently! --- test/browser/test_small_js_flags.js.size | 1 + test/common.py | 10 ++++++++++ test/test_browser.py | 4 +++- test/test_other.py | 10 ---------- 4 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 test/browser/test_small_js_flags.js.size diff --git a/test/browser/test_small_js_flags.js.size b/test/browser/test_small_js_flags.js.size new file mode 100644 index 0000000000000..950a0fae39f86 --- /dev/null +++ b/test/browser/test_small_js_flags.js.size @@ -0,0 +1 @@ +4369 diff --git a/test/common.py b/test/common.py index b6e958af77107..ecb50a93f243a 100644 --- a/test/common.py +++ b/test/common.py @@ -1537,6 +1537,16 @@ def assertBinaryEqual(self, file1, file2): self.assertEqual(read_binary(file1), read_binary(file2)) + def check_expected_size_in_file(self, desc, filename, size): + if EMTEST_REBASELINE: + create_file(filename, f'{size}\n', absolute=True) + size_slack = 0.05 + expected_size = int(read_file(filename).strip()) + delta = size - expected_size + ratio = abs(delta) / float(expected_size) + print(' seen %s size: %d (expected: %d) (delta: %d), ratio to expected: %f' % (desc, size, expected_size, delta, ratio)) + self.assertLess(ratio, size_slack) + library_cache: Dict[str, Tuple[str, object]] = {} def get_build_dir(self): diff --git a/test/test_browser.py b/test/test_browser.py index 135e69d0203b8..04d3353faf1bc 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -4204,7 +4204,9 @@ def test_small_js_flags(self): print('size:', size) # Note that this size includes test harness additions (for reporting the result, etc.). if not self.is_wasm64() and not self.is_2gb(): - self.assertLess(abs(size - 4477), 100) + self.check_expected_size_in_file('js', + test_file('browser/test_small_js_flags.js.size'), + size) # Tests that it is possible to initialize and render WebGL content in a # pthread by using OffscreenCanvas. diff --git a/test/test_other.py b/test/test_other.py index c1ec01d9177e3..940349ba6f881 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -8712,16 +8712,6 @@ def build(args): # adding --metrics should not affect code size self.assertEqual(base_size, os.path.getsize('a.out.wasm')) - def check_expected_size_in_file(self, desc, filename, size): - if common.EMTEST_REBASELINE: - create_file(filename, f'{size}\n', absolute=True) - size_slack = 0.05 - expected_size = int(read_file(filename).strip()) - delta = size - expected_size - ratio = abs(delta) / float(expected_size) - print(' seen %s size: %d (expected: %d) (delta: %d), ratio to expected: %f' % (desc, size, expected_size, delta, ratio)) - self.assertLess(ratio, size_slack) - @crossplatform def test_unoptimized_code_size(self): # We don't care too about unoptimized code size but we would like to keep it From ebd6f3c9fefde33b162d1dd6a546ddf3a01616c9 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 13 Dec 2024 14:44:23 -0800 Subject: [PATCH 063/132] Remove rint from jsmath library. NFC (#23148) We use `__builtin_rint` (which lowers to a single `f64.nearest` instruction) when compiling the musl version of `rint.c` so there there is no need to use a JS call for this case. --- system/lib/jsmath.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/system/lib/jsmath.c b/system/lib/jsmath.c index 87cbc9b3ce336..36bc9829db5e7 100644 --- a/system/lib/jsmath.c +++ b/system/lib/jsmath.c @@ -45,9 +45,3 @@ CALL_JS_2_TRIPLE(pow) CALL_JS_1_IMPL_TRIPLE(round, { return x >= 0 ? Math.floor(x + 0.5) : Math.ceil(x - 0.5); }) -CALL_JS_1_IMPL_TRIPLE(rint, { - function round(x) { - return x >= 0 ? Math.floor(x + 0.5) : Math.ceil(x - 0.5); - } - return (x - Math.floor(x) != .5) ? round(x) : round(x / 2) * 2; -}) From 0dfb071cbb9a99c1342b93f06f65f7d9f48bfb4f Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 13 Dec 2024 15:56:09 -0800 Subject: [PATCH 064/132] JS optimizer: Fix scoping issues with non-defined functions (#23159) Other than simple defined functions (function foo() {}), JS also has arrow functions and object methods. We need to be aware of those in metadce. This fixes #22968 which was an issue with an object method that enclosed a function of the same name as another toplevel function. To fix this, this PR makes us aware of such scopes, and we do not optimize functions in them. That is, we only ever optimize defined functions at the toplevel scope, and anything enclosed is considered fixed. --- .../emitDCEGraph-scopes-output.js | 23 ++ test/js_optimizer/emitDCEGraph-scopes.js | 33 ++ test/test_other.py | 1 + tools/acorn-optimizer.mjs | 324 ++++++++++-------- 4 files changed, 234 insertions(+), 147 deletions(-) create mode 100644 test/js_optimizer/emitDCEGraph-scopes-output.js create mode 100644 test/js_optimizer/emitDCEGraph-scopes.js diff --git a/test/js_optimizer/emitDCEGraph-scopes-output.js b/test/js_optimizer/emitDCEGraph-scopes-output.js new file mode 100644 index 0000000000000..28962c848bd78 --- /dev/null +++ b/test/js_optimizer/emitDCEGraph-scopes-output.js @@ -0,0 +1,23 @@ +[ + { + "name": "emcc$defun$arrowed", + "reaches": [], + "root": true + }, + { + "name": "emcc$defun$bar", + "reaches": [], + "root": true + }, + { + "name": "emcc$defun$caller", + "reaches": [ + "emcc$defun$foo" + ], + "root": true + }, + { + "name": "emcc$defun$foo", + "reaches": [] + } +] diff --git a/test/js_optimizer/emitDCEGraph-scopes.js b/test/js_optimizer/emitDCEGraph-scopes.js new file mode 100644 index 0000000000000..77fe6cc52f8fa --- /dev/null +++ b/test/js_optimizer/emitDCEGraph-scopes.js @@ -0,0 +1,33 @@ +function foo() {} + +function bar() {} + +// caller() calls foo(). There is also another function called "caller", down +// below, which should not confuse us (if it does, nothing would refer to foo, +// and instead we'd think the toplevel caller calls bar). +function caller() { + foo(); +} + +caller(); + +var object = { + method() { + function caller(data) { + bar(); + } + } +}; + +// Similar, with an arrow function. This should also not confuse us (it would +// make "caller" refer to "arrowed". + +function arrowed() {} + +var arrow = () => { + function caller(data) { + arrowed(); + } +} + +wasmImports = {}; diff --git a/test/test_other.py b/test/test_other.py index 940349ba6f881..0b827f6aad0b5 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -2896,6 +2896,7 @@ def test_extern_prepost(self): 'emitDCEGraph3': (['emitDCEGraph', '--no-print'],), 'emitDCEGraph4': (['emitDCEGraph', '--no-print'],), 'emitDCEGraph5': (['emitDCEGraph', '--no-print'],), + 'emitDCEGraph-scopes': (['emitDCEGraph', '--no-print'],), 'minimal-runtime-applyDCEGraphRemovals': (['applyDCEGraphRemovals'],), 'applyDCEGraphRemovals': (['applyDCEGraphRemovals'],), 'applyImportAndExportNameChanges': (['applyImportAndExportNameChanges'],), diff --git a/tools/acorn-optimizer.mjs b/tools/acorn-optimizer.mjs index 18e99fd93cbc4..a6932295e1f5c 100755 --- a/tools/acorn-optimizer.mjs +++ b/tools/acorn-optimizer.mjs @@ -65,9 +65,13 @@ function simpleWalk(node, cs) { } } -// Full post-order walk, calling a single function for all types. -function fullWalk(node, c) { - visitChildren(node, (child) => fullWalk(child, c)); +// Full post-order walk, calling a single function for all types. If |pre| is +// provided, it is called in pre-order (before children). +function fullWalk(node, c, pre) { + if (pre) { + pre(node); + } + visitChildren(node, (child) => fullWalk(child, c, pre)); c(node); } @@ -699,167 +703,192 @@ function emitDCEGraph(ast) { } } - fullWalk(ast, (node) => { - if (isWasmImportsAssign(node)) { - const assignedObject = getWasmImportsValue(node); - assignedObject.properties.forEach((item) => { - let value = item.value; - if (value.type === 'Literal' || value.type === 'FunctionExpression') { - return; // if it's a numeric or function literal, nothing to do here - } - if (value.type === 'LogicalExpression') { - // We may have something like wasmMemory || Module.wasmMemory in pthreads code; - // use the left hand identifier. - value = value.left; - } - assertAt(value.type === 'Identifier', value); - const nativeName = item.key.type == 'Literal' ? item.key.value : item.key.name; - assert(nativeName); - imports.push([value.name, nativeName]); - }); - foundWasmImportsAssign = true; - emptyOut(node); // ignore this in the second pass; this does not root - } else if (node.type === 'AssignmentExpression') { - const target = node.left; - // Ignore assignment to the wasmExports object (as happens in - // applySignatureConversions). - if (isExportUse(target)) { - emptyOut(node); - } - } else if (node.type === 'VariableDeclaration') { - if (node.declarations.length === 1) { - const item = node.declarations[0]; - const name = item.id.name; - const value = item.init; - if (value && isExportUse(value)) { - const asmName = getExportOrModuleUseName(value); - // this is: - // var _x = wasmExports['x']; - saveAsmExport(name, asmName); + // We track defined functions very carefully, so that we can remove them and + // the things they call, but other function scopes (like arrow functions and + // object methods) are trickier to track (object methods require knowing what + // object a function name is called on), so we do not track those. We consider + // all content inside them as top-level, which means it is used. + var specialScopes = 0; + + fullWalk( + ast, + (node) => { + if (isWasmImportsAssign(node)) { + const assignedObject = getWasmImportsValue(node); + assignedObject.properties.forEach((item) => { + let value = item.value; + if (value.type === 'Literal' || value.type === 'FunctionExpression') { + return; // if it's a numeric or function literal, nothing to do here + } + if (value.type === 'LogicalExpression') { + // We may have something like wasmMemory || Module.wasmMemory in pthreads code; + // use the left hand identifier. + value = value.left; + } + assertAt(value.type === 'Identifier', value); + const nativeName = item.key.type == 'Literal' ? item.key.value : item.key.name; + assert(nativeName); + imports.push([value.name, nativeName]); + }); + foundWasmImportsAssign = true; + emptyOut(node); // ignore this in the second pass; this does not root + } else if (node.type === 'AssignmentExpression') { + const target = node.left; + // Ignore assignment to the wasmExports object (as happens in + // applySignatureConversions). + if (isExportUse(target)) { emptyOut(node); - } else if (value && value.type === 'ArrowFunctionExpression') { - // this is - // () => (x = wasmExports['x'])(..) - // or - // () => (x = Module['_x'] = wasmExports['x'])(..) - let asmName = isExportWrapperFunction(value); - if (asmName) { + } + } else if (node.type === 'VariableDeclaration') { + if (node.declarations.length === 1) { + const item = node.declarations[0]; + const name = item.id.name; + const value = item.init; + if (value && isExportUse(value)) { + const asmName = getExportOrModuleUseName(value); + // this is: + // var _x = wasmExports['x']; saveAsmExport(name, asmName); emptyOut(node); - } - } else if (value && value.type === 'AssignmentExpression') { - const assigned = value.left; - if (isModuleUse(assigned) && getExportOrModuleUseName(assigned) === name) { + } else if (value && value.type === 'ArrowFunctionExpression') { // this is - // var x = Module['x'] = ? - // which looks like a wasm export being received. confirm with the asm use - let found = 0; - let asmName; - fullWalk(value.right, (node) => { - if (isExportUse(node)) { - found++; - asmName = getExportOrModuleUseName(node); - } - }); - // in the wasm backend, the asm name may have one fewer "_" prefixed - if (found === 1) { - // this is indeed an export - // the asmName is what the wasm provides directly; the outside JS - // name may be slightly different (extra "_" in wasm backend) + // () => (x = wasmExports['x'])(..) + // or + // () => (x = Module['_x'] = wasmExports['x'])(..) + let asmName = isExportWrapperFunction(value); + if (asmName) { saveAsmExport(name, asmName); - emptyOut(node); // ignore this in the second pass; this does not root - return; + emptyOut(node); } - if (value.right.type === 'Literal') { + } else if (value && value.type === 'AssignmentExpression') { + const assigned = value.left; + if (isModuleUse(assigned) && getExportOrModuleUseName(assigned) === name) { // this is - // var x = Module['x'] = 1234; - // this form occurs when global addresses are exported from the - // module. It doesn't constitute a usage. - assertAt(typeof value.right.value === 'number', value.right); - emptyOut(node); + // var x = Module['x'] = ? + // which looks like a wasm export being received. confirm with the asm use + let found = 0; + let asmName; + fullWalk(value.right, (node) => { + if (isExportUse(node)) { + found++; + asmName = getExportOrModuleUseName(node); + } + }); + // in the wasm backend, the asm name may have one fewer "_" prefixed + if (found === 1) { + // this is indeed an export + // the asmName is what the wasm provides directly; the outside JS + // name may be slightly different (extra "_" in wasm backend) + saveAsmExport(name, asmName); + emptyOut(node); // ignore this in the second pass; this does not root + return; + } + if (value.right.type === 'Literal') { + // this is + // var x = Module['x'] = 1234; + // this form occurs when global addresses are exported from the + // module. It doesn't constitute a usage. + assertAt(typeof value.right.value === 'number', value.right); + emptyOut(node); + } } } } - } - // A variable declaration that has no initial values can be ignored in - // the second pass, these are just declarations, not roots - an actual - // use must be found in order to root. - if (!node.declarations.reduce((hasInit, decl) => hasInit || !!decl.init, false)) { - emptyOut(node); - } - } else if (node.type === 'FunctionDeclaration') { - defuns.push(node); - const name = node.id.name; - nameToGraphName[name] = getGraphName(name, 'defun'); - emptyOut(node); // ignore this in the second pass; we scan defuns separately - } else if (node.type === 'ArrowFunctionExpression') { - // Check if this is the minimal runtime exports function, which looks like - // (output) => { var wasmExports = output.instance.exports; - if ( - node.params.length === 1 && - node.params[0].type === 'Identifier' && - node.params[0].name === 'output' && - node.body.type === 'BlockStatement' - ) { - const body = node.body.body; - if (body.length >= 1) { - const first = body[0]; - let target; - let value; // "(var?) target = value" - // Look either for var wasmExports = or just wasmExports = - if (first.type === 'VariableDeclaration' && first.declarations.length === 1) { - const decl = first.declarations[0]; - target = decl.id; - value = decl.init; - } else if ( - first.type === 'ExpressionStatement' && - first.expression.type === 'AssignmentExpression' - ) { - const assign = first.expression; - if (assign.operator === '=') { - target = assign.left; - value = assign.right; - } - } - if (target && target.type === 'Identifier' && target.name === 'wasmExports' && value) { - if ( - value.type === 'MemberExpression' && - value.object.type === 'MemberExpression' && - value.object.object.type === 'Identifier' && - value.object.object.name === 'output' && - value.object.property.type === 'Identifier' && - value.object.property.name === 'instance' && - value.property.type === 'Identifier' && - value.property.name === 'exports' + // A variable declaration that has no initial values can be ignored in + // the second pass, these are just declarations, not roots - an actual + // use must be found in order to root. + if (!node.declarations.reduce((hasInit, decl) => hasInit || !!decl.init, false)) { + emptyOut(node); + } + } else if (node.type === 'FunctionDeclaration') { + if (!specialScopes) { + defuns.push(node); + const name = node.id.name; + nameToGraphName[name] = getGraphName(name, 'defun'); + emptyOut(node); // ignore this in the second pass; we scan defuns separately + } + } else if (node.type === 'ArrowFunctionExpression') { + assert(specialScopes > 0); + specialScopes--; + // Check if this is the minimal runtime exports function, which looks like + // (output) => { var wasmExports = output.instance.exports; + if ( + node.params.length === 1 && + node.params[0].type === 'Identifier' && + node.params[0].name === 'output' && + node.body.type === 'BlockStatement' + ) { + const body = node.body.body; + if (body.length >= 1) { + const first = body[0]; + let target; + let value; // "(var?) target = value" + // Look either for var wasmExports = or just wasmExports = + if (first.type === 'VariableDeclaration' && first.declarations.length === 1) { + const decl = first.declarations[0]; + target = decl.id; + value = decl.init; + } else if ( + first.type === 'ExpressionStatement' && + first.expression.type === 'AssignmentExpression' ) { - // This looks very much like what we are looking for. - assert(!foundMinimalRuntimeExports); - for (let i = 1; i < body.length; i++) { - const item = body[i]; - if ( - item.type === 'ExpressionStatement' && - item.expression.type === 'AssignmentExpression' && - item.expression.operator === '=' && - item.expression.left.type === 'Identifier' && - item.expression.right.type === 'MemberExpression' && - item.expression.right.object.type === 'Identifier' && - item.expression.right.object.name === 'wasmExports' && - item.expression.right.property.type === 'Literal' - ) { - const name = item.expression.left.name; - const asmName = item.expression.right.property.value; - saveAsmExport(name, asmName); - emptyOut(item); // ignore all this in the second pass; this does not root + const assign = first.expression; + if (assign.operator === '=') { + target = assign.left; + value = assign.right; + } + } + if (target && target.type === 'Identifier' && target.name === 'wasmExports' && value) { + if ( + value.type === 'MemberExpression' && + value.object.type === 'MemberExpression' && + value.object.object.type === 'Identifier' && + value.object.object.name === 'output' && + value.object.property.type === 'Identifier' && + value.object.property.name === 'instance' && + value.property.type === 'Identifier' && + value.property.name === 'exports' + ) { + // This looks very much like what we are looking for. + assert(!foundMinimalRuntimeExports); + for (let i = 1; i < body.length; i++) { + const item = body[i]; + if ( + item.type === 'ExpressionStatement' && + item.expression.type === 'AssignmentExpression' && + item.expression.operator === '=' && + item.expression.left.type === 'Identifier' && + item.expression.right.type === 'MemberExpression' && + item.expression.right.object.type === 'Identifier' && + item.expression.right.object.name === 'wasmExports' && + item.expression.right.property.type === 'Literal' + ) { + const name = item.expression.left.name; + const asmName = item.expression.right.property.value; + saveAsmExport(name, asmName); + emptyOut(item); // ignore all this in the second pass; this does not root + } } + foundMinimalRuntimeExports = true; } - foundMinimalRuntimeExports = true; } } } + } else if (node.type === 'Property' && node.method) { + assert(specialScopes > 0); + specialScopes--; } - } - }); - // must find the info we need + }, + (node) => { + // Pre-walking logic. We note special scopes (see above). + if (node.type === 'ArrowFunctionExpression' || (node.type === 'Property' && node.method)) { + specialScopes++; + } + }, + ); + // Scoping must balance out. + assert(specialScopes === 0); + // We must have found the info we need. assert( foundWasmImportsAssign, 'could not find the assignment to "wasmImports". perhaps --pre-js or --post-js code moved it out of the global scope? (things like that should be done after emcc runs, as they do not need to be run through the optimizer which is the special thing about --pre-js/--post-js code)', @@ -870,6 +899,7 @@ function emitDCEGraph(ast) { saveAsmExport(exp[0], exp[1]); } } + // Second pass: everything used in the toplevel scope is rooted; // things used in defun scopes create links function getGraphName(name, what) { From 46ef8a4da2fd01685218d31fe4466a3ab0c9eaa2 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 13 Dec 2024 16:13:36 -0800 Subject: [PATCH 065/132] Remove `target_environment_may_be` helper. NFC (#23160) We already have the existing, and more widely used, `ENVIRONMENT_MAY_BE_XX` settings. --- tools/building.py | 6 +++--- tools/link.py | 14 +++++++------- tools/shared.py | 4 ---- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/tools/building.py b/tools/building.py index 1110f1dfb7bf7..d5b018d758476 100644 --- a/tools/building.py +++ b/tools/building.py @@ -572,7 +572,7 @@ def closure_compiler(filename, advanced=True, extra_closure_args=None): CLOSURE_EXTERNS += [exports_file.name] # Node.js specific externs - if shared.target_environment_may_be('node'): + if settings.ENVIRONMENT_MAY_BE_NODE: NODE_EXTERNS_BASE = path_from_root('third_party/closure-compiler/node-externs') NODE_EXTERNS = os.listdir(NODE_EXTERNS_BASE) NODE_EXTERNS = [os.path.join(NODE_EXTERNS_BASE, name) for name in NODE_EXTERNS @@ -580,13 +580,13 @@ def closure_compiler(filename, advanced=True, extra_closure_args=None): CLOSURE_EXTERNS += [path_from_root('src/closure-externs/node-externs.js')] + NODE_EXTERNS # V8/SpiderMonkey shell specific externs - if shared.target_environment_may_be('shell'): + if settings.ENVIRONMENT_MAY_BE_SHELL: V8_EXTERNS = [path_from_root('src/closure-externs/v8-externs.js')] SPIDERMONKEY_EXTERNS = [path_from_root('src/closure-externs/spidermonkey-externs.js')] CLOSURE_EXTERNS += V8_EXTERNS + SPIDERMONKEY_EXTERNS # Web environment specific externs - if shared.target_environment_may_be('web') or shared.target_environment_may_be('worker'): + if settings.ENVIRONMENT_MAY_BE_WEB or settings.ENVIRONMENT_MAY_BE_WORKER: BROWSER_EXTERNS_BASE = path_from_root('src/closure-externs/browser-externs') if os.path.isdir(BROWSER_EXTERNS_BASE): BROWSER_EXTERNS = os.listdir(BROWSER_EXTERNS_BASE) diff --git a/tools/link.py b/tools/link.py index 76b6e521bb8d4..4444f4e06146c 100644 --- a/tools/link.py +++ b/tools/link.py @@ -1440,7 +1440,7 @@ def phase_linker_setup(options, state, newargs): # noqa: C901, PLR0912, PLR0915 if 'MODULARIZE' in user_settings: exit_with_error('EXPORT_ES6 requires MODULARIZE to be set') settings.MODULARIZE = 1 - if shared.target_environment_may_be('node') and not settings.USE_ES6_IMPORT_META: + if settings.ENVIRONMENT_MAY_BE_NODE and not settings.USE_ES6_IMPORT_META: # EXPORT_ES6 + ENVIRONMENT=*node* requires the use of import.meta.url if 'USE_ES6_IMPORT_META' in user_settings: exit_with_error('EXPORT_ES6 and ENVIRONMENT=*node* requires USE_ES6_IMPORT_META to be set') @@ -1767,7 +1767,7 @@ def get_full_import_name(name): if settings.NODE_CODE_CACHING: if settings.WASM_ASYNC_COMPILATION: exit_with_error('NODE_CODE_CACHING requires sync compilation (WASM_ASYNC_COMPILATION=0)') - if not shared.target_environment_may_be('node'): + if not settings.ENVIRONMENT_MAY_BE_NODE: exit_with_error('NODE_CODE_CACHING only works in node, but target environments do not include it') if settings.SINGLE_FILE: exit_with_error('NODE_CODE_CACHING saves a file on the side and is not compatible with SINGLE_FILE') @@ -2366,11 +2366,11 @@ def phase_binaryen(target, options, wasm_target): def node_es6_imports(): - if not settings.EXPORT_ES6 or not shared.target_environment_may_be('node'): + if not settings.EXPORT_ES6 or not settings.ENVIRONMENT_MAY_BE_NODE: return '' # Multi-environment builds uses `await import` in `shell.js` - if shared.target_environment_may_be('web'): + if settings.ENVIRONMENT_MAY_BE_WEB: return '' # Use static import declaration if we only target Node.js @@ -2397,8 +2397,8 @@ def modularize(): # Multi-environment ES6 builds require an async function async_emit = '' if settings.EXPORT_ES6 and \ - shared.target_environment_may_be('node') and \ - shared.target_environment_may_be('web'): + settings.ENVIRONMENT_MAY_BE_NODE and \ + settings.ENVIRONMENT_MAY_BE_WEB: async_emit = 'async ' # TODO: Remove when https://bugs.webkit.org/show_bug.cgi?id=223533 is resolved. @@ -2446,7 +2446,7 @@ def modularize(): script_url = 'import.meta.url' else: script_url = "typeof document != 'undefined' ? document.currentScript?.src : undefined" - if shared.target_environment_may_be('node'): + if settings.ENVIRONMENT_MAY_BE_NODE: script_url_node = "if (typeof __filename != 'undefined') _scriptName = _scriptName || __filename;" if settings.MODULARIZE == 'instance': src = '''%(node_imports)s diff --git a/tools/shared.py b/tools/shared.py index b6cc824a0f020..c6eb79378495e 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -640,10 +640,6 @@ def get_temp_files(): return tempfiles.TempFiles(TEMP_DIR, save_debug_files=False) -def target_environment_may_be(environment): - return not settings.ENVIRONMENT or environment in settings.ENVIRONMENT.split(',') - - def print_compiler_stage(cmd): """Emulate the '-v/-###' flags of clang/gcc by printing the sub-commands that we run.""" From d19c16213cdc6f63400bf1a55b3c76704ba663d5 Mon Sep 17 00:00:00 2001 From: emscripten-bot <179889221+emscripten-bot@users.noreply.github.com> Date: Fri, 13 Dec 2024 18:13:54 -0800 Subject: [PATCH 066/132] Mark 3.1.74 as released (#23164) Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action --- ChangeLog.md | 5 ++++- emscripten-version.txt | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index fde29fc55de81..fb191d96b14c2 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -18,8 +18,11 @@ to browse the changes between the tags. See docs/process.md for more on how version tagging works. -3.1.74 (in development) +3.1.75 (in development) ----------------------- + +3.1.74 - 12/14/24 +----------------- - The file system was updated to independently track atime, mtime and ctime instead of using the same time for all three. (#22998) - Emscripten-generated code will now use async/await internally when loading diff --git a/emscripten-version.txt b/emscripten-version.txt index f26702764ab34..00f17b8f33993 100644 --- a/emscripten-version.txt +++ b/emscripten-version.txt @@ -1 +1 @@ -3.1.74-git +3.1.75-git From dfe3356cb1860ebf087de33f85a742e8669cce5b Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 14 Dec 2024 17:01:58 +0100 Subject: [PATCH 067/132] Enable ruff check E303 (#23155) This rule was lost in the recent switch from flake8. This change brings back that rule which is currently in preview in ruff. See https://github.com/emscripten-core/emscripten/pull/23139#discussion_r1883095264 --- .circleci/config.yml | 2 ++ pyproject.toml | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5c5844c7e8c63..61d7cb912a278 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -425,6 +425,8 @@ jobs: - checkout - pip-install - run: ruff check + # TODO (cclauss): When ruff supports rule E303 without --preview, remove following line + - run: ruff check --preview --select=E303 mypy: executor: bionic steps: diff --git a/pyproject.toml b/pyproject.toml index f4c62aacb8f16..874462532f8e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,11 +49,8 @@ lint.ignore = [ "PLW1510", "PLW2901", ] - lint.per-file-ignores."emrun.py" = [ "PLE0704" ] - lint.mccabe.max-complexity = 48 # Recommended: 10 - lint.pylint.allow-magic-value-types = [ "bytes", "float", From d0b04b9b70830184086699937b1ed150e70b8f20 Mon Sep 17 00:00:00 2001 From: jkl Date: Mon, 16 Dec 2024 10:52:16 -0600 Subject: [PATCH 068/132] Allow avxintrin.h to be used by C compiler (#22850) An internal union defined to implement 256-bit AVX support added in PR emscripten-core/emscripten#22430 is missing `union` keywords at declarations so causes errors when used with the C compiler. Add the `union` keyword to the declarations of the `m256_data` union in avxintrin.h. Also adds `__` prefix to make type `__m256_data` to avoid further polluting global namespace. --- system/include/compat/avxintrin.h | 14 +++++++------- test/test_other.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/system/include/compat/avxintrin.h b/system/include/compat/avxintrin.h index 09c9a3e8bf6a0..45171ebbe5e6e 100644 --- a/system/include/compat/avxintrin.h +++ b/system/include/compat/avxintrin.h @@ -40,7 +40,7 @@ typedef struct { __m128i_u v1; } __m256i_u; -union m256_data { +union __m256_data { __m256i int_view; __m256d double_view; __m256 float_view; @@ -1771,42 +1771,42 @@ _mm256_setzero_si256(void) { static __inline__ __m256 __attribute__((__always_inline__, __nodebug__)) _mm256_castpd_ps(__m256d __a) { - m256_data ret; + union __m256_data ret; ret.double_view = __a; return ret.float_view; } static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) _mm256_castpd_si256(__m256d __a) { - m256_data ret; + union __m256_data ret; ret.double_view = __a; return ret.int_view; } static __inline__ __m256d __attribute__((__always_inline__, __nodebug__)) _mm256_castps_pd(__m256 __a) { - m256_data ret; + union __m256_data ret; ret.float_view = __a; return ret.double_view; } static __inline__ __m256i __attribute__((__always_inline__, __nodebug__)) _mm256_castps_si256(__m256 __a) { - m256_data ret; + union __m256_data ret; ret.float_view = __a; return ret.int_view; } static __inline__ __m256 __attribute__((__always_inline__, __nodebug__)) _mm256_castsi256_ps(__m256i __a) { - m256_data ret; + union __m256_data ret; ret.int_view = __a; return ret.float_view; } static __inline__ __m256d __attribute__((__always_inline__, __nodebug__)) _mm256_castsi256_pd(__m256i __a) { - m256_data ret; + union __m256_data ret; ret.int_view = __a; return ret.double_view; } diff --git a/test/test_other.py b/test/test_other.py index 0b827f6aad0b5..316680d541aa2 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -9475,7 +9475,7 @@ def test_standalone_system_headers(self): 'wire.h', 'val.h', 'bind.h', 'webgpu_cpp.h', 'webgpu_cpp_chained_struct.h', 'webgpu_enum_class_bitmasks.h', # Some headers are not yet C compatible - 'arm_neon.h', 'avxintrin.h', 'immintrin.h', + 'arm_neon.h', ] if directory and directory != 'compat': header = f'{directory}/{header}' From 0c3c07f2829f4165c2619ac3dbc7fa19b6c0daa6 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 16 Dec 2024 10:14:22 -0800 Subject: [PATCH 069/132] Unify code for setting up nodefs tests. NFC (#23167) --- test/common.py | 4 +++ test/fs/test_fs_rename_on_existing.c | 37 ++++---------------- test/fs/test_fs_symlink_resolution.c | 8 ----- test/fs/test_mmap.c | 42 ++++++++++------------- test/fs/test_mmap.out | 10 +++--- test/fs/test_nodefs_cloexec.c | 27 ++++----------- test/fs/test_nodefs_dup.c | 50 ++++++++++++---------------- test/fs/test_nodefs_rw.c | 21 ++---------- test/other/alias/main.c | 44 +++++++++++------------- test/setup_nodefs.js | 6 ++++ test/stdio/test_fgetc_ungetc.c | 15 ++------- test/test_core.py | 43 +++++++++++++----------- test/test_other.py | 15 ++++----- test/unistd/access.c | 5 --- test/unistd/misc.c | 10 ++---- test/unistd/truncate.c | 26 --------------- test/unistd/unlink.c | 12 ++----- 17 files changed, 127 insertions(+), 248 deletions(-) create mode 100644 test/setup_nodefs.js diff --git a/test/common.py b/test/common.py index ecb50a93f243a..8ff05424e146f 100644 --- a/test/common.py +++ b/test/common.py @@ -1023,6 +1023,10 @@ def require_wasm2js(self): if self.is_2gb() or self.is_4gb(): self.skipTest('wasm2js does not support over 2gb of memory') + def setup_nodefs_test(self): + self.require_node() + self.emcc_args += ['-lnodefs.js', '--pre-js', test_file('setup_nodefs.js')] + def setup_node_pthreads(self): self.require_node() self.emcc_args += ['-Wno-pthreads-mem-growth', '-pthread'] diff --git a/test/fs/test_fs_rename_on_existing.c b/test/fs/test_fs_rename_on_existing.c index 8c32bc3ed1b49..c6113f87dcc69 100644 --- a/test/fs/test_fs_rename_on_existing.c +++ b/test/fs/test_fs_rename_on_existing.c @@ -8,21 +8,6 @@ #include #include - -#if defined(__EMSCRIPTEN__) -#include -#endif - -void makedir(const char *dir) { - int rtn = mkdir(dir, 0777); - assert(rtn == 0); -} - -void changedir(const char *dir) { - int rtn = chdir(dir); - assert(rtn == 0); -} - static void create_file(const char *path, const char *buffer) { printf("creating: %s\n", path); int fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0666); @@ -35,21 +20,11 @@ static void create_file(const char *path, const char *buffer) { close(fd); } - -void setup() { -#if defined(__EMSCRIPTEN__) && defined(NODEFS) - makedir("working"); - EM_ASM(FS.mount(NODEFS, { root: '.' }, 'working')); - changedir("working"); -#endif -} - int main() { - setup(); - create_file("a", "abc"); - create_file("b", "xyz"); - assert(rename("a", "b") == 0); - assert(unlink("b") == 0); - create_file("b", "xyz"); - printf("success\n"); + create_file("a", "abc"); + create_file("b", "xyz"); + assert(rename("a", "b") == 0); + assert(unlink("b") == 0); + create_file("b", "xyz"); + printf("success\n"); } diff --git a/test/fs/test_fs_symlink_resolution.c b/test/fs/test_fs_symlink_resolution.c index 1c6d88c63a6ec..9ef6756652234 100644 --- a/test/fs/test_fs_symlink_resolution.c +++ b/test/fs/test_fs_symlink_resolution.c @@ -6,9 +6,6 @@ #include #include #include -#if defined(__EMSCRIPTEN__) -#include "emscripten.h" -#endif void makedir(const char *dir) { int rtn = mkdir(dir, 0777); @@ -29,11 +26,6 @@ static void create_file(const char *path) { } void setup() { -#if defined(__EMSCRIPTEN__) && defined(NODEFS) - makedir("working"); - EM_ASM(FS.mount(NODEFS, { root: '.' }, 'working')); - changedir("working"); -#endif makedir("a"); makedir("b"); makedir("b/c"); diff --git a/test/fs/test_mmap.c b/test/fs/test_mmap.c index 5d3927d8a4fd6..1968485fda19e 100644 --- a/test/fs/test_mmap.c +++ b/test/fs/test_mmap.c @@ -19,16 +19,16 @@ void test_mmap_read() { // Use mmap to read in.txt - EM_ASM(FS.writeFile('yolo/in.txt', 'mmap ftw!')); + EM_ASM(FS.writeFile('in.txt', 'mmap ftw!')); - int fd = open("yolo/in.txt", O_RDONLY); + int fd = open("in.txt", O_RDONLY); assert(fd >= 0); int filesize = 9; char* map = (char*)mmap(NULL, filesize, PROT_READ, MAP_PRIVATE, fd, 0); assert(map != MAP_FAILED); - printf("yolo/in.txt content="); + printf("in.txt content="); for (int i = 0; i < filesize; i++) { printf("%c", map[i]); } @@ -42,7 +42,7 @@ void test_mmap_read() { void test_mmap_write() { // Use mmap to write out.txt - int fd = open("yolo/out.txt", O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600); + int fd = open("out.txt", O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600); assert(fd >= 0); const char* text = "written mmap"; @@ -64,12 +64,12 @@ void test_mmap_write() { close(fd); { - FILE* fd = fopen("yolo/out.txt", "r"); + FILE* fd = fopen("out.txt", "r"); assert(fd >= 0); char buffer[15]; memset(buffer, 0, 15); fread(buffer, 1, 14, fd); - printf("yolo/out.txt content=%s\n", buffer); + printf("out.txt content=%s\n", buffer); fclose(fd); } } @@ -79,7 +79,7 @@ void test_mmap_readonly() { // but make sure it's not overwritten on munmap const char* readonlytext = "readonly mmap\0"; const char* text = "write mmap\0"; - const char* path = "yolo/outreadonly.txt"; + const char* path = "outreadonly.txt"; size_t readonlytextsize = strlen(readonlytext); size_t textsize = strlen(text); @@ -102,18 +102,18 @@ void test_mmap_readonly() { close(fd); { - FILE* fd = fopen("yolo/outreadonly.txt", "r"); + FILE* fd = fopen("outreadonly.txt", "r"); assert(fd >= 0); char buffer[16]; memset(buffer, 0, 16); fread(buffer, 1, 15, fd); - printf("yolo/outreadonly.txt content=%s\n", buffer); + printf("outreadonly.txt content=%s\n", buffer); fclose(fd); } } void test_mmap_private() { - int fd = open("yolo/private.txt", O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600); + int fd = open("private.txt", O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600); assert(fd >= 0); const char* text = "written mmap"; @@ -135,18 +135,18 @@ void test_mmap_private() { close(fd); { - FILE* fd = fopen("yolo/private.txt", "r"); + FILE* fd = fopen("private.txt", "r"); assert(fd >= 0); char buffer[15]; memset(buffer, 0, 15); fread(buffer, 1, 14, fd); - printf("yolo/private.txt content=%s\n", buffer); + printf("private.txt content=%s\n", buffer); fclose(fd); } } void test_mmap_shared_with_offset() { - int fd = open("yolo/sharedoffset.txt", O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600); + int fd = open("sharedoffset.txt", O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600); assert(fd > 0); const char* text = "written shared mmap with offset"; @@ -176,7 +176,7 @@ void test_mmap_shared_with_offset() { close(fd); { - FILE* fd = fopen("yolo/sharedoffset.txt", "r"); + FILE* fd = fopen("sharedoffset.txt", "r"); assert(fd >= 0); size_t offset = sysconf(_SC_PAGE_SIZE) * 2; @@ -185,14 +185,14 @@ void test_mmap_shared_with_offset() { fseek(fd, offset, SEEK_SET); fread(buffer, 1, 32, fd); // expect text written from mmap operation to appear at offset in the file - printf("yolo/sharedoffset.txt content=%s %zu\n", buffer, offset); + printf("sharedoffset.txt content=%s %zu\n", buffer, offset); fclose(fd); } } void test_mmap_hint() { // mmap with a address is expected to fail - int fd = open("yolo/private.txt", O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600); + int fd = open("private.txt", O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600); assert(fd != -1); size_t map_size = 1 << 16; @@ -225,7 +225,7 @@ void test_mmap_hint() { */ void test_mmap_overallocate() { #if !defined(NODEFS) && !defined(NODERAWFS) && !defined(WASMFS) - int fd = open("yolo/overallocatedfile.txt", O_RDWR | O_CREAT, (mode_t)0600); + int fd = open("overallocatedfile.txt", O_RDWR | O_CREAT, (mode_t)0600); assert(fd != -1); const size_t textsize = 33; @@ -236,7 +236,7 @@ void test_mmap_overallocate() { } EM_ASM({ - const stream = FS.streams.find(stream => stream.path.indexOf('yolo/overallocatedfile.txt') >= 0); + const stream = FS.streams.find(stream => stream.path.indexOf('overallocatedfile.txt') >= 0); assert(stream.node.usedBytes === Number($0), 'Used bytes on the over-allocated file (' + stream.node.usedBytes + ') ' + 'should be ' + $0 @@ -264,12 +264,6 @@ void test_mmap_overallocate() { } int main() { - EM_ASM( - FS.mkdir('yolo'); -#if NODEFS - FS.mount(NODEFS, { root: '.' }, 'yolo'); -#endif - ); test_mmap_read(); test_mmap_write(); test_mmap_readonly(); diff --git a/test/fs/test_mmap.out b/test/fs/test_mmap.out index ee49ac9d3f560..b5da67362363d 100644 --- a/test/fs/test_mmap.out +++ b/test/fs/test_mmap.out @@ -1,5 +1,5 @@ -yolo/in.txt content=mmap ftw! -yolo/out.txt content=written mmap -yolo/outreadonly.txt content=readonly mmap -yolo/private.txt content= -yolo/sharedoffset.txt content=written shared mmap with offset 131072 +in.txt content=mmap ftw! +out.txt content=written mmap +outreadonly.txt content=readonly mmap +private.txt content= +sharedoffset.txt content=written shared mmap with offset 131072 diff --git a/test/fs/test_nodefs_cloexec.c b/test/fs/test_nodefs_cloexec.c index 45f7ff62936cf..e4a969e7f5eb8 100644 --- a/test/fs/test_nodefs_cloexec.c +++ b/test/fs/test_nodefs_cloexec.c @@ -11,24 +11,11 @@ #include #include -#ifdef NODERAWFS -#define CWD "" -#else -#define CWD "/working/" -#endif - -int main(void) -{ - EM_ASM( -#ifdef NODERAWFS - FS.close(FS.open('test.txt', 'w')); -#else - FS.mkdir('/working'); - FS.mount(NODEFS, {root: '.'}, '/working'); - FS.close(FS.open('/working/test.txt', 'w')); -#endif - ); - assert(open(CWD "test.txt", O_RDONLY | O_CLOEXEC) != -1); - printf("success\n"); - return 0; +int main(void) { + EM_ASM( + FS.close(FS.open('test.txt', 'w')); + ); + assert(open("test.txt", O_RDONLY | O_CLOEXEC) != -1); + printf("success\n"); + return 0; } diff --git a/test/fs/test_nodefs_dup.c b/test/fs/test_nodefs_dup.c index abf34935b11c3..f21cc8e43ba9f 100644 --- a/test/fs/test_nodefs_dup.c +++ b/test/fs/test_nodefs_dup.c @@ -11,35 +11,27 @@ #include #include -#ifdef NODERAWFS -#define CWD "" -#else -#define CWD "/working/" -#endif +int main(void) { + EM_ASM( + FS.close(FS.open('test.txt', 'w')); + ); -int main(void) -{ - EM_ASM( -#ifdef NODERAWFS - FS.close(FS.open('test.txt', 'w')); -#else - FS.mkdir('/working'); - FS.mount(NODEFS, {root: '.'}, '/working'); - FS.close(FS.open('/working/test.txt', 'w')); -#endif - ); - int fd1 = open(CWD "test.txt", O_WRONLY); - int fd2 = dup(fd1); - int fd3 = fcntl(fd1, F_DUPFD_CLOEXEC, 0); + int fd = open("test.txt", O_CREAT, 0444); + assert(fd > 0); + close(fd); - assert(fd1 == 3); - assert(fd2 == 4); - assert(fd3 == 5); - assert(close(fd1) == 0); - assert(write(fd2, "abcdef", 6) == 6); - assert(close(fd2) == 0); - assert(write(fd3, "ghijkl", 6) == 6); - assert(close(fd3) == 0); - printf("success\n"); - return 0; + int fd1 = open("test.txt", O_WRONLY); + int fd2 = dup(fd1); + int fd3 = fcntl(fd1, F_DUPFD_CLOEXEC, 0); + + assert(fd1 == 3); + assert(fd2 == 4); + assert(fd3 == 5); + assert(close(fd1) == 0); + assert(write(fd2, "abcdef", 6) == 6); + assert(close(fd2) == 0); + assert(write(fd3, "ghijkl", 6) == 6); + assert(close(fd3) == 0); + printf("success\n"); + return 0; } diff --git a/test/fs/test_nodefs_rw.c b/test/fs/test_nodefs_rw.c index e6221fec1a15d..48cebcba932ff 100644 --- a/test/fs/test_nodefs_rw.c +++ b/test/fs/test_nodefs_rw.c @@ -11,12 +11,6 @@ #include #include -#ifdef NODERAWFS -#define CWD "" -#else -#define CWD "/working/" -#endif - int main() { FILE *file; int res; @@ -28,17 +22,8 @@ int main() { fs.writeFileSync('foobar.txt', 'yeehaw'); ); -#ifndef NODERAWFS - // mount the current folder as a NODEFS instance - // inside of emscripten - EM_ASM( - FS.mkdir('/working'); - FS.mount(NODEFS, { root: '.' }, '/working'); - ); -#endif - // read and validate the contents of the file - file = fopen(CWD "foobar.txt", "r"); + file = fopen("foobar.txt", "r"); assert(file); res = fread(buffer, sizeof(char), 6, file); assert(res == 6); @@ -49,7 +34,7 @@ int main() { assert(!strcmp(buffer, "yeehaw")); // write out something new - file = fopen(CWD "foobar.txt", "w"); + file = fopen("foobar.txt", "w"); assert(file); res = fwrite("cheez", sizeof(char), 5, file); assert(res == 5); @@ -62,7 +47,7 @@ int main() { assert(contents === 'cheez'); ); - file = fopen(CWD "csfsq", "r"); + file = fopen("csfsq", "r"); assert(file == NULL); assert(errno == ENOENT); diff --git a/test/other/alias/main.c b/test/other/alias/main.c index ff59a398f2d6a..958767b4464e4 100644 --- a/test/other/alias/main.c +++ b/test/other/alias/main.c @@ -10,33 +10,29 @@ #include int bar(void) { - return 42; + return 42; } int foo(void) __attribute__((alias("bar"))); -int main() -{ - EM_ASM({ - FS.mkdir('/working'); - FS.mount(NODEFS, { root: '.' }, '/working'); - }); - void *handle = dlopen("/working/side.wasm", RTLD_NOW); - if (!handle) { - printf("dlopen failed: %s", dlerror()); - return 1; - } +int main() { + void *handle = dlopen("side.wasm", RTLD_NOW); + if (!handle) { + printf("dlopen failed: %s", dlerror()); + return 1; + } - typedef int (*func_type)(void); - func_type exportedfn = (func_type)dlsym(handle, "callAlias"); - if (!exportedfn) { - const char *err = dlerror(); - printf("ERROR: dlsym failed: for callAlias: %s", err); - return 1; - } - if (exportedfn() != 42) - return 1; - dlclose(handle); - printf("success\n"); - return 0; + typedef int (*func_type)(void); + func_type exportedfn = (func_type)dlsym(handle, "callAlias"); + if (!exportedfn) { + const char *err = dlerror(); + printf("ERROR: dlsym failed: for callAlias: %s", err); + return 1; + } + if (exportedfn() != 42) { + return 1; + } + dlclose(handle); + printf("success\n"); + return 0; } diff --git a/test/setup_nodefs.js b/test/setup_nodefs.js new file mode 100644 index 0000000000000..5d1c38dd7898c --- /dev/null +++ b/test/setup_nodefs.js @@ -0,0 +1,6 @@ +Module['onRuntimeInitialized'] = () => { + out('mounting node filesystem under /nodefs'); + FS.mkdir('/nodefs'); + FS.mount(NODEFS, { root: '.' }, '/nodefs'); + FS.chdir('/nodefs'); +}; diff --git a/test/stdio/test_fgetc_ungetc.c b/test/stdio/test_fgetc_ungetc.c index afa90bcda67a5..e67087e416fb6 100644 --- a/test/stdio/test_fgetc_ungetc.c +++ b/test/stdio/test_fgetc_ungetc.c @@ -12,10 +12,6 @@ #include #include -#ifdef __EMSCRIPTEN__ -#include -#endif - static void create_file(const char *path, const char *buffer, int mode) { int fd = open(path, O_WRONLY | O_CREAT | O_EXCL, mode); assert(fd >= 0); @@ -27,7 +23,7 @@ static void create_file(const char *path, const char *buffer, int mode) { } void setup() { - create_file("/tmp/file.txt", "cd", 0666); + create_file("file.txt", "cd", 0666); } void test() { @@ -35,7 +31,7 @@ void test() { int err; char buffer[256]; - file = fopen("/tmp/file.txt", "r"); + file = fopen("file.txt", "r"); assert(file); // pushing EOF always returns EOF @@ -88,13 +84,6 @@ void test() { } int main() { -#ifdef __EMSCRIPTEN__ -#ifdef NODEFS - EM_ASM(FS.mount(NODEFS, { root: '.' }, '/tmp')); -#elif MEMFS - EM_ASM(FS.mount(MEMFS, {}, '/tmp')); -#endif -#endif setup(); test(); return 0; diff --git a/test/test_core.py b/test/test_core.py index d3fff94c5a8ec..6685b5a89918a 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -4920,7 +4920,7 @@ def test_dylink_hyper_dupe(self): @requires_node def test_dylink_load_compiled_side_module(self): self.set_setting('FORCE_FILESYSTEM') - self.emcc_args.append('-lnodefs.js') + self.setup_nodefs_test() if not self.has_changed_setting('INITIAL_MEMORY'): self.set_setting('INITIAL_MEMORY', '64mb') # This test loads the module at runtime with loadWebAssemblyModule so we @@ -4934,9 +4934,7 @@ def test_dylink_load_compiled_side_module(self): extern int sidef(); int main() { EM_ASM({ - FS.mkdir('/working'); - FS.mount(NODEFS, { root: '.' }, '/working'); - var libData = FS.readFile('/working/liblib.so', {encoding: 'binary'}); + var libData = FS.readFile('liblib.so', {encoding: 'binary'}); if (!(libData instanceof Uint8Array)) { libData = new Uint8Array(libData); } @@ -4950,8 +4948,7 @@ def test_dylink_load_compiled_side_module(self): side=r''' #include int sidef() { return 10; } - ''', - expected=['sidef: 10']) + ''', expected=['sidef: 10']) @needs_dylink def test_dylink_dso_needed(self): @@ -5417,8 +5414,7 @@ def test_fgetc_ungetc(self, fs): print('TODO: update this test once the musl ungetc-on-EOF-stream bug is fixed upstream and reaches us') self.emcc_args += ['-D' + fs] if fs == 'NODEFS': - self.require_node() - self.emcc_args += ['-lnodefs.js'] + self.setup_nodefs_test() self.do_runf('stdio/test_fgetc_ungetc.c', 'success') def test_fgetc_unsigned(self): @@ -5680,7 +5676,8 @@ def test_fs_base(self): @is_slow_test @requires_node def test_fs_nodefs_rw(self): - self.emcc_args += ['-lnodefs.js'] + if not self.get_setting('NODERAWFS'): + self.setup_nodefs_test() self.set_setting('SYSCALL_DEBUG') self.do_runf('fs/test_nodefs_rw.c', 'success') if self.maybe_closure(): @@ -5691,7 +5688,8 @@ def test_fs_nodefs_rw(self): def test_fs_nodefs_cloexec(self): if self.get_setting('WASMFS'): self.set_setting('FORCE_FILESYSTEM') - self.emcc_args += ['-lnodefs.js'] + if not self.get_setting('NODERAWFS'): + self.setup_nodefs_test() self.do_runf('fs/test_nodefs_cloexec.c', 'success') @also_with_noderawfs @@ -5699,7 +5697,8 @@ def test_fs_nodefs_cloexec(self): def test_fs_nodefs_dup(self): if self.get_setting('WASMFS'): self.set_setting('FORCE_FILESYSTEM') - self.emcc_args += ['-lnodefs.js'] + if not self.get_setting('NODERAWFS'): + self.setup_nodefs_test() self.do_runf('fs/test_nodefs_dup.c', 'success') @requires_node @@ -5789,15 +5788,14 @@ def test_fs_append(self): self.do_runf('fs/test_append.c', 'success') @parameterized({ - 'memfs': ['MEMFS'], + '': ['MEMFS'], 'nodefs': ['NODEFS'], 'noderaswfs': ['NODERAWFS'], 'wasmfs': ['WASMFS'] }) def test_fs_mmap(self, fs): if fs == 'NODEFS': - self.require_node() - self.emcc_args += ['-lnodefs.js'] + self.setup_nodefs_test() if fs == 'NODERAWFS': self.require_node() self.emcc_args += ['-lnodefs.js', '-lnoderawfs.js'] @@ -5888,6 +5886,8 @@ def test_fs_symlink_resolution(self, args): if nodefs: self.skipTest('NODEFS in WasmFS') self.set_setting('FORCE_FILESYSTEM') + if '-DNODEFS' in args: + self.setup_nodefs_test() self.do_runf('fs/test_fs_symlink_resolution.c', 'success', emcc_args=args) @parameterized({ @@ -5898,12 +5898,13 @@ def test_fs_symlink_resolution(self, args): def test_fs_rename_on_existing(self, args): if self.get_setting('WASMFS'): self.set_setting('FORCE_FILESYSTEM') + if '-DNODEFS' in args: + self.setup_nodefs_test() self.do_runf('fs/test_fs_rename_on_existing.c', 'success', emcc_args=args) def test_sigalrm(self): self.do_runf('test_sigalrm.c', 'Received alarm!') - self.set_setting('EXIT_RUNTIME') - self.do_runf('test_sigalrm.c', 'Received alarm!') + self.do_runf('test_sigalrm.c', 'Received alarm!', emcc_args=['-sEXIT_RUNTIME']) def test_signals(self): self.do_core_test('test_signals.c') @@ -5938,6 +5939,8 @@ def test_unistd_access(self, args): if nodefs: self.skipTest('NODEFS in WasmFS') self.emcc_args += ['-sFORCE_FILESYSTEM'] + if '-DNODEFS' in args: + self.setup_nodefs_test() # On windows we have slighly different output because we the same # level of permissions are not available. For example, on windows # its not possible have a file that is not readable, but writable. @@ -5982,8 +5985,7 @@ def test_unistd_truncate(self, fs): self.skipTest('TODO: NODEFS in WasmFS') self.emcc_args += ['-sFORCE_FILESYSTEM'] if fs == 'NODEFS': - self.emcc_args += ['-lnodefs.js'] - self.require_node() + self.setup_nodefs_test() self.do_run_in_out_file_test('unistd/truncate.c') @no_windows("Windows throws EPERM rather than EACCES or EINVAL") @@ -6047,6 +6049,8 @@ def test_unistd_unlink(self, fs): # 0 if root user if os.geteuid() == 0: self.emcc_args += ['-DSKIP_ACCESS_TESTS'] + if fs == 'NODEFS': + self.setup_nodefs_test() self.do_runf('unistd/unlink.c', 'success') @@ -6107,8 +6111,7 @@ def test_unistd_io(self): def test_unistd_misc(self, fs): self.emcc_args += ['-D' + fs] if fs == 'NODEFS': - self.require_node() - self.emcc_args += ['-lnodefs.js'] + self.setup_nodefs_test() self.do_run_in_out_file_test('unistd/misc.c', interleaved_output=False) @also_with_standalone_wasm() diff --git a/test/test_other.py b/test/test_other.py index 316680d541aa2..8343a3d02f0c0 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -9015,7 +9015,7 @@ def test_export_aliasee(self): self.run_process(cmd) # build main module - args = ['-g', '-sEXPORTED_FUNCTIONS=_main,_foo', '-sMAIN_MODULE=2', '-lnodefs.js'] + args = ['-g', '-sEXPORTED_FUNCTIONS=_main,_foo', '-sMAIN_MODULE=2', '-sNODERAWFS'] cmd = [EMCC, test_file('other/alias/main.c'), '-o', 'main.js'] + args print(' '.join(cmd)) self.run_process(cmd) @@ -14783,10 +14783,8 @@ def test_windows_nodefs_execution_permission(self): void setup() { EM_ASM( - FS.mkdir('/working'); - FS.mount(NODEFS, { root: '.' }, '/working'); - FS.mkdir('/working/new-dir'); - FS.writeFile('/working/new-dir/test.txt', 'test'); + FS.mkdir('new-dir'); + FS.writeFile('new-dir/test.txt', 'test'); ); } @@ -14794,13 +14792,13 @@ def test_windows_nodefs_execution_permission(self): int err; struct stat s; memset(&s, 0, sizeof(s)); - err = stat("/working/new-dir", &s); + err = stat("new-dir", &s); assert(S_ISDIR(s.st_mode)); assert(s.st_mode & S_IXUSR); assert(s.st_mode & S_IXGRP); assert(s.st_mode & S_IXOTH); - err = stat("/working/new-dir/test.txt", &s); + err = stat("new-dir/test.txt", &s); assert(s.st_mode & S_IXUSR); assert(s.st_mode & S_IXGRP); assert(s.st_mode & S_IXOTH); @@ -14814,7 +14812,8 @@ def test_windows_nodefs_execution_permission(self): return EXIT_SUCCESS; } ''' - self.do_run(src, emcc_args=['-lnodefs.js']) + self.setup_nodefs_test() + self.do_run(src) @parameterized({ 'wasm2js': (True,), diff --git a/test/unistd/access.c b/test/unistd/access.c index c125c919a892f..ca0d16ad82130 100644 --- a/test/unistd/access.c +++ b/test/unistd/access.c @@ -16,11 +16,6 @@ int main() { EM_ASM( - FS.mkdir('working'); -#if NODEFS - FS.mount(NODEFS, { root: '.' }, 'working'); -#endif - FS.chdir('working'); FS.writeFile('forbidden', ""); FS.chmod('forbidden', 0o000); FS.writeFile('readable', ""); FS.chmod('readable', 0o444); FS.writeFile('writeable', ""); FS.chmod('writeable', 0o222); diff --git a/test/unistd/misc.c b/test/unistd/misc.c index 0964e4739a2a7..76c35c1776a84 100644 --- a/test/unistd/misc.c +++ b/test/unistd/misc.c @@ -12,15 +12,11 @@ #include #include #include -#include +#include + int main() { - EM_ASM( - FS.mkdir('working'); -#if NODEFS - FS.mount(NODEFS, { root: '.' }, 'working'); -#endif - ); + mkdir("working", 0777); int f = open("working", O_RDONLY); assert(f); diff --git a/test/unistd/truncate.c b/test/unistd/truncate.c index 4aa53f609ed02..af9b0d698deef 100644 --- a/test/unistd/truncate.c +++ b/test/unistd/truncate.c @@ -11,23 +11,8 @@ #include #include #include -#ifdef __EMSCRIPTEN__ -#include -#endif void setup() { -#ifdef __EMSCRIPTEN__ - EM_ASM( - FS.mkdir('working'); -#if NODEFS - FS.mount(NODEFS, { root: '.' }, 'working'); -#endif - FS.chdir('working'); - FS.writeFile('towrite', 'abcdef'); - FS.writeFile('toread', 'abcdef'); - FS.chmod('toread', 0o444); - ); -#else FILE* f = fopen("towrite", "w"); fwrite("abcdef", 6, 1, f); fclose(f); @@ -36,7 +21,6 @@ void setup() { fclose(f); chmod("toread", 0444); -#endif } int main() { @@ -118,15 +102,5 @@ int main() { memset(&s, 0, sizeof s); errno = 0; -#ifdef __EMSCRIPTEN__ - // Restore full permissions on all created files so that python test runner rmtree - // won't have problems on deleting the files. On Windows, calling shutil.rmtree() - // will fail if any of the files are read-only. - EM_ASM( - FS.chmod('toread', 0o777); - ); -#else - chmod("toread", 0777); -#endif return 0; } diff --git a/test/unistd/unlink.c b/test/unistd/unlink.c index c7cdb23f67fc2..09a22f07ff3da 100644 --- a/test/unistd/unlink.c +++ b/test/unistd/unlink.c @@ -13,9 +13,6 @@ #include #include #include -#ifdef __EMSCRIPTEN__ -#include -#endif static void create_file(const char *path, const char *buffer, int mode) { printf("creating: %s\n", path); @@ -30,13 +27,6 @@ static void create_file(const char *path, const char *buffer, int mode) { void setup() { mkdir("working", 0777); -#ifdef __EMSCRIPTEN__ - EM_ASM( -#if NODEFS - FS.mount(NODEFS, { root: '.' }, 'working'); -#endif - ); -#endif chdir("working"); create_file("file", "test", 0777); create_file("file1", "test", 0777); @@ -148,8 +138,10 @@ void test() { // WASMFS behaviour will match the native FS. #ifndef __APPLE__ getcwd(buffer, sizeof(buffer)); + printf("CWD: %s\n", buffer); err = rmdir(buffer); assert(err == -1); + printf("rmdir: %s\n", strerror(errno)); #if defined(NODERAWFS) || defined(WASMFS) assert(errno == ENOTEMPTY); #else From a9108f89b5d2bb1b0a219b7a2a167271a287cf32 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 16 Dec 2024 19:52:12 +0100 Subject: [PATCH 070/132] Use assert in test_unlink.cpp NFC (#23174) This is shorter and the failures give more information. --- test/other/test_unlink.cpp | 77 ++++++++++---------------------------- 1 file changed, 20 insertions(+), 57 deletions(-) diff --git a/test/other/test_unlink.cpp b/test/other/test_unlink.cpp index 0cf778df952a4..bafbbc3758e98 100644 --- a/test/other/test_unlink.cpp +++ b/test/other/test_unlink.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #ifdef WASMFS #include "../wasmfs/get_backend.h" @@ -31,72 +32,42 @@ int main() { // Create a file int fd = open(filename, O_RDWR | O_CREAT, 0777); - if (fd == -1) { - return 1; - } + assert(fd != -1); // Check it exists - if (access(filename, F_OK) != 0) { - return 1; - } + assert(access(filename, F_OK) == 0); // Delete the file - if (unlinkat(AT_FDCWD, filename, 0)) { - return 1; - } + assert(unlinkat(AT_FDCWD, filename, 0) == 0); // Check that it doesn't exist - if (access(filename, F_OK) != -1) { - return 1; - } + assert(access(filename, F_OK) == -1); // Check that we can still write to it - if (write(fd, "hello", 5) != 5) { - return 1; - } + assert(write(fd, "hello", 5) == 5); // And seek in it. - if (lseek(fd, 0, SEEK_SET) != 0) { - return 1; - } + assert(lseek(fd, 0, SEEK_SET) == 0); // And read from it. char buf[6] = {0}; auto r = read(fd, buf, 5); - if (r != 5) { - return 1; - } - if (strcmp("hello", buf) != 0) { - return 1; - } - if (close(fd)) { - return 1; - } + assert(r==5); + assert(strcmp("hello", buf) == 0); + assert(close(fd)==0); // Create a directory - if (mkdir(dirname, 0700) != 0) { - return 1; - } + assert(mkdir(dirname, 0700) == 0); // Open the directory DIR* d = opendir(dirname); - if (d == NULL) { - return 1; - } + assert(d != NULL); // Delete the directory - if (unlinkat(AT_FDCWD, dirname, AT_REMOVEDIR)) { - return 1; - } + assert(unlinkat(AT_FDCWD, dirname, AT_REMOVEDIR) == 0); // Check that it doesn't exist - if (access(dirname, F_OK) != -1) { - return 1; - } + assert(access(dirname, F_OK) == -1); // The rest of this test does not yet pass with the node backend! #ifndef WASMFS_NODE_BACKEND // Check that we can still read the directory, but that it is empty. errno = 0; - if (readdir(d) != NULL || errno != 0) { - return 1; - } + assert(readdir(d) == NULL && errno == 0); // Check that we *cannot* create a child. - if (openat(dirfd(d), filename, O_CREAT | O_WRONLY, S_IRWXU) != -1) { - return 1; - } + assert(openat(dirfd(d), filename, O_CREAT | O_WRONLY, S_IRWXU) == -1); printf("%s\n", strerror(errno)); #ifdef __EMSCRIPTEN__ // Linux allows "." and ".." to be accessed on unlinked directories, but this @@ -105,27 +76,19 @@ int main() { // TODO: Consider supporting "." on unlinked files, if not ".." // Check that we cannot still access "." - if (openat(dirfd(d), ".", O_DIRECTORY | O_RDONLY) != -1) { - return 1; - } + assert(openat(dirfd(d), ".", O_DIRECTORY | O_RDONLY) == -1); #ifdef WASMFS // Check that we cannot still access ".." on WasmFS. - if (openat(dirfd(d), "..", O_DIRECTORY | O_RDONLY) != -1) { - return 1; - } + assert(openat(dirfd(d), "..", O_DIRECTORY | O_RDONLY) == -1); #endif #else // Check that we can still access "." on Linux. int self = openat(dirfd(d), ".", O_DIRECTORY | O_RDONLY); - if (self == -1) { - return 1; - } + assert(self != -1); close(self); // Check that we can still access ".." on Linux. int parent = openat(dirfd(d), "..", O_DIRECTORY | O_RDONLY); - if (parent == -1) { - return 1; - } + assert(parent != -1); close(parent); #endif From c2ba38b8f988e9835b11f12163fa8d9da12b4255 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 16 Dec 2024 11:47:31 -0800 Subject: [PATCH 071/132] Remove `createRequire` in favor of ES6 `import` (#23169) --- src/closure-externs/closure-externs.js | 3 -- src/shell.js | 32 +++++++------------ test/other/test_unoptimized_code_size.js.size | 2 +- ...t_unoptimized_code_size_no_asserts.js.size | 2 +- .../test_unoptimized_code_size_strict.js.size | 2 +- .../closure-compiler/node-externs/url.js | 1 + tools/link.py | 28 +++------------- 7 files changed, 21 insertions(+), 49 deletions(-) diff --git a/src/closure-externs/closure-externs.js b/src/closure-externs/closure-externs.js index 86495adcc15a4..1346cac539330 100644 --- a/src/closure-externs/closure-externs.js +++ b/src/closure-externs/closure-externs.js @@ -15,9 +15,6 @@ var EMSCRIPTEN$IMPORT$META; var EMSCRIPTEN$AWAIT$IMPORT; -// Don't minify createRequire -var createRequire; - // Don't minify startWorker which we use to start workers once the runtime is ready. /** * @param {Object} Module diff --git a/src/shell.js b/src/shell.js index 0010048cf4e84..b799095e8ebd1 100644 --- a/src/shell.js +++ b/src/shell.js @@ -103,22 +103,12 @@ if (ENVIRONMENT_IS_PTHREAD) { #if ENVIRONMENT_MAY_BE_NODE if (ENVIRONMENT_IS_NODE) { - // `require()` is no-op in an ESM module, use `createRequire()` to construct - // the require()` function. This is only necessary for multi-environment - // builds, `-sENVIRONMENT=node` emits a static import declaration instead. - // TODO: Swap all `require()`'s with `import()`'s? -#if EXPORT_ES6 && ENVIRONMENT_MAY_BE_WEB - const { createRequire } = await import('module'); - let dirname = import.meta.url; - if (dirname.startsWith("data:")) { - dirname = '/'; - } - /** @suppress{duplicate} */ - var require = createRequire(dirname); -#endif - #if PTHREADS || WASM_WORKERS +#if EXPORT_ES6 + var worker_threads = await import('worker_threads'); +#else var worker_threads = require('worker_threads'); +#endif global.Worker = worker_threads.Worker; ENVIRONMENT_IS_WORKER = !worker_threads.isMainThread; #if PTHREADS @@ -203,19 +193,21 @@ if (ENVIRONMENT_IS_NODE) { } #endif - // These modules will usually be used on Node.js. Load them eagerly to avoid - // the complexity of lazy-loading. - var fs = require('fs'); - var nodePath = require('path'); - #if EXPORT_ES6 + var fs = await import('fs'); + var nodePath = await import('path'); + var url = await import('url'); // EXPORT_ES6 + ENVIRONMENT_IS_NODE always requires use of import.meta.url, // since there's no way getting the current absolute path of the module when // support for that is not available. if (!import.meta.url.startsWith('data:')) { - scriptDirectory = nodePath.dirname(require('url').fileURLToPath(import.meta.url)) + '/'; + scriptDirectory = nodePath.dirname(url.fileURLToPath(import.meta.url)) + '/'; } #else + // These modules will usually be used on Node.js. Load them eagerly to avoid + // the complexity of lazy-loading. + var fs = require('fs'); + var nodePath = require('path'); scriptDirectory = __dirname + '/'; #endif diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index 4afd342237c00..046e89b60f884 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -54298 +54011 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index 16aa1753892c1..5c472908debfe 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -29718 +29431 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index d61957cf8282e..4bbe505895f0b 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -53094 +52807 diff --git a/third_party/closure-compiler/node-externs/url.js b/third_party/closure-compiler/node-externs/url.js index 7f848f3fe7f09..2ffc965f16ed4 100644 --- a/third_party/closure-compiler/node-externs/url.js +++ b/third_party/closure-compiler/node-externs/url.js @@ -30,6 +30,7 @@ /** * @type {Object.} + * @suppress {duplicate} */ var url = {}; diff --git a/tools/link.py b/tools/link.py index 4444f4e06146c..2d4726bcc286d 100644 --- a/tools/link.py +++ b/tools/link.py @@ -2365,21 +2365,6 @@ def phase_binaryen(target, options, wasm_target): write_file(final_js, js) -def node_es6_imports(): - if not settings.EXPORT_ES6 or not settings.ENVIRONMENT_MAY_BE_NODE: - return '' - - # Multi-environment builds uses `await import` in `shell.js` - if settings.ENVIRONMENT_MAY_BE_WEB: - return '' - - # Use static import declaration if we only target Node.js - return ''' -import { createRequire } from 'module'; -const require = createRequire(import.meta.url); -''' - - def node_pthread_detection(): # Under node we detect that we are running in a pthread by checking the # workerData property. @@ -2394,11 +2379,10 @@ def modularize(): logger.debug(f'Modularizing, assigning to var {settings.EXPORT_NAME}') src = read_file(final_js) - # Multi-environment ES6 builds require an async function + # When targetting node and ES6 we use `await import ..` in the generated code + # so the outer function needs to be marked as async. async_emit = '' - if settings.EXPORT_ES6 and \ - settings.ENVIRONMENT_MAY_BE_NODE and \ - settings.ENVIRONMENT_MAY_BE_WEB: + if settings.EXPORT_ES6 and settings.ENVIRONMENT_MAY_BE_NODE: async_emit = 'async ' # TODO: Remove when https://bugs.webkit.org/show_bug.cgi?id=223533 is resolved. @@ -2449,25 +2433,23 @@ def modularize(): if settings.ENVIRONMENT_MAY_BE_NODE: script_url_node = "if (typeof __filename != 'undefined') _scriptName = _scriptName || __filename;" if settings.MODULARIZE == 'instance': - src = '''%(node_imports)s + src = '''\ var _scriptName = %(script_url)s; %(script_url_node)s %(src)s ''' % { - 'node_imports': node_es6_imports(), 'script_url': script_url, 'script_url_node': script_url_node, 'src': src, } else: - src = '''%(node_imports)s + src = '''\ var %(EXPORT_NAME)s = (() => { var _scriptName = %(script_url)s; %(script_url_node)s return (%(src)s); })(); ''' % { - 'node_imports': node_es6_imports(), 'EXPORT_NAME': settings.EXPORT_NAME, 'script_url': script_url, 'script_url_node': script_url_node, From 5e101a76129c3ae4a07532dbfa3364b4cd27f6a0 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 16 Dec 2024 12:07:20 -0800 Subject: [PATCH 072/132] [NFC] Give some JS optimizer tests nice names (#23161) --- ...DCEGraph2-output.js => emitDCEGraph-dynCall-output.js} | 0 .../{emitDCEGraph2.js => emitDCEGraph-dynCall.js} | 0 ...mitDCEGraph3-output.js => emitDCEGraph-eval-output.js} | 0 .../{emitDCEGraph3.js => emitDCEGraph-eval.js} | 0 ...EGraph5-output.js => emitDCEGraph-prefixing-output.js} | 0 .../{emitDCEGraph5.js => emitDCEGraph-prefixing.js} | 0 ...emitDCEGraph4-output.js => emitDCEGraph-sig-output.js} | 0 .../{emitDCEGraph4.js => emitDCEGraph-sig.js} | 0 test/test_other.py | 8 ++++---- 9 files changed, 4 insertions(+), 4 deletions(-) rename test/js_optimizer/{emitDCEGraph2-output.js => emitDCEGraph-dynCall-output.js} (100%) rename test/js_optimizer/{emitDCEGraph2.js => emitDCEGraph-dynCall.js} (100%) rename test/js_optimizer/{emitDCEGraph3-output.js => emitDCEGraph-eval-output.js} (100%) rename test/js_optimizer/{emitDCEGraph3.js => emitDCEGraph-eval.js} (100%) rename test/js_optimizer/{emitDCEGraph5-output.js => emitDCEGraph-prefixing-output.js} (100%) rename test/js_optimizer/{emitDCEGraph5.js => emitDCEGraph-prefixing.js} (100%) rename test/js_optimizer/{emitDCEGraph4-output.js => emitDCEGraph-sig-output.js} (100%) rename test/js_optimizer/{emitDCEGraph4.js => emitDCEGraph-sig.js} (100%) diff --git a/test/js_optimizer/emitDCEGraph2-output.js b/test/js_optimizer/emitDCEGraph-dynCall-output.js similarity index 100% rename from test/js_optimizer/emitDCEGraph2-output.js rename to test/js_optimizer/emitDCEGraph-dynCall-output.js diff --git a/test/js_optimizer/emitDCEGraph2.js b/test/js_optimizer/emitDCEGraph-dynCall.js similarity index 100% rename from test/js_optimizer/emitDCEGraph2.js rename to test/js_optimizer/emitDCEGraph-dynCall.js diff --git a/test/js_optimizer/emitDCEGraph3-output.js b/test/js_optimizer/emitDCEGraph-eval-output.js similarity index 100% rename from test/js_optimizer/emitDCEGraph3-output.js rename to test/js_optimizer/emitDCEGraph-eval-output.js diff --git a/test/js_optimizer/emitDCEGraph3.js b/test/js_optimizer/emitDCEGraph-eval.js similarity index 100% rename from test/js_optimizer/emitDCEGraph3.js rename to test/js_optimizer/emitDCEGraph-eval.js diff --git a/test/js_optimizer/emitDCEGraph5-output.js b/test/js_optimizer/emitDCEGraph-prefixing-output.js similarity index 100% rename from test/js_optimizer/emitDCEGraph5-output.js rename to test/js_optimizer/emitDCEGraph-prefixing-output.js diff --git a/test/js_optimizer/emitDCEGraph5.js b/test/js_optimizer/emitDCEGraph-prefixing.js similarity index 100% rename from test/js_optimizer/emitDCEGraph5.js rename to test/js_optimizer/emitDCEGraph-prefixing.js diff --git a/test/js_optimizer/emitDCEGraph4-output.js b/test/js_optimizer/emitDCEGraph-sig-output.js similarity index 100% rename from test/js_optimizer/emitDCEGraph4-output.js rename to test/js_optimizer/emitDCEGraph-sig-output.js diff --git a/test/js_optimizer/emitDCEGraph4.js b/test/js_optimizer/emitDCEGraph-sig.js similarity index 100% rename from test/js_optimizer/emitDCEGraph4.js rename to test/js_optimizer/emitDCEGraph-sig.js diff --git a/test/test_other.py b/test/test_other.py index 8343a3d02f0c0..364abd518a6b0 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -2892,10 +2892,10 @@ def test_extern_prepost(self): 'AJSDCE': (['AJSDCE'],), 'emitDCEGraph': (['emitDCEGraph', '--no-print'],), 'emitDCEGraph-closure': (['emitDCEGraph', '--no-print', '--closure-friendly'], 'emitDCEGraph.js'), - 'emitDCEGraph2': (['emitDCEGraph', '--no-print'],), - 'emitDCEGraph3': (['emitDCEGraph', '--no-print'],), - 'emitDCEGraph4': (['emitDCEGraph', '--no-print'],), - 'emitDCEGraph5': (['emitDCEGraph', '--no-print'],), + 'emitDCEGraph-dynCall': (['emitDCEGraph', '--no-print'],), + 'emitDCEGraph-eval': (['emitDCEGraph', '--no-print'],), + 'emitDCEGraph-sig': (['emitDCEGraph', '--no-print'],), + 'emitDCEGraph-prefixing': (['emitDCEGraph', '--no-print'],), 'emitDCEGraph-scopes': (['emitDCEGraph', '--no-print'],), 'minimal-runtime-applyDCEGraphRemovals': (['applyDCEGraphRemovals'],), 'applyDCEGraphRemovals': (['applyDCEGraphRemovals'],), From 97f67452380f6d3cabd05c1a0b69f230300a029b Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 16 Dec 2024 12:10:20 -0800 Subject: [PATCH 073/132] Remove unnecessary checks on the existence of `fetch`. NFC (#23166) As of #23118 we can assume and browser and worker environments always include `fetch`. --- src/preamble.js | 12 ++++++++---- src/source_map_support.js | 2 +- test/other/codesize/test_codesize_cxx_ctors1.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors1.jssize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.jssize | 2 +- test/other/codesize/test_codesize_cxx_except.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except.jssize | 2 +- .../codesize/test_codesize_cxx_except_wasm.gzsize | 2 +- .../codesize/test_codesize_cxx_except_wasm.jssize | 2 +- .../test_codesize_cxx_except_wasm_exnref.gzsize | 2 +- .../test_codesize_cxx_except_wasm_exnref.jssize | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.jssize | 2 +- test/other/codesize/test_codesize_cxx_mangle.gzsize | 2 +- test/other/codesize/test_codesize_cxx_mangle.jssize | 2 +- .../other/codesize/test_codesize_cxx_noexcept.gzsize | 2 +- .../other/codesize/test_codesize_cxx_noexcept.jssize | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.gzsize | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.jssize | 2 +- test/other/codesize/test_codesize_files_js_fs.gzsize | 2 +- test/other/codesize/test_codesize_files_js_fs.jssize | 2 +- .../other/codesize/test_codesize_files_wasmfs.gzsize | 2 +- .../other/codesize/test_codesize_files_wasmfs.jssize | 2 +- test/other/codesize/test_codesize_hello_O0.gzsize | 2 +- test/other/codesize/test_codesize_hello_O0.jssize | 2 +- test/other/codesize/test_codesize_hello_O1.gzsize | 2 +- test/other/codesize/test_codesize_hello_O1.jssize | 2 +- test/other/codesize/test_codesize_hello_O2.gzsize | 2 +- test/other/codesize/test_codesize_hello_O2.jssize | 2 +- test/other/codesize/test_codesize_hello_O3.gzsize | 2 +- test/other/codesize/test_codesize_hello_O3.jssize | 2 +- test/other/codesize/test_codesize_hello_Os.gzsize | 2 +- test/other/codesize/test_codesize_hello_Os.jssize | 2 +- test/other/codesize/test_codesize_hello_Oz.gzsize | 2 +- test/other/codesize/test_codesize_hello_Oz.jssize | 2 +- .../other/codesize/test_codesize_hello_dylink.gzsize | 2 +- .../other/codesize/test_codesize_hello_dylink.jssize | 2 +- .../test_codesize_hello_export_nothing.gzsize | 2 +- .../test_codesize_hello_export_nothing.jssize | 2 +- .../other/codesize/test_codesize_hello_wasmfs.gzsize | 2 +- .../other/codesize/test_codesize_hello_wasmfs.jssize | 2 +- .../test_codesize_libcxxabi_message_O3.gzsize | 2 +- .../test_codesize_libcxxabi_message_O3.jssize | 2 +- ...t_codesize_libcxxabi_message_O3_standalone.gzsize | 2 +- ...t_codesize_libcxxabi_message_O3_standalone.jssize | 2 +- test/other/codesize/test_codesize_mem_O3.gzsize | 2 +- test/other/codesize/test_codesize_mem_O3.jssize | 2 +- test/other/codesize/test_codesize_mem_O3_grow.gzsize | 2 +- test/other/codesize/test_codesize_mem_O3_grow.jssize | 2 +- .../test_codesize_mem_O3_grow_standalone.gzsize | 2 +- .../test_codesize_mem_O3_grow_standalone.jssize | 2 +- .../codesize/test_codesize_mem_O3_standalone.gzsize | 2 +- .../codesize/test_codesize_mem_O3_standalone.jssize | 2 +- .../test_codesize_mem_O3_standalone_lib.gzsize | 2 +- .../test_codesize_mem_O3_standalone_lib.jssize | 2 +- .../test_codesize_mem_O3_standalone_narg.gzsize | 2 +- .../test_codesize_mem_O3_standalone_narg.jssize | 2 +- .../test_codesize_mem_O3_standalone_narg_flto.gzsize | 2 +- .../test_codesize_mem_O3_standalone_narg_flto.jssize | 2 +- test/other/codesize/test_codesize_minimal_64.gzsize | 2 +- test/other/codesize/test_codesize_minimal_64.jssize | 2 +- test/other/codesize/test_codesize_minimal_O0.gzsize | 2 +- test/other/codesize/test_codesize_minimal_O0.jssize | 2 +- test/other/codesize/test_codesize_minimal_O1.gzsize | 2 +- test/other/codesize/test_codesize_minimal_O1.jssize | 2 +- test/other/codesize/test_codesize_minimal_O2.gzsize | 2 +- test/other/codesize/test_codesize_minimal_O2.jssize | 2 +- test/other/codesize/test_codesize_minimal_O3.gzsize | 2 +- test/other/codesize/test_codesize_minimal_O3.jssize | 2 +- test/other/codesize/test_codesize_minimal_Os.gzsize | 2 +- test/other/codesize/test_codesize_minimal_Os.jssize | 2 +- .../codesize/test_codesize_minimal_Oz-ctors.gzsize | 2 +- .../codesize/test_codesize_minimal_Oz-ctors.jssize | 2 +- test/other/codesize/test_codesize_minimal_Oz.gzsize | 2 +- test/other/codesize/test_codesize_minimal_Oz.jssize | 2 +- .../codesize/test_codesize_minimal_pthreads.gzsize | 2 +- .../codesize/test_codesize_minimal_pthreads.jssize | 2 +- .../codesize/test_codesize_minimal_wasmfs.gzsize | 2 +- .../codesize/test_codesize_minimal_wasmfs.jssize | 2 +- test/other/test_unoptimized_code_size.js.size | 2 +- .../test_unoptimized_code_size_no_asserts.js.size | 2 +- test/other/test_unoptimized_code_size_strict.js.size | 2 +- 83 files changed, 90 insertions(+), 86 deletions(-) diff --git a/src/preamble.js b/src/preamble.js index d097c857f89be..5e31b92d017a2 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -818,10 +818,10 @@ async function instantiateAsync(binary, binaryFile, imports) { #if !SINGLE_FILE if (!binary && typeof WebAssembly.instantiateStreaming == 'function' && - !isDataURI(binaryFile) && + !isDataURI(binaryFile) #if ENVIRONMENT_MAY_BE_WEBVIEW // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously. - !isFileURI(binaryFile) && + && !isFileURI(binaryFile) #endif #if ENVIRONMENT_MAY_BE_NODE // Avoid instantiateStreaming() on Node.js environment for now, as while @@ -830,9 +830,13 @@ async function instantiateAsync(binary, binaryFile, imports) { // // Reference: // https://github.com/emscripten-core/emscripten/pull/16917 - !ENVIRONMENT_IS_NODE && + && !ENVIRONMENT_IS_NODE #endif - typeof fetch == 'function') { +#if ENVIRONMENT_MAY_BE_SHELL + // Shell environments don't have fetch. + && !ENVIRONMENT_IS_SHELL +#endif + ) { try { var response = fetch(binaryFile, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}); #if USE_OFFSET_CONVERTER diff --git a/src/source_map_support.js b/src/source_map_support.js index 713cf017e65be..4f2f23d84fc22 100644 --- a/src/source_map_support.js +++ b/src/source_map_support.js @@ -107,7 +107,7 @@ function getSourceMap() { } function getSourceMapPromise() { - if ((ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) && typeof fetch == 'function') { + if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { return fetch(wasmSourceMapFile, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}) .then((response) => response.json()) .catch(getSourceMap); diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 468a6eb07aa8e..372dd800a6664 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8545 +8542 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index 29e9dfe0d59e0..4792957645ab9 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20951 +20925 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index e2ce68595ae3b..f4bd3f09e60d0 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8530 +8526 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 831b5f96cc534..be622c05e5cf1 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20919 +20893 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 01b52bf830622..76c2119667336 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9579 +9572 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index a01c450fd72cc..883a0b6975b4a 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24796 +24770 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index d0dddc6097c20..c58231813b792 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8508 +8503 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index f1ed501dc449f..a2cafeab8aabf 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20845 +20819 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index d0dddc6097c20..c58231813b792 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8508 +8503 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index f1ed501dc449f..a2cafeab8aabf 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20845 +20819 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index cd0e49aee5b8e..8712958ff9448 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8446 +8440 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 92d54f818a532..ce0e8ed643da7 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20530 +20504 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index a6fba7a88ba19..0fd7b9f8eaa2e 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9580 +9573 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index a01c450fd72cc..883a0b6975b4a 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24796 +24770 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 468a6eb07aa8e..372dd800a6664 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8545 +8542 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index 29e9dfe0d59e0..4792957645ab9 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20951 +20925 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize index 39ecd9a41b616..4ccb19fe6a616 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize @@ -1 +1 @@ -3807 +3802 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.jssize b/test/other/codesize/test_codesize_cxx_wasmfs.jssize index dd1e06021b37c..d9d8063900671 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.jssize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.jssize @@ -1 +1 @@ -8588 +8562 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index a3058b5a02fd7..edd0488a70a87 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7686 +7679 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index 47c3867c42329..313631805fc95 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18858 +18832 diff --git a/test/other/codesize/test_codesize_files_wasmfs.gzsize b/test/other/codesize/test_codesize_files_wasmfs.gzsize index 3580ad11bdcb0..eb6dfd83a21e8 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_files_wasmfs.gzsize @@ -1 +1 @@ -2906 +2897 diff --git a/test/other/codesize/test_codesize_files_wasmfs.jssize b/test/other/codesize/test_codesize_files_wasmfs.jssize index a6ea3e034d192..725bb9700b2e6 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.jssize +++ b/test/other/codesize/test_codesize_files_wasmfs.jssize @@ -1 +1 @@ -6229 +6203 diff --git a/test/other/codesize/test_codesize_hello_O0.gzsize b/test/other/codesize/test_codesize_hello_O0.gzsize index 72ac185273c84..42b603432aefe 100644 --- a/test/other/codesize/test_codesize_hello_O0.gzsize +++ b/test/other/codesize/test_codesize_hello_O0.gzsize @@ -1 +1 @@ -8021 +8017 diff --git a/test/other/codesize/test_codesize_hello_O0.jssize b/test/other/codesize/test_codesize_hello_O0.jssize index f18a59a99db88..59deaf245ee60 100644 --- a/test/other/codesize/test_codesize_hello_O0.jssize +++ b/test/other/codesize/test_codesize_hello_O0.jssize @@ -1 +1 @@ -21551 +21521 diff --git a/test/other/codesize/test_codesize_hello_O1.gzsize b/test/other/codesize/test_codesize_hello_O1.gzsize index 8061cb7887295..f1349afff39a3 100644 --- a/test/other/codesize/test_codesize_hello_O1.gzsize +++ b/test/other/codesize/test_codesize_hello_O1.gzsize @@ -1 +1 @@ -2761 +2753 diff --git a/test/other/codesize/test_codesize_hello_O1.jssize b/test/other/codesize/test_codesize_hello_O1.jssize index 162b0d0c72042..c244fa7913935 100644 --- a/test/other/codesize/test_codesize_hello_O1.jssize +++ b/test/other/codesize/test_codesize_hello_O1.jssize @@ -1 +1 @@ -7028 +6998 diff --git a/test/other/codesize/test_codesize_hello_O2.gzsize b/test/other/codesize/test_codesize_hello_O2.gzsize index 1415bc57370d0..65b7a7f809ae5 100644 --- a/test/other/codesize/test_codesize_hello_O2.gzsize +++ b/test/other/codesize/test_codesize_hello_O2.gzsize @@ -1 +1 @@ -2408 +2402 diff --git a/test/other/codesize/test_codesize_hello_O2.jssize b/test/other/codesize/test_codesize_hello_O2.jssize index 87c7f9ec33478..f9d8cb95dd8ce 100644 --- a/test/other/codesize/test_codesize_hello_O2.jssize +++ b/test/other/codesize/test_codesize_hello_O2.jssize @@ -1 +1 @@ -4937 +4911 diff --git a/test/other/codesize/test_codesize_hello_O3.gzsize b/test/other/codesize/test_codesize_hello_O3.gzsize index ed5edbf7f250d..ebc926ef1d463 100644 --- a/test/other/codesize/test_codesize_hello_O3.gzsize +++ b/test/other/codesize/test_codesize_hello_O3.gzsize @@ -1 +1 @@ -2320 +2312 diff --git a/test/other/codesize/test_codesize_hello_O3.jssize b/test/other/codesize/test_codesize_hello_O3.jssize index 1ab0d2e7606cc..44d8a72de1a38 100644 --- a/test/other/codesize/test_codesize_hello_O3.jssize +++ b/test/other/codesize/test_codesize_hello_O3.jssize @@ -1 +1 @@ -4784 +4758 diff --git a/test/other/codesize/test_codesize_hello_Os.gzsize b/test/other/codesize/test_codesize_hello_Os.gzsize index ed5edbf7f250d..ebc926ef1d463 100644 --- a/test/other/codesize/test_codesize_hello_Os.gzsize +++ b/test/other/codesize/test_codesize_hello_Os.gzsize @@ -1 +1 @@ -2320 +2312 diff --git a/test/other/codesize/test_codesize_hello_Os.jssize b/test/other/codesize/test_codesize_hello_Os.jssize index 1ab0d2e7606cc..44d8a72de1a38 100644 --- a/test/other/codesize/test_codesize_hello_Os.jssize +++ b/test/other/codesize/test_codesize_hello_Os.jssize @@ -1 +1 @@ -4784 +4758 diff --git a/test/other/codesize/test_codesize_hello_Oz.gzsize b/test/other/codesize/test_codesize_hello_Oz.gzsize index ec0da141bd5ab..0f6991adc91e5 100644 --- a/test/other/codesize/test_codesize_hello_Oz.gzsize +++ b/test/other/codesize/test_codesize_hello_Oz.gzsize @@ -1 +1 @@ -2301 +2295 diff --git a/test/other/codesize/test_codesize_hello_Oz.jssize b/test/other/codesize/test_codesize_hello_Oz.jssize index 8f9d0a47aed00..63e5168563779 100644 --- a/test/other/codesize/test_codesize_hello_Oz.jssize +++ b/test/other/codesize/test_codesize_hello_Oz.jssize @@ -1 +1 @@ -4751 +4725 diff --git a/test/other/codesize/test_codesize_hello_dylink.gzsize b/test/other/codesize/test_codesize_hello_dylink.gzsize index d665f60e5a1bc..d46a5eeb3db5b 100644 --- a/test/other/codesize/test_codesize_hello_dylink.gzsize +++ b/test/other/codesize/test_codesize_hello_dylink.gzsize @@ -1 +1 @@ -6198 +6191 diff --git a/test/other/codesize/test_codesize_hello_dylink.jssize b/test/other/codesize/test_codesize_hello_dylink.jssize index b796f1274f259..f1e6c6c03a1bc 100644 --- a/test/other/codesize/test_codesize_hello_dylink.jssize +++ b/test/other/codesize/test_codesize_hello_dylink.jssize @@ -1 +1 @@ -13710 +13684 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.gzsize b/test/other/codesize/test_codesize_hello_export_nothing.gzsize index 9cc2f9d9f7d19..6aec59a6d0cad 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.gzsize +++ b/test/other/codesize/test_codesize_hello_export_nothing.gzsize @@ -1 +1 @@ -1694 +1687 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.jssize b/test/other/codesize/test_codesize_hello_export_nothing.jssize index 46aae8dca64cc..93b24425acae2 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.jssize +++ b/test/other/codesize/test_codesize_hello_export_nothing.jssize @@ -1 +1 @@ -3644 +3618 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.gzsize b/test/other/codesize/test_codesize_hello_wasmfs.gzsize index ed5edbf7f250d..ebc926ef1d463 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_hello_wasmfs.gzsize @@ -1 +1 @@ -2320 +2312 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.jssize b/test/other/codesize/test_codesize_hello_wasmfs.jssize index 1ab0d2e7606cc..44d8a72de1a38 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.jssize +++ b/test/other/codesize/test_codesize_hello_wasmfs.jssize @@ -1 +1 @@ -4784 +4758 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize index 0cee2745e0db2..675a793e3bb8f 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize @@ -1 +1 @@ -1896 +1889 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize index cdfa59eaeb4dc..7565b177f4d23 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize @@ -1 +1 @@ -4022 +3995 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize index fe1d264c3d0c1..348c7c2456b13 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize @@ -1 +1 @@ -1934 +1928 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize index 2332265bcdcf8..4a3a63211e267 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize @@ -1 +1 @@ -4069 +4043 diff --git a/test/other/codesize/test_codesize_mem_O3.gzsize b/test/other/codesize/test_codesize_mem_O3.gzsize index cf97139540b7d..8e6541741fb26 100644 --- a/test/other/codesize/test_codesize_mem_O3.gzsize +++ b/test/other/codesize/test_codesize_mem_O3.gzsize @@ -1 +1 @@ -2354 +2349 diff --git a/test/other/codesize/test_codesize_mem_O3.jssize b/test/other/codesize/test_codesize_mem_O3.jssize index ba0fcbee92dbe..546b2455bced4 100644 --- a/test/other/codesize/test_codesize_mem_O3.jssize +++ b/test/other/codesize/test_codesize_mem_O3.jssize @@ -1 +1 @@ -4925 +4899 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.gzsize b/test/other/codesize/test_codesize_mem_O3_grow.gzsize index ea908ff33b176..445f349d2a0d7 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow.gzsize @@ -1 +1 @@ -2503 +2497 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.jssize b/test/other/codesize/test_codesize_mem_O3_grow.jssize index 3333699ae3fbd..7bcc8aba73720 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow.jssize @@ -1 +1 @@ -5210 +5184 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize index cc50439680514..985179ce9b289 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize @@ -1 +1 @@ -2199 +2192 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize index 9266adf35c9cd..ecdf4f5ba87d5 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize @@ -1 +1 @@ -4618 +4592 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize index 5e7c8b88a0264..adcf4b878ee7d 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize @@ -1 +1 @@ -2164 +2158 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_standalone.jssize index d2a5225519bcd..146f070cdcabf 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.jssize @@ -1 +1 @@ -4548 +4522 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize index 2ff4149843110..a7568adae3387 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize @@ -1 +1 @@ -1921 +1914 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize index 2332265bcdcf8..97a67bc728a46 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize @@ -1 +1 @@ -4069 +4042 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize index fe1d264c3d0c1..348c7c2456b13 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize @@ -1 +1 @@ -1934 +1928 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize index 2332265bcdcf8..4a3a63211e267 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize @@ -1 +1 @@ -4069 +4043 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize index fe1d264c3d0c1..348c7c2456b13 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize @@ -1 +1 @@ -1934 +1928 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize index 2332265bcdcf8..4a3a63211e267 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize @@ -1 +1 @@ -4069 +4043 diff --git a/test/other/codesize/test_codesize_minimal_64.gzsize b/test/other/codesize/test_codesize_minimal_64.gzsize index 6d3656504bfd2..2794bbe069d76 100644 --- a/test/other/codesize/test_codesize_minimal_64.gzsize +++ b/test/other/codesize/test_codesize_minimal_64.gzsize @@ -1 +1 @@ -1469 +1458 diff --git a/test/other/codesize/test_codesize_minimal_64.jssize b/test/other/codesize/test_codesize_minimal_64.jssize index b345efadeb220..4fb7d0e7d0511 100644 --- a/test/other/codesize/test_codesize_minimal_64.jssize +++ b/test/other/codesize/test_codesize_minimal_64.jssize @@ -1 +1 @@ -3124 +3098 diff --git a/test/other/codesize/test_codesize_minimal_O0.gzsize b/test/other/codesize/test_codesize_minimal_O0.gzsize index 72298135d0b70..8cd05948b4b40 100644 --- a/test/other/codesize/test_codesize_minimal_O0.gzsize +++ b/test/other/codesize/test_codesize_minimal_O0.gzsize @@ -1 +1 @@ -6555 +6546 diff --git a/test/other/codesize/test_codesize_minimal_O0.jssize b/test/other/codesize/test_codesize_minimal_O0.jssize index 3ae04fb77af32..1b66ee40ff9ad 100644 --- a/test/other/codesize/test_codesize_minimal_O0.jssize +++ b/test/other/codesize/test_codesize_minimal_O0.jssize @@ -1 +1 @@ -17586 +17556 diff --git a/test/other/codesize/test_codesize_minimal_O1.gzsize b/test/other/codesize/test_codesize_minimal_O1.gzsize index e19b378c27520..fa94e88e60f14 100644 --- a/test/other/codesize/test_codesize_minimal_O1.gzsize +++ b/test/other/codesize/test_codesize_minimal_O1.gzsize @@ -1 +1 @@ -1546 +1536 diff --git a/test/other/codesize/test_codesize_minimal_O1.jssize b/test/other/codesize/test_codesize_minimal_O1.jssize index 7f0e18ca00cc8..46b6c4b342033 100644 --- a/test/other/codesize/test_codesize_minimal_O1.jssize +++ b/test/other/codesize/test_codesize_minimal_O1.jssize @@ -1 +1 @@ -3693 +3663 diff --git a/test/other/codesize/test_codesize_minimal_O2.gzsize b/test/other/codesize/test_codesize_minimal_O2.gzsize index 12c4d99b46c4d..88382e8fead7c 100644 --- a/test/other/codesize/test_codesize_minimal_O2.gzsize +++ b/test/other/codesize/test_codesize_minimal_O2.gzsize @@ -1 +1 @@ -1398 +1389 diff --git a/test/other/codesize/test_codesize_minimal_O2.jssize b/test/other/codesize/test_codesize_minimal_O2.jssize index 1e779f31c3179..4d86a0941c7cc 100644 --- a/test/other/codesize/test_codesize_minimal_O2.jssize +++ b/test/other/codesize/test_codesize_minimal_O2.jssize @@ -1 +1 @@ -2829 +2803 diff --git a/test/other/codesize/test_codesize_minimal_O3.gzsize b/test/other/codesize/test_codesize_minimal_O3.gzsize index a3c357ffe951c..2538e3d648dd5 100644 --- a/test/other/codesize/test_codesize_minimal_O3.gzsize +++ b/test/other/codesize/test_codesize_minimal_O3.gzsize @@ -1 +1 @@ -1363 +1354 diff --git a/test/other/codesize/test_codesize_minimal_O3.jssize b/test/other/codesize/test_codesize_minimal_O3.jssize index 2b4ea894fb435..f1349afff39a3 100644 --- a/test/other/codesize/test_codesize_minimal_O3.jssize +++ b/test/other/codesize/test_codesize_minimal_O3.jssize @@ -1 +1 @@ -2779 +2753 diff --git a/test/other/codesize/test_codesize_minimal_Os.gzsize b/test/other/codesize/test_codesize_minimal_Os.gzsize index a3c357ffe951c..2538e3d648dd5 100644 --- a/test/other/codesize/test_codesize_minimal_Os.gzsize +++ b/test/other/codesize/test_codesize_minimal_Os.gzsize @@ -1 +1 @@ -1363 +1354 diff --git a/test/other/codesize/test_codesize_minimal_Os.jssize b/test/other/codesize/test_codesize_minimal_Os.jssize index 2b4ea894fb435..f1349afff39a3 100644 --- a/test/other/codesize/test_codesize_minimal_Os.jssize +++ b/test/other/codesize/test_codesize_minimal_Os.jssize @@ -1 +1 @@ -2779 +2753 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize index 2538e3d648dd5..07aeb9bc360f6 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize @@ -1 +1 @@ -1354 +1345 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize index 057447189685a..3f080eeb6ec84 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize @@ -1 +1 @@ -2764 +2738 diff --git a/test/other/codesize/test_codesize_minimal_Oz.gzsize b/test/other/codesize/test_codesize_minimal_Oz.gzsize index a3c357ffe951c..2538e3d648dd5 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz.gzsize @@ -1 +1 @@ -1363 +1354 diff --git a/test/other/codesize/test_codesize_minimal_Oz.jssize b/test/other/codesize/test_codesize_minimal_Oz.jssize index 2b4ea894fb435..f1349afff39a3 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz.jssize @@ -1 +1 @@ -2779 +2753 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.gzsize b/test/other/codesize/test_codesize_minimal_pthreads.gzsize index f3c2b2fc06522..12e9c25ba4dd9 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.gzsize +++ b/test/other/codesize/test_codesize_minimal_pthreads.gzsize @@ -1 +1 @@ -4163 +4155 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.jssize b/test/other/codesize/test_codesize_minimal_pthreads.jssize index a32df27cb8771..6656d3eb40b5b 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.jssize +++ b/test/other/codesize/test_codesize_minimal_pthreads.jssize @@ -1 +1 @@ -8638 +8612 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize index a3c357ffe951c..2538e3d648dd5 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize @@ -1 +1 @@ -1363 +1354 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.jssize b/test/other/codesize/test_codesize_minimal_wasmfs.jssize index 2b4ea894fb435..f1349afff39a3 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.jssize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.jssize @@ -1 +1 @@ -2779 +2753 diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index 046e89b60f884..cf69ddfe4a77e 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -54011 +53981 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index 5c472908debfe..2aba7946a2888 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -29431 +29401 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index 4bbe505895f0b..b958a7dffaa33 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -52807 +52777 From 658feba98144244a48a90e2cf9136707fa95a0fa Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 16 Dec 2024 13:25:32 -0800 Subject: [PATCH 074/132] [NFC] Remove confusing bullet point in changelog (#23181) Fixes #23178 --- ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index fb191d96b14c2..ffbe23ccb3f95 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -29,7 +29,7 @@ See docs/process.md for more on how version tagging works. the Wasm module. This will be lowered away by babel when targeting older browsers. (#23068) - Due to the discontinued support for invalid specializations of -- `std::basic_string` (https://github.com/llvm/llvm-project/pull/72694), the + `std::basic_string` (https://github.com/llvm/llvm-project/pull/72694), the support for `std::basic_string` was removed from embind. (#23070) - The minimum supported versions of browser engines that we support were updated From 472a57eb19ad237c70ccaff7766e9894e773199c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 16 Dec 2024 13:39:20 -0800 Subject: [PATCH 075/132] Rebaseline codesize expectations. NFC --- test/other/codesize/test_codesize_cxx_ctors1.size | 2 +- test/other/codesize/test_codesize_cxx_ctors2.size | 2 +- test/other/codesize/test_codesize_cxx_except.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.size | 2 +- test/other/codesize/test_codesize_cxx_mangle.size | 2 +- test/other/codesize/test_codesize_cxx_noexcept.size | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.size | 2 +- test/other/codesize/test_codesize_hello_O0.size | 2 +- test/other/test_unoptimized_code_size.wasm.size | 2 +- test/other/test_unoptimized_code_size_no_asserts.wasm.size | 2 +- test/other/test_unoptimized_code_size_strict.wasm.size | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/other/codesize/test_codesize_cxx_ctors1.size b/test/other/codesize/test_codesize_cxx_ctors1.size index 0062807e33f12..125071c29e4ba 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.size +++ b/test/other/codesize/test_codesize_cxx_ctors1.size @@ -1 +1 @@ -129224 +129231 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.size b/test/other/codesize/test_codesize_cxx_ctors2.size index 753caed4b4757..580ebc503462f 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.size +++ b/test/other/codesize/test_codesize_cxx_ctors2.size @@ -1 +1 @@ -128673 +128680 diff --git a/test/other/codesize/test_codesize_cxx_except.size b/test/other/codesize/test_codesize_cxx_except.size index 6f064a664be5b..5563f8a875e81 100644 --- a/test/other/codesize/test_codesize_cxx_except.size +++ b/test/other/codesize/test_codesize_cxx_except.size @@ -1 +1 @@ -171354 +171361 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.size b/test/other/codesize/test_codesize_cxx_except_wasm.size index 5f03a40ca51b3..bfe937c06fe72 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm.size @@ -1 +1 @@ -142474 +142481 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size index 30087621eb370..27c1d7a0535ff 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size @@ -1 +1 @@ -145061 +145068 diff --git a/test/other/codesize/test_codesize_cxx_mangle.size b/test/other/codesize/test_codesize_cxx_mangle.size index 034475a0e5f36..fc07430882075 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.size +++ b/test/other/codesize/test_codesize_cxx_mangle.size @@ -1 +1 @@ -232863 +232870 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.size b/test/other/codesize/test_codesize_cxx_noexcept.size index f0ef6f60a1014..e1072af55a243 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.size +++ b/test/other/codesize/test_codesize_cxx_noexcept.size @@ -1 +1 @@ -132031 +132038 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.size b/test/other/codesize/test_codesize_cxx_wasmfs.size index 1bc6c4829fc6c..6661bc61e54c3 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.size +++ b/test/other/codesize/test_codesize_cxx_wasmfs.size @@ -1 +1 @@ -169283 +169290 diff --git a/test/other/codesize/test_codesize_hello_O0.size b/test/other/codesize/test_codesize_hello_O0.size index 097310b36c5ab..b55e8eb4cd221 100644 --- a/test/other/codesize/test_codesize_hello_O0.size +++ b/test/other/codesize/test_codesize_hello_O0.size @@ -1 +1 @@ -14519 +14531 diff --git a/test/other/test_unoptimized_code_size.wasm.size b/test/other/test_unoptimized_code_size.wasm.size index 097310b36c5ab..b55e8eb4cd221 100644 --- a/test/other/test_unoptimized_code_size.wasm.size +++ b/test/other/test_unoptimized_code_size.wasm.size @@ -1 +1 @@ -14519 +14531 diff --git a/test/other/test_unoptimized_code_size_no_asserts.wasm.size b/test/other/test_unoptimized_code_size_no_asserts.wasm.size index 649c6e5ce3b6a..a65dc9b14619a 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.wasm.size +++ b/test/other/test_unoptimized_code_size_no_asserts.wasm.size @@ -1 +1 @@ -11712 +11724 diff --git a/test/other/test_unoptimized_code_size_strict.wasm.size b/test/other/test_unoptimized_code_size_strict.wasm.size index 097310b36c5ab..b55e8eb4cd221 100644 --- a/test/other/test_unoptimized_code_size_strict.wasm.size +++ b/test/other/test_unoptimized_code_size_strict.wasm.size @@ -1 +1 @@ -14519 +14531 From 1baef43b412f3c6540582d23fb1645e81131cf40 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Mon, 16 Dec 2024 13:43:00 -0800 Subject: [PATCH 076/132] Fix some WasmFS APIs for BIGINT support (#23183) These aren't covered by bigint-enabled tests currently, but will be shortly when we turn bigint on by default. --- src/library_wasmfs.js | 4 ++-- src/library_wasmfs_jsimpl.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/library_wasmfs.js b/src/library_wasmfs.js index 645f3ac597342..fd238bc2767bd 100644 --- a/src/library_wasmfs.js +++ b/src/library_wasmfs.js @@ -198,7 +198,7 @@ FS.init(); var bytesRead; if (seeking) { - bytesRead = __wasmfs_pread(stream.fd, dataBuffer, length, position); + bytesRead = __wasmfs_pread(stream.fd, dataBuffer, length, {{{ splitI64('position') }}}); } else { bytesRead = __wasmfs_read(stream.fd, dataBuffer, length); } @@ -222,7 +222,7 @@ FS.init(); var bytesRead; if (seeking) { - bytesRead = __wasmfs_pwrite(stream.fd, dataBuffer, length, position); + bytesRead = __wasmfs_pwrite(stream.fd, dataBuffer, length, {{{ splitI64('position') }}}); } else { bytesRead = __wasmfs_write(stream.fd, dataBuffer, length); } diff --git a/src/library_wasmfs_jsimpl.js b/src/library_wasmfs_jsimpl.js index f6293f3d460ea..63b3e77ec2aee 100644 --- a/src/library_wasmfs_jsimpl.js +++ b/src/library_wasmfs_jsimpl.js @@ -53,6 +53,7 @@ addToLibrary({ return wasmFS$backends[backend].getSize(file); }, + _wasmfs_jsimpl_set_size__i53abi: true, _wasmfs_jsimpl_set_size: (backend, file, size) => { #if ASSERTIONS assert(wasmFS$backends[backend]); From ff1e239e8b26f06d0c79b0cb532899a09c4e5807 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Mon, 16 Dec 2024 13:45:15 -0800 Subject: [PATCH 077/132] Use CI skip on release-marking PRs (#23165) --- .github/workflows/tag-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index fd44eb7c80551..dbbcf52ea6ed9 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -23,6 +23,7 @@ jobs: with: token: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }} title: Mark ${{ env.RELEASE_VERSION }} as released + body: Update changelog and emscripten-version.txt [ci skip] team-reviewers: release-reviewers delete-branch: true - name: Enable auto-merge From d766ef14c33941b04671bcab4b8fd507244ec41f Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Mon, 16 Dec 2024 14:12:09 -0800 Subject: [PATCH 078/132] Fix some source map and name section behavior (#23182) 1) This causes -g0 to fullyl override -gsource-map (removing the name section) when it comes later on the command line 2) -gsplit-dwarf and -gsource-map work together resulting in dwarf, source maps and name section together. --- emcc.py | 10 ++++++++++ test/test_other.py | 5 ++--- tools/emscripten.py | 16 ++++++++++++---- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/emcc.py b/emcc.py index 2925985f22f6c..b519281e72e84 100644 --- a/emcc.py +++ b/emcc.py @@ -1268,6 +1268,13 @@ def consume_arg_file(): if is_int(requested_level): # the -gX value is the debug level (-g1, -g2, etc.) settings.DEBUG_LEVEL = validate_arg_level(requested_level, 4, 'invalid debug level: ' + arg) + if settings.DEBUG_LEVEL == 0: + # Set these explicitly so -g0 overrides previous -g on the cmdline + settings.GENERATE_DWARF = 0 + settings.GENERATE_SOURCE_MAP = 0 + settings.EMIT_NAME_SECTION = 0 + elif settings.DEBUG_LEVEL > 1: + settings.EMIT_NAME_SECTION = 1 # if we don't need to preserve LLVM debug info, do not keep this flag # for clang if settings.DEBUG_LEVEL < 3: @@ -1298,17 +1305,20 @@ def consume_arg_file(): settings.GENERATE_DWARF = 1 elif requested_level == 'source-map': settings.GENERATE_SOURCE_MAP = 1 + settings.EMIT_NAME_SECTION = 1 newargs[i] = '-g' else: # Other non-integer levels (e.g. -gline-tables-only or -gdwarf-5) are # usually clang flags that emit DWARF. So we pass them through to # clang and make the emscripten code treat it like any other DWARF. settings.GENERATE_DWARF = 1 + settings.EMIT_NAME_SECTION = 1 # In all cases set the emscripten debug level to 3 so that we do not # strip during link (during compile, this does not make a difference). settings.DEBUG_LEVEL = 3 elif check_flag('-profiling') or check_flag('--profiling'): settings.DEBUG_LEVEL = max(settings.DEBUG_LEVEL, 2) + settings.EMIT_NAME_SECTION = 1 elif check_flag('-profiling-funcs') or check_flag('--profiling-funcs'): settings.EMIT_NAME_SECTION = 1 elif newargs[i] == '--tracing' or newargs[i] == '--memoryprofiler': diff --git a/test/test_other.py b/test/test_other.py index 364abd518a6b0..ac84ed83aaa08 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -3095,8 +3095,7 @@ def test_dwarf_sourcemap_names(self): # TODO: It seems odd that -gsource-map leaves behind a name section. Should it? (['-gsource-map'], False, True, True), (['-g1', '-Oz', '-gsource-map'], False, True, True), - # -g0 does not override -gsource-map but does remove name section. TODO: should it? - (['-gsource-map', '-g0'], False, True, False), + (['-gsource-map', '-g0'], False, False, False), # --emit-symbol-map should not affect the results (['--emit-symbol-map', '-gsource-map'], False, True, True), (['--emit-symbol-map'], False, False, False), @@ -3105,7 +3104,7 @@ def test_dwarf_sourcemap_names(self): (['-sASYNCIFY=1', '-gsource-map'], False, True, True), (['-g', '-gsource-map'], True, True, True), (['-g2', '-gsource-map'], False, True, True), - # (['-gsplit-dwarf', '-gsource-map'], True, True, True), TODO this currently fails! + (['-gsplit-dwarf', '-gsource-map'], True, True, True), (['-gsource-map', '-sWASM_BIGINT', '-sERROR_ON_WASM_CHANGES_AFTER_LINK'], False, True, True), ]: print(flags, expect_dwarf, expect_sourcemap, expect_names) diff --git a/tools/emscripten.py b/tools/emscripten.py index c2d36561d7776..c60a3ee71c975 100644 --- a/tools/emscripten.py +++ b/tools/emscripten.py @@ -501,12 +501,14 @@ def finalize_wasm(infile, outfile, js_syms): # if we don't need to modify the wasm, don't tell finalize to emit a wasm file modify_wasm = False + need_name_section = False if settings.WASM2JS: # wasm2js requires full legalization (and will do extra wasm binary # later processing later anyhow) modify_wasm = True if settings.DEBUG_LEVEL >= 2 or settings.ASYNCIFY_ADD or settings.ASYNCIFY_ADVISE or settings.ASYNCIFY_ONLY or settings.ASYNCIFY_REMOVE or settings.EMIT_SYMBOL_MAP or settings.EMIT_NAME_SECTION: + need_name_section = True args.append('-g') if settings.WASM_BIGINT: args.append('--bigint') @@ -568,12 +570,18 @@ def finalize_wasm(infile, outfile, js_syms): infile] shared.check_call(cmd) - if not settings.GENERATE_DWARF or not settings.EMIT_PRODUCERS_SECTION: - # For sections we no longer need, strip now to speed subsequent passes + # For sections we no longer need, strip now to speed subsequent passes. + # If Binaryen is not needed, this is also our last chance to strip. + strip_sections = [] + if not settings.EMIT_PRODUCERS_SECTION: + strip_sections += ['producers'] + if not need_name_section: + strip_sections += ['name'] + + if strip_sections or not settings.GENERATE_DWARF: building.save_intermediate(outfile, 'strip.wasm') - sections = ['producers'] if not settings.EMIT_PRODUCERS_SECTION else [] building.strip(infile, outfile, debug=not settings.GENERATE_DWARF, - sections=sections) + sections=strip_sections) metadata = get_metadata(outfile, outfile, modify_wasm, args) From df004b2a4791fe94d6e34654a3f61b9f91e0823c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 16 Dec 2024 15:04:53 -0800 Subject: [PATCH 079/132] Don't inject assertions onto the ready promise (#23176) This is a debug feature that means users who did not await the promise and tried to access stuff directly on it would see a nice error message. However with the advent of more usage of async/await, for example in \#23157 it is not always the ready promise that gets returned to the user but a language-generated promise from an `await` call. We could try to jump through more hoops to continue to support this debug feature, but I don't think added complexity in the toolchain or the generated code would be worth it. Split out from #23157. --- src/parseTools.mjs | 29 ----------------------------- src/shell.js | 3 --- src/shell_minimal.js | 3 --- test/test_other.py | 25 ------------------------- 4 files changed, 60 deletions(-) diff --git a/src/parseTools.mjs b/src/parseTools.mjs index fa6da8556e314..375b4bdae45c6 100644 --- a/src/parseTools.mjs +++ b/src/parseTools.mjs @@ -971,34 +971,6 @@ function to64(x) { return `BigInt(${x})`; } -// Add assertions to catch common errors when using the Promise object we -// return from MODULARIZE Module() invocations. -function addReadyPromiseAssertions() { - // Warn on someone doing - // - // var instance = Module(); - // ... - // instance._main(); - const properties = Array.from(EXPORTED_FUNCTIONS.values()); - // Also warn on onRuntimeInitialized which might be a common pattern with - // older MODULARIZE-using codebases. - properties.push('onRuntimeInitialized'); - const warningEnding = - ' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js'; - const res = JSON.stringify(properties); - return ( - res + - `.forEach((prop) => { - if (!Object.getOwnPropertyDescriptor(readyPromise, prop)) { - Object.defineProperty(readyPromise, prop, { - get: () => abort('You are getting ' + prop + '${warningEnding}'), - set: () => abort('You are setting ' + prop + '${warningEnding}'), - }); - } -});` - ); -} - function asyncIf(condition) { return condition ? 'async' : ''; } @@ -1118,7 +1090,6 @@ addToCompileTimeContext({ ENVIRONMENT_IS_WORKER_THREAD, addAtExit, addAtInit, - addReadyPromiseAssertions, asyncIf, awaitIf, buildStringArray, diff --git a/src/shell.js b/src/shell.js index b799095e8ebd1..36d9e9a4b042f 100644 --- a/src/shell.js +++ b/src/shell.js @@ -47,9 +47,6 @@ var readyPromise = new Promise((resolve, reject) => { readyPromiseResolve = resolve; readyPromiseReject = reject; }); -#if ASSERTIONS -{{{ addReadyPromiseAssertions() }}} -#endif #endif // Determine the runtime environment we are in. You can customize this by diff --git a/src/shell_minimal.js b/src/shell_minimal.js index 9e8b3039208f0..4ddf6b3b0303c 100644 --- a/src/shell_minimal.js +++ b/src/shell_minimal.js @@ -41,9 +41,6 @@ var readyPromise = new Promise((resolve, reject) => { readyPromiseResolve = resolve; readyPromiseReject = reject; }); -#if ASSERTIONS -{{{ addReadyPromiseAssertions() }}} -#endif #endif #if ENVIRONMENT_MAY_BE_NODE diff --git a/test/test_other.py b/test/test_other.py index ac84ed83aaa08..2648e1f1601f4 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -11962,31 +11962,6 @@ def test_assertions_on_outgoing_module_api_changes(self): ''' self.do_runf('src.cpp', expected, emcc_args=['-sASSERTIONS']) - def test_modularize_assertions_on_ready_promise(self): - # check that when assertions are on we give useful error messages for - # mistakenly thinking the Promise is an instance. I.e., once you could do - # Module()._main to get an instance and the main function, but after - # the breaking change in #10697 Module() now returns a promise, and to get - # the instance you must use .then() to get a callback with the instance. - create_file('test.js', r''' - try { - Module()._main; - } catch(e) { - console.log(e); - } - try { - Module().onRuntimeInitialized = 42; - } catch(e) { - console.log(e); - } - ''') - self.run_process([EMCC, test_file('hello_world.c'), '-sMODULARIZE', '-sASSERTIONS', '--extern-post-js', 'test.js']) - # A return code of 1 is from an uncaught exception not handled by - # the domain or the 'uncaughtException' event handler. - out = self.run_js('a.out.js', assert_returncode=1) - self.assertContained('You are getting _main on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js', out) - self.assertContained('You are setting onRuntimeInitialized on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js', out) - def test_modularize_assertions_on_reject_promise(self): # Check that there is an uncaught exception in modularize mode. # Once we added an `uncaughtException` handler to the global process From f53a7aced35d5411d061e043196657baf80bd980 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 16 Dec 2024 15:35:03 -0800 Subject: [PATCH 080/132] [test] Remove also_with_wasmfs_js. NFC (#23185) The only different here with `also_with_wasmfs` was that this decorator adds `FORCE_FILESYSTEM`, but the only test to use this decorator was already adding this flag. --- test/test_core.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/test/test_core.py b/test/test_core.py index 6685b5a89918a..930bbda052810 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -157,23 +157,6 @@ def decorated(f): return decorated -# Similar to also_with_wasmfs, but also enables the full JS API -def also_with_wasmfs_js(func): - assert callable(func) - - @wraps(func) - def decorated(self): - func(self) - print('wasmfs') - if self.get_setting('STANDALONE_WASM'): - self.skipTest("test currently cannot run both with WASMFS and STANDALONE_WASM") - self.set_setting('WASMFS') - self.set_setting('FORCE_FILESYSTEM') - self.emcc_args = self.emcc_args.copy() + ['-DWASMFS'] - func(self) - return decorated - - def with_asyncify_and_jspi(f): assert callable(f) @@ -5757,7 +5740,7 @@ def test_fs_trackingdelegate(self): self.do_run_in_out_file_test('fs/test_trackingdelegate.c') @also_with_noderawfs - @also_with_wasmfs_js + @also_with_wasmfs def test_fs_writeFile(self): if self.get_setting('WASMFS'): self.set_setting("FORCE_FILESYSTEM") From b8254ef36d7b1279080859f100188043498a88ca Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 16 Dec 2024 15:35:46 -0800 Subject: [PATCH 081/132] More use of async/await keywords in JS library code. NFC (#23150) Followup to #23104 --- src/embind/emval.js | 13 ++++--- src/jsifier.mjs | 2 +- src/library_browser.js | 9 +++-- src/library_trace.js | 34 +++++++++---------- src/library_wget.js | 9 ++--- src/postamble.js | 16 +++------ src/preamble.js | 2 +- src/source_map_support.js | 13 ++++--- test/browser_reporting.js | 13 ++++--- test/other/test_unoptimized_code_size.js.size | 2 +- ...t_unoptimized_code_size_no_asserts.js.size | 2 +- .../test_unoptimized_code_size_strict.js.size | 2 +- 12 files changed, 58 insertions(+), 59 deletions(-) diff --git a/src/embind/emval.js b/src/embind/emval.js index 41f5ca5656924..675db1b2ac0b9 100644 --- a/src/embind/emval.js +++ b/src/embind/emval.js @@ -447,9 +447,9 @@ var LibraryEmVal = { _emval_await__deps: ['$Emval', '$Asyncify'], _emval_await__async: true, _emval_await: (promise) => { - return Asyncify.handleAsync(() => { - promise = Emval.toValue(promise); - return promise.then(Emval.toHandle); + return Asyncify.handleAsync(async () => { + var value = await Emval.toValue(promise); + return Emval.toHandle(value); }); }, #endif @@ -468,10 +468,9 @@ var LibraryEmVal = { }, _emval_coro_suspend__deps: ['$Emval', '_emval_coro_resume'], - _emval_coro_suspend: (promiseHandle, awaiterPtr) => { - Emval.toValue(promiseHandle).then(result => { - __emval_coro_resume(awaiterPtr, Emval.toHandle(result)); - }); + _emval_coro_suspend: async (promiseHandle, awaiterPtr) => { + var result = await Emval.toValue(promiseHandle); + __emval_coro_resume(awaiterPtr, Emval.toHandle(result)); }, _emval_coro_make_promise__deps: ['$Emval', '__cxa_rethrow'], diff --git a/src/jsifier.mjs b/src/jsifier.mjs index b9a4ae1a5f4e0..604d204832dcc 100644 --- a/src/jsifier.mjs +++ b/src/jsifier.mjs @@ -338,7 +338,7 @@ function(${args}) { MEMORY64 && rtnType == 'p' ? 'proxyToMainThreadPtr' : 'proxyToMainThread'; deps.push('$' + proxyFunc); return ` -function(${args}) { +${async_}function(${args}) { if (ENVIRONMENT_IS_PTHREAD) return ${proxyFunc}(${proxiedFunctionTable.length}, 0, ${+sync}${args ? ', ' : ''}${args}); ${body} diff --git a/src/library_browser.js b/src/library_browser.js index 6a098a48813d4..721a27df7f996 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -652,7 +652,7 @@ var LibraryBrowser = { // TODO: currently not callable from a pthread, but immediately calls onerror() if not on main thread. emscripten_async_load_script__deps: ['$UTF8ToString'], - emscripten_async_load_script: (url, onload, onerror) => { + emscripten_async_load_script: async (url, onload, onerror) => { url = UTF8ToString(url); #if PTHREADS if (ENVIRONMENT_IS_PTHREAD) { @@ -687,10 +687,13 @@ var LibraryBrowser = { #if ENVIRONMENT_MAY_BE_NODE && DYNAMIC_EXECUTION if (ENVIRONMENT_IS_NODE) { - readAsync(url, false).then((data) => { + try { + var data = await readAsync(url, false); eval(data); loadDone(); - }, loadError); + } catch { + loadError(); + } return; } #endif diff --git a/src/library_trace.js b/src/library_trace.js index f45ea94a01c7e..e356881d0de00 100644 --- a/src/library_trace.js +++ b/src/library_trace.js @@ -58,29 +58,29 @@ var LibraryTracing = { }, // Work around CORS issues ... - fetchBlob: (url) => { - return fetch(url).then((rsp) => rsp.blob()); + fetchBlob: async (url) => { + var rsp = await fetch(url); + return rsp.blob(); }, - configure: (collector_url, application) => { + configure: async (collector_url, application) => { EmscriptenTrace.now = _emscripten_get_now; var now = new Date(); var session_id = now.getTime().toString() + '_' + Math.floor((Math.random() * 100) + 1).toString(); - EmscriptenTrace.fetchBlob(collector_url + 'worker.js').then((blob) => { - EmscriptenTrace.worker = new Worker(window.URL.createObjectURL(blob)); - EmscriptenTrace.worker.addEventListener('error', (e) => { - out('TRACE WORKER ERROR:'); - out(e); - }, false); - EmscriptenTrace.worker.postMessage({ 'cmd': 'configure', - 'data_version': EmscriptenTrace.DATA_VERSION, - 'session_id': session_id, - 'url': collector_url }); - EmscriptenTrace.configured = true; - EmscriptenTrace.collectorEnabled = true; - EmscriptenTrace.postEnabled = true; - }); + var blob = await EmscriptenTrace.fetchBlob(collector_url + 'worker.js'); + EmscriptenTrace.worker = new Worker(window.URL.createObjectURL(blob)); + EmscriptenTrace.worker.addEventListener('error', (e) => { + out('TRACE WORKER ERROR:'); + out(e); + }, false); + EmscriptenTrace.worker.postMessage({ 'cmd': 'configure', + 'data_version': EmscriptenTrace.DATA_VERSION, + 'session_id': session_id, + 'url': collector_url }); + EmscriptenTrace.configured = true; + EmscriptenTrace.collectorEnabled = true; + EmscriptenTrace.postEnabled = true; EmscriptenTrace.post([EmscriptenTrace.EVENT_APPLICATION_NAME, application]); EmscriptenTrace.post([EmscriptenTrace.EVENT_SESSION_NAME, now.toISOString()]); }, diff --git a/src/library_wget.js b/src/library_wget.js index 279913d0e19b4..578ae81129e65 100644 --- a/src/library_wget.js +++ b/src/library_wget.js @@ -62,10 +62,11 @@ var LibraryWget = { emscripten_async_wget_data__deps: ['$asyncLoad', 'malloc', 'free', '$callUserCallback'], emscripten_async_wget_data__proxy: 'sync', - emscripten_async_wget_data: (url, userdata, onload, onerror) => { + emscripten_async_wget_data: async (url, userdata, onload, onerror) => { {{{ runtimeKeepalivePush() }}} /* no need for run dependency, this is async but will not do any prepare etc. step */ - asyncLoad(UTF8ToString(url)).then((byteArray) => { + try { + var byteArray = await asyncLoad(UTF8ToString(url)); {{{ runtimeKeepalivePop() }}} callUserCallback(() => { var buffer = _malloc(byteArray.length); @@ -73,14 +74,14 @@ var LibraryWget = { {{{ makeDynCall('vppi', 'onload') }}}(userdata, buffer, byteArray.length); _free(buffer); }); - }, () => { + } catch (e) { if (onerror) { {{{ runtimeKeepalivePop() }}} callUserCallback(() => { {{{ makeDynCall('vp', 'onerror') }}}(userdata); }); } - }); + } }, emscripten_async_wget2__deps: ['$PATH_FS', '$wget', '$stackRestore', '$stringToUTF8OnStack'], diff --git a/src/postamble.js b/src/postamble.js index c4c25cfb4a8d8..644d6509864e4 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -40,9 +40,9 @@ dependenciesFulfilled = function runCaller() { #if HAS_MAIN #if MAIN_READS_PARAMS -function callMain(args = []) { +{{{ asyncIf(ASYNCIFY == 2) }}} function callMain(args = []) { #else -function callMain() { +{{{ asyncIf(ASYNCIFY == 2) }}} function callMain() { #endif #if ASSERTIONS assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on Module["onRuntimeInitialized"])'); @@ -100,18 +100,12 @@ function callMain() { // The current spec of JSPI returns a promise only if the function suspends // and a plain value otherwise. This will likely change: // https://github.com/WebAssembly/js-promise-integration/issues/11 - Promise.resolve(ret).then((result) => { - exitJS(result, /* implicit = */ true); - }).catch((e) => { - handleException(e); - }); -#else + ret = await ret; +#endif // ASYNCIFY == 2 // if we're not running an evented main loop, it's time to exit exitJS(ret, /* implicit = */ true); -#endif // ASYNCIFY == 2 return ret; - } - catch (e) { + } catch (e) { return handleException(e); } #if ABORT_ON_WASM_EXCEPTIONS diff --git a/src/preamble.js b/src/preamble.js index 5e31b92d017a2..b256582a05589 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -1091,7 +1091,7 @@ function getWasmImports() { var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info); receiveInstantiationResult(result); #if LOAD_SOURCE_MAP - receiveSourceMapJSON(await getSourceMapPromise()); + receiveSourceMapJSON(await getSourceMapAsync()); #endif return result; #if MODULARIZE diff --git a/src/source_map_support.js b/src/source_map_support.js index 4f2f23d84fc22..84e1bfee66fe1 100644 --- a/src/source_map_support.js +++ b/src/source_map_support.js @@ -106,11 +106,14 @@ function getSourceMap() { return JSON.parse(UTF8ArrayToString(buf)); } -function getSourceMapPromise() { +async function getSourceMapAsync() { if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { - return fetch(wasmSourceMapFile, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}) - .then((response) => response.json()) - .catch(getSourceMap); + try { + var response = await fetch(wasmSourceMapFile, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}); + return response.json(); + } catch { + // Fall back to getSourceMap below + } } - return Promise.resolve(getSourceMap()); + return getSourceMap(); } diff --git a/test/browser_reporting.js b/test/browser_reporting.js index 0ba4b90482de6..64fc270b986f5 100644 --- a/test/browser_reporting.js +++ b/test/browser_reporting.js @@ -2,7 +2,7 @@ var hasModule = typeof Module === 'object' && Module; var reportingURL = 'http://localhost:8888/'; -function reportResultToServer(result) { +async function reportResultToServer(result) { if (reportResultToServer.reported) { // Only report one result per test, even if the test misbehaves and tries to report more. reportErrorToServer(`excessive reported results, sending ${result}, test will fail`); @@ -11,12 +11,11 @@ function reportResultToServer(result) { if ((typeof ENVIRONMENT_IS_NODE !== 'undefined' && ENVIRONMENT_IS_NODE) || (typeof ENVIRONMENT_IS_AUDIO_WORKLET !== 'undefined' && ENVIRONMENT_IS_AUDIO_WORKLET)) { out(`RESULT: ${result}`); } else { - fetch(`${reportingURL}/report_result?${encodeURIComponent(result)}`).then(() => { - if (typeof window === 'object' && window && hasModule && !Module['pageThrewException']) { - /* for easy debugging, don't close window on failure */ - window.close(); - } - }); + await fetch(`${reportingURL}/report_result?${encodeURIComponent(result)}`); + if (typeof window === 'object' && window && hasModule && !Module['pageThrewException']) { + /* for easy debugging, don't close window on failure */ + window.close(); + } } } diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index cf69ddfe4a77e..c92d2e5e9cfeb 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -53981 +53980 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index 2aba7946a2888..27713e9b085b4 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -29401 +29400 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index b958a7dffaa33..b9b5998b7a2be 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -52777 +52776 From 3ffc9a006e451ce5c0230212407207e7fd3fb2a4 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 16 Dec 2024 16:27:41 -0800 Subject: [PATCH 082/132] Elide `findWasmBinary` in `-sSINGLE_FILE` mode. NFC (#23186) --- src/preamble.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/preamble.js b/src/preamble.js index b256582a05589..4f4dc32dba0ca 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -603,8 +603,13 @@ function instrumentWasmTableWithAbort() { } #endif +#if SINGLE_FILE +// In SINGLE_FILE mode the wasm binary is encoded inline here as a data: URL. +var wasmBinaryFile = '{{{ WASM_BINARY_FILE }}}'; +#else +var wasmBinaryFile; function findWasmBinary() { -#if EXPORT_ES6 && USE_ES6_IMPORT_META && !SINGLE_FILE && !AUDIO_WORKLET +#if EXPORT_ES6 && USE_ES6_IMPORT_META && !AUDIO_WORKLET if (Module['locateFile']) { #endif var f = '{{{ WASM_BINARY_FILE }}}'; @@ -614,7 +619,7 @@ function findWasmBinary() { } #endif return f; -#if EXPORT_ES6 && USE_ES6_IMPORT_META && !SINGLE_FILE && !AUDIO_WORKLET // In single-file mode, repeating WASM_BINARY_FILE would emit the contents again. For an Audio Worklet, we cannot use `new URL()`. +#if EXPORT_ES6 && USE_ES6_IMPORT_META && !AUDIO_WORKLET // In single-file mode, repeating WASM_BINARY_FILE would emit the contents again. For an Audio Worklet, we cannot use `new URL()`. } #if ENVIRONMENT_MAY_BE_SHELL if (ENVIRONMENT_IS_SHELL) @@ -624,8 +629,7 @@ function findWasmBinary() { return new URL('{{{ WASM_BINARY_FILE }}}', import.meta.url).href; #endif } - -var wasmBinaryFile; +#endif function getBinarySync(file) { if (file == wasmBinaryFile && wasmBinary) { @@ -1079,7 +1083,9 @@ function getWasmImports() { } #endif +#if !SINGLE_FILE wasmBinaryFile ??= findWasmBinary(); +#endif #if WASM_ASYNC_COMPILATION #if RUNTIME_DEBUG From ccc2a374b3efa16de5b95189e4545771e0e63e82 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 16 Dec 2024 16:57:30 -0800 Subject: [PATCH 083/132] Add maintenance script to automate test rebaselining. NFC (#23162) This is just the first iteration. See #23146 for more plans. --- tools/maint/rebaseline_tests.py | 111 ++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100755 tools/maint/rebaseline_tests.py diff --git a/tools/maint/rebaseline_tests.py b/tools/maint/rebaseline_tests.py new file mode 100755 index 0000000000000..d7e972c9f363b --- /dev/null +++ b/tools/maint/rebaseline_tests.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python3 +# Copyright 2024 The Emscripten Authors. All rights reserved. +# Emscripten is available under two separate licenses, the MIT license and the +# University of Illinois/NCSA Open Source License. Both these licenses can be +# found in the LICENSE file. + +"""Automatically rebaseline tests that have codesize expectations and create +a git commit containing the resulting changes along with readable details of +the generated changes. +""" + +import argparse +import json +import os +import subprocess +import statistics +import sys + +script_dir = os.path.dirname(os.path.abspath(__file__)) +root_dir = os.path.dirname(os.path.dirname(script_dir)) + +sys.path.insert(0, root_dir) +from tools import utils + +TESTS = [ + 'browser.test_small_js_flags', + 'other.test_INCOMING_MODULE_JS_API', + 'other.*code_size*', + 'other.*codesize*' +] + + +def run(cmd, **args): + return subprocess.check_output(cmd, text=True, cwd=root_dir, **args) + + +all_deltas = [] + + +def process_changed_file(filename): + content = open(filename).read() + old_content = run(['git', 'show', f'HEAD:{filename}']) + print(f'processing {filename}') + if len(content.splitlines()) == 1: + size = int(content.strip()) + old_size = int(old_content.strip()) + else: + try: + current_json = json.loads(content) + old_json = json.loads(old_content) + except Exception: + print(f'{filename}: Unable to parse json content. Unsupported file format?') + sys.exit(1) + size = current_json['total'] + old_size = old_json['total'] + + filename = utils.removeprefix(filename, 'test/') + delta = size - old_size + percent_delta = delta * 100 / old_size + all_deltas.append(percent_delta) + return f'{filename}: {old_size} => {size} [{delta:+} bytes / {percent_delta:+.2f}%]\n' + + +def main(argv): + parser = argparse.ArgumentParser() + parser.add_argument('-s', '--skip-tests', action='store_true', help="don't actually run the tests, just analyze the existing results") + args = parser.parse_args() + + if not args.skip_tests: + if run(['git', 'status', '-uno', '--porcelain']).strip(): + print('tree is not clean') + return 1 + + subprocess.check_call(['test/runner', '--rebaseline', '--browser=0'] + TESTS, cwd=root_dir) + + if not run(['git', 'status', '-uno', '--porcelain']): + print('no updates found') + return 1 + + output = run(['git', 'status', '-uno', '--porcelain']) + filenames = [] + for line in output.splitlines(): + status, filename = line.strip().split(' ', 1) + filenames.append(filename) + + + commit_message = f''' +Automatic rebaseline of codesize expectations. NFC + +This is an automatic change generated by tools/maint/rebaseline_tests.py. + +The following ({len(filenames)}) test expectation files were updated by +running the tests with `--rebaseline`: + +''' + + for file in filenames: + commit_message += process_changed_file(file) + + commit_message += f'\nAverage change: {statistics.mean(all_deltas):+.2f}% ({min(all_deltas):+.2f}% - {max(all_deltas):+.2f}%)\n' + + run(['git', 'checkout', '-b', 'rebaseline_tests']) + run(['git', 'add', '-u', '.']) + run(['git', 'commit', '-F', '-'], input=commit_message) + + print(commit_message) + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) From e3cb127824824f79d011df53a01416d8a8d5d9cd Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 16 Dec 2024 17:13:03 -0800 Subject: [PATCH 084/132] Automatic rebaseline of codesize expectations. NFC (#23188) This is an automatic change generated by tools/maint/rebaseline_tests.py. The following (5) test expectation files were updated by running the tests with `--rebaseline`: ``` browser/test_small_js_flags.js.size: 4369 => 4345 [-24 bytes / -0.55%] other/test_INCOMING_MODULE_JS_API.js.size: 3780 => 3758 [-22 bytes / -0.58%] other/test_unoptimized_code_size.js.size: 53980 => 53979 [-1 bytes / -0.00%] other/test_unoptimized_code_size_no_asserts.js.size: 29400 => 29399 [-1 bytes / -0.00%] other/test_unoptimized_code_size_strict.js.size: 52776 => 52775 [-1 bytes / -0.00%] Average change: -0.23% (-0.58% - -0.00%) ``` --- test/browser/test_small_js_flags.js.size | 2 +- test/other/test_INCOMING_MODULE_JS_API.js.size | 2 +- test/other/test_unoptimized_code_size.js.size | 2 +- test/other/test_unoptimized_code_size_no_asserts.js.size | 2 +- test/other/test_unoptimized_code_size_strict.js.size | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/browser/test_small_js_flags.js.size b/test/browser/test_small_js_flags.js.size index 950a0fae39f86..928819ed1470b 100644 --- a/test/browser/test_small_js_flags.js.size +++ b/test/browser/test_small_js_flags.js.size @@ -1 +1 @@ -4369 +4345 diff --git a/test/other/test_INCOMING_MODULE_JS_API.js.size b/test/other/test_INCOMING_MODULE_JS_API.js.size index 578e3b8be086a..6707ffabfa29a 100644 --- a/test/other/test_INCOMING_MODULE_JS_API.js.size +++ b/test/other/test_INCOMING_MODULE_JS_API.js.size @@ -1 +1 @@ -3780 +3758 diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index c92d2e5e9cfeb..261660aa0cc6e 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -53980 +53979 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index 27713e9b085b4..66cccdd3c3a0d 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -29400 +29399 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index b9b5998b7a2be..4898d969ef874 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -52776 +52775 From f615920e160c2d18f4cefa637c45745f0ffdff73 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 16 Dec 2024 17:13:27 -0800 Subject: [PATCH 085/132] Remove extra newline in rebaseline_tests.py. NFC (#23189) --- tools/maint/rebaseline_tests.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/maint/rebaseline_tests.py b/tools/maint/rebaseline_tests.py index d7e972c9f363b..ac00ee04b422f 100755 --- a/tools/maint/rebaseline_tests.py +++ b/tools/maint/rebaseline_tests.py @@ -83,7 +83,6 @@ def main(argv): status, filename = line.strip().split(' ', 1) filenames.append(filename) - commit_message = f''' Automatic rebaseline of codesize expectations. NFC From 2f97d049c434bb8543f139bc4bcb6199f57fd544 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Tue, 17 Dec 2024 08:30:37 -0800 Subject: [PATCH 086/132] Parameterize test_legalize_js_ffi (#23190) --- test/test_other.py | 66 +++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/test/test_other.py b/test/test_other.py index 2648e1f1601f4..3adbe4b84ad59 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -8959,39 +8959,39 @@ def test_exported_runtime_methods_metadce(self, use_legacy_name): for export in exports: self.assertContained(f'Module["{export}"]', js) - def test_legalize_js_ffi(self): - # test disabling of JS FFI legalization - for (args, js_ffi) in [ - (['-sLEGALIZE_JS_FFI=1', '-sSIDE_MODULE', '-O1'], True), - (['-sLEGALIZE_JS_FFI=0', '-sSIDE_MODULE', '-O1'], False), - (['-sLEGALIZE_JS_FFI=0', '-sSIDE_MODULE', '-O0'], False), - (['-sLEGALIZE_JS_FFI=1', '-sWARN_ON_UNDEFINED_SYMBOLS=0', '-O0'], True), - (['-sLEGALIZE_JS_FFI=0', '-sWARN_ON_UNDEFINED_SYMBOLS=0', '-O0'], False), - ]: - print(args) - delete_file('a.out.wasm') - cmd = [EMCC, test_file('other/ffi.c'), '-g', '-o', 'a.out.wasm'] + args - print(' '.join(cmd)) - self.run_process(cmd) - text = self.get_wasm_text('a.out.wasm') - # remove internal comments and extra whitespace - text = re.sub(r'\(;[^;]+;\)', '', text) - text = re.sub(r'\$var\$*.', '', text) - text = re.sub(r'param \$\d+', 'param ', text) - text = re.sub(r' +', ' ', text) - e_add_f32 = re.search(r'func \$add_f \(param f32\) \(param f32\) \(result f32\)', text) - assert e_add_f32, 'add_f export missing' - i_i64_i32 = re.search(r'import "env" "import_ll" .*\(param i32 i32\) \(result i32\)', text) - i_i64_i64 = re.search(r'import "env" "import_ll" .*\(param i64\) \(result i64\)', text) - e_i64_i32 = re.search(r'func \$legalstub\$add_ll \(param i32\) \(param i32\) \(param i32\) \(param i32\) \(result i32\)', text) - if js_ffi: - assert i_i64_i32, 'i64 not converted to i32 in imports' - assert not i_i64_i64, 'i64 not converted to i32 in imports' - assert e_i64_i32, 'i64 not converted to i32 in exports' - else: - assert not i_i64_i32, 'i64 converted to i32 in imports' - assert i_i64_i64, 'i64 converted to i32 in imports' - assert not e_i64_i32, 'i64 converted to i32 in exports' + @parameterized({ + 'legal_side_O1': (['-sLEGALIZE_JS_FFI=1', '-sSIDE_MODULE', '-O1'], True), + 'nolegal_side_O1': (['-sLEGALIZE_JS_FFI=0', '-sSIDE_MODULE', '-O1'], False), + 'nolegal_side_O0': (['-sLEGALIZE_JS_FFI=0', '-sSIDE_MODULE', '-O0'], False), + 'legal_O0': (['-sLEGALIZE_JS_FFI=1', '-sWARN_ON_UNDEFINED_SYMBOLS=0', '-O0'], True), + 'nolegal_O0': (['-sLEGALIZE_JS_FFI=0', '-sWARN_ON_UNDEFINED_SYMBOLS=0', '-O0'], False), + }) + def test_legalize_js_ffi(self, args, js_ffi): + # test disabling of JS FFI legalization when not using bigint + print(args) + delete_file('a.out.wasm') + cmd = [EMCC, test_file('other/ffi.c'), '-g', '-o', 'a.out.wasm'] + args + print(' '.join(cmd)) + self.run_process(cmd) + text = self.get_wasm_text('a.out.wasm') + # remove internal comments and extra whitespace + text = re.sub(r'\(;[^;]+;\)', '', text) + text = re.sub(r'\$var\$*.', '', text) + text = re.sub(r'param \$\d+', 'param ', text) + text = re.sub(r' +', ' ', text) + e_add_f32 = re.search(r'func \$add_f \(param f32\) \(param f32\) \(result f32\)', text) + assert e_add_f32, 'add_f export missing' + i_i64_i32 = re.search(r'import "env" "import_ll" .*\(param i32 i32\) \(result i32\)', text) + i_i64_i64 = re.search(r'import "env" "import_ll" .*\(param i64\) \(result i64\)', text) + e_i64_i32 = re.search(r'func \$legalstub\$add_ll \(param i32\) \(param i32\) \(param i32\) \(param i32\) \(result i32\)', text) + if js_ffi: + assert i_i64_i32, 'i64 not converted to i32 in imports' + assert not i_i64_i64, 'i64 not converted to i32 in imports' + assert e_i64_i32, 'i64 not converted to i32 in exports' + else: + assert not i_i64_i32, 'i64 converted to i32 in imports' + assert i_i64_i64, 'i64 converted to i32 in imports' + assert not e_i64_i32, 'i64 converted to i32 in exports' @disabled('https://github.com/WebAssembly/binaryen/pull/6428') def test_no_legalize_js_ffi(self): From 916b34e68679b663c625fdd6632de4f3fb9e2c3e Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 17 Dec 2024 10:37:19 -0800 Subject: [PATCH 087/132] rebaseline_tests.py: Add --new-branch and --clear-cache. NFC (#23192) --- tools/maint/rebaseline_tests.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/maint/rebaseline_tests.py b/tools/maint/rebaseline_tests.py index ac00ee04b422f..09c9455acf278 100755 --- a/tools/maint/rebaseline_tests.py +++ b/tools/maint/rebaseline_tests.py @@ -64,8 +64,13 @@ def process_changed_file(filename): def main(argv): parser = argparse.ArgumentParser() parser.add_argument('-s', '--skip-tests', action='store_true', help="don't actually run the tests, just analyze the existing results") + parser.add_argument('-b', '--new-branch', action='store_true', help='create a new branch containing the updates') + parser.add_argument('-c', '--clear-cache', action='store_true', help='clear the cache before rebaselining (useful when working with llvm changes)') args = parser.parse_args() + if args.clear_cache: + run(['emcc', '--clear-cache']) + if not args.skip_tests: if run(['git', 'status', '-uno', '--porcelain']).strip(): print('tree is not clean') @@ -91,6 +96,7 @@ def main(argv): The following ({len(filenames)}) test expectation files were updated by running the tests with `--rebaseline`: +``` ''' for file in filenames: @@ -98,7 +104,10 @@ def main(argv): commit_message += f'\nAverage change: {statistics.mean(all_deltas):+.2f}% ({min(all_deltas):+.2f}% - {max(all_deltas):+.2f}%)\n' - run(['git', 'checkout', '-b', 'rebaseline_tests']) + commit_message += '```\n' + + if args.new_branch: + run(['git', 'checkout', '-b', 'rebaseline_tests']) run(['git', 'add', '-u', '.']) run(['git', 'commit', '-F', '-'], input=commit_message) From 0f4d8b885caf1f2dd2c22ae8267fbd0c0a550705 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 17 Dec 2024 19:42:46 +0100 Subject: [PATCH 088/132] Don't normalize path in PATH.basename() (#23180) This brings it in line with the behavior of basename im coreutils and node. --- ChangeLog.md | 5 +++++ src/library_path.js | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index ffbe23ccb3f95..05d25fe02c842 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -20,6 +20,11 @@ See docs/process.md for more on how version tagging works. 3.1.75 (in development) ----------------------- +- `PATH.basename()` no longer calls `PATH.normalize()`, so that + `PATH.basename("a/.")` returns `"."` instead of `"a"` and + `PATH.basename("a/b/..")` returns `".."` instead of `"a"`. This is in line with + the behaviour of both node and coreutils, and is already the case when using + NODERAWFS". (#23180) 3.1.74 - 12/14/24 ----------------- diff --git a/src/library_path.js b/src/library_path.js index ab3112503a202..fd5fec3dc2c46 100644 --- a/src/library_path.js +++ b/src/library_path.js @@ -64,10 +64,9 @@ addToLibrary({ return root + dir; }, basename: (path) => { - // EMSCRIPTEN return '/'' for '/', not an empty string + // EMSCRIPTEN return '/' for '/', not an empty string if (path === '/') return '/'; - path = PATH.normalize(path); - path = path.replace(/\/$/, ""); + path = path.replace(/\/+$/g, ""); var lastSlash = path.lastIndexOf('/'); if (lastSlash === -1) return path; return path.substr(lastSlash+1); From 951f59b1ae7a991d2f1cc0dd998cf5b7e92ba61d Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 17 Dec 2024 10:45:11 -0800 Subject: [PATCH 089/132] Automatic rebaseline of codesize expectations. NFC (#23199) This is an automatic change generated by tools/maint/rebaseline_tests.py. The following (17) test expectation files were updated by running the tests with `--rebaseline`: ``` other/codesize/test_codesize_cxx_ctors1.gzsize: 8542 => 8539 [-3 bytes / -0.04%] other/codesize/test_codesize_cxx_ctors1.jssize: 20925 => 20918 [-7 bytes / -0.03%] other/codesize/test_codesize_cxx_ctors2.gzsize: 8526 => 8523 [-3 bytes / -0.04%] other/codesize/test_codesize_cxx_ctors2.jssize: 20893 => 20886 [-7 bytes / -0.03%] other/codesize/test_codesize_cxx_except.gzsize: 9572 => 9568 [-4 bytes / -0.04%] other/codesize/test_codesize_cxx_except.jssize: 24770 => 24764 [-6 bytes / -0.02%] other/codesize/test_codesize_cxx_except_wasm.gzsize: 8503 => 8500 [-3 bytes / -0.04%] other/codesize/test_codesize_cxx_except_wasm.jssize: 20819 => 20813 [-6 bytes / -0.03%] other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize: 8503 => 8500 [-3 bytes / -0.04%] other/codesize/test_codesize_cxx_except_wasm_exnref.jssize: 20819 => 20813 [-6 bytes / -0.03%] other/codesize/test_codesize_cxx_lto.gzsize: 8440 => 8437 [-3 bytes / -0.04%] other/codesize/test_codesize_cxx_lto.jssize: 20504 => 20498 [-6 bytes / -0.03%] other/codesize/test_codesize_cxx_mangle.gzsize: 9573 => 9571 [-2 bytes / -0.02%] other/codesize/test_codesize_cxx_mangle.jssize: 24770 => 24764 [-6 bytes / -0.02%] other/codesize/test_codesize_cxx_noexcept.gzsize: 8542 => 8539 [-3 bytes / -0.04%] other/codesize/test_codesize_cxx_noexcept.jssize: 20925 => 20918 [-7 bytes / -0.03%] other/codesize/test_codesize_files_js_fs.jssize: 18832 => 18826 [-6 bytes / -0.03%] Average change: -0.03% (-0.04% - -0.02%) ``` --- test/other/codesize/test_codesize_cxx_ctors1.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors1.jssize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.jssize | 2 +- test/other/codesize/test_codesize_cxx_except.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.jssize | 2 +- test/other/codesize/test_codesize_cxx_mangle.gzsize | 2 +- test/other/codesize/test_codesize_cxx_mangle.jssize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.gzsize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.jssize | 2 +- test/other/codesize/test_codesize_files_js_fs.jssize | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 372dd800a6664..33778bf0dfb68 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8542 +8539 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index 4792957645ab9..05d7f0e33f5ee 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20925 +20918 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index f4bd3f09e60d0..bb7cd0078dd57 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8526 +8523 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index be622c05e5cf1..566d1b56cc0f1 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20893 +20886 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 76c2119667336..78c463ebdb2af 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9572 +9568 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 883a0b6975b4a..76dd74ecfa2c8 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24770 +24764 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index c58231813b792..b28927a921976 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8503 +8500 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index a2cafeab8aabf..7687b3f294045 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20819 +20813 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index c58231813b792..b28927a921976 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8503 +8500 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index a2cafeab8aabf..7687b3f294045 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20819 +20813 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 8712958ff9448..999e653c7bdce 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8440 +8437 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index ce0e8ed643da7..c3701654a97fc 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20504 +20498 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index 0fd7b9f8eaa2e..3f1fc91b01d65 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9573 +9571 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 883a0b6975b4a..76dd74ecfa2c8 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24770 +24764 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 372dd800a6664..33778bf0dfb68 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8542 +8539 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index 4792957645ab9..05d7f0e33f5ee 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20925 +20918 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index 313631805fc95..332ae63d9f0c3 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18832 +18826 From 6fa576b70f85758b44bba09066d65ce39b6b5f68 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 17 Dec 2024 10:58:56 -0800 Subject: [PATCH 090/132] Bump Binaryen to 120 (#23197) https://github.com/WebAssembly/binaryen/pull/7153 updated Binaryen version to 121, but bumping the version to 121 here does not pass the CI (because Binaryen version is behind by 2), so this updates the version to 120 for the moment. --- tools/building.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/building.py b/tools/building.py index d5b018d758476..d762304920a90 100644 --- a/tools/building.py +++ b/tools/building.py @@ -39,7 +39,7 @@ # Building binaryen_checked = False -EXPECTED_BINARYEN_VERSION = 119 +EXPECTED_BINARYEN_VERSION = 120 _is_ar_cache: Dict[str, bool] = {} # the exports the user requested From c17479b0c001d41eb60b7b18c8945dc32226b8f9 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 17 Dec 2024 11:19:02 -0800 Subject: [PATCH 091/132] [test] Add new decorators for running tests under different FS backends (#23177) - @with_all_fs - @also_with_nodefs - @also_with_nodefs_both --- src/polyfill/atob.js | 1 + test/common.py | 87 ++++++++++++++++++-- test/test_core.py | 189 +++++++++++++------------------------------ test/test_other.py | 6 +- test/unistd/links.c | 6 +- 5 files changed, 144 insertions(+), 145 deletions(-) diff --git a/src/polyfill/atob.js b/src/polyfill/atob.js index 5de121d14a13f..4626cb72a1f1f 100644 --- a/src/polyfill/atob.js +++ b/src/polyfill/atob.js @@ -14,6 +14,7 @@ if (typeof atob == 'undefined') { if (typeof global != 'undefined' && typeof globalThis == 'undefined') { + /** @suppress{checkTypes} */ globalThis = global; } diff --git a/test/common.py b/test/common.py index 8ff05424e146f..7f5844adac982 100644 --- a/test/common.py +++ b/test/common.py @@ -379,8 +379,9 @@ def metafunc(self, wasmfs, *args, **kwargs): if DEBUG: print('parameterize:wasmfs=%d' % wasmfs) if wasmfs: - self.set_setting('WASMFS') - self.emcc_args.append('-DWASMFS') + self.setup_wasmfs_test() + else: + self.emcc_args += ['-DMEMFS'] f(self, *args, **kwargs) parameterize(metafunc, {'': (False,), @@ -388,6 +389,68 @@ def metafunc(self, wasmfs, *args, **kwargs): return metafunc +def also_with_nodefs(func): + @wraps(func) + def metafunc(self, fs, *args, **kwargs): + if DEBUG: + print('parameterize:fs=%s' % (fs)) + if fs == 'nodefs': + self.setup_nodefs_test() + else: + self.emcc_args += ['-DMEMFS'] + assert fs is None + func(self, *args, **kwargs) + + parameterize(metafunc, {'': (None,), + 'nodefs': ('nodefs',)}) + return metafunc + + +def also_with_nodefs_both(func): + @wraps(func) + def metafunc(self, fs, *args, **kwargs): + if DEBUG: + print('parameterize:fs=%s' % (fs)) + if fs == 'nodefs': + self.setup_nodefs_test() + elif fs == 'rawfs': + self.setup_noderawfs_test() + else: + self.emcc_args += ['-DMEMFS'] + assert fs is None + func(self, *args, **kwargs) + + parameterize(metafunc, {'': (None,), + 'nodefs': ('nodefs',), + 'rawfs': ('rawfs',)}) + return metafunc + + +def with_all_fs(func): + @wraps(func) + def metafunc(self, fs, *args, **kwargs): + if DEBUG: + print('parameterize:fs=%s' % (fs)) + if fs == 'nodefs': + self.setup_nodefs_test() + elif fs == 'rawfs': + self.setup_noderawfs_test() + elif fs == 'wasmfs': + self.setup_wasmfs_test() + else: + self.emcc_args += ['-DMEMFS'] + assert fs is None + func(self, *args, **kwargs) + + # TODO(sbc): rather than treat WASMFS as orthogonal we should + # probably make it combinatorial with nodefs and noderawfs. + parameterize(metafunc, {'': (None,), + 'nodefs': ('nodefs',), + 'rawfs': ('rawfs',), + 'wasmfs': ('wasmfs',)}) + return metafunc + + def also_with_noderawfs(func): assert callable(func) @@ -396,9 +459,9 @@ def metafunc(self, rawfs, *args, **kwargs): if DEBUG: print('parameterize:rawfs=%d' % rawfs) if rawfs: - self.require_node() - self.emcc_args += ['-DNODERAWFS'] - self.set_setting('NODERAWFS') + self.setup_noderawfs_test() + else: + self.emcc_args += ['-DMEMFS'] func(self, *args, **kwargs) parameterize(metafunc, {'': (False,), @@ -1025,7 +1088,19 @@ def require_wasm2js(self): def setup_nodefs_test(self): self.require_node() - self.emcc_args += ['-lnodefs.js', '--pre-js', test_file('setup_nodefs.js')] + if self.get_setting('WASMFS'): + # without this the JS setup code in setup_nodefs.js doesn't work + self.set_setting('FORCE_FILESYSTEM') + self.emcc_args += ['-DNODEFS', '-lnodefs.js', '--pre-js', test_file('setup_nodefs.js')] + + def setup_noderawfs_test(self): + self.require_node() + self.emcc_args += ['-DNODERAWFS'] + self.set_setting('NODERAWFS') + + def setup_wasmfs_test(self): + self.set_setting('WASMFS') + self.emcc_args += ['-DWASMFS'] def setup_node_pthreads(self): self.require_node() diff --git a/test/test_core.py b/test/test_core.py index 930bbda052810..a60f946740009 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -27,7 +27,7 @@ from common import env_modify, with_env_modify, disabled, flaky, node_pthreads, also_with_wasm_bigint from common import read_file, read_binary, requires_v8, requires_node, requires_wasm2js, requires_node_canary from common import compiler_for, crossplatform, no_4gb, no_2gb, also_with_minimal_runtime -from common import also_with_noderawfs, also_with_wasmfs +from common import with_all_fs, also_with_nodefs, also_with_nodefs_both, also_with_noderawfs, also_with_wasmfs from common import with_all_eh_sjlj, with_all_sjlj, also_with_standalone_wasm, can_do_standalone, no_wasm64, requires_wasm_exnref from common import NON_ZERO, WEBIDL_BINDER, EMBUILDER, PYTHON import clang_native @@ -5389,15 +5389,9 @@ def test_proc_self_fd(self): def test_fwrite_0(self): self.do_core_test('test_fwrite_0.c') - @parameterized({ - '': (['MEMFS']), - 'nodefs': (['NODEFS']) - }) - def test_fgetc_ungetc(self, fs): + @also_with_nodefs_both + def test_fgetc_ungetc(self): print('TODO: update this test once the musl ungetc-on-EOF-stream bug is fixed upstream and reaches us') - self.emcc_args += ['-D' + fs] - if fs == 'NODEFS': - self.setup_nodefs_test() self.do_runf('stdio/test_fgetc_ungetc.c', 'success') def test_fgetc_unsigned(self): @@ -5770,21 +5764,11 @@ def test_fs_enotdir(self): def test_fs_append(self): self.do_runf('fs/test_append.c', 'success') - @parameterized({ - '': ['MEMFS'], - 'nodefs': ['NODEFS'], - 'noderaswfs': ['NODERAWFS'], - 'wasmfs': ['WASMFS'] - }) - def test_fs_mmap(self, fs): - if fs == 'NODEFS': - self.setup_nodefs_test() - if fs == 'NODERAWFS': - self.require_node() - self.emcc_args += ['-lnodefs.js', '-lnoderawfs.js'] - if fs == 'WASMFS': - self.emcc_args += ['-sWASMFS', '-sFORCE_FILESYSTEM'] - self.do_run_in_out_file_test('fs/test_mmap.c', emcc_args=['-D' + fs]) + @with_all_fs + def test_fs_mmap(self): + if self.get_setting('WASMFS'): + self.set_setting('FORCE_FILESYSTEM') + self.do_run_in_out_file_test('fs/test_mmap.c') @no_wasmfs('wasmfs will (?) need a non-JS mechanism to ignore permissions during startup') @parameterized({ @@ -5856,34 +5840,23 @@ def test_fs_64bit(self): @requires_node @crossplatform - @parameterized({ - '': ([],), - 'nodefs': (['-DNODEFS', '-lnodefs.js'],), - 'noderawfs': (['-sNODERAWFS'],), - }) - def test_fs_symlink_resolution(self, args): - nodefs = '-DNODEFS' in args or '-sNODERAWFS' in args - if nodefs and WINDOWS: - self.skipTest('No symlinks on Windows') + @with_all_fs + def test_fs_symlink_resolution(self): + nodefs = '-DNODEFS' in self.emcc_args or '-DNODERAWFS' in self.emcc_args if self.get_setting('WASMFS'): - if nodefs: - self.skipTest('NODEFS in WasmFS') self.set_setting('FORCE_FILESYSTEM') - if '-DNODEFS' in args: - self.setup_nodefs_test() - self.do_runf('fs/test_fs_symlink_resolution.c', 'success', emcc_args=args) + if nodefs: + if WINDOWS: + self.skipTest('No symlinks on Windows') + if self.get_setting('WASMFS'): + self.skipTest('NODEFS in WasmFS') + self.do_runf('fs/test_fs_symlink_resolution.c', 'success') - @parameterized({ - '': ([],), - 'nodefs': (['-DNODEFS', '-lnodefs.js'],), - 'noderawfs': (['-sNODERAWFS'],) - }) - def test_fs_rename_on_existing(self, args): + @with_all_fs + def test_fs_rename_on_existing(self): if self.get_setting('WASMFS'): self.set_setting('FORCE_FILESYSTEM') - if '-DNODEFS' in args: - self.setup_nodefs_test() - self.do_runf('fs/test_fs_rename_on_existing.c', 'success', emcc_args=args) + self.do_runf('fs/test_fs_rename_on_existing.c', 'success') def test_sigalrm(self): self.do_runf('test_sigalrm.c', 'Received alarm!') @@ -5908,29 +5881,21 @@ def test_sigaction_default(self, signal, exit_code, assert_identical): assert_returncode=exit_code ) - @requires_node @crossplatform - @parameterized({ - '': (['-DMEMFS'],), - 'nodefs': (['-DNODEFS', '-lnodefs.js'],), - 'noderawfs': (['-DNODERAWFS', '-sNODERAWFS'],) - }) - def test_unistd_access(self, args): - self.emcc_args += args - nodefs = '-DNODEFS' in args or '-DNODERAWFS' in args + @also_with_nodefs_both + def test_unistd_access(self): + nodefs = '-DNODEFS' in self.emcc_args or '-DNODERAWFS' in self.emcc_args if self.get_setting('WASMFS'): + self.set_setting('FORCE_FILESYSTEM') if nodefs: self.skipTest('NODEFS in WasmFS') - self.emcc_args += ['-sFORCE_FILESYSTEM'] - if '-DNODEFS' in args: - self.setup_nodefs_test() # On windows we have slighly different output because we the same # level of permissions are not available. For example, on windows # its not possible have a file that is not readable, but writable. # We also report all files as executable since there is no x bit # recorded there. # See https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/chmod-wchmod?view=msvc-170#remarks - if WINDOWS and '-DNODERAWFS' in args: + if WINDOWS and '-DNODERAWFS' in self.emcc_args: out_suffix = '.win' else: out_suffix = '' @@ -5956,27 +5921,15 @@ def test_unistd_pipe(self): def test_unistd_dup(self): self.do_run_in_out_file_test('unistd/dup.c') - @parameterized({ - '': (['MEMFS']), - 'nodefs': (['NODEFS']) - }) - def test_unistd_truncate(self, fs): - orig_compiler_opts = self.emcc_args.copy() - self.emcc_args = orig_compiler_opts + ['-D' + fs] + @with_all_fs + def test_unistd_truncate(self): + nodefs = '-DNODEFS' in self.emcc_args or '-DNODERAWFS' in self.emcc_args if self.get_setting('WASMFS'): - if fs == 'NODEFS': + self.set_setting('FORCE_FILESYSTEM') + if nodefs: self.skipTest('TODO: NODEFS in WasmFS') - self.emcc_args += ['-sFORCE_FILESYSTEM'] - if fs == 'NODEFS': - self.setup_nodefs_test() - self.do_run_in_out_file_test('unistd/truncate.c') - - @no_windows("Windows throws EPERM rather than EACCES or EINVAL") - @unittest.skipIf(WINDOWS or os.geteuid() == 0, "Root access invalidates this test by being able to write on readonly files") - @requires_node - def test_unistd_truncate_noderawfs(self): - self.set_setting('NODERAWFS') - self.maybe_closure() + if WINDOWS or os.geteuid() == 0: + self.skipTest('Root access invalidates this test by being able to write on readonly files') self.do_run_in_out_file_test('unistd/truncate.c') @also_with_standalone_wasm() @@ -6004,22 +5957,15 @@ def test_unistd_sysconf_phys_pages(self): self.do_runf(filename, str(expected) + ', errno: 0') @no_windows('https://github.com/emscripten-core/emscripten/issues/8882') - @parameterized({ - '': (['MEMFS']), - 'nodefs': (['NODEFS']), - 'noderawfs': (['NODERAWFS']), - }) - def test_unistd_unlink(self, fs): - if fs in ('NODEFS', 'NODERAWFS'): - self.require_node() - if self.get_setting('WASMFS'): - self.skipTest('NODEFS in WasmFS') + @with_all_fs + def test_unistd_unlink(self): + nodefs = '-DNODEFS' in self.emcc_args or '-DNODERAWFS' in self.emcc_args + if self.get_setting('WASMFS') and nodefs: + self.skipTest('NODEFS in WasmFS') - self.emcc_args += ['-D' + fs] # symlinks on node.js on non-linux behave differently (e.g. on Windows they require administrative privileges) # so skip testing those bits on that combination. - if fs == 'NODEFS': - self.emcc_args += ['-lnodefs.js'] + if '-DNODEFS' in self.emcc_args: if WINDOWS: self.emcc_args += ['-DNO_SYMLINK=1'] if MACOS: @@ -6027,35 +5973,27 @@ def test_unistd_unlink(self, fs): # Several differences/bugs on non-linux including https://github.com/nodejs/node/issues/18014 # TODO: NODERAWFS in WasmFS - if fs == 'NODERAWFS': - self.set_setting('NODERAWFS') + if '-DNODERAWFS' in self.emcc_args and os.geteuid() == 0: # 0 if root user - if os.geteuid() == 0: - self.emcc_args += ['-DSKIP_ACCESS_TESTS'] - if fs == 'NODEFS': - self.setup_nodefs_test() + self.emcc_args += ['-DSKIP_ACCESS_TESTS'] self.do_runf('unistd/unlink.c', 'success') - @parameterized({ - '': ([], False), - 'nodefs': (['-DNODEFS', '-lnodefs.js'], True) - }) - def test_unistd_links(self, args, nodefs): - if nodefs: - self.require_node() - if WINDOWS: - self.skipTest('Skipping NODEFS part of this test for test_unistd_links on Windows, since it would require administrative privileges.') - # Also, other detected discrepancies if you do end up running this test on NODEFS: - # test expects /, but Windows gives \ as path slashes. - # Calling readlink() on a non-link gives error 22 EINVAL on Unix, but simply error 0 OK on Windows. + @also_with_nodefs + def test_unistd_links(self): + nodefs = '-DNODEFS' in self.emcc_args + if nodefs and WINDOWS: + self.skipTest('Skipping NODEFS part of this test for test_unistd_links on Windows, since it would require administrative privileges.') + # Also, other detected discrepancies if you do end up running this test on NODEFS: + # test expects /, but Windows gives \ as path slashes. + # Calling readlink() on a non-link gives error 22 EINVAL on Unix, but simply error 0 OK on Windows. if self.get_setting('WASMFS'): if nodefs: self.skipTest('TODO: wasmfs+node') self.emcc_args += ['-sFORCE_FILESYSTEM'] - self.do_run_in_out_file_test('unistd/links.c', emcc_args=args) + self.do_run_in_out_file_test('unistd/links.c') @also_with_noderawfs def test_unistd_write_broken_link(self): @@ -6071,30 +6009,17 @@ def test_unistd_symlink_on_nodefs(self): self.do_run_in_out_file_test('unistd/symlink_on_nodefs.c') @also_with_wasm_bigint + @also_with_nodefs def test_unistd_io(self): - orig_compiler_opts = self.emcc_args.copy() - for fs in ('MEMFS', 'NODEFS'): - self.clear() - self.emcc_args = orig_compiler_opts + ['-D' + fs] - if fs == 'NODEFS': - self.emcc_args += ['-lnodefs.js'] - self.require_node() - if self.get_setting('WASMFS'): - if fs == 'NODEFS': - # TODO: NODEFS in WasmFS - continue - self.emcc_args += ['-sFORCE_FILESYSTEM'] - self.do_run_in_out_file_test('unistd/io.c') + if self.get_setting('WASMFS'): + if '-DNODEFS' in self.emcc_args: + self.skipTest('NODEFS in WasmFS') + self.set_setting('FORCE_FILESYSTEM') + self.do_run_in_out_file_test('unistd/io.c') @no_windows('https://github.com/emscripten-core/emscripten/issues/8882') - @parameterized({ - '': (['MEMFS']), - 'nodefs': (['NODEFS']), - }) - def test_unistd_misc(self, fs): - self.emcc_args += ['-D' + fs] - if fs == 'NODEFS': - self.setup_nodefs_test() + @also_with_nodefs + def test_unistd_misc(self): self.do_run_in_out_file_test('unistd/misc.c', interleaved_output=False) @also_with_standalone_wasm() diff --git a/test/test_other.py b/test/test_other.py index 3adbe4b84ad59..e44c647af12a6 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -115,8 +115,7 @@ def wasmfs_all_backends(f): @wraps(f) def metafunc(self, backend, *args, **kwargs): - self.set_setting('WASMFS') - self.emcc_args.append('-DWASMFS') + self.setup_wasmfs_test() self.emcc_args.append(f'-D{backend}') f(self, *args, **kwargs) @@ -131,8 +130,7 @@ def also_with_wasmfs_all_backends(f): @wraps(f) def metafunc(self, backend, *args, **kwargs): if backend: - self.set_setting('WASMFS') - self.emcc_args.append('-DWASMFS') + self.setup_wasmfs_test() self.emcc_args.append(f'-D{backend}') f(self, *args, **kwargs) diff --git a/test/unistd/links.c b/test/unistd/links.c index 81de30c60b2be..718578359ba06 100644 --- a/test/unistd/links.c +++ b/test/unistd/links.c @@ -41,11 +41,11 @@ void changedir(const char *dir) { } void setup() { - makedir("working"); + makedir("/working"); #if defined(__EMSCRIPTEN__) && defined(NODEFS) - EM_ASM(FS.mount(NODEFS, { root: '.' }, 'working')); + EM_ASM(FS.mount(NODEFS, { root: '.' }, '/working')); #endif - changedir("working"); + changedir("/working"); makelink("../test/../there!", "link"); makefile("file", "test"); makedir("directory"); From 9148ca033bc8128e75697ac6b704f18805d51eed Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 17 Dec 2024 12:31:36 -0800 Subject: [PATCH 092/132] Remove unnecessary `shouldRunNow` global variable. NFC (#23191) --- src/postamble.js | 19 +++---------------- test/browser/test_small_js_flags.js.size | 2 +- .../codesize/test_codesize_cxx_ctors1.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors1.jssize | 2 +- .../codesize/test_codesize_cxx_ctors2.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors2.jssize | 2 +- .../codesize/test_codesize_cxx_except.gzsize | 2 +- .../codesize/test_codesize_cxx_except.jssize | 2 +- .../test_codesize_cxx_except_wasm.gzsize | 2 +- .../test_codesize_cxx_except_wasm.jssize | 2 +- ...est_codesize_cxx_except_wasm_exnref.gzsize | 2 +- ...est_codesize_cxx_except_wasm_exnref.jssize | 2 +- .../codesize/test_codesize_cxx_lto.gzsize | 2 +- .../codesize/test_codesize_cxx_lto.jssize | 2 +- .../codesize/test_codesize_cxx_mangle.gzsize | 2 +- .../codesize/test_codesize_cxx_mangle.jssize | 2 +- .../test_codesize_cxx_noexcept.gzsize | 2 +- .../test_codesize_cxx_noexcept.jssize | 2 +- .../codesize/test_codesize_cxx_wasmfs.gzsize | 2 +- .../codesize/test_codesize_cxx_wasmfs.jssize | 2 +- .../codesize/test_codesize_files_js_fs.gzsize | 2 +- .../codesize/test_codesize_files_js_fs.jssize | 2 +- .../test_codesize_files_wasmfs.gzsize | 2 +- .../test_codesize_files_wasmfs.jssize | 2 +- .../codesize/test_codesize_hello_O0.gzsize | 2 +- .../codesize/test_codesize_hello_O0.jssize | 2 +- .../codesize/test_codesize_hello_O1.gzsize | 2 +- .../codesize/test_codesize_hello_O1.jssize | 2 +- .../codesize/test_codesize_hello_O2.gzsize | 2 +- .../codesize/test_codesize_hello_O2.jssize | 2 +- .../codesize/test_codesize_hello_O3.gzsize | 2 +- .../codesize/test_codesize_hello_O3.jssize | 2 +- .../codesize/test_codesize_hello_Os.gzsize | 2 +- .../codesize/test_codesize_hello_Os.jssize | 2 +- .../codesize/test_codesize_hello_Oz.gzsize | 2 +- .../codesize/test_codesize_hello_Oz.jssize | 2 +- .../test_codesize_hello_dylink.gzsize | 2 +- .../test_codesize_hello_dylink.jssize | 2 +- .../test_codesize_hello_wasmfs.gzsize | 2 +- .../test_codesize_hello_wasmfs.jssize | 2 +- .../test_codesize_libcxxabi_message_O3.gzsize | 2 +- .../test_codesize_libcxxabi_message_O3.jssize | 2 +- ...ize_libcxxabi_message_O3_standalone.gzsize | 2 +- ...ize_libcxxabi_message_O3_standalone.jssize | 2 +- .../codesize/test_codesize_mem_O3.gzsize | 2 +- .../codesize/test_codesize_mem_O3.jssize | 2 +- .../codesize/test_codesize_mem_O3_grow.gzsize | 2 +- .../codesize/test_codesize_mem_O3_grow.jssize | 2 +- ...est_codesize_mem_O3_grow_standalone.gzsize | 2 +- ...est_codesize_mem_O3_grow_standalone.jssize | 2 +- .../test_codesize_mem_O3_standalone.gzsize | 2 +- .../test_codesize_mem_O3_standalone.jssize | 2 +- ...test_codesize_mem_O3_standalone_lib.gzsize | 2 +- ...test_codesize_mem_O3_standalone_lib.jssize | 2 +- ...est_codesize_mem_O3_standalone_narg.gzsize | 2 +- ...est_codesize_mem_O3_standalone_narg.jssize | 2 +- ...odesize_mem_O3_standalone_narg_flto.gzsize | 2 +- ...odesize_mem_O3_standalone_narg_flto.jssize | 2 +- .../test_codesize_minimal_pthreads.gzsize | 2 +- .../test_codesize_minimal_pthreads.jssize | 2 +- test/other/test_unoptimized_code_size.js.size | 2 +- ...t_unoptimized_code_size_no_asserts.js.size | 2 +- .../test_unoptimized_code_size_strict.js.size | 2 +- 63 files changed, 65 insertions(+), 78 deletions(-) diff --git a/src/postamble.js b/src/postamble.js index 644d6509864e4..0896e0c3f7e93 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -202,10 +202,11 @@ function run() { #endif #if HAS_MAIN + {{{ makeModuleReceiveWithVar('noInitialRun', undefined, !INVOKE_RUN) }}} #if MAIN_READS_PARAMS - if (shouldRunNow) callMain(args); + if (!noInitialRun) callMain(args); #else - if (shouldRunNow) callMain(); + if (!noInitialRun) callMain(); #endif #else #if ASSERTIONS @@ -298,20 +299,6 @@ if (Module['preInit']) { } #endif -#if HAS_MAIN -// shouldRunNow refers to calling main(), not run(). -#if INVOKE_RUN -var shouldRunNow = true; -#else -var shouldRunNow = false; -#endif - -#if expectToReceiveOnModule('noInitialRun') -if (Module['noInitialRun']) shouldRunNow = false; -#endif - -#endif // HAS_MAIN - run(); #if BUILD_AS_WORKER diff --git a/test/browser/test_small_js_flags.js.size b/test/browser/test_small_js_flags.js.size index 928819ed1470b..c318f0c61d4fd 100644 --- a/test/browser/test_small_js_flags.js.size +++ b/test/browser/test_small_js_flags.js.size @@ -1 +1 @@ -4345 +4327 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 33778bf0dfb68..7997926125d8f 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8539 +8529 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index 05d7f0e33f5ee..bcbc4c25b77ef 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20918 +20897 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index bb7cd0078dd57..b40b6a0fd0a30 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8523 +8514 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 566d1b56cc0f1..700e855809bbf 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20886 +20865 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 78c463ebdb2af..92aedca0f1608 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9568 +9561 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 76dd74ecfa2c8..d03c402d5ef1e 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24764 +24743 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index b28927a921976..c37d7a8c7497c 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8500 +8488 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index 7687b3f294045..6416addfb79a1 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20813 +20791 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index b28927a921976..c37d7a8c7497c 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8500 +8488 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index 7687b3f294045..6416addfb79a1 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20813 +20791 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 999e653c7bdce..1ee83bdf06f73 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8437 +8428 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index c3701654a97fc..1b3592654f517 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20498 +20477 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index 3f1fc91b01d65..8c22ca2a0d9bb 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9571 +9563 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 76dd74ecfa2c8..d03c402d5ef1e 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24764 +24743 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 33778bf0dfb68..7997926125d8f 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8539 +8529 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index 05d7f0e33f5ee..bcbc4c25b77ef 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20918 +20897 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize index 4ccb19fe6a616..831c634228d7c 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize @@ -1 +1 @@ -3802 +3792 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.jssize b/test/other/codesize/test_codesize_cxx_wasmfs.jssize index d9d8063900671..ae09fe17eadb6 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.jssize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.jssize @@ -1 +1 @@ -8562 +8541 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index edd0488a70a87..4cea879e1407b 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7679 +7666 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index 332ae63d9f0c3..2698b0cefab12 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18826 +18805 diff --git a/test/other/codesize/test_codesize_files_wasmfs.gzsize b/test/other/codesize/test_codesize_files_wasmfs.gzsize index eb6dfd83a21e8..1dea9fded90ce 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_files_wasmfs.gzsize @@ -1 +1 @@ -2897 +2887 diff --git a/test/other/codesize/test_codesize_files_wasmfs.jssize b/test/other/codesize/test_codesize_files_wasmfs.jssize index 725bb9700b2e6..7ad6b3d0b1c75 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.jssize +++ b/test/other/codesize/test_codesize_files_wasmfs.jssize @@ -1 +1 @@ -6203 +6183 diff --git a/test/other/codesize/test_codesize_hello_O0.gzsize b/test/other/codesize/test_codesize_hello_O0.gzsize index 42b603432aefe..274eb1a125e42 100644 --- a/test/other/codesize/test_codesize_hello_O0.gzsize +++ b/test/other/codesize/test_codesize_hello_O0.gzsize @@ -1 +1 @@ -8017 +8020 diff --git a/test/other/codesize/test_codesize_hello_O0.jssize b/test/other/codesize/test_codesize_hello_O0.jssize index 59deaf245ee60..deb732ca28856 100644 --- a/test/other/codesize/test_codesize_hello_O0.jssize +++ b/test/other/codesize/test_codesize_hello_O0.jssize @@ -1 +1 @@ -21521 +21550 diff --git a/test/other/codesize/test_codesize_hello_O1.gzsize b/test/other/codesize/test_codesize_hello_O1.gzsize index f1349afff39a3..3f080eeb6ec84 100644 --- a/test/other/codesize/test_codesize_hello_O1.gzsize +++ b/test/other/codesize/test_codesize_hello_O1.gzsize @@ -1 +1 @@ -2753 +2738 diff --git a/test/other/codesize/test_codesize_hello_O1.jssize b/test/other/codesize/test_codesize_hello_O1.jssize index c244fa7913935..bd48f22f2d557 100644 --- a/test/other/codesize/test_codesize_hello_O1.jssize +++ b/test/other/codesize/test_codesize_hello_O1.jssize @@ -1 +1 @@ -6998 +6970 diff --git a/test/other/codesize/test_codesize_hello_O2.gzsize b/test/other/codesize/test_codesize_hello_O2.gzsize index 65b7a7f809ae5..7ccc3cde58017 100644 --- a/test/other/codesize/test_codesize_hello_O2.gzsize +++ b/test/other/codesize/test_codesize_hello_O2.gzsize @@ -1 +1 @@ -2402 +2388 diff --git a/test/other/codesize/test_codesize_hello_O2.jssize b/test/other/codesize/test_codesize_hello_O2.jssize index f9d8cb95dd8ce..e267c8a08a441 100644 --- a/test/other/codesize/test_codesize_hello_O2.jssize +++ b/test/other/codesize/test_codesize_hello_O2.jssize @@ -1 +1 @@ -4911 +4891 diff --git a/test/other/codesize/test_codesize_hello_O3.gzsize b/test/other/codesize/test_codesize_hello_O3.gzsize index ebc926ef1d463..719b586a2fdb2 100644 --- a/test/other/codesize/test_codesize_hello_O3.gzsize +++ b/test/other/codesize/test_codesize_hello_O3.gzsize @@ -1 +1 @@ -2312 +2307 diff --git a/test/other/codesize/test_codesize_hello_O3.jssize b/test/other/codesize/test_codesize_hello_O3.jssize index 44d8a72de1a38..a7351f2c7998a 100644 --- a/test/other/codesize/test_codesize_hello_O3.jssize +++ b/test/other/codesize/test_codesize_hello_O3.jssize @@ -1 +1 @@ -4758 +4738 diff --git a/test/other/codesize/test_codesize_hello_Os.gzsize b/test/other/codesize/test_codesize_hello_Os.gzsize index ebc926ef1d463..719b586a2fdb2 100644 --- a/test/other/codesize/test_codesize_hello_Os.gzsize +++ b/test/other/codesize/test_codesize_hello_Os.gzsize @@ -1 +1 @@ -2312 +2307 diff --git a/test/other/codesize/test_codesize_hello_Os.jssize b/test/other/codesize/test_codesize_hello_Os.jssize index 44d8a72de1a38..a7351f2c7998a 100644 --- a/test/other/codesize/test_codesize_hello_Os.jssize +++ b/test/other/codesize/test_codesize_hello_Os.jssize @@ -1 +1 @@ -4758 +4738 diff --git a/test/other/codesize/test_codesize_hello_Oz.gzsize b/test/other/codesize/test_codesize_hello_Oz.gzsize index 0f6991adc91e5..f0e709d5b3d2f 100644 --- a/test/other/codesize/test_codesize_hello_Oz.gzsize +++ b/test/other/codesize/test_codesize_hello_Oz.gzsize @@ -1 +1 @@ -2295 +2288 diff --git a/test/other/codesize/test_codesize_hello_Oz.jssize b/test/other/codesize/test_codesize_hello_Oz.jssize index 63e5168563779..29a66372adae4 100644 --- a/test/other/codesize/test_codesize_hello_Oz.jssize +++ b/test/other/codesize/test_codesize_hello_Oz.jssize @@ -1 +1 @@ -4725 +4705 diff --git a/test/other/codesize/test_codesize_hello_dylink.gzsize b/test/other/codesize/test_codesize_hello_dylink.gzsize index d46a5eeb3db5b..a1c8982c1d6cd 100644 --- a/test/other/codesize/test_codesize_hello_dylink.gzsize +++ b/test/other/codesize/test_codesize_hello_dylink.gzsize @@ -1 +1 @@ -6191 +6180 diff --git a/test/other/codesize/test_codesize_hello_dylink.jssize b/test/other/codesize/test_codesize_hello_dylink.jssize index f1e6c6c03a1bc..c20c3c70546f8 100644 --- a/test/other/codesize/test_codesize_hello_dylink.jssize +++ b/test/other/codesize/test_codesize_hello_dylink.jssize @@ -1 +1 @@ -13684 +13662 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.gzsize b/test/other/codesize/test_codesize_hello_wasmfs.gzsize index ebc926ef1d463..719b586a2fdb2 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_hello_wasmfs.gzsize @@ -1 +1 @@ -2312 +2307 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.jssize b/test/other/codesize/test_codesize_hello_wasmfs.jssize index 44d8a72de1a38..a7351f2c7998a 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.jssize +++ b/test/other/codesize/test_codesize_hello_wasmfs.jssize @@ -1 +1 @@ -4758 +4738 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize index 675a793e3bb8f..01ec6ca892159 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize @@ -1 +1 @@ -1889 +1882 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize index 7565b177f4d23..fa07d868f2b60 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize @@ -1 +1 @@ -3995 +3977 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize index 348c7c2456b13..e37d15a094a6b 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize @@ -1 +1 @@ -1928 +1920 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize index 4a3a63211e267..130e6272e7397 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize @@ -1 +1 @@ -4043 +4025 diff --git a/test/other/codesize/test_codesize_mem_O3.gzsize b/test/other/codesize/test_codesize_mem_O3.gzsize index 8e6541741fb26..d61563f9298b0 100644 --- a/test/other/codesize/test_codesize_mem_O3.gzsize +++ b/test/other/codesize/test_codesize_mem_O3.gzsize @@ -1 +1 @@ -2349 +2336 diff --git a/test/other/codesize/test_codesize_mem_O3.jssize b/test/other/codesize/test_codesize_mem_O3.jssize index 546b2455bced4..94166f8c0392a 100644 --- a/test/other/codesize/test_codesize_mem_O3.jssize +++ b/test/other/codesize/test_codesize_mem_O3.jssize @@ -1 +1 @@ -4899 +4878 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.gzsize b/test/other/codesize/test_codesize_mem_O3_grow.gzsize index 445f349d2a0d7..a385b0c6e2512 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow.gzsize @@ -1 +1 @@ -2497 +2486 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.jssize b/test/other/codesize/test_codesize_mem_O3_grow.jssize index 7bcc8aba73720..045c1c6b12f7e 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow.jssize @@ -1 +1 @@ -5184 +5163 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize index 985179ce9b289..d1003cf584d87 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize @@ -1 +1 @@ -2192 +2183 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize index ecdf4f5ba87d5..3f04bd87eea47 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize @@ -1 +1 @@ -4592 +4571 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize index adcf4b878ee7d..6b16d006faa0f 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize @@ -1 +1 @@ -2158 +2148 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_standalone.jssize index 146f070cdcabf..8af91005b834b 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.jssize @@ -1 +1 @@ -4522 +4501 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize index a7568adae3387..c9ac2c6be7141 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize @@ -1 +1 @@ -1914 +1907 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize index 97a67bc728a46..1e7f3fa7c3927 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize @@ -1 +1 @@ -4042 +4024 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize index 348c7c2456b13..e37d15a094a6b 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize @@ -1 +1 @@ -1928 +1920 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize index 4a3a63211e267..130e6272e7397 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize @@ -1 +1 @@ -4043 +4025 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize index 348c7c2456b13..e37d15a094a6b 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize @@ -1 +1 @@ -1928 +1920 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize index 4a3a63211e267..130e6272e7397 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize @@ -1 +1 @@ -4043 +4025 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.gzsize b/test/other/codesize/test_codesize_minimal_pthreads.gzsize index 12e9c25ba4dd9..1e3e300877006 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.gzsize +++ b/test/other/codesize/test_codesize_minimal_pthreads.gzsize @@ -1 +1 @@ -4155 +4146 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.jssize b/test/other/codesize/test_codesize_minimal_pthreads.jssize index 6656d3eb40b5b..74e80adf8b955 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.jssize +++ b/test/other/codesize/test_codesize_minimal_pthreads.jssize @@ -1 +1 @@ -8612 +8594 diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index 261660aa0cc6e..d48e8ed1291a9 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -53979 +53946 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index 66cccdd3c3a0d..bd163cc4e1b0c 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -29399 +29317 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index 4898d969ef874..1cc3925c8f1fa 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -52775 +52768 From 78177f7ab2ad24f867dc7d9f52ddd583971e9c8f Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 17 Dec 2024 12:58:28 -0800 Subject: [PATCH 093/132] WasmFS: Enable wasm64.test_unistd_access under wasmfs (#23203) Fix the signatures of several native wasmfs exports. These are only needed/relevant under wasm64. --- test/test_core.py | 2 +- tools/emscripten.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/test/test_core.py b/test/test_core.py index a60f946740009..87d04cfdc1615 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5882,7 +5882,7 @@ def test_sigaction_default(self, signal, exit_code, assert_identical): ) @crossplatform - @also_with_nodefs_both + @with_all_fs def test_unistd_access(self): nodefs = '-DNODEFS' in self.emcc_args or '-DNODERAWFS' in self.emcc_args if self.get_setting('WASMFS'): diff --git a/tools/emscripten.py b/tools/emscripten.py index c60a3ee71c975..250432f5462f7 100644 --- a/tools/emscripten.py +++ b/tools/emscripten.py @@ -1066,6 +1066,9 @@ def create_pointer_conversion_wrappers(metadata): '__cxa_get_exception_ptr': 'pp', '_wasmfs_write_file': '_ppp', '_wasmfs_mknod': '_p__', + '_wasmfs_symlink': '_pp', + '_wasmfs_chmod': '_p_', + '_wasmfs_lchmod': '_p_', '_wasmfs_get_cwd': 'p_', '_wasmfs_identify': '_p', '_wasmfs_read_file': 'pp', From 399a0772feb3f18e6f64102e21a2915883914019 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 17 Dec 2024 13:01:36 -0800 Subject: [PATCH 094/132] Remove the need for `runCaller`. NFC (#23193) This change removes the need for `runCaller` and the `calledRun` global. Instead we simply set `dependenciesFulfilled` to `run` directly each time to return early due to outstanding dependencies. This also means that we don't need a reentrancy check on `doRun` since `dependenciesFulfilled` is only set in the case where `doRun` didn't actually run. This both simplifies the code and saves on code size. --- src/postamble.js | 14 +++++++------- .../other/codesize/test_codesize_cxx_ctors1.gzsize | 2 +- .../other/codesize/test_codesize_cxx_ctors1.jssize | 2 +- .../other/codesize/test_codesize_cxx_ctors2.gzsize | 2 +- .../other/codesize/test_codesize_cxx_ctors2.jssize | 2 +- .../other/codesize/test_codesize_cxx_except.gzsize | 2 +- .../other/codesize/test_codesize_cxx_except.jssize | 2 +- .../codesize/test_codesize_cxx_except_wasm.gzsize | 2 +- .../codesize/test_codesize_cxx_except_wasm.jssize | 2 +- .../test_codesize_cxx_except_wasm_exnref.gzsize | 2 +- .../test_codesize_cxx_except_wasm_exnref.jssize | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.jssize | 2 +- .../other/codesize/test_codesize_cxx_mangle.gzsize | 2 +- .../other/codesize/test_codesize_cxx_mangle.jssize | 2 +- .../codesize/test_codesize_cxx_noexcept.gzsize | 2 +- .../codesize/test_codesize_cxx_noexcept.jssize | 2 +- .../other/codesize/test_codesize_cxx_wasmfs.gzsize | 2 +- .../other/codesize/test_codesize_cxx_wasmfs.jssize | 2 +- .../codesize/test_codesize_files_js_fs.gzsize | 2 +- .../codesize/test_codesize_files_js_fs.jssize | 2 +- .../codesize/test_codesize_files_wasmfs.gzsize | 2 +- .../codesize/test_codesize_files_wasmfs.jssize | 2 +- test/other/codesize/test_codesize_hello_O0.gzsize | 2 +- test/other/codesize/test_codesize_hello_O0.jssize | 2 +- test/other/codesize/test_codesize_hello_O1.gzsize | 2 +- test/other/codesize/test_codesize_hello_O1.jssize | 2 +- test/other/codesize/test_codesize_hello_O2.gzsize | 2 +- test/other/codesize/test_codesize_hello_O2.jssize | 2 +- test/other/codesize/test_codesize_hello_O3.gzsize | 2 +- test/other/codesize/test_codesize_hello_O3.jssize | 2 +- test/other/codesize/test_codesize_hello_Os.gzsize | 2 +- test/other/codesize/test_codesize_hello_Os.jssize | 2 +- test/other/codesize/test_codesize_hello_Oz.gzsize | 2 +- test/other/codesize/test_codesize_hello_Oz.jssize | 2 +- .../codesize/test_codesize_hello_dylink.gzsize | 2 +- .../codesize/test_codesize_hello_dylink.jssize | 2 +- .../test_codesize_hello_export_nothing.gzsize | 2 +- .../test_codesize_hello_export_nothing.jssize | 2 +- .../codesize/test_codesize_hello_wasmfs.gzsize | 2 +- .../codesize/test_codesize_hello_wasmfs.jssize | 2 +- .../test_codesize_libcxxabi_message_O3.gzsize | 2 +- .../test_codesize_libcxxabi_message_O3.jssize | 2 +- ...codesize_libcxxabi_message_O3_standalone.gzsize | 2 +- ...codesize_libcxxabi_message_O3_standalone.jssize | 2 +- test/other/codesize/test_codesize_mem_O3.gzsize | 2 +- test/other/codesize/test_codesize_mem_O3.jssize | 2 +- .../codesize/test_codesize_mem_O3_grow.gzsize | 2 +- .../codesize/test_codesize_mem_O3_grow.jssize | 2 +- .../test_codesize_mem_O3_grow_standalone.gzsize | 2 +- .../test_codesize_mem_O3_grow_standalone.jssize | 2 +- .../test_codesize_mem_O3_standalone.gzsize | 2 +- .../test_codesize_mem_O3_standalone.jssize | 2 +- .../test_codesize_mem_O3_standalone_lib.gzsize | 2 +- .../test_codesize_mem_O3_standalone_lib.jssize | 2 +- .../test_codesize_mem_O3_standalone_narg.gzsize | 2 +- .../test_codesize_mem_O3_standalone_narg.jssize | 2 +- ...est_codesize_mem_O3_standalone_narg_flto.gzsize | 2 +- ...est_codesize_mem_O3_standalone_narg_flto.jssize | 2 +- .../other/codesize/test_codesize_minimal_64.gzsize | 2 +- .../other/codesize/test_codesize_minimal_64.jssize | 2 +- .../other/codesize/test_codesize_minimal_O0.gzsize | 2 +- .../other/codesize/test_codesize_minimal_O0.jssize | 2 +- .../other/codesize/test_codesize_minimal_O1.gzsize | 2 +- .../other/codesize/test_codesize_minimal_O1.jssize | 2 +- .../other/codesize/test_codesize_minimal_O2.gzsize | 2 +- .../other/codesize/test_codesize_minimal_O2.jssize | 2 +- .../other/codesize/test_codesize_minimal_O3.gzsize | 2 +- .../other/codesize/test_codesize_minimal_O3.jssize | 2 +- .../other/codesize/test_codesize_minimal_Os.gzsize | 2 +- .../other/codesize/test_codesize_minimal_Os.jssize | 2 +- .../codesize/test_codesize_minimal_Oz-ctors.gzsize | 2 +- .../codesize/test_codesize_minimal_Oz-ctors.jssize | 2 +- .../other/codesize/test_codesize_minimal_Oz.gzsize | 2 +- .../other/codesize/test_codesize_minimal_Oz.jssize | 2 +- .../codesize/test_codesize_minimal_pthreads.gzsize | 2 +- .../codesize/test_codesize_minimal_pthreads.jssize | 2 +- .../codesize/test_codesize_minimal_wasmfs.gzsize | 2 +- .../codesize/test_codesize_minimal_wasmfs.jssize | 2 +- test/other/test_unoptimized_code_size.js.size | 2 +- .../test_unoptimized_code_size_no_asserts.js.size | 2 +- .../test_unoptimized_code_size_strict.js.size | 2 +- tools/maint/rebaseline_tests.py | 5 +++-- 83 files changed, 91 insertions(+), 90 deletions(-) diff --git a/src/postamble.js b/src/postamble.js index 0896e0c3f7e93..390ccd5388691 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -26,18 +26,14 @@ if (ENVIRONMENT_IS_WORKER) { {{{ exportRuntime() }}} +#if ASSERTIONS var calledRun; +#endif #if STANDALONE_WASM && MAIN_READS_PARAMS var mainArgs = undefined; #endif -dependenciesFulfilled = function runCaller() { - // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false) - if (!calledRun) run(); - if (!calledRun) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled -}; - #if HAS_MAIN #if MAIN_READS_PARAMS {{{ asyncIf(ASYNCIFY == 2) }}} function callMain(args = []) { @@ -152,6 +148,7 @@ function run() { #if RUNTIME_DEBUG dbg('run() called, but dependencies remain, so not running'); #endif + dependenciesFulfilled = run; return; } @@ -176,14 +173,17 @@ function run() { #if RUNTIME_DEBUG dbg('run() called, but dependencies remain, so not running'); #endif + dependenciesFulfilled = run; return; } function doRun() { // run may have just been called through dependencies being fulfilled just in this very frame, // or while the async setStatus time below was happening - if (calledRun) return; +#if ASSERTIONS + assert(!calledRun); calledRun = true; +#endif Module['calledRun'] = true; if (ABORT) return; diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 7997926125d8f..f88e926d6de12 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8529 +8505 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index bcbc4c25b77ef..eafc8d2f9caf7 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20897 +20848 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index b40b6a0fd0a30..4d6a5c2242ae0 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8514 +8489 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 700e855809bbf..3e49717861889 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20865 +20816 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 92aedca0f1608..d5633366b7d2d 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9561 +9532 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index d03c402d5ef1e..ef8d02c7b4c52 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24743 +24693 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index c37d7a8c7497c..357af50996d0e 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8488 +8462 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index 6416addfb79a1..1d3d5514a0f88 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20791 +20742 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index c37d7a8c7497c..357af50996d0e 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8488 +8462 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index 6416addfb79a1..1d3d5514a0f88 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20791 +20742 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 1ee83bdf06f73..b5d5c1576b065 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8428 +8403 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 1b3592654f517..6428ac978c3f2 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20477 +20432 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index 8c22ca2a0d9bb..d54fe857c2e89 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9563 +9535 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index d03c402d5ef1e..ef8d02c7b4c52 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24743 +24693 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 7997926125d8f..f88e926d6de12 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8529 +8505 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index bcbc4c25b77ef..eafc8d2f9caf7 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20897 +20848 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize index 831c634228d7c..ac5764e2098c7 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize @@ -1 +1 @@ -3792 +3769 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.jssize b/test/other/codesize/test_codesize_cxx_wasmfs.jssize index ae09fe17eadb6..c5bde85823b0f 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.jssize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.jssize @@ -1 +1 @@ -8541 +8493 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index 4cea879e1407b..b1ae2d54cfb87 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7666 +7643 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index 2698b0cefab12..0f2d337842a24 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18805 +18761 diff --git a/test/other/codesize/test_codesize_files_wasmfs.gzsize b/test/other/codesize/test_codesize_files_wasmfs.gzsize index 1dea9fded90ce..f7374e5edea7f 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_files_wasmfs.gzsize @@ -1 +1 @@ -2887 +2866 diff --git a/test/other/codesize/test_codesize_files_wasmfs.jssize b/test/other/codesize/test_codesize_files_wasmfs.jssize index 7ad6b3d0b1c75..c98f921104b33 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.jssize +++ b/test/other/codesize/test_codesize_files_wasmfs.jssize @@ -1 +1 @@ -6183 +6140 diff --git a/test/other/codesize/test_codesize_hello_O0.gzsize b/test/other/codesize/test_codesize_hello_O0.gzsize index 274eb1a125e42..8ca7d7e2dcf2a 100644 --- a/test/other/codesize/test_codesize_hello_O0.gzsize +++ b/test/other/codesize/test_codesize_hello_O0.gzsize @@ -1 +1 @@ -8020 +8003 diff --git a/test/other/codesize/test_codesize_hello_O0.jssize b/test/other/codesize/test_codesize_hello_O0.jssize index deb732ca28856..1e88f55d68b32 100644 --- a/test/other/codesize/test_codesize_hello_O0.jssize +++ b/test/other/codesize/test_codesize_hello_O0.jssize @@ -1 +1 @@ -21550 +21535 diff --git a/test/other/codesize/test_codesize_hello_O1.gzsize b/test/other/codesize/test_codesize_hello_O1.gzsize index 3f080eeb6ec84..c98e88a99e28f 100644 --- a/test/other/codesize/test_codesize_hello_O1.gzsize +++ b/test/other/codesize/test_codesize_hello_O1.gzsize @@ -1 +1 @@ -2738 +2713 diff --git a/test/other/codesize/test_codesize_hello_O1.jssize b/test/other/codesize/test_codesize_hello_O1.jssize index bd48f22f2d557..6fdb8ccd778a3 100644 --- a/test/other/codesize/test_codesize_hello_O1.jssize +++ b/test/other/codesize/test_codesize_hello_O1.jssize @@ -1 +1 @@ -6970 +6921 diff --git a/test/other/codesize/test_codesize_hello_O2.gzsize b/test/other/codesize/test_codesize_hello_O2.gzsize index 7ccc3cde58017..cc278bd694d3e 100644 --- a/test/other/codesize/test_codesize_hello_O2.gzsize +++ b/test/other/codesize/test_codesize_hello_O2.gzsize @@ -1 +1 @@ -2388 +2369 diff --git a/test/other/codesize/test_codesize_hello_O2.jssize b/test/other/codesize/test_codesize_hello_O2.jssize index e267c8a08a441..30162af6fe2dd 100644 --- a/test/other/codesize/test_codesize_hello_O2.jssize +++ b/test/other/codesize/test_codesize_hello_O2.jssize @@ -1 +1 @@ -4891 +4844 diff --git a/test/other/codesize/test_codesize_hello_O3.gzsize b/test/other/codesize/test_codesize_hello_O3.gzsize index 719b586a2fdb2..cc6f0ac7ecffd 100644 --- a/test/other/codesize/test_codesize_hello_O3.gzsize +++ b/test/other/codesize/test_codesize_hello_O3.gzsize @@ -1 +1 @@ -2307 +2283 diff --git a/test/other/codesize/test_codesize_hello_O3.jssize b/test/other/codesize/test_codesize_hello_O3.jssize index a7351f2c7998a..9bce5583b99b7 100644 --- a/test/other/codesize/test_codesize_hello_O3.jssize +++ b/test/other/codesize/test_codesize_hello_O3.jssize @@ -1 +1 @@ -4738 +4695 diff --git a/test/other/codesize/test_codesize_hello_Os.gzsize b/test/other/codesize/test_codesize_hello_Os.gzsize index 719b586a2fdb2..cc6f0ac7ecffd 100644 --- a/test/other/codesize/test_codesize_hello_Os.gzsize +++ b/test/other/codesize/test_codesize_hello_Os.gzsize @@ -1 +1 @@ -2307 +2283 diff --git a/test/other/codesize/test_codesize_hello_Os.jssize b/test/other/codesize/test_codesize_hello_Os.jssize index a7351f2c7998a..9bce5583b99b7 100644 --- a/test/other/codesize/test_codesize_hello_Os.jssize +++ b/test/other/codesize/test_codesize_hello_Os.jssize @@ -1 +1 @@ -4738 +4695 diff --git a/test/other/codesize/test_codesize_hello_Oz.gzsize b/test/other/codesize/test_codesize_hello_Oz.gzsize index f0e709d5b3d2f..42752c3ef1f12 100644 --- a/test/other/codesize/test_codesize_hello_Oz.gzsize +++ b/test/other/codesize/test_codesize_hello_Oz.gzsize @@ -1 +1 @@ -2288 +2265 diff --git a/test/other/codesize/test_codesize_hello_Oz.jssize b/test/other/codesize/test_codesize_hello_Oz.jssize index 29a66372adae4..77d471ad303a9 100644 --- a/test/other/codesize/test_codesize_hello_Oz.jssize +++ b/test/other/codesize/test_codesize_hello_Oz.jssize @@ -1 +1 @@ -4705 +4662 diff --git a/test/other/codesize/test_codesize_hello_dylink.gzsize b/test/other/codesize/test_codesize_hello_dylink.gzsize index a1c8982c1d6cd..06e102d5685af 100644 --- a/test/other/codesize/test_codesize_hello_dylink.gzsize +++ b/test/other/codesize/test_codesize_hello_dylink.gzsize @@ -1 +1 @@ -6180 +6150 diff --git a/test/other/codesize/test_codesize_hello_dylink.jssize b/test/other/codesize/test_codesize_hello_dylink.jssize index c20c3c70546f8..7a9400801574e 100644 --- a/test/other/codesize/test_codesize_hello_dylink.jssize +++ b/test/other/codesize/test_codesize_hello_dylink.jssize @@ -1 +1 @@ -13662 +13609 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.gzsize b/test/other/codesize/test_codesize_hello_export_nothing.gzsize index 6aec59a6d0cad..15475a3d5fc2c 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.gzsize +++ b/test/other/codesize/test_codesize_hello_export_nothing.gzsize @@ -1 +1 @@ -1687 +1667 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.jssize b/test/other/codesize/test_codesize_hello_export_nothing.jssize index 93b24425acae2..5f3db86bbc3ea 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.jssize +++ b/test/other/codesize/test_codesize_hello_export_nothing.jssize @@ -1 +1 @@ -3618 +3575 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.gzsize b/test/other/codesize/test_codesize_hello_wasmfs.gzsize index 719b586a2fdb2..cc6f0ac7ecffd 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_hello_wasmfs.gzsize @@ -1 +1 @@ -2307 +2283 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.jssize b/test/other/codesize/test_codesize_hello_wasmfs.jssize index a7351f2c7998a..9bce5583b99b7 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.jssize +++ b/test/other/codesize/test_codesize_hello_wasmfs.jssize @@ -1 +1 @@ -4738 +4695 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize index 01ec6ca892159..86fc8f4d80b5a 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize @@ -1 +1 @@ -1882 +1862 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize index fa07d868f2b60..58f5850ae5fcf 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize @@ -1 +1 @@ -3977 +3938 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize index e37d15a094a6b..8bae76d7966a2 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize @@ -1 +1 @@ -1920 +1899 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize index 130e6272e7397..6b2af3f880b0c 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize @@ -1 +1 @@ -4025 +3986 diff --git a/test/other/codesize/test_codesize_mem_O3.gzsize b/test/other/codesize/test_codesize_mem_O3.gzsize index d61563f9298b0..2612554b2d3af 100644 --- a/test/other/codesize/test_codesize_mem_O3.gzsize +++ b/test/other/codesize/test_codesize_mem_O3.gzsize @@ -1 +1 @@ -2336 +2313 diff --git a/test/other/codesize/test_codesize_mem_O3.jssize b/test/other/codesize/test_codesize_mem_O3.jssize index 94166f8c0392a..ddeb3cf88bf70 100644 --- a/test/other/codesize/test_codesize_mem_O3.jssize +++ b/test/other/codesize/test_codesize_mem_O3.jssize @@ -1 +1 @@ -4878 +4830 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.gzsize b/test/other/codesize/test_codesize_mem_O3_grow.gzsize index a385b0c6e2512..ea5f1c5174ecc 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow.gzsize @@ -1 +1 @@ -2486 +2461 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.jssize b/test/other/codesize/test_codesize_mem_O3_grow.jssize index 045c1c6b12f7e..581cc8f752a1c 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow.jssize @@ -1 +1 @@ -5163 +5115 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize index d1003cf584d87..5e7c8b88a0264 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize @@ -1 +1 @@ -2183 +2164 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize index 3f04bd87eea47..1f440269b96d4 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize @@ -1 +1 @@ -4571 +4523 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize index 6b16d006faa0f..10c8452b2c3ab 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize @@ -1 +1 @@ -2148 +2128 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_standalone.jssize index 8af91005b834b..ab5135ded797f 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.jssize @@ -1 +1 @@ -4501 +4455 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize index c9ac2c6be7141..c34a5b9bd9c60 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize @@ -1 +1 @@ -1907 +1885 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize index 1e7f3fa7c3927..6cd1cb4835d89 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize @@ -1 +1 @@ -4024 +3985 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize index e37d15a094a6b..8bae76d7966a2 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize @@ -1 +1 @@ -1920 +1899 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize index 130e6272e7397..6b2af3f880b0c 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize @@ -1 +1 @@ -4025 +3986 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize index e37d15a094a6b..8bae76d7966a2 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize @@ -1 +1 @@ -1920 +1899 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize index 130e6272e7397..6b2af3f880b0c 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize @@ -1 +1 @@ -4025 +3986 diff --git a/test/other/codesize/test_codesize_minimal_64.gzsize b/test/other/codesize/test_codesize_minimal_64.gzsize index 2794bbe069d76..2a63ccf651217 100644 --- a/test/other/codesize/test_codesize_minimal_64.gzsize +++ b/test/other/codesize/test_codesize_minimal_64.gzsize @@ -1 +1 @@ -1458 +1439 diff --git a/test/other/codesize/test_codesize_minimal_64.jssize b/test/other/codesize/test_codesize_minimal_64.jssize index 4fb7d0e7d0511..31410c0cab693 100644 --- a/test/other/codesize/test_codesize_minimal_64.jssize +++ b/test/other/codesize/test_codesize_minimal_64.jssize @@ -1 +1 @@ -3098 +3064 diff --git a/test/other/codesize/test_codesize_minimal_O0.gzsize b/test/other/codesize/test_codesize_minimal_O0.gzsize index 8cd05948b4b40..8e86bc3df7942 100644 --- a/test/other/codesize/test_codesize_minimal_O0.gzsize +++ b/test/other/codesize/test_codesize_minimal_O0.gzsize @@ -1 +1 @@ -6546 +6532 diff --git a/test/other/codesize/test_codesize_minimal_O0.jssize b/test/other/codesize/test_codesize_minimal_O0.jssize index 1b66ee40ff9ad..3cac79a0fee52 100644 --- a/test/other/codesize/test_codesize_minimal_O0.jssize +++ b/test/other/codesize/test_codesize_minimal_O0.jssize @@ -1 +1 @@ -17556 +17563 diff --git a/test/other/codesize/test_codesize_minimal_O1.gzsize b/test/other/codesize/test_codesize_minimal_O1.gzsize index fa94e88e60f14..f02edd5f91078 100644 --- a/test/other/codesize/test_codesize_minimal_O1.gzsize +++ b/test/other/codesize/test_codesize_minimal_O1.gzsize @@ -1 +1 @@ -1536 +1520 diff --git a/test/other/codesize/test_codesize_minimal_O1.jssize b/test/other/codesize/test_codesize_minimal_O1.jssize index 46b6c4b342033..7cca7c9e17bf6 100644 --- a/test/other/codesize/test_codesize_minimal_O1.jssize +++ b/test/other/codesize/test_codesize_minimal_O1.jssize @@ -1 +1 @@ -3663 +3664 diff --git a/test/other/codesize/test_codesize_minimal_O2.gzsize b/test/other/codesize/test_codesize_minimal_O2.gzsize index 88382e8fead7c..5ae289b43f8d7 100644 --- a/test/other/codesize/test_codesize_minimal_O2.gzsize +++ b/test/other/codesize/test_codesize_minimal_O2.gzsize @@ -1 +1 @@ -1389 +1371 diff --git a/test/other/codesize/test_codesize_minimal_O2.jssize b/test/other/codesize/test_codesize_minimal_O2.jssize index 4d86a0941c7cc..aa57446358cb9 100644 --- a/test/other/codesize/test_codesize_minimal_O2.jssize +++ b/test/other/codesize/test_codesize_minimal_O2.jssize @@ -1 +1 @@ -2803 +2769 diff --git a/test/other/codesize/test_codesize_minimal_O3.gzsize b/test/other/codesize/test_codesize_minimal_O3.gzsize index 2538e3d648dd5..7345521b14101 100644 --- a/test/other/codesize/test_codesize_minimal_O3.gzsize +++ b/test/other/codesize/test_codesize_minimal_O3.gzsize @@ -1 +1 @@ -1354 +1336 diff --git a/test/other/codesize/test_codesize_minimal_O3.jssize b/test/other/codesize/test_codesize_minimal_O3.jssize index f1349afff39a3..8ef17f6cef8d3 100644 --- a/test/other/codesize/test_codesize_minimal_O3.jssize +++ b/test/other/codesize/test_codesize_minimal_O3.jssize @@ -1 +1 @@ -2753 +2719 diff --git a/test/other/codesize/test_codesize_minimal_Os.gzsize b/test/other/codesize/test_codesize_minimal_Os.gzsize index 2538e3d648dd5..7345521b14101 100644 --- a/test/other/codesize/test_codesize_minimal_Os.gzsize +++ b/test/other/codesize/test_codesize_minimal_Os.gzsize @@ -1 +1 @@ -1354 +1336 diff --git a/test/other/codesize/test_codesize_minimal_Os.jssize b/test/other/codesize/test_codesize_minimal_Os.jssize index f1349afff39a3..8ef17f6cef8d3 100644 --- a/test/other/codesize/test_codesize_minimal_Os.jssize +++ b/test/other/codesize/test_codesize_minimal_Os.jssize @@ -1 +1 @@ -2753 +2719 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize index 07aeb9bc360f6..d378cb0bf85c3 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize @@ -1 +1 @@ -1345 +1327 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize index 3f080eeb6ec84..f3bb5816bff9b 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize @@ -1 +1 @@ -2738 +2704 diff --git a/test/other/codesize/test_codesize_minimal_Oz.gzsize b/test/other/codesize/test_codesize_minimal_Oz.gzsize index 2538e3d648dd5..7345521b14101 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz.gzsize @@ -1 +1 @@ -1354 +1336 diff --git a/test/other/codesize/test_codesize_minimal_Oz.jssize b/test/other/codesize/test_codesize_minimal_Oz.jssize index f1349afff39a3..8ef17f6cef8d3 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz.jssize @@ -1 +1 @@ -2753 +2719 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.gzsize b/test/other/codesize/test_codesize_minimal_pthreads.gzsize index 1e3e300877006..529e64fdfb43e 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.gzsize +++ b/test/other/codesize/test_codesize_minimal_pthreads.gzsize @@ -1 +1 @@ -4146 +4118 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.jssize b/test/other/codesize/test_codesize_minimal_pthreads.jssize index 74e80adf8b955..e4b77e6fc2965 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.jssize +++ b/test/other/codesize/test_codesize_minimal_pthreads.jssize @@ -1 +1 @@ -8594 +8556 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize index 2538e3d648dd5..7345521b14101 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize @@ -1 +1 @@ -1354 +1336 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.jssize b/test/other/codesize/test_codesize_minimal_wasmfs.jssize index f1349afff39a3..8ef17f6cef8d3 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.jssize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.jssize @@ -1 +1 @@ -2753 +2719 diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index d48e8ed1291a9..6f75fa3a9a413 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -53946 +53709 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index bd163cc4e1b0c..e55af0c20aeb7 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -29317 +29018 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index 1cc3925c8f1fa..ca6f382d48289 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -52768 +52531 diff --git a/tools/maint/rebaseline_tests.py b/tools/maint/rebaseline_tests.py index 09c9455acf278..2bb3c7cc1928a 100755 --- a/tools/maint/rebaseline_tests.py +++ b/tools/maint/rebaseline_tests.py @@ -85,8 +85,9 @@ def main(argv): output = run(['git', 'status', '-uno', '--porcelain']) filenames = [] for line in output.splitlines(): - status, filename = line.strip().split(' ', 1) - filenames.append(filename) + status, filename = line.strip().rsplit(' ', 1) + if filename.startswith('test/'): + filenames.append(filename) commit_message = f''' Automatic rebaseline of codesize expectations. NFC From 56ee9ddf41769a02f4fdd43e4bc35f2c8227ccdb Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 17 Dec 2024 13:22:23 -0800 Subject: [PATCH 095/132] CI: Fix indentation in tag-release.yml. NFC (#23202) --- .github/workflows/tag-release.yml | 81 ++++++++++++++++--------------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index dbbcf52ea6ed9..4618416d87ef8 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -9,43 +9,44 @@ on: type: string jobs: - create-release: - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - # Updates changelog and writes the release version into the environment - - name: Update Changelog - run: python3 tools/maint/create_release.py --action - - name: Create Changelog PR - id: cpr - uses: peter-evans/create-pull-request@v6 - with: - token: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }} - title: Mark ${{ env.RELEASE_VERSION }} as released - body: Update changelog and emscripten-version.txt [ci skip] - team-reviewers: release-reviewers - delete-branch: true - - name: Enable auto-merge - run: gh pr merge --squash --auto "${{ steps.cpr.outputs.pull-request-number }}" - env: - GH_TOKEN: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }} - - name: Tag release sha - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }} - script: | - const tag_sha = '${{ inputs.release-sha }}'; - const release_version = '${{ env.RELEASE_VERSION }}'; - console.log(`Version ${release_version} at SHA ${tag_sha}`); - const regex = /^[0-9]+.[0-9]+.[0-9]+$/; - const match = release_version.match(regex); - if (!match) { - throw new Error('Malformed release version'); - } - await github.rest.git.createRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: `refs/tags/${release_version}`, - sha: tag_sha - }); + create-release: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + # Updates changelog and writes the release version into the environment + - name: Update Changelog + run: python3 tools/maint/create_release.py --action + - name: Create Changelog PR + id: cpr + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }} + title: Mark ${{ env.RELEASE_VERSION }} as released + body: Update changelog and emscripten-version.txt [ci skip] + team-reviewers: release-reviewers + delete-branch: true + - name: Enable auto-merge + run: gh pr merge --squash --auto "${{ steps.cpr.outputs.pull-request-number }}" + env: + GH_TOKEN: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }} + - name: Tag release sha + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.EMSCRIPTEN_BOT_TOKEN }} + script: | + const tag_sha = '${{ inputs.release-sha }}'; + const release_version = '${{ env.RELEASE_VERSION }}'; + console.log(`Version ${release_version} at SHA ${tag_sha}`); + const regex = /^[0-9]+.[0-9]+.[0-9]+$/; + const match = release_version.match(regex); + if (!match) { + throw new Error('Malformed release version'); + } + await github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: `refs/tags/${release_version}`, + sha: tag_sha + }); + From 4b708e506a98d7eb886f1ee63347296aecec3199 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 17 Dec 2024 14:02:34 -0800 Subject: [PATCH 096/132] Remove pinned version of lxml from requirements-dev.txt. NFC (#23204) It seems like the underlying issue with the mac package has been fixes somehow, and I was running into issues with this version of lxml not being installable on python 3.12 (which is in ubuntu-latest on github CI). See #19785 --- requirements-dev.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 6fea74921d9df..84c824c5ee1b6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -10,9 +10,6 @@ ruff==0.8.2 types-requests==2.27.14 unittest-xml-reporting==3.1.0 -# See https://github.com/emscripten-core/emscripten/issues/19785 -lxml==4.9.2 - # This version is mentioned in `site/source/docs/site/about.rst`. # Please keep them in sync. sphinx==7.1.2 From 84de057a4865f8feac27e95db924073dce7f9e6c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 17 Dec 2024 14:06:21 -0800 Subject: [PATCH 097/132] Automatic rebaseline of codesize expectations. NFC This is an automatic change generated by tools/maint/rebaseline_tests.py. The following (2) test expectation files were updated by running the tests with `--rebaseline`: ``` browser/test_small_js_flags.js.size: 4327 => 4297 [-30 bytes / -0.69%] other/test_INCOMING_MODULE_JS_API.js.size: 3758 => 3710 [-48 bytes / -1.28%] Average change: -0.99% (-1.28% - -0.69%) ``` --- test/browser/test_small_js_flags.js.size | 2 +- test/other/test_INCOMING_MODULE_JS_API.js.size | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/browser/test_small_js_flags.js.size b/test/browser/test_small_js_flags.js.size index c318f0c61d4fd..555bb91567fa6 100644 --- a/test/browser/test_small_js_flags.js.size +++ b/test/browser/test_small_js_flags.js.size @@ -1 +1 @@ -4327 +4297 diff --git a/test/other/test_INCOMING_MODULE_JS_API.js.size b/test/other/test_INCOMING_MODULE_JS_API.js.size index 6707ffabfa29a..9b8a4c307c7a1 100644 --- a/test/other/test_INCOMING_MODULE_JS_API.js.size +++ b/test/other/test_INCOMING_MODULE_JS_API.js.size @@ -1 +1 @@ -3758 +3710 From f1639a3e6b4165ea555f581bb9a923337992a5fa Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 17 Dec 2024 14:46:19 -0800 Subject: [PATCH 098/132] CI: Check that test expectations are up-to-date (#23201) This test will fail if the expectations are out-of-date on the main branch. This can happen due to either: 1. Somebody forgetting to update the expectations when they land an emscripten change 2. llvm or binaryen changes that rolled in on the auto-roller. For now I propose that we don't make this new check "Required" and we consider this the first step towards making these updates easy and automatic. I made this a github action rather than using CiricleCI since I anticipate using github automation here in the future (for example to suggest updates the current PR). --- .github/workflows/archive.yml | 27 -------------- .github/workflows/ci.yml | 66 +++++++++++++++++++++++++++++++++ tools/maint/rebaseline_tests.py | 46 +++++++++++++++-------- 3 files changed, 96 insertions(+), 43 deletions(-) delete mode 100644 .github/workflows/archive.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/archive.yml b/.github/workflows/archive.yml deleted file mode 100644 index 480bf446da5c9..0000000000000 --- a/.github/workflows/archive.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: CI - -on: - create: - tags: - push: - branches: - - main - pull_request: - -permissions: - contents: read - -jobs: - archive: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - name: make dist - run: | - make dist - version=`cat emscripten-version.txt | sed s/\"//g` - echo "VERSION=$version" >> $GITHUB_ENV - - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 - with: - name: emscripten-${{ env.VERSION }} - path: emscripten-${{ env.VERSION }}.tar.bz2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000000..023e326d92125 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,66 @@ +name: CI + +on: + create: + tags: + push: + branches: + - main + pull_request: + +permissions: + contents: read + +jobs: + archive: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + - name: make dist + run: | + make dist + version=`cat emscripten-version.txt | sed s/\"//g` + echo "VERSION=$version" >> $GITHUB_ENV + - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 + with: + name: emscripten-${{ env.VERSION }} + path: emscripten-${{ env.VERSION }}.tar.bz2 + + check-expectations: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 # We want access to other branches, specifically `main` + - name: pip install + run: | + which python3 + python3 --version + python3 -m pip install -r requirements-dev.txt + - name: Install emsdk + run: | + EM_CONFIG=$HOME/emsdk/.emscripten + echo $EM_CONFIG + echo "EM_CONFIG=$EM_CONFIG" >> $GITHUB_ENV + curl -# -L -o ~/emsdk-main.tar.gz https://github.com/emscripten-core/emsdk/archive/main.tar.gz + tar -C ~ -xf ~/emsdk-main.tar.gz + mv ~/emsdk-main ~/emsdk + cd ~/emsdk + ./emsdk install tot + ./emsdk activate tot + echo "JS_ENGINES = [NODE_JS]" >> $EM_CONFIG + echo "final config:" + cat $EM_CONFIG + - name: Check test expectations on main + run: | + git checkout origin/main + # Hack to honor changes to rebaseline_tests.py in the current PR + git checkout - ./tools/maint/rebaseline_tests.py + ./bootstrap + if ! ./tools/maint/rebaseline_tests.py --check-only; then + echo "Test expectations are out-of-date on the main branch." + echo "You can run `./tools/maint/rebaseline_tests.py --new-branch`" + echo "and use it to create a seperate PR." + exit 1 + fi diff --git a/tools/maint/rebaseline_tests.py b/tools/maint/rebaseline_tests.py index 2bb3c7cc1928a..307af1cda61e1 100755 --- a/tools/maint/rebaseline_tests.py +++ b/tools/maint/rebaseline_tests.py @@ -26,7 +26,8 @@ 'browser.test_small_js_flags', 'other.test_INCOMING_MODULE_JS_API', 'other.*code_size*', - 'other.*codesize*' + 'other.*codesize*', + 'skip:other.test_jspi_code_size', ] @@ -63,33 +64,43 @@ def process_changed_file(filename): def main(argv): parser = argparse.ArgumentParser() - parser.add_argument('-s', '--skip-tests', action='store_true', help="don't actually run the tests, just analyze the existing results") - parser.add_argument('-b', '--new-branch', action='store_true', help='create a new branch containing the updates') - parser.add_argument('-c', '--clear-cache', action='store_true', help='clear the cache before rebaselining (useful when working with llvm changes)') + parser.add_argument('-s', '--skip-tests', action='store_true', help="Don't actually run the tests, just analyze the existing results") + parser.add_argument('-b', '--new-branch', action='store_true', help='Create a new branch containing the updates') + parser.add_argument('-c', '--clear-cache', action='store_true', help='Clear the cache before rebaselining (useful when working with llvm changes)') + parser.add_argument('-n', '--check-only', dest='check_only', action='store_true', help='Return non-zero if test expectations are out of date, and skip creating a git commit') args = parser.parse_args() if args.clear_cache: run(['emcc', '--clear-cache']) if not args.skip_tests: - if run(['git', 'status', '-uno', '--porcelain']).strip(): + if not args.check_only and run(['git', 'status', '-uno', '--porcelain']).strip(): print('tree is not clean') return 1 subprocess.check_call(['test/runner', '--rebaseline', '--browser=0'] + TESTS, cwd=root_dir) - if not run(['git', 'status', '-uno', '--porcelain']): - print('no updates found') - return 1 + if not run(['git', 'status', '-uno', '--porcelain', 'test']): + print('test expectations are up-to-date') + return 0 output = run(['git', 'status', '-uno', '--porcelain']) filenames = [] for line in output.splitlines(): - status, filename = line.strip().rsplit(' ', 1) - if filename.startswith('test/'): + filename = line.strip().rsplit(' ', 1)[1] + if filename.startswith('test'): filenames.append(filename) - commit_message = f''' + if args.check_only: + message = f'''Test expectations are out-of-date + +The following ({len(filenames)}) test expectation files were updated by +running the tests with `--rebaseline`: + +``` +''' + else: + message = f''' Automatic rebaseline of codesize expectations. NFC This is an automatic change generated by tools/maint/rebaseline_tests.py. @@ -101,18 +112,21 @@ def main(argv): ''' for file in filenames: - commit_message += process_changed_file(file) + message += process_changed_file(file) - commit_message += f'\nAverage change: {statistics.mean(all_deltas):+.2f}% ({min(all_deltas):+.2f}% - {max(all_deltas):+.2f}%)\n' + message += f'\nAverage change: {statistics.mean(all_deltas):+.2f}% ({min(all_deltas):+.2f}% - {max(all_deltas):+.2f}%)\n' - commit_message += '```\n' + message += '```\n' + + print(message) + if args.check_only: + return 1 if args.new_branch: run(['git', 'checkout', '-b', 'rebaseline_tests']) run(['git', 'add', '-u', '.']) - run(['git', 'commit', '-F', '-'], input=commit_message) + run(['git', 'commit', '-F', '-'], input=message) - print(commit_message) return 0 From 2ac4c4f2959e621a9acc723a9952db5d1c68f9d4 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 17 Dec 2024 15:40:07 -0800 Subject: [PATCH 099/132] Run `npm audit fix` to update `package-lock.json`. NFC (#23206) --- package-lock.json | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index cec4f1c933bbb..464d0293f217c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,7 @@ "requires": true, "packages": { "": { + "name": "emscripten", "dependencies": { "@babel/cli": "^7.25.6", "@babel/core": "^7.25.2", @@ -2600,9 +2601,9 @@ "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "dependencies": { "path-key": "^3.1.0", @@ -7029,9 +7030,9 @@ "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" }, "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "requires": { "path-key": "^3.1.0", From ad49af31fb5003537d1902c2b487c5f7e52c44f2 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 17 Dec 2024 16:55:54 -0800 Subject: [PATCH 100/132] Remove old warning about firefox bug (#23209) Firstly the bug has a been fixed. Secondly, the warning is no longer up-to-date with the code and it looks like someone would have to do `-sEXPORT_NAME=moduleArg` to hit this name collision now.. which seems more than unlikely. --- tools/link.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/link.py b/tools/link.py index 2d4726bcc286d..85aa1d9ebee54 100644 --- a/tools/link.py +++ b/tools/link.py @@ -2385,10 +2385,6 @@ def modularize(): if settings.EXPORT_ES6 and settings.ENVIRONMENT_MAY_BE_NODE: async_emit = 'async ' - # TODO: Remove when https://bugs.webkit.org/show_bug.cgi?id=223533 is resolved. - if async_emit != '' and settings.EXPORT_NAME == 'config': - diagnostics.warning('emcc', 'EXPORT_NAME should not be named "config" when targeting Safari') - if settings.MODULARIZE == 'instance': src = ''' export default async function init(moduleArg = {}) { From f66b5d706e174d9e5cc6122c06ea29dcd2735cd0 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 17 Dec 2024 22:25:54 -0800 Subject: [PATCH 101/132] Bump Binaryen version to 121 (#23207) https://github.com/WebAssembly/binaryen/pull/7153 updated Binaryen version to 121, and we updated it in Emscripten to 120 to make the CI pass (#23197). Now that https://chromium-review.googlesource.com/c/emscripten-releases/+/6103023 has landed, I think we can update it to 121. --- tools/building.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/building.py b/tools/building.py index d762304920a90..c1caf75ca6840 100644 --- a/tools/building.py +++ b/tools/building.py @@ -39,7 +39,7 @@ # Building binaryen_checked = False -EXPECTED_BINARYEN_VERSION = 120 +EXPECTED_BINARYEN_VERSION = 121 _is_ar_cache: Dict[str, bool] = {} # the exports the user requested From 978488b23e725000f6863e1d236c57698bc6052f Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 18 Dec 2024 09:35:56 -0800 Subject: [PATCH 102/132] Avoid excessive variable reuse in `modularize` function. NFC (#23208) I think this makes it a little easier to follow. --- tools/link.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/link.py b/tools/link.py index 85aa1d9ebee54..7f75ef4edb435 100644 --- a/tools/link.py +++ b/tools/link.py @@ -2377,7 +2377,7 @@ def node_pthread_detection(): def modularize(): global final_js logger.debug(f'Modularizing, assigning to var {settings.EXPORT_NAME}') - src = read_file(final_js) + generated_js = read_file(final_js) # When targetting node and ES6 we use `await import ..` in the generated code # so the outer function needs to be marked as async. @@ -2386,35 +2386,35 @@ def modularize(): async_emit = 'async ' if settings.MODULARIZE == 'instance': - src = ''' + wrapper_function = ''' export default async function init(moduleArg = {}) { var moduleRtn; -%(src)s +%(generated_js)s return await moduleRtn; } ''' % { - 'src': src, + 'generated_js': generated_js } else: - src = ''' + wrapper_function = ''' %(maybe_async)sfunction(moduleArg = {}) { var moduleRtn; -%(src)s +%(generated_js)s return moduleRtn; } ''' % { 'maybe_async': async_emit, - 'src': src, + 'generated_js': generated_js } if settings.MINIMAL_RUNTIME and not settings.PTHREADS: # Single threaded MINIMAL_RUNTIME programs do not need access to # document.currentScript, so a simple export declaration is enough. - src = '/** @nocollapse */ var %s = %s' % (settings.EXPORT_NAME, src) + src = f'/** @nocollapse */ var {settings.EXPORT_NAME} = {wrapper_function};' else: script_url_node = '' # When MODULARIZE this JS may be executed later, @@ -2432,24 +2432,24 @@ def modularize(): src = '''\ var _scriptName = %(script_url)s; %(script_url_node)s - %(src)s + %(wrapper_function)s ''' % { 'script_url': script_url, 'script_url_node': script_url_node, - 'src': src, + 'wrapper_function': wrapper_function, } else: src = '''\ var %(EXPORT_NAME)s = (() => { var _scriptName = %(script_url)s; %(script_url_node)s - return (%(src)s); + return (%(wrapper_function)s); })(); ''' % { 'EXPORT_NAME': settings.EXPORT_NAME, 'script_url': script_url, 'script_url_node': script_url_node, - 'src': src, + 'wrapper_function': wrapper_function, } # Given the async nature of how the Module function and Module object From c26d8059a6744351adb8c25d3a04c994a9ac073d Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 18 Dec 2024 20:16:03 +0100 Subject: [PATCH 103/132] Fix `mkdir("a/b/..")` should return `EEXIST` (#23136) Before this change `mkdir("a/b/..")` surprisingly makes a directory called `a/b/a`. It should raise EEXIST. --- src/library_fs.js | 11 +++++++++-- test/fs/test_fs_mkdir_dotdot.c | 27 +++++++++++++++++++++++++++ test/test_core.py | 4 ++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 test/fs/test_fs_mkdir_dotdot.c diff --git a/src/library_fs.js b/src/library_fs.js index 68c53ad670bb5..ada447d171c18 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -182,7 +182,7 @@ FS.staticInit(); // limit max consecutive symlinks to 40 (SYMLOOP_MAX). linkloop: for (var nlinks = 0; nlinks < 40; nlinks++) { // split the absolute path - var parts = path.split('/').filter((p) => !!p && (p !== '.')); + var parts = path.split('/').filter((p) => !!p); // start at the root var current = FS.root; @@ -195,6 +195,10 @@ FS.staticInit(); break; } + if (parts[i] === '.') { + continue; + } + if (parts[i] === '..') { current_path = PATH.dirname(current_path); current = current.parent; @@ -665,9 +669,12 @@ FS.staticInit(); var lookup = FS.lookupPath(path, { parent: true }); var parent = lookup.node; var name = PATH.basename(path); - if (!name || name === '.' || name === '..') { + if (!name) { throw new FS.ErrnoError({{{ cDefs.EINVAL }}}); } + if (name === '.' || name === '..') { + throw new FS.ErrnoError({{{ cDefs.EEXIST }}}); + } var errCode = FS.mayCreate(parent, name); if (errCode) { throw new FS.ErrnoError(errCode); diff --git a/test/fs/test_fs_mkdir_dotdot.c b/test/fs/test_fs_mkdir_dotdot.c new file mode 100644 index 0000000000000..4bda788dd452a --- /dev/null +++ b/test/fs/test_fs_mkdir_dotdot.c @@ -0,0 +1,27 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main() { + assert(mkdir("test", 0777) == 0); + assert(mkdir("test/a", 0777) == 0); + assert(mkdir("test/a/..", 0777) == -1); + printf("error: %s\n", strerror(errno)); + assert(errno == EEXIST); + assert(mkdir("test/a/.", 0777) == -1); + printf("error: %s\n", strerror(errno)); + assert(errno == EEXIST); + assert(mkdir("test/a/b/..", 0777) == -1); + printf("error: %s\n", strerror(errno)); + assert(errno == ENOENT); + assert(mkdir("test/a/b/.", 0777) == -1); + printf("error: %s\n", strerror(errno)); + assert(errno == ENOENT); + printf("success\n"); +} diff --git a/test/test_core.py b/test/test_core.py index 87d04cfdc1615..cbdf449ec1d0e 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5858,6 +5858,10 @@ def test_fs_rename_on_existing(self): self.set_setting('FORCE_FILESYSTEM') self.do_runf('fs/test_fs_rename_on_existing.c', 'success') + @also_with_nodefs_both + def test_fs_mkdir_dotdot(self): + self.do_runf('fs/test_fs_mkdir_dotdot.c', 'success') + def test_sigalrm(self): self.do_runf('test_sigalrm.c', 'Received alarm!') self.do_runf('test_sigalrm.c', 'Received alarm!', emcc_args=['-sEXIT_RUNTIME']) From 4ba4c603244774e50470403d07bdb52623e02a97 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 18 Dec 2024 11:25:43 -0800 Subject: [PATCH 104/132] Add codesize test for EXPORT_ES6. NFC (#23215) I don't think there any any other codesize tests that cover this. --- test/other/codesize/test_codesize_minimal_esm.exports | 4 ++++ test/other/codesize/test_codesize_minimal_esm.funcs | 2 ++ test/other/codesize/test_codesize_minimal_esm.gzsize | 1 + test/other/codesize/test_codesize_minimal_esm.imports | 1 + test/other/codesize/test_codesize_minimal_esm.jssize | 1 + test/other/codesize/test_codesize_minimal_esm.sent | 1 + test/other/codesize/test_codesize_minimal_esm.size | 1 + test/test_other.py | 1 + 8 files changed, 12 insertions(+) create mode 100644 test/other/codesize/test_codesize_minimal_esm.exports create mode 100644 test/other/codesize/test_codesize_minimal_esm.funcs create mode 100644 test/other/codesize/test_codesize_minimal_esm.gzsize create mode 100644 test/other/codesize/test_codesize_minimal_esm.imports create mode 100644 test/other/codesize/test_codesize_minimal_esm.jssize create mode 100644 test/other/codesize/test_codesize_minimal_esm.sent create mode 100644 test/other/codesize/test_codesize_minimal_esm.size diff --git a/test/other/codesize/test_codesize_minimal_esm.exports b/test/other/codesize/test_codesize_minimal_esm.exports new file mode 100644 index 0000000000000..cf1318048d1eb --- /dev/null +++ b/test/other/codesize/test_codesize_minimal_esm.exports @@ -0,0 +1,4 @@ +a (memory) +b (__wasm_call_ctors) +c (add) +d (__indirect_function_table) diff --git a/test/other/codesize/test_codesize_minimal_esm.funcs b/test/other/codesize/test_codesize_minimal_esm.funcs new file mode 100644 index 0000000000000..08504a53bdb1b --- /dev/null +++ b/test/other/codesize/test_codesize_minimal_esm.funcs @@ -0,0 +1,2 @@ +$__wasm_call_ctors +$add diff --git a/test/other/codesize/test_codesize_minimal_esm.gzsize b/test/other/codesize/test_codesize_minimal_esm.gzsize new file mode 100644 index 0000000000000..50989ffea157c --- /dev/null +++ b/test/other/codesize/test_codesize_minimal_esm.gzsize @@ -0,0 +1 @@ +1400 diff --git a/test/other/codesize/test_codesize_minimal_esm.imports b/test/other/codesize/test_codesize_minimal_esm.imports new file mode 100644 index 0000000000000..8b137891791fe --- /dev/null +++ b/test/other/codesize/test_codesize_minimal_esm.imports @@ -0,0 +1 @@ + diff --git a/test/other/codesize/test_codesize_minimal_esm.jssize b/test/other/codesize/test_codesize_minimal_esm.jssize new file mode 100644 index 0000000000000..9b860457fa607 --- /dev/null +++ b/test/other/codesize/test_codesize_minimal_esm.jssize @@ -0,0 +1 @@ +2865 diff --git a/test/other/codesize/test_codesize_minimal_esm.sent b/test/other/codesize/test_codesize_minimal_esm.sent new file mode 100644 index 0000000000000..8b137891791fe --- /dev/null +++ b/test/other/codesize/test_codesize_minimal_esm.sent @@ -0,0 +1 @@ + diff --git a/test/other/codesize/test_codesize_minimal_esm.size b/test/other/codesize/test_codesize_minimal_esm.size new file mode 100644 index 0000000000000..d69c74c8b95c8 --- /dev/null +++ b/test/other/codesize/test_codesize_minimal_esm.size @@ -0,0 +1 @@ +73 diff --git a/test/test_other.py b/test/test_other.py index e44c647af12a6..79c7c8d426263 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -8846,6 +8846,7 @@ def strip_numeric_suffixes(funcname): '64': (['-Oz', '-sMEMORY64'], [], []), # noqa # WasmFS should not be fully linked into a minimal program. 'wasmfs': (['-Oz', '-sWASMFS'], [], []), # noqa + 'esm': (['-Oz', '-sEXPORT_ES6'], [], []), # noqa }) def test_codesize_minimal(self, *args): self.set_setting('STRICT') From 9d15e2439b93f79cdb52d370f3dcc7b31eaf75cc Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 18 Dec 2024 11:56:29 -0800 Subject: [PATCH 105/132] Automatic rebaseline of codesize expectations. NFC This is an automatic change generated by tools/maint/rebaseline_tests.py. The following (20) test expectation files were updated by running the tests with `--rebaseline`: ``` other/codesize/test_codesize_cxx_ctors1.gzsize: 8505 => 8507 [+2 bytes / +0.02%] other/codesize/test_codesize_cxx_ctors1.jssize: 20848 => 20871 [+23 bytes / +0.11%] other/codesize/test_codesize_cxx_ctors2.gzsize: 8489 => 8491 [+2 bytes / +0.02%] other/codesize/test_codesize_cxx_ctors2.jssize: 20816 => 20839 [+23 bytes / +0.11%] other/codesize/test_codesize_cxx_except.gzsize: 9532 => 9537 [+5 bytes / +0.05%] other/codesize/test_codesize_cxx_except.jssize: 24693 => 24716 [+23 bytes / +0.09%] other/codesize/test_codesize_cxx_except_wasm.gzsize: 8462 => 8467 [+5 bytes / +0.06%] other/codesize/test_codesize_cxx_except_wasm.jssize: 20742 => 20765 [+23 bytes / +0.11%] other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize: 8462 => 8467 [+5 bytes / +0.06%] other/codesize/test_codesize_cxx_except_wasm_exnref.jssize: 20742 => 20765 [+23 bytes / +0.11%] other/codesize/test_codesize_cxx_lto.gzsize: 8403 => 8406 [+3 bytes / +0.04%] other/codesize/test_codesize_cxx_lto.jssize: 20432 => 20455 [+23 bytes / +0.11%] other/codesize/test_codesize_cxx_mangle.gzsize: 9535 => 9541 [+6 bytes / +0.06%] other/codesize/test_codesize_cxx_mangle.jssize: 24693 => 24716 [+23 bytes / +0.09%] other/codesize/test_codesize_cxx_noexcept.gzsize: 8505 => 8507 [+2 bytes / +0.02%] other/codesize/test_codesize_cxx_noexcept.jssize: 20848 => 20871 [+23 bytes / +0.11%] other/codesize/test_codesize_files_js_fs.gzsize: 7643 => 7646 [+3 bytes / +0.04%] other/codesize/test_codesize_files_js_fs.jssize: 18761 => 18784 [+23 bytes / +0.12%] other/codesize/test_codesize_minimal_esm.gzsize: 1400 => 1487 [+87 bytes / +6.21%] other/codesize/test_codesize_minimal_esm.jssize: 2865 => 3095 [+230 bytes / +8.03%] Average change: +0.78% (+0.02% - +8.03%) ``` --- test/other/codesize/test_codesize_cxx_ctors1.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors1.jssize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.jssize | 2 +- test/other/codesize/test_codesize_cxx_except.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.jssize | 2 +- test/other/codesize/test_codesize_cxx_mangle.gzsize | 2 +- test/other/codesize/test_codesize_cxx_mangle.jssize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.gzsize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.jssize | 2 +- test/other/codesize/test_codesize_files_js_fs.gzsize | 2 +- test/other/codesize/test_codesize_files_js_fs.jssize | 2 +- test/other/codesize/test_codesize_minimal_esm.gzsize | 2 +- test/other/codesize/test_codesize_minimal_esm.jssize | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index f88e926d6de12..46d2642cd5ff6 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8505 +8507 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index eafc8d2f9caf7..1ef4c19069463 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20848 +20871 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index 4d6a5c2242ae0..7c325c18dbb27 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8489 +8491 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 3e49717861889..27cf90d8e32cf 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20816 +20839 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index d5633366b7d2d..527aa10c5664b 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9532 +9537 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index ef8d02c7b4c52..bef4f04c14b42 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24693 +24716 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index 357af50996d0e..e480013c31d9e 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8462 +8467 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index 1d3d5514a0f88..f9b02e898e2f7 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20742 +20765 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index 357af50996d0e..e480013c31d9e 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8462 +8467 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index 1d3d5514a0f88..f9b02e898e2f7 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20742 +20765 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index b5d5c1576b065..9fa65500fcae8 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8403 +8406 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 6428ac978c3f2..6b82b8bab281e 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20432 +20455 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index d54fe857c2e89..e237f91b5925d 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9535 +9541 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index ef8d02c7b4c52..bef4f04c14b42 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24693 +24716 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index f88e926d6de12..46d2642cd5ff6 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8505 +8507 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index eafc8d2f9caf7..1ef4c19069463 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20848 +20871 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index b1ae2d54cfb87..d7b618a3dc7f6 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7643 +7646 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index 0f2d337842a24..ffdc6a7d818a0 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18761 +18784 diff --git a/test/other/codesize/test_codesize_minimal_esm.gzsize b/test/other/codesize/test_codesize_minimal_esm.gzsize index 50989ffea157c..84abd852d3092 100644 --- a/test/other/codesize/test_codesize_minimal_esm.gzsize +++ b/test/other/codesize/test_codesize_minimal_esm.gzsize @@ -1 +1 @@ -1400 +1487 diff --git a/test/other/codesize/test_codesize_minimal_esm.jssize b/test/other/codesize/test_codesize_minimal_esm.jssize index 9b860457fa607..1877dcdd8387c 100644 --- a/test/other/codesize/test_codesize_minimal_esm.jssize +++ b/test/other/codesize/test_codesize_minimal_esm.jssize @@ -1 +1 @@ -2865 +3095 From dea1bf91f9b5b21cb76d6ddd12bcd54cd99e9c3f Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 18 Dec 2024 12:02:47 -0800 Subject: [PATCH 106/132] Micro-optimize PATH.basename. NFC (#23198) The following (18) test expectation files were updated by running the tests with `--rebaseline`: ``` other/codesize/test_codesize_cxx_ctors1.gzsize: 8507 => 8482 [-25 bytes / -0.29%] other/codesize/test_codesize_cxx_ctors1.jssize: 20871 => 20818 [-53 bytes / -0.25%] other/codesize/test_codesize_cxx_ctors2.gzsize: 8491 => 8466 [-25 bytes / -0.29%] other/codesize/test_codesize_cxx_ctors2.jssize: 20839 => 20786 [-53 bytes / -0.25%] other/codesize/test_codesize_cxx_except.gzsize: 9537 => 9516 [-21 bytes / -0.22%] other/codesize/test_codesize_cxx_except.jssize: 24716 => 24663 [-53 bytes / -0.21%] other/codesize/test_codesize_cxx_except_wasm.gzsize: 8467 => 8443 [-24 bytes / -0.28%] other/codesize/test_codesize_cxx_except_wasm.jssize: 20765 => 20711 [-54 bytes / -0.26%] other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize: 8467 => 8443 [-24 bytes / -0.28%] other/codesize/test_codesize_cxx_except_wasm_exnref.jssize: 20765 => 20711 [-54 bytes / -0.26%] other/codesize/test_codesize_cxx_lto.gzsize: 8406 => 8389 [-17 bytes / -0.20%] other/codesize/test_codesize_cxx_lto.jssize: 20455 => 20402 [-53 bytes / -0.26%] other/codesize/test_codesize_cxx_mangle.gzsize: 9541 => 9523 [-18 bytes / -0.19%] other/codesize/test_codesize_cxx_mangle.jssize: 24716 => 24663 [-53 bytes / -0.21%] other/codesize/test_codesize_cxx_noexcept.gzsize: 8507 => 8482 [-25 bytes / -0.29%] other/codesize/test_codesize_cxx_noexcept.jssize: 20871 => 20818 [-53 bytes / -0.25%] other/codesize/test_codesize_files_js_fs.gzsize: 7646 => 7621 [-25 bytes / -0.33%] other/codesize/test_codesize_files_js_fs.jssize: 18784 => 18731 [-53 bytes / -0.28%] Average change: -0.26% (-0.33% - -0.19%) ``` --- src/library_path.js | 11 +++-------- test/other/codesize/test_codesize_cxx_ctors1.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors1.jssize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.jssize | 2 +- test/other/codesize/test_codesize_cxx_except.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except.jssize | 2 +- .../codesize/test_codesize_cxx_except_wasm.gzsize | 2 +- .../codesize/test_codesize_cxx_except_wasm.jssize | 2 +- .../test_codesize_cxx_except_wasm_exnref.gzsize | 2 +- .../test_codesize_cxx_except_wasm_exnref.jssize | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.jssize | 2 +- test/other/codesize/test_codesize_cxx_mangle.gzsize | 2 +- test/other/codesize/test_codesize_cxx_mangle.jssize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.gzsize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.jssize | 2 +- test/other/codesize/test_codesize_files_js_fs.gzsize | 2 +- test/other/codesize/test_codesize_files_js_fs.jssize | 2 +- 19 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/library_path.js b/src/library_path.js index fd5fec3dc2c46..b1ff8364afb76 100644 --- a/src/library_path.js +++ b/src/library_path.js @@ -63,14 +63,9 @@ addToLibrary({ } return root + dir; }, - basename: (path) => { - // EMSCRIPTEN return '/' for '/', not an empty string - if (path === '/') return '/'; - path = path.replace(/\/+$/g, ""); - var lastSlash = path.lastIndexOf('/'); - if (lastSlash === -1) return path; - return path.substr(lastSlash+1); - }, + // This differs from node's path.basename in that it returns '/' for '/' + // rather than the empty string. + basename: (path) => path && path.match(/([^\/]+|\/)\/*$/)[1], join: (...paths) => PATH.normalize(paths.join('/')), join2: (l, r) => PATH.normalize(l + '/' + r), }, diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 46d2642cd5ff6..f8c4d739e8274 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8507 +8482 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index 1ef4c19069463..3b3bc5532ae28 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20871 +20818 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index 7c325c18dbb27..6ed96170748c2 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8491 +8466 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 27cf90d8e32cf..035c83c3d83de 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20839 +20786 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 527aa10c5664b..e0a4790acc2ab 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9537 +9516 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index bef4f04c14b42..5540250d5313e 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24716 +24663 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index e480013c31d9e..eb60637f84202 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8467 +8443 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index f9b02e898e2f7..61b087013e3d6 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20765 +20711 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index e480013c31d9e..eb60637f84202 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8467 +8443 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index f9b02e898e2f7..61b087013e3d6 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20765 +20711 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 9fa65500fcae8..638eae8034903 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8406 +8389 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 6b82b8bab281e..6b1a29e39cd0b 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20455 +20402 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index e237f91b5925d..644357aa4e240 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9541 +9523 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index bef4f04c14b42..5540250d5313e 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24716 +24663 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 46d2642cd5ff6..f8c4d739e8274 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8507 +8482 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index 1ef4c19069463..3b3bc5532ae28 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20871 +20818 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index d7b618a3dc7f6..7afd85884af0e 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7646 +7621 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index ffdc6a7d818a0..9aa6c5e6556ea 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18784 +18731 From 79177cc016fcc2b0aff7a4b927448aa6832043b5 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 18 Dec 2024 21:29:48 +0100 Subject: [PATCH 107/132] Fix dup of pipe (#23217) Resolves #22030 --- src/library_pipefs.js | 3 +++ test/unistd/pipe.c | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/library_pipefs.js b/src/library_pipefs.js index 88a0ededa9c8d..48c0d06757593 100644 --- a/src/library_pipefs.js +++ b/src/library_pipefs.js @@ -77,6 +77,9 @@ addToLibrary({ return 0; }, + dup(stream) { + stream.node.pipe.refcnt++; + }, ioctl(stream, request, varargs) { return {{{ cDefs.EINVAL }}}; }, diff --git a/test/unistd/pipe.c b/test/unistd/pipe.c index d4d135ff6e16f..af7b336b060a4 100644 --- a/test/unistd/pipe.c +++ b/test/unistd/pipe.c @@ -58,7 +58,7 @@ void test_poll(int *fd, int data_available) { assert(pfds[1].revents == POLLOUT); } -int main() { +int test_most() { int fd[2]; unsigned char wchar = 0; unsigned char rchar = 0; @@ -154,3 +154,36 @@ int main() { puts("success"); return 0; } + +int test_redirect_stderr_to_pipe() { + int stderrfd = fileno(stderr); + int pipefd[2]; + int original_fd = dup(stderrfd); // duplicate stderr to original_fd, and original_fd is used to restore stderr later + assert(original_fd >= 0); + assert(pipe(pipefd) == 0); + + int read_end_fd = pipefd[0]; + int write_end_fd = pipefd[1]; + + assert(dup2(write_end_fd, stderrfd) == stderrfd); // now things write to fd(stderr) is redirected to write_end_fd + assert(close(write_end_fd) == 0); // close the write end of the pipe after duplicating + + assert(write(stderrfd, "xyz", 3) == 3); // write to the stderr, expected to be read from pipe + + assert(dup2(original_fd, stderrfd) == stderrfd); // restore fd (stderr) to its original state + assert(close(original_fd) == 0); + + char buffer[10]; + memset(buffer, 0, 10); + assert(read(read_end_fd, buffer, 10) == 3); + assert(strcmp(buffer, "xyz") == 0); + assert(close(read_end_fd) == 0); // Close the read end of the pipe + printf("success\n"); + return 0; +} + +int main() { + test_most(); + test_redirect_stderr_to_pipe(); + return 0; +} From 669e01ab154a5adabb28a04fce03c48a1e77b734 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 18 Dec 2024 13:38:33 -0800 Subject: [PATCH 108/132] Assert if `MODULARIZE` factory function is used with `new`. (#23210) Once we start using `async` for for this function then `new` stops working: https://github.com/emscripten-core/emscripten/pull/23157. Using `new` in this was was always an antipattern but there was nothing atopping users from doing this. --- ChangeLog.md | 5 +++++ test/test_browser.py | 35 +++++++++++++---------------------- test/test_other.py | 6 ++++++ tools/link.py | 13 +++++++++++++ 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 05d25fe02c842..c8aec8d73c0a7 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -20,6 +20,11 @@ See docs/process.md for more on how version tagging works. 3.1.75 (in development) ----------------------- +- When using `-sMODULARIZE` we now assert if the factory function is called with + the JS `new` keyword. e.g. `a = new Module()` rather than `b = Module()`. + This paves the way for marking the function as `async` which does not allow + `new` to be used. This usage of `new` here was never documented and is + considered and antipattern. (#23210) - `PATH.basename()` no longer calls `PATH.normalize()`, so that `PATH.basename("a/.")` returns `"."` instead of `"a"` and `PATH.basename("a/b/..")` returns `".."` instead of `"a"`. This is in line with diff --git a/test/test_browser.py b/test/test_browser.py index 04d3353faf1bc..6398a5b917d4d 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -4795,28 +4795,19 @@ def test_browser_run_from_different_directory(self): # Similar to `test_browser_run_from_different_directory`, but asynchronous because of `-sMODULARIZE` def test_browser_run_from_different_directory_async(self): - for args, creations in [ - (['-sMODULARIZE'], [ - 'Module();', # documented way for using modularize - 'new Module();' # not documented as working, but we support it - ]), - ]: - print(args) - # compile the code with the modularize feature and the preload-file option enabled - self.compile_btest('browser_test_hello_world.c', ['-o', 'test.js', '-O3'] + args) - ensure_dir('subdir') - shutil.move('test.js', Path('subdir/test.js')) - shutil.move('test.wasm', Path('subdir/test.wasm')) - for creation in creations: - print(creation) - # Make sure JS is loaded from subdirectory - create_file('test-subdir.html', ''' - - - ''' % creation) - self.run_browser('test-subdir.html', '/report_result?0') + # compile the code with the modularize feature and the preload-file option enabled + self.compile_btest('browser_test_hello_world.c', ['-o', 'test.js', '-O3', '-sMODULARIZE']) + ensure_dir('subdir') + shutil.move('test.js', Path('subdir/test.js')) + shutil.move('test.wasm', Path('subdir/test.wasm')) + # Make sure JS is loaded from subdirectory + create_file('test-subdir.html', ''' + + + ''') + self.run_browser('test-subdir.html', '/report_result?0') # Similar to `test_browser_run_from_different_directory`, but # also also we eval the initial code, so currentScript is not present. That prevents us diff --git a/test/test_other.py b/test/test_other.py index 79c7c8d426263..17fd201531c02 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -6774,6 +6774,12 @@ def test_modularize_strict(self): output = self.run_js('run.js') self.assertEqual(output, 'hello, world!\n') + def test_modularize_new_misuse(self): + self.run_process([EMCC, test_file('hello_world.c'), '-sMODULARIZE', '-sEXPORT_NAME=Foo']) + create_file('run.js', 'var m = require("./a.out.js"); new m();') + err = self.run_js('run.js', assert_returncode=NON_ZERO) + self.assertContained('Error: Foo() should not be called with `new Foo()`', err) + @parameterized({ '': ([],), 'export_name': (['-sEXPORT_NAME=Foo'],), diff --git a/tools/link.py b/tools/link.py index 7f75ef4edb435..88ef0822e8a23 100644 --- a/tools/link.py +++ b/tools/link.py @@ -2452,6 +2452,19 @@ def modularize(): 'wrapper_function': wrapper_function, } + if settings.ASSERTIONS and settings.MODULARIZE != 'instance': + src += '''\ +(() => { + // Create a small, never-async wrapper around %(EXPORT_NAME)s which + // checks for callers incorrectly using it with `new`. + var real_%(EXPORT_NAME)s = %(EXPORT_NAME)s; + %(EXPORT_NAME)s = function(arg) { + if (new.target) throw new Error("%(EXPORT_NAME)s() should not be called with `new %(EXPORT_NAME)s()`"); + return real_%(EXPORT_NAME)s(arg); + } +})(); +''' % {'EXPORT_NAME': settings.EXPORT_NAME} + # Given the async nature of how the Module function and Module object # come into existence in AudioWorkletGlobalScope, store the Module # function under a different variable name so that AudioWorkletGlobalScope From d9d60a1e347358e24e6da26cf8dfbe07bda95459 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 18 Dec 2024 22:57:46 +0100 Subject: [PATCH 109/132] Return EISDIR when trying to create a path ending in / with open (#23135) If we open a path that in a / and we're about to create a file, instead return EISDIR. --- src/library_fs.js | 4 ++++ test/fs/test_enotdir.c | 17 ----------------- test/fs/test_enotdir.out | 1 - test/fs/test_fs_enotdir.c | 24 ++++++++++++++++++++++++ test/test_core.py | 6 ++++-- 5 files changed, 32 insertions(+), 20 deletions(-) delete mode 100644 test/fs/test_enotdir.c delete mode 100644 test/fs/test_enotdir.out create mode 100644 test/fs/test_fs_enotdir.c diff --git a/src/library_fs.js b/src/library_fs.js index ada447d171c18..0af7a7466d808 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -1060,9 +1060,11 @@ FS.staticInit(); mode = 0; } var node; + var isDirPath; if (typeof path == 'object') { node = path; } else { + isDirPath = path.endsWith("/"); // noent_okay makes it so that if the final component of the path // doesn't exist, lookupPath returns `node: undefined`. `path` will be // updated to point to the target of all symlinks. @@ -1081,6 +1083,8 @@ FS.staticInit(); if ((flags & {{{ cDefs.O_EXCL }}})) { throw new FS.ErrnoError({{{ cDefs.EEXIST }}}); } + } else if (isDirPath) { + throw new FS.ErrnoError({{{ cDefs.EISDIR }}}); } else { // node doesn't exist, try to create it node = FS.mknod(path, mode, 0); diff --git a/test/fs/test_enotdir.c b/test/fs/test_enotdir.c deleted file mode 100644 index 0f9bb5f4509ad..0000000000000 --- a/test/fs/test_enotdir.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include -#include -#include -#include -#include - -int main() { - { - int src_fd = open("file", O_CREAT | O_WRONLY, 0777); - close(src_fd); - } - { - int target_fd = mkdir("file/blah", 0777); - printf("target_fd: %d, errno: %d %s\n", target_fd, errno, strerror(errno)); - } -} diff --git a/test/fs/test_enotdir.out b/test/fs/test_enotdir.out deleted file mode 100644 index 55c2464fc101c..0000000000000 --- a/test/fs/test_enotdir.out +++ /dev/null @@ -1 +0,0 @@ -target_fd: -1, errno: 54 Not a directory diff --git a/test/fs/test_fs_enotdir.c b/test/fs/test_fs_enotdir.c new file mode 100644 index 0000000000000..e221ed8e59304 --- /dev/null +++ b/test/fs/test_fs_enotdir.c @@ -0,0 +1,24 @@ +#include +#include +#include +#include +#include +#include +#include + +int main() { + { + int src_fd = open("file", O_CREAT | O_WRONLY, 0777); + assert(src_fd >= 0); + assert(close(src_fd) == 0); + } + { + assert(mkdir("file/blah", 0777) == -1); + assert(errno == ENOTDIR); + } + { + assert(open("./does-not-exist/", O_CREAT) == -1); + assert(errno == EISDIR); + } + printf("success\n"); +} diff --git a/test/test_core.py b/test/test_core.py index cbdf449ec1d0e..c063ef74a561e 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5756,9 +5756,11 @@ def test_fs_emptyPath(self): @no_windows('https://github.com/emscripten-core/emscripten/issues/8882') @crossplatform - @also_with_noderawfs + @also_with_nodefs_both def test_fs_enotdir(self): - self.do_run_in_out_file_test('fs/test_enotdir.c') + if MACOS and '-DNODERAWFS' in self.emcc_args: + self.skipTest('BSD libc sets a different errno') + self.do_runf('fs/test_fs_enotdir.c', 'success') @also_with_noderawfs def test_fs_append(self): From 91f9825b9b63885fb3d6ba433ab5852591882304 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 18 Dec 2024 14:10:33 -0800 Subject: [PATCH 110/132] Automatic rebaseline of codesize expectations. NFC This is an automatic change generated by tools/maint/rebaseline_tests.py. The following (18) test expectation files were updated by running the tests with `--rebaseline`: ``` other/codesize/test_codesize_cxx_ctors1.gzsize: 8482 => 8502 [+20 bytes / +0.24%] other/codesize/test_codesize_cxx_ctors1.jssize: 20818 => 20867 [+49 bytes / +0.24%] other/codesize/test_codesize_cxx_ctors2.gzsize: 8466 => 8486 [+20 bytes / +0.24%] other/codesize/test_codesize_cxx_ctors2.jssize: 20786 => 20835 [+49 bytes / +0.24%] other/codesize/test_codesize_cxx_except.gzsize: 9516 => 9533 [+17 bytes / +0.18%] other/codesize/test_codesize_cxx_except.jssize: 24663 => 24712 [+49 bytes / +0.20%] other/codesize/test_codesize_cxx_except_wasm.gzsize: 8443 => 8464 [+21 bytes / +0.25%] other/codesize/test_codesize_cxx_except_wasm.jssize: 20711 => 20760 [+49 bytes / +0.24%] other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize: 8443 => 8464 [+21 bytes / +0.25%] other/codesize/test_codesize_cxx_except_wasm_exnref.jssize: 20711 => 20760 [+49 bytes / +0.24%] other/codesize/test_codesize_cxx_lto.gzsize: 8389 => 8413 [+24 bytes / +0.29%] other/codesize/test_codesize_cxx_lto.jssize: 20402 => 20451 [+49 bytes / +0.24%] other/codesize/test_codesize_cxx_mangle.gzsize: 9523 => 9538 [+15 bytes / +0.16%] other/codesize/test_codesize_cxx_mangle.jssize: 24663 => 24712 [+49 bytes / +0.20%] other/codesize/test_codesize_cxx_noexcept.gzsize: 8482 => 8502 [+20 bytes / +0.24%] other/codesize/test_codesize_cxx_noexcept.jssize: 20818 => 20867 [+49 bytes / +0.24%] other/codesize/test_codesize_files_js_fs.gzsize: 7621 => 7638 [+17 bytes / +0.22%] other/codesize/test_codesize_files_js_fs.jssize: 18731 => 18780 [+49 bytes / +0.26%] Average change: +0.23% (+0.16% - +0.29%) ``` --- test/other/codesize/test_codesize_cxx_ctors1.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors1.jssize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.jssize | 2 +- test/other/codesize/test_codesize_cxx_except.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.jssize | 2 +- test/other/codesize/test_codesize_cxx_mangle.gzsize | 2 +- test/other/codesize/test_codesize_cxx_mangle.jssize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.gzsize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.jssize | 2 +- test/other/codesize/test_codesize_files_js_fs.gzsize | 2 +- test/other/codesize/test_codesize_files_js_fs.jssize | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index f8c4d739e8274..9bef9b47fbd94 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8482 +8502 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index 3b3bc5532ae28..942a20eff6ed2 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20818 +20867 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index 6ed96170748c2..7128aacdbb82c 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8466 +8486 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 035c83c3d83de..00c53f634409a 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20786 +20835 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index e0a4790acc2ab..938002e8fe4a0 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9516 +9533 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 5540250d5313e..95dd8cc2f81df 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24663 +24712 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index eb60637f84202..4b2de216d1132 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8443 +8464 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index 61b087013e3d6..57438dfc4bcaf 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20711 +20760 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index eb60637f84202..4b2de216d1132 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8443 +8464 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index 61b087013e3d6..57438dfc4bcaf 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20711 +20760 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 638eae8034903..925f351390343 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8389 +8413 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 6b1a29e39cd0b..5d9ea2f2da2dc 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20402 +20451 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index 644357aa4e240..3b72d74c9a260 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9523 +9538 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 5540250d5313e..95dd8cc2f81df 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24663 +24712 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index f8c4d739e8274..9bef9b47fbd94 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8482 +8502 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index 3b3bc5532ae28..942a20eff6ed2 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20818 +20867 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index 7afd85884af0e..68d4bb005ee13 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7621 +7638 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index 9aa6c5e6556ea..96e750c1ec4af 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18731 +18780 From 5fe1d6472531c0229865101869ed415b3f51dc50 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 18 Dec 2024 14:33:11 -0800 Subject: [PATCH 111/132] [ci] Fix "Check test expectations" step so it checks out the target branch (#23220) --- .github/workflows/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 023e326d92125..821915ea44462 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,7 @@ jobs: check-expectations: runs-on: ubuntu-latest + if: github.event_name == 'pull_request' steps: - name: Checkout repo uses: actions/checkout@v4 @@ -52,14 +53,15 @@ jobs: echo "JS_ENGINES = [NODE_JS]" >> $EM_CONFIG echo "final config:" cat $EM_CONFIG - - name: Check test expectations on main + - name: Check test expectations on target branch run: | - git checkout origin/main + git checkout ${{ github.base_ref }} + git rev-parse HEAD # Hack to honor changes to rebaseline_tests.py in the current PR git checkout - ./tools/maint/rebaseline_tests.py ./bootstrap if ! ./tools/maint/rebaseline_tests.py --check-only; then - echo "Test expectations are out-of-date on the main branch." + echo "Test expectations are out-of-date on the target branch." echo "You can run `./tools/maint/rebaseline_tests.py --new-branch`" echo "and use it to create a seperate PR." exit 1 From 93d2f8d5e7e0acca5b4e7facfd99c4000dc41464 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Wed, 18 Dec 2024 14:41:19 -0800 Subject: [PATCH 112/132] Enable WASM_BIGINT by default (#22993) Enables by default by temporarily reducing required Safari version. Also includes bugfixes for WASM_BIGINT compatibility. --- ChangeLog.md | 5 +- .../tools_reference/settings_reference.rst | 2 +- src/settings.js | 2 +- src/shell.js | 3 +- test/browser/test_small_js_flags.js.size | 2 +- test/code_size/embind_hello_wasm.json | 12 ++--- test/code_size/embind_val_wasm.json | 12 ++--- test/common.py | 4 +- .../codesize/test_codesize_cxx_ctors1.exports | 5 -- .../codesize/test_codesize_cxx_ctors1.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors1.jssize | 2 +- .../codesize/test_codesize_cxx_ctors1.size | 2 +- .../codesize/test_codesize_cxx_ctors2.exports | 5 -- .../codesize/test_codesize_cxx_ctors2.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors2.jssize | 2 +- .../codesize/test_codesize_cxx_ctors2.size | 2 +- .../codesize/test_codesize_cxx_except.exports | 6 --- .../codesize/test_codesize_cxx_except.gzsize | 2 +- .../codesize/test_codesize_cxx_except.jssize | 2 +- .../codesize/test_codesize_cxx_except.size | 2 +- .../test_codesize_cxx_except_wasm.exports | 5 -- .../test_codesize_cxx_except_wasm.gzsize | 2 +- .../test_codesize_cxx_except_wasm.jssize | 2 +- .../test_codesize_cxx_except_wasm.size | 2 +- ...st_codesize_cxx_except_wasm_exnref.exports | 5 -- ...est_codesize_cxx_except_wasm_exnref.gzsize | 2 +- ...est_codesize_cxx_except_wasm_exnref.jssize | 2 +- .../test_codesize_cxx_except_wasm_exnref.size | 2 +- .../codesize/test_codesize_cxx_lto.gzsize | 2 +- .../codesize/test_codesize_cxx_lto.imports | 16 +++--- .../codesize/test_codesize_cxx_lto.jssize | 2 +- .../other/codesize/test_codesize_cxx_lto.sent | 16 +++--- .../other/codesize/test_codesize_cxx_lto.size | 2 +- .../codesize/test_codesize_cxx_mangle.exports | 6 --- .../codesize/test_codesize_cxx_mangle.gzsize | 2 +- .../codesize/test_codesize_cxx_mangle.jssize | 2 +- .../codesize/test_codesize_cxx_mangle.size | 2 +- .../test_codesize_cxx_noexcept.exports | 5 -- .../test_codesize_cxx_noexcept.gzsize | 2 +- .../test_codesize_cxx_noexcept.jssize | 2 +- .../codesize/test_codesize_cxx_noexcept.size | 2 +- .../codesize/test_codesize_cxx_wasmfs.exports | 8 --- .../codesize/test_codesize_cxx_wasmfs.gzsize | 2 +- .../codesize/test_codesize_cxx_wasmfs.jssize | 2 +- .../codesize/test_codesize_cxx_wasmfs.size | 2 +- .../codesize/test_codesize_files_js_fs.gzsize | 2 +- .../codesize/test_codesize_files_js_fs.jssize | 2 +- .../test_codesize_files_wasmfs.gzsize | 2 +- .../test_codesize_files_wasmfs.jssize | 2 +- .../codesize/test_codesize_hello_O0.exports | 1 - .../codesize/test_codesize_hello_O0.funcs | 4 -- .../codesize/test_codesize_hello_O0.gzsize | 2 +- .../codesize/test_codesize_hello_O0.jssize | 2 +- .../codesize/test_codesize_hello_O0.size | 2 +- .../codesize/test_codesize_hello_O1.exports | 1 - .../codesize/test_codesize_hello_O1.funcs | 4 -- .../codesize/test_codesize_hello_O1.gzsize | 2 +- .../codesize/test_codesize_hello_O1.jssize | 2 +- .../codesize/test_codesize_hello_O1.size | 2 +- .../codesize/test_codesize_hello_O2.exports | 1 - .../codesize/test_codesize_hello_O2.funcs | 1 - .../codesize/test_codesize_hello_O2.gzsize | 2 +- .../codesize/test_codesize_hello_O2.jssize | 2 +- .../codesize/test_codesize_hello_O2.size | 2 +- .../codesize/test_codesize_hello_O3.gzsize | 2 +- .../codesize/test_codesize_hello_O3.jssize | 2 +- .../codesize/test_codesize_hello_Os.gzsize | 2 +- .../codesize/test_codesize_hello_Os.jssize | 2 +- .../codesize/test_codesize_hello_Oz.gzsize | 2 +- .../codesize/test_codesize_hello_Oz.jssize | 2 +- .../test_codesize_hello_dylink.exports | 1 - .../codesize/test_codesize_hello_dylink.funcs | 1 - .../test_codesize_hello_dylink.gzsize | 2 +- .../test_codesize_hello_dylink.jssize | 2 +- .../codesize/test_codesize_hello_dylink.size | 2 +- .../test_codesize_hello_export_nothing.gzsize | 2 +- .../test_codesize_hello_export_nothing.jssize | 2 +- .../test_codesize_hello_wasmfs.gzsize | 2 +- .../test_codesize_hello_wasmfs.jssize | 2 +- .../test_codesize_libcxxabi_message_O3.gzsize | 2 +- .../test_codesize_libcxxabi_message_O3.jssize | 2 +- ...ize_libcxxabi_message_O3_standalone.gzsize | 2 +- ...ize_libcxxabi_message_O3_standalone.jssize | 2 +- .../codesize/test_codesize_mem_O3.gzsize | 2 +- .../codesize/test_codesize_mem_O3.jssize | 2 +- .../codesize/test_codesize_mem_O3_grow.gzsize | 2 +- .../codesize/test_codesize_mem_O3_grow.jssize | 2 +- ...est_codesize_mem_O3_grow_standalone.gzsize | 2 +- ...est_codesize_mem_O3_grow_standalone.jssize | 2 +- .../test_codesize_mem_O3_standalone.gzsize | 2 +- .../test_codesize_mem_O3_standalone.jssize | 2 +- ...test_codesize_mem_O3_standalone_lib.gzsize | 2 +- ...test_codesize_mem_O3_standalone_lib.jssize | 2 +- ...est_codesize_mem_O3_standalone_narg.gzsize | 2 +- ...est_codesize_mem_O3_standalone_narg.jssize | 2 +- ...odesize_mem_O3_standalone_narg_flto.gzsize | 2 +- ...odesize_mem_O3_standalone_narg_flto.jssize | 2 +- .../codesize/test_codesize_minimal_O0.funcs | 2 - .../codesize/test_codesize_minimal_O0.gzsize | 2 +- .../codesize/test_codesize_minimal_O0.jssize | 2 +- .../codesize/test_codesize_minimal_O0.size | 2 +- .../codesize/test_codesize_minimal_O1.funcs | 2 - .../codesize/test_codesize_minimal_O1.gzsize | 2 +- .../codesize/test_codesize_minimal_O1.jssize | 2 +- .../codesize/test_codesize_minimal_O1.size | 2 +- .../codesize/test_codesize_minimal_O2.gzsize | 2 +- .../codesize/test_codesize_minimal_O2.jssize | 2 +- .../codesize/test_codesize_minimal_O3.gzsize | 2 +- .../codesize/test_codesize_minimal_O3.jssize | 2 +- .../codesize/test_codesize_minimal_Os.gzsize | 2 +- .../codesize/test_codesize_minimal_Os.jssize | 2 +- .../test_codesize_minimal_Os_mr.gzsize | 2 +- .../test_codesize_minimal_Os_mr.jssize | 2 +- .../test_codesize_minimal_Oz-ctors.gzsize | 2 +- .../test_codesize_minimal_Oz-ctors.jssize | 2 +- .../codesize/test_codesize_minimal_Oz.gzsize | 2 +- .../codesize/test_codesize_minimal_Oz.jssize | 2 +- .../codesize/test_codesize_minimal_esm.gzsize | 2 +- .../codesize/test_codesize_minimal_esm.jssize | 2 +- .../test_codesize_minimal_pthreads.gzsize | 2 +- .../test_codesize_minimal_pthreads.jssize | 2 +- .../test_codesize_minimal_wasmfs.gzsize | 2 +- .../test_codesize_minimal_wasmfs.jssize | 2 +- .../other/test_INCOMING_MODULE_JS_API.js.size | 2 +- test/other/test_unoptimized_code_size.js.size | 2 +- .../test_unoptimized_code_size.wasm.size | 2 +- ...t_unoptimized_code_size_no_asserts.js.size | 2 +- ...unoptimized_code_size_no_asserts.wasm.size | 2 +- .../test_unoptimized_code_size_strict.js.size | 2 +- ...est_unoptimized_code_size_strict.wasm.size | 2 +- test/return64bit/testbind.js | 12 +++-- ...estbind_bigint.js => testbind_nobigint.js} | 12 ++--- test/test_core.py | 8 ++- test/test_other.py | 50 ++++++++++--------- test/test_sanity.py | 4 +- tools/feature_matrix.py | 9 ++-- tools/link.py | 11 ++++ 137 files changed, 202 insertions(+), 245 deletions(-) rename test/return64bit/{testbind_bigint.js => testbind_nobigint.js} (57%) diff --git a/ChangeLog.md b/ChangeLog.md index c8aec8d73c0a7..7bbade9d415c2 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,7 +4,7 @@ Note that version numbers do not necessarily reflect the amount of changes between versions. A version number reflects a release that is known to pass all tests, and versions may be tagged more or less frequently at different times. -Note that there is *no* ABI compatibility guarantee between versions - the ABI +nNote that there is *no* ABI compatibility guarantee between versions - the ABI may change, so that we can keep improving and optimizing it. The compiler will automatically invalidate system caches when the version number updates, so that libc etc. are rebuilt for you. You should also rebuild object files and @@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works. 3.1.75 (in development) ----------------------- +- The `WASM_BIGINT` feature has been enabled by default. This has the effect that + Wasm i64 values are passed and returned between Wasm and JS as BigInt values + rather than being split by Binaryen into pairs of Numbers. (#22993) - When using `-sMODULARIZE` we now assert if the factory function is called with the JS `new` keyword. e.g. `a = new Module()` rather than `b = Module()`. This paves the way for marking the function as `async` which does not allow diff --git a/site/source/docs/tools_reference/settings_reference.rst b/site/source/docs/tools_reference/settings_reference.rst index 902920c03c9b4..f89d622dcf579 100644 --- a/site/source/docs/tools_reference/settings_reference.rst +++ b/site/source/docs/tools_reference/settings_reference.rst @@ -2189,7 +2189,7 @@ legalize i64s into pairs of i32s, as the wasm VM will use a BigInt where an i64 is used. If WASM_BIGINT is present, the default minimum supported browser versions will be increased to the min version that supports BigInt. -Default value: false +Default value: true .. _emit_producers_section: diff --git a/src/settings.js b/src/settings.js index 6610dc1e781d2..c838823a12e18 100644 --- a/src/settings.js +++ b/src/settings.js @@ -1498,7 +1498,7 @@ var DYNCALLS = false; // i64 is used. If WASM_BIGINT is present, the default minimum supported browser // versions will be increased to the min version that supports BigInt. // [link] -var WASM_BIGINT = false; +var WASM_BIGINT = true; // WebAssembly defines a "producers section" which compilers and tools can // annotate themselves in, and LLVM emits this by default. diff --git a/src/shell.js b/src/shell.js index 36d9e9a4b042f..f0bd6fba612b4 100644 --- a/src/shell.js +++ b/src/shell.js @@ -34,7 +34,8 @@ var Module = typeof {{{ EXPORT_NAME }}} != 'undefined' ? {{{ EXPORT_NAME }}} : { #endif // USE_CLOSURE_COMPILER #if POLYFILL -#if WASM_BIGINT && MIN_SAFARI_VERSION < 150000 +#if WASM_BIGINT && MIN_SAFARI_VERSION < 140100 +// TODO(https://github.com/emscripten-core/emscripten/issues/23184): Fix this back to 150000 // See https://caniuse.com/mdn-javascript_builtins_bigint64array #include "polyfill/bigint64array.js" #endif diff --git a/test/browser/test_small_js_flags.js.size b/test/browser/test_small_js_flags.js.size index 555bb91567fa6..6502cf0229698 100644 --- a/test/browser/test_small_js_flags.js.size +++ b/test/browser/test_small_js_flags.js.size @@ -1 +1 @@ -4297 +4380 diff --git a/test/code_size/embind_hello_wasm.json b/test/code_size/embind_hello_wasm.json index 9d622aa122fca..c9addb6041924 100644 --- a/test/code_size/embind_hello_wasm.json +++ b/test/code_size/embind_hello_wasm.json @@ -1,10 +1,10 @@ { "a.html": 552, "a.html.gz": 380, - "a.js": 9593, - "a.js.gz": 4230, - "a.wasm": 7615, - "a.wasm.gz": 3471, - "total": 17760, - "total_gz": 8081 + "a.js": 9879, + "a.js.gz": 4288, + "a.wasm": 7580, + "a.wasm.gz": 3449, + "total": 18011, + "total_gz": 8117 } diff --git a/test/code_size/embind_val_wasm.json b/test/code_size/embind_val_wasm.json index 69ed419b496d4..503050a61f0d1 100644 --- a/test/code_size/embind_val_wasm.json +++ b/test/code_size/embind_val_wasm.json @@ -1,10 +1,10 @@ { "a.html": 552, "a.html.gz": 380, - "a.js": 6724, - "a.js.gz": 2900, - "a.wasm": 9528, - "a.wasm.gz": 4896, - "total": 16804, - "total_gz": 8176 + "a.js": 7153, + "a.js.gz": 3042, + "a.wasm": 9493, + "a.wasm.gz": 4872, + "total": 17198, + "total_gz": 8294 } diff --git a/test/common.py b/test/common.py index 7f5844adac982..87111f5bd3ebf 100644 --- a/test/common.py +++ b/test/common.py @@ -37,7 +37,7 @@ from tools.shared import get_canonical_temp_dir, path_from_root from tools.utils import MACOS, WINDOWS, read_file, read_binary, write_binary, exit_with_error from tools.settings import COMPILE_TIME_SETTINGS -from tools import shared, line_endings, building, config, utils +from tools import shared, feature_matrix, line_endings, building, config, utils logger = logging.getLogger('common') @@ -1164,6 +1164,8 @@ def setUp(self): if node_version < emcc_min_node_version: self.emcc_args += building.get_emcc_node_flags(node_version) self.emcc_args.append('-Wno-transpile') + if node_version[0] < feature_matrix.min_browser_versions[feature_matrix.Feature.JS_BIGINT_INTEGRATION]['node'] / 10000: + self.emcc_args.append('-sWASM_BIGINT=0') self.v8_args = ['--wasm-staging'] self.env = {} diff --git a/test/other/codesize/test_codesize_cxx_ctors1.exports b/test/other/codesize/test_codesize_cxx_ctors1.exports index 6fc972ce0131f..e8e129078e743 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.exports +++ b/test/other/codesize/test_codesize_cxx_ctors1.exports @@ -2,11 +2,6 @@ __indirect_function_table __wasm_call_ctors _emscripten_stack_alloc _emscripten_stack_restore -dynCall_iiiiiijj -dynCall_iiiiij -dynCall_iiiiijj -dynCall_jiji -dynCall_viijii emscripten_stack_get_current main memory diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 9bef9b47fbd94..629d814f19953 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8502 +8352 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index 942a20eff6ed2..a22508fe1954b 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20867 +20347 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.size b/test/other/codesize/test_codesize_cxx_ctors1.size index 125071c29e4ba..467ff31c3f2cd 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.size +++ b/test/other/codesize/test_codesize_cxx_ctors1.size @@ -1 +1 @@ -129231 +128974 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.exports b/test/other/codesize/test_codesize_cxx_ctors2.exports index fdac55c82b471..5629d338fd12b 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.exports +++ b/test/other/codesize/test_codesize_cxx_ctors2.exports @@ -1,11 +1,6 @@ __indirect_function_table _emscripten_stack_alloc _emscripten_stack_restore -dynCall_iiiiiijj -dynCall_iiiiij -dynCall_iiiiijj -dynCall_jiji -dynCall_viijii emscripten_stack_get_current main memory diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index 7128aacdbb82c..66543c9213fe0 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8486 +8336 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 00c53f634409a..ee93d493df28c 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20835 +20315 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.size b/test/other/codesize/test_codesize_cxx_ctors2.size index 580ebc503462f..5151c7d5ae032 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.size +++ b/test/other/codesize/test_codesize_cxx_ctors2.size @@ -1 +1 @@ -128680 +128423 diff --git a/test/other/codesize/test_codesize_cxx_except.exports b/test/other/codesize/test_codesize_cxx_except.exports index b6247248c84b6..4facc660ec841 100644 --- a/test/other/codesize/test_codesize_cxx_except.exports +++ b/test/other/codesize/test_codesize_cxx_except.exports @@ -8,12 +8,6 @@ __wasm_call_ctors _emscripten_stack_alloc _emscripten_stack_restore _emscripten_tempret_set -dynCall_iiiiiijj -dynCall_iiiiij -dynCall_iiiiijj -dynCall_jiiii -dynCall_jiji -dynCall_viijii emscripten_stack_get_current main memory diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 938002e8fe4a0..1e8ce7e708846 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9533 +9358 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 95dd8cc2f81df..108fb27854780 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24712 +24116 diff --git a/test/other/codesize/test_codesize_cxx_except.size b/test/other/codesize/test_codesize_cxx_except.size index 5563f8a875e81..7a6716bb2a43a 100644 --- a/test/other/codesize/test_codesize_cxx_except.size +++ b/test/other/codesize/test_codesize_cxx_except.size @@ -1 +1 @@ -171361 +171008 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.exports b/test/other/codesize/test_codesize_cxx_except_wasm.exports index 5555bb2a116cb..85bf5bc4006e4 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.exports +++ b/test/other/codesize/test_codesize_cxx_except_wasm.exports @@ -2,10 +2,5 @@ __indirect_function_table __trap __wasm_call_ctors _emscripten_stack_alloc -dynCall_iiiiiijj -dynCall_iiiiij -dynCall_iiiiijj -dynCall_jiji -dynCall_viijii main memory diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index 4b2de216d1132..f14ddc132870a 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8464 +8321 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index 57438dfc4bcaf..b4fb6fa3b6ed0 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20760 +20240 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.size b/test/other/codesize/test_codesize_cxx_except_wasm.size index bfe937c06fe72..ccdf567408898 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm.size @@ -1 +1 @@ -142481 +142223 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.exports b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.exports index 5555bb2a116cb..85bf5bc4006e4 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.exports +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.exports @@ -2,10 +2,5 @@ __indirect_function_table __trap __wasm_call_ctors _emscripten_stack_alloc -dynCall_iiiiiijj -dynCall_iiiiij -dynCall_iiiiijj -dynCall_jiji -dynCall_viijii main memory diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index 4b2de216d1132..f14ddc132870a 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8464 +8321 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index 57438dfc4bcaf..b4fb6fa3b6ed0 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20760 +20240 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size index 27c1d7a0535ff..9fd3641491ec2 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size @@ -1 +1 @@ -145068 +144810 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 925f351390343..7947190fcc750 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8413 +8348 diff --git a/test/other/codesize/test_codesize_cxx_lto.imports b/test/other/codesize/test_codesize_cxx_lto.imports index e03564194ed36..9277703b69e4a 100644 --- a/test/other/codesize/test_codesize_cxx_lto.imports +++ b/test/other/codesize/test_codesize_cxx_lto.imports @@ -1,11 +1,11 @@ -a (fd_seek) -b (emscripten_resize_heap) -c (_tzset_js) -d (_setitimer_js) -e (_emscripten_runtime_keepalive_clear) -f (_abort_js) -g (proc_exit) -h (fd_write) +a (emscripten_resize_heap) +b (_tzset_js) +c (_setitimer_js) +d (_emscripten_runtime_keepalive_clear) +e (_abort_js) +f (proc_exit) +g (fd_write) +h (fd_seek) i (fd_read) j (fd_close) k (environ_sizes_get) diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 5d9ea2f2da2dc..6525ff13db521 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20451 +20371 diff --git a/test/other/codesize/test_codesize_cxx_lto.sent b/test/other/codesize/test_codesize_cxx_lto.sent index e03564194ed36..9277703b69e4a 100644 --- a/test/other/codesize/test_codesize_cxx_lto.sent +++ b/test/other/codesize/test_codesize_cxx_lto.sent @@ -1,11 +1,11 @@ -a (fd_seek) -b (emscripten_resize_heap) -c (_tzset_js) -d (_setitimer_js) -e (_emscripten_runtime_keepalive_clear) -f (_abort_js) -g (proc_exit) -h (fd_write) +a (emscripten_resize_heap) +b (_tzset_js) +c (_setitimer_js) +d (_emscripten_runtime_keepalive_clear) +e (_abort_js) +f (proc_exit) +g (fd_write) +h (fd_seek) i (fd_read) j (fd_close) k (environ_sizes_get) diff --git a/test/other/codesize/test_codesize_cxx_lto.size b/test/other/codesize/test_codesize_cxx_lto.size index 36e2c6d3c0149..b0dea2b9e570d 100644 --- a/test/other/codesize/test_codesize_cxx_lto.size +++ b/test/other/codesize/test_codesize_cxx_lto.size @@ -1 +1 @@ -121923 +121924 diff --git a/test/other/codesize/test_codesize_cxx_mangle.exports b/test/other/codesize/test_codesize_cxx_mangle.exports index 973868ec0db1e..3dae240b66848 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.exports +++ b/test/other/codesize/test_codesize_cxx_mangle.exports @@ -9,12 +9,6 @@ __wasm_call_ctors _emscripten_stack_alloc _emscripten_stack_restore _emscripten_tempret_set -dynCall_iiiiiijj -dynCall_iiiiij -dynCall_iiiiijj -dynCall_jiiii -dynCall_jiji -dynCall_viijii emscripten_stack_get_current free main diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index 3b72d74c9a260..be24a385bb8fd 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9538 +9361 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 95dd8cc2f81df..108fb27854780 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24712 +24116 diff --git a/test/other/codesize/test_codesize_cxx_mangle.size b/test/other/codesize/test_codesize_cxx_mangle.size index fc07430882075..e1078b8c5934e 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.size +++ b/test/other/codesize/test_codesize_cxx_mangle.size @@ -1 +1 @@ -232870 +232517 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.exports b/test/other/codesize/test_codesize_cxx_noexcept.exports index 6fc972ce0131f..e8e129078e743 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.exports +++ b/test/other/codesize/test_codesize_cxx_noexcept.exports @@ -2,11 +2,6 @@ __indirect_function_table __wasm_call_ctors _emscripten_stack_alloc _emscripten_stack_restore -dynCall_iiiiiijj -dynCall_iiiiij -dynCall_iiiiijj -dynCall_jiji -dynCall_viijii emscripten_stack_get_current main memory diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 9bef9b47fbd94..629d814f19953 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8502 +8352 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index 942a20eff6ed2..a22508fe1954b 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20867 +20347 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.size b/test/other/codesize/test_codesize_cxx_noexcept.size index e1072af55a243..232be2fc5f578 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.size +++ b/test/other/codesize/test_codesize_cxx_noexcept.size @@ -1 +1 @@ -132038 +131781 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.exports b/test/other/codesize/test_codesize_cxx_wasmfs.exports index 748b987551d8c..e8e129078e743 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.exports +++ b/test/other/codesize/test_codesize_cxx_wasmfs.exports @@ -2,14 +2,6 @@ __indirect_function_table __wasm_call_ctors _emscripten_stack_alloc _emscripten_stack_restore -dynCall_iiiiiijj -dynCall_iiiiij -dynCall_iiiiijj -dynCall_iiiij -dynCall_iij -dynCall_ji -dynCall_jiji -dynCall_viijii emscripten_stack_get_current main memory diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize index ac5764e2098c7..799c77152539d 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize @@ -1 +1 @@ -3769 +3653 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.jssize b/test/other/codesize/test_codesize_cxx_wasmfs.jssize index c5bde85823b0f..5e97e16bfa535 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.jssize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.jssize @@ -1 +1 @@ -8493 +7914 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.size b/test/other/codesize/test_codesize_cxx_wasmfs.size index 6661bc61e54c3..8c558ef5ce85b 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.size +++ b/test/other/codesize/test_codesize_cxx_wasmfs.size @@ -1 +1 @@ -169290 +168928 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index 68d4bb005ee13..a6589474f60cb 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7638 +7656 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index 96e750c1ec4af..bf4d7a5e763f4 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18780 +18842 diff --git a/test/other/codesize/test_codesize_files_wasmfs.gzsize b/test/other/codesize/test_codesize_files_wasmfs.gzsize index f7374e5edea7f..a17ea6fb4828b 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_files_wasmfs.gzsize @@ -1 +1 @@ -2866 +2882 diff --git a/test/other/codesize/test_codesize_files_wasmfs.jssize b/test/other/codesize/test_codesize_files_wasmfs.jssize index c98f921104b33..2c55bb009ea6c 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.jssize +++ b/test/other/codesize/test_codesize_files_wasmfs.jssize @@ -1 +1 @@ -6140 +6202 diff --git a/test/other/codesize/test_codesize_hello_O0.exports b/test/other/codesize/test_codesize_hello_O0.exports index 46f6d0a6df26a..430c7650c243b 100644 --- a/test/other/codesize/test_codesize_hello_O0.exports +++ b/test/other/codesize/test_codesize_hello_O0.exports @@ -2,7 +2,6 @@ __indirect_function_table __wasm_call_ctors _emscripten_stack_alloc _emscripten_stack_restore -dynCall_jiji emscripten_stack_get_base emscripten_stack_get_current emscripten_stack_get_end diff --git a/test/other/codesize/test_codesize_hello_O0.funcs b/test/other/codesize/test_codesize_hello_O0.funcs index 7b3556720ebea..a1ff7c64739d8 100644 --- a/test/other/codesize/test_codesize_hello_O0.funcs +++ b/test/other/codesize/test_codesize_hello_O0.funcs @@ -25,9 +25,6 @@ $__wasi_syscall_ret $__wasm_call_ctors $_emscripten_stack_alloc $_emscripten_stack_restore -$_emscripten_tempret_get -$_emscripten_tempret_set -$dynCall_jiji $emscripten_stack_get_base $emscripten_stack_get_current $emscripten_stack_get_end @@ -42,7 +39,6 @@ $frexp $getint $getpid $init_pthread_self -$legalstub$dynCall_jiji $main $memchr $out diff --git a/test/other/codesize/test_codesize_hello_O0.gzsize b/test/other/codesize/test_codesize_hello_O0.gzsize index 8ca7d7e2dcf2a..42b603432aefe 100644 --- a/test/other/codesize/test_codesize_hello_O0.gzsize +++ b/test/other/codesize/test_codesize_hello_O0.gzsize @@ -1 +1 @@ -8003 +8017 diff --git a/test/other/codesize/test_codesize_hello_O0.jssize b/test/other/codesize/test_codesize_hello_O0.jssize index 1e88f55d68b32..ca3736fbbb012 100644 --- a/test/other/codesize/test_codesize_hello_O0.jssize +++ b/test/other/codesize/test_codesize_hello_O0.jssize @@ -1 +1 @@ -21535 +21597 diff --git a/test/other/codesize/test_codesize_hello_O0.size b/test/other/codesize/test_codesize_hello_O0.size index b55e8eb4cd221..08a458d71f92f 100644 --- a/test/other/codesize/test_codesize_hello_O0.size +++ b/test/other/codesize/test_codesize_hello_O0.size @@ -1 +1 @@ -14531 +15142 diff --git a/test/other/codesize/test_codesize_hello_O1.exports b/test/other/codesize/test_codesize_hello_O1.exports index 4f4b6313b5239..e8e129078e743 100644 --- a/test/other/codesize/test_codesize_hello_O1.exports +++ b/test/other/codesize/test_codesize_hello_O1.exports @@ -2,7 +2,6 @@ __indirect_function_table __wasm_call_ctors _emscripten_stack_alloc _emscripten_stack_restore -dynCall_jiji emscripten_stack_get_current main memory diff --git a/test/other/codesize/test_codesize_hello_O1.funcs b/test/other/codesize/test_codesize_hello_O1.funcs index f5073582b3f40..68623ee907e22 100644 --- a/test/other/codesize/test_codesize_hello_O1.funcs +++ b/test/other/codesize/test_codesize_hello_O1.funcs @@ -13,13 +13,9 @@ $__wasi_syscall_ret $__wasm_call_ctors $_emscripten_stack_alloc $_emscripten_stack_restore -$_emscripten_tempret_get -$_emscripten_tempret_set -$dynCall_jiji $emscripten_stack_get_current $fputs $fwrite -$legalstub$dynCall_jiji $main $puts $strlen diff --git a/test/other/codesize/test_codesize_hello_O1.gzsize b/test/other/codesize/test_codesize_hello_O1.gzsize index c98e88a99e28f..690c09f1c702d 100644 --- a/test/other/codesize/test_codesize_hello_O1.gzsize +++ b/test/other/codesize/test_codesize_hello_O1.gzsize @@ -1 +1 @@ -2713 +2697 diff --git a/test/other/codesize/test_codesize_hello_O1.jssize b/test/other/codesize/test_codesize_hello_O1.jssize index 6fdb8ccd778a3..8d2e9dfdb7ff4 100644 --- a/test/other/codesize/test_codesize_hello_O1.jssize +++ b/test/other/codesize/test_codesize_hello_O1.jssize @@ -1 +1 @@ -6921 +6911 diff --git a/test/other/codesize/test_codesize_hello_O1.size b/test/other/codesize/test_codesize_hello_O1.size index 48c6e93066ff9..1c4c2ded8919d 100644 --- a/test/other/codesize/test_codesize_hello_O1.size +++ b/test/other/codesize/test_codesize_hello_O1.size @@ -1 +1 @@ -2535 +2634 diff --git a/test/other/codesize/test_codesize_hello_O2.exports b/test/other/codesize/test_codesize_hello_O2.exports index 4f4b6313b5239..e8e129078e743 100644 --- a/test/other/codesize/test_codesize_hello_O2.exports +++ b/test/other/codesize/test_codesize_hello_O2.exports @@ -2,7 +2,6 @@ __indirect_function_table __wasm_call_ctors _emscripten_stack_alloc _emscripten_stack_restore -dynCall_jiji emscripten_stack_get_current main memory diff --git a/test/other/codesize/test_codesize_hello_O2.funcs b/test/other/codesize/test_codesize_hello_O2.funcs index a16df54d7de2c..2206a46aa8d98 100644 --- a/test/other/codesize/test_codesize_hello_O2.funcs +++ b/test/other/codesize/test_codesize_hello_O2.funcs @@ -8,5 +8,4 @@ $__wasm_call_ctors $_emscripten_stack_alloc $_emscripten_stack_restore $emscripten_stack_get_current -$legalstub$dynCall_jiji $main diff --git a/test/other/codesize/test_codesize_hello_O2.gzsize b/test/other/codesize/test_codesize_hello_O2.gzsize index cc278bd694d3e..7d945b944dabc 100644 --- a/test/other/codesize/test_codesize_hello_O2.gzsize +++ b/test/other/codesize/test_codesize_hello_O2.gzsize @@ -1 +1 @@ -2369 +2359 diff --git a/test/other/codesize/test_codesize_hello_O2.jssize b/test/other/codesize/test_codesize_hello_O2.jssize index 30162af6fe2dd..11336821115bf 100644 --- a/test/other/codesize/test_codesize_hello_O2.jssize +++ b/test/other/codesize/test_codesize_hello_O2.jssize @@ -1 +1 @@ -4844 +4835 diff --git a/test/other/codesize/test_codesize_hello_O2.size b/test/other/codesize/test_codesize_hello_O2.size index b6ac305674cf9..d644427299908 100644 --- a/test/other/codesize/test_codesize_hello_O2.size +++ b/test/other/codesize/test_codesize_hello_O2.size @@ -1 +1 @@ -2047 +1999 diff --git a/test/other/codesize/test_codesize_hello_O3.gzsize b/test/other/codesize/test_codesize_hello_O3.gzsize index cc6f0ac7ecffd..3e263d2e556cd 100644 --- a/test/other/codesize/test_codesize_hello_O3.gzsize +++ b/test/other/codesize/test_codesize_hello_O3.gzsize @@ -1 +1 @@ -2283 +2298 diff --git a/test/other/codesize/test_codesize_hello_O3.jssize b/test/other/codesize/test_codesize_hello_O3.jssize index 9bce5583b99b7..c6a2b270f3b7e 100644 --- a/test/other/codesize/test_codesize_hello_O3.jssize +++ b/test/other/codesize/test_codesize_hello_O3.jssize @@ -1 +1 @@ -4695 +4757 diff --git a/test/other/codesize/test_codesize_hello_Os.gzsize b/test/other/codesize/test_codesize_hello_Os.gzsize index cc6f0ac7ecffd..3e263d2e556cd 100644 --- a/test/other/codesize/test_codesize_hello_Os.gzsize +++ b/test/other/codesize/test_codesize_hello_Os.gzsize @@ -1 +1 @@ -2283 +2298 diff --git a/test/other/codesize/test_codesize_hello_Os.jssize b/test/other/codesize/test_codesize_hello_Os.jssize index 9bce5583b99b7..c6a2b270f3b7e 100644 --- a/test/other/codesize/test_codesize_hello_Os.jssize +++ b/test/other/codesize/test_codesize_hello_Os.jssize @@ -1 +1 @@ -4695 +4757 diff --git a/test/other/codesize/test_codesize_hello_Oz.gzsize b/test/other/codesize/test_codesize_hello_Oz.gzsize index 42752c3ef1f12..9294c7754fde1 100644 --- a/test/other/codesize/test_codesize_hello_Oz.gzsize +++ b/test/other/codesize/test_codesize_hello_Oz.gzsize @@ -1 +1 @@ -2265 +2281 diff --git a/test/other/codesize/test_codesize_hello_Oz.jssize b/test/other/codesize/test_codesize_hello_Oz.jssize index 77d471ad303a9..65e5941a842c5 100644 --- a/test/other/codesize/test_codesize_hello_Oz.jssize +++ b/test/other/codesize/test_codesize_hello_Oz.jssize @@ -1 +1 @@ -4662 +4724 diff --git a/test/other/codesize/test_codesize_hello_dylink.exports b/test/other/codesize/test_codesize_hello_dylink.exports index f1e9af5fcfbf2..99ba54eca755a 100644 --- a/test/other/codesize/test_codesize_hello_dylink.exports +++ b/test/other/codesize/test_codesize_hello_dylink.exports @@ -3,7 +3,6 @@ __wasm_call_ctors _emscripten_stack_alloc _emscripten_stack_restore calloc -dynCall_jiji emscripten_stack_get_current main setThrew diff --git a/test/other/codesize/test_codesize_hello_dylink.funcs b/test/other/codesize/test_codesize_hello_dylink.funcs index 2c23b988a7191..cfe13ffbf5f19 100644 --- a/test/other/codesize/test_codesize_hello_dylink.funcs +++ b/test/other/codesize/test_codesize_hello_dylink.funcs @@ -10,7 +10,6 @@ $_emscripten_stack_alloc $_emscripten_stack_restore $dlcalloc $emscripten_stack_get_current -$legalstub$dynCall_jiji $main $sbrk $setThrew diff --git a/test/other/codesize/test_codesize_hello_dylink.gzsize b/test/other/codesize/test_codesize_hello_dylink.gzsize index 06e102d5685af..416368238e9f1 100644 --- a/test/other/codesize/test_codesize_hello_dylink.gzsize +++ b/test/other/codesize/test_codesize_hello_dylink.gzsize @@ -1 +1 @@ -6150 +6023 diff --git a/test/other/codesize/test_codesize_hello_dylink.jssize b/test/other/codesize/test_codesize_hello_dylink.jssize index 7a9400801574e..3e898f1efeb39 100644 --- a/test/other/codesize/test_codesize_hello_dylink.jssize +++ b/test/other/codesize/test_codesize_hello_dylink.jssize @@ -1 +1 @@ -13609 +13300 diff --git a/test/other/codesize/test_codesize_hello_dylink.size b/test/other/codesize/test_codesize_hello_dylink.size index a30e08ecfada3..e95ec6103f385 100644 --- a/test/other/codesize/test_codesize_hello_dylink.size +++ b/test/other/codesize/test_codesize_hello_dylink.size @@ -1 +1 @@ -9784 +9736 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.gzsize b/test/other/codesize/test_codesize_hello_export_nothing.gzsize index 15475a3d5fc2c..889f56ca7ed18 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.gzsize +++ b/test/other/codesize/test_codesize_hello_export_nothing.gzsize @@ -1 +1 @@ -1667 +1682 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.jssize b/test/other/codesize/test_codesize_hello_export_nothing.jssize index 5f3db86bbc3ea..ee72a28badb95 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.jssize +++ b/test/other/codesize/test_codesize_hello_export_nothing.jssize @@ -1 +1 @@ -3575 +3637 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.gzsize b/test/other/codesize/test_codesize_hello_wasmfs.gzsize index cc6f0ac7ecffd..3e263d2e556cd 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_hello_wasmfs.gzsize @@ -1 +1 @@ -2283 +2298 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.jssize b/test/other/codesize/test_codesize_hello_wasmfs.jssize index 9bce5583b99b7..c6a2b270f3b7e 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.jssize +++ b/test/other/codesize/test_codesize_hello_wasmfs.jssize @@ -1 +1 @@ -4695 +4757 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize index 86fc8f4d80b5a..1ea816877702e 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize @@ -1 +1 @@ -1862 +1876 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize index 58f5850ae5fcf..26a4dd33f0015 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize @@ -1 +1 @@ -3938 +4000 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize index 8bae76d7966a2..a7568adae3387 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize @@ -1 +1 @@ -1899 +1914 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize index 6b2af3f880b0c..965493a318306 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize @@ -1 +1 @@ -3986 +4048 diff --git a/test/other/codesize/test_codesize_mem_O3.gzsize b/test/other/codesize/test_codesize_mem_O3.gzsize index 2612554b2d3af..ffcd151c41f04 100644 --- a/test/other/codesize/test_codesize_mem_O3.gzsize +++ b/test/other/codesize/test_codesize_mem_O3.gzsize @@ -1 +1 @@ -2313 +2328 diff --git a/test/other/codesize/test_codesize_mem_O3.jssize b/test/other/codesize/test_codesize_mem_O3.jssize index ddeb3cf88bf70..86a2a1bb17b2e 100644 --- a/test/other/codesize/test_codesize_mem_O3.jssize +++ b/test/other/codesize/test_codesize_mem_O3.jssize @@ -1 +1 @@ -4830 +4892 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.gzsize b/test/other/codesize/test_codesize_mem_O3_grow.gzsize index ea5f1c5174ecc..721cbb13b4aee 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow.gzsize @@ -1 +1 @@ -2461 +2478 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.jssize b/test/other/codesize/test_codesize_mem_O3_grow.jssize index 581cc8f752a1c..5d539952599b9 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow.jssize @@ -1 +1 @@ -5115 +5177 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize index 5e7c8b88a0264..a7ffd709f6523 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize @@ -1 +1 @@ -2164 +2180 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize index 1f440269b96d4..d6dab2a5d3793 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize @@ -1 +1 @@ -4523 +4585 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize index 10c8452b2c3ab..5cc2201e666e5 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize @@ -1 +1 @@ -2128 +2143 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_standalone.jssize index ab5135ded797f..4d4bc2f8db86e 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.jssize @@ -1 +1 @@ -4455 +4517 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize index c34a5b9bd9c60..62a85b862fd04 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize @@ -1 +1 @@ -1885 +1900 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize index 6cd1cb4835d89..61050f20447d0 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize @@ -1 +1 @@ -3985 +4047 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize index 8bae76d7966a2..a7568adae3387 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize @@ -1 +1 @@ -1899 +1914 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize index 6b2af3f880b0c..965493a318306 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize @@ -1 +1 @@ -3986 +4048 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize index 8bae76d7966a2..a7568adae3387 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize @@ -1 +1 @@ -1899 +1914 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize index 6b2af3f880b0c..965493a318306 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize @@ -1 +1 @@ -3986 +4048 diff --git a/test/other/codesize/test_codesize_minimal_O0.funcs b/test/other/codesize/test_codesize_minimal_O0.funcs index c5eb625aa803c..2b87bdddf10b9 100644 --- a/test/other/codesize/test_codesize_minimal_O0.funcs +++ b/test/other/codesize/test_codesize_minimal_O0.funcs @@ -7,8 +7,6 @@ $__unlockfile $__wasm_call_ctors $_emscripten_stack_alloc $_emscripten_stack_restore -$_emscripten_tempret_get -$_emscripten_tempret_set $add $emscripten_stack_get_base $emscripten_stack_get_current diff --git a/test/other/codesize/test_codesize_minimal_O0.gzsize b/test/other/codesize/test_codesize_minimal_O0.gzsize index 8e86bc3df7942..8793d3d379858 100644 --- a/test/other/codesize/test_codesize_minimal_O0.gzsize +++ b/test/other/codesize/test_codesize_minimal_O0.gzsize @@ -1 +1 @@ -6532 +6554 diff --git a/test/other/codesize/test_codesize_minimal_O0.jssize b/test/other/codesize/test_codesize_minimal_O0.jssize index 3cac79a0fee52..406ffb9d96d4c 100644 --- a/test/other/codesize/test_codesize_minimal_O0.jssize +++ b/test/other/codesize/test_codesize_minimal_O0.jssize @@ -1 +1 @@ -17563 +17637 diff --git a/test/other/codesize/test_codesize_minimal_O0.size b/test/other/codesize/test_codesize_minimal_O0.size index 37cdd416f157a..0141c45d767b7 100644 --- a/test/other/codesize/test_codesize_minimal_O0.size +++ b/test/other/codesize/test_codesize_minimal_O0.size @@ -1 +1 @@ -975 +1104 diff --git a/test/other/codesize/test_codesize_minimal_O1.funcs b/test/other/codesize/test_codesize_minimal_O1.funcs index 891bb2f267dcb..819f7d5bf2b03 100644 --- a/test/other/codesize/test_codesize_minimal_O1.funcs +++ b/test/other/codesize/test_codesize_minimal_O1.funcs @@ -1,7 +1,5 @@ $__wasm_call_ctors $_emscripten_stack_alloc $_emscripten_stack_restore -$_emscripten_tempret_get -$_emscripten_tempret_set $add $emscripten_stack_get_current diff --git a/test/other/codesize/test_codesize_minimal_O1.gzsize b/test/other/codesize/test_codesize_minimal_O1.gzsize index f02edd5f91078..45ff3acb5f914 100644 --- a/test/other/codesize/test_codesize_minimal_O1.gzsize +++ b/test/other/codesize/test_codesize_minimal_O1.gzsize @@ -1 +1 @@ -1520 +1531 diff --git a/test/other/codesize/test_codesize_minimal_O1.jssize b/test/other/codesize/test_codesize_minimal_O1.jssize index 7cca7c9e17bf6..f76268c8b2ac3 100644 --- a/test/other/codesize/test_codesize_minimal_O1.jssize +++ b/test/other/codesize/test_codesize_minimal_O1.jssize @@ -1 +1 @@ -3664 +3713 diff --git a/test/other/codesize/test_codesize_minimal_O1.size b/test/other/codesize/test_codesize_minimal_O1.size index 100000a67875f..8b84f57086ba5 100644 --- a/test/other/codesize/test_codesize_minimal_O1.size +++ b/test/other/codesize/test_codesize_minimal_O1.size @@ -1 +1 @@ -376 +397 diff --git a/test/other/codesize/test_codesize_minimal_O2.gzsize b/test/other/codesize/test_codesize_minimal_O2.gzsize index 5ae289b43f8d7..a3d3785badfdf 100644 --- a/test/other/codesize/test_codesize_minimal_O2.gzsize +++ b/test/other/codesize/test_codesize_minimal_O2.gzsize @@ -1 +1 @@ -1371 +1380 diff --git a/test/other/codesize/test_codesize_minimal_O2.jssize b/test/other/codesize/test_codesize_minimal_O2.jssize index aa57446358cb9..e88d628aa7ae4 100644 --- a/test/other/codesize/test_codesize_minimal_O2.jssize +++ b/test/other/codesize/test_codesize_minimal_O2.jssize @@ -1 +1 @@ -2769 +2812 diff --git a/test/other/codesize/test_codesize_minimal_O3.gzsize b/test/other/codesize/test_codesize_minimal_O3.gzsize index 7345521b14101..cd692fa07fb1d 100644 --- a/test/other/codesize/test_codesize_minimal_O3.gzsize +++ b/test/other/codesize/test_codesize_minimal_O3.gzsize @@ -1 +1 @@ -1336 +1346 diff --git a/test/other/codesize/test_codesize_minimal_O3.jssize b/test/other/codesize/test_codesize_minimal_O3.jssize index 8ef17f6cef8d3..9f876b5c8336c 100644 --- a/test/other/codesize/test_codesize_minimal_O3.jssize +++ b/test/other/codesize/test_codesize_minimal_O3.jssize @@ -1 +1 @@ -2719 +2762 diff --git a/test/other/codesize/test_codesize_minimal_Os.gzsize b/test/other/codesize/test_codesize_minimal_Os.gzsize index 7345521b14101..cd692fa07fb1d 100644 --- a/test/other/codesize/test_codesize_minimal_Os.gzsize +++ b/test/other/codesize/test_codesize_minimal_Os.gzsize @@ -1 +1 @@ -1336 +1346 diff --git a/test/other/codesize/test_codesize_minimal_Os.jssize b/test/other/codesize/test_codesize_minimal_Os.jssize index 8ef17f6cef8d3..9f876b5c8336c 100644 --- a/test/other/codesize/test_codesize_minimal_Os.jssize +++ b/test/other/codesize/test_codesize_minimal_Os.jssize @@ -1 +1 @@ -2719 +2762 diff --git a/test/other/codesize/test_codesize_minimal_Os_mr.gzsize b/test/other/codesize/test_codesize_minimal_Os_mr.gzsize index 6d26270b57e67..4438e30535f75 100644 --- a/test/other/codesize/test_codesize_minimal_Os_mr.gzsize +++ b/test/other/codesize/test_codesize_minimal_Os_mr.gzsize @@ -1 +1 @@ -283 +293 diff --git a/test/other/codesize/test_codesize_minimal_Os_mr.jssize b/test/other/codesize/test_codesize_minimal_Os_mr.jssize index ed4f162019058..5f3bb9813eade 100644 --- a/test/other/codesize/test_codesize_minimal_Os_mr.jssize +++ b/test/other/codesize/test_codesize_minimal_Os_mr.jssize @@ -1 +1 @@ -431 +474 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize index d378cb0bf85c3..a9449958c6a77 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize @@ -1 +1 @@ -1327 +1338 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize index f3bb5816bff9b..0e4b8c8ebc97d 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize @@ -1 +1 @@ -2704 +2747 diff --git a/test/other/codesize/test_codesize_minimal_Oz.gzsize b/test/other/codesize/test_codesize_minimal_Oz.gzsize index 7345521b14101..cd692fa07fb1d 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz.gzsize @@ -1 +1 @@ -1336 +1346 diff --git a/test/other/codesize/test_codesize_minimal_Oz.jssize b/test/other/codesize/test_codesize_minimal_Oz.jssize index 8ef17f6cef8d3..9f876b5c8336c 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz.jssize @@ -1 +1 @@ -2719 +2762 diff --git a/test/other/codesize/test_codesize_minimal_esm.gzsize b/test/other/codesize/test_codesize_minimal_esm.gzsize index 84abd852d3092..9639a4ce0392a 100644 --- a/test/other/codesize/test_codesize_minimal_esm.gzsize +++ b/test/other/codesize/test_codesize_minimal_esm.gzsize @@ -1 +1 @@ -1487 +1496 diff --git a/test/other/codesize/test_codesize_minimal_esm.jssize b/test/other/codesize/test_codesize_minimal_esm.jssize index 1877dcdd8387c..46b6da4851e58 100644 --- a/test/other/codesize/test_codesize_minimal_esm.jssize +++ b/test/other/codesize/test_codesize_minimal_esm.jssize @@ -1 +1 @@ -3095 +3138 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.gzsize b/test/other/codesize/test_codesize_minimal_pthreads.gzsize index 529e64fdfb43e..5255d8eda08aa 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.gzsize +++ b/test/other/codesize/test_codesize_minimal_pthreads.gzsize @@ -1 +1 @@ -4118 +4184 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.jssize b/test/other/codesize/test_codesize_minimal_pthreads.jssize index e4b77e6fc2965..c9e63f57e5ed2 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.jssize +++ b/test/other/codesize/test_codesize_minimal_pthreads.jssize @@ -1 +1 @@ -8556 +8711 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize index 7345521b14101..cd692fa07fb1d 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize @@ -1 +1 @@ -1336 +1346 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.jssize b/test/other/codesize/test_codesize_minimal_wasmfs.jssize index 8ef17f6cef8d3..9f876b5c8336c 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.jssize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.jssize @@ -1 +1 @@ -2719 +2762 diff --git a/test/other/test_INCOMING_MODULE_JS_API.js.size b/test/other/test_INCOMING_MODULE_JS_API.js.size index 9b8a4c307c7a1..791d82540e015 100644 --- a/test/other/test_INCOMING_MODULE_JS_API.js.size +++ b/test/other/test_INCOMING_MODULE_JS_API.js.size @@ -1 +1 @@ -3710 +3772 diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index 6f75fa3a9a413..6defabfd2bdbe 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -53709 +53866 diff --git a/test/other/test_unoptimized_code_size.wasm.size b/test/other/test_unoptimized_code_size.wasm.size index b55e8eb4cd221..08a458d71f92f 100644 --- a/test/other/test_unoptimized_code_size.wasm.size +++ b/test/other/test_unoptimized_code_size.wasm.size @@ -1 +1 @@ -14531 +15142 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index e55af0c20aeb7..a1bca43a18bc5 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -29018 +29065 diff --git a/test/other/test_unoptimized_code_size_no_asserts.wasm.size b/test/other/test_unoptimized_code_size_no_asserts.wasm.size index a65dc9b14619a..c343caa8e2659 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.wasm.size +++ b/test/other/test_unoptimized_code_size_no_asserts.wasm.size @@ -1 +1 @@ -11724 +12223 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index ca6f382d48289..2bc64bf3c0783 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -52531 +52649 diff --git a/test/other/test_unoptimized_code_size_strict.wasm.size b/test/other/test_unoptimized_code_size_strict.wasm.size index b55e8eb4cd221..08a458d71f92f 100644 --- a/test/other/test_unoptimized_code_size_strict.wasm.size +++ b/test/other/test_unoptimized_code_size_strict.wasm.size @@ -1 +1 @@ -14531 +15142 diff --git a/test/return64bit/testbind.js b/test/return64bit/testbind.js index 9ca30d0d18977..cd21d62a82967 100644 --- a/test/return64bit/testbind.js +++ b/test/return64bit/testbind.js @@ -4,14 +4,18 @@ // returned via the accessor method getTempRet0() Module['runtest'] = function() { - var low = _test_return64(0x11223344, 0xaabbccdd); - var high = getTempRet0(); + // Use eval to create BigInt, as no support for Xn notation yet in JS + // optimizer. + var bigint = _test_return64(eval('0xaabbccdd11223344n')); + var low = Number(bigint & 0xffffffffn); + var high = Number(bigint >> 32n); console.log("low = " + low); console.log("high = " + high); var ptr = _get_func_ptr(); - low = dynCall_jj(ptr, 0x12345678, 0xabcdef19); - high = getTempRet0(); + bigint = dynCall('jj', ptr, [eval('0xabcdef1912345678n')]); + low = Number(bigint & 0xffffffffn); + high = Number(bigint >> 32n); console.log("low = " + low); console.log("high = " + high); }; diff --git a/test/return64bit/testbind_bigint.js b/test/return64bit/testbind_nobigint.js similarity index 57% rename from test/return64bit/testbind_bigint.js rename to test/return64bit/testbind_nobigint.js index cd21d62a82967..9ca30d0d18977 100644 --- a/test/return64bit/testbind_bigint.js +++ b/test/return64bit/testbind_nobigint.js @@ -4,18 +4,14 @@ // returned via the accessor method getTempRet0() Module['runtest'] = function() { - // Use eval to create BigInt, as no support for Xn notation yet in JS - // optimizer. - var bigint = _test_return64(eval('0xaabbccdd11223344n')); - var low = Number(bigint & 0xffffffffn); - var high = Number(bigint >> 32n); + var low = _test_return64(0x11223344, 0xaabbccdd); + var high = getTempRet0(); console.log("low = " + low); console.log("high = " + high); var ptr = _get_func_ptr(); - bigint = dynCall('jj', ptr, [eval('0xabcdef1912345678n')]); - low = Number(bigint & 0xffffffffn); - high = Number(bigint >> 32n); + low = dynCall_jj(ptr, 0x12345678, 0xabcdef19); + high = getTempRet0(); console.log("low = " + low); console.log("high = " + high); }; diff --git a/test/test_core.py b/test/test_core.py index c063ef74a561e..28d53550518d1 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -1934,12 +1934,10 @@ def test_em_js(self, args, force_c): self.do_core_test('test_em_js.cpp', force_c=force_c) self.assertContained("no args returning int", read_file('test_em_js.js')) - @no_wasm2js('WASM_BIGINT is not compatible with wasm2js') + @no_wasm2js('test depends on WASM_BIGINT which is not compatible with wasm2js') def test_em_js_i64(self): - err = self.expect_fail([EMCC, '-Werror', test_file('core/test_em_js_i64.c')]) + err = self.expect_fail([EMCC, '-Werror', '-sWASM_BIGINT=0', test_file('core/test_em_js_i64.c')]) self.assertContained('emcc: error: using 64-bit arguments in EM_JS function without WASM_BIGINT is not yet fully supported: `foo`', err) - - self.set_setting('WASM_BIGINT') self.node_args += shared.node_bigint_flags(self.get_nodejs()) self.do_core_test('test_em_js_i64.c') @@ -6927,7 +6925,7 @@ def test_EXPORTED_RUNTIME_METHODS(self): def test_dyncall_specific(self, *args): if self.get_setting('MEMORY64'): self.skipTest('not compatible with MEMORY64') - if self.get_setting('WASM_BIGINT'): + if self.get_setting('WASM_BIGINT') != 0 and not self.is_wasm2js(): # define DYNCALLS because this test does test calling them directly, and # in WASM_BIGINT mode we do not enable them by default (since we can do # more without them - we don't need to legalize) diff --git a/test/test_other.py b/test/test_other.py index 17fd201531c02..2642b9aafd82c 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -2974,7 +2974,7 @@ def test_emcc_debug_files(self, opt): self.assertFalse(os.path.exists(self.canonical_temp_dir)) else: print(sorted(os.listdir(self.canonical_temp_dir))) - self.assertExists(os.path.join(self.canonical_temp_dir, 'emcc-03-original.js')) + self.assertExists(os.path.join(self.canonical_temp_dir, 'emcc-02-original.js')) def test_debuginfo_line_tables_only(self): def test(do_compile): @@ -3521,10 +3521,10 @@ def test_embind_tsgen_val(self): def test_embind_tsgen_bigint(self): args = [EMXX, test_file('other/embind_tsgen_bigint.cpp'), '-lembind', '--emit-tsd', 'embind_tsgen_bigint.d.ts'] # Check that TypeScript generation fails when code contains bigints but their support is not enabled - stderr = self.expect_fail(args) + stderr = self.expect_fail(args + ['-sWASM_BIGINT=0']) self.assertContained("Missing primitive type to TS type for 'int64_t", stderr) # Check that TypeScript generation works when bigint support is enabled - self.run_process(args + ['-sWASM_BIGINT']) + self.run_process(args) self.assertFileContents(test_file('other/embind_tsgen_bigint.d.ts'), read_file('embind_tsgen_bigint.d.ts')) @requires_wasm64 @@ -8053,7 +8053,7 @@ def test_malloc_multithreading(self, allocator, args): @parameterized({ '': ([], 'testbind.js'), - 'bigint': (['-sWASM_BIGINT'], 'testbind_bigint.js'), + 'nobigint': (['-sWASM_BIGINT=0'], 'testbind_nobigint.js'), }) @requires_node def test_i64_return_value(self, args, bind_js): @@ -8235,15 +8235,15 @@ def test_memory_growth_noasm(self): assert 'use asm' not in src def test_EM_ASM_i64(self): + self.do_other_test('test_em_asm_i64.cpp') + self.do_other_test('test_em_asm_i64.cpp', force_c=True) + + self.set_setting('WASM_BIGINT', 0) expected = 'Invalid character 106("j") in readEmAsmArgs!' self.do_runf('other/test_em_asm_i64.cpp', expected_output=expected, assert_returncode=NON_ZERO) - self.set_setting('WASM_BIGINT') - self.do_other_test('test_em_asm_i64.cpp') - self.do_other_test('test_em_asm_i64.cpp', force_c=True) - def test_eval_ctor_ordering(self): # ensure order of execution remains correct, even with a bad ctor def test(p1, p2, p3, last, expected): @@ -8549,7 +8549,7 @@ def test_binaryen_warn_mem(self): self.run_process([EMCC, test_file('hello_world.c'), '-sINITIAL_MEMORY=' + str(16 * 1024 * 1024), '--pre-js', 'pre.js', '-sWASM_ASYNC_COMPILATION=0', '-sIMPORTED_MEMORY']) out = self.run_js('a.out.js', assert_returncode=NON_ZERO) self.assertContained('LinkError', out) - self.assertContained("memory import 2 has a larger maximum size 800 than the module's declared maximum", out) + self.assertContained("has a larger maximum size 800 than the module's declared maximum", out) self.assertNotContained('hello, world!', out) # and with memory growth, all should be good self.run_process([EMCC, test_file('hello_world.c'), '-sINITIAL_MEMORY=' + str(16 * 1024 * 1024), '--pre-js', 'pre.js', '-sALLOW_MEMORY_GROWTH', '-sWASM_ASYNC_COMPILATION=0', '-sIMPORTED_MEMORY']) @@ -8975,7 +8975,7 @@ def test_legalize_js_ffi(self, args, js_ffi): # test disabling of JS FFI legalization when not using bigint print(args) delete_file('a.out.wasm') - cmd = [EMCC, test_file('other/ffi.c'), '-g', '-o', 'a.out.wasm'] + args + cmd = [EMCC, test_file('other/ffi.c'), '-g', '-o', 'a.out.wasm', '-sWASM_BIGINT=0'] + args print(' '.join(cmd)) self.run_process(cmd) text = self.get_wasm_text('a.out.wasm') @@ -11508,13 +11508,13 @@ def test(code): print(f'int:{i} float:{f} double:{lf}: both{both}') # iprintf is much smaller than printf with float support - self.assertGreater(i, f - 3500) + self.assertGreater(i, f - 3800) self.assertLess(i, f - 3000) # __small_printf is somewhat smaller than printf with long double support self.assertGreater(f, lf - 900) self.assertLess(f, lf - 500) # both is a little bigger still - self.assertGreater(lf, both - 110) + self.assertGreater(lf, both - 150) self.assertLess(lf, both - 50) @parameterized({ @@ -12352,19 +12352,18 @@ def ok(args, filename='hello_world.cpp', expected='hello, world!'): args += ['-sERROR_ON_WASM_CHANGES_AFTER_LINK'] self.do_runf(filename, expected, emcc_args=args) - # -O0 with BigInt support (to avoid the need for legalization) - required_flags = ['-sWASM_BIGINT'] - ok(required_flags) + # -O0 with BigInt support (now on by default) + ok([]) # Same with DWARF - ok(required_flags + ['-g']) + ok(['-g']) # Function pointer calls from JS work too - ok(required_flags, filename='hello_world_main_loop.cpp') + ok([], filename='hello_world_main_loop.cpp') # -O1 is ok as we don't run wasm-opt there (but no higher, see below) - ok(required_flags + ['-O1']) + ok(['-O1']) # Exception support shouldn't require changes after linking - ok(required_flags + ['-fexceptions']) + ok(['-fexceptions']) # Standalone mode should not do anything special to the wasm. - ok(required_flags + ['-sSTANDALONE_WASM']) + ok(['-sSTANDALONE_WASM']) # other builds fail with a standard message + extra details def fail(args, details): @@ -12376,11 +12375,13 @@ def fail(args, details): # plain -O0 legalization_message = 'to disable int64 legalization (which requires changes after link) use -sWASM_BIGINT' - fail([], legalization_message) + fail(['-sWASM_BIGINT=0'], legalization_message) + # TODO(https://github.com/emscripten-core/emscripten/issues/23184): change this back to 140100 after 15 is default + fail(['-sMIN_SAFARI_VERSION=140000'], legalization_message) # optimized builds even without legalization optimization_message = '-O2+ optimizations always require changes, build with -O0 or -O1 instead' - fail(required_flags + ['-O2'], optimization_message) - fail(required_flags + ['-O3'], optimization_message) + fail(['-O2'], optimization_message) + fail(['-O3'], optimization_message) @crossplatform def test_output_to_nowhere(self): @@ -14450,7 +14451,8 @@ def test_reproduce(self): def test_min_browser_version(self): err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Wno-transpile', '-Werror', '-sWASM_BIGINT', '-sMIN_SAFARI_VERSION=120000']) - self.assertContained('emcc: error: MIN_SAFARI_VERSION=120000 is not compatible with WASM_BIGINT (150000 or above required)', err) + # TODO(https://github.com/emscripten-core/emscripten/issues/23184): fix back to 15000 once Safari 15 is default + self.assertContained('emcc: error: MIN_SAFARI_VERSION=120000 is not compatible with WASM_BIGINT (140100 or above required)', err) err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Wno-transpile', '-Werror', '-pthread', '-sMIN_CHROME_VERSION=73']) self.assertContained('emcc: error: MIN_CHROME_VERSION=73 is not compatible with pthreads (74 or above required)', err) diff --git a/test/test_sanity.py b/test/test_sanity.py index 17b95aac6824a..801ad5f36e609 100644 --- a/test/test_sanity.py +++ b/test/test_sanity.py @@ -777,10 +777,10 @@ def test_binaryen_version(self): f.write('\nBINARYEN_ROOT = "' + self.in_dir('fake') + '"') make_fake_tool(self.in_dir('fake', 'bin', 'wasm-opt'), 'foo') - self.check_working([EMCC, test_file('hello_world.c')], 'error parsing binaryen version (wasm-opt version foo). Please check your binaryen installation') + self.check_working([EMCC, test_file('hello_world.c'), '-O2'], 'error parsing binaryen version (wasm-opt version foo). Please check your binaryen installation') make_fake_tool(self.in_dir('fake', 'bin', 'wasm-opt'), '70') - self.check_working([EMCC, test_file('hello_world.c')], 'unexpected binaryen version: 70 (expected ') + self.check_working([EMCC, test_file('hello_world.c'), '-O2'], 'unexpected binaryen version: 70 (expected ') def test_bootstrap(self): restore_and_set_up() diff --git a/tools/feature_matrix.py b/tools/feature_matrix.py index 61c9399dd1aad..372d17c4ae332 100644 --- a/tools/feature_matrix.py +++ b/tools/feature_matrix.py @@ -66,7 +66,8 @@ class Feature(IntEnum): Feature.JS_BIGINT_INTEGRATION: { 'chrome': 67, 'firefox': 68, - 'safari': 150000, + 'safari': 140100, # TODO(https://github.com/emscripten-core/emscripten/issues/23184): set this back to 15 after we update the default targets. + 'node': 130000, }, Feature.THREADS: { 'chrome': 74, @@ -137,7 +138,7 @@ def enable_feature(feature, reason, override=False): f'{name}={user_settings[name]} is not compatible with {reason} ' f'({min_version} or above required)') else: - # Otherwise we bump the minimum version to accommodate the feature. + # If no conflict, bump the minimum version to accommodate the feature. setattr(settings, name, min_version) @@ -151,7 +152,9 @@ def disable_feature(feature): # a user requests a feature that we know is only supported in browsers # from a specific version and above, we can assume that browser version. def apply_min_browser_versions(): - if settings.WASM_BIGINT: + if settings.WASM_BIGINT and 'WASM_BIGINT' in user_settings: + # WASM_BIGINT is enabled by default, don't use it to enable other features + # unless the user explicitly enabled it. enable_feature(Feature.JS_BIGINT_INTEGRATION, 'WASM_BIGINT') if settings.PTHREADS: enable_feature(Feature.THREADS, 'pthreads') diff --git a/tools/link.py b/tools/link.py index 88ef0822e8a23..bbf9829a595c9 100644 --- a/tools/link.py +++ b/tools/link.py @@ -795,9 +795,19 @@ def phase_linker_setup(options, state, newargs): # noqa: C901, PLR0912, PLR0915 # to js. settings.WASM = 1 settings.WASM2JS = 1 + # Wasm bigint doesn't make sense with wasm2js, since it controls how the + # wasm and JS interact. + if user_settings.get('WASM_BIGINT') and settings.WASM_BIGINT: + exit_with_error('WASM_BIGINT=1 is not compatible with WASM=0 (wasm2js)') + settings.WASM_BIGINT = 0 + feature_matrix.disable_feature(feature_matrix.Feature.JS_BIGINT_INTEGRATION) if settings.WASM == 2: # Requesting both Wasm and Wasm2JS support settings.WASM2JS = 1 + if user_settings.get('WASM_BIGINT') and settings.WASM_BIGINT: + exit_with_error('WASM_BIGINT=1 is not compatible with WASM=2 (wasm2js)') + settings.WASM_BIGINT = 0 + feature_matrix.disable_feature(feature_matrix.Feature.JS_BIGINT_INTEGRATION) if options.oformat == OFormat.WASM and not settings.SIDE_MODULE: # if the output is just a wasm file, it will normally be a standalone one, @@ -1391,6 +1401,7 @@ def phase_linker_setup(options, state, newargs): # noqa: C901, PLR0912, PLR0915 settings.SUPPORTS_PROMISE_ANY = feature_matrix.caniuse(feature_matrix.Feature.PROMISE_ANY) if not settings.BULK_MEMORY: settings.BULK_MEMORY = feature_matrix.caniuse(feature_matrix.Feature.BULK_MEMORY) + default_setting('WASM_BIGINT', feature_matrix.caniuse(feature_matrix.Feature.JS_BIGINT_INTEGRATION)) if settings.AUDIO_WORKLET: if settings.AUDIO_WORKLET == 1: From adb972cf88d1f4fd1b9097327da114ca4585b5ff Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 18 Dec 2024 14:41:36 -0800 Subject: [PATCH 113/132] Remove unnecessary `await` in `MODULARIZE=instance` mode. NFC (#23219) Since the init function is already marks as async it fine/better to simply return the promise here rather than awaiting on it. --- tools/link.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/link.py b/tools/link.py index bbf9829a595c9..2d7b6c603d7fb 100644 --- a/tools/link.py +++ b/tools/link.py @@ -2403,7 +2403,7 @@ def modularize(): %(generated_js)s - return await moduleRtn; + return moduleRtn; } ''' % { 'generated_js': generated_js From b330159b412819b632bf20f26db37bed1d8b2aa5 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 18 Dec 2024 17:25:55 -0800 Subject: [PATCH 114/132] Convert `createWasm` async/await where possible (#23157) 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 generate: ``` var wasmExport = await createWasm(); // returns actual exports ... 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. There are two minor observable effects of this change: 1. In `MODULARIZE` mode its no longer possible to call `new Foo()` with factory function. We already added a debug error for in #23210. 2. Because we now can `await` for createWasm to return, the `run` method can run on first call, which means it runs `main` on first call, which means main will now run before `postjs` code, just like it would with sync instantiation. --- ChangeLog.md | 6 ++++++ src/preamble.js | 13 ++++++------- test/browser/test_small_js_flags.js.size | 2 +- test/code_size/hello_webgl2_wasm.json | 8 ++++---- test/code_size/hello_webgl2_wasm2js.json | 8 ++++---- test/code_size/hello_webgl_wasm.json | 8 ++++---- test/code_size/hello_webgl_wasm2js.json | 8 ++++---- .../codesize/test_codesize_cxx_ctors1.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors1.jssize | 2 +- .../codesize/test_codesize_cxx_ctors2.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors2.jssize | 2 +- .../codesize/test_codesize_cxx_except.gzsize | 2 +- .../codesize/test_codesize_cxx_except.jssize | 2 +- .../test_codesize_cxx_except_wasm.jssize | 2 +- ...test_codesize_cxx_except_wasm_exnref.jssize | 2 +- .../codesize/test_codesize_cxx_lto.gzsize | 2 +- .../codesize/test_codesize_cxx_lto.jssize | 2 +- .../codesize/test_codesize_cxx_mangle.gzsize | 2 +- .../codesize/test_codesize_cxx_mangle.jssize | 2 +- .../codesize/test_codesize_cxx_noexcept.gzsize | 2 +- .../codesize/test_codesize_cxx_noexcept.jssize | 2 +- .../codesize/test_codesize_cxx_wasmfs.gzsize | 2 +- .../codesize/test_codesize_cxx_wasmfs.jssize | 2 +- .../codesize/test_codesize_files_js_fs.gzsize | 2 +- .../codesize/test_codesize_files_js_fs.jssize | 2 +- .../codesize/test_codesize_files_wasmfs.jssize | 2 +- .../codesize/test_codesize_hello_O0.gzsize | 2 +- .../codesize/test_codesize_hello_O0.jssize | 2 +- .../codesize/test_codesize_hello_O1.gzsize | 2 +- .../codesize/test_codesize_hello_O1.jssize | 2 +- .../codesize/test_codesize_hello_O2.gzsize | 2 +- .../codesize/test_codesize_hello_O2.jssize | 2 +- .../codesize/test_codesize_hello_O3.gzsize | 2 +- .../codesize/test_codesize_hello_O3.jssize | 2 +- .../codesize/test_codesize_hello_Os.gzsize | 2 +- .../codesize/test_codesize_hello_Os.jssize | 2 +- .../codesize/test_codesize_hello_Oz.gzsize | 2 +- .../codesize/test_codesize_hello_Oz.jssize | 2 +- .../codesize/test_codesize_hello_dylink.gzsize | 2 +- .../codesize/test_codesize_hello_dylink.jssize | 2 +- .../test_codesize_hello_export_nothing.gzsize | 2 +- .../test_codesize_hello_export_nothing.jssize | 2 +- .../codesize/test_codesize_hello_wasmfs.gzsize | 2 +- .../codesize/test_codesize_hello_wasmfs.jssize | 2 +- .../test_codesize_libcxxabi_message_O3.gzsize | 2 +- .../test_codesize_libcxxabi_message_O3.jssize | 2 +- ...size_libcxxabi_message_O3_standalone.gzsize | 2 +- ...size_libcxxabi_message_O3_standalone.jssize | 2 +- .../other/codesize/test_codesize_mem_O3.gzsize | 2 +- .../other/codesize/test_codesize_mem_O3.jssize | 2 +- .../codesize/test_codesize_mem_O3_grow.gzsize | 2 +- .../codesize/test_codesize_mem_O3_grow.jssize | 2 +- ...test_codesize_mem_O3_grow_standalone.gzsize | 2 +- ...test_codesize_mem_O3_grow_standalone.jssize | 2 +- .../test_codesize_mem_O3_standalone.gzsize | 2 +- .../test_codesize_mem_O3_standalone.jssize | 2 +- .../test_codesize_mem_O3_standalone_lib.gzsize | 2 +- .../test_codesize_mem_O3_standalone_lib.jssize | 2 +- ...test_codesize_mem_O3_standalone_narg.gzsize | 2 +- ...test_codesize_mem_O3_standalone_narg.jssize | 2 +- ...codesize_mem_O3_standalone_narg_flto.gzsize | 2 +- ...codesize_mem_O3_standalone_narg_flto.jssize | 2 +- .../codesize/test_codesize_minimal_64.gzsize | 2 +- .../codesize/test_codesize_minimal_64.jssize | 2 +- .../codesize/test_codesize_minimal_O1.gzsize | 2 +- .../codesize/test_codesize_minimal_O1.jssize | 2 +- .../codesize/test_codesize_minimal_O2.gzsize | 2 +- .../codesize/test_codesize_minimal_O2.jssize | 2 +- .../codesize/test_codesize_minimal_O3.gzsize | 2 +- .../codesize/test_codesize_minimal_O3.jssize | 2 +- .../codesize/test_codesize_minimal_Os.gzsize | 2 +- .../codesize/test_codesize_minimal_Os.jssize | 2 +- .../test_codesize_minimal_Oz-ctors.jssize | 2 +- .../codesize/test_codesize_minimal_Oz.gzsize | 2 +- .../codesize/test_codesize_minimal_Oz.jssize | 2 +- .../codesize/test_codesize_minimal_esm.gzsize | 2 +- .../codesize/test_codesize_minimal_esm.jssize | 2 +- .../test_codesize_minimal_pthreads.gzsize | 2 +- .../test_codesize_minimal_pthreads.jssize | 2 +- .../test_codesize_minimal_wasmfs.gzsize | 2 +- .../test_codesize_minimal_wasmfs.jssize | 2 +- test/other/test_INCOMING_MODULE_JS_API.js.size | 2 +- test/other/test_unoptimized_code_size.js.size | 2 +- ...st_unoptimized_code_size_no_asserts.js.size | 2 +- .../test_unoptimized_code_size_strict.js.size | 2 +- test/test_unicode_js_library.out | 2 +- tools/emscripten.py | 18 ++++++++++++++++-- tools/link.py | 14 ++++++++------ 88 files changed, 132 insertions(+), 111 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 7bbade9d415c2..8400bcaa9a81d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -33,6 +33,12 @@ See docs/process.md for more on how version tagging works. `PATH.basename("a/b/..")` returns `".."` instead of `"a"`. This is in line with the behaviour of both node and coreutils, and is already the case when using NODERAWFS". (#23180) +- The factory function exposed in `-sMODULARIZE` mode is now marked as `async` + when `WASM_ASYNC_COMPILATION` is enabled (the default). This allows us to use + `await` during module creation. One side effect of this is that code in + `--post-js` files will now be delayed until after module creation and after + `main` runs. This matches the existing behaviour when using sync instantation + (`-sWASM_ASYNC_COMPILATION=0`) but is an observable difference. (#23157) 3.1.74 - 12/14/24 ----------------- diff --git a/src/preamble.js b/src/preamble.js index 4f4dc32dba0ca..2e91449ac76fc 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -1036,11 +1036,11 @@ function getWasmImports() { trueModule = null; #endif #if SHARED_MEMORY || RELOCATABLE - receiveInstance(result['instance'], result['module']); + return receiveInstance(result['instance'], result['module']); #else // TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line. // When the regression is fixed, can restore the above PTHREADS-enabled path. - receiveInstance(result['instance']); + return receiveInstance(result['instance']); #endif } #endif // WASM_ASYNC_COMPILATION @@ -1076,8 +1076,7 @@ function getWasmImports() { // Instantiate from the module posted from the main thread. // We can just use sync instantiation in the worker. var instance = new WebAssembly.Instance(module, getWasmImports()); - receiveInstance(instance, module); - resolve(); + resolve(receiveInstance(instance, module)); }; }); } @@ -1095,16 +1094,16 @@ function getWasmImports() { try { #endif var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info); - receiveInstantiationResult(result); + var exports = receiveInstantiationResult(result); #if LOAD_SOURCE_MAP receiveSourceMapJSON(await getSourceMapAsync()); #endif - return result; + return exports; #if MODULARIZE } catch (e) { // If instantiation fails, reject the module ready promise. readyPromiseReject(e); - return; + return Promise.reject(e); } #endif #else // WASM_ASYNC_COMPILATION diff --git a/test/browser/test_small_js_flags.js.size b/test/browser/test_small_js_flags.js.size index 6502cf0229698..bce5ffdd8fabd 100644 --- a/test/browser/test_small_js_flags.js.size +++ b/test/browser/test_small_js_flags.js.size @@ -1 +1 @@ -4380 +4374 diff --git a/test/code_size/hello_webgl2_wasm.json b/test/code_size/hello_webgl2_wasm.json index 13919b590d957..d7738773ebc50 100644 --- a/test/code_size/hello_webgl2_wasm.json +++ b/test/code_size/hello_webgl2_wasm.json @@ -1,10 +1,10 @@ { "a.html": 454, "a.html.gz": 328, - "a.js": 4532, - "a.js.gz": 2315, + "a.js": 4538, + "a.js.gz": 2320, "a.wasm": 10402, "a.wasm.gz": 6703, - "total": 15388, - "total_gz": 9346 + "total": 15394, + "total_gz": 9351 } diff --git a/test/code_size/hello_webgl2_wasm2js.json b/test/code_size/hello_webgl2_wasm2js.json index d54f14a652c99..da83c09580bbe 100644 --- a/test/code_size/hello_webgl2_wasm2js.json +++ b/test/code_size/hello_webgl2_wasm2js.json @@ -1,8 +1,8 @@ { "a.html": 346, "a.html.gz": 262, - "a.js": 22200, - "a.js.gz": 11583, - "total": 22546, - "total_gz": 11845 + "a.js": 22206, + "a.js.gz": 11589, + "total": 22552, + "total_gz": 11851 } diff --git a/test/code_size/hello_webgl_wasm.json b/test/code_size/hello_webgl_wasm.json index e619b3f3321c3..e4c3af111aac8 100644 --- a/test/code_size/hello_webgl_wasm.json +++ b/test/code_size/hello_webgl_wasm.json @@ -1,10 +1,10 @@ { "a.html": 454, "a.html.gz": 328, - "a.js": 4070, - "a.js.gz": 2158, + "a.js": 4076, + "a.js.gz": 2163, "a.wasm": 10402, "a.wasm.gz": 6703, - "total": 14926, - "total_gz": 9189 + "total": 14932, + "total_gz": 9194 } diff --git a/test/code_size/hello_webgl_wasm2js.json b/test/code_size/hello_webgl_wasm2js.json index a01758dd16374..c2cb2b2deec67 100644 --- a/test/code_size/hello_webgl_wasm2js.json +++ b/test/code_size/hello_webgl_wasm2js.json @@ -1,8 +1,8 @@ { "a.html": 346, "a.html.gz": 262, - "a.js": 21726, - "a.js.gz": 11413, - "total": 22072, - "total_gz": 11675 + "a.js": 21732, + "a.js.gz": 11419, + "total": 22078, + "total_gz": 11681 } diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 629d814f19953..7c05c8455e746 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8352 +8351 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index a22508fe1954b..82d8332d892e9 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20347 +20343 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index 66543c9213fe0..e7f2f2aa09e70 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8336 +8334 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index ee93d493df28c..f8c47ad8dd2c0 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20315 +20311 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 1e8ce7e708846..26f242e26fb55 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9358 +9356 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 108fb27854780..c495dc33171d4 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24116 +24112 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index b4fb6fa3b6ed0..276f80508b53d 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20240 +20236 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index b4fb6fa3b6ed0..276f80508b53d 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20240 +20236 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 7947190fcc750..a665dbc2e401e 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8348 +8347 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 6525ff13db521..cd0660982b7d0 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20371 +20367 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index be24a385bb8fd..886a28e6c91b7 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9361 +9359 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 108fb27854780..c495dc33171d4 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24116 +24112 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 629d814f19953..7c05c8455e746 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8352 +8351 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index a22508fe1954b..82d8332d892e9 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20347 +20343 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize index 799c77152539d..384632eff7fe6 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize @@ -1 +1 @@ -3653 +3651 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.jssize b/test/other/codesize/test_codesize_cxx_wasmfs.jssize index 5e97e16bfa535..122c645d8cd89 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.jssize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.jssize @@ -1 +1 @@ -7914 +7910 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index a6589474f60cb..309e97c7a9f6c 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7656 +7654 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index bf4d7a5e763f4..79d0a5b02487f 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18842 +18838 diff --git a/test/other/codesize/test_codesize_files_wasmfs.jssize b/test/other/codesize/test_codesize_files_wasmfs.jssize index 2c55bb009ea6c..d665f60e5a1bc 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.jssize +++ b/test/other/codesize/test_codesize_files_wasmfs.jssize @@ -1 +1 @@ -6202 +6198 diff --git a/test/other/codesize/test_codesize_hello_O0.gzsize b/test/other/codesize/test_codesize_hello_O0.gzsize index 42b603432aefe..f36af27d0621f 100644 --- a/test/other/codesize/test_codesize_hello_O0.gzsize +++ b/test/other/codesize/test_codesize_hello_O0.gzsize @@ -1 +1 @@ -8017 +8012 diff --git a/test/other/codesize/test_codesize_hello_O0.jssize b/test/other/codesize/test_codesize_hello_O0.jssize index ca3736fbbb012..0c10608bd8f7e 100644 --- a/test/other/codesize/test_codesize_hello_O0.jssize +++ b/test/other/codesize/test_codesize_hello_O0.jssize @@ -1 +1 @@ -21597 +21588 diff --git a/test/other/codesize/test_codesize_hello_O1.gzsize b/test/other/codesize/test_codesize_hello_O1.gzsize index 690c09f1c702d..8933964377fbf 100644 --- a/test/other/codesize/test_codesize_hello_O1.gzsize +++ b/test/other/codesize/test_codesize_hello_O1.gzsize @@ -1 +1 @@ -2697 +2694 diff --git a/test/other/codesize/test_codesize_hello_O1.jssize b/test/other/codesize/test_codesize_hello_O1.jssize index 8d2e9dfdb7ff4..a25b0436b3627 100644 --- a/test/other/codesize/test_codesize_hello_O1.jssize +++ b/test/other/codesize/test_codesize_hello_O1.jssize @@ -1 +1 @@ -6911 +6899 diff --git a/test/other/codesize/test_codesize_hello_O2.gzsize b/test/other/codesize/test_codesize_hello_O2.gzsize index 7d945b944dabc..da797840923f0 100644 --- a/test/other/codesize/test_codesize_hello_O2.gzsize +++ b/test/other/codesize/test_codesize_hello_O2.gzsize @@ -1 +1 @@ -2359 +2357 diff --git a/test/other/codesize/test_codesize_hello_O2.jssize b/test/other/codesize/test_codesize_hello_O2.jssize index 11336821115bf..7e8c8fed96c82 100644 --- a/test/other/codesize/test_codesize_hello_O2.jssize +++ b/test/other/codesize/test_codesize_hello_O2.jssize @@ -1 +1 @@ -4835 +4831 diff --git a/test/other/codesize/test_codesize_hello_O3.gzsize b/test/other/codesize/test_codesize_hello_O3.gzsize index 3e263d2e556cd..616e2787a51d3 100644 --- a/test/other/codesize/test_codesize_hello_O3.gzsize +++ b/test/other/codesize/test_codesize_hello_O3.gzsize @@ -1 +1 @@ -2298 +2296 diff --git a/test/other/codesize/test_codesize_hello_O3.jssize b/test/other/codesize/test_codesize_hello_O3.jssize index c6a2b270f3b7e..3658ed8053766 100644 --- a/test/other/codesize/test_codesize_hello_O3.jssize +++ b/test/other/codesize/test_codesize_hello_O3.jssize @@ -1 +1 @@ -4757 +4753 diff --git a/test/other/codesize/test_codesize_hello_Os.gzsize b/test/other/codesize/test_codesize_hello_Os.gzsize index 3e263d2e556cd..616e2787a51d3 100644 --- a/test/other/codesize/test_codesize_hello_Os.gzsize +++ b/test/other/codesize/test_codesize_hello_Os.gzsize @@ -1 +1 @@ -2298 +2296 diff --git a/test/other/codesize/test_codesize_hello_Os.jssize b/test/other/codesize/test_codesize_hello_Os.jssize index c6a2b270f3b7e..3658ed8053766 100644 --- a/test/other/codesize/test_codesize_hello_Os.jssize +++ b/test/other/codesize/test_codesize_hello_Os.jssize @@ -1 +1 @@ -4757 +4753 diff --git a/test/other/codesize/test_codesize_hello_Oz.gzsize b/test/other/codesize/test_codesize_hello_Oz.gzsize index 9294c7754fde1..20c65f21df41d 100644 --- a/test/other/codesize/test_codesize_hello_Oz.gzsize +++ b/test/other/codesize/test_codesize_hello_Oz.gzsize @@ -1 +1 @@ -2281 +2279 diff --git a/test/other/codesize/test_codesize_hello_Oz.jssize b/test/other/codesize/test_codesize_hello_Oz.jssize index 65e5941a842c5..4f652d136a346 100644 --- a/test/other/codesize/test_codesize_hello_Oz.jssize +++ b/test/other/codesize/test_codesize_hello_Oz.jssize @@ -1 +1 @@ -4724 +4720 diff --git a/test/other/codesize/test_codesize_hello_dylink.gzsize b/test/other/codesize/test_codesize_hello_dylink.gzsize index 416368238e9f1..45a2573f0aa4b 100644 --- a/test/other/codesize/test_codesize_hello_dylink.gzsize +++ b/test/other/codesize/test_codesize_hello_dylink.gzsize @@ -1 +1 @@ -6023 +6028 diff --git a/test/other/codesize/test_codesize_hello_dylink.jssize b/test/other/codesize/test_codesize_hello_dylink.jssize index 3e898f1efeb39..c7ce89ced910f 100644 --- a/test/other/codesize/test_codesize_hello_dylink.jssize +++ b/test/other/codesize/test_codesize_hello_dylink.jssize @@ -1 +1 @@ -13300 +13317 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.gzsize b/test/other/codesize/test_codesize_hello_export_nothing.gzsize index 889f56ca7ed18..357a340dae7ae 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.gzsize +++ b/test/other/codesize/test_codesize_hello_export_nothing.gzsize @@ -1 +1 @@ -1682 +1681 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.jssize b/test/other/codesize/test_codesize_hello_export_nothing.jssize index ee72a28badb95..00987dc4e5708 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.jssize +++ b/test/other/codesize/test_codesize_hello_export_nothing.jssize @@ -1 +1 @@ -3637 +3633 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.gzsize b/test/other/codesize/test_codesize_hello_wasmfs.gzsize index 3e263d2e556cd..616e2787a51d3 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_hello_wasmfs.gzsize @@ -1 +1 @@ -2298 +2296 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.jssize b/test/other/codesize/test_codesize_hello_wasmfs.jssize index c6a2b270f3b7e..3658ed8053766 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.jssize +++ b/test/other/codesize/test_codesize_hello_wasmfs.jssize @@ -1 +1 @@ -4757 +4753 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize index 1ea816877702e..988fde4112c52 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize @@ -1 +1 @@ -1876 +1873 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize index 26a4dd33f0015..1263586a20af3 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize @@ -1 +1 @@ -4000 +3996 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize index a7568adae3387..23e07fb71b3f9 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize @@ -1 +1 @@ -1914 +1912 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize index 965493a318306..24b2d1ddd384c 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize @@ -1 +1 @@ -4048 +4044 diff --git a/test/other/codesize/test_codesize_mem_O3.gzsize b/test/other/codesize/test_codesize_mem_O3.gzsize index ffcd151c41f04..a4e114468e7e2 100644 --- a/test/other/codesize/test_codesize_mem_O3.gzsize +++ b/test/other/codesize/test_codesize_mem_O3.gzsize @@ -1 +1 @@ -2328 +2327 diff --git a/test/other/codesize/test_codesize_mem_O3.jssize b/test/other/codesize/test_codesize_mem_O3.jssize index 86a2a1bb17b2e..a155f5afbd071 100644 --- a/test/other/codesize/test_codesize_mem_O3.jssize +++ b/test/other/codesize/test_codesize_mem_O3.jssize @@ -1 +1 @@ -4892 +4888 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.gzsize b/test/other/codesize/test_codesize_mem_O3_grow.gzsize index 721cbb13b4aee..9c251745dda72 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow.gzsize @@ -1 +1 @@ -2478 +2476 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.jssize b/test/other/codesize/test_codesize_mem_O3_grow.jssize index 5d539952599b9..cd147334a1386 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow.jssize @@ -1 +1 @@ -5177 +5172 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize index a7ffd709f6523..d1fc75efc83f6 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize @@ -1 +1 @@ -2180 +2177 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize index d6dab2a5d3793..5b9e54fbbe923 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize @@ -1 +1 @@ -4585 +4581 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize index 5cc2201e666e5..1ed292725657e 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize @@ -1 +1 @@ -2143 +2140 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_standalone.jssize index 4d4bc2f8db86e..570a753145afa 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.jssize @@ -1 +1 @@ -4517 +4513 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize index 62a85b862fd04..3964950a079db 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize @@ -1 +1 @@ -1900 +1898 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize index 61050f20447d0..4a3a63211e267 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize @@ -1 +1 @@ -4047 +4043 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize index a7568adae3387..23e07fb71b3f9 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize @@ -1 +1 @@ -1914 +1912 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize index 965493a318306..24b2d1ddd384c 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize @@ -1 +1 @@ -4048 +4044 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize index a7568adae3387..23e07fb71b3f9 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize @@ -1 +1 @@ -1914 +1912 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize index 965493a318306..24b2d1ddd384c 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize @@ -1 +1 @@ -4048 +4044 diff --git a/test/other/codesize/test_codesize_minimal_64.gzsize b/test/other/codesize/test_codesize_minimal_64.gzsize index 2a63ccf651217..4d851a7800ac5 100644 --- a/test/other/codesize/test_codesize_minimal_64.gzsize +++ b/test/other/codesize/test_codesize_minimal_64.gzsize @@ -1 +1 @@ -1439 +1441 diff --git a/test/other/codesize/test_codesize_minimal_64.jssize b/test/other/codesize/test_codesize_minimal_64.jssize index 31410c0cab693..9bcc9f43c3d2c 100644 --- a/test/other/codesize/test_codesize_minimal_64.jssize +++ b/test/other/codesize/test_codesize_minimal_64.jssize @@ -1 +1 @@ -3064 +3058 diff --git a/test/other/codesize/test_codesize_minimal_O1.gzsize b/test/other/codesize/test_codesize_minimal_O1.gzsize index 45ff3acb5f914..effd6e7865f0d 100644 --- a/test/other/codesize/test_codesize_minimal_O1.gzsize +++ b/test/other/codesize/test_codesize_minimal_O1.gzsize @@ -1 +1 @@ -1531 +1534 diff --git a/test/other/codesize/test_codesize_minimal_O1.jssize b/test/other/codesize/test_codesize_minimal_O1.jssize index f76268c8b2ac3..496991636dc10 100644 --- a/test/other/codesize/test_codesize_minimal_O1.jssize +++ b/test/other/codesize/test_codesize_minimal_O1.jssize @@ -1 +1 @@ -3713 +3702 diff --git a/test/other/codesize/test_codesize_minimal_O2.gzsize b/test/other/codesize/test_codesize_minimal_O2.gzsize index a3d3785badfdf..1eea322546e5a 100644 --- a/test/other/codesize/test_codesize_minimal_O2.gzsize +++ b/test/other/codesize/test_codesize_minimal_O2.gzsize @@ -1 +1 @@ -1380 +1381 diff --git a/test/other/codesize/test_codesize_minimal_O2.jssize b/test/other/codesize/test_codesize_minimal_O2.jssize index e88d628aa7ae4..f06c1c5aa9471 100644 --- a/test/other/codesize/test_codesize_minimal_O2.jssize +++ b/test/other/codesize/test_codesize_minimal_O2.jssize @@ -1 +1 @@ -2812 +2806 diff --git a/test/other/codesize/test_codesize_minimal_O3.gzsize b/test/other/codesize/test_codesize_minimal_O3.gzsize index cd692fa07fb1d..79abba8435fb0 100644 --- a/test/other/codesize/test_codesize_minimal_O3.gzsize +++ b/test/other/codesize/test_codesize_minimal_O3.gzsize @@ -1 +1 @@ -1346 +1348 diff --git a/test/other/codesize/test_codesize_minimal_O3.jssize b/test/other/codesize/test_codesize_minimal_O3.jssize index 9f876b5c8336c..0ece43ab5c071 100644 --- a/test/other/codesize/test_codesize_minimal_O3.jssize +++ b/test/other/codesize/test_codesize_minimal_O3.jssize @@ -1 +1 @@ -2762 +2756 diff --git a/test/other/codesize/test_codesize_minimal_Os.gzsize b/test/other/codesize/test_codesize_minimal_Os.gzsize index cd692fa07fb1d..79abba8435fb0 100644 --- a/test/other/codesize/test_codesize_minimal_Os.gzsize +++ b/test/other/codesize/test_codesize_minimal_Os.gzsize @@ -1 +1 @@ -1346 +1348 diff --git a/test/other/codesize/test_codesize_minimal_Os.jssize b/test/other/codesize/test_codesize_minimal_Os.jssize index 9f876b5c8336c..0ece43ab5c071 100644 --- a/test/other/codesize/test_codesize_minimal_Os.jssize +++ b/test/other/codesize/test_codesize_minimal_Os.jssize @@ -1 +1 @@ -2762 +2756 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize index 0e4b8c8ebc97d..32dec52aa5d71 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize @@ -1 +1 @@ -2747 +2741 diff --git a/test/other/codesize/test_codesize_minimal_Oz.gzsize b/test/other/codesize/test_codesize_minimal_Oz.gzsize index cd692fa07fb1d..79abba8435fb0 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz.gzsize @@ -1 +1 @@ -1346 +1348 diff --git a/test/other/codesize/test_codesize_minimal_Oz.jssize b/test/other/codesize/test_codesize_minimal_Oz.jssize index 9f876b5c8336c..0ece43ab5c071 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz.jssize @@ -1 +1 @@ -2762 +2756 diff --git a/test/other/codesize/test_codesize_minimal_esm.gzsize b/test/other/codesize/test_codesize_minimal_esm.gzsize index 9639a4ce0392a..499020422191c 100644 --- a/test/other/codesize/test_codesize_minimal_esm.gzsize +++ b/test/other/codesize/test_codesize_minimal_esm.gzsize @@ -1 +1 @@ -1496 +1509 diff --git a/test/other/codesize/test_codesize_minimal_esm.jssize b/test/other/codesize/test_codesize_minimal_esm.jssize index 46b6da4851e58..7f7703d078eb4 100644 --- a/test/other/codesize/test_codesize_minimal_esm.jssize +++ b/test/other/codesize/test_codesize_minimal_esm.jssize @@ -1 +1 @@ -3138 +3157 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.gzsize b/test/other/codesize/test_codesize_minimal_pthreads.gzsize index 5255d8eda08aa..025479c9c2a8b 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.gzsize +++ b/test/other/codesize/test_codesize_minimal_pthreads.gzsize @@ -1 +1 @@ -4184 +4190 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.jssize b/test/other/codesize/test_codesize_minimal_pthreads.jssize index c9e63f57e5ed2..7a53a34d4eeef 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.jssize +++ b/test/other/codesize/test_codesize_minimal_pthreads.jssize @@ -1 +1 @@ -8711 +8728 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize index cd692fa07fb1d..79abba8435fb0 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize @@ -1 +1 @@ -1346 +1348 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.jssize b/test/other/codesize/test_codesize_minimal_wasmfs.jssize index 9f876b5c8336c..0ece43ab5c071 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.jssize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.jssize @@ -1 +1 @@ -2762 +2756 diff --git a/test/other/test_INCOMING_MODULE_JS_API.js.size b/test/other/test_INCOMING_MODULE_JS_API.js.size index 791d82540e015..8151f378a5913 100644 --- a/test/other/test_INCOMING_MODULE_JS_API.js.size +++ b/test/other/test_INCOMING_MODULE_JS_API.js.size @@ -1 +1 @@ -3772 +3766 diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index 6defabfd2bdbe..e904f31f54481 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -53866 +53888 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index a1bca43a18bc5..a66da51014b62 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -29065 +29087 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index 2bc64bf3c0783..aee5ffc51afd6 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -52649 +52671 diff --git a/test/test_unicode_js_library.out b/test/test_unicode_js_library.out index c96bed51b0188..aa42466399fb6 100644 --- a/test/test_unicode_js_library.out +++ b/test/test_unicode_js_library.out @@ -1,2 +1,2 @@ -Unicode postjs: àČšñéáúÍųåêâăščếệüçλληνικάбългарскиPусскийСрпскиУкраїнська한국어中文普通话(中国大陆)普通话(香港)中文(台灣)粵語(香港)日本語हिन्दीภาษาไทย Unicode snowman ☃ says hello! àČšñéáúÍųåêâăščếệüçλληνικάбългарскиPусскийСрпскиУкраїнська한국어中文普通话(中国大陆)普通话(香港)中文(台灣)粵語(香港)日本語हिन्दीภาษาไทย +Unicode postjs: àČšñéáúÍųåêâăščếệüçλληνικάбългарскиPусскийСрпскиУкраїнська한국어中文普通话(中国大陆)普通话(香港)中文(台灣)粵語(香港)日本語हिन्दीภาษาไทย diff --git a/tools/emscripten.py b/tools/emscripten.py index 250432f5462f7..0db61d81e9c61 100644 --- a/tools/emscripten.py +++ b/tools/emscripten.py @@ -893,6 +893,16 @@ def create_sending(metadata, library_symbols): return '{\n ' + ',\n '.join(elems) + '\n}' +def can_use_await(): + # In MODULARIZE mode we can use `await` since the factory function itself + # is marked as `async` and the generated code all lives inside that factory + # function. + # However, because closure does not see this (it runs only on the inner code), + # it sees this as a top-level-await, which it does not yet support. + # FIXME(https://github.com/emscripten-core/emscripten/issues/23158) + return settings.MODULARIZE and not settings.USE_CLOSURE_COMPILER + + def make_export_wrappers(function_exports): assert not settings.MINIMAL_RUNTIME @@ -932,7 +942,7 @@ def install_wrapper(sym): # With assertions enabled we create a wrapper that are calls get routed through, for # the lifetime of the program. wrapper += f"createExportWrapper('{name}', {nargs});" - elif settings.WASM_ASYNC_COMPILATION or settings.PTHREADS: + elif (settings.WASM_ASYNC_COMPILATION and not can_use_await()) or settings.PTHREADS: # With WASM_ASYNC_COMPILATION wrapper will replace the global var and Module var on # first use. args = [f'a{i}' for i in range(nargs)] @@ -998,7 +1008,11 @@ def create_module(receiving, metadata, global_exports, library_symbols): if not settings.MINIMAL_RUNTIME: if settings.WASM_ASYNC_COMPILATION: - module.append("var wasmExports;\ncreateWasm();\n") + if can_use_await(): + # In modularize mode the generated code is within a factory function. + module.append("var wasmExports = await createWasm();\n") + else: + module.append("var wasmExports;\ncreateWasm();\n") else: module.append("var wasmExports = createWasm();\n") diff --git a/tools/link.py b/tools/link.py index 2d7b6c603d7fb..fe10af00857ef 100644 --- a/tools/link.py +++ b/tools/link.py @@ -2392,13 +2392,14 @@ def modularize(): # When targetting node and ES6 we use `await import ..` in the generated code # so the outer function needs to be marked as async. - async_emit = '' - if settings.EXPORT_ES6 and settings.ENVIRONMENT_MAY_BE_NODE: - async_emit = 'async ' + if settings.WASM_ASYNC_COMPILATION or (settings.EXPORT_ES6 and settings.ENVIRONMENT_MAY_BE_NODE): + maybe_async = 'async ' + else: + maybe_async = '' if settings.MODULARIZE == 'instance': wrapper_function = ''' -export default async function init(moduleArg = {}) { +export default %(maybe_async)s function init(moduleArg = {}) { var moduleRtn; %(generated_js)s @@ -2406,7 +2407,8 @@ def modularize(): return moduleRtn; } ''' % { - 'generated_js': generated_js + 'generated_js': generated_js, + 'maybe_async': maybe_async, } else: wrapper_function = ''' @@ -2418,7 +2420,7 @@ def modularize(): return moduleRtn; } ''' % { - 'maybe_async': async_emit, + 'maybe_async': maybe_async, 'generated_js': generated_js } From 0186a3f32ae6e4db0f600c619a447aaa7d942d3f Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 18 Dec 2024 19:29:22 -0800 Subject: [PATCH 115/132] Disable test_fs_mkdir_dotdot on windows. NFC (#23223) This test was recently added in #23136 but the test fails on windows due to errno mismatch. See #8882. --- test/test_core.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_core.py b/test/test_core.py index 28d53550518d1..fb29ed537d709 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5859,6 +5859,8 @@ def test_fs_rename_on_existing(self): self.do_runf('fs/test_fs_rename_on_existing.c', 'success') @also_with_nodefs_both + @crossplatform + @no_windows('https://github.com/emscripten-core/emscripten/issues/8882') def test_fs_mkdir_dotdot(self): self.do_runf('fs/test_fs_mkdir_dotdot.c', 'success') From 971d4f6558dc5638a572dbd9a8092641b3a380e0 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Wed, 18 Dec 2024 20:35:27 -0800 Subject: [PATCH 116/132] Use consistent prefix map when building deterministic system libraries (#23222) When `deterministic_paths` is set, we are currently using `-ffile-prefix-map` to produce the same path in data and debug info. In the case of absolute paths, their emscripten path is replaced with a fake path `/emsdk/emscripten`, and in the case of relative paths, all path relative to the emscripten directory is removed, so `../../system/lib/somefile.c` becomes `system/lib/somefiles.c`. https://github.com/emscripten-core/emscripten/blob/f66b5d706e174d9e5cc6122c06ea29dcd2735cd0/tools/system_libs.py#L472-L477 https://github.com/emscripten-core/emscripten/blob/f66b5d706e174d9e5cc6122c06ea29dcd2735cd0/tools/system_libs.py#L495-L501 So this does not make relative paths and absolute paths the same, which can lead to different builds depending on whether the command line uses absolute paths vs. relative ones. Currently we use relative paths when `EMCC_BATCH_BUILD` is set. And Ninja builds cannot use relative paths. This is also what was suggested in https://github.com/emscripten-core/emscripten/issues/23195#issuecomment-2549784273 while discussins `__FILE__` problem in #23195. This does not change any code size tests because no code size tests happens to contain `__FILE__` at the moment. (One will be added in #22994) --- test/test_other.py | 2 +- tools/system_libs.py | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/test/test_other.py b/test/test_other.py index 2642b9aafd82c..1ae34b5c98081 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -10409,7 +10409,7 @@ def test_dwarf_system_lib(self): [LLVM_DWARFDUMP, libc, '-debug-info', '-debug-line', '--recurse-depth=0'], stdout=PIPE).stdout # Check that the embedded location of the source file is correct. - self.assertIn('DW_AT_name\t("system/lib/emmalloc.c")', dwdump) + self.assertIn('DW_AT_name\t("/emsdk/emscripten/system/lib/emmalloc.c")', dwdump) self.assertIn('DW_AT_comp_dir\t("/emsdk/emscripten")', dwdump) @parameterized({ diff --git a/tools/system_libs.py b/tools/system_libs.py index e6bbf1c3435b1..3b01a85fbf651 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -42,6 +42,10 @@ # link time. USE_NINJA = int(os.environ.get('EMCC_USE_NINJA', '0')) +# A (fake) deterministic emscripten path to use in __FILE__ macro and debug info +# to produce reproducible builds across platforms. +DETERMINISITIC_PREFIX = '/emsdk/emscripten' + def files_in_path(path, filenames): srcdir = utils.path_from_root(path) @@ -472,9 +476,9 @@ def generate_ninja(self, build_dir, libname): if self.deterministic_paths: source_dir = utils.path_from_root() relative_source_dir = os.path.relpath(source_dir, build_dir) - cflags += [f'-ffile-prefix-map={source_dir}=/emsdk/emscripten', - f'-ffile-prefix-map={relative_source_dir}/=', - '-fdebug-compilation-dir=/emsdk/emscripten'] + cflags += [f'-ffile-prefix-map={source_dir}={DETERMINISITIC_PREFIX}', + f'-ffile-prefix-map={relative_source_dir}={DETERMINISITIC_PREFIX}', + f'-fdebug-compilation-dir={DETERMINISITIC_PREFIX}'] asflags = get_base_cflags(preprocess=False) input_files = self.get_files() ninja_file = os.path.join(build_dir, 'build.ninja') @@ -496,9 +500,9 @@ def build_objects(self, build_dir): source_dir = utils.path_from_root() if batch_inputs: relative_source_dir = os.path.relpath(source_dir, build_dir) - cflags += [f'-ffile-prefix-map={relative_source_dir}/='] - cflags += [f'-ffile-prefix-map={source_dir}=/emsdk/emscripten', - '-fdebug-compilation-dir=/emsdk/emscripten'] + cflags += [f'-ffile-prefix-map={relative_source_dir}={DETERMINISITIC_PREFIX}'] + cflags += [f'-ffile-prefix-map={source_dir}={DETERMINISITIC_PREFIX}', + f'-fdebug-compilation-dir={DETERMINISITIC_PREFIX}'] case_insensitive = is_case_insensitive(build_dir) for src in self.get_files(): ext = shared.suffix(src) From 89c946e5bb5cc467f8b85158ac81d601d4cabc1a Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 19 Dec 2024 13:11:32 +0100 Subject: [PATCH 117/132] Make open O_CREATE mode 0 work (#23137) In nodefs we first create the node with permissions 0 and then try to open it. The open fails because we don't have read permissions. The following (18) test expectation files were updated by running the tests with `--rebaseline`: ``` other/codesize/test_codesize_cxx_ctors1.gzsize: 8351 => 8407 [+56 bytes / +0.67%] other/codesize/test_codesize_cxx_ctors1.jssize: 20343 => 20486 [+143 bytes / +0.70%] other/codesize/test_codesize_cxx_ctors2.gzsize: 8334 => 8390 [+56 bytes / +0.67%] other/codesize/test_codesize_cxx_ctors2.jssize: 20311 => 20454 [+143 bytes / +0.70%] other/codesize/test_codesize_cxx_except.gzsize: 9356 => 9411 [+55 bytes / +0.59%] other/codesize/test_codesize_cxx_except.jssize: 24112 => 24255 [+143 bytes / +0.59%] other/codesize/test_codesize_cxx_except_wasm.gzsize: 8321 => 8373 [+52 bytes / +0.62%] other/codesize/test_codesize_cxx_except_wasm.jssize: 20236 => 20379 [+143 bytes / +0.71%] other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize: 8321 => 8373 [+52 bytes / +0.62%] other/codesize/test_codesize_cxx_except_wasm_exnref.jssize: 20236 => 20379 [+143 bytes / +0.71%] other/codesize/test_codesize_cxx_lto.gzsize: 8347 => 8404 [+57 bytes / +0.68%] other/codesize/test_codesize_cxx_lto.jssize: 20367 => 20510 [+143 bytes / +0.70%] other/codesize/test_codesize_cxx_mangle.gzsize: 9359 => 9416 [+57 bytes / +0.61%] other/codesize/test_codesize_cxx_mangle.jssize: 24112 => 24255 [+143 bytes / +0.59%] other/codesize/test_codesize_cxx_noexcept.gzsize: 8351 => 8407 [+56 bytes / +0.67%] other/codesize/test_codesize_cxx_noexcept.jssize: 20343 => 20486 [+143 bytes / +0.70%] other/codesize/test_codesize_files_js_fs.gzsize: 7654 => 7702 [+48 bytes / +0.63%] other/codesize/test_codesize_files_js_fs.jssize: 18838 => 18980 [+142 bytes / +0.75%] Average change: +0.66% (+0.59% - +0.75%) ``` --- src/library_fs.js | 8 ++++++- test/fs/test_fs_open_no_permissions.c | 21 +++++++++++++++++++ .../codesize/test_codesize_cxx_ctors1.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors1.jssize | 2 +- .../codesize/test_codesize_cxx_ctors2.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors2.jssize | 2 +- .../codesize/test_codesize_cxx_except.gzsize | 2 +- .../codesize/test_codesize_cxx_except.jssize | 2 +- .../test_codesize_cxx_except_wasm.gzsize | 2 +- .../test_codesize_cxx_except_wasm.jssize | 2 +- ...est_codesize_cxx_except_wasm_exnref.gzsize | 2 +- ...est_codesize_cxx_except_wasm_exnref.jssize | 2 +- .../codesize/test_codesize_cxx_lto.gzsize | 2 +- .../codesize/test_codesize_cxx_lto.jssize | 2 +- .../codesize/test_codesize_cxx_mangle.gzsize | 2 +- .../codesize/test_codesize_cxx_mangle.jssize | 2 +- .../test_codesize_cxx_noexcept.gzsize | 2 +- .../test_codesize_cxx_noexcept.jssize | 2 +- .../codesize/test_codesize_files_js_fs.gzsize | 2 +- .../codesize/test_codesize_files_js_fs.jssize | 2 +- test/test_core.py | 4 ++++ 21 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 test/fs/test_fs_open_no_permissions.c diff --git a/src/library_fs.js b/src/library_fs.js index 0af7a7466d808..6ed0734949fa1 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -1087,7 +1087,10 @@ FS.staticInit(); throw new FS.ErrnoError({{{ cDefs.EISDIR }}}); } else { // node doesn't exist, try to create it - node = FS.mknod(path, mode, 0); + // Ignore the permission bits here to ensure we can `open` this new + // file below. We use chmod below the apply the permissions once the + // file is open. + node = FS.mknod(path, mode | 0o777, 0); created = true; } } @@ -1137,6 +1140,9 @@ FS.staticInit(); if (stream.stream_ops.open) { stream.stream_ops.open(stream); } + if (created) { + FS.chmod(node, mode & 0o777); + } #if expectToReceiveOnModule('logReadFiles') if (Module['logReadFiles'] && !(flags & {{{ cDefs.O_WRONLY}}})) { if (!(path in FS.readFiles)) { diff --git a/test/fs/test_fs_open_no_permissions.c b/test/fs/test_fs_open_no_permissions.c new file mode 100644 index 0000000000000..c1b647396009e --- /dev/null +++ b/test/fs/test_fs_open_no_permissions.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// TODO: Combine this with test_fcntl_open.c. First requires fixing +// test_fcntl_open.c on noderawfs. +int main() { + int res = open("a", O_CREAT, 0); + printf("error: %s\n", strerror(errno)); + assert(res >= 0); + struct stat st; + assert(stat("a", &st) == 0); + assert((st.st_mode & 0777) == 0); + printf("success\n"); +} diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 7c05c8455e746..4be81cb9fb3af 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8351 +8407 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index 82d8332d892e9..a20e18243e7cb 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20343 +20486 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index e7f2f2aa09e70..a559385da7f91 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8334 +8390 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index f8c47ad8dd2c0..0ca3697c3144a 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20311 +20454 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 26f242e26fb55..d2e5ea2910cc9 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9356 +9411 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index c495dc33171d4..d80dc789e6880 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24112 +24255 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index f14ddc132870a..2a12540f0635f 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8321 +8373 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index 276f80508b53d..903c819cfe0ac 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20236 +20379 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index f14ddc132870a..2a12540f0635f 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8321 +8373 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index 276f80508b53d..903c819cfe0ac 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20236 +20379 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index a665dbc2e401e..5f41444ba9dcc 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8347 +8404 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index cd0660982b7d0..c7e497cb94f12 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20367 +20510 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index 886a28e6c91b7..54e18a6e2baed 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9359 +9416 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index c495dc33171d4..d80dc789e6880 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24112 +24255 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 7c05c8455e746..4be81cb9fb3af 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8351 +8407 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index 82d8332d892e9..a20e18243e7cb 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20343 +20486 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index 309e97c7a9f6c..c3a0b57749871 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7654 +7702 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index 79d0a5b02487f..33dab3f6f464f 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18838 +18980 diff --git a/test/test_core.py b/test/test_core.py index fb29ed537d709..015601b228aa2 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5858,6 +5858,10 @@ def test_fs_rename_on_existing(self): self.set_setting('FORCE_FILESYSTEM') self.do_runf('fs/test_fs_rename_on_existing.c', 'success') + @also_with_nodefs_both + def test_fs_open_no_permissions(self): + self.do_runf('fs/test_fs_open_no_permissions.c', 'success') + @also_with_nodefs_both @crossplatform @no_windows('https://github.com/emscripten-core/emscripten/issues/8882') From 021e1740369097c5b6521f54d2cc3a1dfa1f87ff Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 19 Dec 2024 17:00:03 +0100 Subject: [PATCH 118/132] Opening a directory with O_CREAT should return EISDIR (#23218) So that the behavior matches the behavior on linux. This makes the test pass on nodefs and noderawfs. This allows merging the test added in #23137 into test_fcntl_open.c --- src/library_fs.js | 4 ++-- system/lib/wasmfs/syscalls.cpp | 2 +- test/fcntl/test_fcntl_open.c | 2 +- test/fcntl/test_fcntl_open.out | 16 ++++++++-------- .../codesize/test_codesize_cxx_ctors1.gzsize | 2 +- .../codesize/test_codesize_cxx_ctors2.gzsize | 2 +- .../codesize/test_codesize_cxx_except.gzsize | 2 +- .../test_codesize_cxx_except_wasm.gzsize | 2 +- .../test_codesize_cxx_except_wasm_exnref.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- .../codesize/test_codesize_cxx_mangle.gzsize | 2 +- .../codesize/test_codesize_cxx_noexcept.gzsize | 2 +- .../codesize/test_codesize_files_js_fs.gzsize | 2 +- test/test_core.py | 1 + 14 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/library_fs.js b/src/library_fs.js index 6ed0734949fa1..5fb60d1fb5aee 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -426,8 +426,8 @@ FS.staticInit(); if (FS.isLink(node.mode)) { return {{{ cDefs.ELOOP }}}; } else if (FS.isDir(node.mode)) { - if (FS.flagsToPermissionString(flags) !== 'r' || // opening for write - (flags & {{{ cDefs.O_TRUNC }}})) { // TODO: check for O_SEARCH? (== search for dir only) + if (FS.flagsToPermissionString(flags) !== 'r' // opening for write + || (flags & ({{{ cDefs.O_TRUNC }}} | {{{ cDefs.O_CREAT }}}))) { // TODO: check for O_SEARCH? (== search for dir only) return {{{ cDefs.EISDIR }}}; } } diff --git a/system/lib/wasmfs/syscalls.cpp b/system/lib/wasmfs/syscalls.cpp index 82e3e9d6e0324..94ad74b6595bd 100644 --- a/system/lib/wasmfs/syscalls.cpp +++ b/system/lib/wasmfs/syscalls.cpp @@ -520,7 +520,7 @@ static __wasi_fd_t doOpen(path::ParsedParent parsed, return -EEXIST; } - if (child->is() && accessMode != O_RDONLY) { + if (child->is() && (accessMode != O_RDONLY || (flags & O_CREAT))) { return -EISDIR; } diff --git a/test/fcntl/test_fcntl_open.c b/test/fcntl/test_fcntl_open.c index 0f48c9c17a974..a34de9ea676a2 100644 --- a/test/fcntl/test_fcntl_open.c +++ b/test/fcntl/test_fcntl_open.c @@ -78,7 +78,7 @@ void test() { if ((flags & O_CREAT) && (flags & O_EXCL)) { assert(!success); assert(errno == EEXIST); - } else if ((flags & O_TRUNC) || i != 0 /*mode != O_RDONLY*/) { + } else if ((flags & O_TRUNC) || i != 0 /*mode != O_RDONLY*/ || (flags & O_CREAT)) { assert(!success); assert(errno == EISDIR); } else { diff --git a/test/fcntl/test_fcntl_open.out b/test/fcntl/test_fcntl_open.out index f510e40657a78..19938d6ca9642 100644 --- a/test/fcntl/test_fcntl_open.out +++ b/test/fcntl/test_fcntl_open.out @@ -19,8 +19,8 @@ errno: 0 st_mode: 0100000 EXISTING FOLDER 0,1 -success: 1 -errno: 0 +success: 0 +errno: 31 st_mode: 040000 NON-EXISTING 0,1 @@ -139,8 +139,8 @@ errno: 0 st_mode: 0100000 EXISTING FOLDER 0,9 -success: 1 -errno: 0 +success: 0 +errno: 31 st_mode: 040000 NON-EXISTING 0,9 @@ -259,8 +259,8 @@ errno: 0 st_mode: 0100000 EXISTING FOLDER 0,17 -success: 1 -errno: 0 +success: 0 +errno: 31 st_mode: 040000 NON-EXISTING 0,17 @@ -379,8 +379,8 @@ errno: 0 st_mode: 0100000 EXISTING FOLDER 0,25 -success: 1 -errno: 0 +success: 0 +errno: 31 st_mode: 040000 NON-EXISTING 0,25 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 4be81cb9fb3af..b2fd8c7b992c7 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8407 +8408 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index a559385da7f91..cdc91cd424110 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8390 +8392 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index d2e5ea2910cc9..199a0b963f1ab 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9411 +9413 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index 2a12540f0635f..0b2a5d20da7ef 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8373 +8374 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index 2a12540f0635f..0b2a5d20da7ef 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8373 +8374 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 5f41444ba9dcc..9fa65500fcae8 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8404 +8406 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index 54e18a6e2baed..b92fe18e229cc 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9416 +9417 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 4be81cb9fb3af..b2fd8c7b992c7 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8407 +8408 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index c3a0b57749871..3eb330568eb87 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7702 +7704 diff --git a/test/test_core.py b/test/test_core.py index 015601b228aa2..01565ae626e6f 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5543,6 +5543,7 @@ def test_fcntl(self): self.add_pre_run("FS.createDataFile('/', 'test', 'abcdef', true, true, false);") self.do_run_in_out_file_test('fcntl/test_fcntl.c') + @also_with_nodefs_both def test_fcntl_open(self): self.do_run_in_out_file_test('fcntl/test_fcntl_open.c') From aead0b05fecb5de0daca419d4d5b05cd19671eb3 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 19 Dec 2024 17:15:28 +0100 Subject: [PATCH 119/132] Ensure the ino we give to readdir matches the ino we give to stat (#23139) If we stat a file in the nodefs it gives a different value for the inode than if we use readdir. Readdir gives the inode in the host file system, stat gives the inode in the native file system. Ideally they should agree about what the inode is. --- src/library_nodefs.js | 2 +- test/common.py | 15 +---- .../fs/test_fs_readdir_ino_matches_stat_ino.c | 62 +++++++++++++++++++ test/test_core.py | 4 ++ 4 files changed, 69 insertions(+), 14 deletions(-) create mode 100644 test/fs/test_fs_readdir_ino_matches_stat_ino.c diff --git a/src/library_nodefs.js b/src/library_nodefs.js index 5570bcc68f5c8..21e0561b783d9 100644 --- a/src/library_nodefs.js +++ b/src/library_nodefs.js @@ -138,7 +138,7 @@ addToLibrary({ } return { dev: stat.dev, - ino: stat.ino, + ino: node.id, mode: stat.mode, nlink: stat.nlink, uid: stat.uid, diff --git a/test/common.py b/test/common.py index 87111f5bd3ebf..541d89aaca73f 100644 --- a/test/common.py +++ b/test/common.py @@ -742,27 +742,16 @@ def make_executable(name): def make_dir_writeable(dirname): - # Ensure all files are readable and writable by the current user. - permission_bits = stat.S_IWRITE | stat.S_IREAD - - def is_writable(path): - return (os.stat(path).st_mode & permission_bits) != permission_bits - - def make_writable(path): - new_mode = os.stat(path).st_mode | permission_bits - os.chmod(path, new_mode) - # Some tests make files and subdirectories read-only, so rmtree/unlink will not delete # them. Force-make everything writable in the subdirectory to make it # removable and re-attempt. - if not is_writable(dirname): - make_writable(dirname) + os.chmod(dirname, 0o777) for directory, subdirs, files in os.walk(dirname): for item in files + subdirs: i = os.path.join(directory, item) if not os.path.islink(i): - make_writable(i) + os.chmod(i, 0o777) def force_delete_dir(dirname): diff --git a/test/fs/test_fs_readdir_ino_matches_stat_ino.c b/test/fs/test_fs_readdir_ino_matches_stat_ino.c new file mode 100644 index 0000000000000..68e1f1da4e55d --- /dev/null +++ b/test/fs/test_fs_readdir_ino_matches_stat_ino.c @@ -0,0 +1,62 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// TODO: Consider merging this with test/dirent/test_readdir.c? +// That test doesn't work on nodefs, which has to be fixed before these two +// tests can be merged . + +void setup() { + // If the node working directory does not have execute permissions, then + // `fs.readdir` will fail. For that reason we have to work in a subdirectory + // and remove execute permissions from that. + mkdir("sub", 0775); + assert(chdir("sub") == 0); + int res = open("b", O_CREAT, 0777); + assert(res >= 0); + assert(close(res) == 0); + assert(symlink("b", "a") == 0); +} + +int main() { + setup(); + int dirfd = open(".", O_RDONLY); + assert(dirfd > 0); + DIR *dirp = fdopendir(dirfd); + assert(dirp != NULL); + struct stat sta, stb; + assert(lstat("a", &sta) == 0); + assert(lstat("b", &stb) == 0); + // Test that removing permissions from the directory does not affect the + // already open directory handle that we have (dirp). +#ifndef NODERAWFS + assert(chmod(".", 0675) == 0); +#endif + int a_ino = -1; + int b_ino = -1; + struct dirent *ep; + while ((ep = readdir(dirp))) { + if (strcmp(ep->d_name, "a") == 0) { + a_ino = ep->d_ino; + } + if (strcmp(ep->d_name, "b") == 0) { + b_ino = ep->d_ino; + } + } + assert(errno == 0); + assert(a_ino >= 0); + assert(b_ino >= 0); + printf("readdir a_ino: %d, b_ino: %d\n", a_ino, b_ino); + printf("stat a_ino: %llu, b_ino: %llu\n", sta.st_ino, stb.st_ino); + assert(a_ino == sta.st_ino); + assert(b_ino == stb.st_ino); + printf("success\n"); + return 0; +} diff --git a/test/test_core.py b/test/test_core.py index 01565ae626e6f..ba51f97e69200 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5859,6 +5859,10 @@ def test_fs_rename_on_existing(self): self.set_setting('FORCE_FILESYSTEM') self.do_runf('fs/test_fs_rename_on_existing.c', 'success') + @also_with_nodefs_both + def test_fs_readdir_ino_matches_stat_ino(self): + self.do_runf('fs/test_fs_readdir_ino_matches_stat_ino.c', 'success') + @also_with_nodefs_both def test_fs_open_no_permissions(self): self.do_runf('fs/test_fs_open_no_permissions.c', 'success') From d23a20d3593895b483ff473518081ec4455706be Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Thu, 19 Dec 2024 10:57:21 -0800 Subject: [PATCH 120/132] Enable nontrapping-fp by default (#23007) Enable nontrapping-fptoint by lowering the browser target requirement. Once all 3 Safari 15 features have been enabled, I will reset the requirement correctly. --- ChangeLog.md | 8 ++++++++ emcc.py | 8 ++++++-- test/code_size/hello_webgl2_wasm.json | 8 ++++---- test/code_size/hello_webgl2_wasm2js.json | 8 ++++---- test/code_size/hello_webgl_wasm.json | 8 ++++---- test/code_size/hello_webgl_wasm2js.json | 8 ++++---- test/code_size/math_wasm.json | 8 ++++---- test/code_size/random_printf_wasm.json | 8 ++++---- test/code_size/random_printf_wasm2js.json | 4 ++-- test/other/codesize/test_codesize_cxx_ctors1.size | 2 +- test/other/codesize/test_codesize_cxx_ctors2.size | 2 +- test/other/codesize/test_codesize_cxx_except.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.size | 2 +- .../codesize/test_codesize_cxx_except_wasm_exnref.size | 2 +- test/other/codesize/test_codesize_cxx_lto.size | 2 +- test/other/codesize/test_codesize_cxx_mangle.size | 2 +- test/other/codesize/test_codesize_cxx_noexcept.size | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.size | 2 +- test/other/codesize/test_codesize_hello_O0.size | 2 +- test/other/codesize/test_codesize_hello_O1.size | 2 +- test/other/codesize/test_codesize_minimal_O0.size | 2 +- test/other/codesize/test_codesize_minimal_O1.size | 2 +- test/other/codesize/test_codesize_minimal_pthreads.size | 2 +- test/other/test_unoptimized_code_size.wasm.size | 2 +- .../other/test_unoptimized_code_size_no_asserts.wasm.size | 2 +- test/other/test_unoptimized_code_size_strict.wasm.size | 2 +- test/test_other.py | 8 ++++---- tools/feature_matrix.py | 3 ++- tools/link.py | 3 +++ 29 files changed, 66 insertions(+), 50 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 8400bcaa9a81d..7db38dcfc8072 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -20,6 +20,14 @@ See docs/process.md for more on how version tagging works. 3.1.75 (in development) ----------------------- +- The Wasm nontrapping-fptoint feature has been enabled by default. clang will + generate nontrapping (saturating) float-to-int conversion instructions for + C typecasts. This should have no effect on programs that do not have + undefined behavior but if the casted floating-point value is outside the range + of the target integer type, the result will be a number of the max or min value + instead of a trap. This also results in a small code size improvement because + of details of the LLVM IR semantics. This feature can be disabled in clang with + the -mno-nontrapping-fptoint flag. (#23007) - The `WASM_BIGINT` feature has been enabled by default. This has the effect that Wasm i64 values are passed and returned between Wasm and JS as BigInt values rather than being split by Binaryen into pairs of Numbers. (#22993) diff --git a/emcc.py b/emcc.py index b519281e72e84..1ae6a24f94477 100644 --- a/emcc.py +++ b/emcc.py @@ -392,8 +392,6 @@ def get_clang_flags(user_args): if not settings.BULK_MEMORY: flags.append('-mno-bulk-memory') flags.append('-mno-bulk-memory-opt') - if '-mnontrapping-fptoint' not in user_args and '-mno-nontrapping-fptoint' not in user_args: - flags.append('-mno-nontrapping-fptoint') if settings.RELOCATABLE and '-fPIC' not in user_args: flags.append('-fPIC') @@ -1435,6 +1433,12 @@ def consume_arg_file(): override=True) elif arg == '-mno-sign-ext': feature_matrix.disable_feature(feature_matrix.Feature.SIGN_EXT) + elif arg == '-mnontrappting-fptoint': + feature_matrix.enable_feature(feature_matrix.Feature.NON_TRAPPING_FPTOINT, + '-mnontrapping-fptoint', + override=True) + elif arg == '-mno-nontrapping-fptoint': + feature_matrix.disable_feature(feature_matrix.Feature.NON_TRAPPING_FPTOINT) elif arg == '-fexceptions': # TODO Currently -fexceptions only means Emscripten EH. Switch to wasm # exception handling by default when -fexceptions is given when wasm diff --git a/test/code_size/hello_webgl2_wasm.json b/test/code_size/hello_webgl2_wasm.json index d7738773ebc50..57518ddaba94c 100644 --- a/test/code_size/hello_webgl2_wasm.json +++ b/test/code_size/hello_webgl2_wasm.json @@ -3,8 +3,8 @@ "a.html.gz": 328, "a.js": 4538, "a.js.gz": 2320, - "a.wasm": 10402, - "a.wasm.gz": 6703, - "total": 15394, - "total_gz": 9351 + "a.wasm": 10206, + "a.wasm.gz": 6663, + "total": 15198, + "total_gz": 9311 } diff --git a/test/code_size/hello_webgl2_wasm2js.json b/test/code_size/hello_webgl2_wasm2js.json index da83c09580bbe..3074c7154d437 100644 --- a/test/code_size/hello_webgl2_wasm2js.json +++ b/test/code_size/hello_webgl2_wasm2js.json @@ -1,8 +1,8 @@ { "a.html": 346, "a.html.gz": 262, - "a.js": 22206, - "a.js.gz": 11589, - "total": 22552, - "total_gz": 11851 + "a.js": 22202, + "a.js.gz": 11604, + "total": 22548, + "total_gz": 11866 } diff --git a/test/code_size/hello_webgl_wasm.json b/test/code_size/hello_webgl_wasm.json index e4c3af111aac8..1aad262f62aa7 100644 --- a/test/code_size/hello_webgl_wasm.json +++ b/test/code_size/hello_webgl_wasm.json @@ -3,8 +3,8 @@ "a.html.gz": 328, "a.js": 4076, "a.js.gz": 2163, - "a.wasm": 10402, - "a.wasm.gz": 6703, - "total": 14932, - "total_gz": 9194 + "a.wasm": 10206, + "a.wasm.gz": 6663, + "total": 14736, + "total_gz": 9154 } diff --git a/test/code_size/hello_webgl_wasm2js.json b/test/code_size/hello_webgl_wasm2js.json index c2cb2b2deec67..c0b731a9418e9 100644 --- a/test/code_size/hello_webgl_wasm2js.json +++ b/test/code_size/hello_webgl_wasm2js.json @@ -1,8 +1,8 @@ { "a.html": 346, "a.html.gz": 262, - "a.js": 21732, - "a.js.gz": 11419, - "total": 22078, - "total_gz": 11681 + "a.js": 21728, + "a.js.gz": 11435, + "total": 22074, + "total_gz": 11697 } diff --git a/test/code_size/math_wasm.json b/test/code_size/math_wasm.json index 391e9180af9a3..af0e00a9e9803 100644 --- a/test/code_size/math_wasm.json +++ b/test/code_size/math_wasm.json @@ -3,8 +3,8 @@ "a.html.gz": 380, "a.js": 110, "a.js.gz": 125, - "a.wasm": 2719, - "a.wasm.gz": 1675, - "total": 3381, - "total_gz": 2180 + "a.wasm": 2695, + "a.wasm.gz": 1664, + "total": 3357, + "total_gz": 2169 } diff --git a/test/code_size/random_printf_wasm.json b/test/code_size/random_printf_wasm.json index 8548e41737392..ade5c33a60bb4 100644 --- a/test/code_size/random_printf_wasm.json +++ b/test/code_size/random_printf_wasm.json @@ -1,6 +1,6 @@ { - "a.html": 12597, - "a.html.gz": 6882, - "total": 12597, - "total_gz": 6882 + "a.html": 12517, + "a.html.gz": 6871, + "total": 12517, + "total_gz": 6871 } diff --git a/test/code_size/random_printf_wasm2js.json b/test/code_size/random_printf_wasm2js.json index b3fe0c465524e..ea20a2b833652 100644 --- a/test/code_size/random_printf_wasm2js.json +++ b/test/code_size/random_printf_wasm2js.json @@ -1,6 +1,6 @@ { "a.html": 17195, - "a.html.gz": 7478, + "a.html.gz": 7480, "total": 17195, - "total_gz": 7478 + "total_gz": 7480 } diff --git a/test/other/codesize/test_codesize_cxx_ctors1.size b/test/other/codesize/test_codesize_cxx_ctors1.size index 467ff31c3f2cd..4f8ba557ee1b8 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.size +++ b/test/other/codesize/test_codesize_cxx_ctors1.size @@ -1 +1 @@ -128974 +128914 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.size b/test/other/codesize/test_codesize_cxx_ctors2.size index 5151c7d5ae032..e231c13fee48e 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.size +++ b/test/other/codesize/test_codesize_cxx_ctors2.size @@ -1 +1 @@ -128423 +128363 diff --git a/test/other/codesize/test_codesize_cxx_except.size b/test/other/codesize/test_codesize_cxx_except.size index 7a6716bb2a43a..eb55c181c5216 100644 --- a/test/other/codesize/test_codesize_cxx_except.size +++ b/test/other/codesize/test_codesize_cxx_except.size @@ -1 +1 @@ -171008 +170948 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.size b/test/other/codesize/test_codesize_cxx_except_wasm.size index ccdf567408898..27d22ec7b1d75 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm.size @@ -1 +1 @@ -142223 +142163 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size index 9fd3641491ec2..c6bf43ceae592 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.size @@ -1 +1 @@ -144810 +144750 diff --git a/test/other/codesize/test_codesize_cxx_lto.size b/test/other/codesize/test_codesize_cxx_lto.size index b0dea2b9e570d..a10677fcc662b 100644 --- a/test/other/codesize/test_codesize_cxx_lto.size +++ b/test/other/codesize/test_codesize_cxx_lto.size @@ -1 +1 @@ -121924 +121864 diff --git a/test/other/codesize/test_codesize_cxx_mangle.size b/test/other/codesize/test_codesize_cxx_mangle.size index e1078b8c5934e..f1d783a2932c3 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.size +++ b/test/other/codesize/test_codesize_cxx_mangle.size @@ -1 +1 @@ -232517 +232457 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.size b/test/other/codesize/test_codesize_cxx_noexcept.size index 232be2fc5f578..75539b68cab43 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.size +++ b/test/other/codesize/test_codesize_cxx_noexcept.size @@ -1 +1 @@ -131781 +131721 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.size b/test/other/codesize/test_codesize_cxx_wasmfs.size index 8c558ef5ce85b..8140672e8a8ef 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.size +++ b/test/other/codesize/test_codesize_cxx_wasmfs.size @@ -1 +1 @@ -168928 +168868 diff --git a/test/other/codesize/test_codesize_hello_O0.size b/test/other/codesize/test_codesize_hello_O0.size index 08a458d71f92f..5e161ac666248 100644 --- a/test/other/codesize/test_codesize_hello_O0.size +++ b/test/other/codesize/test_codesize_hello_O0.size @@ -1 +1 @@ -15142 +15087 diff --git a/test/other/codesize/test_codesize_hello_O1.size b/test/other/codesize/test_codesize_hello_O1.size index 1c4c2ded8919d..d061229a5f7d6 100644 --- a/test/other/codesize/test_codesize_hello_O1.size +++ b/test/other/codesize/test_codesize_hello_O1.size @@ -1 +1 @@ -2634 +2655 diff --git a/test/other/codesize/test_codesize_minimal_O0.size b/test/other/codesize/test_codesize_minimal_O0.size index 0141c45d767b7..7061465351498 100644 --- a/test/other/codesize/test_codesize_minimal_O0.size +++ b/test/other/codesize/test_codesize_minimal_O0.size @@ -1 +1 @@ -1104 +1125 diff --git a/test/other/codesize/test_codesize_minimal_O1.size b/test/other/codesize/test_codesize_minimal_O1.size index 8b84f57086ba5..29aae8eeca636 100644 --- a/test/other/codesize/test_codesize_minimal_O1.size +++ b/test/other/codesize/test_codesize_minimal_O1.size @@ -1 +1 @@ -397 +418 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.size b/test/other/codesize/test_codesize_minimal_pthreads.size index 0a5bf4b2a51ac..59501bf076992 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.size +++ b/test/other/codesize/test_codesize_minimal_pthreads.size @@ -1 +1 @@ -19487 +19448 diff --git a/test/other/test_unoptimized_code_size.wasm.size b/test/other/test_unoptimized_code_size.wasm.size index 08a458d71f92f..5e161ac666248 100644 --- a/test/other/test_unoptimized_code_size.wasm.size +++ b/test/other/test_unoptimized_code_size.wasm.size @@ -1 +1 @@ -15142 +15087 diff --git a/test/other/test_unoptimized_code_size_no_asserts.wasm.size b/test/other/test_unoptimized_code_size_no_asserts.wasm.size index c343caa8e2659..3b081b1eeb5dc 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.wasm.size +++ b/test/other/test_unoptimized_code_size_no_asserts.wasm.size @@ -1 +1 @@ -12223 +12168 diff --git a/test/other/test_unoptimized_code_size_strict.wasm.size b/test/other/test_unoptimized_code_size_strict.wasm.size index 08a458d71f92f..5e161ac666248 100644 --- a/test/other/test_unoptimized_code_size_strict.wasm.size +++ b/test/other/test_unoptimized_code_size_strict.wasm.size @@ -1 +1 @@ -15142 +15087 diff --git a/test/test_other.py b/test/test_other.py index 1ae34b5c98081..4a9b63b498d1d 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -10461,7 +10461,7 @@ def compile(flags): compile(['-c']) verify_features_sec('bulk-memory', False) - verify_features_sec('nontrapping-fptoint', False) + verify_features_sec('nontrapping-fptoint', True) verify_features_sec('sign-ext', True) verify_features_sec('mutable-globals', True) verify_features_sec('multivalue', True) @@ -10482,8 +10482,8 @@ def compile(flags): compile(['-sMIN_FIREFOX_VERSION=61', '-msign-ext']) verify_features_sec_linked('sign-ext', True) - compile(['-mnontrapping-fptoint', '-c']) - verify_features_sec('nontrapping-fptoint', True) + compile(['-mno-nontrapping-fptoint']) + verify_features_sec_linked('nontrapping-fptoint', False) # Setting this SAFARI_VERSION should enable bulk memory because it links in emscripten_memcpy_bulkmem # However it does not enable nontrapping-fptoint yet because it has no effect at compile time and @@ -10493,7 +10493,7 @@ def compile(flags): verify_features_sec_linked('mutable-globals', True) verify_features_sec_linked('multivalue', True) verify_features_sec_linked('bulk-memory', True) - verify_features_sec_linked('nontrapping-fptoint', False) + verify_features_sec_linked('nontrapping-fptoint', True) compile(['-sMIN_SAFARI_VERSION=150000', '-mno-bulk-memory']) # -mno-bulk-memory at link time overrides MIN_SAFARI_VERSION diff --git a/tools/feature_matrix.py b/tools/feature_matrix.py index 372d17c4ae332..283c9e52f2c21 100644 --- a/tools/feature_matrix.py +++ b/tools/feature_matrix.py @@ -46,7 +46,8 @@ class Feature(IntEnum): Feature.NON_TRAPPING_FPTOINT: { 'chrome': 75, 'firefox': 65, - 'safari': 150000, + 'safari': 140100, # TODO: Reset back to 150000 when the default changes + 'node': 130000, }, Feature.SIGN_EXT: { 'chrome': 74, diff --git a/tools/link.py b/tools/link.py index fe10af00857ef..6dec5fd5fd20d 100644 --- a/tools/link.py +++ b/tools/link.py @@ -340,6 +340,9 @@ def get_binaryen_passes(): if not feature_matrix.caniuse(feature_matrix.Feature.SIGN_EXT): logger.debug('lowering sign-ext feature due to incompatible target browser engines') passes += ['--signext-lowering'] + # nontrapping-fp is enabled by default in llvm. Lower it away if requested. + if not feature_matrix.caniuse(feature_matrix.Feature.NON_TRAPPING_FPTOINT): + passes += ['--llvm-nontrapping-fptoint-lowering'] if optimizing: passes += ['--post-emscripten'] if settings.SIDE_MODULE: From fc66f9a72ae9b583eae39b151fe2400950a8719e Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 19 Dec 2024 11:37:47 -0800 Subject: [PATCH 121/132] Remove unnecessary @nocollape. NFC (#23216) This was added back in #20191 but I can't see how it can work. The thing is being applied to here is a function variable. e.g.: ``` var Modulle = function() { ... return the a new module }; ``` From the documentation for @nocollape is not clear to me that it has any effect on normal variables like this. --- tools/link.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/link.py b/tools/link.py index 6dec5fd5fd20d..6c3ca352ff6d7 100644 --- a/tools/link.py +++ b/tools/link.py @@ -2430,7 +2430,7 @@ def modularize(): if settings.MINIMAL_RUNTIME and not settings.PTHREADS: # Single threaded MINIMAL_RUNTIME programs do not need access to # document.currentScript, so a simple export declaration is enough. - src = f'/** @nocollapse */ var {settings.EXPORT_NAME} = {wrapper_function};' + src = f'var {settings.EXPORT_NAME} = {wrapper_function};' else: script_url_node = '' # When MODULARIZE this JS may be executed later, From c4ecb13cbf368a731cc96613cf34a94962a5311d Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Thu, 19 Dec 2024 11:42:10 -0800 Subject: [PATCH 122/132] Disable test_fs_readdir_ino_matches_stat_ino on Windows (#23234) --- test/test_core.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_core.py b/test/test_core.py index ba51f97e69200..243b6d202babd 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5860,6 +5860,8 @@ def test_fs_rename_on_existing(self): self.do_runf('fs/test_fs_rename_on_existing.c', 'success') @also_with_nodefs_both + @no_windows('stat ino values dont match on windows') + @crossplatform def test_fs_readdir_ino_matches_stat_ino(self): self.do_runf('fs/test_fs_readdir_ino_matches_stat_ino.c', 'success') From 66c0a02884b74e9c726e26f46f5af1c47557ddbc Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 19 Dec 2024 13:35:22 -0800 Subject: [PATCH 123/132] [ci] Add expectations check for PR branch (#23226) See #23146 --- .github/workflows/ci.yml | 20 +++++++++++++++++++- tools/maint/rebaseline_tests.py | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 821915ea44462..f6b1abea01ce7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,7 @@ jobs: cat $EM_CONFIG - name: Check test expectations on target branch run: | + echo "Checking out ${{ github.base_ref }}" git checkout ${{ github.base_ref }} git rev-parse HEAD # Hack to honor changes to rebaseline_tests.py in the current PR @@ -62,7 +63,24 @@ jobs: ./bootstrap if ! ./tools/maint/rebaseline_tests.py --check-only; then echo "Test expectations are out-of-date on the target branch." - echo "You can run `./tools/maint/rebaseline_tests.py --new-branch`" + echo "You can run './tools/maint/rebaseline_tests.py --new-branch'" echo "and use it to create a seperate PR." + echo "-- This failure is only a warning and can be ignored" + exit 1 + fi + - name: Check test expectations on PR branch + run: | + echo "Checking out ${{ github.ref }} (${{ github.sha }})" + # For some reason we cannot pass ${{ github.ref }} direclty to git + # since it doesn't recognise it. + git checkout ${{ github.sha }} + git rev-parse HEAD + ./bootstrap + if ! ./tools/maint/rebaseline_tests.py --check-only --clear-cache; then + echo "Test expectations are out-of-date on the PR branch." + echo "You can run './tools/maint/rebaseline_tests.py' to" + echo "create a commit updating the expectations." + echo "Be sure to have `emsdk install tot` first." + echo "-- This failure is only a warning and can be ignored" exit 1 fi diff --git a/tools/maint/rebaseline_tests.py b/tools/maint/rebaseline_tests.py index 307af1cda61e1..151a37ef5f3e0 100755 --- a/tools/maint/rebaseline_tests.py +++ b/tools/maint/rebaseline_tests.py @@ -71,7 +71,7 @@ def main(argv): args = parser.parse_args() if args.clear_cache: - run(['emcc', '--clear-cache']) + run(['./emcc', '--clear-cache']) if not args.skip_tests: if not args.check_only and run(['git', 'status', '-uno', '--porcelain']).strip(): From 82491a8f69f1af30f31e8f5b5213fda7f81925e8 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 19 Dec 2024 14:30:42 -0800 Subject: [PATCH 124/132] Avoid extra whitespace when using `asyncIf`/`awaitIf` macros. NFC (#23237) --- src/library_pthread.js | 2 +- src/library_wasmfs_opfs.js | 8 ++++---- src/parseTools.mjs | 4 ++-- src/postamble.js | 4 ++-- src/preamble.js | 2 +- src/runtime_pthread.js | 4 ++-- test/other/test_unoptimized_code_size.js.size | 2 +- test/other/test_unoptimized_code_size_no_asserts.js.size | 2 +- test/other/test_unoptimized_code_size_strict.js.size | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/library_pthread.js b/src/library_pthread.js index 64d276410d3fa..55477e3f92f29 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -1043,7 +1043,7 @@ var LibraryPThread = { '$runtimeKeepaliveCounter', #endif ], - $invokeEntryPoint: {{{ asyncIf(ASYNCIFY == 2) }}} (ptr, arg) => { + $invokeEntryPoint: {{{ asyncIf(ASYNCIFY == 2) }}}(ptr, arg) => { #if PTHREADS_DEBUG dbg(`invokeEntryPoint: ${ptrToString(ptr)}`); #endif diff --git a/src/library_wasmfs_opfs.js b/src/library_wasmfs_opfs.js index 00f71e09cbf65..4dd7598226298 100644 --- a/src/library_wasmfs_opfs.js +++ b/src/library_wasmfs_opfs.js @@ -319,11 +319,11 @@ addToLibrary({ _wasmfs_opfs_read_access__i53abi: true, _wasmfs_opfs_read_access__deps: ['$wasmfsOPFSAccessHandles'], - _wasmfs_opfs_read_access: {{{ asyncIf(!PTHREADS) }}} function(accessID, bufPtr, len, pos) { + _wasmfs_opfs_read_access: {{{ asyncIf(!PTHREADS) }}}function(accessID, bufPtr, len, pos) { let accessHandle = wasmfsOPFSAccessHandles.get(accessID); let data = HEAPU8.subarray(bufPtr, bufPtr + len); try { - return {{{ awaitIf(!PTHREADS) }}} accessHandle.read(data, {at: pos}); + return {{{ awaitIf(!PTHREADS) }}}accessHandle.read(data, {at: pos}); } catch (e) { if (e.name == "TypeError") { return -{{{ cDefs.EINVAL }}}; @@ -367,11 +367,11 @@ addToLibrary({ _wasmfs_opfs_write_access__i53abi: true, _wasmfs_opfs_write_access__deps: ['$wasmfsOPFSAccessHandles'], - _wasmfs_opfs_write_access: {{{ asyncIf(!PTHREADS) }}} function(accessID, bufPtr, len, pos) { + _wasmfs_opfs_write_access: {{{ asyncIf(!PTHREADS) }}}function(accessID, bufPtr, len, pos) { let accessHandle = wasmfsOPFSAccessHandles.get(accessID); let data = HEAPU8.subarray(bufPtr, bufPtr + len); try { - return {{{ awaitIf(!PTHREADS) }}} accessHandle.write(data, {at: pos}); + return {{{ awaitIf(!PTHREADS) }}}accessHandle.write(data, {at: pos}); } catch (e) { if (e.name == "TypeError") { return -{{{ cDefs.EINVAL }}}; diff --git a/src/parseTools.mjs b/src/parseTools.mjs index 375b4bdae45c6..509ff01727b44 100644 --- a/src/parseTools.mjs +++ b/src/parseTools.mjs @@ -972,11 +972,11 @@ function to64(x) { } function asyncIf(condition) { - return condition ? 'async' : ''; + return condition ? 'async ' : ''; } function awaitIf(condition) { - return condition ? 'await' : ''; + return condition ? 'await ' : ''; } // Adds a call to runtimeKeepalivePush, if needed by the current build diff --git a/src/postamble.js b/src/postamble.js index 390ccd5388691..b40dc8992f5f7 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -36,9 +36,9 @@ var mainArgs = undefined; #if HAS_MAIN #if MAIN_READS_PARAMS -{{{ asyncIf(ASYNCIFY == 2) }}} function callMain(args = []) { +{{{ asyncIf(ASYNCIFY == 2) }}}function callMain(args = []) { #else -{{{ asyncIf(ASYNCIFY == 2) }}} function callMain() { +{{{ asyncIf(ASYNCIFY == 2) }}}function callMain() { #endif #if ASSERTIONS assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on Module["onRuntimeInitialized"])'); diff --git a/src/preamble.js b/src/preamble.js index 2e91449ac76fc..7ba3754e88051 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -921,7 +921,7 @@ function getWasmImports() { // Create the wasm instance. // Receives the wasm imports, returns the exports. -{{{ asyncIf(WASM_ASYNC_COMPILATION) }}} function createWasm() { +{{{ asyncIf(WASM_ASYNC_COMPILATION) }}}function createWasm() { // Load the wasm module and create an instance of using native support in the JS engine. // handle a generated wasm instance, receiving its exports and // performing other necessary setup diff --git a/src/runtime_pthread.js b/src/runtime_pthread.js index b9563279b7ba3..484ecb59050dd 100644 --- a/src/runtime_pthread.js +++ b/src/runtime_pthread.js @@ -66,7 +66,7 @@ if (ENVIRONMENT_IS_PTHREAD) { // notified about them. self.onunhandledrejection = (e) => { throw e.reason || e; }; - {{{ asyncIf(ASYNCIFY == 2) }}} function handleMessage(e) { + {{{ asyncIf(ASYNCIFY == 2) }}}function handleMessage(e) { try { var msgData = e['data']; //dbg('msgData: ' + Object.keys(msgData)); @@ -177,7 +177,7 @@ if (ENVIRONMENT_IS_PTHREAD) { } try { - {{{ awaitIf(ASYNCIFY == 2) }}} invokeEntryPoint(msgData.start_routine, msgData.arg); + {{{ awaitIf(ASYNCIFY == 2) }}}invokeEntryPoint(msgData.start_routine, msgData.arg); } catch(ex) { if (ex != 'unwind') { // The pthread "crashed". Do not call `_emscripten_thread_exit` (which diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index e904f31f54481..5b5e77051524d 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -53888 +53887 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index a66da51014b62..85517970c8c6c 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -29087 +29086 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index aee5ffc51afd6..be31bd8016b9c 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -52671 +52670 From e1be139f77337fc78d5db6aac79da0c98a175ab5 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Thu, 19 Dec 2024 15:44:32 -0800 Subject: [PATCH 125/132] Disable test_fs_open_no_permissions under nodefs on Windows (#23238) --- test/test_core.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/test_core.py b/test/test_core.py index 243b6d202babd..bf58fca067ac5 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5866,7 +5866,10 @@ def test_fs_readdir_ino_matches_stat_ino(self): self.do_runf('fs/test_fs_readdir_ino_matches_stat_ino.c', 'success') @also_with_nodefs_both + @crossplatform def test_fs_open_no_permissions(self): + if ('-DNODEFS' in self.emcc_args or '-DNODERAWFS' in self.emcc_args) and WINDOWS: + self.skipTest('fs_open_no_permissions fails on windows') self.do_runf('fs/test_fs_open_no_permissions.c', 'success') @also_with_nodefs_both From 89f7c26f5616d455fa8219f4940d933d638984d9 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 19 Dec 2024 17:01:25 -0800 Subject: [PATCH 126/132] Remove test_export_es6_allows_export_in_post_js. NFC (#23240) This test was added in #13937. Here we are testing something that we actually decided we did not want to support. Specifically in #13894 we decided that `--extern-post-js` was the place to allow this. More importantly the resulting JS module simple doesn't work because in `MODULARIZE` mode the code from `--post-js` does not end up at the top level but instead inside a factory function. Note that this test does not try to exectute the resulting JS. If you try to execute it you get `SyntaxError: Unexpected token 'export'`. Since we don't support it I think its best to remove this test. I'm also working on a change to move the modularization code before acorn and closure, and with that change this won't even compile (because the modularization process puts all the code inside and inner scope). --- test/export_module.js | 5 ----- test/test_other.py | 5 ----- 2 files changed, 10 deletions(-) delete mode 100644 test/export_module.js diff --git a/test/export_module.js b/test/export_module.js deleted file mode 100644 index 8829a7a359411..0000000000000 --- a/test/export_module.js +++ /dev/null @@ -1,5 +0,0 @@ -function doNothing() { - return false; -} - -export {doNothing}; diff --git a/test/test_other.py b/test/test_other.py index 4a9b63b498d1d..036a0709b5ea3 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -425,11 +425,6 @@ def test_export_es6_node_requires_import_meta(self): '-sENVIRONMENT=node', '-sEXPORT_ES6', '-sUSE_ES6_IMPORT_META=0']) self.assertContained('EXPORT_ES6 and ENVIRONMENT=*node* requires USE_ES6_IMPORT_META to be set', err) - def test_export_es6_allows_export_in_post_js(self): - self.run_process([EMCC, test_file('hello_world.c'), '-O3', '-sEXPORT_ES6', '--post-js', test_file('export_module.js')]) - src = read_file('a.out.js') - self.assertContained('export{doNothing};', src) - @parameterized({ '': (False,), 'package_json': (True,), From 3d4df5b73be7ca25ef78b45bce98c7c2eed34fcd Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 19 Dec 2024 17:52:05 -0800 Subject: [PATCH 127/132] Disable test_fcntl_open under windows + noderawfs. NFC (#23241) --- test/test_core.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/test_core.py b/test/test_core.py index bf58fca067ac5..6846074f2dfa2 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5544,7 +5544,10 @@ def test_fcntl(self): self.do_run_in_out_file_test('fcntl/test_fcntl.c') @also_with_nodefs_both + @crossplatform def test_fcntl_open(self): + if '-DNODERAWFS' in self.emcc_args and WINDOWS: + self.skipTest('currently failing under windows and noderawfs') self.do_run_in_out_file_test('fcntl/test_fcntl_open.c') @also_with_wasm_bigint From 06f343dedb818a81dc8bd4f865ceb9d51880a3e6 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Fri, 20 Dec 2024 13:11:08 -0800 Subject: [PATCH 128/132] Fix Sanitizer failures in FS tests (#23243) * Add a mode parameter to the open() call in test_fs_enotdir to avoid reading the uninitialized parameter when using O_CREAT * Add a call to closedir pair the call to fdopendir in in test_fs_readdir_ino_matches_stat_ino, which allows the implementation to free the underlying stream and make LSan happy. --- test/fs/test_fs_enotdir.c | 2 +- test/fs/test_fs_readdir_ino_matches_stat_ino.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/fs/test_fs_enotdir.c b/test/fs/test_fs_enotdir.c index e221ed8e59304..0e776a732a248 100644 --- a/test/fs/test_fs_enotdir.c +++ b/test/fs/test_fs_enotdir.c @@ -17,7 +17,7 @@ int main() { assert(errno == ENOTDIR); } { - assert(open("./does-not-exist/", O_CREAT) == -1); + assert(open("./does-not-exist/", O_CREAT, 0777) == -1); assert(errno == EISDIR); } printf("success\n"); diff --git a/test/fs/test_fs_readdir_ino_matches_stat_ino.c b/test/fs/test_fs_readdir_ino_matches_stat_ino.c index 68e1f1da4e55d..3d231eb7a60e7 100644 --- a/test/fs/test_fs_readdir_ino_matches_stat_ino.c +++ b/test/fs/test_fs_readdir_ino_matches_stat_ino.c @@ -58,5 +58,6 @@ int main() { assert(a_ino == sta.st_ino); assert(b_ino == stb.st_ino); printf("success\n"); + closedir(dirp); return 0; } From 4cbcb262fa917fade59d291d2c85514c7a798c17 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Fri, 20 Dec 2024 13:56:19 -0800 Subject: [PATCH 129/132] Disable test_fcntl_open on MacOS (#23244) It was disabled on Windows in #23241 but fails on MacOS too. --------- Co-authored-by: Alon Zakai --- test/test_core.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_core.py b/test/test_core.py index 6846074f2dfa2..8075a42ade9bd 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -19,7 +19,7 @@ from tools.shared import PIPE from tools.shared import EMCC, EMAR, FILE_PACKAGER -from tools.utils import WINDOWS, MACOS, write_file, delete_file +from tools.utils import WINDOWS, MACOS, LINUX, write_file, delete_file from tools import shared, building, config, utils, webassembly import common from common import RunnerCore, path_from_root, requires_native_clang, test_file, create_file @@ -5546,8 +5546,8 @@ def test_fcntl(self): @also_with_nodefs_both @crossplatform def test_fcntl_open(self): - if '-DNODERAWFS' in self.emcc_args and WINDOWS: - self.skipTest('currently failing under windows and noderawfs') + if '-DNODERAWFS' in self.emcc_args and not LINUX: + self.skipTest('noderawfs fails here under non-linux') self.do_run_in_out_file_test('fcntl/test_fcntl_open.c') @also_with_wasm_bigint From 74d95fb1bb0a0748a74268e622779036f25e7a3a Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Fri, 20 Dec 2024 15:49:25 -0800 Subject: [PATCH 130/132] Add deterministic prefix in Library.get_flags() (NFC) (#23225) This factors duplicate routines to add deterministic prefix paths out to `Library.get_cflags()`. Suggested in https://github.com/emscripten-core/emscripten/pull/23222#discussion_r1891063416. --- tools/system_libs.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/tools/system_libs.py b/tools/system_libs.py index 3b01a85fbf651..ef896f6ec96ac 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -471,14 +471,9 @@ def get_files(self): def generate_ninja(self, build_dir, libname): ensure_sysroot() utils.safe_ensure_dirs(build_dir) + self.build_dir = build_dir cflags = self.get_cflags() - if self.deterministic_paths: - source_dir = utils.path_from_root() - relative_source_dir = os.path.relpath(source_dir, build_dir) - cflags += [f'-ffile-prefix-map={source_dir}={DETERMINISITIC_PREFIX}', - f'-ffile-prefix-map={relative_source_dir}={DETERMINISITIC_PREFIX}', - f'-fdebug-compilation-dir={DETERMINISITIC_PREFIX}'] asflags = get_base_cflags(preprocess=False) input_files = self.get_files() ninja_file = os.path.join(build_dir, 'build.ninja') @@ -492,17 +487,11 @@ def build_objects(self, build_dir): with the `cflags` returned by `self.get_cflags()`. """ batch_inputs = int(os.environ.get('EMCC_BATCH_BUILD', '1')) + self.build_dir = build_dir batches = {} commands = [] objects = set() cflags = self.get_cflags() - if self.deterministic_paths: - source_dir = utils.path_from_root() - if batch_inputs: - relative_source_dir = os.path.relpath(source_dir, build_dir) - cflags += [f'-ffile-prefix-map={relative_source_dir}={DETERMINISITIC_PREFIX}'] - cflags += [f'-ffile-prefix-map={source_dir}={DETERMINISITIC_PREFIX}', - f'-fdebug-compilation-dir={DETERMINISITIC_PREFIX}'] case_insensitive = is_case_insensitive(build_dir) for src in self.get_files(): ext = shared.suffix(src) @@ -611,6 +600,12 @@ def get_cflags(self): if self.includes: cflags += ['-I' + utils.path_from_root(i) for i in self._inherit_list('includes')] + if self.deterministic_paths: + source_dir = utils.path_from_root() + relative_source_dir = os.path.relpath(source_dir, self.build_dir) + cflags += [f'-ffile-prefix-map={relative_source_dir}={DETERMINISITIC_PREFIX}'] + cflags += [f'-ffile-prefix-map={source_dir}={DETERMINISITIC_PREFIX}', + f'-fdebug-compilation-dir={DETERMINISITIC_PREFIX}'] return cflags def get_base_name_prefix(self): From 1444a9391ae9dd0c7df3b2263f16247081232e74 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Fri, 20 Dec 2024 20:55:54 -0800 Subject: [PATCH 131/132] Update compiler-rt to LLVM 19.1.4 (#22937) All changes are upstream changes except for a few unused variable warning fixes and code size rebaselines. This PR was created by running https://github.com/emscripten-core/emscripten/blob/main/system/lib/update_compiler_rt.py script. --- ChangeLog.md | 1 + .../include/sanitizer/allocator_interface.h | 15 +- .../include/sanitizer/linux_syscall_hooks.h | 16 +- .../include/sanitizer/nsan_interface.h | 75 +++++ .../compiler-rt/lib/asan/asan_allocator.cpp | 10 +- .../lib/asan/asan_descriptions.cpp | 8 +- .../lib/compiler-rt/lib/asan/asan_fuchsia.cpp | 2 - .../lib/compiler-rt/lib/asan/asan_globals.cpp | 8 +- .../compiler-rt/lib/asan/asan_globals_win.cpp | 8 +- .../lib/asan/asan_interceptors.cpp | 44 ++- .../lib/compiler-rt/lib/asan/asan_internal.h | 1 - .../lib/compiler-rt/lib/asan/asan_linux.cpp | 11 +- system/lib/compiler-rt/lib/asan/asan_mac.cpp | 8 +- .../lib/asan/asan_malloc_linux.cpp | 4 +- .../lib/compiler-rt/lib/asan/asan_mapping.h | 7 +- .../lib/compiler-rt/lib/asan/asan_preinit.cpp | 10 +- .../lib/asan/asan_premap_shadow.cpp | 3 +- .../lib/compiler-rt/lib/asan/asan_report.cpp | 33 +- system/lib/compiler-rt/lib/asan/asan_rtl.cpp | 7 +- .../lib/asan/asan_suppressions.cpp | 5 +- .../lib/compiler-rt/lib/asan/asan_thread.cpp | 15 +- system/lib/compiler-rt/lib/asan/asan_win.cpp | 5 +- .../lib/asan/asan_win_dll_thunk.cpp | 2 +- system/lib/compiler-rt/lib/builtins/atomic.c | 14 +- system/lib/compiler-rt/lib/builtins/divtc3.c | 2 +- .../compiler-rt/lib/builtins/extendbfsf2.c | 13 + .../compiler-rt/lib/builtins/fp_add_impl.inc | 2 +- .../lib/compiler-rt/lib/builtins/fp_extend.h | 26 +- .../lib/builtins/fp_fixint_impl.inc | 4 +- system/lib/compiler-rt/lib/builtins/fp_lib.h | 17 +- .../lib/compiler-rt/lib/builtins/int_math.h | 13 +- .../lib/compiler-rt/lib/builtins/int_types.h | 4 +- system/lib/compiler-rt/lib/builtins/multc3.c | 2 +- .../lib/builtins/os_version_check.c | 4 +- .../lib/builtins/trampoline_setup.c | 42 +++ .../lib/interception/interception.h | 16 +- .../lib/interception/interception_linux.h | 16 +- .../lib/interception/interception_win.cpp | 13 +- .../compiler-rt/lib/lsan/lsan_allocator.cpp | 2 +- .../lib/compiler-rt/lib/lsan/lsan_common.cpp | 2 +- .../lib/lsan/lsan_common_linux.cpp | 2 +- .../lib/lsan/lsan_interceptors.cpp | 5 +- .../lib/compiler-rt/lib/lsan/lsan_preinit.cpp | 8 +- .../lib/compiler-rt/lib/lsan/lsan_thread.cpp | 6 +- .../lib/sanitizer_common/sancov_flags.cpp | 6 +- .../sanitizer_common/sanitizer_allocator.cpp | 2 +- .../sanitizer_allocator_interface.h | 2 + .../sanitizer_allocator_primary32.h | 2 +- .../sanitizer_allocator_primary64.h | 9 +- .../lib/sanitizer_common/sanitizer_asm.h | 14 +- .../lib/sanitizer_common/sanitizer_atomic.h | 14 +- .../sanitizer_common/sanitizer_atomic_clang.h | 85 +++-- .../sanitizer_atomic_clang_mips.h | 117 ------- .../sanitizer_atomic_clang_other.h | 85 ----- .../sanitizer_atomic_clang_x86.h | 113 ------- .../sanitizer_common/sanitizer_atomic_msvc.h | 8 +- .../sanitizer_common/sanitizer_bitvector.h | 8 +- .../lib/sanitizer_common/sanitizer_common.cpp | 15 +- .../lib/sanitizer_common/sanitizer_common.h | 32 +- .../sanitizer_common_interceptors.inc | 318 +++++------------- .../sanitizer_common_interface.inc | 1 + .../sanitizer_common_libcdep.cpp | 6 +- .../sanitizer_common_syscalls.inc | 35 ++ .../sanitizer_coverage_libcdep_new.cpp | 3 +- .../lib/sanitizer_common/sanitizer_file.cpp | 4 +- .../sanitizer_common/sanitizer_fuchsia.cpp | 17 +- .../lib/sanitizer_common/sanitizer_hash.h | 2 +- .../sanitizer_internal_defs.h | 20 +- .../sanitizer_common/sanitizer_libignore.cpp | 4 +- .../lib/sanitizer_common/sanitizer_linux.cpp | 300 +++++++++++++++-- .../sanitizer_linux_libcdep.cpp | 34 +- .../lib/sanitizer_common/sanitizer_mac.cpp | 8 +- .../lib/sanitizer_common/sanitizer_mutex.cpp | 6 +- .../sanitizer_placement_new.h | 4 +- .../lib/sanitizer_common/sanitizer_platform.h | 6 +- .../sanitizer_platform_interceptors.h | 5 +- .../sanitizer_platform_limits_freebsd.cpp | 2 + .../sanitizer_platform_limits_freebsd.h | 22 +- .../lib/sanitizer_common/sanitizer_posix.cpp | 12 +- .../lib/sanitizer_common/sanitizer_posix.h | 28 +- .../sanitizer_posix_libcdep.cpp | 33 +- .../lib/sanitizer_common/sanitizer_printf.cpp | 2 +- .../sanitizer_procmaps_bsd.cpp | 36 +- .../sanitizer_procmaps_common.cpp | 2 +- .../sanitizer_procmaps_solaris.cpp | 4 + .../lib/sanitizer_common/sanitizer_ptrauth.h | 46 +-- .../sanitizer_stacktrace_libcdep.cpp | 8 +- .../sanitizer_stacktrace_printer.cpp | 16 +- .../sanitizer_stacktrace_printer.h | 16 +- .../sanitizer_stacktrace_sparc.cpp | 11 +- .../sanitizer_stoptheworld_linux_libcdep.cpp | 4 +- .../sanitizer_stoptheworld_netbsd_libcdep.cpp | 4 +- .../sanitizer_suppressions.cpp | 2 +- .../sanitizer_symbolizer_markup.cpp | 10 +- .../sanitizer_symbolizer_markup_constants.h | 6 +- .../sanitizer_symbolizer_report.cpp | 4 + .../sanitizer_tls_get_addr.cpp | 15 +- .../sanitizer_common/sanitizer_unwind_win.cpp | 7 + .../lib/sanitizer_common/sanitizer_win.cpp | 25 +- .../lib/compiler-rt/lib/ubsan/ubsan_diag.cpp | 2 +- .../compiler-rt/lib/ubsan/ubsan_handlers.cpp | 27 +- .../compiler-rt/lib/ubsan/ubsan_handlers.h | 1 + .../ubsan/ubsan_init_standalone_preinit.cpp | 4 +- .../lib/ubsan/ubsan_signals_standalone.cpp | 5 + .../lib/ubsan/ubsan_type_hash_itanium.cpp | 2 +- system/lib/compiler-rt/readme.txt | 6 +- .../codesize/test_codesize_cxx_ctors1.size | 2 +- .../codesize/test_codesize_cxx_ctors2.size | 2 +- .../codesize/test_codesize_cxx_except.size | 2 +- .../test_codesize_cxx_except_wasm.size | 2 +- .../test_codesize_cxx_except_wasm_exnref.size | 2 +- .../other/codesize/test_codesize_cxx_lto.size | 2 +- .../codesize/test_codesize_cxx_mangle.size | 2 +- .../codesize/test_codesize_cxx_noexcept.size | 2 +- .../codesize/test_codesize_cxx_wasmfs.size | 2 +- 115 files changed, 1190 insertions(+), 986 deletions(-) create mode 100644 system/lib/compiler-rt/include/sanitizer/nsan_interface.h create mode 100644 system/lib/compiler-rt/lib/builtins/extendbfsf2.c delete mode 100644 system/lib/compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang_mips.h delete mode 100644 system/lib/compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang_other.h delete mode 100644 system/lib/compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang_x86.h diff --git a/ChangeLog.md b/ChangeLog.md index 7db38dcfc8072..2c678e0dcb449 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -20,6 +20,7 @@ See docs/process.md for more on how version tagging works. 3.1.75 (in development) ----------------------- +- compiler-rt was updated to LLVM 19.1.4. (#22937) - The Wasm nontrapping-fptoint feature has been enabled by default. clang will generate nontrapping (saturating) float-to-int conversion instructions for C typecasts. This should have no effect on programs that do not have diff --git a/system/lib/compiler-rt/include/sanitizer/allocator_interface.h b/system/lib/compiler-rt/include/sanitizer/allocator_interface.h index a792e9f0136e6..1696a92681e35 100644 --- a/system/lib/compiler-rt/include/sanitizer/allocator_interface.h +++ b/system/lib/compiler-rt/include/sanitizer/allocator_interface.h @@ -62,13 +62,20 @@ size_t SANITIZER_CDECL __sanitizer_get_free_bytes(void); size_t SANITIZER_CDECL __sanitizer_get_unmapped_bytes(void); /* Malloc hooks that may be optionally provided by user. - __sanitizer_malloc_hook(ptr, size) is called immediately after - allocation of "size" bytes, which returned "ptr". - __sanitizer_free_hook(ptr) is called immediately before - deallocation of "ptr". */ + - __sanitizer_malloc_hook(ptr, size) is called immediately after allocation + of "size" bytes, which returned "ptr". + - __sanitizer_free_hook(ptr) is called immediately before deallocation of + "ptr". + - __sanitizer_ignore_free_hook(ptr) is called immediately before deallocation + of "ptr", and if it returns a non-zero value, the deallocation of "ptr" + will not take place. This allows software to make free a no-op until it + calls free() again in the same pointer at a later time. Hint: read this as + "ignore the free" rather than "ignore the hook". +*/ void SANITIZER_CDECL __sanitizer_malloc_hook(const volatile void *ptr, size_t size); void SANITIZER_CDECL __sanitizer_free_hook(const volatile void *ptr); +int SANITIZER_CDECL __sanitizer_ignore_free_hook(const volatile void *ptr); /* Installs a pair of hooks for malloc/free. Several (currently, 5) hook pairs may be installed, they are executed diff --git a/system/lib/compiler-rt/include/sanitizer/linux_syscall_hooks.h b/system/lib/compiler-rt/include/sanitizer/linux_syscall_hooks.h index 3f3f1e78dfb85..5f262455cb946 100644 --- a/system/lib/compiler-rt/include/sanitizer/linux_syscall_hooks.h +++ b/system/lib/compiler-rt/include/sanitizer/linux_syscall_hooks.h @@ -1856,6 +1856,15 @@ __sanitizer_syscall_pre_impl_sigaltstack((long)ss, (long)oss) #define __sanitizer_syscall_post_sigaltstack(res, ss, oss) \ __sanitizer_syscall_post_impl_sigaltstack(res, (long)ss, (long)oss) +#define __sanitizer_syscall_pre_futex(uaddr, futex_op, val, timeout, uaddr2, \ + val3) \ + __sanitizer_syscall_pre_impl_futex((long)uaddr, (long)futex_op, (long)val, \ + (long)timeout, (long)uaddr2, (long)val3) +#define __sanitizer_syscall_post_futex(res, uaddr, futex_op, val, timeout, \ + uaddr2, val3) \ + __sanitizer_syscall_post_impl_futex(res, (long)uaddr, (long)futex_op, \ + (long)val, (long)timeout, (long)uaddr2, \ + (long)val3) // And now a few syscalls we don't handle yet. #define __sanitizer_syscall_pre_afs_syscall(...) @@ -1875,7 +1884,6 @@ #define __sanitizer_syscall_pre_fchown32(...) #define __sanitizer_syscall_pre_ftime(...) #define __sanitizer_syscall_pre_ftruncate64(...) -#define __sanitizer_syscall_pre_futex(...) #define __sanitizer_syscall_pre_getegid32(...) #define __sanitizer_syscall_pre_geteuid32(...) #define __sanitizer_syscall_pre_getgid32(...) @@ -1954,7 +1962,6 @@ #define __sanitizer_syscall_post_fchown32(res, ...) #define __sanitizer_syscall_post_ftime(res, ...) #define __sanitizer_syscall_post_ftruncate64(res, ...) -#define __sanitizer_syscall_post_futex(res, ...) #define __sanitizer_syscall_post_getegid32(res, ...) #define __sanitizer_syscall_post_geteuid32(res, ...) #define __sanitizer_syscall_post_getgid32(res, ...) @@ -3093,6 +3100,11 @@ void __sanitizer_syscall_post_impl_rt_sigaction(long res, long signum, long act, long oldact, long sz); void __sanitizer_syscall_pre_impl_sigaltstack(long ss, long oss); void __sanitizer_syscall_post_impl_sigaltstack(long res, long ss, long oss); +void __sanitizer_syscall_pre_impl_futex(long uaddr, long futex_op, long val, + long timeout, long uaddr2, long val3); +void __sanitizer_syscall_post_impl_futex(long res, long uaddr, long futex_op, + long val, long timeout, long uaddr2, + long val3); #ifdef __cplusplus } // extern "C" #endif diff --git a/system/lib/compiler-rt/include/sanitizer/nsan_interface.h b/system/lib/compiler-rt/include/sanitizer/nsan_interface.h new file mode 100644 index 0000000000000..057ca0473bb3c --- /dev/null +++ b/system/lib/compiler-rt/include/sanitizer/nsan_interface.h @@ -0,0 +1,75 @@ +//===-- sanitizer/nsan_interface.h ------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Public interface for nsan. +// +//===----------------------------------------------------------------------===// +#ifndef SANITIZER_NSAN_INTERFACE_H +#define SANITIZER_NSAN_INTERFACE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/// User-provided default option settings. +/// +/// You can provide your own implementation of this function to return a string +/// containing NSan runtime options (for example, +/// verbosity=1:halt_on_error=0). +/// +/// \returns Default options string. +const char *__nsan_default_options(void); + +// Dumps nsan shadow data for a block of `size_bytes` bytes of application +// memory at location `addr`. +// +// Each line contains application address, shadow types, then values. +// Unknown types are shown as `__`, while known values are shown as +// `f`, `d`, `l` for float, double, and long double respectively. Position is +// shown as a single hex digit. The shadow value itself appears on the line that +// contains the first byte of the value. +// FIXME: Show both shadow and application value. +// +// Example: `__nsan_dump_shadow_mem(addr, 32, 8, 0)` might print: +// +// 0x0add7359: __ f0 f1 f2 f3 __ __ __ (42.000) +// 0x0add7361: __ d1 d2 d3 d4 d5 d6 d7 +// 0x0add7369: d8 f0 f1 f2 f3 __ __ f2 (-1.000) (12.5) +// 0x0add7371: f3 __ __ __ __ __ __ __ +// +// This means that there is: +// - a shadow double for the float at address 0x0add7360, with value 42; +// - a shadow float128 for the double at address 0x0add7362, with value -1; +// - a shadow double for the float at address 0x0add736a, with value 12.5; +// There was also a shadow double for the float at address 0x0add736e, but bytes +// f0 and f1 were overwritten by one or several stores, so that the shadow value +// is no longer valid. +// The argument `reserved` can be any value. Its true value is provided by the +// instrumentation. +void __nsan_dump_shadow_mem(const char *addr, size_t size_bytes, + size_t bytes_per_line, size_t reserved); + +// Explicitly dumps a value. +// FIXME: vector versions ? +void __nsan_dump_float(float value); +void __nsan_dump_double(double value); +void __nsan_dump_longdouble(long double value); + +// Explicitly checks a value. +// FIXME: vector versions ? +void __nsan_check_float(float value); +void __nsan_check_double(double value); +void __nsan_check_longdouble(long double value); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // SANITIZER_NSAN_INTERFACE_H diff --git a/system/lib/compiler-rt/lib/asan/asan_allocator.cpp b/system/lib/compiler-rt/lib/asan/asan_allocator.cpp index 22dcf6132707b..9e66f77217ec6 100644 --- a/system/lib/compiler-rt/lib/asan/asan_allocator.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_allocator.cpp @@ -717,7 +717,15 @@ struct Allocator { return; } - RunFreeHooks(ptr); + if (RunFreeHooks(ptr)) { + // Someone used __sanitizer_ignore_free_hook() and decided that they + // didn't want the memory to __sanitizer_ignore_free_hook freed right now. + // When they call free() on this pointer again at a later time, we should + // ignore the alloc-type mismatch and allow them to deallocate the pointer + // through free(), rather than the initial alloc type. + m->alloc_type = FROM_MALLOC; + return; + } // Must mark the chunk as quarantined before any changes to its metadata. // Do not quarantine given chunk if we failed to set CHUNK_QUARANTINE flag. diff --git a/system/lib/compiler-rt/lib/asan/asan_descriptions.cpp b/system/lib/compiler-rt/lib/asan/asan_descriptions.cpp index ef6f3e0a096f8..1c2f20a76343b 100644 --- a/system/lib/compiler-rt/lib/asan/asan_descriptions.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_descriptions.cpp @@ -245,11 +245,11 @@ static void PrintAccessAndVarIntersection(const StackVarDescr &var, uptr addr, InternalScopedString str; str.AppendF(" [%zd, %zd)", var.beg, var_end); // Render variable name. - str.AppendF(" '"); + str.Append(" '"); for (uptr i = 0; i < var.name_len; ++i) { str.AppendF("%c", var.name_pos[i]); } - str.AppendF("'"); + str.Append("'"); if (var.line > 0) { str.AppendF(" (line %zd)", var.line); } @@ -260,7 +260,7 @@ static void PrintAccessAndVarIntersection(const StackVarDescr &var, uptr addr, str.AppendF("%s <== Memory access at offset %zd %s this variable%s\n", d.Location(), addr, pos_descr, d.Default()); } else { - str.AppendF("\n"); + str.Append("\n"); } Printf("%s", str.data()); } @@ -292,7 +292,7 @@ static void DescribeAddressRelativeToGlobal(uptr addr, uptr access_size, str.AppendF(" global variable '%s' defined in '", MaybeDemangleGlobalName(g.name)); PrintGlobalLocation(&str, g, /*print_module_name=*/false); - str.AppendF("' (0x%zx) of size %zu\n", g.beg, g.size); + str.AppendF("' (%p) of size %zu\n", (void *)g.beg, g.size); str.Append(d.Default()); PrintGlobalNameIfASCII(&str, g); Printf("%s", str.data()); diff --git a/system/lib/compiler-rt/lib/asan/asan_fuchsia.cpp b/system/lib/compiler-rt/lib/asan/asan_fuchsia.cpp index 12625e9d75833..dbc4342e83388 100644 --- a/system/lib/compiler-rt/lib/asan/asan_fuchsia.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_fuchsia.cpp @@ -57,8 +57,6 @@ void AsanCheckDynamicRTPrereqs() {} void AsanCheckIncompatibleRT() {} void InitializeAsanInterceptors() {} -void *AsanDoesNotSupportStaticLinkage() { return nullptr; } - void InitializePlatformExceptionHandlers() {} void AsanOnDeadlySignal(int signo, void *siginfo, void *context) { UNIMPLEMENTED(); diff --git a/system/lib/compiler-rt/lib/asan/asan_globals.cpp b/system/lib/compiler-rt/lib/asan/asan_globals.cpp index 083bfeed99945..17289937b4293 100644 --- a/system/lib/compiler-rt/lib/asan/asan_globals.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_globals.cpp @@ -345,8 +345,8 @@ void __asan_unregister_image_globals(uptr *flag) { } void __asan_register_elf_globals(uptr *flag, void *start, void *stop) { - if (*flag) return; - if (!start) return; + if (*flag || start == stop) + return; CHECK_EQ(0, ((uptr)stop - (uptr)start) % sizeof(__asan_global)); __asan_global *globals_start = (__asan_global*)start; __asan_global *globals_stop = (__asan_global*)stop; @@ -355,8 +355,8 @@ void __asan_register_elf_globals(uptr *flag, void *start, void *stop) { } void __asan_unregister_elf_globals(uptr *flag, void *start, void *stop) { - if (!*flag) return; - if (!start) return; + if (!*flag || start == stop) + return; CHECK_EQ(0, ((uptr)stop - (uptr)start) % sizeof(__asan_global)); __asan_global *globals_start = (__asan_global*)start; __asan_global *globals_stop = (__asan_global*)stop; diff --git a/system/lib/compiler-rt/lib/asan/asan_globals_win.cpp b/system/lib/compiler-rt/lib/asan/asan_globals_win.cpp index 19af88ab12b40..9442cc35d5ab7 100644 --- a/system/lib/compiler-rt/lib/asan/asan_globals_win.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_globals_win.cpp @@ -17,10 +17,10 @@ namespace __asan { #pragma section(".ASAN$GA", read, write) #pragma section(".ASAN$GZ", read, write) -extern "C" __declspec(allocate(".ASAN$GA")) - ALIGNED(sizeof(__asan_global)) __asan_global __asan_globals_start = {}; -extern "C" __declspec(allocate(".ASAN$GZ")) - ALIGNED(sizeof(__asan_global)) __asan_global __asan_globals_end = {}; +extern "C" alignas(sizeof(__asan_global)) + __declspec(allocate(".ASAN$GA")) __asan_global __asan_globals_start = {}; +extern "C" alignas(sizeof(__asan_global)) + __declspec(allocate(".ASAN$GZ")) __asan_global __asan_globals_end = {}; #pragma comment(linker, "/merge:.ASAN=.data") static void call_on_globals(void (*hook)(__asan_global *, uptr)) { diff --git a/system/lib/compiler-rt/lib/asan/asan_interceptors.cpp b/system/lib/compiler-rt/lib/asan/asan_interceptors.cpp index 4d6d395616b7a..194c506a3320d 100644 --- a/system/lib/compiler-rt/lib/asan/asan_interceptors.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_interceptors.cpp @@ -333,7 +333,7 @@ INTERCEPTOR(int, pthread_timedjoin_np, void *thread, void **ret, } # endif -DEFINE_REAL_PTHREAD_FUNCTIONS +DEFINE_INTERNAL_PTHREAD_FUNCTIONS #endif // ASAN_INTERCEPT_PTHREAD_CREATE #if ASAN_INTERCEPT_SWAPCONTEXT @@ -352,8 +352,16 @@ static void ClearShadowMemoryForContextStack(uptr stack, uptr ssize) { PoisonShadow(bottom, ssize, 0); } +// Since Solaris 10/SPARC, ucp->uc_stack.ss_sp refers to the stack base address +// as on other targets. For binary compatibility, the new version uses a +// different external name, so we intercept that. +# if SANITIZER_SOLARIS && defined(__sparc__) +INTERCEPTOR(void, __makecontext_v2, struct ucontext_t *ucp, void (*func)(), + int argc, ...) { +# else INTERCEPTOR(void, makecontext, struct ucontext_t *ucp, void (*func)(), int argc, ...) { +# endif va_list ap; uptr args[64]; // We don't know a better way to forward ... into REAL function. We can @@ -373,7 +381,11 @@ INTERCEPTOR(void, makecontext, struct ucontext_t *ucp, void (*func)(), int argc, ENUMERATE_ARRAY_16(0), ENUMERATE_ARRAY_16(16), ENUMERATE_ARRAY_16(32), \ ENUMERATE_ARRAY_16(48) +# if SANITIZER_SOLARIS && defined(__sparc__) + REAL(__makecontext_v2) +# else REAL(makecontext) +# endif ((struct ucontext_t *)ucp, func, argc, ENUMERATE_ARRAY_64()); # undef ENUMERATE_ARRAY_4 @@ -558,6 +570,17 @@ INTERCEPTOR(char *, strcpy, char *to, const char *from) { return REAL(strcpy)(to, from); } +// Windows doesn't always define the strdup identifier, +// and when it does it's a macro defined to either _strdup +// or _strdup_dbg, _strdup_dbg ends up calling _strdup, so +// we want to intercept that. push/pop_macro are used to avoid problems +// if this file ends up including in the future. +# if SANITIZER_WINDOWS +# pragma push_macro("strdup") +# undef strdup +# define strdup _strdup +# endif + INTERCEPTOR(char*, strdup, const char *s) { void *ctx; ASAN_INTERCEPTOR_ENTER(ctx, strdup); @@ -575,7 +598,7 @@ INTERCEPTOR(char*, strdup, const char *s) { return reinterpret_cast(new_mem); } -#if ASAN_INTERCEPT___STRDUP +# if ASAN_INTERCEPT___STRDUP INTERCEPTOR(char*, __strdup, const char *s) { void *ctx; ASAN_INTERCEPTOR_ENTER(ctx, strdup); @@ -724,7 +747,7 @@ INTERCEPTOR(int, atexit, void (*func)()) { extern "C" { extern int _pthread_atfork(void (*prepare)(), void (*parent)(), void (*child)()); -}; +} INTERCEPTOR(int, pthread_atfork, void (*prepare)(), void (*parent)(), void (*child)()) { @@ -738,8 +761,8 @@ INTERCEPTOR(int, pthread_atfork, void (*prepare)(), void (*parent)(), #endif #if ASAN_INTERCEPT_VFORK -DEFINE_REAL(int, vfork) -DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(int, vfork) +DEFINE_REAL(int, vfork,) +DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(int, vfork,) #endif // ---------------------- InitializeAsanInterceptors ---------------- {{{1 @@ -758,7 +781,7 @@ void InitializeAsanInterceptors() { ASAN_INTERCEPT_FUNC(strncat); ASAN_INTERCEPT_FUNC(strncpy); ASAN_INTERCEPT_FUNC(strdup); -#if ASAN_INTERCEPT___STRDUP +# if ASAN_INTERCEPT___STRDUP ASAN_INTERCEPT_FUNC(__strdup); #endif #if ASAN_INTERCEPT_INDEX && ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX @@ -780,7 +803,12 @@ void InitializeAsanInterceptors() { # if ASAN_INTERCEPT_SWAPCONTEXT ASAN_INTERCEPT_FUNC(swapcontext); + // See the makecontext interceptor above for an explanation. +# if SANITIZER_SOLARIS && defined(__sparc__) + ASAN_INTERCEPT_FUNC(__makecontext_v2); +# else ASAN_INTERCEPT_FUNC(makecontext); +# endif # endif # if ASAN_INTERCEPT__LONGJMP ASAN_INTERCEPT_FUNC(_longjmp); @@ -849,6 +877,10 @@ void InitializeAsanInterceptors() { VReport(1, "AddressSanitizer: libc interceptors initialized\n"); } +# if SANITIZER_WINDOWS +# pragma pop_macro("strdup") +# endif + } // namespace __asan #endif // !SANITIZER_FUCHSIA && !SANITIZER_RTEMS && !SANITIZER_EMSCRIPTEN diff --git a/system/lib/compiler-rt/lib/asan/asan_internal.h b/system/lib/compiler-rt/lib/asan/asan_internal.h index 2944ebe213b5d..06dfc4b177339 100644 --- a/system/lib/compiler-rt/lib/asan/asan_internal.h +++ b/system/lib/compiler-rt/lib/asan/asan_internal.h @@ -80,7 +80,6 @@ void ReplaceSystemMalloc(); // asan_linux.cpp / asan_mac.cpp / asan_win.cpp uptr FindDynamicShadowStart(); -void *AsanDoesNotSupportStaticLinkage(); void AsanCheckDynamicRTPrereqs(); void AsanCheckIncompatibleRT(); diff --git a/system/lib/compiler-rt/lib/asan/asan_linux.cpp b/system/lib/compiler-rt/lib/asan/asan_linux.cpp index 37d3bad1b1ec6..0b470db86748f 100644 --- a/system/lib/compiler-rt/lib/asan/asan_linux.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_linux.cpp @@ -47,15 +47,12 @@ # if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS # include -extern "C" void *_DYNAMIC; # elif SANITIZER_NETBSD # include # include -extern Elf_Dyn _DYNAMIC; # else # include # include -extern ElfW(Dyn) _DYNAMIC[]; # endif typedef enum { @@ -76,11 +73,6 @@ void InitializePlatformInterceptors() {} void InitializePlatformExceptionHandlers() {} bool IsSystemHeapAddress(uptr addr) { return false; } -void *AsanDoesNotSupportStaticLinkage() { - // This will fail to link with -static. - return &_DYNAMIC; -} - # if ASAN_PREMAP_SHADOW uptr FindPremappedShadowStart(uptr shadow_size_bytes) { uptr granularity = GetMmapGranularity(); @@ -101,7 +93,8 @@ uptr FindDynamicShadowStart() { # endif return MapDynamicShadow(shadow_size_bytes, ASAN_SHADOW_SCALE, - /*min_shadow_base_alignment*/ 0, kHighMemEnd); + /*min_shadow_base_alignment*/ 0, kHighMemEnd, + GetMmapGranularity()); } void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { diff --git a/system/lib/compiler-rt/lib/asan/asan_mac.cpp b/system/lib/compiler-rt/lib/asan/asan_mac.cpp index 1b0e9b3fe0060..bfc349223258b 100644 --- a/system/lib/compiler-rt/lib/asan/asan_mac.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_mac.cpp @@ -49,14 +49,10 @@ void InitializePlatformInterceptors() {} void InitializePlatformExceptionHandlers() {} bool IsSystemHeapAddress (uptr addr) { return false; } -// No-op. Mac does not support static linkage anyway. -void *AsanDoesNotSupportStaticLinkage() { - return 0; -} - uptr FindDynamicShadowStart() { return MapDynamicShadow(MemToShadowSize(kHighMemEnd), ASAN_SHADOW_SCALE, - /*min_shadow_base_alignment*/ 0, kHighMemEnd); + /*min_shadow_base_alignment*/ 0, kHighMemEnd, + GetMmapGranularity()); } // No-op. Mac does not support static linkage anyway. diff --git a/system/lib/compiler-rt/lib/asan/asan_malloc_linux.cpp b/system/lib/compiler-rt/lib/asan/asan_malloc_linux.cpp index 40cec4365b964..84f146d99d82d 100644 --- a/system/lib/compiler-rt/lib/asan/asan_malloc_linux.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_malloc_linux.cpp @@ -185,11 +185,11 @@ struct MallocDebugL { void* (*valloc)(uptr size); }; -ALIGNED(32) const MallocDebugK asan_malloc_dispatch_k = { +alignas(32) const MallocDebugK asan_malloc_dispatch_k = { WRAP(malloc), WRAP(free), WRAP(calloc), WRAP(realloc), WRAP(memalign), WRAP(malloc_usable_size)}; -ALIGNED(32) const MallocDebugL asan_malloc_dispatch_l = { +alignas(32) const MallocDebugL asan_malloc_dispatch_l = { WRAP(calloc), WRAP(free), WRAP(mallinfo), WRAP(malloc), WRAP(malloc_usable_size), WRAP(memalign), WRAP(posix_memalign), WRAP(pvalloc), WRAP(realloc), diff --git a/system/lib/compiler-rt/lib/asan/asan_mapping.h b/system/lib/compiler-rt/lib/asan/asan_mapping.h index 81173be01e2c4..1d0f8131338ed 100644 --- a/system/lib/compiler-rt/lib/asan/asan_mapping.h +++ b/system/lib/compiler-rt/lib/asan/asan_mapping.h @@ -72,7 +72,10 @@ // || `[0x2000000000, 0x23ffffffff]` || LowShadow || // || `[0x0000000000, 0x1fffffffff]` || LowMem || // -// Default Linux/RISCV64 Sv39 mapping: +// Default Linux/RISCV64 Sv39 mapping with SHADOW_OFFSET == 0xd55550000; +// (the exact location of SHADOW_OFFSET may vary depending the dynamic probing +// by FindDynamicShadowStart). +// // || `[0x1555550000, 0x3fffffffff]` || HighMem || // || `[0x0fffffa000, 0x1555555fff]` || HighShadow || // || `[0x0effffa000, 0x0fffff9fff]` || ShadowGap || @@ -186,7 +189,7 @@ # elif SANITIZER_FREEBSD && defined(__aarch64__) # define ASAN_SHADOW_OFFSET_CONST 0x0000800000000000 # elif SANITIZER_RISCV64 -# define ASAN_SHADOW_OFFSET_CONST 0x0000000d55550000 +# define ASAN_SHADOW_OFFSET_DYNAMIC # elif defined(__aarch64__) # define ASAN_SHADOW_OFFSET_CONST 0x0000001000000000 # elif defined(__powerpc64__) diff --git a/system/lib/compiler-rt/lib/asan/asan_preinit.cpp b/system/lib/compiler-rt/lib/asan/asan_preinit.cpp index b07556ec96f8f..23169383bb74c 100644 --- a/system/lib/compiler-rt/lib/asan/asan_preinit.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_preinit.cpp @@ -15,10 +15,8 @@ using namespace __asan; #if SANITIZER_CAN_USE_PREINIT_ARRAY - // The symbol is called __local_asan_preinit, because it's not intended to be - // exported. - // This code linked into the main executable when -fsanitize=address is in - // the link flags. It can only use exported interface functions. - __attribute__((section(".preinit_array"), used)) - void (*__local_asan_preinit)(void) = __asan_init; +// This section is linked into the main executable when -fsanitize=address is +// specified to perform initialization at a very early stage. +__attribute__((section(".preinit_array"), used)) static auto preinit = + __asan_init; #endif diff --git a/system/lib/compiler-rt/lib/asan/asan_premap_shadow.cpp b/system/lib/compiler-rt/lib/asan/asan_premap_shadow.cpp index bed2f62a22511..6e08b8f966507 100644 --- a/system/lib/compiler-rt/lib/asan/asan_premap_shadow.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_premap_shadow.cpp @@ -33,7 +33,8 @@ uptr PremapShadowSize() { // PremapShadowSize() bytes on the right of it are mapped r/o. uptr PremapShadow() { return MapDynamicShadow(PremapShadowSize(), /*mmap_alignment_scale*/ 3, - /*min_shadow_base_alignment*/ 0, kHighMemEnd); + /*min_shadow_base_alignment*/ 0, kHighMemEnd, + GetMmapGranularity()); } bool PremapShadowFailed() { diff --git a/system/lib/compiler-rt/lib/asan/asan_report.cpp b/system/lib/compiler-rt/lib/asan/asan_report.cpp index 7603e8131154b..fd590e401f67f 100644 --- a/system/lib/compiler-rt/lib/asan/asan_report.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_report.cpp @@ -24,6 +24,7 @@ #include "sanitizer_common/sanitizer_common.h" #include "sanitizer_common/sanitizer_flags.h" #include "sanitizer_common/sanitizer_interface_internal.h" +#include "sanitizer_common/sanitizer_placement_new.h" #include "sanitizer_common/sanitizer_report_decorator.h" #include "sanitizer_common/sanitizer_stackdepot.h" #include "sanitizer_common/sanitizer_symbolizer.h" @@ -32,8 +33,11 @@ namespace __asan { // -------------------- User-specified callbacks ----------------- {{{1 static void (*error_report_callback)(const char*); -static char *error_message_buffer = nullptr; -static uptr error_message_buffer_pos = 0; +using ErrorMessageBuffer = InternalMmapVectorNoCtor; +alignas( + alignof(ErrorMessageBuffer)) static char error_message_buffer_placeholder + [sizeof(ErrorMessageBuffer)]; +static ErrorMessageBuffer *error_message_buffer = nullptr; static Mutex error_message_buf_mutex; static const unsigned kAsanBuggyPcPoolSize = 25; static __sanitizer::atomic_uintptr_t AsanBuggyPcPool[kAsanBuggyPcPoolSize]; @@ -42,17 +46,14 @@ void AppendToErrorMessageBuffer(const char *buffer) { Lock l(&error_message_buf_mutex); if (!error_message_buffer) { error_message_buffer = - (char*)MmapOrDieQuietly(kErrorMessageBufferSize, __func__); - error_message_buffer_pos = 0; + new (error_message_buffer_placeholder) ErrorMessageBuffer(); + error_message_buffer->Initialize(kErrorMessageBufferSize); } - uptr length = internal_strlen(buffer); - RAW_CHECK(kErrorMessageBufferSize >= error_message_buffer_pos); - uptr remaining = kErrorMessageBufferSize - error_message_buffer_pos; - internal_strncpy(error_message_buffer + error_message_buffer_pos, - buffer, remaining); - error_message_buffer[kErrorMessageBufferSize - 1] = '\0'; - // FIXME: reallocate the buffer instead of truncating the message. - error_message_buffer_pos += Min(remaining, length); + uptr error_message_buffer_len = error_message_buffer->size(); + uptr buffer_len = internal_strlen(buffer); + error_message_buffer->resize(error_message_buffer_len + buffer_len); + internal_memcpy(error_message_buffer->data() + error_message_buffer_len, + buffer, buffer_len); } // ---------------------- Helper functions ----------------------- {{{1 @@ -158,14 +159,14 @@ class ScopedInErrorReport { // Copy the message buffer so that we could start logging without holding a // lock that gets acquired during printing. - InternalMmapVector buffer_copy(kErrorMessageBufferSize); + InternalScopedString buffer_copy; { Lock l(&error_message_buf_mutex); - internal_memcpy(buffer_copy.data(), - error_message_buffer, kErrorMessageBufferSize); + error_message_buffer->push_back('\0'); + buffer_copy.Append(error_message_buffer->data()); // Clear error_message_buffer so that if we find other errors // we don't re-log this error. - error_message_buffer_pos = 0; + error_message_buffer->clear(); } LogFullErrorReport(buffer_copy.data()); diff --git a/system/lib/compiler-rt/lib/asan/asan_rtl.cpp b/system/lib/compiler-rt/lib/asan/asan_rtl.cpp index bb149bfbd3f5a..f9aeac33a0c91 100644 --- a/system/lib/compiler-rt/lib/asan/asan_rtl.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_rtl.cpp @@ -386,7 +386,7 @@ void PrintAddressSpaceLayout() { Printf("SHADOW_SCALE: %d\n", (int)ASAN_SHADOW_SCALE); Printf("SHADOW_GRANULARITY: %d\n", (int)ASAN_SHADOW_GRANULARITY); - Printf("SHADOW_OFFSET: 0x%zx\n", (uptr)ASAN_SHADOW_OFFSET); + Printf("SHADOW_OFFSET: %p\n", (void *)ASAN_SHADOW_OFFSET); CHECK(ASAN_SHADOW_SCALE >= 3 && ASAN_SHADOW_SCALE <= 7); if (kMidMemBeg) CHECK(kMidShadowBeg > kLowShadowEnd && @@ -414,6 +414,8 @@ static bool AsanInitInternal() { return false; } + // Make sure we are not statically linked. + __interception::DoesNotSupportStaticLinking(); AsanCheckIncompatibleRT(); AsanCheckDynamicRTPrereqs(); AvoidCVE_2016_2143(); @@ -425,9 +427,6 @@ static bool AsanInitInternal() { InitializeHighMemEnd(); - // Make sure we are not statically linked. - AsanDoesNotSupportStaticLinkage(); - // Install tool-specific callbacks in sanitizer_common. AddDieCallback(AsanDie); SetCheckUnwindCallback(CheckUnwind); diff --git a/system/lib/compiler-rt/lib/asan/asan_suppressions.cpp b/system/lib/compiler-rt/lib/asan/asan_suppressions.cpp index e71d231821866..94289d14d7e78 100644 --- a/system/lib/compiler-rt/lib/asan/asan_suppressions.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_suppressions.cpp @@ -20,7 +20,7 @@ namespace __asan { -ALIGNED(64) static char suppression_placeholder[sizeof(SuppressionContext)]; +alignas(64) static char suppression_placeholder[sizeof(SuppressionContext)]; static SuppressionContext *suppression_ctx = nullptr; static const char kInterceptorName[] = "interceptor_name"; static const char kInterceptorViaFunction[] = "interceptor_via_fun"; @@ -39,8 +39,7 @@ void InitializeSuppressions() { suppression_ctx = new (suppression_placeholder) SuppressionContext(kSuppressionTypes, ARRAY_SIZE(kSuppressionTypes)); suppression_ctx->ParseFromFile(flags()->suppressions); - if (&__asan_default_suppressions) - suppression_ctx->Parse(__asan_default_suppressions()); + suppression_ctx->Parse(__asan_default_suppressions()); } bool IsInterceptorSuppressed(const char *interceptor_name) { diff --git a/system/lib/compiler-rt/lib/asan/asan_thread.cpp b/system/lib/compiler-rt/lib/asan/asan_thread.cpp index cc292861c81f2..fc3891759bc88 100644 --- a/system/lib/compiler-rt/lib/asan/asan_thread.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_thread.cpp @@ -44,10 +44,15 @@ static ThreadRegistry *asan_thread_registry; static ThreadArgRetval *thread_data; static Mutex mu_for_thread_context; +// TODO(leonardchan@): It should be possible to make LowLevelAllocator +// threadsafe and consolidate this one into the GlobalLoweLevelAllocator. +// We should be able to do something similar to what's in +// sanitizer_stack_store.cpp. +static LowLevelAllocator allocator_for_thread_context; static ThreadContextBase *GetAsanThreadContext(u32 tid) { Lock lock(&mu_for_thread_context); - return new (GetGlobalLowLevelAllocator()) AsanThreadContext(tid); + return new (allocator_for_thread_context) AsanThreadContext(tid); } static void InitThreads() { @@ -62,10 +67,10 @@ static void InitThreads() { // thread before all TSD destructors will be called for it. // MIPS requires aligned address - static ALIGNED(alignof( - ThreadRegistry)) char thread_registry_placeholder[sizeof(ThreadRegistry)]; - static ALIGNED(alignof( - ThreadArgRetval)) char thread_data_placeholder[sizeof(ThreadArgRetval)]; + alignas(alignof(ThreadRegistry)) static char + thread_registry_placeholder[sizeof(ThreadRegistry)]; + alignas(alignof(ThreadArgRetval)) static char + thread_data_placeholder[sizeof(ThreadArgRetval)]; asan_thread_registry = new (thread_registry_placeholder) ThreadRegistry(GetAsanThreadContext); diff --git a/system/lib/compiler-rt/lib/asan/asan_win.cpp b/system/lib/compiler-rt/lib/asan/asan_win.cpp index 8507e675684ed..09a13b11cff1f 100644 --- a/system/lib/compiler-rt/lib/asan/asan_win.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_win.cpp @@ -266,11 +266,10 @@ void PlatformTSDDtor(void *tsd) { AsanThread::TSDDtor(tsd); } // }}} // ---------------------- Various stuff ---------------- {{{ -void *AsanDoesNotSupportStaticLinkage() { return 0; } - uptr FindDynamicShadowStart() { return MapDynamicShadow(MemToShadowSize(kHighMemEnd), ASAN_SHADOW_SCALE, - /*min_shadow_base_alignment*/ 0, kHighMemEnd); + /*min_shadow_base_alignment*/ 0, kHighMemEnd, + GetMmapGranularity()); } void AsanCheckDynamicRTPrereqs() {} diff --git a/system/lib/compiler-rt/lib/asan/asan_win_dll_thunk.cpp b/system/lib/compiler-rt/lib/asan/asan_win_dll_thunk.cpp index 0fa636bec0d00..35871a942a7a1 100644 --- a/system/lib/compiler-rt/lib/asan/asan_win_dll_thunk.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_win_dll_thunk.cpp @@ -80,7 +80,7 @@ INTERCEPT_LIBRARY_FUNCTION(strchr); INTERCEPT_LIBRARY_FUNCTION(strcmp); INTERCEPT_LIBRARY_FUNCTION(strcpy); INTERCEPT_LIBRARY_FUNCTION(strcspn); -INTERCEPT_LIBRARY_FUNCTION(strdup); +INTERCEPT_LIBRARY_FUNCTION(_strdup); INTERCEPT_LIBRARY_FUNCTION(strlen); INTERCEPT_LIBRARY_FUNCTION(strncat); INTERCEPT_LIBRARY_FUNCTION(strncmp); diff --git a/system/lib/compiler-rt/lib/builtins/atomic.c b/system/lib/compiler-rt/lib/builtins/atomic.c index 852bb20f08672..aded25d9baa98 100644 --- a/system/lib/compiler-rt/lib/builtins/atomic.c +++ b/system/lib/compiler-rt/lib/builtins/atomic.c @@ -12,7 +12,7 @@ // // 1) This code must work with C programs that do not link to anything // (including pthreads) and so it should not depend on any pthread -// functions. +// functions. If the user wishes to opt into using pthreads, they may do so. // 2) Atomic operations, rather than explicit mutexes, are most commonly used // on code where contended operations are rate. // @@ -56,7 +56,17 @@ static const long SPINLOCK_MASK = SPINLOCK_COUNT - 1; // defined. Each platform should define the Lock type, and corresponding // lock() and unlock() functions. //////////////////////////////////////////////////////////////////////////////// -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(_LIBATOMIC_USE_PTHREAD) +#include +typedef pthread_mutex_t Lock; +/// Unlock a lock. This is a release operation. +__inline static void unlock(Lock *l) { pthread_mutex_unlock(l); } +/// Locks a lock. +__inline static void lock(Lock *l) { pthread_mutex_lock(l); } +/// locks for atomic operations +static Lock locks[SPINLOCK_COUNT]; + +#elif defined(__FreeBSD__) || defined(__DragonFly__) #include // clang-format off #include diff --git a/system/lib/compiler-rt/lib/builtins/divtc3.c b/system/lib/compiler-rt/lib/builtins/divtc3.c index 099de5802daf0..c393de815337e 100644 --- a/system/lib/compiler-rt/lib/builtins/divtc3.c +++ b/system/lib/compiler-rt/lib/builtins/divtc3.c @@ -13,7 +13,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_F128) +#if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128) // Returns: the quotient of (a + ib) / (c + id) diff --git a/system/lib/compiler-rt/lib/builtins/extendbfsf2.c b/system/lib/compiler-rt/lib/builtins/extendbfsf2.c new file mode 100644 index 0000000000000..e159d7997f655 --- /dev/null +++ b/system/lib/compiler-rt/lib/builtins/extendbfsf2.c @@ -0,0 +1,13 @@ +//===-- lib/extendbfsf2.c - bfloat -> single conversion -----------*- C -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#define SRC_BFLOAT16 +#define DST_SINGLE +#include "fp_extend_impl.inc" + +COMPILER_RT_ABI float __extendbfsf2(src_t a) { return __extendXfYf2__(a); } diff --git a/system/lib/compiler-rt/lib/builtins/fp_add_impl.inc b/system/lib/compiler-rt/lib/builtins/fp_add_impl.inc index 7133358df9bd2..d20599921e7d8 100644 --- a/system/lib/compiler-rt/lib/builtins/fp_add_impl.inc +++ b/system/lib/compiler-rt/lib/builtins/fp_add_impl.inc @@ -91,7 +91,7 @@ static __inline fp_t __addXf3__(fp_t a, fp_t b) { // Shift the significand of b by the difference in exponents, with a sticky // bottom bit to get rounding correct. - const unsigned int align = aExponent - bExponent; + const unsigned int align = (unsigned int)(aExponent - bExponent); if (align) { if (align < typeWidth) { const bool sticky = (bSignificand << (typeWidth - align)) != 0; diff --git a/system/lib/compiler-rt/lib/builtins/fp_extend.h b/system/lib/compiler-rt/lib/builtins/fp_extend.h index 95ea2a7ac4b2c..22bf2b2514e57 100644 --- a/system/lib/compiler-rt/lib/builtins/fp_extend.h +++ b/system/lib/compiler-rt/lib/builtins/fp_extend.h @@ -37,16 +37,7 @@ static const int srcSigFracBits = 52; // srcBits - srcSigFracBits - 1 static const int srcExpBits = 11; -static inline int src_rep_t_clz_impl(src_rep_t a) { -#if defined __LP64__ - return __builtin_clzl(a); -#else - if (a & REP_C(0xffffffff00000000)) - return clzsi(a >> 32); - else - return 32 + clzsi(a & REP_C(0xffffffff)); -#endif -} +static inline int src_rep_t_clz_impl(src_rep_t a) { return __builtin_clzll(a); } #define src_rep_t_clz src_rep_t_clz_impl #elif defined SRC_80 @@ -81,6 +72,21 @@ static inline int src_rep_t_clz_impl(src_rep_t a) { #define src_rep_t_clz src_rep_t_clz_impl +#elif defined SRC_BFLOAT16 +#ifdef COMPILER_RT_HAS_BFLOAT16 +typedef __bf16 src_t; +#else +typedef uint16_t src_t; +#endif +typedef uint16_t src_rep_t; +#define SRC_REP_C UINT16_C +static const int srcBits = sizeof(src_t) * CHAR_BIT; +static const int srcSigFracBits = 7; +// -1 accounts for the sign bit. +// srcBits - srcSigFracBits - 1 +static const int srcExpBits = 8; +#define src_rep_t_clz __builtin_clz + #else #error Source should be half, single, or double precision! #endif // end source precision diff --git a/system/lib/compiler-rt/lib/builtins/fp_fixint_impl.inc b/system/lib/compiler-rt/lib/builtins/fp_fixint_impl.inc index 3556bad9990b2..2f2f77ce781ae 100644 --- a/system/lib/compiler-rt/lib/builtins/fp_fixint_impl.inc +++ b/system/lib/compiler-rt/lib/builtins/fp_fixint_impl.inc @@ -34,7 +34,7 @@ static __inline fixint_t __fixint(fp_t a) { // If 0 <= exponent < significandBits, right shift to get the result. // Otherwise, shift left. if (exponent < significandBits) - return sign * (significand >> (significandBits - exponent)); + return (fixint_t)(sign * (significand >> (significandBits - exponent))); else - return sign * ((fixuint_t)significand << (exponent - significandBits)); + return (fixint_t)(sign * ((fixuint_t)significand << (exponent - significandBits))); } diff --git a/system/lib/compiler-rt/lib/builtins/fp_lib.h b/system/lib/compiler-rt/lib/builtins/fp_lib.h index c4f0a5b9587f7..b2a89506135be 100644 --- a/system/lib/compiler-rt/lib/builtins/fp_lib.h +++ b/system/lib/compiler-rt/lib/builtins/fp_lib.h @@ -43,8 +43,8 @@ static __inline int rep_clz(rep_t a) { return clzsi(a); } // 32x32 --> 64 bit multiply static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) { const uint64_t product = (uint64_t)a * b; - *hi = product >> 32; - *lo = product; + *hi = (rep_t)(product >> 32); + *lo = (rep_t)product; } COMPILER_RT_ABI fp_t __addsf3(fp_t a, fp_t b); @@ -58,16 +58,7 @@ typedef double fp_t; #define REP_C UINT64_C #define significandBits 52 -static __inline int rep_clz(rep_t a) { -#if defined __LP64__ - return __builtin_clzl(a); -#else - if (a & REP_C(0xffffffff00000000)) - return clzsi(a >> 32); - else - return 32 + clzsi(a & REP_C(0xffffffff)); -#endif -} +static inline int rep_clz(rep_t a) { return __builtin_clzll(a); } #define loWord(a) (a & 0xffffffffU) #define hiWord(a) (a >> 32) @@ -239,7 +230,7 @@ static __inline int normalize(rep_t *significand) { return 1 - shift; } -static __inline void wideLeftShift(rep_t *hi, rep_t *lo, int count) { +static __inline void wideLeftShift(rep_t *hi, rep_t *lo, unsigned int count) { *hi = *hi << count | *lo >> (typeWidth - count); *lo = *lo << count; } diff --git a/system/lib/compiler-rt/lib/builtins/int_math.h b/system/lib/compiler-rt/lib/builtins/int_math.h index 74d3e311db5e7..08bfe922ffa13 100644 --- a/system/lib/compiler-rt/lib/builtins/int_math.h +++ b/system/lib/compiler-rt/lib/builtins/int_math.h @@ -65,9 +65,12 @@ #define crt_copysign(x, y) __builtin_copysign((x), (y)) #define crt_copysignf(x, y) __builtin_copysignf((x), (y)) #define crt_copysignl(x, y) __builtin_copysignl((x), (y)) -#if __has_builtin(__builtin_copysignf128) +// We define __has_builtin to always return 0 for GCC versions below 10, +// but __builtin_copysignf128 is available since version 7. +#if __has_builtin(__builtin_copysignf128) || \ + (defined(__GNUC__) && __GNUC__ >= 7) #define crt_copysignf128(x, y) __builtin_copysignf128((x), (y)) -#elif __has_builtin(__builtin_copysignq) || (defined(__GNUC__) && __GNUC__ >= 7) +#elif __has_builtin(__builtin_copysignq) #define crt_copysignf128(x, y) __builtin_copysignq((x), (y)) #endif #endif @@ -80,9 +83,11 @@ #define crt_fabs(x) __builtin_fabs((x)) #define crt_fabsf(x) __builtin_fabsf((x)) #define crt_fabsl(x) __builtin_fabsl((x)) -#if __has_builtin(__builtin_fabsf128) +// We define __has_builtin to always return 0 for GCC versions below 10, +// but __builtin_fabsf128 is available since version 7. +#if __has_builtin(__builtin_fabsf128) || (defined(__GNUC__) && __GNUC__ >= 7) #define crt_fabsf128(x) __builtin_fabsf128((x)) -#elif __has_builtin(__builtin_fabsq) || (defined(__GNUC__) && __GNUC__ >= 7) +#elif __has_builtin(__builtin_fabsq) #define crt_fabsf128(x) __builtin_fabsq((x)) #endif #endif diff --git a/system/lib/compiler-rt/lib/builtins/int_types.h b/system/lib/compiler-rt/lib/builtins/int_types.h index ca97391fc2846..48862f3642175 100644 --- a/system/lib/compiler-rt/lib/builtins/int_types.h +++ b/system/lib/compiler-rt/lib/builtins/int_types.h @@ -107,8 +107,8 @@ typedef union { static __inline ti_int make_ti(di_int h, di_int l) { twords r; - r.s.high = h; - r.s.low = l; + r.s.high = (du_int)h; + r.s.low = (du_int)l; return r.all; } diff --git a/system/lib/compiler-rt/lib/builtins/multc3.c b/system/lib/compiler-rt/lib/builtins/multc3.c index 61a3f45e47279..a89832f0e883e 100644 --- a/system/lib/compiler-rt/lib/builtins/multc3.c +++ b/system/lib/compiler-rt/lib/builtins/multc3.c @@ -15,7 +15,7 @@ #include "int_lib.h" #include "int_math.h" -#if defined(CRT_HAS_F128) +#if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128) // Returns: the product of a + ib and c + id diff --git a/system/lib/compiler-rt/lib/builtins/os_version_check.c b/system/lib/compiler-rt/lib/builtins/os_version_check.c index 182eabe7a6ae2..01fae834ab219 100644 --- a/system/lib/compiler-rt/lib/builtins/os_version_check.c +++ b/system/lib/compiler-rt/lib/builtins/os_version_check.c @@ -316,8 +316,8 @@ int32_t __isOSVersionAtLeast(int32_t Major, int32_t Minor, int32_t Subminor) { static pthread_once_t once = PTHREAD_ONCE_INIT; pthread_once(&once, readSystemProperties); - return SdkVersion >= Major || - (IsPreRelease && Major == __ANDROID_API_FUTURE__); + // Allow all on pre-release. Note that we still rely on compile-time checks. + return SdkVersion >= Major || IsPreRelease; } #else diff --git a/system/lib/compiler-rt/lib/builtins/trampoline_setup.c b/system/lib/compiler-rt/lib/builtins/trampoline_setup.c index 844eb27944142..830e25e4c0303 100644 --- a/system/lib/compiler-rt/lib/builtins/trampoline_setup.c +++ b/system/lib/compiler-rt/lib/builtins/trampoline_setup.c @@ -41,3 +41,45 @@ COMPILER_RT_ABI void __trampoline_setup(uint32_t *trampOnStack, __clear_cache(trampOnStack, &trampOnStack[10]); } #endif // __powerpc__ && !defined(__powerpc64__) + +// The AArch64 compiler generates calls to __trampoline_setup() when creating +// trampoline functions on the stack for use with nested functions. +// This function creates a custom 36-byte trampoline function on the stack +// which loads x18 with a pointer to the outer function's locals +// and then jumps to the target nested function. +// Note: x18 is a reserved platform register on Windows and macOS. + +#if defined(__aarch64__) && defined(__ELF__) +COMPILER_RT_ABI void __trampoline_setup(uint32_t *trampOnStack, + int trampSizeAllocated, + const void *realFunc, void *localsPtr) { + // This should never happen, but if compiler did not allocate + // enough space on stack for the trampoline, abort. + if (trampSizeAllocated < 36) + compilerrt_abort(); + + // create trampoline + // Load realFunc into x17. mov/movk 16 bits at a time. + trampOnStack[0] = + 0xd2800000u | ((((uint64_t)realFunc >> 0) & 0xffffu) << 5) | 0x11; + trampOnStack[1] = + 0xf2a00000u | ((((uint64_t)realFunc >> 16) & 0xffffu) << 5) | 0x11; + trampOnStack[2] = + 0xf2c00000u | ((((uint64_t)realFunc >> 32) & 0xffffu) << 5) | 0x11; + trampOnStack[3] = + 0xf2e00000u | ((((uint64_t)realFunc >> 48) & 0xffffu) << 5) | 0x11; + // Load localsPtr into x18 + trampOnStack[4] = + 0xd2800000u | ((((uint64_t)localsPtr >> 0) & 0xffffu) << 5) | 0x12; + trampOnStack[5] = + 0xf2a00000u | ((((uint64_t)localsPtr >> 16) & 0xffffu) << 5) | 0x12; + trampOnStack[6] = + 0xf2c00000u | ((((uint64_t)localsPtr >> 32) & 0xffffu) << 5) | 0x12; + trampOnStack[7] = + 0xf2e00000u | ((((uint64_t)localsPtr >> 48) & 0xffffu) << 5) | 0x12; + trampOnStack[8] = 0xd61f0220; // br x17 + + // Clear instruction cache. + __clear_cache(trampOnStack, &trampOnStack[9]); +} +#endif // defined(__aarch64__) && !defined(__APPLE__) && !defined(_WIN64) diff --git a/system/lib/compiler-rt/lib/interception/interception.h b/system/lib/compiler-rt/lib/interception/interception.h index 43a03d6eafb2e..ff794a05be391 100644 --- a/system/lib/compiler-rt/lib/interception/interception.h +++ b/system/lib/compiler-rt/lib/interception/interception.h @@ -208,11 +208,11 @@ const interpose_substitution substitution_##func_name[] \ ".type " SANITIZER_STRINGIFY(TRAMPOLINE(func)) ", " \ ASM_TYPE_FUNCTION_STR "\n" \ SANITIZER_STRINGIFY(TRAMPOLINE(func)) ":\n" \ - SANITIZER_STRINGIFY(CFI_STARTPROC) "\n" \ + C_ASM_STARTPROC "\n" \ C_ASM_TAIL_CALL(SANITIZER_STRINGIFY(TRAMPOLINE(func)), \ "__interceptor_" \ SANITIZER_STRINGIFY(ASM_PREEMPTIBLE_SYM(func))) "\n" \ - SANITIZER_STRINGIFY(CFI_ENDPROC) "\n" \ + C_ASM_ENDPROC "\n" \ ".size " SANITIZER_STRINGIFY(TRAMPOLINE(func)) ", " \ ".-" SANITIZER_STRINGIFY(TRAMPOLINE(func)) "\n" \ ); @@ -359,6 +359,18 @@ typedef unsigned long long uptr; // NOLINT #else typedef unsigned long uptr; // NOLINT #endif // _WIN64 + +#if defined(__ELF__) && !SANITIZER_FUCHSIA +// The use of interceptors makes many sanitizers unusable for static linking. +// Define a function, if called, will cause a linker error (undefined _DYNAMIC). +// However, -static-pie (which is not common) cannot be detected at link time. +extern uptr kDynamic[] asm("_DYNAMIC"); +inline void DoesNotSupportStaticLinking() { + [[maybe_unused]] volatile auto x = &kDynamic; +} +#else +inline void DoesNotSupportStaticLinking() {} +#endif } // namespace __interception #define INCLUDED_FROM_INTERCEPTION_LIB diff --git a/system/lib/compiler-rt/lib/interception/interception_linux.h b/system/lib/compiler-rt/lib/interception/interception_linux.h index caa42fc4b7ccd..557e18269898f 100644 --- a/system/lib/compiler-rt/lib/interception/interception_linux.h +++ b/system/lib/compiler-rt/lib/interception/interception_linux.h @@ -28,12 +28,14 @@ bool InterceptFunction(const char *name, const char *ver, uptr *ptr_to_real, uptr func, uptr trampoline); } // namespace __interception -#define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) \ - ::__interception::InterceptFunction( \ - #func, \ - (::__interception::uptr *)&REAL(func), \ - (::__interception::uptr)&(func), \ - (::__interception::uptr)&TRAMPOLINE(func)) +// Cast func to type of REAL(func) before casting to uptr in case it is an +// overloaded function, which is the case for some glibc functions when +// _FORTIFY_SOURCE is used. This disambiguates which overload to use. +#define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) \ + ::__interception::InterceptFunction( \ + #func, (::__interception::uptr *)&REAL(func), \ + (::__interception::uptr)(decltype(REAL(func)))&(func), \ + (::__interception::uptr) &TRAMPOLINE(func)) // dlvsym is a GNU extension supported by some other platforms. #if SANITIZER_GLIBC || SANITIZER_FREEBSD || SANITIZER_NETBSD @@ -41,7 +43,7 @@ bool InterceptFunction(const char *name, const char *ver, uptr *ptr_to_real, ::__interception::InterceptFunction( \ #func, symver, \ (::__interception::uptr *)&REAL(func), \ - (::__interception::uptr)&(func), \ + (::__interception::uptr)(decltype(REAL(func)))&(func), \ (::__interception::uptr)&TRAMPOLINE(func)) #else #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ diff --git a/system/lib/compiler-rt/lib/interception/interception_win.cpp b/system/lib/compiler-rt/lib/interception/interception_win.cpp index 1829358705fe8..a638e66eccee5 100644 --- a/system/lib/compiler-rt/lib/interception/interception_win.cpp +++ b/system/lib/compiler-rt/lib/interception/interception_win.cpp @@ -339,7 +339,7 @@ struct TrampolineMemoryRegion { uptr max_size; }; -UNUSED static const uptr kTrampolineScanLimitRange = 1 << 31; // 2 gig +UNUSED static const uptr kTrampolineScanLimitRange = 1ull << 31; // 2 gig static const int kMaxTrampolineRegion = 1024; static TrampolineMemoryRegion TrampolineRegions[kMaxTrampolineRegion]; @@ -479,6 +479,8 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) { switch (*(u8*)address) { case 0x90: // 90 : nop + case 0xC3: // C3 : ret (for small/empty function interception + case 0xCC: // CC : int 3 i.e. registering weak functions) return 1; case 0x50: // push eax / rax @@ -502,7 +504,6 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) { // Cannot overwrite control-instruction. Return 0 to indicate failure. case 0xE9: // E9 XX XX XX XX : jmp