Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/lib/libstrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libwebaudio.js
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion test/codesize/audio_worklet_wasm.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ var L = [], M = a => {
}, Q = (a, b, e, d) => {
b = P[b];
P[a].connect(b.destination || b, e, d);
}, P = {}, R = 0, S = globalThis.TextDecoder ? new TextDecoder : void 0, T = (a = 0) => {
}, P = {}, R = 0, S = globalThis.TextDecoder && new TextDecoder, T = (a = 0) => {
for (var b = J, e = a, d = e + void 0; b[e] && !(e >= d); ) ++e;
if (16 < e - a && b.buffer && S) return S.decode(b.slice(a, e));
for (d = ""; a < e; ) {
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_ctors1.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_ctors2.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_except.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_except_wasm.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_except_wasm_legacy.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 5 additions & 5 deletions test/codesize/test_codesize_cxx_mangle.json
Original file line number Diff line number Diff line change
@@ -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,
"a.out.nodebug.wasm.gz": 78935,
"total": 258687,
"total_gz": 88083,
"sent": [
"__cxa_begin_catch",
"__cxa_end_catch",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_noexcept.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_wasmfs.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion test/codesize/test_codesize_file_preload.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_file_preload.json
Original file line number Diff line number Diff line change
@@ -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)"
],
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_files_js_fs.json
Original file line number Diff line number Diff line change
@@ -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)",
Expand Down
12 changes: 6 additions & 6 deletions test/codesize/test_codesize_files_wasmfs.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 5471,
"a.out.js.gz": 2579,
"a.out.nodebug.wasm": 50235,
"a.out.nodebug.wasm.gz": 18098,
"total": 55706,
"total_gz": 20677,
"a.out.js": 5465,
"a.out.js.gz": 2576,
"a.out.nodebug.wasm": 50231,
"a.out.nodebug.wasm.gz": 18094,
"total": 55696,
"total_gz": 20670,
"sent": [
"a (emscripten_date_now)",
"b (emscripten_err)",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_O0.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_O1.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_O2.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_O3.json
Original file line number Diff line number Diff line change
@@ -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)"
],
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_Os.json
Original file line number Diff line number Diff line change
@@ -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)"
],
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_dylink.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 3 additions & 3 deletions test/codesize/test_codesize_hello_dylink_all.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"a.out.js": 245848,
"a.out.nodebug.wasm": 597755,
"total": 843603,
"a.out.js": 245842,
"a.out.nodebug.wasm": 597763,
"total": 843605,
"sent": [
"IMG_Init",
"IMG_Load",
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_hello_single_file.json
Original file line number Diff line number Diff line change
@@ -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)"
]
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_wasmfs.json
Original file line number Diff line number Diff line change
@@ -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)"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 519,
"a.html.gz": 357,
"a.js": 3859,
"a.js.gz": 2037,
"a.js": 3853,
"a.js.gz": 2035,
"a.wasm": 1308,
"a.wasm.gz": 876,
"total": 5686,
"total_gz": 3270
"total": 5680,
"total_gz": 3268
}
2 changes: 1 addition & 1 deletion test/codesize/test_small_js_flags.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"a.out.js": 2732,
"a.out.js": 2726,
"a.out.js.gz": 1495
}
16 changes: 8 additions & 8 deletions test/codesize/test_unoptimized_code_size.json
Original file line number Diff line number Diff line change
@@ -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
}
Loading