diff --git a/src/lib/libstrings.js b/src/lib/libstrings.js index 6f3f42546012c..82152e2c89438 100644 --- a/src/lib/libstrings.js +++ b/src/lib/libstrings.js @@ -9,11 +9,13 @@ #endif addToLibrary({ + // In -sAUDIO_WORKLET builds, TextDecoder will not exist in AudioWorkletGlobalScope, + // so we cannot try to unconditionally initialize it in that build mode. +#if TEXTDECODER == 2 && !AUDIO_WORKLET // TextDecoder constructor defaults to UTF-8 -#if TEXTDECODER == 2 $UTF8Decoder: "new TextDecoder()", #else - $UTF8Decoder: "globalThis.TextDecoder ? new TextDecoder() : undefined", + $UTF8Decoder: "globalThis.TextDecoder && new TextDecoder()", #endif $findStringEnd: (heapOrArray, idx, maxBytesToRead, ignoreNul) => { diff --git a/src/lib/libwebaudio.js b/src/lib/libwebaudio.js index 318626374edec..3378cc89792d9 100644 --- a/src/lib/libwebaudio.js +++ b/src/lib/libwebaudio.js @@ -1,8 +1,8 @@ #if AUDIO_WORKLET && !WASM_WORKERS -#error "Building with -sAUDIO_WORKLET also requires enabling -sWASM_WORKERS!" +#error "Building with -sAUDIO_WORKLET also requires enabling -sWASM_WORKERS" #endif #if AUDIO_WORKLET && TEXTDECODER == 2 -#error "-sAUDIO_WORKLET does not support -sTEXTDECODER=2 since TextDecoder is not available in AudioWorkletGlobalScope! Use e.g. -sTEXTDECODER=1 when building with -sAUDIO_WORKLET" +#warning "-sAUDIO_WORKLET does not support -sTEXTDECODER=2 since TextDecoder is not available in AudioWorkletGlobalScope. Text decoding will be unavailable in Audio Worklets. If you need string marshalling in Audio Worklets, build with -sTEXTDECODER=1." #endif #if AUDIO_WORKLET && SINGLE_FILE #error "-sAUDIO_WORKLET does not support -sSINGLE_FILE" diff --git a/test/codesize/audio_worklet_wasm.expected.js b/test/codesize/audio_worklet_wasm.expected.js index 7b42f0b8fc59d..579197520960d 100644 --- a/test/codesize/audio_worklet_wasm.expected.js +++ b/test/codesize/audio_worklet_wasm.expected.js @@ -111,7 +111,7 @@ var K = [], L = a => { }, P = (a, c, b, f) => { c = O[c]; O[a].connect(c.destination || c, b, f); -}, O = {}, Q = 0, R = globalThis.TextDecoder ? new TextDecoder : void 0, S = (a = 0) => { +}, O = {}, Q = 0, R = globalThis.TextDecoder && new TextDecoder, S = (a = 0) => { for (var c = I, b = a, f = b + void 0; c[b] && !(b >= f); ) ++b; if (16 < b - a && c.buffer && R) return R.decode(c.slice(a, b)); for (f = ""; a < b; ) { diff --git a/test/codesize/test_codesize_cxx_ctors1.json b/test/codesize/test_codesize_cxx_ctors1.json index 158bf08138da9..31b088ae7c7c8 100644 --- a/test/codesize/test_codesize_cxx_ctors1.json +++ b/test/codesize/test_codesize_cxx_ctors1.json @@ -1,10 +1,10 @@ { - "a.out.js": 19676, - "a.out.js.gz": 8151, + "a.out.js": 19670, + "a.out.js.gz": 8152, "a.out.nodebug.wasm": 129509, "a.out.nodebug.wasm.gz": 49243, - "total": 149185, - "total_gz": 57394, + "total": 149179, + "total_gz": 57395, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_ctors2.json b/test/codesize/test_codesize_cxx_ctors2.json index 69395e2c8d2fe..8c881d7873a96 100644 --- a/test/codesize/test_codesize_cxx_ctors2.json +++ b/test/codesize/test_codesize_cxx_ctors2.json @@ -1,10 +1,10 @@ { - "a.out.js": 19653, - "a.out.js.gz": 8138, + "a.out.js": 19647, + "a.out.js.gz": 8139, "a.out.nodebug.wasm": 128936, "a.out.nodebug.wasm.gz": 48884, - "total": 148589, - "total_gz": 57022, + "total": 148583, + "total_gz": 57023, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_except.json b/test/codesize/test_codesize_cxx_except.json index 8059d11df30d9..3cf50e085bf85 100644 --- a/test/codesize/test_codesize_cxx_except.json +++ b/test/codesize/test_codesize_cxx_except.json @@ -1,10 +1,10 @@ { - "a.out.js": 23331, - "a.out.js.gz": 9129, + "a.out.js": 23325, + "a.out.js.gz": 9128, "a.out.nodebug.wasm": 171271, "a.out.nodebug.wasm.gz": 57338, - "total": 194602, - "total_gz": 66467, + "total": 194596, + "total_gz": 66466, "sent": [ "__cxa_begin_catch", "__cxa_end_catch", diff --git a/test/codesize/test_codesize_cxx_except_wasm.json b/test/codesize/test_codesize_cxx_except_wasm.json index 9ef392b38466c..6ac496e63b2eb 100644 --- a/test/codesize/test_codesize_cxx_except_wasm.json +++ b/test/codesize/test_codesize_cxx_except_wasm.json @@ -1,10 +1,10 @@ { - "a.out.js": 19561, - "a.out.js.gz": 8098, + "a.out.js": 19555, + "a.out.js.gz": 8099, "a.out.nodebug.wasm": 144630, "a.out.nodebug.wasm.gz": 54894, - "total": 164191, - "total_gz": 62992, + "total": 164185, + "total_gz": 62993, "sent": [ "_abort_js", "_tzset_js", diff --git a/test/codesize/test_codesize_cxx_except_wasm_legacy.json b/test/codesize/test_codesize_cxx_except_wasm_legacy.json index cc4a766009cda..1b7e054223d79 100644 --- a/test/codesize/test_codesize_cxx_except_wasm_legacy.json +++ b/test/codesize/test_codesize_cxx_except_wasm_legacy.json @@ -1,10 +1,10 @@ { - "a.out.js": 19561, - "a.out.js.gz": 8098, + "a.out.js": 19555, + "a.out.js.gz": 8099, "a.out.nodebug.wasm": 142219, "a.out.nodebug.wasm.gz": 54358, - "total": 161780, - "total_gz": 62456, + "total": 161774, + "total_gz": 62457, "sent": [ "_abort_js", "_tzset_js", diff --git a/test/codesize/test_codesize_cxx_mangle.json b/test/codesize/test_codesize_cxx_mangle.json index 1c8daacf91df0..0b993be3b0329 100644 --- a/test/codesize/test_codesize_cxx_mangle.json +++ b/test/codesize/test_codesize_cxx_mangle.json @@ -1,10 +1,10 @@ { - "a.out.js": 23381, - "a.out.js.gz": 9149, + "a.out.js": 23375, + "a.out.js.gz": 9148, "a.out.nodebug.wasm": 235312, "a.out.nodebug.wasm.gz": 78933, - "total": 258693, - "total_gz": 88082, + "total": 258687, + "total_gz": 88081, "sent": [ "__cxa_begin_catch", "__cxa_end_catch", diff --git a/test/codesize/test_codesize_cxx_noexcept.json b/test/codesize/test_codesize_cxx_noexcept.json index 935cbae71797f..4a0e197e931a5 100644 --- a/test/codesize/test_codesize_cxx_noexcept.json +++ b/test/codesize/test_codesize_cxx_noexcept.json @@ -1,10 +1,10 @@ { - "a.out.js": 19676, - "a.out.js.gz": 8151, + "a.out.js": 19670, + "a.out.js.gz": 8152, "a.out.nodebug.wasm": 131926, "a.out.nodebug.wasm.gz": 50238, - "total": 151602, - "total_gz": 58389, + "total": 151596, + "total_gz": 58390, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_wasmfs.json b/test/codesize/test_codesize_cxx_wasmfs.json index 9facc4405eea9..7e77d1ac35dba 100644 --- a/test/codesize/test_codesize_cxx_wasmfs.json +++ b/test/codesize/test_codesize_cxx_wasmfs.json @@ -1,10 +1,10 @@ { - "a.out.js": 7065, - "a.out.js.gz": 3329, + "a.out.js": 7059, + "a.out.js.gz": 3330, "a.out.nodebug.wasm": 169797, "a.out.nodebug.wasm.gz": 63087, - "total": 176862, - "total_gz": 66416, + "total": 176856, + "total_gz": 66417, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_file_preload.expected.js b/test/codesize/test_codesize_file_preload.expected.js index 5cee8cc358835..26f7b514301a3 100644 --- a/test/codesize/test_codesize_file_preload.expected.js +++ b/test/codesize/test_codesize_file_preload.expected.js @@ -666,7 +666,7 @@ var PATH_FS = { } }; -var UTF8Decoder = globalThis.TextDecoder ? new TextDecoder : undefined; +var UTF8Decoder = globalThis.TextDecoder && new TextDecoder; var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => { var maxIdx = idx + maxBytesToRead; diff --git a/test/codesize/test_codesize_file_preload.json b/test/codesize/test_codesize_file_preload.json index 7ef313b66368f..9e84e556b8f61 100644 --- a/test/codesize/test_codesize_file_preload.json +++ b/test/codesize/test_codesize_file_preload.json @@ -1,10 +1,10 @@ { - "a.out.js": 22479, - "a.out.js.gz": 9348, + "a.out.js": 22473, + "a.out.js.gz": 9349, "a.out.nodebug.wasm": 1681, "a.out.nodebug.wasm.gz": 960, - "total": 24160, - "total_gz": 10308, + "total": 24154, + "total_gz": 10309, "sent": [ "a (fd_write)" ], diff --git a/test/codesize/test_codesize_files_js_fs.json b/test/codesize/test_codesize_files_js_fs.json index e876b23a80945..1e6532c6790b5 100644 --- a/test/codesize/test_codesize_files_js_fs.json +++ b/test/codesize/test_codesize_files_js_fs.json @@ -1,10 +1,10 @@ { - "a.out.js": 18279, - "a.out.js.gz": 7466, + "a.out.js": 18273, + "a.out.js.gz": 7462, "a.out.nodebug.wasm": 381, "a.out.nodebug.wasm.gz": 260, - "total": 18660, - "total_gz": 7726, + "total": 18654, + "total_gz": 7722, "sent": [ "a (fd_write)", "b (fd_read)", diff --git a/test/codesize/test_codesize_files_wasmfs.json b/test/codesize/test_codesize_files_wasmfs.json index 7bdae3939e735..89106d810a267 100644 --- a/test/codesize/test_codesize_files_wasmfs.json +++ b/test/codesize/test_codesize_files_wasmfs.json @@ -1,10 +1,10 @@ { - "a.out.js": 5471, - "a.out.js.gz": 2579, + "a.out.js": 5465, + "a.out.js.gz": 2576, "a.out.nodebug.wasm": 50235, "a.out.nodebug.wasm.gz": 18098, - "total": 55706, - "total_gz": 20677, + "total": 55700, + "total_gz": 20674, "sent": [ "a (emscripten_date_now)", "b (emscripten_err)", diff --git a/test/codesize/test_codesize_hello_O0.json b/test/codesize/test_codesize_hello_O0.json index b268eaeaba1cd..c82d335d1d30e 100644 --- a/test/codesize/test_codesize_hello_O0.json +++ b/test/codesize/test_codesize_hello_O0.json @@ -1,10 +1,10 @@ { - "a.out.js": 23206, - "a.out.js.gz": 8525, + "a.out.js": 23198, + "a.out.js.gz": 8524, "a.out.nodebug.wasm": 15127, "a.out.nodebug.wasm.gz": 7450, - "total": 38333, - "total_gz": 15975, + "total": 38325, + "total_gz": 15974, "sent": [ "fd_write" ], diff --git a/test/codesize/test_codesize_hello_O1.json b/test/codesize/test_codesize_hello_O1.json index 5eea936e2ba2e..9525cad3cc8c3 100644 --- a/test/codesize/test_codesize_hello_O1.json +++ b/test/codesize/test_codesize_hello_O1.json @@ -1,10 +1,10 @@ { - "a.out.js": 6353, - "a.out.js.gz": 2462, + "a.out.js": 6345, + "a.out.js.gz": 2460, "a.out.nodebug.wasm": 2675, "a.out.nodebug.wasm.gz": 1491, - "total": 9028, - "total_gz": 3953, + "total": 9020, + "total_gz": 3951, "sent": [ "fd_write" ], diff --git a/test/codesize/test_codesize_hello_O2.json b/test/codesize/test_codesize_hello_O2.json index 6d95b8ea6d495..c0f30e38d682c 100644 --- a/test/codesize/test_codesize_hello_O2.json +++ b/test/codesize/test_codesize_hello_O2.json @@ -1,10 +1,10 @@ { - "a.out.js": 4325, - "a.out.js.gz": 2132, + "a.out.js": 4319, + "a.out.js.gz": 2131, "a.out.nodebug.wasm": 1927, "a.out.nodebug.wasm.gz": 1138, - "total": 6252, - "total_gz": 3270, + "total": 6246, + "total_gz": 3269, "sent": [ "fd_write" ], diff --git a/test/codesize/test_codesize_hello_O3.json b/test/codesize/test_codesize_hello_O3.json index 5e120b0bd2e06..1b9f5f4d33fd2 100644 --- a/test/codesize/test_codesize_hello_O3.json +++ b/test/codesize/test_codesize_hello_O3.json @@ -1,10 +1,10 @@ { - "a.out.js": 4267, - "a.out.js.gz": 2092, + "a.out.js": 4261, + "a.out.js.gz": 2091, "a.out.nodebug.wasm": 1681, "a.out.nodebug.wasm.gz": 960, - "total": 5948, - "total_gz": 3052, + "total": 5942, + "total_gz": 3051, "sent": [ "a (fd_write)" ], diff --git a/test/codesize/test_codesize_hello_Os.json b/test/codesize/test_codesize_hello_Os.json index 3b66cac60bc76..560a05125f5ce 100644 --- a/test/codesize/test_codesize_hello_Os.json +++ b/test/codesize/test_codesize_hello_Os.json @@ -1,10 +1,10 @@ { - "a.out.js": 4267, - "a.out.js.gz": 2092, + "a.out.js": 4261, + "a.out.js.gz": 2091, "a.out.nodebug.wasm": 1671, "a.out.nodebug.wasm.gz": 964, - "total": 5938, - "total_gz": 3056, + "total": 5932, + "total_gz": 3055, "sent": [ "a (fd_write)" ], diff --git a/test/codesize/test_codesize_hello_dylink.json b/test/codesize/test_codesize_hello_dylink.json index 0725e21aa1784..67d37ec2376cf 100644 --- a/test/codesize/test_codesize_hello_dylink.json +++ b/test/codesize/test_codesize_hello_dylink.json @@ -1,10 +1,10 @@ { - "a.out.js": 26937, - "a.out.js.gz": 11474, + "a.out.js": 26931, + "a.out.js.gz": 11473, "a.out.nodebug.wasm": 18567, "a.out.nodebug.wasm.gz": 9199, - "total": 45504, - "total_gz": 20673, + "total": 45498, + "total_gz": 20672, "sent": [ "__heap_base", "__indirect_function_table", diff --git a/test/codesize/test_codesize_hello_dylink_all.json b/test/codesize/test_codesize_hello_dylink_all.json index 2dec9c6cb50d4..7a1fb7e1ba03a 100644 --- a/test/codesize/test_codesize_hello_dylink_all.json +++ b/test/codesize/test_codesize_hello_dylink_all.json @@ -1,7 +1,7 @@ { - "a.out.js": 245848, + "a.out.js": 245842, "a.out.nodebug.wasm": 597755, - "total": 843603, + "total": 843597, "sent": [ "IMG_Init", "IMG_Load", diff --git a/test/codesize/test_codesize_hello_single_file.json b/test/codesize/test_codesize_hello_single_file.json index 17d49fc2bd11d..b216a17b1a986 100644 --- a/test/codesize/test_codesize_hello_single_file.json +++ b/test/codesize/test_codesize_hello_single_file.json @@ -1,6 +1,6 @@ { - "a.out.js": 6503, - "a.out.js.gz": 3580, + "a.out.js": 6497, + "a.out.js.gz": 3579, "sent": [ "a (fd_write)" ] diff --git a/test/codesize/test_codesize_hello_wasmfs.json b/test/codesize/test_codesize_hello_wasmfs.json index 5e120b0bd2e06..1b9f5f4d33fd2 100644 --- a/test/codesize/test_codesize_hello_wasmfs.json +++ b/test/codesize/test_codesize_hello_wasmfs.json @@ -1,10 +1,10 @@ { - "a.out.js": 4267, - "a.out.js.gz": 2092, + "a.out.js": 4261, + "a.out.js.gz": 2091, "a.out.nodebug.wasm": 1681, "a.out.nodebug.wasm.gz": 960, - "total": 5948, - "total_gz": 3052, + "total": 5942, + "total_gz": 3051, "sent": [ "a (fd_write)" ], diff --git a/test/codesize/test_minimal_runtime_code_size_audio_worklet.json b/test/codesize/test_minimal_runtime_code_size_audio_worklet.json index 0df0a1a9df5fc..f185c2835ae59 100644 --- a/test/codesize/test_minimal_runtime_code_size_audio_worklet.json +++ b/test/codesize/test_minimal_runtime_code_size_audio_worklet.json @@ -1,10 +1,10 @@ { "a.html": 519, "a.html.gz": 357, - "a.js": 4108, - "a.js.gz": 2104, + "a.js": 4102, + "a.js.gz": 2103, "a.wasm": 1308, "a.wasm.gz": 876, - "total": 5935, - "total_gz": 3337 + "total": 5929, + "total_gz": 3336 } diff --git a/test/codesize/test_small_js_flags.json b/test/codesize/test_small_js_flags.json index 4b91b8456f856..258ceaa4a17cf 100644 --- a/test/codesize/test_small_js_flags.json +++ b/test/codesize/test_small_js_flags.json @@ -1,4 +1,4 @@ { - "a.out.js": 2732, + "a.out.js": 2726, "a.out.js.gz": 1495 } diff --git a/test/codesize/test_unoptimized_code_size.json b/test/codesize/test_unoptimized_code_size.json index 1a2d9196d9c0b..16940da00e92d 100644 --- a/test/codesize/test_unoptimized_code_size.json +++ b/test/codesize/test_unoptimized_code_size.json @@ -1,16 +1,16 @@ { - "hello_world.js": 55411, - "hello_world.js.gz": 17487, + "hello_world.js": 55400, + "hello_world.js.gz": 17483, "hello_world.wasm": 15127, "hello_world.wasm.gz": 7450, - "no_asserts.js": 26570, - "no_asserts.js.gz": 8870, + "no_asserts.js": 26559, + "no_asserts.js.gz": 8867, "no_asserts.wasm": 12227, "no_asserts.wasm.gz": 6010, - "strict.js": 53449, - "strict.js.gz": 16824, + "strict.js": 53438, + "strict.js.gz": 16822, "strict.wasm": 15127, "strict.wasm.gz": 7447, - "total": 177911, - "total_gz": 64088 + "total": 177878, + "total_gz": 64079 }