Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/lib/libaddfunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ addToLibrary({
#endif
},

$updateTableMap__deps: ['$getWasmTableEntry'],
$updateTableMap__deps: ['$getWasmTableEntry', '$functionsInTableMap'],
$updateTableMap: (offset, count) => {
if (functionsInTableMap) {
for (var i = offset; i < offset + count; i++) {
Expand Down
6 changes: 5 additions & 1 deletion src/lib/libcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,7 @@ addToLibrary({
$timers: {},

$clearTimers__internal: true,
$clearTimers__deps: ['$timers'],
$clearTimers: () => {
for (var t of Object.values(timers)) {
clearTimeout(t.id);
Expand Down Expand Up @@ -2079,9 +2080,12 @@ addToLibrary({
emscripten_throw_string: (str) => { throw UTF8ToString(str); },

#if !MINIMAL_RUNTIME
$handleException__deps: [
'$ExitStatus',
#if STACK_OVERFLOW_CHECK
$handleException__deps: ['emscripten_stack_get_current'],
'emscripten_stack_get_current',
#endif
],
$handleException: (e) => {
// Certain exception types we do not treat as errors since they are used for
// internal control flow.
Expand Down
16 changes: 13 additions & 3 deletions src/lib/libdylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const UNDEFINED_ADDR = to64(-1);

var LibraryDylink = {
#if FILESYSTEM
$registerWasmPlugin__deps: ['$preloadPlugins'],
$registerWasmPlugin__deps: ['$preloadPlugins', '$loadWebAssemblyModule', '$preloadedWasm'],
$registerWasmPlugin: () => {
// Use string keys here for public methods to avoid minification since the
// plugin consumer also uses string keys.
Expand Down Expand Up @@ -310,7 +310,7 @@ var LibraryDylink = {
},

$reportUndefinedSymbols__internal: true,
$reportUndefinedSymbols__deps: ['$GOT', '$resolveGlobalSymbol'],
$reportUndefinedSymbols__deps: ['$GOT', '$resolveGlobalSymbol', '$addFunction'],
$reportUndefinedSymbols: () => {
#if DYLINK_DEBUG
dbg('reportUndefinedSymbols');
Expand Down Expand Up @@ -393,7 +393,11 @@ var LibraryDylink = {
// Allocate memory even if malloc isn't ready yet. The allocated memory here
// must be zero initialized since its used for all static data, including bss.
$getMemory__noleakcheck: true,
$getMemory__deps: ['emscripten_get_sbrk_ptr', '__heap_base', '$alignMemory', 'calloc'],
// `__heap_base` is also used below, but is added via `REQUIRED_EXPORTS` in
// `link.py` rather than `__deps` because `wasm-ld` processes stub library
// dependencies before synthesizing optional symbols like `__heap_base`.
// See https://github.com/llvm/llvm-project/issues/180632
$getMemory__deps: ['emscripten_get_sbrk_ptr', '$alignMemory', 'calloc'],
$getMemory: (size) => {
// After the runtime is initialized, we must only use sbrk() normally.
#if DYLINK_DEBUG
Expand Down Expand Up @@ -684,6 +688,9 @@ var LibraryDylink = {
'$loadDynamicLibrary',
'$getDylinkMetadata',
'$instantiateModule',
#if FILESYSTEM
'$findLibraryFS',
#endif
],
$loadWebAssemblyModule: (binary, flags, libName, localScope, handle) => {
#if DYLINK_DEBUG
Expand Down Expand Up @@ -722,6 +729,7 @@ var LibraryDylink = {
$instantiateModule__deps: [
'$getMemory', '$updateGOT',
'$relocateExports', '$resolveGlobalSymbol', '$GOTHandler',
'$reportUndefinedSymbols',
'$alignMemory', '$updateTableMap',
'$wasmTable', '$addOnPostCtor',
'$addEmAsm', '$addEmJs',
Expand Down Expand Up @@ -996,6 +1004,7 @@ var LibraryDylink = {
},
#endif

$newDSO__deps: ['$LDSO'],
$newDSO: (name, handle, syms) => {
var dso = {
refcount: Infinity,
Expand Down Expand Up @@ -1082,6 +1091,7 @@ var LibraryDylink = {
'$mergeLibSymbols', '$newDSO',
'$asyncLoad',
#if FILESYSTEM
'$FS',
'$preloadedWasm',
'$findLibraryFS',
#endif
Expand Down
1 change: 1 addition & 0 deletions src/lib/libfs_shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ addToLibrary({
return mode;
},

$FS_fileDataToTypedArray__deps: ['$intArrayFromString'],
$FS_fileDataToTypedArray: (data) => {
if (typeof data === 'string') {
data = intArrayFromString(data, true);
Expand Down
1 change: 1 addition & 0 deletions src/lib/libopenal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@ var LibraryOpenAL = {
// alDopplerVelocity() sets a multiplier for the speed of sound.
// It's deprecated since it's equivalent to directly calling
// alSpeedOfSound() with an appropriately premultiplied value.
alDopplerVelocity__deps: ['$warnOnce'],
alDopplerVelocity__proxy: 'sync',
alDopplerVelocity: (value) => {
warnOnce('alDopplerVelocity() is deprecated, and only kept for compatibility with OpenAL 1.0. Use alSpeedOfSound() instead.');
Expand Down
7 changes: 6 additions & 1 deletion src/lib/libpthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,20 @@ const pthreadWorkerOptions = `{
var LibraryPThread = {
$PThread__postset: 'PThread.init();',
$PThread__deps: ['_emscripten_thread_init',
'$callUserCallback',
'$checkMailbox',
'$terminateWorker',
'$cleanupThread',
#if !MINIMAL_RUNTIME && PTHREAD_POOL_SIZE
#if !MINIMAL_RUNTIME
'$wasmMemory',
#if PTHREAD_POOL_SIZE
'$addOnPreRun',
#if !PTHREAD_POOL_DELAY_LOAD
'$addRunDependency',
'$removeRunDependency',
#endif
#endif
#endif
#if MAIN_MODULE
'$markAsFinished',
#endif
Expand Down
1 change: 1 addition & 0 deletions src/lib/libwasm_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ addToLibrary({
// which these postponed function calls can be dispatched.
$_wasmWorkerDelayedMessageQueue: [],

$_wasmWorkerAppendToQueue__deps: ['$_wasmWorkerDelayedMessageQueue'],
$_wasmWorkerAppendToQueue: (e) => {
_wasmWorkerDelayedMessageQueue.push(e);
},
Expand Down
1 change: 1 addition & 0 deletions src/lib/libwebaudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ var LibraryWebAudio = {
// etc., but the created worklet does.
_emscripten_create_audio_worklet__deps: [
'$_emAudioDispatchProcessorCallback',
'$emAudio',
'$stackAlloc', '$stackRestore', '$stackSave', '$HEAP32', '$HEAPU32', '$HEAPF32',
#if WASM_BIGINT || MEMORY64
'$HEAP64', '$HEAPU64',
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/audio_worklet_wasm.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ u || (x = new WebAssembly.Memory({
shared: !0
}), y());

var M = a => {
var L = [], M = a => {
L.push(a);
}, L = [], N = a => {
}, N = a => {
a = a.data;
var b = a._wsc;
b && A.get(b)(...a.x);
Expand All @@ -114,7 +114,7 @@ var M = a => {
a = a.data;
var b = a._wsc;
b && A.get(b)(...a.D);
}, ca = (a, b, c, k, d, g, f) => {
}, Q = {}, ca = (a, b, c, k, d, g, f) => {
var l = Q[b], n = l.audioWorklet;
d = () => {
A.get(g)(b, 0, f);
Expand Down Expand Up @@ -159,7 +159,7 @@ var M = a => {
} else k += String.fromCharCode(d);
}
return k;
}, Q = {}, T = 0, ea = a => {
}, T = 0, ea = a => {
if (a) {
var b = G[a >> 2];
b = (b ? S(b) : "") || void 0;
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/hello_wasm_worker_wasm.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ e || (g = new WebAssembly.Memory({
shared: !0
}));

var l = a => {
var k = [], l = a => {
k.push(a);
}, k = [], n = a => {
}, n = a => {
a = a.data;
var b = a._wsc;
b && m.get(b)(...a.x);
Expand Down
136 changes: 68 additions & 68 deletions test/codesize/test_codesize_file_preload.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,74 @@ var FS_createPreloadedFile = (parent, name, url, canRead, canWrite, onload, oner
FS_preloadFile(parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish).then(onload).catch(onerror);
};

var lengthBytesUTF8 = str => {
var len = 0;
for (var i = 0; i < str.length; ++i) {
var u = str.codePointAt(i);
if (u <= 127) {
len++;
} else if (u <= 2047) {
len += 2;
} else if (u <= 65535) {
len += 3;
} else {
len += 4;
// Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
// We need to manually skip over the second code unit for correct iteration.
i++;
}
}
return len;
};

var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
// Parameter maxBytesToWrite is not optional. Negative values, 0, null,
// undefined and false each don't write out any bytes.
if (!(maxBytesToWrite > 0)) return 0;
var startIdx = outIdx;
var endIdx = outIdx + maxBytesToWrite - 1;
// -1 for string null terminator.
for (var i = 0; i < str.length; ++i) {
// For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
// and https://www.ietf.org/rfc/rfc2279.txt
// and https://tools.ietf.org/html/rfc3629
var u = str.codePointAt(i);
if (u <= 127) {
if (outIdx >= endIdx) break;
heap[outIdx++] = u;
} else if (u <= 2047) {
if (outIdx + 1 >= endIdx) break;
heap[outIdx++] = 192 | (u >> 6);
heap[outIdx++] = 128 | (u & 63);
} else if (u <= 65535) {
if (outIdx + 2 >= endIdx) break;
heap[outIdx++] = 224 | (u >> 12);
heap[outIdx++] = 128 | ((u >> 6) & 63);
heap[outIdx++] = 128 | (u & 63);
} else {
if (outIdx + 3 >= endIdx) break;
heap[outIdx++] = 240 | (u >> 18);
heap[outIdx++] = 128 | ((u >> 12) & 63);
heap[outIdx++] = 128 | ((u >> 6) & 63);
heap[outIdx++] = 128 | (u & 63);
// Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
// We need to manually skip over the second code unit for correct iteration.
i++;
}
}
// Null-terminate the pointer to the buffer.
heap[outIdx] = 0;
return outIdx - startIdx;
};

/** @type {function(string, boolean=, number=)} */ var intArrayFromString = (stringy, dontAddNull, length) => {
var len = length > 0 ? length : lengthBytesUTF8(stringy) + 1;
var u8array = new Array(len);
var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
if (dontAddNull) u8array.length = numBytesWritten;
return u8array;
};

var FS_fileDataToTypedArray = data => {
if (typeof data === "string") {
data = intArrayFromString(data, true);
Expand Down Expand Up @@ -1002,74 +1070,6 @@ var MEMFS = {

var FS_stdin_getChar_buffer = [];

var lengthBytesUTF8 = str => {
var len = 0;
for (var i = 0; i < str.length; ++i) {
var u = str.codePointAt(i);
if (u <= 127) {
len++;
} else if (u <= 2047) {
len += 2;
} else if (u <= 65535) {
len += 3;
} else {
len += 4;
// Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
// We need to manually skip over the second code unit for correct iteration.
i++;
}
}
return len;
};

var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
// Parameter maxBytesToWrite is not optional. Negative values, 0, null,
// undefined and false each don't write out any bytes.
if (!(maxBytesToWrite > 0)) return 0;
var startIdx = outIdx;
var endIdx = outIdx + maxBytesToWrite - 1;
// -1 for string null terminator.
for (var i = 0; i < str.length; ++i) {
// For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
// and https://www.ietf.org/rfc/rfc2279.txt
// and https://tools.ietf.org/html/rfc3629
var u = str.codePointAt(i);
if (u <= 127) {
if (outIdx >= endIdx) break;
heap[outIdx++] = u;
} else if (u <= 2047) {
if (outIdx + 1 >= endIdx) break;
heap[outIdx++] = 192 | (u >> 6);
heap[outIdx++] = 128 | (u & 63);
} else if (u <= 65535) {
if (outIdx + 2 >= endIdx) break;
heap[outIdx++] = 224 | (u >> 12);
heap[outIdx++] = 128 | ((u >> 6) & 63);
heap[outIdx++] = 128 | (u & 63);
} else {
if (outIdx + 3 >= endIdx) break;
heap[outIdx++] = 240 | (u >> 18);
heap[outIdx++] = 128 | ((u >> 12) & 63);
heap[outIdx++] = 128 | ((u >> 6) & 63);
heap[outIdx++] = 128 | (u & 63);
// Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
// We need to manually skip over the second code unit for correct iteration.
i++;
}
}
// Null-terminate the pointer to the buffer.
heap[outIdx] = 0;
return outIdx - startIdx;
};

/** @type {function(string, boolean=, number=)} */ var intArrayFromString = (stringy, dontAddNull, length) => {
var len = length > 0 ? length : lengthBytesUTF8(stringy) + 1;
var u8array = new Array(len);
var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
if (dontAddNull) u8array.length = numBytesWritten;
return u8array;
};

var FS_stdin_getChar = () => {
if (!FS_stdin_getChar_buffer.length) {
var result = null;
Expand Down
4 changes: 2 additions & 2 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": 22169,
"a.out.js.gz": 9236,
"a.out.js.gz": 9244,
"a.out.nodebug.wasm": 1198,
"a.out.nodebug.wasm.gz": 730,
"total": 23367,
"total_gz": 9966,
"total_gz": 9974,
"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": 26228,
"a.out.js.gz": 11156,
"a.out.js": 26229,
"a.out.js.gz": 11137,
"a.out.nodebug.wasm": 16986,
"a.out.nodebug.wasm.gz": 8667,
"total": 43214,
"total_gz": 19823,
"total": 43215,
"total_gz": 19804,
"sent": [
"__syscall_stat64",
"emscripten_resize_heap",
Expand Down
4 changes: 2 additions & 2 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": 272705,
"a.out.js": 272704,
"a.out.nodebug.wasm": 589443,
"total": 862148,
"total": 862147,
"sent": [
"IMG_Init",
"IMG_Load",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_minimal_pthreads.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 6893,
"a.out.js.gz": 3411,
"a.out.js": 6889,
"a.out.js.gz": 3404,
"a.out.nodebug.wasm": 19139,
"a.out.nodebug.wasm.gz": 8819,
"total": 26032,
"total_gz": 12230,
"total": 26028,
"total_gz": 12223,
"sent": [
"a (memory)",
"b (exit)",
Expand Down
Loading
Loading