From 35584679883a8e80623bb1c122c8867a4ebfe6a0 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 17 Apr 2024 11:17:50 -0700 Subject: [PATCH] Add new simple export mechanism This change adds a new `-sEXPORT` setting that can by used to export any type of symbols (see #8380) It also includes a new `-sMANGLED_SYMBOLS` setting which default to true in order to not break backwards compatibility. Both these new settings are currently experimental and using `-sEXPORT` currently disables `-sMANGLED_SYMBOLS` by default. --- emcc.py | 6 +- site/source/docs/getting_started/FAQ.rst | 2 +- .../docs/optimizing/Module-Splitting.rst | 4 +- site/source/docs/porting/Debugging.rst | 2 +- .../Interacting-with-code.rst | 6 +- src/Fetch.js | 8 +- src/compiler.mjs | 2 +- src/deterministic.js | 2 +- src/embind/embind.js | 26 +- src/embind/embind_shared.js | 4 +- src/embind/emval.js | 8 +- src/jsifier.mjs | 64 ++-- src/library.js | 166 +++++---- src/library_async.js | 28 +- src/library_autodebug.js | 2 +- src/library_browser.js | 20 +- src/library_ccall.js | 2 +- src/library_dylink.js | 12 +- src/library_egl.js | 4 +- src/library_eventloop.js | 16 +- src/library_exceptions.js | 34 +- src/library_fs.js | 2 +- src/library_glemu.js | 327 +++++++++--------- src/library_glfw.js | 26 +- src/library_glut.js | 12 +- src/library_html5.js | 104 +++--- src/library_html5_webgl.js | 18 +- src/library_idbstore.js | 6 +- src/library_legacy.js | 12 +- src/library_nodefs.js | 2 +- src/library_openal.js | 4 +- src/library_promise.js | 4 +- src/library_pthread.js | 42 +-- src/library_sdl.js | 100 +++--- src/library_stack_trace.js | 20 +- src/library_strings.js | 2 +- src/library_syscall.js | 2 +- src/library_time.js | 2 +- src/library_trace.js | 14 +- src/library_uuid.js | 16 +- src/library_wasi.js | 6 +- src/library_wasm_worker.js | 10 +- src/library_wasmfs.js | 104 +++--- src/library_wasmfs_fetch.js | 4 +- src/library_wasmfs_jsimpl.js | 10 +- src/library_wasmfs_node.js | 2 +- src/library_wasmfs_opfs.js | 4 +- src/library_webgl.js | 12 +- src/library_webgpu.js | 20 +- src/library_websocket.js | 8 +- src/library_wget.js | 8 +- src/memoryprofiler.js | 20 +- src/parseTools.mjs | 10 +- src/parseTools_legacy.mjs | 4 +- src/postamble.js | 14 +- src/postamble_minimal.js | 10 +- src/preamble.js | 12 +- src/runtime_asan.js | 32 +- src/runtime_debug.js | 2 +- src/runtime_pthread.js | 14 +- src/runtime_safe_heap.js | 19 +- src/runtime_shared.js | 2 +- src/runtime_stack_check.js | 6 +- src/settings.js | 10 + src/threadprofiler.js | 4 +- test/benchmark/benchmark_utf16.cpp | 4 +- test/benchmark/benchmark_utf8.c | 4 +- test/code_size/embind_hello_wasm.json | 8 +- test/code_size/embind_val_wasm.json | 8 +- test/code_size/hello_wasm_worker_wasm.js | 2 +- test/code_size/hello_wasm_worker_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/hello_world_wasm.json | 8 +- test/code_size/hello_world_wasm2js.js | 66 ++-- test/code_size/hello_world_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 | 8 +- test/core/FS_exports_assert_2.out | 2 +- test/core/js_library_i64_params.js | 2 +- ...legacy_exported_runtime_numbers_assert.out | 2 +- test/core/test_abort_on_exceptions_post.js | 4 +- test/core/test_aborting_new.cpp | 2 +- test/core/test_asan_js_stack_op.c | 2 +- test/core/test_asyncify_assertions.c | 2 +- test/core/test_dlfcn_self.c | 4 +- test/core/test_dlfcn_self.out | 6 +- test/core/test_em_async_js.c | 6 +- test/core/test_em_js.cpp | 4 +- test/core/test_emscripten_api.cpp | 2 +- test/core/test_getValue_setValue_assert.out | 2 +- test/core/test_utf.c | 4 +- test/declare_asm_module_exports.c | 2 +- test/embind/embind.benchmark.js | 64 ++-- test/embind/test_unsigned.cpp | 2 +- .../applyImportAndExportNameChanges-output.js | 18 +- .../applyImportAndExportNameChanges.js | 18 +- ...applyImportAndExportNameChanges2-output.js | 46 +-- .../applyImportAndExportNameChanges2.js | 48 +-- test/minimal_webgl/library_js.js | 4 +- test/module_exports/main.js | 4 +- .../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.exports | 6 +- .../codesize/test_codesize_cxx_lto.gzsize | 2 +- .../codesize/test_codesize_cxx_lto.jssize | 2 +- .../other/codesize/test_codesize_cxx_lto.size | 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 +- .../test_codesize_files_js_fs.exports | 3 + .../codesize/test_codesize_files_js_fs.funcs | 3 + .../codesize/test_codesize_files_js_fs.gzsize | 2 +- .../codesize/test_codesize_files_js_fs.jssize | 2 +- .../codesize/test_codesize_files_js_fs.size | 2 +- .../test_codesize_files_wasmfs.exports | 3 + .../codesize/test_codesize_files_wasmfs.funcs | 3 + .../test_codesize_files_wasmfs.gzsize | 2 +- .../test_codesize_files_wasmfs.jssize | 2 +- .../codesize/test_codesize_files_wasmfs.size | 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.exports | 3 + .../codesize/test_codesize_hello_O3.funcs | 3 + .../codesize/test_codesize_hello_O3.gzsize | 2 +- .../codesize/test_codesize_hello_O3.jssize | 2 +- .../codesize/test_codesize_hello_O3.size | 2 +- .../codesize/test_codesize_hello_Os.exports | 3 + .../codesize/test_codesize_hello_Os.funcs | 3 + .../codesize/test_codesize_hello_Os.gzsize | 2 +- .../codesize/test_codesize_hello_Os.jssize | 2 +- .../codesize/test_codesize_hello_Os.size | 2 +- .../codesize/test_codesize_hello_Oz.exports | 3 + .../codesize/test_codesize_hello_Oz.funcs | 3 + .../codesize/test_codesize_hello_Oz.gzsize | 2 +- .../codesize/test_codesize_hello_Oz.jssize | 2 +- .../codesize/test_codesize_hello_Oz.size | 2 +- .../test_codesize_hello_dylink.gzsize | 2 +- .../test_codesize_hello_dylink.jssize | 2 +- ...test_codesize_hello_export_nothing.exports | 10 +- .../test_codesize_hello_export_nothing.funcs | 10 + .../test_codesize_hello_export_nothing.gzsize | 2 +- ...test_codesize_hello_export_nothing.imports | 3 +- .../test_codesize_hello_export_nothing.jssize | 2 +- .../test_codesize_hello_export_nothing.sent | 3 +- .../test_codesize_hello_export_nothing.size | 2 +- .../test_codesize_hello_wasmfs.exports | 3 + .../codesize/test_codesize_hello_wasmfs.funcs | 3 + .../test_codesize_hello_wasmfs.gzsize | 2 +- .../test_codesize_hello_wasmfs.jssize | 2 +- .../codesize/test_codesize_hello_wasmfs.size | 2 +- ...test_codesize_libcxxabi_message_O3.exports | 3 + .../test_codesize_libcxxabi_message_O3.funcs | 3 + .../test_codesize_libcxxabi_message_O3.gzsize | 2 +- .../test_codesize_libcxxabi_message_O3.jssize | 2 +- .../test_codesize_libcxxabi_message_O3.size | 2 +- ...ze_libcxxabi_message_O3_standalone.exports | 2 + ...size_libcxxabi_message_O3_standalone.funcs | 2 + ...ize_libcxxabi_message_O3_standalone.gzsize | 2 +- ...ize_libcxxabi_message_O3_standalone.jssize | 2 +- ...esize_libcxxabi_message_O3_standalone.size | 2 +- .../codesize/test_codesize_mem_O3.exports | 4 +- .../other/codesize/test_codesize_mem_O3.funcs | 2 + .../codesize/test_codesize_mem_O3.gzsize | 2 +- .../codesize/test_codesize_mem_O3.jssize | 2 +- test/other/codesize/test_codesize_mem_O3.size | 2 +- .../test_codesize_mem_O3_grow.exports | 4 +- .../codesize/test_codesize_mem_O3_grow.funcs | 2 + .../codesize/test_codesize_mem_O3_grow.gzsize | 2 +- .../codesize/test_codesize_mem_O3_grow.jssize | 2 +- .../codesize/test_codesize_mem_O3_grow.size | 2 +- ...st_codesize_mem_O3_grow_standalone.exports | 2 + ...test_codesize_mem_O3_grow_standalone.funcs | 2 + ...est_codesize_mem_O3_grow_standalone.gzsize | 2 +- ...est_codesize_mem_O3_grow_standalone.jssize | 2 +- .../test_codesize_mem_O3_grow_standalone.size | 2 +- .../test_codesize_mem_O3_standalone.exports | 2 + .../test_codesize_mem_O3_standalone.funcs | 2 + .../test_codesize_mem_O3_standalone.gzsize | 2 +- .../test_codesize_mem_O3_standalone.jssize | 2 +- .../test_codesize_mem_O3_standalone.size | 2 +- ...est_codesize_mem_O3_standalone_lib.exports | 2 + .../test_codesize_mem_O3_standalone_lib.funcs | 2 + ...test_codesize_mem_O3_standalone_lib.gzsize | 2 +- ...test_codesize_mem_O3_standalone_lib.jssize | 2 +- .../test_codesize_mem_O3_standalone_lib.size | 2 +- ...st_codesize_mem_O3_standalone_narg.exports | 2 + ...test_codesize_mem_O3_standalone_narg.funcs | 2 + ...est_codesize_mem_O3_standalone_narg.gzsize | 2 +- ...est_codesize_mem_O3_standalone_narg.jssize | 2 +- .../test_codesize_mem_O3_standalone_narg.size | 2 +- ...desize_mem_O3_standalone_narg_flto.exports | 2 + ...codesize_mem_O3_standalone_narg_flto.funcs | 2 + ...odesize_mem_O3_standalone_narg_flto.gzsize | 2 +- ...odesize_mem_O3_standalone_narg_flto.jssize | 2 +- ..._codesize_mem_O3_standalone_narg_flto.size | 2 +- .../codesize/test_codesize_minimal_64.exports | 3 + .../codesize/test_codesize_minimal_64.funcs | 3 + .../codesize/test_codesize_minimal_64.gzsize | 2 +- .../codesize/test_codesize_minimal_64.jssize | 2 +- .../codesize/test_codesize_minimal_64.size | 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.exports | 3 + .../codesize/test_codesize_minimal_O3.funcs | 3 + .../codesize/test_codesize_minimal_O3.gzsize | 2 +- .../codesize/test_codesize_minimal_O3.jssize | 2 +- .../codesize/test_codesize_minimal_O3.size | 2 +- .../codesize/test_codesize_minimal_Os.exports | 3 + .../codesize/test_codesize_minimal_Os.funcs | 3 + .../codesize/test_codesize_minimal_Os.gzsize | 2 +- .../codesize/test_codesize_minimal_Os.jssize | 2 +- .../codesize/test_codesize_minimal_Os.size | 2 +- .../test_codesize_minimal_Os_mr.exports | 3 + .../test_codesize_minimal_Os_mr.funcs | 3 + .../codesize/test_codesize_minimal_Os_mr.size | 2 +- .../test_codesize_minimal_Oz-ctors.exports | 3 + .../test_codesize_minimal_Oz-ctors.funcs | 3 + .../test_codesize_minimal_Oz-ctors.gzsize | 2 +- .../test_codesize_minimal_Oz-ctors.jssize | 2 +- .../test_codesize_minimal_Oz-ctors.size | 2 +- .../codesize/test_codesize_minimal_Oz.exports | 3 + .../codesize/test_codesize_minimal_Oz.funcs | 3 + .../codesize/test_codesize_minimal_Oz.gzsize | 2 +- .../codesize/test_codesize_minimal_Oz.jssize | 2 +- .../codesize/test_codesize_minimal_Oz.size | 2 +- .../test_codesize_minimal_pthreads.exports | 18 +- .../test_codesize_minimal_pthreads.funcs | 2 + .../test_codesize_minimal_pthreads.gzsize | 2 +- .../test_codesize_minimal_pthreads.jssize | 2 +- .../test_codesize_minimal_pthreads.size | 2 +- .../test_codesize_minimal_wasmfs.exports | 3 + .../test_codesize_minimal_wasmfs.funcs | 3 + .../test_codesize_minimal_wasmfs.gzsize | 2 +- .../test_codesize_minimal_wasmfs.jssize | 2 +- .../test_codesize_minimal_wasmfs.size | 2 +- .../embind_jsgen_method_pointer_stability.cpp | 4 +- test/other/test_jspi_wildcard.c | 6 +- test/other/test_memory64_proxies.js | 4 +- test/other/test_parseTools.js | 28 +- test/other/test_split_module.post.js | 6 +- 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/return64bit/testbind.js | 4 +- test/return64bit/testbind_bigint.js | 4 +- test/test_browser.py | 2 +- test/test_core.py | 69 ++-- test/test_other.py | 154 +++++---- test/test_override_system_js_lib_symbol.js | 8 +- tools/acorn-optimizer.mjs | 8 +- tools/building.py | 118 ++++++- tools/emscripten.py | 159 +++++---- tools/js_manipulation.py | 2 +- tools/link.py | 96 +++-- tools/maint/gen_sig_info.py | 2 +- tools/settings.py | 1 + tools/shared.py | 15 +- tools/webidl_binder.py | 34 +- 281 files changed, 1659 insertions(+), 1351 deletions(-) diff --git a/emcc.py b/emcc.py index dfe088e7b75c0..8dfd03388a787 100644 --- a/emcc.py +++ b/emcc.py @@ -293,10 +293,6 @@ def apply_user_settings(): setattr(settings, user_key, value) - if key == 'EXPORTED_FUNCTIONS': - # used for warnings in emscripten.py - settings.USER_EXPORTS = settings.EXPORTED_FUNCTIONS.copy() - # TODO(sbc): Remove this legacy way. if key == 'WASM_OBJECT_FILES': settings.LTO = 0 if value else 'full' @@ -1516,7 +1512,7 @@ def in_directory(root, child): def parse_symbol_list_file(contents): """Parse contents of one-symbol-per-line response file. This format can by used - with, for example, -sEXPORTED_FUNCTIONS=@filename and avoids the need for any + with, for example, -sEXPORTS=@filename and avoids the need for any kind of quoting or escaping. """ values = contents.splitlines() diff --git a/site/source/docs/getting_started/FAQ.rst b/site/source/docs/getting_started/FAQ.rst index be6b48b437a1f..4b27443452e70 100644 --- a/site/source/docs/getting_started/FAQ.rst +++ b/site/source/docs/getting_started/FAQ.rst @@ -350,7 +350,7 @@ Here is an example of how to use it: diff --git a/site/source/docs/optimizing/Module-Splitting.rst b/site/source/docs/optimizing/Module-Splitting.rst index c7ec126babb53..c563bf5ca7594 100644 --- a/site/source/docs/optimizing/Module-Splitting.rst +++ b/site/source/docs/optimizing/Module-Splitting.rst @@ -131,7 +131,7 @@ Here’s the function to write the profile and our new main function:: // Get the size of the profile and allocate a buffer for it. var len = __write_profile(0, 0); - var ptr = _malloc(len); + var ptr = malloc(len); // Write the profile data to the buffer. __write_profile(ptr, len); @@ -142,7 +142,7 @@ Here’s the function to write the profile and our new main function:: fs.writeFileSync('profile.data', profile_data); // Free the buffer. - _free(ptr); + free(ptr); }); int main() { diff --git a/site/source/docs/porting/Debugging.rst b/site/source/docs/porting/Debugging.rst index 3a7c3b67bfbe2..473bc3860c7ff 100644 --- a/site/source/docs/porting/Debugging.rst +++ b/site/source/docs/porting/Debugging.rst @@ -287,7 +287,7 @@ Note that you need to emit HTML as in that example, as the memory profiler output is rendered onto the page. To view it, load ``page.html`` in your browser (remember to use a :ref:`local webserver `). The display auto-updates, so you can open the devtools console and run a command like -``_malloc(1024 * 1024)``. That will allocate 1MB of memory, which will then show +``malloc(1024 * 1024)``. That will allocate 1MB of memory, which will then show up on the memory profiler display. .. _debugging-autodebugger: diff --git a/site/source/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.rst b/site/source/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.rst index a94b04918f4a9..93930b7dbead6 100644 --- a/site/source/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.rst +++ b/site/source/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.rst @@ -238,7 +238,7 @@ The parameters you pass to and receive from functions need to be primitive value - JavaScript string ``someString`` can be converted to a ``char *`` using ``ptr = stringToNewUTF8(someString)``. .. note:: The conversion to a pointer allocates memory, which needs to be - freed up via a call to ``free(ptr)`` afterwards (``_free`` in JavaScript side) - + freed up via a call to ``free(ptr)`` afterwards - - ``char *`` received from C/C++ can be converted to a JavaScript string using :js:func:`UTF8ToString`. There are other convenience functions for converting strings and encodings @@ -702,10 +702,10 @@ to process the data, and finally frees the buffer. .. code-block:: javascript - var buf = Module._malloc(myTypedArray.length*myTypedArray.BYTES_PER_ELEMENT); + var buf = Module.malloc(myTypedArray.length*myTypedArray.BYTES_PER_ELEMENT); Module.HEAPU8.set(myTypedArray, buf); Module.ccall('my_function', 'number', ['number'], [buf]); - Module._free(buf); + Module.free(buf); Here ``my_function`` is a C function that receives a single integer parameter (or a pointer, they are both just 32-bit integers for us) and returns an diff --git a/src/Fetch.js b/src/Fetch.js index 27fa8a90f6aaa..92cb360f09912 100644 --- a/src/Fetch.js +++ b/src/Fetch.js @@ -152,7 +152,7 @@ function fetchLoadCachedData(db, fetch, onsuccess, onerror) { #endif // The data pointer malloc()ed here has the same lifetime as the emscripten_fetch_t structure itself has, and is // freed when emscripten_fetch_close() is called. - var ptr = _malloc(len); + var ptr = malloc(len); HEAPU8.set(new Uint8Array(value), ptr); {{{ makeSetValue('fetch', C_STRUCTS.emscripten_fetch_t.data, 'ptr', '*') }}}; writeI53ToI64(fetch + {{{ C_STRUCTS.emscripten_fetch_t.numBytes }}}, len); @@ -329,7 +329,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) { #endif // The data pointer malloc()ed here has the same lifetime as the emscripten_fetch_t structure itself has, and is // freed when emscripten_fetch_close() is called. - ptr = _malloc(ptrLen); + ptr = malloc(ptrLen); HEAPU8.set(new Uint8Array(/** @type{Array} */(xhr.response)), ptr); } {{{ makeSetValue('fetch', C_STRUCTS.emscripten_fetch_t.data, 'ptr', '*') }}} @@ -401,7 +401,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) { assert(onprogress, 'When doing a streaming fetch, you should have an onprogress handler registered to receive the chunks!'); #endif // Allocate byte data in Emscripten heap for the streamed memory block (freed immediately after onprogress call) - ptr = _malloc(ptrLen); + ptr = malloc(ptrLen); HEAPU8.set(new Uint8Array(/** @type{Array} */(xhr.response)), ptr); } {{{ makeSetValue('fetch', C_STRUCTS.emscripten_fetch_t.data, 'ptr', '*') }}} @@ -415,7 +415,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) { if (xhr.statusText) stringToUTF8(xhr.statusText, fetch + {{{ C_STRUCTS.emscripten_fetch_t.statusText }}}, 64); onprogress?.(fetch, xhr, e); if (ptr) { - _free(ptr); + free(ptr); } }; xhr.onreadystatechange = (e) => { diff --git a/src/compiler.mjs b/src/compiler.mjs index e5cd8d29c64f3..f9bb9343681aa 100755 --- a/src/compiler.mjs +++ b/src/compiler.mjs @@ -50,7 +50,7 @@ if (!ALL_INCOMING_MODULE_JS_API.length) { ALL_INCOMING_MODULE_JS_API = INCOMING_MODULE_JS_API; } -EXPORTED_FUNCTIONS = new Set(EXPORTED_FUNCTIONS); +EXPORTS = new Set(EXPORTS); WASM_EXPORTS = new Set(WASM_EXPORTS); SIDE_MODULE_EXPORTS = new Set(SIDE_MODULE_EXPORTS); INCOMING_MODULE_JS_API = new Set(INCOMING_MODULE_JS_API); diff --git a/src/deterministic.js b/src/deterministic.js index 4a99e37487b9b..0627991fcce85 100644 --- a/src/deterministic.js +++ b/src/deterministic.js @@ -26,7 +26,7 @@ Module['thisProgram'] = 'thisProgram'; // for consistency between different buil function hashMemory(id) { var ret = 0; - var len = _sbrk(0); + var len = sbrk(0); for (var i = 0; i < len; i++) { ret = (ret*17 + HEAPU8[i])|0; } diff --git a/src/embind/embind.js b/src/embind/embind.js index 64b6fd437d36a..c79cf45b225b9 100644 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -6,10 +6,10 @@ /*global addToLibrary*/ /*global Module, asm*/ -/*global _malloc, _free, _memcpy*/ +/*global malloc, free, memcpy*/ /*global FUNCTION_TABLE, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64*/ /*global readLatin1String*/ -/*global Emval, emval_handle_array, __emval_decref*/ +/*global Emval, emval_handle_array, _emval_decref*/ /*jslint sub:true*/ /* The symbols 'fromWireType' and 'toWireType' must be accessed via array notation to be closure-safe since craftInvokerFunction crafts functions as strings that can't be closured. */ // -- jshint doesn't understand library syntax, so we need to specifically tell it about the symbols we define @@ -46,7 +46,7 @@ var LibraryEmbind = { name: 'emscripten::val', 'fromWireType': (handle) => { var rv = Emval.toValue(handle); - __emval_decref(handle); + _emval_decref(handle); return rv; }, 'toWireType': (destructors, value) => Emval.toHandle(value), @@ -536,7 +536,7 @@ var LibraryEmbind = { str = a.join(''); } - _free(value); + free(value); return str; }, @@ -558,7 +558,7 @@ var LibraryEmbind = { } // assumes POINTER_SIZE alignment - var base = _malloc({{{ POINTER_SIZE }}} + length + 1); + var base = malloc({{{ POINTER_SIZE }}} + length + 1); var ptr = base + {{{ POINTER_SIZE }}}; {{{ makeSetValue('base', '0', 'length', SIZE_TYPE) }}}; if (stdStringIsUTF8 && valueIsOfTypeString) { @@ -568,7 +568,7 @@ var LibraryEmbind = { for (var i = 0; i < length; ++i) { var charCode = value.charCodeAt(i); if (charCode > 255) { - _free(ptr); + free(ptr); throwBindingError('String has UTF-16 code units that do not fit in 8 bits'); } HEAPU8[ptr + i] = charCode; @@ -581,14 +581,14 @@ var LibraryEmbind = { } if (destructors !== null) { - destructors.push(_free, base); + destructors.push(free, base); } return base; }, argPackAdvance: GenericWireTypeSize, 'readValueFromPointer': readPointer, destructorFunction(ptr) { - _free(ptr); + free(ptr); }, }); }, @@ -636,7 +636,7 @@ var LibraryEmbind = { } } - _free(value); + free(value); return str; }, @@ -647,20 +647,20 @@ var LibraryEmbind = { // assumes POINTER_SIZE alignment var length = lengthBytesUTF(value); - var ptr = _malloc({{{ POINTER_SIZE }}} + length + charSize); + var ptr = malloc({{{ POINTER_SIZE }}} + length + charSize); {{{ makeSetValue('ptr', '0', 'length / charSize', SIZE_TYPE) }}}; encodeString(value, ptr + {{{ POINTER_SIZE }}}, length + charSize); if (destructors !== null) { - destructors.push(_free, ptr); + destructors.push(free, ptr); } return ptr; }, argPackAdvance: GenericWireTypeSize, 'readValueFromPointer': readPointer, destructorFunction(ptr) { - _free(ptr); + free(ptr); } }); }, @@ -671,7 +671,7 @@ var LibraryEmbind = { _embind_register_user_type__deps: ['_embind_register_emval'], _embind_register_user_type: (rawType, name) => { - __embind_register_emval(rawType); + _embind_register_emval(rawType); }, _embind_register_optional__deps: ['$registerType', '$EmValOptionalType'], diff --git a/src/embind/embind_shared.js b/src/embind/embind_shared.js index 2f630fd378466..a2c4291229460 100644 --- a/src/embind/embind_shared.js +++ b/src/embind/embind_shared.js @@ -117,9 +117,9 @@ var LibraryEmbindShared = { }, $getTypeName__deps: ['$readLatin1String', '__getTypeName', 'free'], $getTypeName: (type) => { - var ptr = ___getTypeName(type); + var ptr = __getTypeName(type); var rv = readLatin1String(ptr); - _free(ptr); + free(ptr); return rv; }, $getFunctionName__deps: [], diff --git a/src/embind/emval.js b/src/embind/emval.js index 41f5ca5656924..f84f78a5ce7ff 100644 --- a/src/embind/emval.js +++ b/src/embind/emval.js @@ -12,7 +12,7 @@ /*jslint sub:true*/ /* The symbols 'fromWireType' and 'toWireType' must be accessed via array notation to be closure-safe since craftInvokerFunction crafts functions as strings that can't be closured. */ // -- jshint doesn't understand library syntax, so we need to mark the symbols exposed here -/*global getStringOrSymbol, emval_freelist, emval_handles, Emval, __emval_unregister, count_emval_handles, emval_symbols, __emval_decref*/ +/*global getStringOrSymbol, emval_freelist, emval_handles, Emval, _emval_unregister, count_emval_handles, emval_symbols, _emval_decref*/ /*global emval_addMethodCaller, emval_methodCallers, addToLibrary, global, emval_lookupTypes, makeLegalFunctionName*/ /*global emval_get_global*/ @@ -116,7 +116,7 @@ var LibraryEmVal = { _emval_run_destructors: (handle) => { var destructors = Emval.toValue(handle); runDestructors(destructors); - __emval_decref(handle); + _emval_decref(handle); }, _emval_new_array__deps: ['$Emval'], @@ -470,7 +470,7 @@ 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_resume(awaiterPtr, Emval.toHandle(result)); }); }, @@ -483,7 +483,7 @@ var LibraryEmVal = { // user-friendly error message and stacktrace from C++ exception // if EXCEPTION_STACK_TRACES is enabled and numeric exception // with metadata optimised out otherwise. - ___cxa_rethrow(); + __cxa_rethrow(); } catch (e) { // But catch it so that it rejects the promise instead of throwing // in an unpredictable place during async execution. diff --git a/src/jsifier.mjs b/src/jsifier.mjs index b9a4ae1a5f4e0..6ae094901476c 100644 --- a/src/jsifier.mjs +++ b/src/jsifier.mjs @@ -46,12 +46,8 @@ const extraLibraryFuncs = []; // the same namespace as function pointers in general). const proxiedFunctionTable = []; -// Mangles the given C/JS side function name to assembly level function name (adds an underscore) -function mangleCSymbolName(f) { - if (f === '__main_argc_argv') { - f = 'main'; - } - return f[0] == '$' ? f.substr(1) : '_' + f; +function getOutputName(sym) { + return sym[0] == '$' ? sym.substr(1) : sym; } // Splits out items that pass filter. Returns also the original sans the filtered @@ -178,7 +174,7 @@ export function runJSify(symbolsOnly) { for (const key of Object.keys(LibraryManager.library)) { if (!isDecorator(key)) { - if (INCLUDE_FULL_LIBRARY || EXPORTED_FUNCTIONS.has(mangleCSymbolName(key))) { + if (INCLUDE_FULL_LIBRARY || EXPORTS.has(getOutputName(key))) { symbolsNeeded.push(key); } } @@ -264,7 +260,7 @@ ${argConversions} }); } - function processLibraryFunction(snippet, symbol, mangled, deps, isStub) { + function processLibraryFunction(snippet, symbol, outputName, deps, isStub) { // It is possible that when printing the function as a string on Windows, // the js interpreter we are in returns the string with Windows line endings // \r\n. This is undesirable, since line endings are managed in the form \n @@ -293,7 +289,7 @@ ${argConversions} } return `\ function(${args}) { - if (runtimeDebug) err("[library call:${mangled}: " + Array.prototype.slice.call(arguments).map(prettyPrint) + "]"); + if (runtimeDebug) err("[library call:${outputName}: " + Array.prototype.slice.call(arguments).map(prettyPrint) + "]"); ${run_func} if (runtimeDebug) err(" [ return:" + prettyPrint(ret)); return ret; @@ -351,12 +347,12 @@ ${body} snippet, (args, body) => ` function(${args}) { - assert(!ENVIRONMENT_IS_WASM_WORKER, "Attempted to call proxied function '${mangled}' in a Wasm Worker, but in Wasm Worker enabled builds, proxied function architecture is not available!"); + assert(!ENVIRONMENT_IS_WASM_WORKER, "Attempted to call proxied function '${outputName}' in a Wasm Worker, but in Wasm Worker enabled builds, proxied function architecture is not available!"); ${body} }\n`, ); } - proxiedFunctionTable.push(mangled); + proxiedFunctionTable.push(outputName); } } @@ -434,7 +430,7 @@ function(${args}) { // Without WASM_BIGINT functions that return i64 depend on setTempRet0 // to return the upper 32-bits of the result. // See makeReturn64 in parseTools.py. - deps.push('setTempRet0'); + deps.push('$setTempRet0'); } let isAsyncFunction = false; @@ -467,7 +463,7 @@ function(${args}) { // will resolve the correct symbol at runtime, or assert if its missing. let isStub = false; - const mangled = mangleCSymbolName(symbol); + const outputName = getOutputName(symbol); if (!LibraryManager.library.hasOwnProperty(symbol)) { const isWeakImport = WEAK_IMPORTS.has(symbol); @@ -488,8 +484,7 @@ function(${args}) { 'To disable errors for undefined symbols use `-sERROR_ON_UNDEFINED_SYMBOLS=0`', ); warnOnce( - mangled + - ' may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library', + outputName + ' may need to be added to EXPORTS if it arrives from a system library', ); } else if (VERBOSE || WARN_ON_UNDEFINED_SYMBOLS) { warn(msg); @@ -526,7 +521,7 @@ function(${args}) { } } - librarySymbols.push(mangled); + librarySymbols.push(symbol); const original = LibraryManager.library[symbol]; let snippet = original; @@ -549,7 +544,7 @@ function(${args}) { // make ourselves equal to it. This avoid having duplicate // functions with identical content. aliasTarget = snippet; - snippet = mangleCSymbolName(aliasTarget); + snippet = getOutputName(aliasTarget); deps.push(aliasTarget); } } @@ -558,7 +553,7 @@ function(${args}) { addImplicitDeps(snippet, deps); } else if (typeof snippet == 'function') { isFunction = true; - snippet = processLibraryFunction(snippet, symbol, mangled, deps, isStub); + snippet = processLibraryFunction(snippet, symbol, outputName, deps, isStub); addImplicitDeps(snippet, deps); } @@ -609,28 +604,31 @@ function(${args}) { } else { contentText = snippet; // Regular JS function that will be executed in the context of the calling thread. } - // Give the function the correct (mangled) name. Overwrite it if it's + // Give the function the correct name. Overwrite it if it's // already named. This must happen after the last call to // modifyJSFunction which could have changed or removed the name. if (contentText.match(/^\s*([^}]*)\s*=>/s)) { // Handle arrow functions - contentText = `var ${mangled} = ` + contentText + ';'; + contentText = `var ${outputName} = ` + contentText + ';'; } else if (contentText.startsWith('class ')) { - contentText = contentText.replace(/^class /, `class ${mangled} `); + contentText = contentText.replace(/^class /, `class ${outputName} `); } else { // Handle regular (non-arrow) functions - contentText = contentText.replace(/function(?:\s+([^(]+))?\s*\(/, `function ${mangled}(`); + contentText = contentText.replace( + /function(?:\s+([^(]+))?\s*\(/, + `function ${outputName}(`, + ); } } else if (typeof snippet == 'string' && snippet.startsWith(';')) { // In JS libraries // foo: ';[code here verbatim]' // emits // 'var foo;[code here verbatim];' - contentText = 'var ' + mangled + snippet; + contentText = 'var ' + outputName + snippet; if (snippet[snippet.length - 1] != ';' && snippet[snippet.length - 1] != '}') contentText += ';'; } else if (typeof snippet == 'undefined') { - contentText = `var ${mangled};`; + contentText = `var ${outputName};`; } else { // In JS libraries // foo: '=[value]' @@ -639,15 +637,17 @@ function(${args}) { if (typeof snippet == 'string' && snippet[0] == '=') { snippet = snippet.substr(1); } - contentText = `var ${mangled} = ${snippet};`; + if (snippet != outputName) { + contentText = `var ${outputName} = ${snippet};`; + } } // asm module exports are done in emscripten.py, after the asm module is ready. Here // we also export library methods as necessary. - if ((EXPORT_ALL || EXPORTED_FUNCTIONS.has(mangled)) && !isStub) { + if ((EXPORT_ALL || EXPORTS.has(outputName)) && !isStub) { if (MODULARIZE === 'instance') { - contentText += `\n__exp_${mangled} = ${mangled};`; + contentText += `\n__exp_${outputName} = ${outputName};`; } else { - contentText += `\nModule['${mangled}'] = ${mangled};`; + contentText += `\nModule['${outputName}'] = ${outputName};`; } } // Relocatable code needs signatures to create proper wrappers. @@ -655,13 +655,13 @@ function(${args}) { if (!WASM_BIGINT) { sig = sig[0].replace('j', 'i') + sig.slice(1).replace(/j/g, 'ii'); } - contentText += `\n${mangled}.sig = '${sig}';`; + contentText += `\n${outputName}.sig = '${sig}';`; } if (ASYNCIFY && isAsyncFunction) { - contentText += `\n${mangled}.isAsync = true;`; + contentText += `\n${outputName}.isAsync = true;`; } if (isStub) { - contentText += `\n${mangled}.stub = true;`; + contentText += `\n${outputName}.stub = true;`; if (ASYNCIFY && MAIN_MODULE) { contentText += `\nasyncifyStubs['${symbol}'] = undefined;`; } @@ -678,7 +678,7 @@ function(${args}) { } if (EMIT_TSD) { - LibraryManager.libraryDefinitions[mangled] = { + LibraryManager.libraryDefinitions[outputName] = { docs: docs ?? null, snippet: snippet ?? null, }; diff --git a/src/library.js b/src/library.js index c7f26d2919a5c..06e80ced3f279 100644 --- a/src/library.js +++ b/src/library.js @@ -23,21 +23,21 @@ addToLibrary({ // JS aliases for native stack manipulation functions and tempret handling $stackSave__deps: ['emscripten_stack_get_current'], - $stackSave: () => _emscripten_stack_get_current(), + $stackSave: () => emscripten_stack_get_current(), $stackRestore__deps: ['_emscripten_stack_restore'], - $stackRestore: (val) => __emscripten_stack_restore(val), + $stackRestore: (val) => _emscripten_stack_restore(val), $stackAlloc__deps: ['_emscripten_stack_alloc'], - $stackAlloc: (sz) => __emscripten_stack_alloc(sz), + $stackAlloc: (sz) => _emscripten_stack_alloc(sz), $getTempRet0__deps: ['_emscripten_tempret_get'], - $getTempRet0: (val) => __emscripten_tempret_get(), + $getTempRet0: (val) => _emscripten_tempret_get(), $setTempRet0__deps: ['_emscripten_tempret_set'], - $setTempRet0: (val) => __emscripten_tempret_set(val), + $setTempRet0: (val) => _emscripten_tempret_set(val), // Aliases that allow legacy names (without leading $) for the // functions to continue to work in `__deps` entries. stackAlloc: '$stackAlloc', stackSave: '$stackSave', - stackRestore: '$stackSave', + stackRestore: '$stackRestore', setTempRet0: '$setTempRet0', getTempRet0: '$getTempRet0', @@ -65,10 +65,17 @@ addToLibrary({ }, #if SAFE_HEAP - // Trivial wrappers around runtime functions that make these symbols available - // to native code. - segfault: '=segfault', - alignfault: '=alignfault', + segfault: () => { + abort('segmentation fault'); + }, + + alignfault: () => { +#if SAFE_HEAP == 1 + abort('alignment fault'); +#else + warnOnce('alignment fault'); +#endif + }, #endif // ========================================================================== @@ -103,7 +110,7 @@ addToLibrary({ assert(!implicit); #endif #if PTHREADS_DEBUG - dbg(`Pthread ${ptrToString(_pthread_self())} called exit(${status}), posting exitOnMainThread.`); + dbg(`Pthread ${ptrToString(pthread_self())} called exit(${status}), posting exitOnMainThread.`); #endif // When running in a pthread we propagate the exit back to the main thread // where it can decide if the whole process should be shut down or not. @@ -134,7 +141,7 @@ addToLibrary({ } #endif // ASSERTIONS - _proc_exit(status); + proc_exit(status); }, #endif @@ -250,7 +257,7 @@ addToLibrary({ #if EMSCRIPTEN_TRACING // Report old layout one last time - _emscripten_trace_report_memory_layout(); + emscripten_trace_report_memory_layout(); #endif // Memory resize rules: @@ -302,11 +309,11 @@ addToLibrary({ var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), {{{ WASM_PAGE_SIZE }}})); #if ASSERTIONS == 2 - var t0 = _emscripten_get_now(); + var t0 = emscripten_get_now(); #endif var replacement = growMemory(newSize); #if ASSERTIONS == 2 - var t1 = _emscripten_get_now(); + var t1 = emscripten_get_now(); dbg(`Heap resize call from ${oldSize} to ${newSize} took ${(t1 - t0)} msecs. Success: ${!!replacement}`); #endif if (replacement) { @@ -317,7 +324,7 @@ addToLibrary({ #if EMSCRIPTEN_TRACING traceLogMessage("Emscripten", `Enlarging memory arrays from ${oldSize} to ${newSize}`); // And now report the new layout - _emscripten_trace_report_memory_layout(); + emscripten_trace_report_memory_layout(); #endif return true; } @@ -452,8 +459,8 @@ addToLibrary({ $setStackLimits__deps: ['$setDylinkStackLimits'], #endif $setStackLimits: () => { - var stackLow = _emscripten_stack_get_base(); - var stackHigh = _emscripten_stack_get_end(); + var stackLow = emscripten_stack_get_base(); + var stackHigh = emscripten_stack_get_end(); #if RUNTIME_DEBUG dbg(`setStackLimits: ${ptrToString(stackLow)}, ${ptrToString(stackHigh)}`); #endif @@ -462,7 +469,7 @@ addToLibrary({ // that each need to have their stack limits set. setDylinkStackLimits(stackLow, stackHigh); #else - ___set_stack_limits(stackLow, stackHigh); + __set_stack_limits(stackLow, stackHigh); #endif }, #endif @@ -660,7 +667,7 @@ addToLibrary({ $strError: (errno) => errno + '', #else $strError__deps: ['strerror', '$UTF8ToString'], - $strError: (errno) => UTF8ToString(_strerror(errno)), + $strError: (errno) => UTF8ToString(strerror(errno)), #endif #if PROXY_POSIX_SOCKETS == 0 @@ -721,7 +728,7 @@ addToLibrary({ offset = z-1; } else { // parse hex to field to 16-bit value and write it in network byte-order - parts[w+offset] = _htons(parseInt(words[w],16)); + parts[w+offset] = htons(parseInt(words[w],16)); } } else { // parsed IPv4 words @@ -827,7 +834,7 @@ addToLibrary({ } } // converts 16-bit words from big-endian to little-endian before converting to hex string - str += Number(_ntohs(parts[word] & 0xffff)).toString(16); + str += Number(ntohs(parts[word] & 0xffff)).toString(16); str += word < 7 ? ":" : ""; } return str; @@ -837,7 +844,7 @@ addToLibrary({ $readSockaddr: (sa, salen) => { // family / port offsets are common to both sockaddr_in and sockaddr_in6 var family = {{{ makeGetValue('sa', C_STRUCTS.sockaddr_in.sin_family, 'i16') }}}; - var port = _ntohs({{{ makeGetValue('sa', C_STRUCTS.sockaddr_in.sin_port, 'u16') }}}); + var port = ntohs({{{ makeGetValue('sa', C_STRUCTS.sockaddr_in.sin_port, 'u16') }}}); var addr; switch (family) { @@ -878,7 +885,7 @@ addToLibrary({ } {{{ makeSetValue('sa', C_STRUCTS.sockaddr_in.sin_family, 'family', 'i16') }}}; {{{ makeSetValue('sa', C_STRUCTS.sockaddr_in.sin_addr.s_addr, 'addr', 'i32') }}}; - {{{ makeSetValue('sa', C_STRUCTS.sockaddr_in.sin_port, '_htons(port)', 'i16') }}}; + {{{ makeSetValue('sa', C_STRUCTS.sockaddr_in.sin_port, 'htons(port)', 'i16') }}}; break; case {{{ cDefs.AF_INET6 }}}: addr = inetPton6(addr); @@ -891,7 +898,7 @@ addToLibrary({ {{{ makeSetValue('sa', C_STRUCTS.sockaddr_in6.sin6_addr.__in6_union.__s6_addr+4, 'addr[1]', 'i32') }}}; {{{ makeSetValue('sa', C_STRUCTS.sockaddr_in6.sin6_addr.__in6_union.__s6_addr+8, 'addr[2]', 'i32') }}}; {{{ makeSetValue('sa', C_STRUCTS.sockaddr_in6.sin6_addr.__in6_union.__s6_addr+12, 'addr[3]', 'i32') }}}; - {{{ makeSetValue('sa', C_STRUCTS.sockaddr_in6.sin6_port, '_htons(port)', 'i16') }}}; + {{{ makeSetValue('sa', C_STRUCTS.sockaddr_in6.sin6_port, 'htons(port)', 'i16') }}}; break; default: return {{{ cDefs.EAFNOSUPPORT }}}; @@ -982,11 +989,11 @@ addToLibrary({ addr = family === {{{ cDefs.AF_INET6 }}} ? inetNtop6(addr) : inetNtop4(addr); - sa = _malloc(salen); + sa = malloc(salen); errno = writeSockaddr(sa, family, addr, port); assert(!errno); - ai = _malloc({{{ C_STRUCTS.addrinfo.__size__ }}}); + ai = malloc({{{ C_STRUCTS.addrinfo.__size__ }}}); {{{ makeSetValue('ai', C_STRUCTS.addrinfo.ai_family, 'family', 'i32') }}}; {{{ makeSetValue('ai', C_STRUCTS.addrinfo.ai_socktype, 'type', 'i32') }}}; {{{ makeSetValue('ai', C_STRUCTS.addrinfo.ai_protocol, 'proto', 'i32') }}}; @@ -1065,7 +1072,7 @@ addToLibrary({ } if ((flags & {{{ cDefs.AI_PASSIVE }}}) === 0) { if (family === {{{ cDefs.AF_INET }}}) { - addr = _htonl({{{ cDefs.INADDR_LOOPBACK }}}); + addr = htonl({{{ cDefs.INADDR_LOOPBACK }}}); } else { addr = [0, 0, 0, _htonl(1)]; } @@ -1086,7 +1093,7 @@ addToLibrary({ family = {{{ cDefs.AF_INET }}}; } else if (family === {{{ cDefs.AF_INET6 }}} && (flags & {{{ cDefs.AI_V4MAPPED }}})) { - addr = [0, 0, _htonl(0xffff), addr]; + addr = [0, 0, htonl(0xffff), addr]; family = {{{ cDefs.AF_INET6 }}}; } else { return {{{ cDefs.EAI_NONAME }}}; @@ -1120,7 +1127,7 @@ addToLibrary({ if (family === {{{ cDefs.AF_UNSPEC }}}) { family = {{{ cDefs.AF_INET }}}; } else if (family === {{{ cDefs.AF_INET6 }}}) { - addr = [0, 0, _htonl(0xffff), addr]; + addr = [0, 0, htonl(0xffff), addr]; } ai = allocaddrinfo(family, type, proto, null, addr, port); {{{ makeSetValue('out', '0', 'ai', '*') }}}; @@ -1185,24 +1192,24 @@ addToLibrary({ // Allocate and populate a protoent structure given a name, protocol number and array of aliases function allocprotoent(name, proto, aliases) { // write name into buffer - var nameBuf = _malloc(name.length + 1); + var nameBuf = malloc(name.length + 1); stringToAscii(name, nameBuf); // write aliases into buffer var j = 0; var length = aliases.length; - var aliasListBuf = _malloc((length + 1) * 4); // Use length + 1 so we have space for the terminating NULL ptr. + var aliasListBuf = malloc((length + 1) * 4); // Use length + 1 so we have space for the terminating NULL ptr. for (var i = 0; i < length; i++, j += 4) { var alias = aliases[i]; - var aliasBuf = _malloc(alias.length + 1); + var aliasBuf = malloc(alias.length + 1); stringToAscii(alias, aliasBuf); {{{ makeSetValue('aliasListBuf', 'j', 'aliasBuf', POINTER_TYPE) }}}; } {{{ makeSetValue('aliasListBuf', 'j', '0', POINTER_TYPE) }}}; // Terminating NULL pointer. // generate protoent - var pe = _malloc({{{ C_STRUCTS.protoent.__size__ }}}); + var pe = malloc({{{ C_STRUCTS.protoent.__size__ }}}); {{{ makeSetValue('pe', C_STRUCTS.protoent.p_name, 'nameBuf', POINTER_TYPE) }}}; {{{ makeSetValue('pe', C_STRUCTS.protoent.p_aliases, 'aliasListBuf', POINTER_TYPE) }}}; {{{ makeSetValue('pe', C_STRUCTS.protoent.p_proto, 'proto', 'i32') }}}; @@ -1222,7 +1229,7 @@ addToLibrary({ map['udp'] = map['17'] = entry; } - _setprotoent.index = 0; + setprotoent.index = 0; }, endprotoent: () => { @@ -1234,10 +1241,10 @@ addToLibrary({ getprotoent: (number) => { // struct protoent *getprotoent(void); // reads the next entry from the protocols 'database' or return NULL if 'eof' - if (_setprotoent.index === Protocols.list.length) { + if (setprotoent.index === Protocols.list.length) { return 0; } - var result = Protocols.list[_setprotoent.index++]; + var result = Protocols.list[setprotoent.index++]; return result; }, @@ -1245,7 +1252,7 @@ addToLibrary({ getprotobyname: (name) => { // struct protoent *getprotobyname(const char *); name = UTF8ToString(name); - _setprotoent(true); + setprotoent(true); var result = Protocols.map[name]; return result; }, @@ -1253,7 +1260,7 @@ addToLibrary({ getprotobynumber__deps: ['setprotoent', '$Protocols'], getprotobynumber: (number) => { // struct protoent *getprotobynumber(int proto); - _setprotoent(true); + setprotoent(true); var result = Protocols.map[number]; return result; }, @@ -1317,7 +1324,7 @@ addToLibrary({ #if RUNTIME_DEBUG dbg(`itimer fired: ${which}`); #endif - callUserCallback(() => __emscripten_timeout(which, _emscripten_get_now())); + callUserCallback(() => _emscripten_timeout(which, emscripten_get_now())); }, timeout_ms); timers[which] = { id, timeout_ms }; return 0; @@ -1350,12 +1357,12 @@ addToLibrary({ return 0; } s += ''; - var me = _emscripten_run_script_string; + var me = emscripten_run_script_string; var len = lengthBytesUTF8(s); if (!me.bufferSize || me.bufferSize < len+1) { - if (me.bufferSize) _free(me.buffer); + if (me.bufferSize) free(me.buffer); me.bufferSize = len+1; - me.buffer = _malloc(me.bufferSize); + me.buffer = malloc(me.bufferSize); } stringToUTF8(s, me.buffer, me.bufferSize); return me.buffer; @@ -1381,12 +1388,12 @@ addToLibrary({ // Audio Worklets enabled, do a dynamic check for its presence. if (typeof performance != 'undefined' && {{{ getPerformanceNow() }}}) { #if PTHREADS - _emscripten_get_now = () => performance.timeOrigin + {{{ getPerformanceNow() }}}(); + emscripten_get_now = () => performance.timeOrigin + {{{ getPerformanceNow() }}}(); #else - _emscripten_get_now = () => {{{ getPerformanceNow() }}}(); + emscripten_get_now = () => {{{ getPerformanceNow() }}}(); #endif } else { - _emscripten_get_now = Date.now; + emscripten_get_now = Date.now; } `, #else @@ -1490,7 +1497,7 @@ addToLibrary({ var ret = getCompilerSetting(name); if (typeof ret == 'number' || typeof ret == 'boolean') return ret; - var cache = _emscripten_get_compiler_setting.cache ??= {}; + var cache = emscripten_get_compiler_setting.cache ??= {}; var fullret = cache[name]; if (fullret) return fullret; return cache[name] = stringToNewUTF8(ret); @@ -1519,21 +1526,21 @@ addToLibrary({ ], $withBuiltinMalloc__docs: '/** @suppress{checkTypes} */', $withBuiltinMalloc: (func) => { - var prev_malloc = typeof _malloc != 'undefined' ? _malloc : undefined; - var prev_calloc = typeof _calloc != 'undefined' ? _calloc : undefined; - var prev_memalign = typeof _memalign != 'undefined' ? _memalign : undefined; - var prev_free = typeof _free != 'undefined' ? _free : undefined; - _malloc = _emscripten_builtin_malloc; - _calloc = _emscripten_builtin_calloc; - _memalign = _emscripten_builtin_memalign; - _free = _emscripten_builtin_free; + var prev_malloc = typeof malloc != 'undefined' ? malloc : undefined; + var prev_calloc = typeof calloc != 'undefined' ? calloc : undefined; + var prev_memalign = typeof memalign != 'undefined' ? memalign : undefined; + var prev_free = typeof free != 'undefined' ? free : undefined; + malloc = emscripten_builtin_malloc; + calloc = emscripten_builtin_calloc; + memalign = emscripten_builtin_memalign; + free = emscripten_builtin_free; try { return func(); } finally { - _malloc = prev_malloc; - _calloc = prev_calloc; - _memalign = prev_memalign; - _free = prev_free; + malloc = prev_malloc; + calloc = prev_calloc; + memalign = prev_memalign; + free = prev_free; } }, @@ -1666,7 +1673,9 @@ addToLibrary({ #if !DECLARE_ASM_MODULE_EXPORTS // When DECLARE_ASM_MODULE_EXPORTS is not set we export native symbols // at runtime rather than statically in JS code. +#if MANGLED_SYMBOLS $exportWasmSymbols__deps: ['$asmjsMangle'], +#endif $exportWasmSymbols: (wasmExports) => { #if ENVIRONMENT_MAY_BE_NODE && ENVIRONMENT_MAY_BE_WEB var global_object = (typeof process != "undefined" ? global : this); @@ -1676,12 +1685,20 @@ addToLibrary({ var global_object = this; #endif - for (var __exportedFunc in wasmExports) { - var jsname = asmjsMangle(__exportedFunc); + for (var sym in wasmExports) { + var name = sym == '__main_argc_argv' ? 'main' : sym; #if MINIMAL_RUNTIME - global_object[jsname] = wasmExports[__exportedFunc]; + global_object[name] = wasmExports[sym]; #else - global_object[jsname] = Module[jsname] = wasmExports[__exportedFunc]; + global_object[name] = Module[sym] = wasmExports[sym]; +#endif +#if MANGLED_SYMBOLS + var mangled = asmjsMangle(name); +#if MINIMAL_RUNTIME + global_object[mangled] = wasmExports[sym]; +#else + global_object[mangled] = Module[mangled] = wasmExports[sym]; +#endif #endif } @@ -1720,7 +1737,7 @@ addToLibrary({ _Unwind_RaiseException__deps: ['__cxa_throw'], _Unwind_RaiseException: (ex) => { err('Warning: _Unwind_RaiseException is not correctly implemented'); - return ___cxa_throw(ex, 0, 0); + return __cxa_throw(ex, 0, 0); }, _Unwind_DeleteException: (ex) => err('TODO: Unwind_DeleteException'), @@ -1732,8 +1749,8 @@ addToLibrary({ // Used by wasm-emscripten-finalize to implement STACK_OVERFLOW_CHECK __handle_stack_overflow__deps: ['emscripten_stack_get_base', 'emscripten_stack_get_end', '$ptrToString'], __handle_stack_overflow: (requested) => { - var base = _emscripten_stack_get_base(); - var end = _emscripten_stack_get_end(); + var base = emscripten_stack_get_base(); + var end = emscripten_stack_get_end(); abort(`stack overflow (Attempt to set SP to ${ptrToString(requested)}` + `, with stack limits [${ptrToString(end)} - ${ptrToString(base)}` + ']). If you require more stack space build with -sSTACK_SIZE='); @@ -1973,8 +1990,8 @@ addToLibrary({ #if !EXIT_RUNTIME && ASSERTIONS warnOnce('emscripten_force_exit cannot actually shut down the runtime, as the build does not have EXIT_RUNTIME set'); #endif - __emscripten_runtime_keepalive_clear(); - _exit(status); + _emscripten_runtime_keepalive_clear(); + exit(status); }, emscripten_out: (str) => out(UTF8ToString(str)), @@ -2055,7 +2072,7 @@ addToLibrary({ #if STACK_OVERFLOW_CHECK checkStackCookie(); if (e instanceof WebAssembly.RuntimeError) { - if (_emscripten_stack_get_current() <= 0) { + if (emscripten_stack_get_current() <= 0) { err('Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to {{{ STACK_SIZE }}})'); } } @@ -2159,10 +2176,10 @@ addToLibrary({ #endif try { #if PTHREADS - if (ENVIRONMENT_IS_PTHREAD) __emscripten_thread_exit(EXITSTATUS); + if (ENVIRONMENT_IS_PTHREAD) _emscripten_thread_exit(EXITSTATUS); else #endif - _exit(EXITSTATUS); + exit(EXITSTATUS); } catch (e) { handleException(e); } @@ -2175,9 +2192,6 @@ addToLibrary({ #endif // MINIMAL_RUNTIME $asmjsMangle: (x) => { - if (x == '__main_argc_argv') { - x = 'main'; - } return x.startsWith('dynCall_') ? x : '_' + x; }, @@ -2216,7 +2230,7 @@ addToLibrary({ $mmapAlloc: (size) => { #if hasExportedSymbol('emscripten_builtin_memalign') size = alignMemory(size, {{{ WASM_PAGE_SIZE }}}); - var ptr = _emscripten_builtin_memalign({{{ WASM_PAGE_SIZE }}}, size); + var ptr = emscripten_builtin_memalign({{{ WASM_PAGE_SIZE }}}, size); if (ptr) zeroMemory(ptr, size); return ptr; #elif ASSERTIONS @@ -2431,7 +2445,7 @@ function wrapSyscallFunction(x, library, isWasi) { // In PURE_WASI mode we can't assume the wasm binary was built by emscripten // and politely notify us on memory growth. Instead we have to check for // possible memory growth on each syscall. - var pre = '\nif (!HEAPU8.byteLength) _emscripten_notify_memory_growth(0);\n' + var pre = '\nif (!HEAPU8.byteLength) emscripten_notify_memory_growth(0);\n' library[x + '__deps'].push('emscripten_notify_memory_growth'); #else var pre = ''; diff --git a/src/library_async.js b/src/library_async.js index 4ada1dccaa1c5..06e89798771d6 100644 --- a/src/library_async.js +++ b/src/library_async.js @@ -214,7 +214,7 @@ addToLibrary({ #endif {{{ runtimeKeepalivePush(); }}} // Keep the runtime alive so that a re-wind can be done later. - runAndAbortIfError(_asyncify_stop_unwind); + runAndAbortIfError(asyncify_stop_unwind); if (typeof Fibers != 'undefined') { Fibers.trampoline(); } @@ -240,7 +240,7 @@ addToLibrary({ // The Asyncify ABI only interprets the first two fields, the rest is for the runtime. // We also embed a stack in the same memory region here, right next to the structure. // This struct is also defined as asyncify_data_t in emscripten/fiber.h - var ptr = _malloc({{{ C_STRUCTS.asyncify_data_s.__size__ }}} + Asyncify.StackSize); + var ptr = malloc({{{ C_STRUCTS.asyncify_data_s.__size__ }}} + Asyncify.StackSize); Asyncify.setDataHeader(ptr, ptr + {{{ C_STRUCTS.asyncify_data_s.__size__ }}}, Asyncify.StackSize); Asyncify.setDataRewindFunc(ptr); return ptr; @@ -342,7 +342,7 @@ addToLibrary({ dbg(`ASYNCIFY: start rewind ${Asyncify.currData}`); #endif Asyncify.state = Asyncify.State.Rewinding; - runAndAbortIfError(() => _asyncify_start_rewind(Asyncify.currData)); + runAndAbortIfError(() => asyncify_start_rewind(Asyncify.currData)); if (typeof MainLoop != 'undefined' && MainLoop.func) { MainLoop.resume(); } @@ -394,7 +394,7 @@ addToLibrary({ if (typeof MainLoop != 'undefined' && MainLoop.func) { MainLoop.pause(); } - runAndAbortIfError(() => _asyncify_start_unwind(Asyncify.currData)); + runAndAbortIfError(() => asyncify_start_unwind(Asyncify.currData)); } } else if (Asyncify.state === Asyncify.State.Rewinding) { // Stop a resume. @@ -402,8 +402,8 @@ addToLibrary({ dbg('ASYNCIFY: stop rewind'); #endif Asyncify.state = Asyncify.State.Normal; - runAndAbortIfError(_asyncify_stop_rewind); - _free(Asyncify.currData); + runAndAbortIfError(asyncify_stop_rewind); + free(Asyncify.currData); Asyncify.currData = null; // Call all sleep callbacks now that the sleep-resume is all done. Asyncify.sleepCallbacks.forEach(callUserCallback); @@ -472,7 +472,7 @@ addToLibrary({ return Asyncify.handleSleep((wakeUp) => { asyncLoad(UTF8ToString(url), (byteArray) => { // can only allocate the buffer after the wakeUp, not during an asyncing - var buffer = _malloc(byteArray.length); // must be freed by caller! + var buffer = malloc(byteArray.length); // must be freed by caller! HEAPU8.set(byteArray, buffer); {{{ makeSetValue('pbuffer', 0, 'buffer', '*') }}}; {{{ makeSetValue('pnum', 0, 'byteArray.length', 'i32') }}}; @@ -512,8 +512,8 @@ addToLibrary({ createWasm(); }), - _load_secondary_module__sig: 'v', - _load_secondary_module: async function() { + __load_secondary_module__sig: 'v', + __load_secondary_module: async function() { // Mark the module as loading for the wasm module (so it doesn't try to load it again). wasmExports['load_secondary_module_status'].value = 1; var imports = {'primary': wasmExports}; @@ -548,10 +548,10 @@ addToLibrary({ finishContextSwitch(newFiber) { var stack_base = {{{ makeGetValue('newFiber', C_STRUCTS.emscripten_fiber_s.stack_base, '*') }}}; var stack_max = {{{ makeGetValue('newFiber', C_STRUCTS.emscripten_fiber_s.stack_limit, '*') }}}; - _emscripten_stack_set_limits(stack_base, stack_max); + emscripten_stack_set_limits(stack_base, stack_max); #if STACK_OVERFLOW_CHECK >= 2 - ___set_stack_limits(stack_base, stack_max); + __set_stack_limits(stack_base, stack_max); #endif stackRestore({{{ makeGetValue('newFiber', C_STRUCTS.emscripten_fiber_s.stack_ptr, '*') }}}); @@ -578,7 +578,7 @@ addToLibrary({ dbg('ASYNCIFY/FIBER: start rewind', asyncifyData, '(resuming fiber', newFiber, ')'); #endif Asyncify.state = Asyncify.State.Rewinding; - _asyncify_start_rewind(asyncifyData); + asyncify_start_rewind(asyncifyData); Asyncify.doRewind(asyncifyData); } }, @@ -601,7 +601,7 @@ addToLibrary({ #if ASYNCIFY_DEBUG dbg('ASYNCIFY/FIBER: start unwind', asyncifyData); #endif - _asyncify_start_unwind(asyncifyData); + asyncify_start_unwind(asyncifyData); var stackTop = stackSave(); {{{ makeSetValue('oldFiber', C_STRUCTS.emscripten_fiber_s.stack_ptr, 'stackTop', '*') }}}; @@ -615,7 +615,7 @@ addToLibrary({ dbg('ASYNCIFY/FIBER: stop rewind'); #endif Asyncify.state = Asyncify.State.Normal; - _asyncify_stop_rewind(); + asyncify_stop_rewind(); Asyncify.currData = null; } }, diff --git a/src/library_autodebug.js b/src/library_autodebug.js index f5f4a79d0b4fa..62fcd2424c287 100644 --- a/src/library_autodebug.js +++ b/src/library_autodebug.js @@ -109,7 +109,7 @@ addToLibrary({ dbg('store_val_i32 ' + [loc, value]); return value; }, - $store_val_i64__deps: ['setTempRet0'], + $store_val_i64__deps: ['$setTempRet0'], $store_val_i64: (loc, low, high) => { dbg('store_val_i64 ' + [loc, low, high]); setTempRet0(high); diff --git a/src/library_browser.js b/src/library_browser.js index dbfdacea10125..4c421b858c629 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -647,7 +647,7 @@ var LibraryBrowser = { emscripten_async_run_script__deps: ['emscripten_run_script', '$safeSetTimeout'], emscripten_async_run_script: (script, millis) => { // TODO: cache these to avoid generating garbage - safeSetTimeout(() => _emscripten_run_script(script), millis); + safeSetTimeout(() => emscripten_run_script(script), millis); }, // TODO: currently not callable from a pthread, but immediately calls onerror() if not on main thread. @@ -706,13 +706,13 @@ var LibraryBrowser = { emscripten_get_window_title: () => { var buflen = 256; - if (!_emscripten_get_window_title.buffer) { - _emscripten_get_window_title.buffer = _malloc(buflen); + if (!emscripten_get_window_title.buffer) { + emscripten_get_window_title.buffer = malloc(buflen); } - stringToUTF8(document.title, _emscripten_get_window_title.buffer, buflen); + stringToUTF8(document.title, emscripten_get_window_title.buffer, buflen); - return _emscripten_get_window_title.buffer; + return emscripten_get_window_title.buffer; }, emscripten_set_window_title__proxy: 'sync', @@ -778,9 +778,9 @@ var LibraryBrowser = { if (data) { if (!data.byteLength) data = new Uint8Array(data); if (!info.buffer || info.bufferSize < data.length) { - if (info.buffer) _free(info.buffer); + if (info.buffer) free(info.buffer); info.bufferSize = data.length; - info.buffer = _malloc(data.length); + info.buffer = malloc(data.length); } HEAPU8.set(data, info.buffer); callbackInfo.func(info.buffer, data.length, callbackInfo.arg); @@ -797,7 +797,7 @@ var LibraryBrowser = { emscripten_destroy_worker: (id) => { var info = Browser.workers[id]; info.worker.terminate(); - if (info.buffer) _free(info.buffer); + if (info.buffer) free(info.buffer); Browser.workers[id] = null; }, @@ -885,7 +885,7 @@ var LibraryBrowser = { var ctx = canvas.getContext("2d"); var image = ctx.getImageData(0, 0, canvas.width, canvas.height); - var buf = _malloc(canvas.width * canvas.height * 4); + var buf = malloc(canvas.width * canvas.height * 4); HEAPU8.set(image.data, buf); @@ -898,7 +898,7 @@ var LibraryBrowser = { emscripten_get_preloaded_image_data_from_FILE__deps: ['$getPreloadedImageData', 'fileno'], emscripten_get_preloaded_image_data_from_FILE__proxy: 'sync', emscripten_get_preloaded_image_data_from_FILE: (file, w, h) => { - var fd = _fileno(file); + var fd = fileno(file); var stream = FS.getStream(fd); if (stream) { return getPreloadedImageData(stream.path, w, h); diff --git a/src/library_ccall.js b/src/library_ccall.js index 09022e9c6c819..a777d44add073 100644 --- a/src/library_ccall.js +++ b/src/library_ccall.js @@ -7,7 +7,7 @@ addToLibrary({ // Returns the C function with a specified identifier (for C++, you need to do manual name mangling) $getCFunc: (ident) => { - var func = Module['_' + ident]; // closure exported function + var func = Module[ident]; #if ASSERTIONS assert(func, 'Cannot call unknown function ' + ident + ', make sure it is exported'); #endif diff --git a/src/library_dylink.js b/src/library_dylink.js index dee697661bb66..e33cc3dbb4341 100644 --- a/src/library_dylink.js +++ b/src/library_dylink.js @@ -90,7 +90,7 @@ var LibraryDylink = { // test to check if e was not a Number. if (e !== e+0) throw e; #endif - _setThrew(1, 0); + setThrew(1, 0); #if WASM_BIGINT // In theory this if statement could be done on // creating the function, but I just added this to @@ -350,7 +350,7 @@ var LibraryDylink = { #endif var sp = stackSave(); var cmsg = stringToUTF8OnStack(msg); - ___dl_seterr(cmsg, 0); + __dl_seterr(cmsg, 0); stackRestore(sp); }, @@ -373,15 +373,15 @@ var LibraryDylink = { // Currently we don't support freeing of static data when modules are // unloaded via dlclose. This function is tagged as `noleakcheck` to // avoid having this reported as leak. - return _calloc(size, 1); + return calloc(size, 1); } - var ret = ___heap_base; + var ret = __heap_base; // Keep __heap_base stack aligned. var end = ret + alignMemory(size, {{{ STACK_ALIGN }}}); #if ASSERTIONS assert(end <= HEAP8.length, 'failure to getMemory - memory growth etc. is not supported there, call malloc/sbrk directly or increase INITIAL_MEMORY'); #endif - ___heap_base = end; + __heap_base = end; GOT['__heap_base'].value = {{{ to64('end') }}}; return ret; }, @@ -766,7 +766,7 @@ var LibraryDylink = { // now. Otherwise this is delayed until `setDylinkStackLimits` is // called after initialization. if (moduleExports['__set_stack_limits'] && runtimeInitialized) { - moduleExports['__set_stack_limits']({{{ to64('_emscripten_stack_get_base()') }}}, {{{ to64('_emscripten_stack_get_end()') }}}); + moduleExports['__set_stack_limits']({{{ to64('emscripten_stack_get_base()') }}}, {{{ to64('emscripten_stack_get_end()') }}}); } #endif diff --git a/src/library_egl.js b/src/library_egl.js index 75fa239e8120d..0202af753da48 100644 --- a/src/library_egl.js +++ b/src/library_egl.js @@ -576,8 +576,8 @@ var LibraryEGL = { EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */); return 0; } - if (interval == 0) _emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_SETTIMEOUT }}}, 0); - else _emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_RAF }}}, interval); + if (interval == 0) emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_SETTIMEOUT }}}, 0); + else emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_RAF }}}, interval); EGL.setErrorCode(0x3000 /* EGL_SUCCESS */); return 1; diff --git a/src/library_eventloop.js b/src/library_eventloop.js index e91845680e539..dbaa161d3ad9b 100644 --- a/src/library_eventloop.js +++ b/src/library_eventloop.js @@ -128,7 +128,7 @@ LibraryJSEventLoop = { emscripten_set_timeout_loop__deps: ['$callUserCallback', 'emscripten_get_now'], emscripten_set_timeout_loop: (cb, msecs, userData) => { function tick() { - var t = _emscripten_get_now(); + var t = emscripten_get_now(); var n = t + msecs; {{{ runtimeKeepalivePop() }}} callUserCallback(() => { @@ -137,7 +137,7 @@ LibraryJSEventLoop = { // negative setTimeout as timeout of 0 // (https://stackoverflow.com/questions/8430966/is-calling-settimeout-with-a-negative-delay-ok) {{{ runtimeKeepalivePush() }}} - setTimeout(tick, n - _emscripten_get_now()); + setTimeout(tick, n - emscripten_get_now()); } }); } @@ -226,7 +226,7 @@ LibraryJSEventLoop = { MainLoop.func = null; // do not set timing and call scheduler, we will do it on the next lines setMainLoop(func, 0, false, MainLoop.arg, true); - _emscripten_set_main_loop_timing(timingMode, timingValue); + emscripten_set_main_loop_timing(timingMode, timingValue); MainLoop.scheduler(); }, @@ -334,7 +334,7 @@ LibraryJSEventLoop = { } if (mode == {{{ cDefs.EM_TIMING_SETTIMEOUT }}}) { MainLoop.scheduler = function MainLoop_scheduler_setTimeout() { - var timeUntilNextTick = Math.max(0, MainLoop.tickStartTime + value - _emscripten_get_now())|0; + var timeUntilNextTick = Math.max(0, MainLoop.tickStartTime + value - emscripten_get_now())|0; setTimeout(MainLoop.runner, timeUntilNextTick); // doing this each time means that on exception, we stop }; MainLoop.method = 'timeout'; @@ -424,7 +424,7 @@ LibraryJSEventLoop = { } // We create the loop runner here but it is not actually running until - // _emscripten_set_main_loop_timing is called (which might happen a + // emscripten_set_main_loop_timing is called (which might happen a // later time). This member signifies that the current runner has not // yet been started so that we can call runtimeKeepalivePush when it // gets it timing set for the first time. @@ -468,7 +468,7 @@ LibraryJSEventLoop = { MainLoop.scheduler(); return; } else if (MainLoop.timingMode == {{{ cDefs.EM_TIMING_SETTIMEOUT }}}) { - MainLoop.tickStartTime = _emscripten_get_now(); + MainLoop.tickStartTime = emscripten_get_now(); } #if ASSERTIONS @@ -488,10 +488,10 @@ LibraryJSEventLoop = { if (!noSetTiming) { if (fps && fps > 0) { - _emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_SETTIMEOUT }}}, 1000.0 / fps); + emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_SETTIMEOUT }}}, 1000.0 / fps); } else { // Do rAF by rendering each frame (no decimating) - _emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_RAF }}}, 1); + emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_RAF }}}, 1); } MainLoop.scheduler(); diff --git a/src/library_exceptions.js b/src/library_exceptions.js index 6d7dc784ff2ff..6d2531fd8582b 100644 --- a/src/library_exceptions.js +++ b/src/library_exceptions.js @@ -12,7 +12,7 @@ var LibraryExceptions = { // This class is the exception metadata which is prepended to each thrown object (in WASM memory). // It is allocated in one block among with a thrown object in __cxa_allocate_exception and freed - // in ___cxa_free_exception. It roughly corresponds to __cxa_exception structure in libcxxabi. The + // in __cxa_free_exception. It roughly corresponds to __cxa_exception structure in libcxxabi. The // class itself is just a native pointer wrapper, and contains all the necessary accessors for the // fields in the native structure. // TODO: Unfortunately this approach still cannot be considered thread-safe because single @@ -139,8 +139,8 @@ var LibraryExceptions = { #if EXCEPTION_DEBUG dbg('__cxa_begin_catch ' + [ptrToString(ptr), 'stack', exceptionCaught]); #endif - ___cxa_increment_exception_refcount(ptr); - return ___cxa_get_exception_ptr(ptr); + __cxa_increment_exception_refcount(ptr); + return __cxa_get_exception_ptr(ptr); }, // We're done with a catch. Now, we can run the destructor if there is one @@ -150,7 +150,7 @@ var LibraryExceptions = { __cxa_end_catch__deps: ['$exceptionCaught', '$exceptionLast', '__cxa_decrement_exception_refcount', 'setThrew'], __cxa_end_catch: () => { // Clear state flag. - _setThrew(0, 0); + setThrew(0, 0); #if ASSERTIONS assert(exceptionCaught.length > 0); #endif @@ -160,7 +160,7 @@ var LibraryExceptions = { #if EXCEPTION_DEBUG dbg('__cxa_end_catch popped ' + [info, exceptionLast, 'stack', exceptionCaught]); #endif - ___cxa_decrement_exception_refcount(info.excPtr); + __cxa_decrement_exception_refcount(info.excPtr); exceptionLast = 0; // XXX in decRef? }, @@ -175,7 +175,7 @@ var LibraryExceptions = { return 0; } var info = exceptionCaught[exceptionCaught.length - 1]; - ___cxa_increment_exception_refcount(info.excPtr); + __cxa_increment_exception_refcount(info.excPtr); return info.excPtr; }, @@ -185,7 +185,7 @@ var LibraryExceptions = { var info = new ExceptionInfo(ptr); exceptionCaught.push(info); info.set_rethrown(true); - ___cxa_rethrow(); + __cxa_rethrow(); }, // Finds a suitable catch clause for when an exception is thrown. @@ -233,7 +233,7 @@ var LibraryExceptions = { break; } var adjusted_ptr_addr = info.ptr + {{{ C_STRUCTS.__cxa_exception.adjustedPtr }}}; - if (___cxa_can_catch(caughtType, thrownType, adjusted_ptr_addr)) { + if (__cxa_can_catch(caughtType, thrownType, adjusted_ptr_addr)) { #if EXCEPTION_DEBUG dbg(" findMatchingCatch found " + [ptrToString(info.get_adjusted_ptr()), caughtType]); #endif @@ -263,15 +263,15 @@ var LibraryExceptions = { var sp = stackSave(); var type_addr_addr = stackAlloc({{{ POINTER_SIZE }}}); var message_addr_addr = stackAlloc({{{ POINTER_SIZE }}}); - ___get_exception_message(ptr, type_addr_addr, message_addr_addr); + __get_exception_message(ptr, type_addr_addr, message_addr_addr); var type_addr = {{{ makeGetValue('type_addr_addr', 0, '*') }}}; var message_addr = {{{ makeGetValue('message_addr_addr', 0, '*') }}}; var type = UTF8ToString(type_addr); - _free(type_addr); + free(type_addr); var message; if (message_addr) { message = UTF8ToString(message_addr); - _free(message_addr); + free(message_addr); } stackRestore(sp); return [type, message]; @@ -283,7 +283,7 @@ var LibraryExceptions = { // exported, whereas in dynamic linking, tags are defined in library.js in // JS code and wasm modules import them. #if RELOCATABLE - ___cpp_exception // defined in library.js + __cpp_exception // defined in library.js #else wasmExports['__cpp_exception'] #endif @@ -311,19 +311,19 @@ var LibraryExceptions = { // In Wasm EH, the value extracted from WebAssembly.Exception is a pointer // to the unwind header. Convert it to the actual thrown value. var unwind_header = ex.getArg(getCppExceptionTag(), 0); - return ___thrown_object_from_unwind_exception(unwind_header); + return __thrown_object_from_unwind_exception(unwind_header); }, $incrementExceptionRefcount__deps: ['__cxa_increment_exception_refcount', '$getCppExceptionThrownObjectFromWebAssemblyException'], $incrementExceptionRefcount: (ex) => { var ptr = getCppExceptionThrownObjectFromWebAssemblyException(ex); - ___cxa_increment_exception_refcount(ptr); + __cxa_increment_exception_refcount(ptr); }, $decrementExceptionRefcount__deps: ['__cxa_decrement_exception_refcount', '$getCppExceptionThrownObjectFromWebAssemblyException'], $decrementExceptionRefcount: (ex) => { var ptr = getCppExceptionThrownObjectFromWebAssemblyException(ex); - ___cxa_decrement_exception_refcount(ptr); + __cxa_decrement_exception_refcount(ptr); }, $getExceptionMessage__deps: ['$getCppExceptionThrownObjectFromWebAssemblyException', '$getExceptionMessageCommon'], @@ -334,10 +334,10 @@ var LibraryExceptions = { #elif !DISABLE_EXCEPTION_CATCHING $incrementExceptionRefcount__deps: ['__cxa_increment_exception_refcount'], - $incrementExceptionRefcount: (ptr) => ___cxa_increment_exception_refcount(ptr), + $incrementExceptionRefcount: (ptr) => __cxa_increment_exception_refcount(ptr), $decrementExceptionRefcount__deps: ['__cxa_decrement_exception_refcount'], - $decrementExceptionRefcount: (ptr) => ___cxa_decrement_exception_refcount(ptr), + $decrementExceptionRefcount: (ptr) => __cxa_decrement_exception_refcount(ptr), $getExceptionMessage__deps: ['$getExceptionMessageCommon'], $getExceptionMessage: (ptr) => getExceptionMessageCommon(ptr), diff --git a/src/library_fs.js b/src/library_fs.js index 886efa61f4c45..3d75c605209c6 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -1482,7 +1482,7 @@ FS.staticInit(); FS.initialized = false; // force-flush all streams, so we get musl std streams printed out #if hasExportedSymbol('fflush') - _fflush(0); + fflush(0); #endif // close all of our streams for (var i = 0; i < FS.streams.length; i++) { diff --git a/src/library_glemu.js b/src/library_glemu.js index 196a889f09213..6e96f72869076 100644 --- a/src/library_glemu.js +++ b/src/library_glemu.js @@ -34,38 +34,38 @@ var LibraryGLEmulation = { $GLEmulation__postset: #if MAYBE_CLOSURE_COMPILER // Forward declare GL functions that are overridden by GLEmulation here to appease Closure compiler. - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDrawArrays;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDrawElements;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glActiveTexture;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glEnable;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDisable;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glTexEnvf;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glTexEnvi;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glTexEnvfv;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetIntegerv;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glIsEnabled;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetBooleanv;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetString;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glCreateShader;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glShaderSource;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glCompileShader;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glAttachShader;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDetachShader;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glUseProgram;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDeleteProgram;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glBindAttribLocation;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glLinkProgram;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glBindBuffer;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetFloatv;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glHint;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glEnableVertexAttribArray;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDisableVertexAttribArray;' + - '/**@suppress {duplicate, undefinedVars}*/var _emscripten_glVertexAttribPointer;' + - '/**@suppress {duplicate, undefinedVars}*/var _glTexEnvf;' + - '/**@suppress {duplicate, undefinedVars}*/var _glTexEnvi;' + - '/**@suppress {duplicate, undefinedVars}*/var _glTexEnvfv;' + - '/**@suppress {duplicate, undefinedVars}*/var _glGetTexEnviv;' + - '/**@suppress {duplicate, undefinedVars}*/var _glGetTexEnvfv;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glDrawArrays;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glDrawElements;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glActiveTexture;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glEnable;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glDisable;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glTexEnvf;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glTexEnvi;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glTexEnvfv;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glGetIntegerv;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glIsEnabled;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glGetBooleanv;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glGetString;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glCreateShader;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glShaderSource;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glCompileShader;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glAttachShader;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glDetachShader;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glUseProgram;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glDeleteProgram;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glBindAttribLocation;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glLinkProgram;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glBindBuffer;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glGetFloatv;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glHint;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glEnableVertexAttribArray;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glDisableVertexAttribArray;' + + '/**@suppress {duplicate, undefinedVars}*/var emscripten_glVertexAttribPointer;' + + '/**@suppress {duplicate, undefinedVars}*/var glTexEnvf;' + + '/**@suppress {duplicate, undefinedVars}*/var glTexEnvi;' + + '/**@suppress {duplicate, undefinedVars}*/var glTexEnvfv;' + + '/**@suppress {duplicate, undefinedVars}*/var glGetTexEnviv;' + + '/**@suppress {duplicate, undefinedVars}*/var glGetTexEnvfv;' + #endif 'GLEmulation.init();', $GLEmulation: { @@ -203,8 +203,8 @@ var LibraryGLEmulation = { 0x80A0: 1 // GL_SAMPLE_COVERAGE }; - var orig_glEnable = _glEnable; - _glEnable = _emscripten_glEnable = (cap) => { + var orig_glEnable = glEnable; + glEnable = emscripten_glEnable = (cap) => { // Clean up the renderer on any change to the rendering state. The optimization of // skipping renderer setup is aimed at the case of multiple glDraw* right after each other GLImmediate.lastRenderer?.cleanup(); @@ -245,7 +245,7 @@ var LibraryGLEmulation = { // it by forwarding to glEnableClientState /* Actually, let's not, for now. (This sounds exceedingly broken) * This is in gl_ps_workaround2.c. - _glEnableClientState(cap); + glEnableClientState(cap); */ return; } else if (!(cap in validCapabilities)) { @@ -255,8 +255,8 @@ var LibraryGLEmulation = { }; {{{ copySigs('glEnable') }}} - var orig_glDisable = _glDisable; - _glDisable = _emscripten_glDisable = (cap) => { + var orig_glDisable = glDisable; + glDisable = emscripten_glDisable = (cap) => { GLImmediate.lastRenderer?.cleanup(); if (cap == 0xB60 /* GL_FOG */) { if (GLEmulation.fogEnabled != false) { @@ -295,7 +295,7 @@ var LibraryGLEmulation = { // it by forwarding to glDisableClientState /* Actually, let's not, for now. (This sounds exceedingly broken) * This is in gl_ps_workaround2.c. - _glDisableClientState(cap); + glDisableClientState(cap); */ return; } else if (!(cap in validCapabilities)) { @@ -305,8 +305,8 @@ var LibraryGLEmulation = { }; {{{ copySigs('glDisable') }}} - var orig_glIsEnabled = _glIsEnabled; - _glIsEnabled = _emscripten_glIsEnabled = (cap) => { + var orig_glIsEnabled = glIsEnabled; + glIsEnabled = emscripten_glIsEnabled = (cap) => { if (cap == 0xB60 /* GL_FOG */) { return GLEmulation.fogEnabled ? 1 : 0; } else if ((cap >= 0x3000) && (cap < 0x3006) /* GL_CLIP_PLANE0 to GL_CLIP_PLANE5 */) { @@ -326,8 +326,8 @@ var LibraryGLEmulation = { }; {{{ copySigs('glIsEnabled') }}} - var orig_glGetBooleanv = _glGetBooleanv; - _glGetBooleanv = _emscripten_glGetBooleanv = (pname, p) => { + var orig_glGetBooleanv = glGetBooleanv; + glGetBooleanv = emscripten_glGetBooleanv = (pname, p) => { var attrib = GLEmulation.getAttributeFromCapability(pname); if (attrib !== null) { {{{ fromPtr('p') }}} @@ -339,8 +339,8 @@ var LibraryGLEmulation = { }; {{{ copySigs('glGetBooleanv') }}} - var orig_glGetIntegerv = _glGetIntegerv; - _glGetIntegerv = _emscripten_glGetIntegerv = (pname, params) => { + var orig_glGetIntegerv = glGetIntegerv; + glGetIntegerv = emscripten_glGetIntegerv = (pname, params) => { {{{ fromPtr('params') }}} switch (pname) { case 0x84E2: pname = GLctx.MAX_TEXTURE_IMAGE_UNITS /* fake it */; break; // GL_MAX_TEXTURE_UNITS @@ -422,8 +422,8 @@ var LibraryGLEmulation = { }; {{{ copySigs('glGetIntegerv') }}} - var orig_glGetString = _glGetString; - _glGetString = _emscripten_glGetString = (name_) => { + var orig_glGetString = glGetString; + glGetString = emscripten_glGetString = (name_) => { if (GL.stringCache[name_]) return GL.stringCache[name_]; switch (name_) { case 0x1F03 /* GL_EXTENSIONS */: // Add various extensions that we can support @@ -446,8 +446,8 @@ var LibraryGLEmulation = { GL.shaderSources = {}; GL.shaderOriginalSources = {}; #endif - var orig_glCreateShader = _glCreateShader; - _glCreateShader = _emscripten_glCreateShader = (shaderType) => { + var orig_glCreateShader = glCreateShader; + glCreateShader = emscripten_glCreateShader = (shaderType) => { var id = orig_glCreateShader(shaderType); GL.shaderInfos[id] = { type: shaderType, @@ -464,13 +464,13 @@ var LibraryGLEmulation = { return source; } - var orig_glShaderSource = _glShaderSource; - _glShaderSource = _emscripten_glShaderSource = (shader, count, string, length) => { + var orig_glShaderSource = glShaderSource; + glShaderSource = emscripten_glShaderSource = (shader, count, string, length) => { {{{ fromPtr('string') }}} {{{ fromPtr('length') }}} var source = GL.getSource(shader, count, string, length); #if GL_DEBUG - dbg("glShaderSource: Input: \n" + source); + dbg('glShaderSource: Input: \n' + source); GL.shaderOriginalSources[shader] = source; #endif // XXX We add attributes and uniforms to shaders. The program can ask for the # of them, and see the @@ -580,8 +580,8 @@ var LibraryGLEmulation = { }; {{{ copySigs('glShaderSource') }}} - var orig_glCompileShader = _glCompileShader; - _glCompileShader = _emscripten_glCompileShader = (shader) => { + var orig_glCompileShader = glCompileShader; + glCompileShader = emscripten_glCompileShader = (shader) => { GLctx.compileShader(GL.shaders[shader]); #if GL_DEBUG if (!GLctx.getShaderParameter(GL.shaders[shader], GLctx.COMPILE_STATUS)) { @@ -596,19 +596,19 @@ var LibraryGLEmulation = { {{{ copySigs('glCompileShader') }}} GL.programShaders = {}; - var orig_glAttachShader = _glAttachShader; - _glAttachShader = _emscripten_glAttachShader = (program, shader) => { + var orig_glAttachShader = glAttachShader; + glAttachShader = emscripten_glAttachShader = (program, shader) => { GL.programShaders[program] ||= []; GL.programShaders[program].push(shader); orig_glAttachShader(program, shader); }; {{{ copySigs('glAttachShader') }}} - var orig_glDetachShader = _glDetachShader; - _glDetachShader = _emscripten_glDetachShader = (program, shader) => { + var orig_glDetachShader = glDetachShader; + glDetachShader = emscripten_glDetachShader = (program, shader) => { var programShader = GL.programShaders[program]; if (!programShader) { - err(`WARNING: _glDetachShader received invalid program: ${program}`); + err(`WARNING: glDetachShader received invalid program: ${program}`); return; } var index = programShader.indexOf(shader); @@ -617,8 +617,8 @@ var LibraryGLEmulation = { }; {{{ copySigs('glDetachShader') }}} - var orig_glUseProgram = _glUseProgram; - _glUseProgram = _emscripten_glUseProgram = (program) => { + var orig_glUseProgram = glUseProgram; + glUseProgram = emscripten_glUseProgram = (program) => { #if GL_DEBUG if (GL.debug) { dbg('[using program with shaders]'); @@ -639,8 +639,8 @@ var LibraryGLEmulation = { } {{{ copySigs('glUseProgram') }}} - var orig_glDeleteProgram = _glDeleteProgram; - _glDeleteProgram = _emscripten_glDeleteProgram = (program) => { + var orig_glDeleteProgram = glDeleteProgram; + glDeleteProgram = emscripten_glDeleteProgram = (program) => { orig_glDeleteProgram(program); if (program == GL.currProgram) { GLImmediate.currentRenderer = null; // This changes the FFP emulation shader program, need to recompute that. @@ -651,15 +651,15 @@ var LibraryGLEmulation = { // If attribute 0 was not bound, bind it to 0 for WebGL performance reasons. Track if 0 is free for that. var zeroUsedPrograms = {}; - var orig_glBindAttribLocation = _glBindAttribLocation; - _glBindAttribLocation = _emscripten_glBindAttribLocation = (program, index, name) => { + var orig_glBindAttribLocation = glBindAttribLocation; + glBindAttribLocation = emscripten_glBindAttribLocation = (program, index, name) => { if (index == 0) zeroUsedPrograms[program] = true; orig_glBindAttribLocation(program, index, name); }; {{{ copySigs('glBindAttribLocation') }}} - var orig_glLinkProgram = _glLinkProgram; - _glLinkProgram = _emscripten_glLinkProgram = (program) => { + var orig_glLinkProgram = glLinkProgram; + glLinkProgram = emscripten_glLinkProgram = (program) => { if (!(program in zeroUsedPrograms)) { GLctx.bindAttribLocation(GL.programs[program], 0, 'a_position'); } @@ -667,8 +667,8 @@ var LibraryGLEmulation = { }; {{{ copySigs('glLinkProgram') }}} - var orig_glBindBuffer = _glBindBuffer; - _glBindBuffer = _emscripten_glBindBuffer = (target, buffer) => { + var orig_glBindBuffer = glBindBuffer; + glBindBuffer = emscripten_glBindBuffer = (target, buffer) => { orig_glBindBuffer(target, buffer); if (target == GLctx.ARRAY_BUFFER) { if (GLEmulation.currentVao) { @@ -683,8 +683,8 @@ var LibraryGLEmulation = { }; {{{ copySigs('glBindBuffer') }}} - var orig_glGetFloatv = _glGetFloatv; - _glGetFloatv = _emscripten_glGetFloatv = (pname, params) => { + var orig_glGetFloatv = glGetFloatv; + glGetFloatv = emscripten_glGetFloatv = (pname, params) => { {{{ fromPtr('params') }}} if (pname == 0xBA6) { // GL_MODELVIEW_MATRIX HEAPF32.set(GLImmediate.matrix[0/*m*/], {{{ getHeapOffset('params', 'float') }}}); @@ -715,8 +715,8 @@ var LibraryGLEmulation = { }; {{{ copySigs('glGetFloatv') }}} - var orig_glHint = _glHint; - _glHint = _emscripten_glHint = (target, mode) => { + var orig_glHint = glHint; + glHint = emscripten_glHint = (target, mode) => { if (target == 0x84EF) { // GL_TEXTURE_COMPRESSION_HINT return; } @@ -724,24 +724,24 @@ var LibraryGLEmulation = { }; {{{ copySigs('glHint') }}} - var orig_glEnableVertexAttribArray = _glEnableVertexAttribArray; - _glEnableVertexAttribArray = _emscripten_glEnableVertexAttribArray = (index) => { + var orig_glEnableVertexAttribArray = glEnableVertexAttribArray; + glEnableVertexAttribArray = emscripten_glEnableVertexAttribArray = (index) => { orig_glEnableVertexAttribArray(index); GLEmulation.enabledVertexAttribArrays[index] = 1; if (GLEmulation.currentVao) GLEmulation.currentVao.enabledVertexAttribArrays[index] = 1; }; {{{ copySigs('glEnableVertexAttribArray') }}} - var orig_glDisableVertexAttribArray = _glDisableVertexAttribArray; - _glDisableVertexAttribArray = _emscripten_glDisableVertexAttribArray = (index) => { + var orig_glDisableVertexAttribArray = glDisableVertexAttribArray; + glDisableVertexAttribArray = emscripten_glDisableVertexAttribArray = (index) => { orig_glDisableVertexAttribArray(index); delete GLEmulation.enabledVertexAttribArrays[index]; if (GLEmulation.currentVao) delete GLEmulation.currentVao.enabledVertexAttribArrays[index]; }; {{{ copySigs('glDisableVertexAttribArray') }}} - var orig_glVertexAttribPointer = _glVertexAttribPointer; - _glVertexAttribPointer = _emscripten_glVertexAttribPointer = (index, size, type, normalized, stride, pointer) => { + var orig_glVertexAttribPointer = glVertexAttribPointer; + glVertexAttribPointer = emscripten_glVertexAttribPointer = (index, size, type, normalized, stride, pointer) => { orig_glVertexAttribPointer(index, size, type, normalized, stride, pointer); if (GLEmulation.currentVao) { // TODO: avoid object creation here? likely not hot though GLEmulation.currentVao.vertexAttribPointers[index] = [index, size, type, normalized, stride, pointer]; @@ -774,9 +774,9 @@ var LibraryGLEmulation = { glDeleteObject__deps: ['glDeleteProgram', 'glDeleteShader'], glDeleteObject: (id) => { if (GL.programs[id]) { - _glDeleteProgram(id); + glDeleteProgram(id); } else if (GL.shaders[id]) { - _glDeleteShader(id); + glDeleteShader(id); } else { err(`WARNING: deleteObject received invalid id: ${id}`); } @@ -792,7 +792,7 @@ var LibraryGLEmulation = { {{{ makeSetValue('result', '0', 'log.length', 'i32') }}}; return; } - _glGetProgramiv(id, type, result); + glGetProgramiv(id, type, result); } else if (GL.shaders[id]) { if (type == 0x8B84) { // GL_OBJECT_INFO_LOG_LENGTH_ARB var log = GLctx.getShaderInfoLog(GL.shaders[id]); @@ -805,7 +805,7 @@ var LibraryGLEmulation = { {{{ makeSetValue('result', '0', 'source.length', 'i32') }}}; return; } - _glGetShaderiv(id, type, result); + glGetShaderiv(id, type, result); } else { err(`WARNING: getObjectParameteriv received invalid id: ${id}`); } @@ -815,9 +815,9 @@ var LibraryGLEmulation = { glGetInfoLog__deps: ['glGetProgramInfoLog', 'glGetShaderInfoLog'], glGetInfoLog: (id, maxLength, length, infoLog) => { if (GL.programs[id]) { - _glGetProgramInfoLog(id, maxLength, length, infoLog); + glGetProgramInfoLog(id, maxLength, length, infoLog); } else if (GL.shaders[id]) { - _glGetShaderInfoLog(id, maxLength, length, infoLog); + glGetShaderInfoLog(id, maxLength, length, infoLog); } else { err(`WARNING: glGetInfoLog received invalid id: ${id}`); } @@ -2769,62 +2769,62 @@ var LibraryGLEmulation = { GLEmulation.init(); } - var glActiveTexture = _glActiveTexture; - _glActiveTexture = _emscripten_glActiveTexture = (texture) => { + var glActiveTexture_real = glActiveTexture; + glActiveTexture = emscripten_glActiveTexture = (texture) => { GLImmediate.TexEnvJIT.hook_activeTexture(texture); - glActiveTexture(texture); + glActiveTexture_real(texture); }; - var glEnable = _glEnable; - _glEnable = _emscripten_glEnable = (cap) => { + var glEnable_real = glEnable; + glEnable = emscripten_glEnable = (cap) => { GLImmediate.TexEnvJIT.hook_enable(cap); - glEnable(cap); + glEnable_real(cap); }; - var glDisable = _glDisable; - _glDisable = _emscripten_glDisable = (cap) => { + var glDisable_real = glDisable; + glDisable = emscripten_glDisable = (cap) => { GLImmediate.TexEnvJIT.hook_disable(cap); - glDisable(cap); + glDisable_real(cap); }; - var glTexEnvf = (typeof _glTexEnvf != 'undefined') ? _glTexEnvf : () => {}; + var glTexEnvf_real = (typeof glTexEnvf != 'undefined') ? glTexEnvf : () => {}; /** @suppress {checkTypes} */ - _glTexEnvf = _emscripten_glTexEnvf = (target, pname, param) => { + glTexEnvf = emscripten_glTexEnvf = (target, pname, param) => { GLImmediate.TexEnvJIT.hook_texEnvf(target, pname, param); // Don't call old func, since we are the implementor. - //glTexEnvf(target, pname, param); + //glTexEnvf_real(target, pname, param); }; - var glTexEnvi = (typeof _glTexEnvi != 'undefined') ? _glTexEnvi : () => {}; + var glTexEnvi_real = (typeof glTexEnvi != 'undefined') ? glTexEnvi : () => {}; /** @suppress {checkTypes} */ - _glTexEnvi = _emscripten_glTexEnvi = (target, pname, param) => { + glTexEnvi = emscripten_glTexEnvi = (target, pname, param) => { {{{ fromPtr('param') }}} GLImmediate.TexEnvJIT.hook_texEnvi(target, pname, param); // Don't call old func, since we are the implementor. - //glTexEnvi(target, pname, param); + //glTexEnvi_real(target, pname, param); }; - var glTexEnvfv = (typeof _glTexEnvfv != 'undefined') ? _glTexEnvfv : () => {}; + var glTexEnvfv_real = (typeof glTexEnvfv != 'undefined') ? glTexEnvfv : () => {}; /** @suppress {checkTypes} */ - _glTexEnvfv = _emscripten_glTexEnvfv = (target, pname, param) => { + glTexEnvfv = emscripten_glTexEnvfv = (target, pname, param) => { {{{ fromPtr('param') }}} GLImmediate.TexEnvJIT.hook_texEnvfv(target, pname, param); // Don't call old func, since we are the implementor. - //glTexEnvfv(target, pname, param); + //glTexEnvfv_real(target, pname, param); }; - _glGetTexEnviv = (target, pname, param) => { + glGetTexEnviv = (target, pname, param) => { {{{ fromPtr('param') }}} GLImmediate.TexEnvJIT.hook_getTexEnviv(target, pname, param); }; - _glGetTexEnvfv = (target, pname, param) => { + glGetTexEnvfv = (target, pname, param) => { {{{ fromPtr('param') }}} GLImmediate.TexEnvJIT.hook_getTexEnvfv(target, pname, param); }; - var glGetIntegerv = _glGetIntegerv; - _glGetIntegerv = _emscripten_glGetIntegerv = (pname, params) => { + var glGetIntegerv_real = glGetIntegerv; + glGetIntegerv = emscripten_glGetIntegerv = (pname, params) => { switch (pname) { case 0x8B8D: { // GL_CURRENT_PROGRAM // Just query directly so we're working with WebGL objects. @@ -2837,7 +2837,7 @@ var LibraryGLEmulation = { break; } } - glGetIntegerv(pname, params); + glGetIntegerv_real(pname, params); }; }, @@ -2964,7 +2964,7 @@ var LibraryGLEmulation = { #if GL_ASSERTIONS warnOnce('Rendering from planar client-side vertex arrays. This is a very slow emulation path! Use interleaved vertex arrays for best performance.'); #endif - GLImmediate.restrideBuffer ||= _malloc(GL.MAX_TEMP_BUFFER_SIZE); + GLImmediate.restrideBuffer ||= malloc(GL.MAX_TEMP_BUFFER_SIZE); var start = GLImmediate.restrideBuffer; bytes = 0; // calculate restrided offsets and total size @@ -3185,19 +3185,19 @@ var LibraryGLEmulation = { }, glVertex2fv__deps: ['glVertex2f'], - glVertex2fv: (p) => _glVertex2f({{{ makeGetValue('p', '0', 'float') }}}, - {{{ makeGetValue('p', '4', 'float') }}}), + glVertex2fv: (p) => glVertex2f({{{ makeGetValue('p', '0', 'float') }}}, + {{{ makeGetValue('p', '4', 'float') }}}), glVertex3fv__deps: ['glVertex3f'], - glVertex3fv: (p) => _glVertex3f({{{ makeGetValue('p', '0', 'float') }}}, - {{{ makeGetValue('p', '4', 'float') }}}, - {{{ makeGetValue('p', '8', 'float') }}}), + glVertex3fv: (p) => glVertex3f({{{ makeGetValue('p', '0', 'float') }}}, + {{{ makeGetValue('p', '4', 'float') }}}, + {{{ makeGetValue('p', '8', 'float') }}}), glVertex4fv__deps: ['glVertex4f'], - glVertex4fv: (p) => _glVertex4f({{{ makeGetValue('p', '0', 'float') }}}, - {{{ makeGetValue('p', '4', 'float') }}}, - {{{ makeGetValue('p', '8', 'float') }}}, - {{{ makeGetValue('p', '12', 'float') }}}), + glVertex4fv: (p) => glVertex4f({{{ makeGetValue('p', '0', 'float') }}}, + {{{ makeGetValue('p', '4', 'float') }}}, + {{{ makeGetValue('p', '8', 'float') }}}, + {{{ makeGetValue('p', '12', 'float') }}}), glVertex2i: 'glVertex2f', @@ -3217,7 +3217,7 @@ var LibraryGLEmulation = { glTexCoord2fv__deps: ['glTexCoord2i'], glTexCoord2fv: (v) => - _glTexCoord2i({{{ makeGetValue('v', '0', 'float') }}}, {{{ makeGetValue('v', '4', 'float') }}}), + glTexCoord2i({{{ makeGetValue('v', '0', 'float') }}}, {{{ makeGetValue('v', '4', 'float') }}}), glTexCoord4f: () => { throw 'glTexCoord4f: TODO' }, @@ -3250,59 +3250,59 @@ var LibraryGLEmulation = { glColor4d: 'glColor4f', glColor4ub__deps: ['glColor4f'], - glColor4ub: (r, g, b, a) => _glColor4f((r&255)/255, (g&255)/255, (b&255)/255, (a&255)/255), + glColor4ub: (r, g, b, a) => glColor4f((r&255)/255, (g&255)/255, (b&255)/255, (a&255)/255), glColor4us__deps: ['glColor4f'], - glColor4us: (r, g, b, a) => _glColor4f((r&65535)/65535, (g&65535)/65535, (b&65535)/65535, (a&65535)/65535), + glColor4us: (r, g, b, a) => glColor4f((r&65535)/65535, (g&65535)/65535, (b&65535)/65535, (a&65535)/65535), glColor4ui__deps: ['glColor4f'], - glColor4ui: (r, g, b, a) => _glColor4f((r>>>0)/4294967295, (g>>>0)/4294967295, (b>>>0)/4294967295, (a>>>0)/4294967295), + glColor4ui: (r, g, b, a) => glColor4f((r>>>0)/4294967295, (g>>>0)/4294967295, (b>>>0)/4294967295, (a>>>0)/4294967295), glColor3f__deps: ['glColor4f'], - glColor3f: (r, g, b) => _glColor4f(r, g, b, 1), + glColor3f: (r, g, b) => glColor4f(r, g, b, 1), glColor3d: 'glColor3f', glColor3ub__deps: ['glColor4ub'], - glColor3ub: (r, g, b) => _glColor4ub(r, g, b, 255), + glColor3ub: (r, g, b) => glColor4ub(r, g, b, 255), glColor3us__deps: ['glColor4us'], - glColor3us: (r, g, b) => _glColor4us(r, g, b, 65535), + glColor3us: (r, g, b) => glColor4us(r, g, b, 65535), glColor3ui__deps: ['glColor4ui'], - glColor3ui: (r, g, b) => _glColor4ui(r, g, b, 4294967295), + glColor3ui: (r, g, b) => glColor4ui(r, g, b, 4294967295), glColor3ubv__deps: ['glColor3ub'], - glColor3ubv: (p) => _glColor3ub({{{ makeGetValue('p', '0', 'i8') }}}, - {{{ makeGetValue('p', '1', 'i8') }}}, - {{{ makeGetValue('p', '2', 'i8') }}}), + glColor3ubv: (p) => glColor3ub({{{ makeGetValue('p', '0', 'i8') }}}, + {{{ makeGetValue('p', '1', 'i8') }}}, + {{{ makeGetValue('p', '2', 'i8') }}}), glColor3usv__deps: ['glColor3us'], - glColor3usv: (p) => _glColor3us({{{ makeGetValue('p', '0', 'i16') }}}, - {{{ makeGetValue('p', '2', 'i16') }}}, - {{{ makeGetValue('p', '4', 'i16') }}}), + glColor3usv: (p) => glColor3us({{{ makeGetValue('p', '0', 'i16') }}}, + {{{ makeGetValue('p', '2', 'i16') }}}, + {{{ makeGetValue('p', '4', 'i16') }}}), glColor3uiv__deps: ['glColor3ui'], - glColor3uiv: (p) => _glColor3ui({{{ makeGetValue('p', '0', 'i32') }}}, - {{{ makeGetValue('p', '4', 'i32') }}}, - {{{ makeGetValue('p', '8', 'i32') }}}), + glColor3uiv: (p) => glColor3ui({{{ makeGetValue('p', '0', 'i32') }}}, + {{{ makeGetValue('p', '4', 'i32') }}}, + {{{ makeGetValue('p', '8', 'i32') }}}), glColor3fv__deps: ['glColor3f'], - glColor3fv: (p) => _glColor3f({{{ makeGetValue('p', '0', 'float') }}}, - {{{ makeGetValue('p', '4', 'float') }}}, - {{{ makeGetValue('p', '8', 'float') }}}), + glColor3fv: (p) => glColor3f({{{ makeGetValue('p', '0', 'float') }}}, + {{{ makeGetValue('p', '4', 'float') }}}, + {{{ makeGetValue('p', '8', 'float') }}}), glColor4fv__deps: ['glColor4f'], - glColor4fv: (p) => _glColor4f({{{ makeGetValue('p', '0', 'float') }}}, - {{{ makeGetValue('p', '4', 'float') }}}, - {{{ makeGetValue('p', '8', 'float') }}}, - {{{ makeGetValue('p', '12', 'float') }}}), + glColor4fv: (p) => glColor4f({{{ makeGetValue('p', '0', 'float') }}}, + {{{ makeGetValue('p', '4', 'float') }}}, + {{{ makeGetValue('p', '8', 'float') }}}, + {{{ makeGetValue('p', '12', 'float') }}}), glColor4ubv__deps: ['glColor4ub'], - glColor4ubv: (p) => _glColor4ub({{{ makeGetValue('p', '0', 'i8') }}}, - {{{ makeGetValue('p', '1', 'i8') }}}, - {{{ makeGetValue('p', '2', 'i8') }}}, - {{{ makeGetValue('p', '3', 'i8') }}}), + glColor4ubv: (p) => glColor4ub({{{ makeGetValue('p', '0', 'i8') }}}, + {{{ makeGetValue('p', '1', 'i8') }}}, + {{{ makeGetValue('p', '2', 'i8') }}}, + {{{ makeGetValue('p', '3', 'i8') }}}), glFogf: (pname, param) => { // partial support, TODO switch (pname) { @@ -3332,9 +3332,8 @@ var LibraryGLEmulation = { } }, glFogi__deps: ['glFogf'], - glFogi: (pname, param) => { - return _glFogf(pname, param); - }, + glFogi: (pname, param) => glFogf(pname, param), + glFogfv__deps: ['glFogf'], glFogfv: (pname, param) => { // partial support, TODO switch (pname) { @@ -3346,7 +3345,7 @@ var LibraryGLEmulation = { break; case 0xB63: // GL_FOG_START case 0xB64: // GL_FOG_END - _glFogf(pname, {{{ makeGetValue('param', '0', 'float') }}}); break; + glFogf(pname, {{{ makeGetValue('param', '0', 'float') }}}); break; } }, glFogiv__deps: ['glFogf'], @@ -3359,7 +3358,7 @@ var LibraryGLEmulation = { GLEmulation.fogColor[3] = ({{{ makeGetValue('param', '12', 'i32') }}}/2147483647)/2.0+0.5; break; default: - _glFogf(pname, {{{ makeGetValue('param', '0', 'i32') }}}); break; + glFogf(pname, {{{ makeGetValue('param', '0', 'i32') }}}); break; } }, glFogx: 'glFogi', @@ -3409,17 +3408,17 @@ var LibraryGLEmulation = { }, glNormal3fv__deps: ['glNormal3f'], - glNormal3fv: (p) => { - _glNormal3f({{{ makeGetValue('p', '0', 'float') }}}, {{{ makeGetValue('p', '4', 'float') }}}, {{{ makeGetValue('p', '8', 'float') }}}); - }, + glNormal3fv: (p) => + glNormal3f({{{ makeGetValue('p', '0', 'float') }}}, + {{{ makeGetValue('p', '4', 'float') }}}, + {{{ makeGetValue('p', '8', 'float') }}}), // Additional non-GLES rendering calls glDrawRangeElements__deps: ['glDrawElements'], - glDrawRangeElements: (mode, start, end, count, type, indices) => { - _glDrawElements(mode, count, type, indices, start, end); - }, + glDrawRangeElements: (mode, start, end, count, type, indices) => + glDrawElements(mode, count, type, indices, start, end), // ClientState/gl*Pointer @@ -3587,8 +3586,8 @@ var LibraryGLEmulation = { // undo vao-related things, wipe the slate clean, both for vao of 0 or an actual vao GLEmulation.currentVao = null; // make sure the commands we run here are not recorded GLImmediate.lastRenderer?.cleanup(); - _glBindBuffer(GLctx.ARRAY_BUFFER, 0); // XXX if one was there before we were bound? - _glBindBuffer(GLctx.ELEMENT_ARRAY_BUFFER, 0); + glBindBuffer(GLctx.ARRAY_BUFFER, 0); // XXX if one was there before we were bound? + glBindBuffer(GLctx.ELEMENT_ARRAY_BUFFER, 0); for (var vaa in GLEmulation.enabledVertexAttribArrays) { GLctx.disableVertexAttribArray(vaa); } @@ -3599,16 +3598,16 @@ var LibraryGLEmulation = { if (vao) { // replay vao var info = GLEmulation.vaos[vao]; - _glBindBuffer(GLctx.ARRAY_BUFFER, info.arrayBuffer); // XXX overwrite current binding? - _glBindBuffer(GLctx.ELEMENT_ARRAY_BUFFER, info.elementArrayBuffer); + glBindBuffer(GLctx.ARRAY_BUFFER, info.arrayBuffer); // XXX overwrite current binding? + glBindBuffer(GLctx.ELEMENT_ARRAY_BUFFER, info.elementArrayBuffer); for (var vaa in info.enabledVertexAttribArrays) { - _glEnableVertexAttribArray(vaa); + glEnableVertexAttribArray(vaa); } for (var vaa in info.vertexAttribPointers) { - _glVertexAttribPointer(...info.vertexAttribPointers[vaa]); + glVertexAttribPointer(...info.vertexAttribPointers[vaa]); } for (var attrib in info.enabledClientStates) { - _glEnableClientState(attrib|0); + glEnableClientState(attrib|0); } GLEmulation.currentVao = info; // set currentVao last, so the commands we ran here were not recorded } @@ -3945,7 +3944,7 @@ var LibraryGLEmulation = { }, gluOrtho2D__deps: ['glOrtho'], - gluOrtho2D: (left, right, bottom, top) => _glOrtho(left, right, bottom, top, -1, 1), + gluOrtho2D: (left, right, bottom, top) => glOrtho(left, right, bottom, top, -1, 1), }; // Legacy GL emulation diff --git a/src/library_glfw.js b/src/library_glfw.js index 142f79e85aa29..238d954430d7e 100644 --- a/src/library_glfw.js +++ b/src/library_glfw.js @@ -703,7 +703,7 @@ var LibraryGLFW = { #endif }, - getTime: () => _emscripten_get_now() / 1000, + getTime: () => emscripten_get_now() / 1000, /* GLFW2 wrapping */ @@ -713,7 +713,7 @@ var LibraryGLFW = { win.title = title; if (GLFW.active.id == win.id) { - _emscripten_set_window_title(title); + emscripten_set_window_title(title); } }, @@ -744,8 +744,8 @@ var LibraryGLFW = { id: stringToNewUTF8(gamepad.id), buttonsCount: gamepad.buttons.length, axesCount: gamepad.axes.length, - buttons: _malloc(gamepad.buttons.length), - axes: _malloc(gamepad.axes.length*4), + buttons: malloc(gamepad.buttons.length), + axes: malloc(gamepad.axes.length*4), }; if (GLFW.joystickFunc) { @@ -770,9 +770,9 @@ var LibraryGLFW = { {{{ makeDynCall('vii', 'GLFW.joystickFunc') }}}(joy, 0x00040002); // GLFW_DISCONNECTED } - _free(GLFW.joys[joy].id); - _free(GLFW.joys[joy].buttons); - _free(GLFW.joys[joy].axes); + free(GLFW.joys[joy].id); + free(GLFW.joys[joy].buttons); + free(GLFW.joys[joy].axes); delete GLFW.joys[joy]; } @@ -836,7 +836,7 @@ var LibraryGLFW = { event.preventDefault(); #if FILESYSTEM - var filenames = _malloc(event.dataTransfer.files.length*4); + var filenames = malloc(event.dataTransfer.files.length*4); var filenamesArray = []; var count = event.dataTransfer.files.length; @@ -861,9 +861,9 @@ var LibraryGLFW = { {{{ makeDynCall('vpii', 'GLFW.active.dropFunc') }}}(GLFW.active.id, count, filenames); for (var i = 0; i < filenamesArray.length; ++i) { - _free(filenamesArray[i]); + free(filenamesArray[i]); } - _free(filenames); + free(filenames); } }; reader.readAsArrayBuffer(file); @@ -1493,8 +1493,8 @@ var LibraryGLFW = { glfwSwapInterval__deps: ['emscripten_set_main_loop_timing'], glfwSwapInterval: (interval) => { interval = Math.abs(interval); // GLFW uses negative values to enable GLX_EXT_swap_control_tear, which we don't have, so just treat negative and positive the same. - if (interval == 0) _emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_SETTIMEOUT }}}, 0); - else _emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_RAF }}}, interval); + if (interval == 0) emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_SETTIMEOUT }}}, 0); + else emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_RAF }}}, interval); }, #if USE_GLFW == 3 @@ -1517,7 +1517,7 @@ var LibraryGLFW = { glfwGetMonitors: (count) => { {{{ makeSetValue('count', '0', '1', 'i32') }}}; if (!GLFW.monitors) { - GLFW.monitors = _malloc({{{ POINTER_SIZE }}}); + GLFW.monitors = malloc({{{ POINTER_SIZE }}}); {{{ makeSetValue('GLFW.monitors', '0', '1', 'i32') }}}; } return GLFW.monitors; diff --git a/src/library_glut.js b/src/library_glut.js index d9cc636f391f4..d294ff8e2f7b1 100644 --- a/src/library_glut.js +++ b/src/library_glut.js @@ -292,12 +292,12 @@ var LibraryGLUT = { } Browser.setCanvasSize(width, height, true); // N.B. GLUT.reshapeFunc is also registered as a canvas resize callback. // Just call it once here. - /* Can't call _glutReshapeWindow as that requests cancelling fullscreen. */ + /* Can't call glutReshapeWindow as that requests cancelling fullscreen. */ if (GLUT.reshapeFunc) { // out("GLUT.reshapeFunc (from FS): " + width + ", " + height); {{{ makeDynCall('vii', 'GLUT.reshapeFunc') }}}(width, height); } - _glutPostRedisplay(); + glutPostRedisplay(); } }, @@ -588,7 +588,7 @@ var LibraryGLUT = { if (GLUT.reshapeFunc) { {{{ makeDynCall('vii', 'GLUT.reshapeFunc') }}}(width, height); } - _glutPostRedisplay(); + glutPostRedisplay(); }, glutPositionWindow__proxy: 'sync', @@ -596,7 +596,7 @@ var LibraryGLUT = { glutPositionWindow: (x, y) => { Browser.exitFullscreen(); /* TODO */ - _glutPostRedisplay(); + glutPostRedisplay(); }, glutFullScreen__proxy: 'sync', @@ -633,8 +633,8 @@ var LibraryGLUT = { glutMainLoop__proxy: 'sync', glutMainLoop__deps: ['$GLUT', 'glutReshapeWindow', 'glutPostRedisplay'], glutMainLoop: () => { - _glutReshapeWindow(Module['canvas'].width, Module['canvas'].height); - _glutPostRedisplay(); + glutReshapeWindow(Module['canvas'].width, Module['canvas'].height); + glutPostRedisplay(); throw 'unwind'; }, diff --git a/src/library_html5.js b/src/library_html5.js index 0e2971e78f79d..460f574de9842 100644 --- a/src/library_html5.js +++ b/src/library_html5.js @@ -261,7 +261,7 @@ var LibraryHTML5 = { #if PTHREADS targetThread = JSEvents.getTargetThreadForEventCallback(targetThread); #endif - JSEvents.keyEvent ||= _malloc({{{ C_STRUCTS.EmscriptenKeyboardEvent.__size__ }}}); + JSEvents.keyEvent ||= malloc({{{ C_STRUCTS.EmscriptenKeyboardEvent.__size__ }}}); var keyEventHandlerFunc = (e) => { #if ASSERTIONS @@ -269,7 +269,7 @@ var LibraryHTML5 = { #endif #if PTHREADS - var keyEventData = targetThread ? _malloc({{{ C_STRUCTS.EmscriptenKeyboardEvent.__size__ }}}) : JSEvents.keyEvent; // This allocated block is passed as satellite data to the proxied function call, so the call frees up the data block when done. + var keyEventData = targetThread ? malloc({{{ C_STRUCTS.EmscriptenKeyboardEvent.__size__ }}}) : JSEvents.keyEvent; // This allocated block is passed as satellite data to the proxied function call, so the call frees up the data block when done. #else var keyEventData = JSEvents.keyEvent; #endif @@ -292,7 +292,7 @@ var LibraryHTML5 = { stringToUTF8(e.locale || '', keyEventData + {{{ C_STRUCTS.EmscriptenKeyboardEvent.locale }}}, {{{ cDefs.EM_HTML5_SHORT_STRING_LEN_BYTES }}}); #if PTHREADS - if (targetThread) __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, keyEventData, userData); + if (targetThread) _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, keyEventData, userData); else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, keyEventData, userData)) e.preventDefault(); @@ -515,7 +515,7 @@ var LibraryHTML5 = { #if PTHREADS targetThread = JSEvents.getTargetThreadForEventCallback(targetThread); #endif - JSEvents.mouseEvent ||= _malloc({{{ C_STRUCTS.EmscriptenMouseEvent.__size__ }}}); + JSEvents.mouseEvent ||= malloc({{{ C_STRUCTS.EmscriptenMouseEvent.__size__ }}}); target = findEventTarget(target); var mouseEventHandlerFunc = (e = event) => { @@ -524,9 +524,9 @@ var LibraryHTML5 = { #if PTHREADS if (targetThread) { - var mouseEventData = _malloc({{{ C_STRUCTS.EmscriptenMouseEvent.__size__ }}}); // This allocated block is passed as satellite data to the proxied function call, so the call frees up the data block when done. + var mouseEventData = malloc({{{ C_STRUCTS.EmscriptenMouseEvent.__size__ }}}); // This allocated block is passed as satellite data to the proxied function call, so the call frees up the data block when done. fillMouseEventData(mouseEventData, e, target); - __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, mouseEventData, userData); + _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, mouseEventData, userData); } else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, JSEvents.mouseEvent, userData)) e.preventDefault(); @@ -606,12 +606,12 @@ var LibraryHTML5 = { #if PTHREADS targetThread = JSEvents.getTargetThreadForEventCallback(targetThread); #endif - JSEvents.wheelEvent ||= _malloc({{{ C_STRUCTS.EmscriptenWheelEvent.__size__ }}}); + JSEvents.wheelEvent ||= malloc({{{ C_STRUCTS.EmscriptenWheelEvent.__size__ }}}); // The DOM Level 3 events spec event 'wheel' var wheelHandlerFunc = (e = event) => { #if PTHREADS - var wheelEvent = targetThread ? _malloc({{{ C_STRUCTS.EmscriptenWheelEvent.__size__ }}}) : JSEvents.wheelEvent; // This allocated block is passed as satellite data to the proxied function call, so the call frees up the data block when done. + var wheelEvent = targetThread ? malloc({{{ C_STRUCTS.EmscriptenWheelEvent.__size__ }}}) : JSEvents.wheelEvent; // This allocated block is passed as satellite data to the proxied function call, so the call frees up the data block when done. #else var wheelEvent = JSEvents.wheelEvent; #endif @@ -621,7 +621,7 @@ var LibraryHTML5 = { {{{ makeSetValue('wheelEvent', C_STRUCTS.EmscriptenWheelEvent.deltaZ, 'e["deltaZ"]', 'double') }}}; {{{ makeSetValue('wheelEvent', C_STRUCTS.EmscriptenWheelEvent.deltaMode, 'e["deltaMode"]', 'i32') }}}; #if PTHREADS - if (targetThread) __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, wheelEvent, userData); + if (targetThread) _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, wheelEvent, userData); else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, wheelEvent, userData)) e.preventDefault(); @@ -681,7 +681,7 @@ var LibraryHTML5 = { #if PTHREADS targetThread = JSEvents.getTargetThreadForEventCallback(targetThread); #endif - JSEvents.uiEvent ||= _malloc({{{ C_STRUCTS.EmscriptenUiEvent.__size__ }}}); + JSEvents.uiEvent ||= malloc({{{ C_STRUCTS.EmscriptenUiEvent.__size__ }}}); #if DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR target = findEventTarget(target); @@ -708,7 +708,7 @@ var LibraryHTML5 = { return; } #if PTHREADS - var uiEvent = targetThread ? _malloc({{{ C_STRUCTS.EmscriptenUiEvent.__size__ }}}) : JSEvents.uiEvent; + var uiEvent = targetThread ? malloc({{{ C_STRUCTS.EmscriptenUiEvent.__size__ }}}) : JSEvents.uiEvent; #else var uiEvent = JSEvents.uiEvent; #endif @@ -722,7 +722,7 @@ var LibraryHTML5 = { {{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.scrollTop, 'pageXOffset | 0', 'i32') }}}; // scroll offsets are float {{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.scrollLeft, 'pageYOffset | 0', 'i32') }}}; #if PTHREADS - if (targetThread) __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, uiEvent, userData); + if (targetThread) _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, uiEvent, userData); else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, uiEvent, userData)) e.preventDefault(); @@ -753,14 +753,14 @@ var LibraryHTML5 = { #if PTHREADS targetThread = JSEvents.getTargetThreadForEventCallback(targetThread); #endif - JSEvents.focusEvent ||= _malloc({{{ C_STRUCTS.EmscriptenFocusEvent.__size__ }}}); + JSEvents.focusEvent ||= malloc({{{ C_STRUCTS.EmscriptenFocusEvent.__size__ }}}); var focusEventHandlerFunc = (e = event) => { var nodeName = JSEvents.getNodeNameForTarget(e.target); var id = e.target.id ? e.target.id : ''; #if PTHREADS - var focusEvent = targetThread ? _malloc({{{ C_STRUCTS.EmscriptenFocusEvent.__size__ }}}) : JSEvents.focusEvent; + var focusEvent = targetThread ? malloc({{{ C_STRUCTS.EmscriptenFocusEvent.__size__ }}}) : JSEvents.focusEvent; #else var focusEvent = JSEvents.focusEvent; #endif @@ -768,7 +768,7 @@ var LibraryHTML5 = { stringToUTF8(id, focusEvent + {{{ C_STRUCTS.EmscriptenFocusEvent.id }}}, {{{ cDefs.EM_HTML5_LONG_STRING_LEN_BYTES }}}); #if PTHREADS - if (targetThread) __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, focusEvent, userData); + if (targetThread) _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, focusEvent, userData); else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, focusEvent, userData)) e.preventDefault(); @@ -817,16 +817,16 @@ var LibraryHTML5 = { #if PTHREADS targetThread = JSEvents.getTargetThreadForEventCallback(targetThread); #endif - JSEvents.deviceOrientationEvent ||= _malloc({{{ C_STRUCTS.EmscriptenDeviceOrientationEvent.__size__ }}}); + JSEvents.deviceOrientationEvent ||= malloc({{{ C_STRUCTS.EmscriptenDeviceOrientationEvent.__size__ }}}); var deviceOrientationEventHandlerFunc = (e = event) => { fillDeviceOrientationEventData(JSEvents.deviceOrientationEvent, e, target); // TODO: Thread-safety with respect to emscripten_get_deviceorientation_status() #if PTHREADS if (targetThread) { - var deviceOrientationEvent = _malloc({{{ C_STRUCTS.EmscriptenDeviceOrientationEvent.__size__ }}}); + var deviceOrientationEvent = malloc({{{ C_STRUCTS.EmscriptenDeviceOrientationEvent.__size__ }}}); fillDeviceOrientationEventData(deviceOrientationEvent, e, target); - __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, deviceOrientationEvent, userData); + _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, deviceOrientationEvent, userData); } else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, JSEvents.deviceOrientationEvent, userData)) e.preventDefault(); @@ -887,16 +887,16 @@ var LibraryHTML5 = { #if PTHREADS targetThread = JSEvents.getTargetThreadForEventCallback(targetThread); #endif - JSEvents.deviceMotionEvent ||= _malloc({{{ C_STRUCTS.EmscriptenDeviceMotionEvent.__size__ }}}); + JSEvents.deviceMotionEvent ||= malloc({{{ C_STRUCTS.EmscriptenDeviceMotionEvent.__size__ }}}); var deviceMotionEventHandlerFunc = (e = event) => { fillDeviceMotionEventData(JSEvents.deviceMotionEvent, e, target); // TODO: Thread-safety with respect to emscripten_get_devicemotion_status() #if PTHREADS if (targetThread) { - var deviceMotionEvent = _malloc({{{ C_STRUCTS.EmscriptenDeviceMotionEvent.__size__ }}}); + var deviceMotionEvent = malloc({{{ C_STRUCTS.EmscriptenDeviceMotionEvent.__size__ }}}); fillDeviceMotionEventData(deviceMotionEvent, e, target); - __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, deviceMotionEvent, userData); + _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, deviceMotionEvent, userData); } else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, JSEvents.deviceMotionEvent, userData)) e.preventDefault(); @@ -969,11 +969,11 @@ var LibraryHTML5 = { #if PTHREADS targetThread = JSEvents.getTargetThreadForEventCallback(targetThread); #endif - JSEvents.orientationChangeEvent ||= _malloc({{{ C_STRUCTS.EmscriptenOrientationChangeEvent.__size__ }}}); + JSEvents.orientationChangeEvent ||= malloc({{{ C_STRUCTS.EmscriptenOrientationChangeEvent.__size__ }}}); var orientationChangeEventHandlerFunc = (e = event) => { #if PTHREADS - var orientationChangeEvent = targetThread ? _malloc({{{ C_STRUCTS.EmscriptenOrientationChangeEvent.__size__ }}}) : JSEvents.orientationChangeEvent; + var orientationChangeEvent = targetThread ? malloc({{{ C_STRUCTS.EmscriptenOrientationChangeEvent.__size__ }}}) : JSEvents.orientationChangeEvent; #else var orientationChangeEvent = JSEvents.orientationChangeEvent; #endif @@ -981,7 +981,7 @@ var LibraryHTML5 = { fillOrientationChangeEventData(orientationChangeEvent); #if PTHREADS - if (targetThread) __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, orientationChangeEvent, userData); + if (targetThread) _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, orientationChangeEvent, userData); else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, orientationChangeEvent, userData)) e.preventDefault(); @@ -1081,11 +1081,11 @@ var LibraryHTML5 = { #if PTHREADS targetThread = JSEvents.getTargetThreadForEventCallback(targetThread); #endif - JSEvents.fullscreenChangeEvent ||= _malloc({{{ C_STRUCTS.EmscriptenFullscreenChangeEvent.__size__ }}}); + JSEvents.fullscreenChangeEvent ||= malloc({{{ C_STRUCTS.EmscriptenFullscreenChangeEvent.__size__ }}}); var fullscreenChangeEventhandlerFunc = (e = event) => { #if PTHREADS - var fullscreenChangeEvent = targetThread ? _malloc({{{ C_STRUCTS.EmscriptenFullscreenChangeEvent.__size__ }}}) : JSEvents.fullscreenChangeEvent; + var fullscreenChangeEvent = targetThread ? malloc({{{ C_STRUCTS.EmscriptenFullscreenChangeEvent.__size__ }}}) : JSEvents.fullscreenChangeEvent; #else var fullscreenChangeEvent = JSEvents.fullscreenChangeEvent; #endif @@ -1093,7 +1093,7 @@ var LibraryHTML5 = { fillFullscreenChangeEventData(fullscreenChangeEvent); #if PTHREADS - if (targetThread) __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, fullscreenChangeEvent, userData); + if (targetThread) _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, fullscreenChangeEvent, userData); else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, fullscreenChangeEvent, userData)) e.preventDefault(); @@ -1168,7 +1168,7 @@ var LibraryHTML5 = { if (strategy.canvasResizedCallback) { #if PTHREADS - if (strategy.canvasResizedCallbackTargetThread) __emscripten_run_callback_on_thread(strategy.canvasResizedCallbackTargetThread, strategy.canvasResizedCallback, {{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, strategy.canvasResizedCallbackUserData); + if (strategy.canvasResizedCallbackTargetThread) _emscripten_run_callback_on_thread(strategy.canvasResizedCallbackTargetThread, strategy.canvasResizedCallback, {{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, strategy.canvasResizedCallbackUserData); else #endif {{{ makeDynCall('iipp', 'strategy.canvasResizedCallback') }}}({{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, strategy.canvasResizedCallbackUserData); @@ -1306,7 +1306,7 @@ var LibraryHTML5 = { if (currentFullscreenStrategy.canvasResizedCallback) { #if PTHREADS - if (currentFullscreenStrategy.canvasResizedCallbackTargetThread) __emscripten_run_callback_on_thread(currentFullscreenStrategy.canvasResizedCallbackTargetThread, currentFullscreenStrategy.canvasResizedCallback, {{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, currentFullscreenStrategy.canvasResizedCallbackUserData); + if (currentFullscreenStrategy.canvasResizedCallbackTargetThread) _emscripten_run_callback_on_thread(currentFullscreenStrategy.canvasResizedCallbackTargetThread, currentFullscreenStrategy.canvasResizedCallback, {{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, currentFullscreenStrategy.canvasResizedCallbackUserData); else #endif {{{ makeDynCall('iipp', 'currentFullscreenStrategy.canvasResizedCallback') }}}({{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, currentFullscreenStrategy.canvasResizedCallbackUserData); @@ -1416,7 +1416,7 @@ var LibraryHTML5 = { if (!inCenteredWithoutScalingFullscreenMode && currentFullscreenStrategy.canvasResizedCallback) { #if PTHREADS - if (currentFullscreenStrategy.canvasResizedCallbackTargetThread) __emscripten_run_callback_on_thread(currentFullscreenStrategy.canvasResizedCallbackTargetThread, currentFullscreenStrategy.canvasResizedCallback, {{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, currentFullscreenStrategy.canvasResizedCallbackUserData); + if (currentFullscreenStrategy.canvasResizedCallbackTargetThread) _emscripten_run_callback_on_thread(currentFullscreenStrategy.canvasResizedCallbackTargetThread, currentFullscreenStrategy.canvasResizedCallback, {{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, currentFullscreenStrategy.canvasResizedCallbackUserData); else #endif {{{ makeDynCall('iipp', 'currentFullscreenStrategy.canvasResizedCallback') }}}({{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, currentFullscreenStrategy.canvasResizedCallbackUserData); @@ -1532,7 +1532,7 @@ var LibraryHTML5 = { removeEventListener('resize', softFullscreenResizeWebGLRenderTarget); if (strategy.canvasResizedCallback) { #if PTHREADS - if (strategy.canvasResizedCallbackTargetThread) __emscripten_run_callback_on_thread(strategy.canvasResizedCallbackTargetThread, strategy.canvasResizedCallback, {{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, strategy.canvasResizedCallbackUserData); + if (strategy.canvasResizedCallbackTargetThread) _emscripten_run_callback_on_thread(strategy.canvasResizedCallbackTargetThread, strategy.canvasResizedCallback, {{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, strategy.canvasResizedCallbackUserData); else #endif {{{ makeDynCall('iipp', 'strategy.canvasResizedCallback') }}}({{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, strategy.canvasResizedCallbackUserData); @@ -1546,7 +1546,7 @@ var LibraryHTML5 = { // Inform the caller that the canvas size has changed. if (strategy.canvasResizedCallback) { #if PTHREADS - if (strategy.canvasResizedCallbackTargetThread) __emscripten_run_callback_on_thread(strategy.canvasResizedCallbackTargetThread, strategy.canvasResizedCallback, {{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, strategy.canvasResizedCallbackUserData); + if (strategy.canvasResizedCallbackTargetThread) _emscripten_run_callback_on_thread(strategy.canvasResizedCallbackTargetThread, strategy.canvasResizedCallback, {{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, strategy.canvasResizedCallbackUserData); else #endif {{{ makeDynCall('iipp', 'strategy.canvasResizedCallback') }}}({{{ cDefs.EMSCRIPTEN_EVENT_CANVASRESIZED }}}, 0, strategy.canvasResizedCallbackUserData); @@ -1611,18 +1611,18 @@ var LibraryHTML5 = { #if PTHREADS targetThread = JSEvents.getTargetThreadForEventCallback(targetThread); #endif - JSEvents.pointerlockChangeEvent ||= _malloc({{{ C_STRUCTS.EmscriptenPointerlockChangeEvent.__size__ }}}); + JSEvents.pointerlockChangeEvent ||= malloc({{{ C_STRUCTS.EmscriptenPointerlockChangeEvent.__size__ }}}); var pointerlockChangeEventHandlerFunc = (e = event) => { #if PTHREADS - var pointerlockChangeEvent = targetThread ? _malloc({{{ C_STRUCTS.EmscriptenPointerlockChangeEvent.__size__ }}}) : JSEvents.pointerlockChangeEvent; + var pointerlockChangeEvent = targetThread ? malloc({{{ C_STRUCTS.EmscriptenPointerlockChangeEvent.__size__ }}}) : JSEvents.pointerlockChangeEvent; #else var pointerlockChangeEvent = JSEvents.pointerlockChangeEvent; #endif fillPointerlockChangeEventData(pointerlockChangeEvent); #if PTHREADS - if (targetThread) __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, pointerlockChangeEvent, userData); + if (targetThread) _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, pointerlockChangeEvent, userData); else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, pointerlockChangeEvent, userData)) e.preventDefault(); @@ -1667,7 +1667,7 @@ var LibraryHTML5 = { var pointerlockErrorEventHandlerFunc = (e = event) => { #if PTHREADS - if (targetThread) __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, 0, userData); + if (targetThread) _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, 0, userData); else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, 0, userData)) e.preventDefault(); @@ -1840,11 +1840,11 @@ var LibraryHTML5 = { #if PTHREADS targetThread = JSEvents.getTargetThreadForEventCallback(targetThread); #endif - JSEvents.visibilityChangeEvent ||= _malloc({{{ C_STRUCTS.EmscriptenVisibilityChangeEvent.__size__ }}}); + JSEvents.visibilityChangeEvent ||= malloc({{{ C_STRUCTS.EmscriptenVisibilityChangeEvent.__size__ }}}); var visibilityChangeEventHandlerFunc = (e = event) => { #if PTHREADS - var visibilityChangeEvent = targetThread ? _malloc({{{ C_STRUCTS.EmscriptenVisibilityChangeEvent.__size__ }}}) : JSEvents.visibilityChangeEvent; + var visibilityChangeEvent = targetThread ? malloc({{{ C_STRUCTS.EmscriptenVisibilityChangeEvent.__size__ }}}) : JSEvents.visibilityChangeEvent; #else var visibilityChangeEvent = JSEvents.visibilityChangeEvent; #endif @@ -1852,7 +1852,7 @@ var LibraryHTML5 = { fillVisibilityChangeEventData(visibilityChangeEvent); #if PTHREADS - if (targetThread) __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, visibilityChangeEvent, userData); + if (targetThread) _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, visibilityChangeEvent, userData); else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, visibilityChangeEvent, userData)) e.preventDefault(); @@ -1894,7 +1894,7 @@ var LibraryHTML5 = { #if PTHREADS targetThread = JSEvents.getTargetThreadForEventCallback(targetThread); #endif - JSEvents.touchEvent ||= _malloc({{{ C_STRUCTS.EmscriptenTouchEvent.__size__ }}}); + JSEvents.touchEvent ||= malloc({{{ C_STRUCTS.EmscriptenTouchEvent.__size__ }}}); target = findEventTarget(target); @@ -1924,7 +1924,7 @@ var LibraryHTML5 = { } #if PTHREADS - var touchEvent = targetThread ? _malloc({{{ C_STRUCTS.EmscriptenTouchEvent.__size__ }}}) : JSEvents.touchEvent; + var touchEvent = targetThread ? malloc({{{ C_STRUCTS.EmscriptenTouchEvent.__size__ }}}) : JSEvents.touchEvent; #else var touchEvent = JSEvents.touchEvent; #endif @@ -1966,7 +1966,7 @@ var LibraryHTML5 = { {{{ makeSetValue('touchEvent', C_STRUCTS.EmscriptenTouchEvent.numTouches, 'numTouches', 'i32') }}}; #if PTHREADS - if (targetThread) __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, touchEvent, userData); + if (targetThread) _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, touchEvent, userData); else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, touchEvent, userData)) e.preventDefault(); @@ -2042,18 +2042,18 @@ var LibraryHTML5 = { #if PTHREADS targetThread = JSEvents.getTargetThreadForEventCallback(targetThread); #endif - JSEvents.gamepadEvent ||= _malloc({{{ C_STRUCTS.EmscriptenGamepadEvent.__size__ }}}); + JSEvents.gamepadEvent ||= malloc({{{ C_STRUCTS.EmscriptenGamepadEvent.__size__ }}}); var gamepadEventHandlerFunc = (e = event) => { #if PTHREADS - var gamepadEvent = targetThread ? _malloc({{{ C_STRUCTS.EmscriptenGamepadEvent.__size__ }}}) : JSEvents.gamepadEvent; + var gamepadEvent = targetThread ? malloc({{{ C_STRUCTS.EmscriptenGamepadEvent.__size__ }}}) : JSEvents.gamepadEvent; #else var gamepadEvent = JSEvents.gamepadEvent; #endif fillGamepadEventData(gamepadEvent, e["gamepad"]); #if PTHREADS - if (targetThread) __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, gamepadEvent, userData); + if (targetThread) _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, gamepadEvent, userData); else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, gamepadEvent, userData)) e.preventDefault(); @@ -2075,14 +2075,14 @@ var LibraryHTML5 = { emscripten_set_gamepadconnected_callback_on_thread__proxy: 'sync', emscripten_set_gamepadconnected_callback_on_thread__deps: ['$registerGamepadEventCallback', 'emscripten_sample_gamepad_data'], emscripten_set_gamepadconnected_callback_on_thread: (userData, useCapture, callbackfunc, targetThread) => { - if (_emscripten_sample_gamepad_data()) return {{{ cDefs.EMSCRIPTEN_RESULT_NOT_SUPPORTED }}}; + if (emscripten_sample_gamepad_data()) return {{{ cDefs.EMSCRIPTEN_RESULT_NOT_SUPPORTED }}}; return registerGamepadEventCallback({{{ cDefs.EMSCRIPTEN_EVENT_TARGET_WINDOW }}}, userData, useCapture, callbackfunc, {{{ cDefs.EMSCRIPTEN_EVENT_GAMEPADCONNECTED }}}, "gamepadconnected", targetThread); }, emscripten_set_gamepaddisconnected_callback_on_thread__proxy: 'sync', emscripten_set_gamepaddisconnected_callback_on_thread__deps: ['$registerGamepadEventCallback', 'emscripten_sample_gamepad_data'], emscripten_set_gamepaddisconnected_callback_on_thread: (userData, useCapture, callbackfunc, targetThread) => { - if (_emscripten_sample_gamepad_data()) return {{{ cDefs.EMSCRIPTEN_RESULT_NOT_SUPPORTED }}}; + if (emscripten_sample_gamepad_data()) return {{{ cDefs.EMSCRIPTEN_RESULT_NOT_SUPPORTED }}}; return registerGamepadEventCallback({{{ cDefs.EMSCRIPTEN_EVENT_TARGET_WINDOW }}}, userData, useCapture, callbackfunc, {{{ cDefs.EMSCRIPTEN_EVENT_GAMEPADDISCONNECTED }}}, "gamepaddisconnected", targetThread); }, @@ -2182,18 +2182,18 @@ var LibraryHTML5 = { #if PTHREADS targetThread = JSEvents.getTargetThreadForEventCallback(targetThread); #endif - JSEvents.batteryEvent ||= _malloc({{{ C_STRUCTS.EmscriptenBatteryEvent.__size__ }}}); + JSEvents.batteryEvent ||= malloc({{{ C_STRUCTS.EmscriptenBatteryEvent.__size__ }}}); var batteryEventHandlerFunc = (e = event) => { #if PTHREADS - var batteryEvent = targetThread ? _malloc({{{ C_STRUCTS.EmscriptenBatteryEvent.__size__ }}}) : JSEvents.batteryEvent; + var batteryEvent = targetThread ? malloc({{{ C_STRUCTS.EmscriptenBatteryEvent.__size__ }}}) : JSEvents.batteryEvent; #else var batteryEvent = JSEvents.batteryEvent; #endif fillBatteryEventData(batteryEvent, battery()); #if PTHREADS - if (targetThread) __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, batteryEvent, userData); + if (targetThread) _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, batteryEvent, userData); else #endif if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, batteryEvent, userData)) e.preventDefault(); @@ -2354,7 +2354,7 @@ var LibraryHTML5 = { // and it needs to synchronously proxy over to another thread, so marshal the string onto the heap to do the call. var sp = stackSave(); var targetInt = stringToUTF8OnStack(target.id); - _emscripten_set_canvas_element_size(targetInt, width, height); + emscripten_set_canvas_element_size(targetInt, width, height); stackRestore(sp); } }, @@ -2430,7 +2430,7 @@ var LibraryHTML5 = { var h = w + 4; var targetInt = stringToUTF8OnStack(target.id); - var ret = _emscripten_get_canvas_element_size(targetInt, w, h); + var ret = emscripten_get_canvas_element_size(targetInt, w, h); var size = [{{{ makeGetValue('w', 0, 'i32')}}}, {{{ makeGetValue('h', 0, 'i32')}}}]; stackRestore(sp); return size; diff --git a/src/library_html5_webgl.js b/src/library_html5_webgl.js index 64dec4c0d43b1..68e9111f934af 100644 --- a/src/library_html5_webgl.js +++ b/src/library_html5_webgl.js @@ -31,7 +31,7 @@ var LibraryHtml5WebGL = { emscripten_webgl_create_context_proxied__proxy: 'sync', emscripten_webgl_create_context_proxied__deps: ['emscripten_webgl_do_create_context'], emscripten_webgl_create_context_proxied: (target, attributes) => - _emscripten_webgl_do_create_context(target, attributes), + emscripten_webgl_do_create_context(target, attributes), // The other proxied GL commands are defined in C (guarded by the // __EMSCRIPTEN_OFFSCREEN_FRAMEBUFFER__ definition). @@ -111,11 +111,11 @@ var LibraryHtml5WebGL = { dbg('Performance warning: forcing renderViaOffscreenBackBuffer=true and preserveDrawingBuffer=true since proxying WebGL rendering.'); #endif // We will be proxying - if OffscreenCanvas is supported, we can proxy a bit more efficiently by avoiding having to create an Offscreen FBO. - if (!_emscripten_supports_offscreencanvas()) { + if (!emscripten_supports_offscreencanvas()) { {{{ makeSetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.renderViaOffscreenBackBuffer, '1', 'i8') }}}; {{{ makeSetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.preserveDrawingBuffer, '1', 'i8') }}}; } - return _emscripten_webgl_create_context_proxied(target, attributes); + return emscripten_webgl_create_context_proxied(target, attributes); } } #endif @@ -131,12 +131,12 @@ var LibraryHtml5WebGL = { if (canvas.offscreenCanvas) canvas = canvas.offscreenCanvas; #if GL_DEBUG - if (_emscripten_supports_offscreencanvas() && canvas instanceof OffscreenCanvas) dbg(`emscripten_webgl_create_context: Creating an OffscreenCanvas-based WebGL context on target "${targetStr}"`); + if (emscripten_supports_offscreencanvas() && canvas instanceof OffscreenCanvas) dbg(`emscripten_webgl_create_context: Creating an OffscreenCanvas-based WebGL context on target "${targetStr}"`); else if (typeof HTMLCanvasElement != 'undefined' && canvas instanceof HTMLCanvasElement) dbg(`emscripten_webgl_create_context: Creating an HTMLCanvasElement-based WebGL context on target "${targetStr}"`); #endif if (contextAttributes.explicitSwapControl) { - var supportsOffscreenCanvas = canvas.transferControlToOffscreen || (_emscripten_supports_offscreencanvas() && canvas instanceof OffscreenCanvas); + var supportsOffscreenCanvas = canvas.transferControlToOffscreen || (emscripten_supports_offscreencanvas() && canvas instanceof OffscreenCanvas); if (!supportsOffscreenCanvas) { #if OFFSCREEN_FRAMEBUFFER @@ -161,7 +161,7 @@ var LibraryHtml5WebGL = { if (!canvas.controlTransferredOffscreen) { GL.offscreenCanvases[canvas.id] = { canvas: canvas.transferControlToOffscreen(), - canvasSharedPtr: _malloc(12), + canvasSharedPtr: malloc(12), id: canvas.id }; canvas.controlTransferredOffscreen = true; @@ -249,7 +249,7 @@ var LibraryHtml5WebGL = { emscripten_webgl_do_commit_frame: () => { #if TRACE_WEBGL_CALLS - var threadId = (typeof _pthread_self != 'undefined') ? _pthread_self : () => 1; + var threadId = (typeof pthread_self != 'undefined') ? _pthread_self : () => 1; err(`[Thread ${threadId()}, GL ctx: ${GL.currentContext.handle}]: emscripten_webgl_do_commit_frame()`); #endif if (!GL.currentContext || !GL.currentContext.GLctx) { @@ -322,7 +322,7 @@ var LibraryHtml5WebGL = { // the call over to the target thread. $emscripten_webgl_destroy_context_before_on_calling_thread__deps: ['emscripten_webgl_get_current_context', 'emscripten_webgl_make_context_current'], $emscripten_webgl_destroy_context_before_on_calling_thread: (contextHandle) => { - if (_emscripten_webgl_get_current_context() == contextHandle) _emscripten_webgl_make_context_current(0); + if (emscripten_webgl_get_current_context() == contextHandle) emscripten_webgl_make_context_current(0); }, #endif @@ -413,7 +413,7 @@ var LibraryHtml5WebGL = { var webGlEventHandlerFunc = (e = event) => { #if PTHREADS - if (targetThread) __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, 0, userData); + if (targetThread) _emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, 0, userData); else #endif if ({{{ makeDynCall('iiii', 'callbackfunc') }}}(eventTypeId, 0, userData)) e.preventDefault(); diff --git a/src/library_idbstore.js b/src/library_idbstore.js index 336fa259ffaac..63b8102887319 100644 --- a/src/library_idbstore.js +++ b/src/library_idbstore.js @@ -25,10 +25,10 @@ var LibraryIDBStore = { if (onerror) {{{ makeDynCall('vp', 'onerror') }}}(arg); return; } - var buffer = _malloc(byteArray.length); + var buffer = malloc(byteArray.length); HEAPU8.set(byteArray, buffer); {{{ makeDynCall('vppi', 'onload') }}}(arg, buffer, byteArray.length); - _free(buffer); + free(buffer); }); }); }, @@ -101,7 +101,7 @@ var LibraryIDBStore = { wakeUp(); return; } - var buffer = _malloc(byteArray.length); // must be freed by the caller! + var buffer = malloc(byteArray.length); // must be freed by the caller! HEAPU8.set(byteArray, buffer); {{{ makeSetValue('pbuffer', 0, 'buffer', '*') }}}; {{{ makeSetValue('pnum', 0, 'byteArray.length', 'i32') }}}; diff --git a/src/library_legacy.js b/src/library_legacy.js index 5bfd84b92bc14..3195c9eb68f91 100644 --- a/src/library_legacy.js +++ b/src/library_legacy.js @@ -5,14 +5,14 @@ */ legacyFuncs = { - $ALLOC_NORMAL: 0, // Tries to use _malloc() + $ALLOC_NORMAL: 0, // Tries to use malloc() $ALLOC_STACK: 1, // Lives for the duration of the current function call /** * allocate(): This function is no longer used by emscripten but is kept around to avoid * breaking external users. * You should normally not use allocate(), and instead allocate - * memory using _malloc()/stackAlloc(), initialize it with + * memory using malloc()/stackAlloc(), initialize it with * setValue(), and so forth. * @param {(Uint8Array|Array)} slab: An array of data. * @param {number=} allocator : How to allocate memory, see ALLOC_* @@ -28,7 +28,7 @@ legacyFuncs = { if (allocator == ALLOC_STACK) { ret = stackAlloc(slab.length); } else { - ret = _malloc(slab.length); + ret = malloc(slab.length); } if (!slab.subarray && !slab.slice) { @@ -79,7 +79,7 @@ legacyFuncs = { #if SUPPORT_ERRNO $setErrNo__deps: ['__errno_location'], $setErrNo: (value) => { - {{{makeSetValue("___errno_location()", 0, 'value', 'i32') }}}; + {{{makeSetValue("__errno_location()", 0, 'value', 'i32') }}}; return value; }, #else @@ -105,14 +105,14 @@ legacyFuncs = { s = s.substr(1); var buf = stringToUTF8OnStack(s); var status = stackAlloc(4); - var ret = ___cxa_demangle(buf, 0, 0, status); + var ret = __cxa_demangle(buf, 0, 0, status); if ({{{ makeGetValue('status', '0', 'i32') }}} === 0 && ret) { return UTF8ToString(ret); } // otherwise, libcxxabi failed } catch(e) { } finally { - _free(ret); + free(ret); if (demangle.recursionGuard < 2) --demangle.recursionGuard; } // failure when using libcxxabi, don't demangle diff --git a/src/library_nodefs.js b/src/library_nodefs.js index d30c69815c133..3799c77596bff 100644 --- a/src/library_nodefs.js +++ b/src/library_nodefs.js @@ -9,7 +9,7 @@ addToLibrary({ $NODEFS__deps: ['$stringToUTF8OnStack', 'wasmfs_create_node_backend'], $NODEFS: { createBackend(opts) { - return _wasmfs_create_node_backend(stringToUTF8OnStack(opts.root)); + return wasmfs_create_node_backend(stringToUTF8OnStack(opts.root)); } } #else diff --git a/src/library_openal.js b/src/library_openal.js index 446d7f2fb7878..a8110f63a160f 100644 --- a/src/library_openal.js +++ b/src/library_openal.js @@ -2656,7 +2656,7 @@ var LibraryOpenAL = { AL.alcErr = {{{ cDefs.ALC_INVALID_ENUM }}}; return 0; } - return _alcGetString(deviceId, param); + return alcGetString(deviceId, param); } ret = stringToNewUTF8(ret); @@ -2868,7 +2868,7 @@ var LibraryOpenAL = { for (var i = 0; i < count; ++i) { var srcId = {{{ makeGetValue('pSourceIds', 'i*4', 'i32') }}}; AL.setSourceState(AL.currentCtx.sources[srcId], {{{ cDefs.AL_STOPPED }}}); - _alSourcei(srcId, 0x1009 /* AL_BUFFER */, 0); + alSourcei(srcId, 0x1009 /* AL_BUFFER */, 0); delete AL.currentCtx.sources[srcId]; AL.freeIds.push(srcId); } diff --git a/src/library_promise.js b/src/library_promise.js index 406c319042b30..ab55857033da9 100644 --- a/src/library_promise.js +++ b/src/library_promise.js @@ -63,7 +63,7 @@ addToLibrary({ return; case {{{ cDefs.EM_PROMISE_MATCH_RELEASE }}}: info.resolve(getPromise(value)); - _emscripten_promise_destroy(value); + emscripten_promise_destroy(value); return; case {{{ cDefs.EM_PROMISE_REJECT }}}: info.reject(value); @@ -122,7 +122,7 @@ addToLibrary({ return getPromise(resultVal); case {{{ cDefs.EM_PROMISE_MATCH_RELEASE }}}: var ret = getPromise(resultVal); - _emscripten_promise_destroy(resultVal); + emscripten_promise_destroy(resultVal); return ret; case {{{ cDefs.EM_PROMISE_REJECT }}}: throw resultVal; diff --git a/src/library_pthread.js b/src/library_pthread.js index 1daa32022aad1..e16ca61ff0fc9 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -68,12 +68,12 @@ var LibraryPThread = { debugInit() { function pthreadLogPrefix() { var t = 0; - if (runtimeInitialized && typeof _pthread_self != 'undefined' + if (runtimeInitialized && typeof pthread_self != 'undefined' #if EXIT_RUNTIME && !runtimeExited #endif ) { - t = _pthread_self(); + t = pthread_self(); } return `w:${workerID},t:${ptrToString(t)}: `; } @@ -200,7 +200,7 @@ var LibraryPThread = { // Finally, free the underlying (and now-unused) pthread structure in // linear memory. - __emscripten_thread_free_data(pthread_ptr); + _emscripten_thread_free_data(pthread_ptr); }, receiveObjectTransfer(data) { #if OFFSCREENCANVAS_SUPPORT @@ -233,7 +233,7 @@ var LibraryPThread = { // If this message is intended to a recipient that is not the main // thread, forward it to the target thread. - if (d.targetThread && d.targetThread != _pthread_self()) { + if (d.targetThread && d.targetThread != pthread_self()) { var targetWorker = PThread.pthreads[d.targetThread]; if (targetWorker) { targetWorker.postMessage(d, d.transferList); @@ -651,7 +651,7 @@ var LibraryPThread = { // Pass the thread address to the native code where they stored in wasm // globals which act as a form of TLS. Global constructors trying // to access this value will read the wrong value, but that is UB anyway. - __emscripten_thread_init( + _emscripten_thread_init( tb, /*is_main=*/!ENVIRONMENT_IS_WORKER, /*is_runtime=*/1, @@ -669,7 +669,7 @@ var LibraryPThread = { $pthreadCreateProxied__internal: true, $pthreadCreateProxied__proxy: 'sync', $pthreadCreateProxied__deps: ['__pthread_create_js'], - $pthreadCreateProxied: (pthread_ptr, attr, startRoutine, arg) => ___pthread_create_js(pthread_ptr, attr, startRoutine, arg), + $pthreadCreateProxied: (pthread_ptr, attr, startRoutine, arg) => __pthread_create_js(pthread_ptr, attr, startRoutine, arg), #if OFFSCREENCANVAS_SUPPORT // ASan wraps the emscripten_builtin_pthread_create call in @@ -688,7 +688,7 @@ var LibraryPThread = { #endif ], __pthread_create_js: (pthread_ptr, attr, startRoutine, arg) => { - if (!_emscripten_has_threading_support()) { + if (!emscripten_has_threading_support()) { #if ASSERTIONS dbg('pthread_create: environment does not support SharedArrayBuffer, pthreads are not available'); #endif @@ -764,7 +764,7 @@ var LibraryPThread = { // Create a shared information block in heap so that we can control // the canvas size from any thread. if (!canvas.canvasSharedPtr) { - canvas.canvasSharedPtr = _malloc({{{ 8 + POINTER_SIZE }}}); + canvas.canvasSharedPtr = malloc({{{ 8 + POINTER_SIZE }}}); {{{ makeSetValue('canvas.canvasSharedPtr', 0, 'canvas.width', 'i32') }}}; {{{ makeSetValue('canvas.canvasSharedPtr', 4, 'canvas.height', 'i32') }}}; {{{ makeSetValue('canvas.canvasSharedPtr', 8, 0, '*') }}}; // pthread ptr to the thread that owns this canvas, filled in below. @@ -884,7 +884,7 @@ var LibraryPThread = { #if PROXY_TO_PTHREAD {{{ runtimeKeepalivePop() }}}; #endif - _exit(returnCode); + exit(returnCode); }, #if MEMORY64 @@ -933,7 +933,7 @@ var LibraryPThread = { HEAPF64[b + i] = arg; #endif } - var rtn = __emscripten_run_on_main_thread_js(funcIndex, emAsmAddr, serializedNumCallArgs, args, sync); + var rtn = _emscripten_run_on_main_thread_js(funcIndex, emAsmAddr, serializedNumCallArgs, args, sync); stackRestore(sp); return rtn; }, @@ -1020,7 +1020,7 @@ var LibraryPThread = { #endif // Set stack limits used by `emscripten/stack.h` function. These limits are // cached in wasm-side globals to make checks as fast as possible. - _emscripten_stack_set_limits(stackHigh, stackLow); + emscripten_stack_set_limits(stackHigh, stackLow); #if STACK_OVERFLOW_CHECK >= 2 setStackLimits(); @@ -1068,7 +1068,7 @@ var LibraryPThread = { // Before we call the thread entry point, make sure any shared libraries // have been loaded on this there. Otherwise our table might be not be // in sync and might not contain the function pointer `ptr` at all. - __emscripten_dlsync_self(); + _emscripten_dlsync_self(); #endif // pthread entry points are always of signature 'void *ThreadMain(void *arg)' // Native codebases sometimes spawn threads with other thread entry point @@ -1090,12 +1090,12 @@ var LibraryPThread = { // In MINIMAL_RUNTIME the noExitRuntime concept does not apply to // pthreads. To exit a pthread with live runtime, use the function // emscripten_unwind_to_js_event_loop() in the pthread body. - __emscripten_thread_exit(result); + _emscripten_thread_exit(result); #else if (keepRuntimeAlive()) { EXITSTATUS = result; } else { - __emscripten_thread_exit(result); + _emscripten_thread_exit(result); } #endif } @@ -1146,19 +1146,19 @@ var LibraryPThread = { // This first promise resolves once the main thread has loaded all modules. var info = makePromise(); promises.push(info.promise); - __emscripten_dlsync_self_async(info.id); + _emscripten_dlsync_self_async(info.id); // We then create a sequence of promises, one per thread, that resolve once // each thread has performed its sync using _emscripten_proxy_dlsync. // Any new threads that are created after this call will automatically be - // in sync because we call `__emscripten_dlsync_self` in + // in sync because we call `_emscripten_dlsync_self` in // invokeEntryPoint before the threads entry point is called. for (const ptr of Object.keys(PThread.pthreads)) { const pthread_ptr = Number(ptr); if (pthread_ptr !== caller && !PThread.finishedThreads.has(pthread_ptr)) { info = makePromise(); - __emscripten_proxy_dlsync_async(pthread_ptr, info.id); + _emscripten_proxy_dlsync_async(pthread_ptr, info.id); PThread.outstandingPromises[pthread_ptr] = info; promises.push(info.promise); } @@ -1191,7 +1191,7 @@ var LibraryPThread = { for (const ptr of Object.keys(PThread.pthreads)) { const pthread_ptr = Number(ptr); if (!PThread.finishedThreads.has(pthread_ptr)) { - __emscripten_proxy_dlsync(pthread_ptr); + _emscripten_proxy_dlsync(pthread_ptr); } } }, @@ -1209,14 +1209,14 @@ var LibraryPThread = { $checkMailbox: () => { // Only check the mailbox if we have a live pthread runtime. We implement // pthread_self to return 0 if there is no live runtime. - var pthread_ptr = _pthread_self(); + var pthread_ptr = pthread_self(); if (pthread_ptr) { // If we are using Atomics.waitAsync as our notification mechanism, wait // for a notification before processing the mailbox to avoid missing any // work that could otherwise arrive after we've finished processing the // mailbox and before we're ready for the next notification. - __emscripten_thread_mailbox_await(pthread_ptr); - callUserCallback(__emscripten_check_mailbox); + _emscripten_thread_mailbox_await(pthread_ptr); + callUserCallback(_emscripten_check_mailbox); } }, diff --git a/src/library_sdl.js b/src/library_sdl.js index ff5a5ace624ca..b58f18585e771 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -352,8 +352,8 @@ var LibrarySDL = { var is_SDL_HWPALETTE = flags & {{{ cDefs.SDL_HWPALETTE }}}; var is_SDL_OPENGL = flags & {{{ cDefs.SDL_OPENGL }}}; - var surf = _malloc({{{ C_STRUCTS.SDL_Surface.__size__ }}}); - var pixelFormat = _malloc({{{ C_STRUCTS.SDL_PixelFormat.__size__ }}}); + var surf = malloc({{{ C_STRUCTS.SDL_Surface.__size__ }}}); + var pixelFormat = malloc({{{ C_STRUCTS.SDL_PixelFormat.__size__ }}}); // surface with SDL_HWPALETTE flag is 8bpp surface (1 byte) var bpp = is_SDL_HWPALETTE ? 1 : 4; var buffer = 0; @@ -361,7 +361,7 @@ var LibrarySDL = { // preemptively initialize this for software surfaces, // otherwise it will be lazily initialized inside of SDL_LockSurface if (!is_SDL_HWSURFACE && !is_SDL_OPENGL) { - buffer = _malloc(width * height * 4); + buffer = malloc(width * height * 4); } {{{ makeSetValue('surf', C_STRUCTS.SDL_Surface.flags, 'flags', 'i32') }}}; @@ -481,9 +481,9 @@ var LibrarySDL = { var info = SDL.surfaces[surf]; if (!info.usePageCanvas && info.canvas) SDL.canvasPool.push(info.canvas); - if (info.buffer) _free(info.buffer); - _free(info.pixelFormat); - _free(surf); + if (info.buffer) free(info.buffer); + free(info.pixelFormat); + free(surf); SDL.surfaces[surf] = null; if (surf === SDL.screen) { @@ -534,7 +534,7 @@ var LibrarySDL = { if (dst != SDL.screen) { // XXX As in IMG_Load, for compatibility we write out |pixels| warnOnce('WARNING: copying canvas data to memory for compatibility'); - _SDL_LockSurface(dst); + SDL_LockSurface(dst); dstData.locked--; // The surface is not actually locked in this hack } return 0; @@ -929,8 +929,8 @@ var LibrarySDL = { makeCEvent(event, ptr) { if (typeof event == 'number') { // This is a pointer to a copy of a native C event that was SDL_PushEvent'ed - _memcpy(ptr, event, {{{ C_STRUCTS.SDL_KeyboardEvent.__size__ }}}); - _free(event); // the copy is no longer needed + memcpy(ptr, event, {{{ C_STRUCTS.SDL_KeyboardEvent.__size__ }}}); + free(event); // the copy is no longer needed return; } @@ -1016,7 +1016,7 @@ var LibrarySDL = { if (touch['deviceID'] === undefined) touch.deviceID = SDL.TOUCH_DEFAULT_ID; if (dx === 0 && dy === 0 && event.type === 'touchmove') return false; // don't send these if nothing happened {{{ makeSetValue('ptr', C_STRUCTS.SDL_TouchFingerEvent.type, 'SDL.DOMEventToSDLEvent[event.type]', 'i32') }}}; - {{{ makeSetValue('ptr', C_STRUCTS.SDL_TouchFingerEvent.timestamp, '_SDL_GetTicks()', 'i32') }}}; + {{{ makeSetValue('ptr', C_STRUCTS.SDL_TouchFingerEvent.timestamp, 'SDL_GetTicks()', 'i32') }}}; {{{ makeSetValue('ptr', C_STRUCTS.SDL_TouchFingerEvent.touchId, 'touch.deviceID', 'i64') }}}; {{{ makeSetValue('ptr', C_STRUCTS.SDL_TouchFingerEvent.fingerId, 'touch.identifier', 'i64') }}}; {{{ makeSetValue('ptr', C_STRUCTS.SDL_TouchFingerEvent.x, 'x', 'float') }}}; @@ -1370,7 +1370,7 @@ var LibrarySDL = { SDL_Linked_Version__proxy: 'sync', SDL_Linked_Version: () => { if (SDL.version === null) { - SDL.version = _malloc({{{ C_STRUCTS.SDL_version.__size__ }}}); + SDL.version = malloc({{{ C_STRUCTS.SDL_version.__size__ }}}); {{{ makeSetValue('SDL.version', C_STRUCTS.SDL_version.major, '1', 'i8') }}}; {{{ makeSetValue('SDL.version', C_STRUCTS.SDL_version.minor, '3', 'i8') }}}; {{{ makeSetValue('SDL.version', C_STRUCTS.SDL_version.patch, '0', 'i8') }}}; @@ -1397,7 +1397,7 @@ var LibrarySDL = { } window.addEventListener("unload", SDL.receiveEvent); - SDL.keyboardState = _calloc(0x10000, 1); // Our SDL needs 512, but 64K is safe for older SDLs + SDL.keyboardState = calloc(0x10000, 1); // Our SDL needs 512, but 64K is safe for older SDLs // Initialize this structure carefully for closure SDL.DOMEventToSDLEvent['keydown'] = {{{ cDefs.SDL_KEYDOWN }}}; SDL.DOMEventToSDLEvent['keyup'] = {{{ cDefs.SDL_KEYUP }}}; @@ -1428,7 +1428,7 @@ var LibrarySDL = { SDL_WasInit__proxy: 'sync', SDL_WasInit: (flags) => { if (SDL.startTime === null) { - _SDL_Init(0); + SDL_Init(0); } return 1; }, @@ -1436,7 +1436,7 @@ var LibrarySDL = { SDL_GetVideoInfo__deps: ['calloc'], SDL_GetVideoInfo__proxy: 'sync', SDL_GetVideoInfo: () => { - var ret = _calloc({{{ C_STRUCTS.SDL_VideoInfo.__size__ }}}, 1); + var ret = calloc({{{ C_STRUCTS.SDL_VideoInfo.__size__ }}}, 1); {{{ makeSetValue('ret', C_STRUCTS.SDL_VideoInfo.current_w, 'Module["canvas"].width', 'i32') }}}; {{{ makeSetValue('ret', C_STRUCTS.SDL_VideoInfo.current_h, 'Module["canvas"].height', 'i32') }}}; return ret; @@ -1543,7 +1543,7 @@ var LibrarySDL = { SDL_Quit__deps: ['SDL_AudioQuit'], SDL_Quit: () => { - _SDL_AudioQuit(); + SDL_AudioQuit(); out('SDL_Quit called (and ignored)'); }, @@ -1556,7 +1556,7 @@ var LibrarySDL = { if (surfData.locked > 1) return 0; if (!surfData.buffer) { - surfData.buffer = _malloc(surfData.width * surfData.height * 4); + surfData.buffer = malloc(surfData.width * surfData.height * 4); {{{ makeSetValue('surf', C_STRUCTS.SDL_Surface.pixels, 'surfData.buffer', POINTER_TYPE) }}}; } @@ -1753,7 +1753,7 @@ var LibrarySDL = { SDL_WM_SetCaption__deps: ['emscripten_set_window_title'], SDL_WM_SetCaption: (title, icon) => { if (title) { - _emscripten_set_window_title(title); + emscripten_set_window_title(title); } icon &&= UTF8ToString(icon); }, @@ -1771,7 +1771,7 @@ var LibrarySDL = { }, SDL_GetKeyState__deps: ['SDL_GetKeyboardState'], - SDL_GetKeyState: () => _SDL_GetKeyboardState(0), + SDL_GetKeyState: () => SDL_GetKeyboardState(0), SDL_GetKeyName__proxy: 'sync', SDL_GetKeyName__deps: ['$stringToUTF8', 'realloc'], @@ -1890,7 +1890,7 @@ var LibrarySDL = { }, SDL_DisplayFormatAlpha__deps: ['SDL_ConvertSurface'], - SDL_DisplayFormatAlpha: (surf) => _SDL_ConvertSurface(surf, 0, 0), + SDL_DisplayFormatAlpha: (surf) => SDL_ConvertSurface(surf, 0, 0), SDL_FreeSurface__proxy: 'sync', SDL_FreeSurface: (surf) => { @@ -1978,7 +1978,7 @@ var LibrarySDL = { rotozoomSurface__deps: ['zoomSurface'], rotozoomSurface: (src, angle, zoom, smooth) => { if (angle % 360 === 0) { - return _zoomSurface(src, zoom, zoom, smooth); + return zoomSurface(src, zoom, zoom, smooth); } var srcData = SDL.surfaces[src]; var w = srcData.width * zoom; @@ -2018,8 +2018,8 @@ var LibrarySDL = { SDL_PushEvent__proxy: 'sync', SDL_PushEvent: (ptr) => { - var copy = _malloc({{{ C_STRUCTS.SDL_KeyboardEvent.__size__ }}}); - _memcpy(copy, ptr, {{{ C_STRUCTS.SDL_KeyboardEvent.__size__ }}}); + var copy = malloc({{{ C_STRUCTS.SDL_KeyboardEvent.__size__ }}}); + memcpy(copy, ptr, {{{ C_STRUCTS.SDL_KeyboardEvent.__size__ }}}); SDL.events.push(copy); return 0; }, @@ -2066,7 +2066,7 @@ var LibrarySDL = { SDL.eventHandlerContext = userdata; // All SDLEvents take the same amount of memory - SDL.eventHandlerTemp ||= _malloc({{{ C_STRUCTS.SDL_KeyboardEvent.__size__ }}}); + SDL.eventHandlerTemp ||= malloc({{{ C_STRUCTS.SDL_KeyboardEvent.__size__ }}}); }, SDL_SetColors__proxy: 'sync', @@ -2096,7 +2096,7 @@ var LibrarySDL = { SDL_SetPalette__deps: ['SDL_SetColors'], SDL_SetPalette: (surf, flags, colors, firstColor, nColors) => - _SDL_SetColors(surf, colors, firstColor, nColors), + SDL_SetColors(surf, colors, firstColor, nColors), SDL_MapRGB__proxy: 'sync', SDL_MapRGB: (fmt, r, g, b) => { @@ -2187,7 +2187,7 @@ var LibrarySDL = { // stb_image integration support var cleanup = () => { stackRestore(sp); - if (rwops && freeSrc) _SDL_FreeRW(rwopsID); + if (rwops && freeSrc) SDL_FreeRW(rwopsID); } var addCleanup = (func) => { var old = cleanup; @@ -2309,7 +2309,7 @@ var LibrarySDL = { // there are cases where you just want to blit them, so you just need the hardware // accelerated version. However, code everywhere seems to assume that the pixels // are in fact available, so we retrieve it here. This does add overhead though. - _SDL_LockSurface(surf); + SDL_LockSurface(surf); surfData.locked--; // The surface is not actually locked in this hack if (SDL.GL) { // After getting the pixel data, we can free the canvas and context if we do not need to do 2D canvas blitting @@ -2325,8 +2325,8 @@ var LibrarySDL = { IMG_Load__deps: ['IMG_Load_RW', 'SDL_RWFromFile'], IMG_Load__proxy: 'sync', IMG_Load: (filename) => { - var rwops = _SDL_RWFromFile(filename, 0); - var result = _IMG_Load_RW(rwops, 1); + var rwops = SDL_RWFromFile(filename, 0); + var result = IMG_Load_RW(rwops, 1); return result; }, @@ -2408,7 +2408,7 @@ var LibrarySDL = { SDL.audio.bufferDurationSecs = SDL.audio.bufferSize / SDL.audio.bytesPerSample / SDL.audio.channels / SDL.audio.freq; // Audio samples are played with a constant delay of this many seconds to account for browser and jitter. SDL.audio.bufferingDelay = 50 / 1000; - SDL.audio.buffer = _malloc(SDL.audio.bufferSize); + SDL.audio.buffer = malloc(SDL.audio.bufferSize); // To account for jittering in frametimes, always have multiple audio // buffers queued up for the audio output device. @@ -2594,8 +2594,8 @@ var LibrarySDL = { SDL.audio.callbackRemover(); SDL.audio.callbackRemover = null; } - _SDL_PauseAudio(1); - _free(SDL.audio.buffer); + SDL_PauseAudio(1); + free(SDL.audio.buffer); SDL.audio = null; SDL.allocateChannels(0); } @@ -2662,9 +2662,9 @@ var LibrarySDL = { Mix_Volume: (channel, volume) => { if (channel == -1) { for (var i = 0; i < SDL.numChannels-1; i++) { - _Mix_Volume(i, volume); + Mix_Volume(i, volume); } - return _Mix_Volume(SDL.numChannels-1, volume); + return Mix_Volume(SDL.numChannels-1, volume); } return SDL.setGetVolume(SDL.channels[channel], volume); }, @@ -2700,7 +2700,7 @@ var LibrarySDL = { if (type === 2/*SDL_RWOPS_STDFILE*/) { var fp = {{{ makeGetValue('rwopsID', C_STRUCTS.SDL_RWops.hidden.stdio.fp, 'i32') }}}; - var fd = _fileno(fp); + var fd = fileno(fp); var stream = FS.getStream(fd); if (stream) { rwops = { filename: stream.path }; @@ -2797,9 +2797,9 @@ var LibrarySDL = { Mix_LoadWAV__deps: ['Mix_LoadWAV_RW', 'SDL_RWFromFile', 'SDL_FreeRW'], Mix_LoadWAV__proxy: 'sync', Mix_LoadWAV: (filename) => { - var rwops = _SDL_RWFromFile(filename, 0); - var result = _Mix_LoadWAV_RW(rwops, 0); - _SDL_FreeRW(rwops); + var rwops = SDL_RWFromFile(filename, 0); + var result = Mix_LoadWAV_RW(rwops, 0); + SDL_FreeRW(rwops); return result; }, @@ -2931,7 +2931,7 @@ var LibrarySDL = { Mix_HookMusicFinished: (func) => { SDL.hookMusicFinished = func; if (SDL.music.audio) { // ensure the callback will be called, if a music is already playing - SDL.music.audio['onended'] = _Mix_HaltMusic; + SDL.music.audio['onended'] = Mix_HaltMusic; } }, @@ -2939,14 +2939,14 @@ var LibrarySDL = { Mix_VolumeMusic: (volume) => SDL.setGetVolume(SDL.music, volume), Mix_LoadMUS_RW__deps: ['Mix_LoadWAV_RW'], - Mix_LoadMUS_RW: (filename) => _Mix_LoadWAV_RW(filename, 0), + Mix_LoadMUS_RW: (filename) => Mix_LoadWAV_RW(filename, 0), Mix_LoadMUS__deps: ['Mix_LoadMUS_RW', 'SDL_RWFromFile', 'SDL_FreeRW'], Mix_LoadMUS__proxy: 'sync', Mix_LoadMUS: (filename) => { - var rwops = _SDL_RWFromFile(filename, 0); - var result = _Mix_LoadMUS_RW(rwops); - _SDL_FreeRW(rwops); + var rwops = SDL_RWFromFile(filename, 0); + var result = Mix_LoadMUS_RW(rwops); + SDL_FreeRW(rwops); return result; }, @@ -2975,7 +2975,7 @@ var LibrarySDL = { } audio['onended'] = function() { if (SDL.music.audio === this || SDL.music.audio?.webAudioNode === this) { - _Mix_HaltMusic(); // will send callback + Mix_HaltMusic(); // will send callback } } audio.loop = loops != 0 && loops != 1; // TODO: handle N loops for finite N @@ -3026,7 +3026,7 @@ var LibrarySDL = { if (channel === -1) { var count = 0; for (var i = 0; i < SDL.channels.length; i++) { - count += _Mix_Playing(i); + count += Mix_Playing(i); } return count; } @@ -3041,7 +3041,7 @@ var LibrarySDL = { Mix_Pause: (channel) => { if (channel === -1) { for (var i = 0; i { if (channel === -1) { for (var i = 0; i _boxRGBA(surf, x1, y1, x1, y1, r, g, b, a), + pixelRGBA: (surf, x1, y1, r, g, b, a) => boxRGBA(surf, x1, y1, x1, y1, r, g, b, a), // GL @@ -3377,7 +3377,7 @@ var LibrarySDL = { }, SDL_GL_SetSwapInterval__deps: ['emscripten_set_main_loop_timing'], - SDL_GL_SetSwapInterval: (state) => _emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_RAF }}}, state), + SDL_GL_SetSwapInterval: (state) => emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_RAF }}}, state), SDL_SetWindowTitle__proxy: 'sync', SDL_SetWindowTitle: (window, title) => { @@ -3551,7 +3551,7 @@ var LibrarySDL = { SDL_GetCurrentAudioDriver: () => stringToNewUTF8('Emscripten Audio'), SDL_GetScancodeFromKey: (key) => SDL.scanCodes[key], SDL_GetAudioDriver__deps: ['SDL_GetCurrentAudioDriver'], - SDL_GetAudioDriver: (index) => _SDL_GetCurrentAudioDriver(), + SDL_GetAudioDriver: (index) => SDL_GetCurrentAudioDriver(), SDL_EnableUNICODE__proxy: 'sync', SDL_EnableUNICODE: (on) => { diff --git a/src/library_stack_trace.js b/src/library_stack_trace.js index b5c92f41d651d..59399c3beb96f 100644 --- a/src/library_stack_trace.js +++ b/src/library_stack_trace.js @@ -15,8 +15,8 @@ var LibraryStackTrace = { // Find the symbols in the callstack that corresponds to the functions that // report callstack information, and remove everything up to these from the // output. - var iThisFunc = callstack.lastIndexOf('_emscripten_log'); - var iThisFunc2 = callstack.lastIndexOf('_emscripten_get_callstack'); + var iThisFunc = callstack.lastIndexOf('emscripten_log '); + var iThisFunc2 = callstack.lastIndexOf('emscripten_get_callstack '); var iNextLine = callstack.indexOf('\n', Math.max(iThisFunc, iThisFunc2))+1; callstack = callstack.slice(iNextLine); @@ -259,7 +259,7 @@ var LibraryStackTrace = { // Look up the function name from our stack frame cache with our PC representation. #if USE_OFFSET_CONVERTER emscripten_pc_get_function__deps: ['$UNWIND_CACHE', 'free', '$stringToNewUTF8'], - // Don't treat allocation of _emscripten_pc_get_function.ret as a leak + // Don't treat allocation of emscripten_pc_get_function.ret as a leak emscripten_pc_get_function__noleakcheck: true, #endif emscripten_pc_get_function: (pc) => { @@ -284,9 +284,9 @@ var LibraryStackTrace = { } else { name = wasmOffsetConverter.getName(pc); } - if (_emscripten_pc_get_function.ret) _free(_emscripten_pc_get_function.ret); - _emscripten_pc_get_function.ret = stringToNewUTF8(name); - return _emscripten_pc_get_function.ret; + if (emscripten_pc_get_function.ret) free(emscripten_pc_get_function.ret); + emscripten_pc_get_function.ret = stringToNewUTF8(name); + return emscripten_pc_get_function.ret; #endif }, @@ -320,15 +320,15 @@ var LibraryStackTrace = { // Look up the file name from our stack frame cache with our PC representation. emscripten_pc_get_file__deps: ['$convertPCtoSourceLocation', 'free', '$stringToNewUTF8'], - // Don't treat allocation of _emscripten_pc_get_file.ret as a leak + // Don't treat allocation of emscripten_pc_get_file.ret as a leak emscripten_pc_get_file__noleakcheck: true, emscripten_pc_get_file: (pc) => { var result = convertPCtoSourceLocation(pc); if (!result) return 0; - if (_emscripten_pc_get_file.ret) _free(_emscripten_pc_get_file.ret); - _emscripten_pc_get_file.ret = stringToNewUTF8(result.file); - return _emscripten_pc_get_file.ret; + if (emscripten_pc_get_file.ret) free(emscripten_pc_get_file.ret); + emscripten_pc_get_file.ret = stringToNewUTF8(result.file); + return emscripten_pc_get_file.ret; }, // Look up the line number from our stack frame cache with our PC representation. diff --git a/src/library_strings.js b/src/library_strings.js index e5a0c03b0b32c..4254e6378e324 100644 --- a/src/library_strings.js +++ b/src/library_strings.js @@ -477,7 +477,7 @@ addToLibrary({ $stringToNewUTF8__deps: ['$lengthBytesUTF8', '$stringToUTF8', 'malloc'], $stringToNewUTF8: (str) => { var size = lengthBytesUTF8(str) + 1; - var ret = _malloc(size); + var ret = malloc(size); if (ret) stringToUTF8(str, ret, size); return ret; }, diff --git a/src/library_syscall.js b/src/library_syscall.js index 73dd12fe09fbe..158350f740016 100644 --- a/src/library_syscall.js +++ b/src/library_syscall.js @@ -817,7 +817,7 @@ var SyscallsLibrary = { __syscall_fstatfs64__deps: ['__syscall_statfs64'], __syscall_fstatfs64: (fd, size, buf) => { var stream = SYSCALLS.getStreamFromFD(fd); - return ___syscall_statfs64(0, size, buf); + return __syscall_statfs64(0, size, buf); }, __syscall_fadvise64__nothrow: true, __syscall_fadvise64__proxy: 'none', diff --git a/src/library_time.js b/src/library_time.js index 92ae8a43ac6cd..0280c2c9dcd7c 100644 --- a/src/library_time.js +++ b/src/library_time.js @@ -516,5 +516,5 @@ addToLibrary({ return 0; }, strptime_l__deps: ['strptime'], - strptime_l: (buf, format, tm, locale) => _strptime(buf, format, tm), // no locale support yet + strptime_l: (buf, format, tm, locale) => strptime(buf, format, tm), // no locale support yet }); diff --git a/src/library_trace.js b/src/library_trace.js index f45ea94a01c7e..2f60199e7785c 100644 --- a/src/library_trace.js +++ b/src/library_trace.js @@ -50,9 +50,9 @@ var LibraryTracing = { init: () => { Module['emscripten_trace_configure'] = traceConfigure; - Module['emscripten_trace_configure_for_google_wtf'] = _emscripten_trace_configure_for_google_wtf; + Module['emscripten_trace_configure_for_google_wtf'] = emscripten_trace_configure_for_google_wtf; Module['emscripten_trace_enter_context'] = traceEnterContext; - Module['emscripten_trace_exit_context'] = _emscripten_trace_exit_context; + Module['emscripten_trace_exit_context'] = emscripten_trace_exit_context; Module['emscripten_trace_log_message'] = traceLogMessage; Module['emscripten_trace_mark'] = traceMark; }, @@ -63,7 +63,7 @@ var LibraryTracing = { }, configure: (collector_url, application) => { - EmscriptenTrace.now = _emscripten_get_now; + EmscriptenTrace.now = emscripten_get_now; var now = new Date(); var session_id = now.getTime().toString() + '_' + Math.floor((Math.random() * 100) + 1).toString(); @@ -254,10 +254,10 @@ var LibraryTracing = { if (EmscriptenTrace.postEnabled) { var memory_layout = { 'static_base': {{{ GLOBAL_BASE }}}, - 'stack_base': _emscripten_stack_get_base(), - 'stack_top': _emscripten_stack_get_current(), - 'stack_max': _emscripten_stack_get_end(), - 'dynamic_top': _sbrk(0), + 'stack_base': emscripten_stack_get_base(), + 'stack_top': emscripten_stack_get_current(), + 'stack_max': emscripten_stack_get_end(), + 'dynamic_top': sbrk(0), 'total_memory': HEAP8.length }; var now = EmscriptenTrace.now(); diff --git a/src/library_uuid.js b/src/library_uuid.js index 14429bea6e1a1..c1e91abdbea74 100644 --- a/src/library_uuid.js +++ b/src/library_uuid.js @@ -15,11 +15,11 @@ addToLibrary({ // Returns an integer less than, equal to, or greater than zero if uu1 is found, respectively, to be // lexicographically less than, equal, or greater than uu2. uuid_compare__deps: ['memcmp'], - uuid_compare: (uu1, uu2) => _memcmp(uu1, uu2, 16), + uuid_compare: (uu1, uu2) => memcmp(uu1, uu2, 16), // Copies the 'compact' UUID variable from src to dst. uuid_copy__deps: ['memcpy'], - uuid_copy: (dst, src) => _memcpy(dst, src, 16), + uuid_copy: (dst, src) => memcpy(dst, src, 16), // Write a RFC4122 version 4 compliant UUID largely based on the method found in // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript @@ -117,18 +117,14 @@ addToLibrary({ }, // Convert a 'compact' form UUID to a lower case string. + // void uuid_unparse_lower(const uuid_t uu, char *out); uuid_unparse_lower__deps: ['uuid_unparse'], - uuid_unparse_lower: (uu, out) => { - // void uuid_unparse_lower(const uuid_t uu, char *out); - _uuid_unparse(uu, out); - }, + uuid_unparse_lower: (uu, out) => uuid_unparse(uu, out), // Convert a 'compact' form UUID to an upper case string. + // void uuid_unparse_upper(const uuid_t uu, char *out); uuid_unparse_upper__deps: ['uuid_unparse'], - uuid_unparse_upper: (uu, out) => { - // void uuid_unparse_upper(const uuid_t uu, char *out); - _uuid_unparse(uu, out, true); - }, + uuid_unparse_upper: (uu, out) => uuid_unparse(uu, out, true), // int uuid_type(const uuid_t uu); uuid_type: (uu) => {{{ cDefs.UUID_TYPE_DCE_RANDOM }}}, diff --git a/src/library_wasi.js b/src/library_wasi.js index 63a202eb52a39..f84bdb7448318 100644 --- a/src/library_wasi.js +++ b/src/library_wasi.js @@ -159,7 +159,7 @@ var WasiLibrary = { if (clk_id === {{{ cDefs.__WASI_CLOCKID_REALTIME }}}) { now = Date.now(); } else if (nowIsMonotonic) { - now = _emscripten_get_now(); + now = emscripten_get_now(); } else { return {{{ cDefs.ENOSYS }}}; } @@ -181,7 +181,7 @@ var WasiLibrary = { if (clk_id === {{{ cDefs.CLOCK_REALTIME }}}) { nsec = 1000 * 1000; // educated guess that it's milliseconds } else if (nowIsMonotonic) { - nsec = _emscripten_get_now_res(); + nsec = emscripten_get_now_res(); } else { return {{{ cDefs.ENOSYS }}}; } @@ -255,7 +255,7 @@ var WasiLibrary = { $flush_NO_FILESYSTEM: () => { // flush anything remaining in the buffers during shutdown #if hasExportedSymbol('fflush') - _fflush(0); + fflush(0); #endif if (printCharBuffers[1].length) printChar(1, {{{ charCode("\n") }}}); if (printCharBuffers[2].length) printChar(2, {{{ charCode("\n") }}}); diff --git a/src/library_wasm_worker.js b/src/library_wasm_worker.js index 32107a07bdc0d..26aa4c53315e6 100644 --- a/src/library_wasm_worker.js +++ b/src/library_wasm_worker.js @@ -95,19 +95,19 @@ addToLibrary({ // remove this in the future. Note that this call is not exactly correct, // since this limit will include the TLS slot, that will be part of the // region between m['sb'] and m['sz'], so we need to fix up the call below. - ___set_stack_limits(m['sb'] + m['sz'], m['sb']); + __set_stack_limits(m['sb'] + m['sz'], m['sb']); #endif // Run the C side Worker initialization for stack and TLS. - __emscripten_wasm_worker_initialize(m['sb'], m['sz']); + _emscripten_wasm_worker_initialize(m['sb'], m['sz']); #if PTHREADS // Record the pthread configuration, and whether this Wasm Worker supports synchronous blocking in emscripten_futex_wait(). // (regular Wasm Workers do, AudioWorklets don't) - ___set_thread_state(/*thread_ptr=*/0, /*is_main_thread=*/0, /*is_runtime_thread=*/0, /*supports_wait=*/ {{{ workerSupportsFutexWait() }}}); + __set_thread_state(/*thread_ptr=*/0, /*is_main_thread=*/0, /*is_runtime_thread=*/0, /*supports_wait=*/ {{{ workerSupportsFutexWait() }}}); #endif #if STACK_OVERFLOW_CHECK >= 2 // Fix up stack base. (TLS frame is created at the bottom address end of the stack) // See https://github.com/emscripten-core/emscripten/issues/16496 - ___set_stack_limits(_emscripten_stack_get_base(), _emscripten_stack_get_end()); + __set_stack_limits(emscripten_stack_get_base(), emscripten_stack_get_end()); #endif #if STACK_OVERFLOW_CHECK @@ -165,7 +165,7 @@ if (ENVIRONMENT_IS_WASM_WORKER }`, _emscripten_create_wasm_worker: (stackLowestAddress, stackSize) => { #if ASSERTIONS - if (!_emscripten_has_threading_support()) { + if (!emscripten_has_threading_support()) { err('create_wasm_worker: environment does not support SharedArrayBuffer, wasm workers are not available'); return 0; } diff --git a/src/library_wasmfs.js b/src/library_wasmfs.js index b209d4be9ec98..b3ef89c60e35f 100644 --- a/src/library_wasmfs.js +++ b/src/library_wasmfs.js @@ -8,7 +8,7 @@ addToLibrary({ $MEMFS__deps: ['wasmfs_create_memory_backend'], $MEMFS: { createBackend(opts) { - return _wasmfs_create_memory_backend(); + return wasmfs_create_memory_backend(); } }, $wasmFSPreloadedFiles: [], @@ -123,11 +123,11 @@ FS.init(); }, #if hasExportedSymbol('_wasmfs_read_file') // Support the JS function exactly - // when the __wasmfs_* function is + // when the _wasmfs_* function is // present to be called (otherwise, // we'd error anyhow). This depends // on other code including the - // __wasmfs_* method properly. + // _wasmfs_* method properly. readFile(path, opts = {}) { opts.encoding = opts.encoding || 'binary'; if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') { @@ -136,7 +136,7 @@ FS.init(); // Copy the file into a JS buffer on the heap. var sp = stackSave(); - var buf = __wasmfs_read_file(stringToUTF8OnStack(path)); + var buf = _wasmfs_read_file(stringToUTF8OnStack(path)); stackRestore(sp); // The signed integer length resides in the first 8 bytes of the buffer. @@ -154,7 +154,7 @@ FS.init(); #endif #if hasExportedSymbol('_wasmfs_get_cwd') // Similar to readFile, above. - cwd: () => UTF8ToString(__wasmfs_get_cwd()), + cwd: () => UTF8ToString(_wasmfs_get_cwd()), #endif #if FORCE_FILESYSTEM || INCLUDE_FULL_LIBRARY // see comment above @@ -176,32 +176,32 @@ FS.init(); mkdir: (path, mode) => FS_mkdir(path, mode), mkdirTree: (path, mode) => FS_mkdirTree(path, mode), rmdir: (path) => FS.handleError( - withStackSave(() => __wasmfs_rmdir(stringToUTF8OnStack(path))) + withStackSave(() => _wasmfs_rmdir(stringToUTF8OnStack(path))) ), open: (path, flags, mode) => withStackSave(() => { flags = typeof flags == 'string' ? FS_modeStringToFlags(flags) : flags; mode = typeof mode == 'undefined' ? 438 /* 0666 */ : mode; var buffer = stringToUTF8OnStack(path); - var fd = FS.handleError(__wasmfs_open(buffer, flags, mode)); + var fd = FS.handleError(_wasmfs_open(buffer, flags, mode)); return { fd : fd }; }), create: (path, mode) => FS_create(path, mode), - close: (stream) => FS.handleError(-__wasmfs_close(stream.fd)), + close: (stream) => FS.handleError(-_wasmfs_close(stream.fd)), unlink: (path) => FS_unlink(path), chdir: (path) => withStackSave(() => { var buffer = stringToUTF8OnStack(path); - return __wasmfs_chdir(buffer); + return _wasmfs_chdir(buffer); }), read(stream, buffer, offset, length, position) { var seeking = typeof position != 'undefined'; - var dataBuffer = _malloc(length); + var dataBuffer = malloc(length); var bytesRead; if (seeking) { - bytesRead = __wasmfs_pread(stream.fd, dataBuffer, length, position); + bytesRead = _wasmfs_pread(stream.fd, dataBuffer, length, position); } else { - bytesRead = __wasmfs_read(stream.fd, dataBuffer, length); + bytesRead = _wasmfs_read(stream.fd, dataBuffer, length); } bytesRead = FS.handleError(bytesRead); @@ -209,51 +209,51 @@ FS.init(); buffer[offset + i] = {{{ makeGetValue('dataBuffer', 'i', 'i8')}}} } - _free(dataBuffer); + free(dataBuffer); return bytesRead; }, // Note that canOwn is an optimization that we ignore for now in WasmFS. write(stream, buffer, offset, length, position, canOwn) { var seeking = typeof position != 'undefined'; - var dataBuffer = _malloc(length); + var dataBuffer = malloc(length); for (var i = 0; i < length; i++) { {{{ makeSetValue('dataBuffer', 'i', 'buffer[offset + i]', 'i8') }}}; } var bytesRead; if (seeking) { - bytesRead = __wasmfs_pwrite(stream.fd, dataBuffer, length, position); + bytesRead = _wasmfs_pwrite(stream.fd, dataBuffer, length, position); } else { - bytesRead = __wasmfs_write(stream.fd, dataBuffer, length); + bytesRead = _wasmfs_write(stream.fd, dataBuffer, length); } bytesRead = FS.handleError(bytesRead); - _free(dataBuffer); + free(dataBuffer); return bytesRead; }, allocate(stream, offset, length) { - return FS.handleError(__wasmfs_allocate(stream.fd, {{{ splitI64('offset') }}}, {{{ splitI64('length') }}})); + return FS.handleError(_wasmfs_allocate(stream.fd, {{{ splitI64('offset') }}}, {{{ splitI64('length') }}})); }, writeFile: (path, data) => FS_writeFile(path, data), mmap: (stream, length, offset, prot, flags) => { - var buf = FS.handleError(__wasmfs_mmap(length, prot, flags, stream.fd, {{{ splitI64('offset') }}})); + var buf = FS.handleError(_wasmfs_mmap(length, prot, flags, stream.fd, {{{ splitI64('offset') }}})); return { ptr: buf, allocated: true }; }, // offset is passed to msync to maintain backwards compatibility with the legacy JS API but is not used by WasmFS. msync: (stream, bufferPtr, offset, length, mmapFlags) => { assert(offset === 0); // TODO: assert that stream has the fd corresponding to the mapped buffer (bufferPtr). - return FS.handleError(__wasmfs_msync(bufferPtr, length, mmapFlags)); + return FS.handleError(_wasmfs_msync(bufferPtr, length, mmapFlags)); }, munmap: (addr, length) => ( - FS.handleError(__wasmfs_munmap(addr, length)) + FS.handleError(_wasmfs_munmap(addr, length)) ), symlink: (target, linkpath) => withStackSave(() => ( - __wasmfs_symlink(stringToUTF8OnStack(target), stringToUTF8OnStack(linkpath)) + _wasmfs_symlink(stringToUTF8OnStack(target), stringToUTF8OnStack(linkpath)) )), readlink(path) { - var readBuffer = FS.handleError(withStackSave(() => __wasmfs_readlink(stringToUTF8OnStack(path)))); + var readBuffer = FS.handleError(withStackSave(() => _wasmfs_readlink(stringToUTF8OnStack(path)))); return UTF8ToString(readBuffer); }, statBufToObject(statBuf) { @@ -275,53 +275,53 @@ FS.init(); } }, stat(path) { - var statBuf = _malloc({{{ C_STRUCTS.stat.__size__ }}}); + var statBuf = malloc({{{ C_STRUCTS.stat.__size__ }}}); FS.handleError(withStackSave(() => - __wasmfs_stat(stringToUTF8OnStack(path), statBuf) + _wasmfs_stat(stringToUTF8OnStack(path), statBuf) )); var stats = FS.statBufToObject(statBuf); - _free(statBuf); + free(statBuf); return stats; }, lstat(path) { - var statBuf = _malloc({{{ C_STRUCTS.stat.__size__ }}}); + var statBuf = malloc({{{ C_STRUCTS.stat.__size__ }}}); FS.handleError(withStackSave(() => - __wasmfs_lstat(stringToUTF8OnStack(path), statBuf) + _wasmfs_lstat(stringToUTF8OnStack(path), statBuf) )); var stats = FS.statBufToObject(statBuf); - _free(statBuf); + free(statBuf); return stats; }, chmod(path, mode) { return FS.handleError(withStackSave(() => { var buffer = stringToUTF8OnStack(path); - return __wasmfs_chmod(buffer, mode); + return _wasmfs_chmod(buffer, mode); })); }, lchmod(path, mode) { return FS.handleError(withStackSave(() => { var buffer = stringToUTF8OnStack(path); - return __wasmfs_lchmod(buffer, mode); + return _wasmfs_lchmod(buffer, mode); })); }, fchmod(fd, mode) { - return FS.handleError(__wasmfs_fchmod(fd, mode)); + return FS.handleError(_wasmfs_fchmod(fd, mode)); }, utime: (path, atime, mtime) => ( FS.handleError(withStackSave(() => ( - __wasmfs_utime(stringToUTF8OnStack(path), atime, mtime) + _wasmfs_utime(stringToUTF8OnStack(path), atime, mtime) ))) ), truncate(path, len) { - return FS.handleError(withStackSave(() => (__wasmfs_truncate(stringToUTF8OnStack(path), {{{ splitI64('len') }}})))); + return FS.handleError(withStackSave(() => (_wasmfs_truncate(stringToUTF8OnStack(path), {{{ splitI64('len') }}})))); }, ftruncate(fd, len) { - return FS.handleError(__wasmfs_ftruncate(fd, {{{ splitI64('len') }}})); + return FS.handleError(_wasmfs_ftruncate(fd, {{{ splitI64('len') }}})); }, findObject(path) { - var result = withStackSave(() => __wasmfs_identify(stringToUTF8OnStack(path))); + var result = withStackSave(() => _wasmfs_identify(stringToUTF8OnStack(path))); if (result == {{{ cDefs.ENOENT }}}) { return null; } @@ -333,16 +333,16 @@ FS.init(); readdir: (path) => withStackSave(() => { var pathBuffer = stringToUTF8OnStack(path); var entries = []; - var state = __wasmfs_readdir_start(pathBuffer); + var state = _wasmfs_readdir_start(pathBuffer); if (!state) { // TODO: The old FS threw an ErrnoError here. throw new Error("No such directory"); } var entry; - while (entry = __wasmfs_readdir_get(state)) { + while (entry = _wasmfs_readdir_get(state)) { entries.push(UTF8ToString(entry)); } - __wasmfs_readdir_finish(state); + _wasmfs_readdir_finish(state); return entries; }), mount: (type, opts, mountpoint) => { @@ -354,16 +354,16 @@ FS.init(); } #endif var backendPointer = type.createBackend(opts); - return FS.handleError(withStackSave(() => __wasmfs_mount(stringToUTF8OnStack(mountpoint), backendPointer))); + return FS.handleError(withStackSave(() => _wasmfs_mount(stringToUTF8OnStack(mountpoint), backendPointer))); }, unmount: (mountpoint) => ( - FS.handleError(withStackSave(() => __wasmfs_unmount(stringToUTF8OnStack(mountpoint)))) + FS.handleError(withStackSave(() => _wasmfs_unmount(stringToUTF8OnStack(mountpoint)))) ), // TODO: lookup mknod: (path, mode, dev) => FS_mknod(path, mode, dev), makedev: (ma, mi) => ((ma) << 8 | (mi)), registerDevice(dev, ops) { - var backendPointer = _wasmfs_create_jsimpl_backend(); + var backendPointer = wasmfs_create_jsimpl_backend(); var definedOps = { userRead: ops.read, userWrite: ops.write, @@ -458,19 +458,19 @@ FS.init(); } return FS.handleError(withStackSave(() => ( - _wasmfs_create_file(stringToUTF8OnStack(path), mode, deviceBackend) + wasmfs_create_file(stringToUTF8OnStack(path), mode, deviceBackend) ))); }, rename(oldPath, newPath) { return FS.handleError(withStackSave(() => { var oldPathBuffer = stringToUTF8OnStack(oldPath); var newPathBuffer = stringToUTF8OnStack(newPath); - return __wasmfs_rename(oldPathBuffer, newPathBuffer); + return _wasmfs_rename(oldPathBuffer, newPathBuffer); })); }, // TODO: syncfs llseek(stream, offset, whence) { - return FS.handleError(__wasmfs_llseek(stream.fd, {{{ splitI64('offset') }}}, whence)); + return FS.handleError(_wasmfs_llseek(stream.fd, {{{ splitI64('offset') }}}, whence)); } // TODO: ioctl @@ -512,7 +512,7 @@ FS.init(); $FS_mknod__deps: ['_wasmfs_mknod'], $FS_mknod: (path, mode, dev) => FS.handleError(withStackSave(() => { var pathBuffer = stringToUTF8OnStack(path); - return __wasmfs_mknod(pathBuffer, mode, dev); + return _wasmfs_mknod(pathBuffer, mode, dev); })), $FS_create__deps: ['$FS_mknod'], @@ -532,15 +532,15 @@ FS.init(); var actualNumBytes = stringToUTF8Array(data, buf, 0, buf.length); data = buf.slice(0, actualNumBytes); } - var dataBuffer = _malloc(data.length); + var dataBuffer = malloc(data.length); #if ASSERTIONS assert(dataBuffer); #endif for (var i = 0; i < data.length; i++) { {{{ makeSetValue('dataBuffer', 'i', 'data[i]', 'i8') }}}; } - var ret = __wasmfs_write_file(pathBuffer, dataBuffer, data.length); - _free(dataBuffer); + var ret = _wasmfs_write_file(pathBuffer, dataBuffer, data.length); + free(dataBuffer); stackRestore(sp); return ret; }, @@ -548,7 +548,7 @@ FS.init(); $FS_mkdir__deps: ['_wasmfs_mkdir'], $FS_mkdir: (path, mode = 511 /* 0777 */) => FS.handleError(withStackSave(() => { var buffer = stringToUTF8OnStack(path); - return __wasmfs_mkdir(buffer, mode); + return _wasmfs_mkdir(buffer, mode); })), $FS_mkdirTree__docs: ` @@ -574,7 +574,7 @@ FS.init(); $FS_unlink__deps: ['_wasmfs_unlink'], $FS_unlink: (path) => withStackSave(() => { var buffer = stringToUTF8OnStack(path); - return __wasmfs_unlink(buffer); + return _wasmfs_unlink(buffer); }), // Wasm access calls. @@ -622,7 +622,7 @@ FS.init(); if (ABORT) { clearInterval(intervalID); } else { - _emscripten_proxy_execute_queue(queue); + emscripten_proxy_execute_queue(queue); } }, 50); }, diff --git a/src/library_wasmfs_fetch.js b/src/library_wasmfs_fetch.js index c0b8f2bcc2114..ef605c819de07 100644 --- a/src/library_wasmfs_fetch.js +++ b/src/library_wasmfs_fetch.js @@ -26,7 +26,7 @@ addToLibrary({ } // This is the first time we want the file's data. var url = ''; - var fileUrl_p = __wasmfs_fetch_get_file_path(file); + var fileUrl_p = _wasmfs_fetch_get_file_path(file); var fileUrl = UTF8ToString(fileUrl_p); var isAbs = fileUrl.indexOf('://') !== -1; if (isAbs) { @@ -50,7 +50,7 @@ addToLibrary({ // Start with the normal JSFile operations. This sets // wasmFS$backends[backend] // which we will then augment. - __wasmfs_create_js_file_backend_js(backend); + _wasmfs_create_js_file_backend_js(backend); // Add the async operations on top. var jsFileOps = wasmFS$backends[backend]; diff --git a/src/library_wasmfs_jsimpl.js b/src/library_wasmfs_jsimpl.js index f6293f3d460ea..08660981d1794 100644 --- a/src/library_wasmfs_jsimpl.js +++ b/src/library_wasmfs_jsimpl.js @@ -71,7 +71,7 @@ addToLibrary({ assert(wasmFS$backends[backend]); #endif await wasmFS$backends[backend].allocFile(file); - _emscripten_proxy_finish(ctx); + emscripten_proxy_finish(ctx); }, _wasmfs_jsimpl_async_free_file__deps: ['emscripten_proxy_finish'], @@ -80,7 +80,7 @@ addToLibrary({ assert(wasmFS$backends[backend]); #endif await wasmFS$backends[backend].freeFile(file); - _emscripten_proxy_finish(ctx); + emscripten_proxy_finish(ctx); }, _wasmfs_jsimpl_async_write__i53abi: true, @@ -91,7 +91,7 @@ addToLibrary({ #endif var result = await wasmFS$backends[backend].write(file, buffer, length, offset); {{{ makeSetValue('result_p', 0, 'result', SIZE_TYPE) }}}; - _emscripten_proxy_finish(ctx); + emscripten_proxy_finish(ctx); }, _wasmfs_jsimpl_async_read__i53abi: true, @@ -102,7 +102,7 @@ addToLibrary({ #endif var result = await wasmFS$backends[backend].read(file, buffer, length, offset); {{{ makeSetValue('result_p', 0, 'result', SIZE_TYPE) }}}; - _emscripten_proxy_finish(ctx); + emscripten_proxy_finish(ctx); }, _wasmfs_jsimpl_async_get_size__deps: ['emscripten_proxy_finish'], @@ -112,6 +112,6 @@ addToLibrary({ #endif var size = await wasmFS$backends[backend].getSize(file); {{{ makeSetValue('size_p', 0, 'size', 'i64') }}}; - _emscripten_proxy_finish(ctx); + emscripten_proxy_finish(ctx); }, }); diff --git a/src/library_wasmfs_node.js b/src/library_wasmfs_node.js index f0739f46f1029..d3feb91748bef 100644 --- a/src/library_wasmfs_node.js +++ b/src/library_wasmfs_node.js @@ -87,7 +87,7 @@ addToLibrary({ } else { type = {{{ cDefine('File::UnknownKind') }}}; } - __wasmfs_node_record_dirent(vec, name, type); + _wasmfs_node_record_dirent(vec, name, type); stackRestore(sp); // implicitly return 0 }); diff --git a/src/library_wasmfs_opfs.js b/src/library_wasmfs_opfs.js index 00f71e09cbf65..26f902ad976a8 100644 --- a/src/library_wasmfs_opfs.js +++ b/src/library_wasmfs_opfs.js @@ -64,7 +64,7 @@ addToLibrary({ // When used with JSPI the work will be executed in an async block so there // is no need to notify when done. #if PTHREADS - _emscripten_proxy_finish(ctx); + emscripten_proxy_finish(ctx); #endif }, @@ -168,7 +168,7 @@ addToLibrary({ let type = child.kind == "file" ? {{{ cDefine('File::DataFileKind') }}} : {{{ cDefine('File::DirectoryKind') }}}; - __wasmfs_opfs_record_entry(entriesPtr, namePtr, type) + _wasmfs_opfs_record_entry(entriesPtr, namePtr, type) stackRestore(sp); } } catch { diff --git a/src/library_webgl.js b/src/library_webgl.js index adc211205fad7..593cf510f1a46 100644 --- a/src/library_webgl.js +++ b/src/library_webgl.js @@ -666,7 +666,7 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; } } #if PTHREADS - err(`[Thread ${_pthread_self()}, GL ctx: ${contextHandle}]: ${f}(${args}) -> ${ret}`); + err(`[Thread ${pthread_self()}, GL ctx: ${contextHandle}]: ${f}(${args}) -> ${ret}`); #else err(`[ctx: ${contextHandle}]: ${f}(${args}) -> ${ret}`); #endif @@ -1093,14 +1093,14 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; #if PTHREADS // with pthreads a context is a location in memory with some synchronized // data between threads - var handle = _malloc({{{ 2 * POINTER_SIZE }}}); + var handle = malloc({{{ 2 * POINTER_SIZE }}}); #if GL_ASSERTIONS assert(handle, 'malloc() failed in GL.registerContext!'); #endif #if GL_SUPPORT_EXPLICIT_SWAP_CONTROL {{{ makeSetValue('handle', 0, 'webGLContextAttributes.explicitSwapControl', 'i8')}}}; #endif - {{{ makeSetValue('handle', POINTER_SIZE, '_pthread_self()', '*')}}}; // the thread pointer of the thread that owns the control of the context + {{{ makeSetValue('handle', POINTER_SIZE, 'pthread_self()', '*')}}}; // the thread pointer of the thread that owns the control of the context #else // PTHREADS // without pthreads a context is just an integer ID var handle = GL.getNewId(GL.contexts); @@ -1193,7 +1193,7 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; GL.contexts[contextHandle].GLctx.canvas.GLctxObject = undefined; } #if PTHREADS - _free(GL.contexts[contextHandle].handle); + free(GL.contexts[contextHandle].handle); #endif GL.contexts[contextHandle] = null; }, @@ -4161,7 +4161,7 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; return 0; } - var mem = _malloc(length), binding = emscriptenWebGLGetBufferBinding(target); + var mem = malloc(length), binding = emscriptenWebGLGetBufferBinding(target); if (!mem) return 0; binding = GL.mappedBuffers[binding] ??= {}; @@ -4243,7 +4243,7 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; #endif GLctx.bufferSubData(target, mapping.offset, HEAPU8.subarray(mapping.mem, mapping.mem+mapping.length)); } - _free(mapping.mem); + free(mapping.mem); mapping.mem = 0; return 1; }, diff --git a/src/library_webgpu.js b/src/library_webgpu.js index c98c0f8a009a6..ff0e117bfad41 100644 --- a/src/library_webgpu.js +++ b/src/library_webgpu.js @@ -1916,13 +1916,13 @@ var LibraryWebGPU = { shaderModule.getCompilationInfo().then((compilationInfo) => { {{{ runtimeKeepalivePop() }}} callUserCallback(() => { - var compilationMessagesPtr = _malloc({{{ C_STRUCTS.WGPUCompilationMessage.__size__ }}} * compilationInfo.messages.length); + var compilationMessagesPtr = malloc({{{ C_STRUCTS.WGPUCompilationMessage.__size__ }}} * compilationInfo.messages.length); var messageStringPtrs = []; // save these to free later for (var i = 0; i < compilationInfo.messages.length; ++i) { var compilationMessage = compilationInfo.messages[i]; var compilationMessagePtr = compilationMessagesPtr + {{{ C_STRUCTS.WGPUCompilationMessage.__size__ }}} * i; var messageSize = lengthBytesUTF8(compilationMessage.message) + 1; - var messagePtr = _malloc(messageSize); + var messagePtr = malloc(messageSize); messageStringPtrs.push(messagePtr); stringToUTF8(compilationMessage.message, messagePtr, messageSize); {{{ makeSetValue('compilationMessagePtr', C_STRUCTS.WGPUCompilationMessage.message, 'messagePtr', '*') }}}; @@ -1937,17 +1937,17 @@ var LibraryWebGPU = { {{{ makeSetValue('compilationMessagePtr', C_STRUCTS.WGPUCompilationMessage.utf16Offset, 'compilationMessage.offset', 'i64') }}}; {{{ makeSetValue('compilationMessagePtr', C_STRUCTS.WGPUCompilationMessage.utf16Length, 'compilationMessage.length', 'i64') }}}; } - var compilationInfoPtr = _malloc({{{ C_STRUCTS.WGPUCompilationInfo.__size__ }}}); + var compilationInfoPtr = malloc({{{ C_STRUCTS.WGPUCompilationInfo.__size__ }}}); {{{ makeSetValue('compilationInfoPtr', C_STRUCTS.WGPUCompilationInfo.messageCount, 'compilationInfo.messages.length', '*') }}} {{{ makeSetValue('compilationInfoPtr', C_STRUCTS.WGPUCompilationInfo.messages, 'compilationMessagesPtr', '*') }}}; {{{ makeDynCall('vipp', 'callback') }}}({{{ gpu.CompilationInfoRequestStatus.Success }}}, compilationInfoPtr, userdata); messageStringPtrs.forEach((ptr) => { - _free(ptr); + free(ptr); }); - _free(compilationMessagesPtr); - _free(compilationInfoPtr); + free(compilationMessagesPtr); + free(compilationInfoPtr); }); }); }, @@ -2015,9 +2015,9 @@ var LibraryWebGPU = { // TODO(kainino0x): Somehow inject a validation error? return 0; } - var data = _memalign(16, mapped.byteLength); + var data = memalign(16, mapped.byteLength); HEAPU8.set(new Uint8Array(mapped), data); - bufferWrapper.onUnmap.push(() => _free(data)); + bufferWrapper.onUnmap.push(() => free(data)); return data; }, @@ -2056,11 +2056,11 @@ var LibraryWebGPU = { return 0; } - var data = _memalign(16, mapped.byteLength); + var data = memalign(16, mapped.byteLength); zeroMemory(data, mapped.byteLength); bufferWrapper.onUnmap.push(() => { new Uint8Array(mapped).set(HEAPU8.subarray(data, data + mapped.byteLength)); - _free(data); + free(data); }); return data; }, diff --git a/src/library_websocket.js b/src/library_websocket.js index 1fc88821017b0..d29cab7be6b69 100644 --- a/src/library_websocket.js +++ b/src/library_websocket.js @@ -20,7 +20,7 @@ var LibraryWebSocket = { getSocketEvent(socketId) { // Singleton event pointer. Use EmscriptenWebSocketCloseEvent, which is // the largest event struct - this.socketEvent ||= _malloc({{{ C_STRUCTS.EmscriptenWebSocketCloseEvent.__size__ }}}); + this.socketEvent ||= malloc({{{ C_STRUCTS.EmscriptenWebSocketCloseEvent.__size__ }}}); {{{ makeSetValue('this.socketEvent', 0, 'socketId', 'u32') }}}; return this.socketEvent; }, @@ -151,7 +151,7 @@ var LibraryWebSocket = { emscripten_websocket_set_onopen_callback_on_thread: (socketId, userData, callbackFunc, thread) => { // TODO: // if (thread == {{{ cDefs.EM_CALLBACK_THREAD_CONTEXT_CALLING_THREAD }}} || -// (thread == _pthread_self()) return emscripten_websocket_set_onopen_callback_on_calling_thread(socketId, userData, callbackFunc); +// (thread == pthread_self()) return emscripten_websocket_set_onopen_callback_on_calling_thread(socketId, userData, callbackFunc); var socket = WS.getSocket(socketId); if (!socket) { #if WEBSOCKET_DEBUG @@ -252,7 +252,7 @@ var LibraryWebSocket = { #endif } else { var len = e.data.byteLength; - var buf = _malloc(len); + var buf = malloc(len); HEAP8.set(new Uint8Array(e.data), buf); #if WEBSOCKET_DEBUG var s = `WebSocket onmessage, received data: ${len} bytes of binary:`; @@ -270,7 +270,7 @@ var LibraryWebSocket = { {{{ makeSetValue('eventPtr', C_STRUCTS.EmscriptenWebSocketMessageEvent.numBytes, 'len', 'i32') }}}, {{{ makeSetValue('eventPtr', C_STRUCTS.EmscriptenWebSocketMessageEvent.isText, 'isText', 'i8') }}}, {{{ makeDynCall('iipp', 'callbackFunc') }}}(0/*TODO*/, eventPtr, userData); - _free(buf); + free(buf); } return {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}}; }, diff --git a/src/library_wget.js b/src/library_wget.js index e8404cefd0d09..0c1a13b5572a9 100644 --- a/src/library_wget.js +++ b/src/library_wget.js @@ -67,10 +67,10 @@ var LibraryWget = { asyncLoad(UTF8ToString(url), (byteArray) => { {{{ runtimeKeepalivePop() }}} callUserCallback(() => { - var buffer = _malloc(byteArray.length); + var buffer = malloc(byteArray.length); HEAPU8.set(byteArray, buffer); {{{ makeDynCall('vppi', 'onload') }}}(userdata, buffer, byteArray.length); - _free(buffer); + free(buffer); }); }, () => { if (onerror) { @@ -189,10 +189,10 @@ var LibraryWget = { http.onload = (e) => { if (http.status >= 200 && http.status < 300 || (http.status === 0 && _url.substr(0,4).toLowerCase() != "http")) { var byteArray = new Uint8Array(/** @type{ArrayBuffer} */(http.response)); - var buffer = _malloc(byteArray.length); + var buffer = malloc(byteArray.length); HEAPU8.set(byteArray, buffer); if (onload) {{{ makeDynCall('vippi', 'onload') }}}(handle, userdata, buffer, byteArray.length); - if (free) _free(buffer); + if (free) free(buffer); } else { onerrorjs(); } diff --git a/src/memoryprofiler.js b/src/memoryprofiler.js index ec0585eed9a23..d7579c93fc31a 100644 --- a/src/memoryprofiler.js +++ b/src/memoryprofiler.js @@ -36,7 +36,7 @@ var emscriptenMemoryProfiler = { allocationSitePtrs: {}, // Stores an associative array of records HEAP ptr -> size so that we can - // retrieve how much memory was freed in calls to _free() and decrement the + // retrieve how much memory was freed in calls to free() and decrement the // tracked usage accordingly. // E.g. sizeOfAllocatedPtr[address] returns the size of the heap pointer // starting at 'address'. @@ -162,7 +162,7 @@ var emscriptenMemoryProfiler = { recordStackWatermark() { if (typeof runtimeInitialized == 'undefined' || runtimeInitialized) { var self = emscriptenMemoryProfiler; - self.stackTopWatermark = Math.min(self.stackTopWatermark, _emscripten_stack_get_current()); + self.stackTopWatermark = Math.min(self.stackTopWatermark, emscripten_stack_get_current()); } }, @@ -184,9 +184,9 @@ var emscriptenMemoryProfiler = { self.recordStackWatermark(); - // Remember the size of the allocated block to know how much will be _free()d later. + // Remember the size of the allocated block to know how much will be free()d later. self.sizeOfAllocatedPtr[ptr] = size; - // Also track if this was a _malloc performed at preRun time. + // Also track if this was a malloc performed at preRun time. if (!self.pagePreRunIsFinished) self.sizeOfPreRunAllocatedPtr[ptr] = size; var loc = new Error().stack.toString(); @@ -225,7 +225,7 @@ var emscriptenMemoryProfiler = { } delete self.allocationSitePtrs[ptr]; delete self.sizeOfAllocatedPtr[ptr]; - delete self.sizeOfPreRunAllocatedPtr[ptr]; // Also free if this happened to be a _malloc performed at preRun time. + delete self.sizeOfPreRunAllocatedPtr[ptr]; // Also free if this happened to be a malloc performed at preRun time. ++self.totalTimesFreeCalled; }, @@ -488,9 +488,9 @@ var emscriptenMemoryProfiler = { if (typeof runtimeInitialized != 'undefined' && !runtimeInitialized) { return; } - var stackBase = _emscripten_stack_get_base(); - var stackMax = _emscripten_stack_get_end(); - var stackCurrent = _emscripten_stack_get_current(); + var stackBase = emscripten_stack_get_base(); + var stackMax = emscripten_stack_get_end(); + var stackCurrent = emscripten_stack_get_current(); var width = (nBits(HEAP8.length) + 3) / 4; // Pointer 'word width' var html = 'Total HEAP size: ' + self.formatBytes(HEAP8.length) + '.'; html += '
' + colorBar('#202020') + 'STATIC memory area size: ' + self.formatBytes(stackMax - {{{ GLOBAL_BASE }}}); @@ -502,8 +502,8 @@ var emscriptenMemoryProfiler = { html += '. STACK_MAX: ' + toHex(stackMax, width) + '.'; html += '
STACK memory area used now (should be zero): ' + self.formatBytes(stackBase - stackCurrent) + '.' + colorBar('#FFFF00') + ' STACK watermark highest seen usage (approximate lower-bound!): ' + self.formatBytes(stackBase - self.stackTopWatermark); - var heap_base = Module['___heap_base']; - var heap_end = _sbrk({{{ to64('0') }}}); + var heap_base = Module['__heap_base']; + var heap_end = sbrk({{{ to64('0') }}}); html += "
DYNAMIC memory area size: " + self.formatBytes(heap_end - heap_base); html += ". start: " + toHex(heap_base, width); html += ". end: " + toHex(heap_end, width) + "."; diff --git a/src/parseTools.mjs b/src/parseTools.mjs index ca474affa3978..733a422190106 100644 --- a/src/parseTools.mjs +++ b/src/parseTools.mjs @@ -922,7 +922,7 @@ function hasExportedSymbol(sym) { // wasmTable are set. In this case we maybe need to re-export them on the // Module object. function receivedSymbol(sym) { - if (EXPORTED_RUNTIME_METHODS.has(sym)) { + if (EXPORTS.has(sym)) { return `Module['${sym}'] = ${sym};`; } return ''; @@ -987,7 +987,7 @@ function addReadyPromiseAssertions() { // var instance = Module(); // ... // instance._main(); - const properties = Array.from(EXPORTED_FUNCTIONS.values()); + const properties = Object.values(EXPORTS); // Also warn on onRuntimeInitialized which might be a common pattern with // older MODULARIZE-using codebases. properties.push('onRuntimeInitialized'); @@ -999,8 +999,8 @@ function addReadyPromiseAssertions() { `.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}'), + get: () => abort('You are getting \`' + prop + '\`${warningEnding}'), + set: () => abort('You are setting \`' + prop + '\`${warningEnding}'), }); } });` @@ -1071,7 +1071,7 @@ function getEntryFunction() { if (MAIN_MODULE) { return `resolveGlobalSymbol('${entryFunction}').sym;`; } - return `_${entryFunction}`; + return entryFunction; } function formattedMinNodeVersion() { diff --git a/src/parseTools_legacy.mjs b/src/parseTools_legacy.mjs index 53746e20c5c32..6f1daa0689cd2 100644 --- a/src/parseTools_legacy.mjs +++ b/src/parseTools_legacy.mjs @@ -82,7 +82,7 @@ function makeCopyValues(dest, src, num, type, modifier, align, sep = ';') { if (!isNumber(num)) num = stripCorrections(num); if (!isNumber(align)) align = stripCorrections(align); if (!isNumber(num) || parseInt(num) / align >= UNROLL_LOOP_MAX) { - return '(_memcpy(' + dest + ', ' + src + ', ' + num + ')|0)'; + return '(memcpy(' + dest + ', ' + src + ', ' + num + ')|0)'; } num = parseInt(num); // remove corrections, since we will be correcting after we add anyhow, @@ -104,7 +104,7 @@ function makeCopyValues(dest, src, num, type, modifier, align, sep = ';') { function makeMalloc(source, param) { warn('use of legacy parseTools function: makeMalloc'); - return `_malloc(${param})`; + return `malloc(${param})`; } function getNativeFieldSize(type) { diff --git a/src/postamble.js b/src/postamble.js index 075ed1048e48d..f4b41e52b9203 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -133,9 +133,9 @@ function stackCheckInit() { assert(!ENVIRONMENT_IS_PTHREAD); #endif #if RELOCATABLE - _emscripten_stack_set_limits({{{ STACK_HIGH }}} , {{{ STACK_LOW }}}); + emscripten_stack_set_limits({{{ STACK_HIGH }}} , {{{ STACK_LOW }}}); #else - _emscripten_stack_init(); + emscripten_stack_init(); #endif // TODO(sbc): Move writeStackCookie to native to to avoid this. writeStackCookie(); @@ -228,7 +228,7 @@ function run() { #endif #else #if ASSERTIONS - assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'); + assert(!Module['main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'); #endif // ASSERTIONS #endif // HAS_MAIN @@ -278,9 +278,9 @@ function checkUnflushedContent() { #elif WASMFS && hasExportedSymbol('wasmfs_flush') // In WasmFS we must also flush the WasmFS internal buffers, for this check // to work. - _wasmfs_flush(); + wasmfs_flush(); #elif hasExportedSymbol('fflush') - _fflush(0); + fflush(0); #endif #if '$FS' in addedLibraryItems && '$TTY' in addedLibraryItems // also flush in the JS FS layer @@ -374,9 +374,9 @@ var workerResponded = false, workerCallbackId = -1; if (data) { if (!data.byteLength) data = new Uint8Array(data); if (!buffer || bufferSize < data.length) { - if (buffer) _free(buffer); + if (buffer) free(buffer); bufferSize = data.length; - buffer = _malloc(data.length); + buffer = malloc(data.length); } HEAPU8.set(data, buffer); } diff --git a/src/postamble_minimal.js b/src/postamble_minimal.js index f34830f0cbd59..a6480e0b8e7b9 100644 --- a/src/postamble_minimal.js +++ b/src/postamble_minimal.js @@ -19,9 +19,9 @@ function run() { // User requested the PROXY_TO_PTHREAD option, so call a stub main which // pthread_create()s a new thread that will call the user's real main() for // the application. - var ret = __emscripten_proxy_main(); + var ret = _emscripten_proxy_main(); #else - var ret = _main(); + var ret = main(); #if EXIT_RUNTIME callRuntimeCallbacks(__ATEXIT__); @@ -38,7 +38,7 @@ function run() { runtimeExited = true; #endif - _proc_exit(ret); + proc_exit(ret); #endif #endif // PROXY_TO_PTHREAD @@ -62,7 +62,7 @@ function initRuntime(wasmExports) { #endif #if STACK_OVERFLOW_CHECK - _emscripten_stack_init(); + emscripten_stack_init(); writeStackCookie(); #if STACK_OVERFLOW_CHECK >= 2 setStackLimits(); @@ -82,7 +82,7 @@ function initRuntime(wasmExports) { // Initialize wasm (asynchronous) -// In non-fastcomp non-asm.js builds, grab wasm exports to outer scope +// In wasm2js builds, grab wasm exports to outer scope // for emscripten_get_exported_function() to be able to access them. #if LibraryManager.has('library_exports.js') var wasmExports; diff --git a/src/preamble.js b/src/preamble.js index d924c4ab9f8a2..cee166ab51311 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -102,14 +102,14 @@ function assert(condition, text) { // We used to include malloc/free by default in the past. Show a helpful error in // builds with assertions. #if !hasExportedSymbol('malloc') -function _malloc() { - abort('malloc() called but not included in the build - add `_malloc` to EXPORTED_FUNCTIONS'); +function malloc() { + abort('malloc() called but not included in the build - add `malloc` to EXPORTS'); } #endif // malloc #if !hasExportedSymbol('free') -function _free() { +function free() { // Show a helpful error since we used to include free by default in the past. - abort('free() called but not included in the build - add `_free` to EXPORTED_FUNCTIONS'); + abort('free() called but not included in the build - add `free` to EXPORTS'); } #endif // free #endif // ASSERTIONS @@ -269,7 +269,7 @@ function exitRuntime() { if (ENVIRONMENT_IS_PTHREAD) return; // PThreads reuse the runtime from the main thread. #endif #if !STANDALONE_WASM - ___funcs_on_exit(); // Native atexit() functions + __funcs_on_exit(); // Native atexit() functions #endif callRuntimeCallbacks(__ATEXIT__); <<< ATEXITS >>> @@ -464,7 +464,7 @@ function abort(what) { // caught by 'catch_all'), but in case throwing RuntimeError is fine because // the module has not even been instantiated, even less running. if (runtimeInitialized) { - ___trap(); + __trap(); } #endif /** @suppress {checkTypes} */ diff --git a/src/runtime_asan.js b/src/runtime_asan.js index babc684d04ffc..5f4eb693d89ac 100644 --- a/src/runtime_asan.js +++ b/src/runtime_asan.js @@ -14,82 +14,82 @@ /** @suppress{duplicate} */ function _asan_js_load_1(ptr) { - if (runtimeInitialized) return __asan_c_load_1(ptr); + if (runtimeInitialized) return _asan_c_load_1(ptr); return HEAP8[ptr]; } /** @suppress{duplicate} */ function _asan_js_load_1u(ptr) { - if (runtimeInitialized) return __asan_c_load_1u(ptr); + if (runtimeInitialized) return _asan_c_load_1u(ptr); return HEAPU8[ptr]; } /** @suppress{duplicate} */ function _asan_js_load_2(ptr) { - if (runtimeInitialized) return __asan_c_load_2(ptr); + if (runtimeInitialized) return _asan_c_load_2(ptr); return HEAP16[ptr]; } /** @suppress{duplicate} */ function _asan_js_load_2u(ptr) { - if (runtimeInitialized) return __asan_c_load_2u(ptr); + if (runtimeInitialized) return _asan_c_load_2u(ptr); return HEAPU16[ptr]; } /** @suppress{duplicate} */ function _asan_js_load_4(ptr) { - if (runtimeInitialized) return __asan_c_load_4(ptr); + if (runtimeInitialized) return _asan_c_load_4(ptr); return HEAP32[ptr]; } /** @suppress{duplicate} */ function _asan_js_load_4u(ptr) { - if (runtimeInitialized) return __asan_c_load_4u(ptr) >>> 0; + if (runtimeInitialized) return _asan_c_load_4u(ptr) >>> 0; return HEAPU32[ptr]; } /** @suppress{duplicate} */ function _asan_js_load_f(ptr) { - if (runtimeInitialized) return __asan_c_load_f(ptr); + if (runtimeInitialized) return _asan_c_load_f(ptr); return HEAPF32[ptr]; } /** @suppress{duplicate} */ function _asan_js_load_d(ptr) { - if (runtimeInitialized) return __asan_c_load_d(ptr); + if (runtimeInitialized) return _asan_c_load_d(ptr); return HEAPF64[ptr]; } /** @suppress{duplicate} */ function _asan_js_store_1(ptr, val) { - if (runtimeInitialized) return __asan_c_store_1(ptr, val); + if (runtimeInitialized) return _asan_c_store_1(ptr, val); return HEAP8[ptr] = val; } /** @suppress{duplicate} */ function _asan_js_store_1u(ptr, val) { - if (runtimeInitialized) return __asan_c_store_1u(ptr, val); + if (runtimeInitialized) return _asan_c_store_1u(ptr, val); return HEAPU8[ptr] = val; } /** @suppress{duplicate} */ function _asan_js_store_2(ptr, val) { - if (runtimeInitialized) return __asan_c_store_2(ptr, val); + if (runtimeInitialized) return _asan_c_store_2(ptr, val); return HEAP16[ptr] = val; } /** @suppress{duplicate} */ function _asan_js_store_2u(ptr, val) { - if (runtimeInitialized) return __asan_c_store_2u(ptr, val); + if (runtimeInitialized) return _asan_c_store_2u(ptr, val); return HEAPU16[ptr] = val; } /** @suppress{duplicate} */ function _asan_js_store_4(ptr, val) { - if (runtimeInitialized) return __asan_c_store_4(ptr, val); + if (runtimeInitialized) return _asan_c_store_4(ptr, val); return HEAP32[ptr] = val; } /** @suppress{duplicate} */ function _asan_js_store_4u(ptr, val) { - if (runtimeInitialized) return __asan_c_store_4u(ptr, val) >>> 0; + if (runtimeInitialized) return _asan_c_store_4u(ptr, val) >>> 0; return HEAPU32[ptr] = val; } /** @suppress{duplicate} */ function _asan_js_store_f(ptr, val) { - if (runtimeInitialized) return __asan_c_store_f(ptr, val); + if (runtimeInitialized) return _asan_c_store_f(ptr, val); return HEAPF32[ptr] = val; } /** @suppress{duplicate} */ function _asan_js_store_d(ptr, val) { - if (runtimeInitialized) return __asan_c_store_d(ptr, val); + if (runtimeInitialized) return _asan_c_store_d(ptr, val); return HEAPF64[ptr] = val; } diff --git a/src/runtime_debug.js b/src/runtime_debug.js index 2cc1d464e8ea3..f2629f530494b 100644 --- a/src/runtime_debug.js +++ b/src/runtime_debug.js @@ -124,7 +124,7 @@ function unexportedRuntimeSymbol(sym) { Object.defineProperty(Module, sym, { configurable: true, get() { - var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`; + var msg = `'${sym}' was not exported. add it to EXPORTS (see the Emscripten FAQ)`; if (isExportedByForceFilesystem(sym)) { msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you'; } diff --git a/src/runtime_pthread.js b/src/runtime_pthread.js index b9563279b7ba3..2ea0ca75c506a 100644 --- a/src/runtime_pthread.js +++ b/src/runtime_pthread.js @@ -58,7 +58,7 @@ if (ENVIRONMENT_IS_PTHREAD) { #endif function threadAlert(...args) { var text = args.join(' '); - postMessage({cmd: 'alert', text, threadId: _pthread_self()}); + postMessage({cmd: 'alert', text, threadId: pthread_self()}); } self.alert = threadAlert; @@ -155,23 +155,23 @@ if (ENVIRONMENT_IS_PTHREAD) { establishStackSpace(msgData.pthread_ptr); // Pass the thread address to wasm to store it for fast access. - __emscripten_thread_init(msgData.pthread_ptr, /*is_main=*/0, /*is_runtime=*/0, /*can_block=*/1, 0, 0); + _emscripten_thread_init(msgData.pthread_ptr, /*is_main=*/0, /*is_runtime=*/0, /*can_block=*/1, 0, 0); PThread.receiveObjectTransfer(msgData); PThread.threadInitTLS(); // Await mailbox notifications with `Atomics.waitAsync` so we can start // using the fast `Atomics.notify` notification path. - __emscripten_thread_mailbox_await(msgData.pthread_ptr); + _emscripten_thread_mailbox_await(msgData.pthread_ptr); if (!initializedJS) { #if EMBIND #if PTHREADS_DEBUG - dbg(`worker: Pthread 0x${_pthread_self().toString(16)} initializing embind.`); + dbg(`worker: Pthread 0x${pthread_self().toString(16)} initializing embind.`); #endif // Embind must initialize itself on all threads, as it generates support JS. // We only do this once per worker since they get reused - __embind_initialize_bindings(); + _embind_initialize_bindings(); #endif // EMBIND initializedJS = true; } @@ -186,7 +186,7 @@ if (ENVIRONMENT_IS_PTHREAD) { throw ex; } #if RUNTIME_DEBUG - dbg(`worker: Pthread 0x${_pthread_self().toString(16)} completed its main entry point with an 'unwind', keeping the worker alive for asynchronous operation.`); + dbg(`worker: Pthread 0x${pthread_self().toString(16)} completed its main entry point with an 'unwind', keeping the worker alive for asynchronous operation.`); #endif } } else if (msgData.target === 'setimmediate') { @@ -207,7 +207,7 @@ if (ENVIRONMENT_IS_PTHREAD) { err(`worker: onmessage() captured an uncaught exception: ${ex}`); if (ex?.stack) err(ex.stack); #endif - __emscripten_thread_crashed(); + _emscripten_thread_crashed(); throw ex; } }; diff --git a/src/runtime_safe_heap.js b/src/runtime_safe_heap.js index 2531bd811c1a7..508c9bf246745 100644 --- a/src/runtime_safe_heap.js +++ b/src/runtime_safe_heap.js @@ -42,9 +42,9 @@ function SAFE_HEAP_STORE(dest, value, bytes, isFloat) { #else if (runtimeInitialized) { #endif - var brk = _sbrk(0); + var brk = sbrk(0); if (dest + bytes > brk) abort(`segmentation fault, exceeded the top of the available dynamic heap when storing ${bytes} bytes to address ${dest}. DYNAMICTOP=${brk}`); - if (brk < _emscripten_stack_get_base()) abort(`brk >= _emscripten_stack_get_base() (brk=${brk}, _emscripten_stack_get_base()=${_emscripten_stack_get_base()})`); // sbrk-managed memory must be above the stack + if (brk < emscripten_stack_get_base()) abort(`brk >= emscripten_stack_get_base() (brk=${brk}, emscripten_stack_get_base()=${emscripten_stack_get_base()})`); // sbrk-managed memory must be above the stack if (brk > wasmMemory.buffer.byteLength) abort(`brk <= wasmMemory.buffer.byteLength (brk=${brk}, wasmMemory.buffer.byteLength=${wasmMemory.buffer.byteLength})`); } setValue_safe(dest, value, getSafeHeapType(bytes, isFloat)); @@ -70,9 +70,9 @@ function SAFE_HEAP_LOAD(dest, bytes, unsigned, isFloat) { #else if (runtimeInitialized) { #endif - var brk = _sbrk(0); + var brk = sbrk(0); if (dest + bytes > brk) abort(`segmentation fault, exceeded the top of the available dynamic heap when loading ${bytes} bytes from address ${dest}. DYNAMICTOP=${brk}`); - if (brk < _emscripten_stack_get_base()) abort(`brk >= _emscripten_stack_get_base() (brk=${brk}, _emscripten_stack_get_base()=${_emscripten_stack_get_base()})`); // sbrk-managed memory must be above the stack + if (brk < emscripten_stack_get_base()) abort(`brk >= emscripten_stack_get_base() (brk=${brk}, emscripten_stack_get_base()=${emscripten_stack_get_base()})`); // sbrk-managed memory must be above the stack if (brk > wasmMemory.buffer.byteLength) abort(`brk <= wasmMemory.buffer.byteLength (brk=${brk}, wasmMemory.buffer.byteLength=${wasmMemory.buffer.byteLength})`); } var type = getSafeHeapType(bytes, isFloat); @@ -94,14 +94,3 @@ function SAFE_FT_MASK(value, mask) { } return ret; } - -function segfault() { - abort('segmentation fault'); -} -function alignfault() { -#if SAFE_HEAP == 1 - abort('alignment fault'); -#else - warnOnce('alignment fault'); -#endif -} diff --git a/src/runtime_shared.js b/src/runtime_shared.js index 22ef5e881c426..f7dd5bb398e79 100644 --- a/src/runtime_shared.js +++ b/src/runtime_shared.js @@ -18,7 +18,7 @@ // the heap. AudioWorkletGlobalScope is unable to access global JS vars // in the compiled main JS file. shouldExport = true; - } else if (EXPORTED_RUNTIME_METHODS.includes(x)) { + } else if (EXPORTS.includes(x)) { shouldExport = true; } } diff --git a/src/runtime_stack_check.js b/src/runtime_stack_check.js index bbeb97c9a2eee..88a9e9b3ddc61 100644 --- a/src/runtime_stack_check.js +++ b/src/runtime_stack_check.js @@ -7,7 +7,7 @@ #if STACK_OVERFLOW_CHECK // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode. function writeStackCookie() { - var max = _emscripten_stack_get_end(); + var max = emscripten_stack_get_end(); #if RUNTIME_DEBUG dbg(`writeStackCookie: ${ptrToString(max)}`); #endif @@ -20,7 +20,7 @@ function writeStackCookie() { if (max == 0) { max += 4; } - // The stack grow downwards towards _emscripten_stack_get_end. + // The stack grow downwards towards emscripten_stack_get_end. // We write cookies to the final two words in the stack and detect if they are // ever overwritten. {{{ makeSetValue('max', 0, '0x02135467', 'u32') }}}; @@ -35,7 +35,7 @@ function checkStackCookie() { #if !MINIMAL_RUNTIME if (ABORT) return; #endif - var max = _emscripten_stack_get_end(); + var max = emscripten_stack_get_end(); #if RUNTIME_DEBUG >= 2 dbg(`checkStackCookie: ${ptrToString(max)}`); #endif diff --git a/src/settings.js b/src/settings.js index e009a98c907e7..d0993c63999c9 100644 --- a/src/settings.js +++ b/src/settings.js @@ -1076,6 +1076,12 @@ var NODE_CODE_CACHING = false; // [link] var EXPORTED_FUNCTIONS = []; +// Unverals specifier for module exports. This settings replaces, and is +// mutuallry exclusive with both EXPORTED_FUNCTIONS and +// EXPORTED_RUNTIME_METHODS. It can also be used to export JS library symbols +// without also needing to specify DEFAULT_LIBRARY_FUNCS_TO_INCLUDE. +var EXPORTS = []; + // If true, we export all the symbols that are present in JS onto the Module // object. This does not affect which symbols will be present - it does not // prevent DCE or cause anything to be included in linking. It only does @@ -2186,6 +2192,10 @@ var LEGACY_RUNTIME = false; // [link] var SIGNATURE_CONVERSIONS = []; +// Define native symbols with a leading underscore, in addition unmanged +// symbols. This is mostly for compability with legacy codebases. +var MANGLED_SYMBOLS = true; + //=========================================== // Internal, used for testing only, from here //=========================================== diff --git a/src/threadprofiler.js b/src/threadprofiler.js index ceef416d56248..b6843a9fae160 100644 --- a/src/threadprofiler.js +++ b/src/threadprofiler.js @@ -37,7 +37,7 @@ var emscriptenThreadProfiler = { }, dumpState() { - var mainThread = _emscripten_main_runtime_thread_id(); + var mainThread = emscripten_main_runtime_thread_id(); var threads = [mainThread]; for (var thread of Object.values(PThread.pthreads)) { @@ -65,7 +65,7 @@ var emscriptenThreadProfiler = { return; } var str = ''; - var mainThread = _emscripten_main_runtime_thread_id(); + var mainThread = emscripten_main_runtime_thread_id(); var threads = [mainThread]; for (var thread of Object.values(PThread.pthreads)) { diff --git a/test/benchmark/benchmark_utf16.cpp b/test/benchmark/benchmark_utf16.cpp index ad17747a7964a..fe26ea87c7c1d 100644 --- a/test/benchmark/benchmark_utf16.cpp +++ b/test/benchmark/benchmark_utf16.cpp @@ -14,9 +14,9 @@ EM_JS_DEPS(deps, "$UTF16ToString"); double test(const unsigned short *str) { double res = EM_ASM_DOUBLE({ - var t0 = _emscripten_get_now(); + var t0 = emscripten_get_now(); var str = UTF16ToString($0); - var t1 = _emscripten_get_now(); + var t1 = emscripten_get_now(); out('t: ' + (t1 - t0) + ', len(result): ' + str.length + ', result: ' + str.slice(0, 100)); return (t1-t0); }, str); diff --git a/test/benchmark/benchmark_utf8.c b/test/benchmark/benchmark_utf8.c index 38a93b25902db..6ae89b22d85b3 100644 --- a/test/benchmark/benchmark_utf8.c +++ b/test/benchmark/benchmark_utf8.c @@ -14,9 +14,9 @@ EM_JS_DEPS(deps, "$UTF8ToString,emscripten_get_now"); double test(const char *str) { double res = EM_ASM_DOUBLE({ - var t0 = _emscripten_get_now(); + var t0 = emscripten_get_now(); var str = UTF8ToString($0); - var t1 = _emscripten_get_now(); + var t1 = emscripten_get_now(); // out('t: ' + (t1 - t0) + ', len(result): ' + str.length + ', result: ' + str.slice(0, 100)); return (t1-t0); }, str); diff --git a/test/code_size/embind_hello_wasm.json b/test/code_size/embind_hello_wasm.json index f3b1d73bc6bec..333d0cc062ea6 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": 7776, + "a.wasm.gz": 3534, + "total": 18046, + "total_gz": 8205 } diff --git a/test/code_size/embind_val_wasm.json b/test/code_size/embind_val_wasm.json index a29f2a93b393a..a4f3b08e22c33 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": 9564, - "a.wasm.gz": 4908, - "total": 16965, - "total_gz": 8235 + "a.wasm": 9608, + "a.wasm.gz": 4937, + "total": 17009, + "total_gz": 8264 } diff --git a/test/code_size/hello_wasm_worker_wasm.js b/test/code_size/hello_wasm_worker_wasm.js index 4e7446cc3dfa6..88da1ed3c0934 100644 --- a/test/code_size/hello_wasm_worker_wasm.js +++ b/test/code_size/hello_wasm_worker_wasm.js @@ -42,7 +42,7 @@ WebAssembly.instantiate(b.wasm, { }).then((a => { a = a.instance.exports; p = a.g; - q = a.i; + q = a.l; h = a.h; c ? (a = b, q(a.sb, a.sz), removeEventListener("message", l), g = g.forEach(k), addEventListener("message", k)) : a.f(); diff --git a/test/code_size/hello_wasm_worker_wasm.json b/test/code_size/hello_wasm_worker_wasm.json index 870b7172314c4..be9f27da4ef85 100644 --- a/test/code_size/hello_wasm_worker_wasm.json +++ b/test/code_size/hello_wasm_worker_wasm.json @@ -5,8 +5,8 @@ "a.js.gz": 455, "a.ww.js": 115, "a.ww.js.gz": 127, - "a.wasm": 1881, - "a.wasm.gz": 1065, - "total": 3279, - "total_gz": 2031 + "a.wasm": 1929, + "a.wasm.gz": 1091, + "total": 3327, + "total_gz": 2057 } diff --git a/test/code_size/hello_webgl2_wasm.json b/test/code_size/hello_webgl2_wasm.json index 6a80b58ccd57a..e12c3b93084c9 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": 4531, "a.js.gz": 2312, - "a.wasm": 10402, - "a.wasm.gz": 6704, - "total": 15387, - "total_gz": 9344 + "a.wasm": 10446, + "a.wasm.gz": 6734, + "total": 15431, + "total_gz": 9374 } diff --git a/test/code_size/hello_webgl2_wasm2js.json b/test/code_size/hello_webgl2_wasm2js.json index 3d8c851127bc8..86911a58eedbc 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": 22199, - "a.js.gz": 11579, - "total": 22545, - "total_gz": 11841 + "a.js": 22287, + "a.js.gz": 11611, + "total": 22633, + "total_gz": 11873 } diff --git a/test/code_size/hello_webgl_wasm.json b/test/code_size/hello_webgl_wasm.json index 78cc66760308e..7c03690596576 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": 4069, "a.js.gz": 2158, - "a.wasm": 10402, - "a.wasm.gz": 6704, - "total": 14925, - "total_gz": 9190 + "a.wasm": 10446, + "a.wasm.gz": 6734, + "total": 14969, + "total_gz": 9220 } diff --git a/test/code_size/hello_webgl_wasm2js.json b/test/code_size/hello_webgl_wasm2js.json index 1320f0d8bddcf..8df941698b0a9 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": 21725, - "a.js.gz": 11413, - "total": 22071, - "total_gz": 11675 + "a.js": 21813, + "a.js.gz": 11444, + "total": 22159, + "total_gz": 11706 } diff --git a/test/code_size/hello_world_wasm.json b/test/code_size/hello_world_wasm.json index dc5b02a59ba81..0cb3c44063ed1 100644 --- a/test/code_size/hello_world_wasm.json +++ b/test/code_size/hello_world_wasm.json @@ -3,8 +3,8 @@ "a.html.gz": 380, "a.js": 283, "a.js.gz": 244, - "a.wasm": 103, - "a.wasm.gz": 113, - "total": 938, - "total_gz": 737 + "a.wasm": 166, + "a.wasm.gz": 156, + "total": 1001, + "total_gz": 780 } diff --git a/test/code_size/hello_world_wasm2js.js b/test/code_size/hello_world_wasm2js.js index 506eec49240aa..53672adfcc032 100644 --- a/test/code_size/hello_world_wasm2js.js +++ b/test/code_size/hello_world_wasm2js.js @@ -1,30 +1,30 @@ var d = Module, g, h, k = new TextDecoder, l; function e(b) { - this.exports = function(r) { - function u(c) { - c.set = function(a, f) { - this[a] = f; + this.exports = function(t) { + function u(f) { + f.set = function(a, m) { + this[a] = m; }; - c.get = function(a) { + f.get = function(a) { return this[a]; }; - return c; + return f; } - function x(c, a, f) { - for (var v, p = 0, t = a, w = f.length, y = a + (3 * w >> 2) - ("=" == f[w - 2]) - ("=" == f[w - 1]); p < w; p += 4) a = m[f.charCodeAt(p + 1)], - v = m[f.charCodeAt(p + 2)], c[t++] = m[f.charCodeAt(p)] << 2 | a >> 4, t < y && (c[t++] = a << 4 | v >> 2), - t < y && (c[t++] = v << 6 | m[f.charCodeAt(p + 3)]); + function x(f, a, m) { + for (var v, n = 0, c = a, w = m.length, y = a + (3 * w >> 2) - ("=" == m[w - 2]) - ("=" == m[w - 1]); n < w; n += 4) a = p[m.charCodeAt(n + 1)], + v = p[m.charCodeAt(n + 2)], f[c++] = p[m.charCodeAt(n)] << 2 | a >> 4, c < y && (f[c++] = a << 4 | v >> 2), + c < y && (f[c++] = v << 6 | p[m.charCodeAt(n + 3)]); } - for (var q, m = new Uint8Array(123), n = 25; 0 <= n; --n) m[48 + n] = 52 + n, m[65 + n] = n, - m[97 + n] = 26 + n; - m[43] = 62; - m[47] = 63; - return function(c) { - var a = new ArrayBuffer(16908288), f = new Uint8Array(a), v = c.a.a; - q = f; - x(q, 1024, "aGVsbG8h"); - c = u([]); + for (var r, p = new Uint8Array(123), q = 25; 0 <= q; --q) p[48 + q] = 52 + q, p[65 + q] = q, + p[97 + q] = 26 + q; + p[43] = 62; + p[47] = 63; + return function(f) { + var a = new ArrayBuffer(16908288), m = new Uint8Array(a), v = f.a.a, n = 66576; + r = m; + x(r, 1024, "aGVsbG8h"); + f = u([]); return { b: Object.create(Object.prototype, { grow: {}, @@ -35,33 +35,43 @@ function e(b) { } }), c: function() {}, - d: function(p, t) { + d: function(c, w) { v(1024); return 0; }, - e: c + e: f, + f: function(c) { + n = c | 0; + }, + g: function(c) { + n = c = n - (c | 0) & -16; + return c | 0; + }, + h: function() { + return n | 0; + } }; - }(r); + }(t); }(b); } -(function(b, r) { +(function(b, t) { return { then: function(u) { u({ - instance: new e(r) + instance: new e(t) }); } }; })(d.wasm, { a: { a: b => { - var r = console, u = r.log; + var t = console, u = t.log; if (b) { - for (var x = b + void 0, q = b; !(q >= x) && g[q]; ) ++q; - b = k.decode(g.subarray(b, q)); + for (var x = b + void 0, r = b; !(r >= x) && g[r]; ) ++r; + b = k.decode(g.subarray(b, r)); } else b = ""; - u.call(r, b); + u.call(t, b); } } }).then((b => { diff --git a/test/code_size/hello_world_wasm2js.json b/test/code_size/hello_world_wasm2js.json index 4b2ebea84cdfe..b138035b250bd 100644 --- a/test/code_size/hello_world_wasm2js.json +++ b/test/code_size/hello_world_wasm2js.json @@ -1,8 +1,8 @@ { "a.html": 323, "a.html.gz": 253, - "a.js": 1052, - "a.js.gz": 630, - "total": 1375, - "total_gz": 883 + "a.js": 1148, + "a.js.gz": 668, + "total": 1471, + "total_gz": 921 } diff --git a/test/code_size/math_wasm.json b/test/code_size/math_wasm.json index 391e9180af9a3..3f5a19b724a33 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": 2786, + "a.wasm.gz": 1722, + "total": 3448, + "total_gz": 2227 } diff --git a/test/code_size/random_printf_wasm.json b/test/code_size/random_printf_wasm.json index d2f98594aa0a4..a495ce27df305 100644 --- a/test/code_size/random_printf_wasm.json +++ b/test/code_size/random_printf_wasm.json @@ -1,6 +1,6 @@ { - "a.html": 12694, - "a.html.gz": 6913, - "total": 12694, - "total_gz": 6913 + "a.html": 12762, + "a.html.gz": 6942, + "total": 12762, + "total_gz": 6942 } diff --git a/test/code_size/random_printf_wasm2js.json b/test/code_size/random_printf_wasm2js.json index ad119151aacfd..bcd7fb98ab548 100644 --- a/test/code_size/random_printf_wasm2js.json +++ b/test/code_size/random_printf_wasm2js.json @@ -1,6 +1,6 @@ { - "a.html": 17270, - "a.html.gz": 7507, - "total": 17270, - "total_gz": 7507 + "a.html": 17358, + "a.html.gz": 7539, + "total": 17358, + "total_gz": 7539 } diff --git a/test/core/FS_exports_assert_2.out b/test/core/FS_exports_assert_2.out index ed4fc2cde0c50..f21d07d20b70b 100644 --- a/test/core/FS_exports_assert_2.out +++ b/test/core/FS_exports_assert_2.out @@ -1 +1 @@ -Aborted('FS_createDataFile' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ). Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you) +Aborted('FS_createDataFile' was not exported. add it to EXPORTS (see the Emscripten FAQ). Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you) diff --git a/test/core/js_library_i64_params.js b/test/core/js_library_i64_params.js index d596e8dd0073b..1690afddc7f07 100644 --- a/test/core/js_library_i64_params.js +++ b/test/core/js_library_i64_params.js @@ -5,7 +5,7 @@ TestLibrary = { {{{ receiveI64ParamAsI53('foo', `(err('overflow'), ${makeReturn64('42')})`) }}} err('js:got: ' + foo); - _called_from_js({{{ splitI64("foo") }}}); + called_from_js({{{ splitI64("foo") }}}); if (foo < 0) var rtn = Math.ceil(foo / 2); diff --git a/test/core/legacy_exported_runtime_numbers_assert.out b/test/core/legacy_exported_runtime_numbers_assert.out index f501a197b6a27..056a235d5f4bc 100644 --- a/test/core/legacy_exported_runtime_numbers_assert.out +++ b/test/core/legacy_exported_runtime_numbers_assert.out @@ -1 +1 @@ -Aborted('ALLOC_STACK' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)) +Aborted('ALLOC_STACK' was not exported. add it to EXPORTS (see the Emscripten FAQ)) diff --git a/test/core/test_abort_on_exceptions_post.js b/test/core/test_abort_on_exceptions_post.js index 2c66fa2a6063f..4f0e3b4486ffe 100644 --- a/test/core/test_abort_on_exceptions_post.js +++ b/test/core/test_abort_on_exceptions_post.js @@ -1,7 +1,7 @@ addOnPostRun(function() { try { // Crash the program - _cFunc(); + cFunc(); } catch(e) { // Catch the abort @@ -10,7 +10,7 @@ addOnPostRun(function() { out("again"); try { // Try executing a function directly - _cFunc(); + cFunc(); out("never"); } catch(e) { diff --git a/test/core/test_aborting_new.cpp b/test/core/test_aborting_new.cpp index 69f2ce5ee2710..3554340947283 100644 --- a/test/core/test_aborting_new.cpp +++ b/test/core/test_aborting_new.cpp @@ -14,7 +14,7 @@ int main() { EM_ASM({ // Catch the failure here so we can report it. try { - _allocate_too_much(); + allocate_too_much(); out("no abort happened"); } catch (e) { assert(("" + e).indexOf("Aborted") >= 0, "expect an abort from new"); diff --git a/test/core/test_asan_js_stack_op.c b/test/core/test_asan_js_stack_op.c index 72392bc67cc18..9e243d703e6f2 100644 --- a/test/core/test_asan_js_stack_op.c +++ b/test/core/test_asan_js_stack_op.c @@ -8,7 +8,7 @@ EMSCRIPTEN_KEEPALIVE void c_func(char *str) { EM_JS_DEPS(js_func, "$stringToUTF8OnStack"); EM_JS(void, js_func, (void), { - _c_func(stringToUTF8OnStack('Hello, World!')); + c_func(stringToUTF8OnStack('Hello, World!')); }); int main(void) { diff --git a/test/core/test_asyncify_assertions.c b/test/core/test_asyncify_assertions.c index 8133af123e788..50429e6dabb3e 100644 --- a/test/core/test_asyncify_assertions.c +++ b/test/core/test_asyncify_assertions.c @@ -5,7 +5,7 @@ EM_JS(void, suspend, (), { Asyncify.handleSleep((wakeUp) => { Module.resume = wakeUp; setTimeout(function() { - Module._resume_from_inside_c(); + Module.resume_from_inside_c(); }, 1); }); }); diff --git a/test/core/test_dlfcn_self.c b/test/core/test_dlfcn_self.c index f986f41954097..4784ea36500d0 100644 --- a/test/core/test_dlfcn_self.c +++ b/test/core/test_dlfcn_self.c @@ -13,7 +13,7 @@ int EMSCRIPTEN_KEEPALIVE global = 123; EMSCRIPTEN_KEEPALIVE void foo(int x) { - printf("%d\n", x); + printf("foo called: %d\n", x); } void repeatable() { @@ -32,7 +32,9 @@ void repeatable() { } int main() { + printf("in main\n"); repeatable(); repeatable(); + printf("done main\n"); return 0; } diff --git a/test/core/test_dlfcn_self.out b/test/core/test_dlfcn_self.out index 3e67fe1ac4f36..ce2ef0090a924 100644 --- a/test/core/test_dlfcn_self.out +++ b/test/core/test_dlfcn_self.out @@ -1,2 +1,4 @@ -123 -123 +in main +foo called: 123 +foo called: 123 +done main diff --git a/test/core/test_em_async_js.c b/test/core/test_em_async_js.c index e72dcad60db96..0b20d2905054d 100644 --- a/test/core/test_em_async_js.c +++ b/test/core/test_em_async_js.c @@ -22,9 +22,11 @@ EM_ASYNC_JS(double, foo, (int timeout), { () => { // Do a simple call back into compiled code synchronously. This is // allowed (an async one would not). - _inc_result(); + inc_result(); // Do the same with ccall. + out("XXX"); ccall("inc_result"); + out("YYY"); // Finish the async operation. out("resolving promise"); resolve(); @@ -32,7 +34,7 @@ EM_ASYNC_JS(double, foo, (int timeout), { timeout )); // Do another simple call back into compiled code synchronously. - return _get_result(); + return get_result(); }); // Test out void return and no params. diff --git a/test/core/test_em_js.cpp b/test/core/test_em_js.cpp index 1d50e6e55f97e..d4d4a546b53b3 100644 --- a/test/core/test_em_js.cpp +++ b/test/core/test_em_js.cpp @@ -68,7 +68,7 @@ EM_JS_DEPS(deps, "$stringToUTF8,$lengthBytesUTF8"); EM_JS(char*, return_utf8_str, (void), { var jsString = 'こんにちは'; var lengthBytes = lengthBytesUTF8(jsString)+1; - var stringOnWasmHeap = _malloc(lengthBytes); + var stringOnWasmHeap = malloc(lengthBytes); stringToUTF8(jsString, stringOnWasmHeap, lengthBytes); // FIXME(https://github.com/emscripten-core/emscripten/issues/16975) #if __wasm64__ @@ -81,7 +81,7 @@ EM_JS(char*, return_utf8_str, (void), { EM_JS(char*, return_str, (void), { var jsString = 'hello from js'; var lengthBytes = jsString.length+1; - var stringOnWasmHeap = _malloc(lengthBytes); + var stringOnWasmHeap = malloc(lengthBytes); stringToUTF8(jsString, stringOnWasmHeap, lengthBytes); // FIXME(https://github.com/emscripten-core/emscripten/issues/16975) #if __wasm64__ diff --git a/test/core/test_emscripten_api.cpp b/test/core/test_emscripten_api.cpp index 766db92ea70ca..600e68b4c9009 100644 --- a/test/core/test_emscripten_api.cpp +++ b/test/core/test_emscripten_api.cpp @@ -17,7 +17,7 @@ int main() { emscripten_run_script("out('hello world' + '!')"); printf("*%d*\n", emscripten_run_script_int("5*20")); printf("*%s*\n", emscripten_run_script_string("'five'+'six'")); - emscripten_run_script("Module['_save_me_aimee']()"); + emscripten_run_script("Module['save_me_aimee']()"); // double d = 0.1234567891231219886553; int len = emscripten_print_double(d, NULL, -1); diff --git a/test/core/test_getValue_setValue_assert.out b/test/core/test_getValue_setValue_assert.out index 3b7a0c5374450..ba05cf2fd5e2a 100644 --- a/test/core/test_getValue_setValue_assert.out +++ b/test/core/test_getValue_setValue_assert.out @@ -1 +1 @@ -Aborted('setValue' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)) +Aborted('setValue' was not exported. add it to EXPORTS (see the Emscripten FAQ)) diff --git a/test/core/test_utf.c b/test/core/test_utf.c index e39d55c3e8d2b..a0a6e52e5600b 100644 --- a/test/core/test_utf.c +++ b/test/core/test_utf.c @@ -14,12 +14,12 @@ int main() { printf("%d %d %d %d %s\n", c[0] & 0xff, c[1] & 0xff, c[2] & 0xff, c[3] & 0xff, c); emscripten_run_script( - "var cheez = _malloc(100);" + "var cheez = malloc(100);" "Module.stringToUTF8(\"μ†ℱ ╋ℯ╳╋ 😇\", cheez, 100);" "out([UTF8ToString(cheez), Module.getValue(cheez, " "'i8')&0xff, Module.getValue(cheez+1, 'i8')&0xff, " "Module.getValue(cheez+2, 'i8')&0xff, Module.getValue(cheez+3, " "'i8')&0xff].join(','));" - "_free(cheez);" + "free(cheez);" ); } diff --git a/test/declare_asm_module_exports.c b/test/declare_asm_module_exports.c index ed22684c03e46..84234840fd5dd 100644 --- a/test/declare_asm_module_exports.c +++ b/test/declare_asm_module_exports.c @@ -7,7 +7,7 @@ int EMSCRIPTEN_KEEPALIVE cFunction(void) { } EM_JS(int, jsFunction, (), { - return _cFunction(); + return cFunction(); }); // Intentional use of __main_argc_argv diff --git a/test/embind/embind.benchmark.js b/test/embind/embind.benchmark.js index d4ae0b0473727..9c4725b7f63a9 100644 --- a/test/embind/embind.benchmark.js +++ b/test/embind/embind.benchmark.js @@ -1,7 +1,7 @@ addToLibrary({ increment_counter_benchmark_js: function(N) { var ctr = _get_counter(); - var a = _emscripten_get_now(); + var a = emscripten_get_now(); for(i = 0; i < N; ++i) { _increment_counter(); _increment_counter(); @@ -14,14 +14,14 @@ addToLibrary({ _increment_counter(); _increment_counter(); } - var b = _emscripten_get_now(); + var b = emscripten_get_now(); var ctr2 = _get_counter(); out("JS increment_counter " + N + " iters: " + (b-a) + " msecs. result: " + (ctr2-ctr)); }, increment_class_counter_benchmark_embind_js: function(N) { var foo = new Module['Foo'](); - var a = _emscripten_get_now(); + var a = emscripten_get_now(); for(i = 0; i < N; ++i) { foo['incr_class_counter'](); foo['incr_class_counter'](); @@ -34,13 +34,13 @@ addToLibrary({ foo['incr_class_counter'](); foo['incr_class_counter'](); } - var b = _emscripten_get_now(); + var b = emscripten_get_now(); out("JS embind increment_class_counter " + N + " iters: " + (b-a) + " msecs. result: " + foo['class_counter_val']()); foo['delete'](); }, returns_input_benchmark_js: function() { - var a = _emscripten_get_now(); + var a = emscripten_get_now(); var t = 0; for(i = 0; i < 100000; ++i) { t += _returns_input(i); @@ -54,12 +54,12 @@ addToLibrary({ t += _returns_input(i); t += _returns_input(i); } - var b = _emscripten_get_now(); + var b = emscripten_get_now(); out("JS returns_input 100000 iters: " + (b-a) + " msecs. result: " + t); }, sum_int_benchmark_js: function() { - var a = _emscripten_get_now(); + var a = emscripten_get_now(); var r = 0; for(i = 0; i < 100000; ++i) { r += _sum_int(i, 2, 3, 4, 5, 6, 7, 8, 9); @@ -73,12 +73,12 @@ addToLibrary({ r += _sum_int(i, 2, 3, 4, 5, 6, 7, 8, 9); r += _sum_int(i, 2, 3, 4, 5, 6, 7, 8, 9); } - var b = _emscripten_get_now(); + var b = emscripten_get_now(); out("JS sum_int 100000 iters: " + (b-a) + " msecs. result: " + r); }, sum_float_benchmark_js: function() { - var a = _emscripten_get_now(); + var a = emscripten_get_now(); var r = 0; for(i = 0; i < 100000; ++i) { r += _sum_float(i, 2, 3, 4, 5, 6, 7, 8, 9); @@ -92,13 +92,13 @@ addToLibrary({ r += _sum_float(i, 2, 3, 4, 5, 6, 7, 8, 9); r += _sum_float(i, 2, 3, 4, 5, 6, 7, 8, 9); } - var b = _emscripten_get_now(); + var b = emscripten_get_now(); out("JS sum_float 100000 iters: " + (b-a) + " msecs. result: " + r); }, increment_counter_benchmark_embind_js: function (N) { var ctr = _get_counter(); - var a = _emscripten_get_now(); + var a = emscripten_get_now(); for(i = 0; i < N; ++i) { Module['increment_counter'](); Module['increment_counter'](); @@ -111,13 +111,13 @@ addToLibrary({ Module['increment_counter'](); Module['increment_counter'](); } - var b = _emscripten_get_now(); + var b = emscripten_get_now(); var ctr2 = _get_counter(); out("JS embind increment_counter " + N + " iters: " + (b-a) + " msecs. result: " + (ctr2-ctr)); }, returns_input_benchmark_embind_js: function() { - var a = _emscripten_get_now(); + var a = emscripten_get_now(); var t = 0; for(i = 0; i < 100000; ++i) { t += Module['returns_input'](i); @@ -131,12 +131,12 @@ addToLibrary({ t += Module['returns_input'](i); t += Module['returns_input'](i); } - var b = _emscripten_get_now(); + var b = emscripten_get_now(); out("JS embind returns_input 100000 iters: " + (b-a) + " msecs. result: " + t); }, sum_int_benchmark_embind_js: function() { - var a = _emscripten_get_now(); + var a = emscripten_get_now(); var r = 0; for(i = 0; i < 100000; ++i) { r += Module['sum_int'](i, 2, 3, 4, 5, 6, 7, 8, 9); @@ -150,12 +150,12 @@ addToLibrary({ r += Module['sum_int'](i, 2, 3, 4, 5, 6, 7, 8, 9); r += Module['sum_int'](i, 2, 3, 4, 5, 6, 7, 8, 9); } - var b = _emscripten_get_now(); + var b = emscripten_get_now(); out("JS embind sum_int 100000 iters: " + (b-a) + " msecs. result: " + r); }, sum_float_benchmark_embind_js: function() { - var a = _emscripten_get_now(); + var a = emscripten_get_now(); var r = 0; for(i = 0; i < 100000; ++i) { r += Module['sum_float'](i, 2, 3, 4, 5, 6, 7, 8, 9); @@ -169,7 +169,7 @@ addToLibrary({ r += Module['sum_float'](i, 2, 3, 4, 5, 6, 7, 8, 9); r += Module['sum_float'](i, 2, 3, 4, 5, 6, 7, 8, 9); } - var b = _emscripten_get_now(); + var b = emscripten_get_now(); out("JS embind sum_float 100000 iters: " + (b-a) + " msecs. result: " + r); }, @@ -180,7 +180,7 @@ addToLibrary({ objects.push(Module['create_game_object']()); } - var a = _emscripten_get_now(); + var a = emscripten_get_now(); for(i = 0; i < N; ++i) { var t = objects[i]['GetTransform'](); var pos = Module['add'](t['GetPosition'](), [2, 0, 1]); @@ -189,7 +189,7 @@ addToLibrary({ t['SetRotation'](rot); t['delete'](); } - var b = _emscripten_get_now(); + var b = emscripten_get_now(); var accum = [0,0,0]; for(i = 0; i < N; ++i) { @@ -209,12 +209,12 @@ addToLibrary({ objects.push(Module['create_game_object']()); } - var a = _emscripten_get_now(); + var a = emscripten_get_now(); for(i = 0; i < N; ++i) { var t = Module['pass_gameobject_ptr'](objects[i]); t['delete'](); } - var b = _emscripten_get_now(); + var b = emscripten_get_now(); for(i = 0; i < N; ++i) { objects[i]['delete'](); @@ -229,9 +229,9 @@ addToLibrary({ call0: function() { } }); - var start = _emscripten_get_now(); + var start = emscripten_get_now(); Module['callInterface0'](N, obj); - var elapsed = _emscripten_get_now() - start; + var elapsed = emscripten_get_now() - start; out("C++ -> JS void through interface " + N + " iters: " + elapsed + " msecs."); obj.delete(); }, @@ -243,9 +243,9 @@ addToLibrary({ return s1 + s2; } }); - var start = _emscripten_get_now(); + var start = emscripten_get_now(); Module['callInterface1'](N, obj); - var elapsed = _emscripten_get_now() - start; + var elapsed = emscripten_get_now() - start; out("C++ -> JS std::wstring through interface " + N + " iters: " + elapsed + " msecs."); obj.delete(); }, @@ -262,14 +262,14 @@ addToLibrary({ }, }); - var start = _emscripten_get_now(); + var start = emscripten_get_now(); Module['callInterface2'](N, obj); - var elapsed = _emscripten_get_now() - start; + var elapsed = emscripten_get_now() - start; out("C++ -> JS typed array instantiation " + N + " iters: " + elapsed + " msecs."); - var start = _emscripten_get_now(); + var start = emscripten_get_now(); Module['callInterface3'](N, obj); - var elapsed = _emscripten_get_now() - start; + var elapsed = emscripten_get_now() - start; out("C++ -> JS memory_view instantiation" + N + " iters: " + elapsed + " msecs."); obj.delete(); }, @@ -277,11 +277,11 @@ addToLibrary({ returns_val_benchmark: function() { var N = 1000000; var v = 1; - var start = _emscripten_get_now(); + var start = emscripten_get_now(); for(var i = 0; i < N; ++i) { v = Module['returns_val'](v); } - var elapsed = _emscripten_get_now() - start; + var elapsed = emscripten_get_now() - start; out("returns_val " + N + " iters: " + elapsed + " msecs"); }, diff --git a/test/embind/test_unsigned.cpp b/test/embind/test_unsigned.cpp index edf52fc0121c0..b25f3279fb8a4 100644 --- a/test/embind/test_unsigned.cpp +++ b/test/embind/test_unsigned.cpp @@ -36,6 +36,6 @@ int main() // Module['set_bind_u64'](2147483648); // todo: embind does not currently support 64-bit integers. Module['set_bind_u32'](2147483648); // Module['_set_c_u64'](2147483648); // todo: embind does not currently support 64-bit integers. - Module['_set_c_u32'](2147483648); + Module['set_c_u32'](2147483648); ); } diff --git a/test/js_optimizer/applyImportAndExportNameChanges-output.js b/test/js_optimizer/applyImportAndExportNameChanges-output.js index 8b13b1981eb49..f6c7f39deec41 100644 --- a/test/js_optimizer/applyImportAndExportNameChanges-output.js +++ b/test/js_optimizer/applyImportAndExportNameChanges-output.js @@ -3,15 +3,15 @@ var name; var wasmImports = { a: 1, A: 33, - b: ___syscall6, - __setErrNo: ___setErrNo, - memset: _memset, - sbrk: _sbrk, - memcpy: _memcpy, - emscripten_memcpy_js: _emscripten_memcpy_js, - c: ___syscall54, - d: ___syscall140, - q: ___syscall146 + b: __syscall6, + __setErrNo: __setErrNo, + memset: memset, + sbrk: sbrk, + memcpy: memcpy, + _emscripten_memcpy_js: _emscripten_memcpy_js, + c: __syscall54, + d: __syscall140, + q: __syscall146 }; var expD1 = Module["expD1"] = wasmExports["c"]; diff --git a/test/js_optimizer/applyImportAndExportNameChanges.js b/test/js_optimizer/applyImportAndExportNameChanges.js index 6ed31351ab3f0..f624a8a54fa8e 100644 --- a/test/js_optimizer/applyImportAndExportNameChanges.js +++ b/test/js_optimizer/applyImportAndExportNameChanges.js @@ -2,15 +2,15 @@ var name; var wasmImports = { save1: 1, number: 33, - __syscall6: ___syscall6, - __setErrNo: ___setErrNo, - memset: _memset, - sbrk: _sbrk, - memcpy: _memcpy, - emscripten_memcpy_js: _emscripten_memcpy_js, - __syscall54: ___syscall54, - __syscall140: ___syscall140, - __syscall146: ___syscall146 + __syscall6: __syscall6, + __setErrNo: __setErrNo, + memset: memset, + sbrk: sbrk, + memcpy: memcpy, + _emscripten_memcpy_js: _emscripten_memcpy_js, + __syscall54: __syscall54, + __syscall140: __syscall140, + __syscall146: __syscall146 }; // exports diff --git a/test/js_optimizer/applyImportAndExportNameChanges2-output.js b/test/js_optimizer/applyImportAndExportNameChanges2-output.js index 5da1dd3362854..f11d9094a57d7 100644 --- a/test/js_optimizer/applyImportAndExportNameChanges2-output.js +++ b/test/js_optimizer/applyImportAndExportNameChanges2-output.js @@ -126,7 +126,7 @@ var SYSCALLS = { } }; -function ___syscall140(which, varargs) { +function __syscall140(which, varargs) { SYSCALLS.varargs = varargs; try { var stream = SYSCALLS.getStreamFromFD(), offset_high = SYSCALLS.get(), offset_low = SYSCALLS.get(), result = SYSCALLS.get(), whence = SYSCALLS.get(); @@ -141,7 +141,7 @@ function ___syscall140(which, varargs) { } } -function ___syscall146(which, varargs) { +function __syscall146(which, varargs) { SYSCALLS.varargs = varargs; try { var stream = SYSCALLS.get(), iov = SYSCALLS.get(), iovcnt = SYSCALLS.get(); @@ -161,7 +161,7 @@ function ___syscall146(which, varargs) { } } -function ___syscall54(which, varargs) { +function __syscall54(which, varargs) { SYSCALLS.varargs = varargs; try { return 0; @@ -171,7 +171,7 @@ function ___syscall54(which, varargs) { } } -function ___syscall6(which, varargs) { +function __syscall6(which, varargs) { SYSCALLS.varargs = varargs; try { var stream = SYSCALLS.getStreamFromFD(); @@ -183,11 +183,11 @@ function ___syscall6(which, varargs) { } } -function _emscripten_get_now() { +function emscripten_get_now() { abort(); } -function _emscripten_random() { +function emscripten_random() { return Math.random(); } @@ -196,35 +196,35 @@ function _emscripten_memcpy_js(dest, src, num) { } if (ENVIRONMENT_IS_NODE) { - _emscripten_get_now = function _emscripten_get_now_actual() { + emscripten_get_now = function emscripten_get_now_actual() { var t = process.hrtime(); return t[0] * 1e3 + t[1] / 1e6; }; } else if (typeof self === "object" && self["performance"] && typeof self["performance"]["now"] === "function") { - _emscripten_get_now = function() { + emscripten_get_now = function() { return self["performance"]["now"](); }; } else if (typeof performance === "object" && typeof performance["now"] === "function") { - _emscripten_get_now = function() { + emscripten_get_now = function() { return performance["now"](); }; } else { - _emscripten_get_now = Date.now; + emscripten_get_now = Date.now; } var wasmImports = { b: abort, - h: ___syscall140, - a: ___syscall146, - g: ___syscall54, - f: ___syscall6, - e: _emscripten_get_now, + h: __syscall140, + a: __syscall146, + g: __syscall54, + f: __syscall6, + e: emscripten_get_now, d: _emscripten_memcpy_js, - c: _emscripten_random + c: emscripten_random }; function run() { - var ret = _main(); + var ret = main(); } function initRuntime(wasmExports) { @@ -262,15 +262,15 @@ var imports = { } }; -var ___errno_location, _llvm_bswap_i32, _main, _memcpy, _memset, dynCall_ii, dynCall_iiii; +var __errno_location, llvm_bswap_i32, main, memcpy, memset, dynCall_ii, dynCall_iiii; WebAssembly.instantiate(Module["wasm"], imports).then(output => { var wasmExports = output.instance.exports; - ___errno_location = wasmExports["j"]; - _llvm_bswap_i32 = wasmExports["k"]; - _main = wasmExports["l"]; - _memcpy = wasmExports["m"]; - _memset = wasmExports["n"]; + __errno_location = wasmExports["j"]; + llvm_bswap_i32 = wasmExports["k"]; + main = wasmExports["l"]; + memcpy = wasmExports["m"]; + memset = wasmExports["n"]; dynCall_ii = wasmExports["o"]; dynCall_iiii = wasmExports["p"]; initRuntime(wasmExports); diff --git a/test/js_optimizer/applyImportAndExportNameChanges2.js b/test/js_optimizer/applyImportAndExportNameChanges2.js index 1900946eabfaf..f8d7ef0057c2b 100644 --- a/test/js_optimizer/applyImportAndExportNameChanges2.js +++ b/test/js_optimizer/applyImportAndExportNameChanges2.js @@ -113,7 +113,7 @@ var SYSCALLS = { }) }; -function ___syscall140(which, varargs) { +function __syscall140(which, varargs) { SYSCALLS.varargs = varargs; try { var stream = SYSCALLS.getStreamFromFD(), @@ -132,7 +132,7 @@ function ___syscall140(which, varargs) { } } -function ___syscall146(which, varargs) { +function __syscall146(which, varargs) { SYSCALLS.varargs = varargs; try { var stream = SYSCALLS.get(), @@ -154,7 +154,7 @@ function ___syscall146(which, varargs) { } } -function ___syscall54(which, varargs) { +function __syscall54(which, varargs) { SYSCALLS.varargs = varargs; try { return 0 @@ -164,7 +164,7 @@ function ___syscall54(which, varargs) { } } -function ___syscall6(which, varargs) { +function __syscall6(which, varargs) { SYSCALLS.varargs = varargs; try { var stream = SYSCALLS.getStreamFromFD(); @@ -176,11 +176,11 @@ function ___syscall6(which, varargs) { } } -function _emscripten_get_now() { +function emscripten_get_now() { abort() } -function _emscripten_random() { +function emscripten_random() { return Math.random() } @@ -188,34 +188,34 @@ function _emscripten_memcpy_js(dest, src, num) { HEAPU8.set(HEAPU8.subarray(src, src + num), dest) } if (ENVIRONMENT_IS_NODE) { - _emscripten_get_now = function _emscripten_get_now_actual() { + emscripten_get_now = function emscripten_get_now_actual() { var t = process.hrtime(); return t[0] * 1e3 + t[1] / 1e6 } } else if (typeof self === "object" && self["performance"] && typeof self["performance"]["now"] === "function") { - _emscripten_get_now = (function() { + emscripten_get_now = (function() { return self["performance"]["now"]() }) } else if (typeof performance === "object" && typeof performance["now"] === "function") { - _emscripten_get_now = (function() { + emscripten_get_now = (function() { return performance["now"]() }) } else { - _emscripten_get_now = Date.now + emscripten_get_now = Date.now } var wasmImports = { abort: abort, - ___syscall140: ___syscall140, - ___syscall146: ___syscall146, - ___syscall54: ___syscall54, - ___syscall6: ___syscall6, - _emscripten_get_now: _emscripten_get_now, + __syscall140: __syscall140, + __syscall146: __syscall146, + __syscall54: __syscall54, + __syscall6: __syscall6, + emscripten_get_now: emscripten_get_now, _emscripten_memcpy_js: _emscripten_memcpy_js, - _emscripten_random: _emscripten_random + emscripten_random: emscripten_random }; function run() { - var ret = _main() + var ret = main() } function initRuntime(wasmExports) { @@ -246,14 +246,14 @@ var imports = { }) } }; -var ___errno_location, _llvm_bswap_i32, _main, _memcpy, _memset, dynCall_ii, dynCall_iiii; +var __errno_location, llvm_bswap_i32, main, memcpy, memset, dynCall_ii, dynCall_iiii; WebAssembly.instantiate(Module["wasm"], imports).then(((output) => { var wasmExports = output.instance.exports; - ___errno_location = wasmExports["___errno_location"]; - _llvm_bswap_i32 = wasmExports["_llvm_bswap_i32"]; - _main = wasmExports["_main"]; - _memcpy = wasmExports["_memcpy"]; - _memset = wasmExports["_memset"]; + __errno_location = wasmExports["__errno_location"]; + llvm_bswap_i32 = wasmExports["llvm_bswap_i32"]; + main = wasmExports["main"]; + memcpy = wasmExports["memcpy"]; + memset = wasmExports["memset"]; dynCall_ii = wasmExports["dynCall_ii"]; dynCall_iiii = wasmExports["dynCall_iiii"]; initRuntime(wasmExports); @@ -262,4 +262,4 @@ WebAssembly.instantiate(Module["wasm"], imports).then(((output) => { -// EXTRA_INFO: {"mapping": {"_llvm_bswap_i32": "k", "_emscripten_random": "c", "dynCall_ii": "o", "__GLOBAL__sub_I_test_global_initializer_cpp": "i", "___errno_location": "j", "dynCall_iiii": "p", "___syscall6": "f", "_memset": "n", "_memcpy": "m", "abort": "b", "___syscall146": "a", "_emscripten_memcpy_js": "d", "___syscall54": "g", "___syscall140": "h", "_emscripten_get_now": "e", "_main": "l"}} +// EXTRA_INFO: {"mapping": {"llvm_bswap_i32": "k", "emscripten_random": "c", "dynCall_ii": "o", "__GLOBAL__sub_I_test_global_initializer_cpp": "i", "__errno_location": "j", "dynCall_iiii": "p", "__syscall6": "f", "memset": "n", "memcpy": "m", "abort": "b", "__syscall146": "a", "_emscripten_memcpy_js": "d", "__syscall54": "g", "__syscall140": "h", "emscripten_get_now": "e", "main": "l"}} diff --git a/test/minimal_webgl/library_js.js b/test/minimal_webgl/library_js.js index b546b99d6f298..2cd8a7fcc5cd1 100644 --- a/test/minimal_webgl/library_js.js +++ b/test/minimal_webgl/library_js.js @@ -26,7 +26,7 @@ addToLibrary({ ctx.strokeText(String.fromCharCode(unicodeChar), 0, canvas.height-7); } ctx.fillText(String.fromCharCode(unicodeChar), 0, canvas.height-7); - _uploadFlipped(canvas); + uploadFlipped(canvas); }, load_texture_from_url__deps: ['uploadFlipped'], load_texture_from_url: function(glTexture, url, outW, outH) { @@ -35,7 +35,7 @@ addToLibrary({ HEAPU32[outW>>2] = img.width; HEAPU32[outH>>2] = img.height; GLctx.bindTexture(0xDE1/*GLctx.TEXTURE_2D*/, GL.textures[glTexture]); - _uploadFlipped(img); + uploadFlipped(img); }; img.src = UTF8ToString(url); } diff --git a/test/module_exports/main.js b/test/module_exports/main.js index 5741f1d91d2c9..de833ff9caa02 100644 --- a/test/module_exports/main.js +++ b/test/module_exports/main.js @@ -8,7 +8,7 @@ var Module = require("./test.js"); console.log("\nTesting main.js"); var length = 20; -var ptr = Module._malloc(length); // Get buffer from emscripten. +var ptr = Module.malloc(length); // Get buffer from emscripten. var buffer= new Uint8Array(Module.HEAPU8.buffer, ptr, length); // Get a bytes view on the newly allocated buffer. // Populate the buffer in JavaScript land. @@ -27,4 +27,4 @@ bufferTest(ptr, length); // Call our exported C function to prove the buffer was console.log("\nbufferTest finished\n"); // free the heap buffer -Module._free(ptr); +Module.free(ptr); diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 70461f8a6e739..6d7b12e1212e6 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8450 +8559 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index cfe33a90d39b5..e1b3454b67f39 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20797 +21276 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index 3a402b492b0d7..8154d5a9ff1cb 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8436 +8552 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index f9b02e898e2f7..0c265eda97ec2 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20765 +21243 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 7eee896173205..4c2ef996f501d 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9477 +9607 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 790b94dcc58e4..16a8d8f4db149 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24640 +25450 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index 6536dd0d80ddf..ac1b3392a65c4 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8419 +8496 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index bd029fefbea94..675d8ae072864 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20691 +20993 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 6536dd0d80ddf..ac1b3392a65c4 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 @@ -8419 +8496 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 bd029fefbea94..675d8ae072864 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 @@ -20691 +20993 diff --git a/test/other/codesize/test_codesize_cxx_lto.exports b/test/other/codesize/test_codesize_cxx_lto.exports index bdd4fd36c8b21..11a010d224484 100644 --- a/test/other/codesize/test_codesize_cxx_lto.exports +++ b/test/other/codesize/test_codesize_cxx_lto.exports @@ -2,4 +2,8 @@ m (memory) n (__wasm_call_ctors) o (main) p (_emscripten_timeout) -q (__indirect_function_table) +q (_emscripten_stack_restore) +r (_emscripten_stack_alloc) +s (emscripten_stack_get_current) +t (__cxa_increment_exception_refcount) +u (__indirect_function_table) diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index c24db41a3eb53..86bfcc5a26337 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8349 +8522 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 6e2cb31607353..d4c1ca1b4e2aa 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20376 +20906 diff --git a/test/other/codesize/test_codesize_cxx_lto.size b/test/other/codesize/test_codesize_cxx_lto.size index 4a07ebe525783..33a5bba3c2ed7 100644 --- a/test/other/codesize/test_codesize_cxx_lto.size +++ b/test/other/codesize/test_codesize_cxx_lto.size @@ -1 +1 @@ -122474 +122548 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index a434caefa3d33..7c702c2a0243a 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9480 +9641 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 790b94dcc58e4..99b19590912f2 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24640 +25564 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 70461f8a6e739..6d7b12e1212e6 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8450 +8559 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index cfe33a90d39b5..e1b3454b67f39 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20797 +21276 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize index 4a45c385de208..721b0f7df1122 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize @@ -1 +1 @@ -3895 +4001 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.jssize b/test/other/codesize/test_codesize_cxx_wasmfs.jssize index 4a63574e4a00e..cf3f777f2521e 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.jssize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.jssize @@ -1 +1 @@ -8691 +9170 diff --git a/test/other/codesize/test_codesize_files_js_fs.exports b/test/other/codesize/test_codesize_files_js_fs.exports index 72c90266f84cf..ab0c506f8eaa7 100644 --- a/test/other/codesize/test_codesize_files_js_fs.exports +++ b/test/other/codesize/test_codesize_files_js_fs.exports @@ -2,3 +2,6 @@ e (memory) f (__wasm_call_ctors) g (main) h (__indirect_function_table) +i (_emscripten_stack_restore) +j (_emscripten_stack_alloc) +k (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_files_js_fs.funcs b/test/other/codesize/test_codesize_files_js_fs.funcs index d58afb638ae74..205b9c5965ea5 100644 --- a/test/other/codesize/test_codesize_files_js_fs.funcs +++ b/test/other/codesize/test_codesize_files_js_fs.funcs @@ -1,2 +1,5 @@ $__wasm_call_ctors +$_emscripten_stack_alloc +$_emscripten_stack_restore +$emscripten_stack_get_current $main diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index 594e0a236d3a5..3eb330568eb87 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7584 +7704 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index 6689ea31bd688..742c85da3b4dc 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18694 +19092 diff --git a/test/other/codesize/test_codesize_files_js_fs.size b/test/other/codesize/test_codesize_files_js_fs.size index 6bb2f4ee89f3f..54bb288154715 100644 --- a/test/other/codesize/test_codesize_files_js_fs.size +++ b/test/other/codesize/test_codesize_files_js_fs.size @@ -1 +1 @@ -389 +441 diff --git a/test/other/codesize/test_codesize_files_wasmfs.exports b/test/other/codesize/test_codesize_files_wasmfs.exports index 1b3d6ede9e560..9696955da8d36 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.exports +++ b/test/other/codesize/test_codesize_files_wasmfs.exports @@ -2,3 +2,6 @@ q (memory) r (__wasm_call_ctors) s (main) t (__indirect_function_table) +u (_emscripten_stack_restore) +v (_emscripten_stack_alloc) +w (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_files_wasmfs.funcs b/test/other/codesize/test_codesize_files_wasmfs.funcs index c13be46f97079..44ff9361d1987 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.funcs +++ b/test/other/codesize/test_codesize_files_wasmfs.funcs @@ -28,12 +28,15 @@ $__pthread_mutex_lock $__throw_bad_alloc_shim\28\29 $__unlockfile $__wasm_call_ctors +$_emscripten_stack_alloc +$_emscripten_stack_restore $abort $char*\20std::__2::copy_n\5babi:nn180100\5d\28char\20const*\2c\20unsigned\20long\2c\20char*\29 $decltype\28auto\29\20std::__2::__variant_detail::__visitation::__base::__dispatcher<0ul>::__dispatch\5babi:nn180100\5d>\2c\20int>\2c\20\28std::__2::__variant_detail::_Trait\291>::__destroy\5babi:nn180100\5d\28\29::'lambda'\28auto&\29&&\2c\20std::__2::__variant_detail::__base<\28std::__2::__variant_detail::_Trait\291\2c\20std::__2::vector>\2c\20int>&>\28auto\2c\20std::__2::__variant_detail::__base<\28std::__2::__variant_detail::_Trait\291\2c\20std::__2::vector>\2c\20int>&\29 $decltype\28auto\29\20std::__2::__variant_detail::__visitation::__base::__dispatcher<1ul>::__dispatch\5babi:nn180100\5d>\2c\20\28std::__2::__variant_detail::_Trait\291>::__destroy\5babi:nn180100\5d\28\29::'lambda'\28auto&\29&&\2c\20std::__2::__variant_detail::__base<\28std::__2::__variant_detail::_Trait\291\2c\20long\2c\20std::__2::shared_ptr>&>\28auto\2c\20std::__2::__variant_detail::__base<\28std::__2::__variant_detail::_Trait\291\2c\20long\2c\20std::__2::shared_ptr>&\29 $dummy $emscripten_builtin_malloc +$emscripten_stack_get_current $fflush $is_equal\28std::type_info\20const*\2c\20std::type_info\20const*\2c\20bool\29 $main diff --git a/test/other/codesize/test_codesize_files_wasmfs.gzsize b/test/other/codesize/test_codesize_files_wasmfs.gzsize index 02089ff0b983b..ea0965b43e18b 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_files_wasmfs.gzsize @@ -1 +1 @@ -2989 +3120 diff --git a/test/other/codesize/test_codesize_files_wasmfs.jssize b/test/other/codesize/test_codesize_files_wasmfs.jssize index d928f1e433d22..55f2572634b03 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.jssize +++ b/test/other/codesize/test_codesize_files_wasmfs.jssize @@ -1 +1 @@ -6327 +6742 diff --git a/test/other/codesize/test_codesize_files_wasmfs.size b/test/other/codesize/test_codesize_files_wasmfs.size index 8dbc1b508195f..556b3478d14e4 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.size +++ b/test/other/codesize/test_codesize_files_wasmfs.size @@ -1 +1 @@ -51157 +51204 diff --git a/test/other/codesize/test_codesize_hello_O0.gzsize b/test/other/codesize/test_codesize_hello_O0.gzsize index 21424ac54ff74..2e4fc5a4d89dc 100644 --- a/test/other/codesize/test_codesize_hello_O0.gzsize +++ b/test/other/codesize/test_codesize_hello_O0.gzsize @@ -1 +1 @@ -8040 +8246 diff --git a/test/other/codesize/test_codesize_hello_O0.jssize b/test/other/codesize/test_codesize_hello_O0.jssize index 9e6f15369d6f3..85a1bae531ea9 100644 --- a/test/other/codesize/test_codesize_hello_O0.jssize +++ b/test/other/codesize/test_codesize_hello_O0.jssize @@ -1 +1 @@ -21408 +22345 diff --git a/test/other/codesize/test_codesize_hello_O1.gzsize b/test/other/codesize/test_codesize_hello_O1.gzsize index c1fe14e0295ce..5058bd1fa6c9b 100644 --- a/test/other/codesize/test_codesize_hello_O1.gzsize +++ b/test/other/codesize/test_codesize_hello_O1.gzsize @@ -1 +1 @@ -2818 +2961 diff --git a/test/other/codesize/test_codesize_hello_O1.jssize b/test/other/codesize/test_codesize_hello_O1.jssize index 331d936bc2012..c60c349c22f0d 100644 --- a/test/other/codesize/test_codesize_hello_O1.jssize +++ b/test/other/codesize/test_codesize_hello_O1.jssize @@ -1 +1 @@ -7025 +7587 diff --git a/test/other/codesize/test_codesize_hello_O2.gzsize b/test/other/codesize/test_codesize_hello_O2.gzsize index ff7f50a6d7109..4b430fcbd1409 100644 --- a/test/other/codesize/test_codesize_hello_O2.gzsize +++ b/test/other/codesize/test_codesize_hello_O2.gzsize @@ -1 +1 @@ -2498 +2613 diff --git a/test/other/codesize/test_codesize_hello_O2.jssize b/test/other/codesize/test_codesize_hello_O2.jssize index f61405c38790b..a1c32bfa8313c 100644 --- a/test/other/codesize/test_codesize_hello_O2.jssize +++ b/test/other/codesize/test_codesize_hello_O2.jssize @@ -1 +1 @@ -5036 +5529 diff --git a/test/other/codesize/test_codesize_hello_O3.exports b/test/other/codesize/test_codesize_hello_O3.exports index 99502013435fa..c9e74010f99b0 100644 --- a/test/other/codesize/test_codesize_hello_O3.exports +++ b/test/other/codesize/test_codesize_hello_O3.exports @@ -2,3 +2,6 @@ c (memory) d (__wasm_call_ctors) e (main) f (__indirect_function_table) +g (_emscripten_stack_restore) +h (_emscripten_stack_alloc) +i (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_hello_O3.funcs b/test/other/codesize/test_codesize_hello_O3.funcs index 341b1f7f10988..6c8b46c9d3b11 100644 --- a/test/other/codesize/test_codesize_hello_O3.funcs +++ b/test/other/codesize/test_codesize_hello_O3.funcs @@ -4,4 +4,7 @@ $__fwritex $__stdio_write $__towrite $__wasm_call_ctors +$_emscripten_stack_alloc +$_emscripten_stack_restore +$emscripten_stack_get_current $main diff --git a/test/other/codesize/test_codesize_hello_O3.gzsize b/test/other/codesize/test_codesize_hello_O3.gzsize index 94c0c0eb6b8d3..1232cc3bd2c42 100644 --- a/test/other/codesize/test_codesize_hello_O3.gzsize +++ b/test/other/codesize/test_codesize_hello_O3.gzsize @@ -1 +1 @@ -2418 +2538 diff --git a/test/other/codesize/test_codesize_hello_O3.jssize b/test/other/codesize/test_codesize_hello_O3.jssize index 2fe2a2bc84df4..82758ce061e87 100644 --- a/test/other/codesize/test_codesize_hello_O3.jssize +++ b/test/other/codesize/test_codesize_hello_O3.jssize @@ -1 +1 @@ -4882 +5289 diff --git a/test/other/codesize/test_codesize_hello_O3.size b/test/other/codesize/test_codesize_hello_O3.size index 173a6680f8970..9bbb4748627a3 100644 --- a/test/other/codesize/test_codesize_hello_O3.size +++ b/test/other/codesize/test_codesize_hello_O3.size @@ -1 +1 @@ -1737 +1785 diff --git a/test/other/codesize/test_codesize_hello_Os.exports b/test/other/codesize/test_codesize_hello_Os.exports index 99502013435fa..c9e74010f99b0 100644 --- a/test/other/codesize/test_codesize_hello_Os.exports +++ b/test/other/codesize/test_codesize_hello_Os.exports @@ -2,3 +2,6 @@ c (memory) d (__wasm_call_ctors) e (main) f (__indirect_function_table) +g (_emscripten_stack_restore) +h (_emscripten_stack_alloc) +i (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_hello_Os.funcs b/test/other/codesize/test_codesize_hello_Os.funcs index 6840fa3f66bd8..2206a46aa8d98 100644 --- a/test/other/codesize/test_codesize_hello_Os.funcs +++ b/test/other/codesize/test_codesize_hello_Os.funcs @@ -5,4 +5,7 @@ $__stdio_write $__towrite $__wasi_syscall_ret $__wasm_call_ctors +$_emscripten_stack_alloc +$_emscripten_stack_restore +$emscripten_stack_get_current $main diff --git a/test/other/codesize/test_codesize_hello_Os.gzsize b/test/other/codesize/test_codesize_hello_Os.gzsize index 94c0c0eb6b8d3..1232cc3bd2c42 100644 --- a/test/other/codesize/test_codesize_hello_Os.gzsize +++ b/test/other/codesize/test_codesize_hello_Os.gzsize @@ -1 +1 @@ -2418 +2538 diff --git a/test/other/codesize/test_codesize_hello_Os.jssize b/test/other/codesize/test_codesize_hello_Os.jssize index 2fe2a2bc84df4..82758ce061e87 100644 --- a/test/other/codesize/test_codesize_hello_Os.jssize +++ b/test/other/codesize/test_codesize_hello_Os.jssize @@ -1 +1 @@ -4882 +5289 diff --git a/test/other/codesize/test_codesize_hello_Os.size b/test/other/codesize/test_codesize_hello_Os.size index 54c9fc81b32d0..33e82b72271ac 100644 --- a/test/other/codesize/test_codesize_hello_Os.size +++ b/test/other/codesize/test_codesize_hello_Os.size @@ -1 +1 @@ -1728 +1776 diff --git a/test/other/codesize/test_codesize_hello_Oz.exports b/test/other/codesize/test_codesize_hello_Oz.exports index a88ed67232916..33ec86c5453a3 100644 --- a/test/other/codesize/test_codesize_hello_Oz.exports +++ b/test/other/codesize/test_codesize_hello_Oz.exports @@ -2,3 +2,6 @@ b (memory) c (__wasm_call_ctors) d (main) e (__indirect_function_table) +f (_emscripten_stack_restore) +g (_emscripten_stack_alloc) +h (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_hello_Oz.funcs b/test/other/codesize/test_codesize_hello_Oz.funcs index 6840fa3f66bd8..2206a46aa8d98 100644 --- a/test/other/codesize/test_codesize_hello_Oz.funcs +++ b/test/other/codesize/test_codesize_hello_Oz.funcs @@ -5,4 +5,7 @@ $__stdio_write $__towrite $__wasi_syscall_ret $__wasm_call_ctors +$_emscripten_stack_alloc +$_emscripten_stack_restore +$emscripten_stack_get_current $main diff --git a/test/other/codesize/test_codesize_hello_Oz.gzsize b/test/other/codesize/test_codesize_hello_Oz.gzsize index 2f097f031198d..29a73575702ea 100644 --- a/test/other/codesize/test_codesize_hello_Oz.gzsize +++ b/test/other/codesize/test_codesize_hello_Oz.gzsize @@ -1 +1 @@ -2397 +2524 diff --git a/test/other/codesize/test_codesize_hello_Oz.jssize b/test/other/codesize/test_codesize_hello_Oz.jssize index c8db55238c8e5..d57d96f601aca 100644 --- a/test/other/codesize/test_codesize_hello_Oz.jssize +++ b/test/other/codesize/test_codesize_hello_Oz.jssize @@ -1 +1 @@ -4849 +5256 diff --git a/test/other/codesize/test_codesize_hello_Oz.size b/test/other/codesize/test_codesize_hello_Oz.size index b151ec96e078d..b9e1221b537cc 100644 --- a/test/other/codesize/test_codesize_hello_Oz.size +++ b/test/other/codesize/test_codesize_hello_Oz.size @@ -1 +1 @@ -1286 +1334 diff --git a/test/other/codesize/test_codesize_hello_dylink.gzsize b/test/other/codesize/test_codesize_hello_dylink.gzsize index 97efd5dbc5030..84f6f618568b1 100644 --- a/test/other/codesize/test_codesize_hello_dylink.gzsize +++ b/test/other/codesize/test_codesize_hello_dylink.gzsize @@ -1 +1 @@ -6339 +6439 diff --git a/test/other/codesize/test_codesize_hello_dylink.jssize b/test/other/codesize/test_codesize_hello_dylink.jssize index 9195b2fc9c83d..5bdfc2df6faa7 100644 --- a/test/other/codesize/test_codesize_hello_dylink.jssize +++ b/test/other/codesize/test_codesize_hello_dylink.jssize @@ -1 +1 @@ -13936 +14451 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.exports b/test/other/codesize/test_codesize_hello_export_nothing.exports index 289268e7fa628..c9e74010f99b0 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.exports +++ b/test/other/codesize/test_codesize_hello_export_nothing.exports @@ -1,3 +1,7 @@ -a (memory) -b (__wasm_call_ctors) -c (__indirect_function_table) +c (memory) +d (__wasm_call_ctors) +e (main) +f (__indirect_function_table) +g (_emscripten_stack_restore) +h (_emscripten_stack_alloc) +i (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_hello_export_nothing.funcs b/test/other/codesize/test_codesize_hello_export_nothing.funcs index 1fe1814e56896..2206a46aa8d98 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.funcs +++ b/test/other/codesize/test_codesize_hello_export_nothing.funcs @@ -1 +1,11 @@ +$__emscripten_stdout_close +$__emscripten_stdout_seek +$__fwritex +$__stdio_write +$__towrite +$__wasi_syscall_ret $__wasm_call_ctors +$_emscripten_stack_alloc +$_emscripten_stack_restore +$emscripten_stack_get_current +$main diff --git a/test/other/codesize/test_codesize_hello_export_nothing.gzsize b/test/other/codesize/test_codesize_hello_export_nothing.gzsize index 1351198febbf9..1232cc3bd2c42 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.gzsize +++ b/test/other/codesize/test_codesize_hello_export_nothing.gzsize @@ -1 +1 @@ -1762 +2538 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.imports b/test/other/codesize/test_codesize_hello_export_nothing.imports index 8b137891791fe..747be6c703000 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.imports +++ b/test/other/codesize/test_codesize_hello_export_nothing.imports @@ -1 +1,2 @@ - +a (fd_write) +b (_emscripten_memcpy_js) diff --git a/test/other/codesize/test_codesize_hello_export_nothing.jssize b/test/other/codesize/test_codesize_hello_export_nothing.jssize index 3dc49aa04aae0..82758ce061e87 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.jssize +++ b/test/other/codesize/test_codesize_hello_export_nothing.jssize @@ -1 +1 @@ -3733 +5289 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.sent b/test/other/codesize/test_codesize_hello_export_nothing.sent index 8b137891791fe..747be6c703000 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.sent +++ b/test/other/codesize/test_codesize_hello_export_nothing.sent @@ -1 +1,2 @@ - +a (fd_write) +b (_emscripten_memcpy_js) diff --git a/test/other/codesize/test_codesize_hello_export_nothing.size b/test/other/codesize/test_codesize_hello_export_nothing.size index fb1e7bc86996a..33e82b72271ac 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.size +++ b/test/other/codesize/test_codesize_hello_export_nothing.size @@ -1 +1 @@ -54 +1776 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.exports b/test/other/codesize/test_codesize_hello_wasmfs.exports index 99502013435fa..c9e74010f99b0 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.exports +++ b/test/other/codesize/test_codesize_hello_wasmfs.exports @@ -2,3 +2,6 @@ c (memory) d (__wasm_call_ctors) e (main) f (__indirect_function_table) +g (_emscripten_stack_restore) +h (_emscripten_stack_alloc) +i (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_hello_wasmfs.funcs b/test/other/codesize/test_codesize_hello_wasmfs.funcs index 341b1f7f10988..6c8b46c9d3b11 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.funcs +++ b/test/other/codesize/test_codesize_hello_wasmfs.funcs @@ -4,4 +4,7 @@ $__fwritex $__stdio_write $__towrite $__wasm_call_ctors +$_emscripten_stack_alloc +$_emscripten_stack_restore +$emscripten_stack_get_current $main diff --git a/test/other/codesize/test_codesize_hello_wasmfs.gzsize b/test/other/codesize/test_codesize_hello_wasmfs.gzsize index 94c0c0eb6b8d3..1232cc3bd2c42 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_hello_wasmfs.gzsize @@ -1 +1 @@ -2418 +2538 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.jssize b/test/other/codesize/test_codesize_hello_wasmfs.jssize index 2fe2a2bc84df4..82758ce061e87 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.jssize +++ b/test/other/codesize/test_codesize_hello_wasmfs.jssize @@ -1 +1 @@ -4882 +5289 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.size b/test/other/codesize/test_codesize_hello_wasmfs.size index 173a6680f8970..9bbb4748627a3 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.size +++ b/test/other/codesize/test_codesize_hello_wasmfs.size @@ -1 +1 @@ -1737 +1785 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.exports b/test/other/codesize/test_codesize_libcxxabi_message_O3.exports index 9b4a5741d1ead..a6b0ed7e4c7f3 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.exports +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.exports @@ -2,3 +2,6 @@ a (memory) b (__wasm_call_ctors) c (main) d (__indirect_function_table) +e (_emscripten_stack_restore) +f (_emscripten_stack_alloc) +g (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.funcs b/test/other/codesize/test_codesize_libcxxabi_message_O3.funcs index d58afb638ae74..205b9c5965ea5 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.funcs +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.funcs @@ -1,2 +1,5 @@ $__wasm_call_ctors +$_emscripten_stack_alloc +$_emscripten_stack_restore +$emscripten_stack_get_current $main diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize index 22c92a24f4a53..9644fad8371dc 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize @@ -1 +1 @@ -1971 +2108 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize index a6813d6cb29fd..b193f399e245f 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize @@ -1 +1 @@ -4110 +4516 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.size b/test/other/codesize/test_codesize_libcxxabi_message_O3.size index c17e934b51c1f..4e9bdff0c6937 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.size +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.size @@ -1 +1 @@ -97 +164 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.exports b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.exports index 92d336c44efa9..305e7e85f5052 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.exports +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.exports @@ -1,3 +1,5 @@ __indirect_function_table +_emscripten_stack_restore _start +emscripten_stack_get_current memory diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.funcs b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.funcs index 86fd2dc1446bb..1525e0fcb99ec 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.funcs +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.funcs @@ -1,2 +1,4 @@ $__wasm_call_ctors +$_emscripten_stack_restore $_start +$emscripten_stack_get_current 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..deecdcd483c35 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 +2111 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..f60a0d5932730 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 +4494 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.size b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.size index eec49411b8413..10b0c0dbc8878 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.size +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.size @@ -1 +1 @@ -177 +264 diff --git a/test/other/codesize/test_codesize_mem_O3.exports b/test/other/codesize/test_codesize_mem_O3.exports index e4da374988186..0d3303e41e676 100644 --- a/test/other/codesize/test_codesize_mem_O3.exports +++ b/test/other/codesize/test_codesize_mem_O3.exports @@ -2,4 +2,6 @@ b (memory) c (__wasm_call_ctors) d (__main_argc_argv) e (__indirect_function_table) -f (_emscripten_stack_alloc) +f (_emscripten_stack_restore) +g (_emscripten_stack_alloc) +h (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_mem_O3.funcs b/test/other/codesize/test_codesize_mem_O3.funcs index e9c1f0cd2f18b..9fb12c64e1841 100644 --- a/test/other/codesize/test_codesize_mem_O3.funcs +++ b/test/other/codesize/test_codesize_mem_O3.funcs @@ -1,4 +1,6 @@ $__wasm_call_ctors $_emscripten_stack_alloc +$_emscripten_stack_restore +$emscripten_stack_get_current $main $sbrk diff --git a/test/other/codesize/test_codesize_mem_O3.gzsize b/test/other/codesize/test_codesize_mem_O3.gzsize index 51d5790fa9f86..b04af7c81b6a4 100644 --- a/test/other/codesize/test_codesize_mem_O3.gzsize +++ b/test/other/codesize/test_codesize_mem_O3.gzsize @@ -1 +1 @@ -2434 +2566 diff --git a/test/other/codesize/test_codesize_mem_O3.jssize b/test/other/codesize/test_codesize_mem_O3.jssize index 19320f4b34e76..34b60f7f7d26e 100644 --- a/test/other/codesize/test_codesize_mem_O3.jssize +++ b/test/other/codesize/test_codesize_mem_O3.jssize @@ -1 +1 @@ -5024 +5451 diff --git a/test/other/codesize/test_codesize_mem_O3.size b/test/other/codesize/test_codesize_mem_O3.size index 2c9122f5b758b..623a8cd4ce9a5 100644 --- a/test/other/codesize/test_codesize_mem_O3.size +++ b/test/other/codesize/test_codesize_mem_O3.size @@ -1 +1 @@ -5288 +5318 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.exports b/test/other/codesize/test_codesize_mem_O3_grow.exports index e4da374988186..0d3303e41e676 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.exports +++ b/test/other/codesize/test_codesize_mem_O3_grow.exports @@ -2,4 +2,6 @@ b (memory) c (__wasm_call_ctors) d (__main_argc_argv) e (__indirect_function_table) -f (_emscripten_stack_alloc) +f (_emscripten_stack_restore) +g (_emscripten_stack_alloc) +h (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_mem_O3_grow.funcs b/test/other/codesize/test_codesize_mem_O3_grow.funcs index e9c1f0cd2f18b..9fb12c64e1841 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.funcs +++ b/test/other/codesize/test_codesize_mem_O3_grow.funcs @@ -1,4 +1,6 @@ $__wasm_call_ctors $_emscripten_stack_alloc +$_emscripten_stack_restore +$emscripten_stack_get_current $main $sbrk diff --git a/test/other/codesize/test_codesize_mem_O3_grow.gzsize b/test/other/codesize/test_codesize_mem_O3_grow.gzsize index f5f09cbbb8f59..8361266fd249f 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow.gzsize @@ -1 +1 @@ -2578 +2710 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.jssize b/test/other/codesize/test_codesize_mem_O3_grow.jssize index 59a265c26452e..f98cf06b14d6e 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow.jssize @@ -1 +1 @@ -5306 +5732 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.size b/test/other/codesize/test_codesize_mem_O3_grow.size index 82758ce061e87..4ab91bdec7345 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.size +++ b/test/other/codesize/test_codesize_mem_O3_grow.size @@ -1 +1 @@ -5289 +5319 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.exports b/test/other/codesize/test_codesize_mem_O3_grow_standalone.exports index 92d336c44efa9..305e7e85f5052 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.exports +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.exports @@ -1,3 +1,5 @@ __indirect_function_table +_emscripten_stack_restore _start +emscripten_stack_get_current memory diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.funcs b/test/other/codesize/test_codesize_mem_O3_grow_standalone.funcs index 8a606d12795d2..910166f70f95f 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.funcs +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.funcs @@ -1,3 +1,5 @@ $__wasm_call_ctors +$_emscripten_stack_restore $_start +$emscripten_stack_get_current $sbrk 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..616d337066df5 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 +2373 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..611e4315f299b 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 +5044 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.size b/test/other/codesize/test_codesize_mem_O3_grow_standalone.size index a0096d7853f16..600eb9a405cfb 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.size +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.size @@ -1 +1 @@ -5612 +5689 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.exports b/test/other/codesize/test_codesize_mem_O3_standalone.exports index 92d336c44efa9..305e7e85f5052 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.exports +++ b/test/other/codesize/test_codesize_mem_O3_standalone.exports @@ -1,3 +1,5 @@ __indirect_function_table +_emscripten_stack_restore _start +emscripten_stack_get_current memory diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.funcs b/test/other/codesize/test_codesize_mem_O3_standalone.funcs index 8a606d12795d2..910166f70f95f 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.funcs +++ b/test/other/codesize/test_codesize_mem_O3_standalone.funcs @@ -1,3 +1,5 @@ $__wasm_call_ctors +$_emscripten_stack_restore $_start +$emscripten_stack_get_current $sbrk diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize index f80488fd5ce7c..c4fdb9ba8959b 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize @@ -1 +1 @@ -2242 +2346 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_standalone.jssize index 4fbccb1a0a505..6a59641459b58 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.jssize @@ -1 +1 @@ -4643 +4974 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.size b/test/other/codesize/test_codesize_mem_O3_standalone.size index b7b57d282909f..0435b54f97ed3 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.size +++ b/test/other/codesize/test_codesize_mem_O3_standalone.size @@ -1 +1 @@ -5537 +5614 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.exports b/test/other/codesize/test_codesize_mem_O3_standalone_lib.exports index f6bd3d591ceba..9fb73637bee9a 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.exports +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.exports @@ -1,4 +1,6 @@ __indirect_function_table +_emscripten_stack_restore _initialize +emscripten_stack_get_current foo memory diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.funcs b/test/other/codesize/test_codesize_mem_O3_standalone_lib.funcs index 109453df798f0..8cf1d36a04b02 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.funcs +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.funcs @@ -1,3 +1,5 @@ $__wasm_call_ctors +$_emscripten_stack_restore +$emscripten_stack_get_current $foo $sbrk 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..0590616883e33 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 +2093 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..f60a0d5932730 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 +4494 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.size b/test/other/codesize/test_codesize_mem_O3_standalone_lib.size index 25db995aa2569..1ffc824561994 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.size +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.size @@ -1 +1 @@ -5300 +5377 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.exports b/test/other/codesize/test_codesize_mem_O3_standalone_narg.exports index 92d336c44efa9..305e7e85f5052 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.exports +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.exports @@ -1,3 +1,5 @@ __indirect_function_table +_emscripten_stack_restore _start +emscripten_stack_get_current memory diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.funcs b/test/other/codesize/test_codesize_mem_O3_standalone_narg.funcs index 8a606d12795d2..910166f70f95f 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.funcs +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.funcs @@ -1,3 +1,5 @@ $__wasm_call_ctors +$_emscripten_stack_restore $_start +$emscripten_stack_get_current $sbrk 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..deecdcd483c35 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 +2111 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..f60a0d5932730 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 +4494 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.size b/test/other/codesize/test_codesize_mem_O3_standalone_narg.size index e650e5aa24adc..c460b4fe4ea60 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.size +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.size @@ -1 +1 @@ -5330 +5407 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.exports b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.exports index 92d336c44efa9..305e7e85f5052 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.exports +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.exports @@ -1,3 +1,5 @@ __indirect_function_table +_emscripten_stack_restore _start +emscripten_stack_get_current memory diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.funcs b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.funcs index 8a606d12795d2..910166f70f95f 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.funcs +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.funcs @@ -1,3 +1,5 @@ $__wasm_call_ctors +$_emscripten_stack_restore $_start +$emscripten_stack_get_current $sbrk 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..deecdcd483c35 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 +2111 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..f60a0d5932730 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 +4494 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.size b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.size index bcfe4e9786b14..a6c9dc98cc2ef 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.size +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.size @@ -1 +1 @@ -4138 +4215 diff --git a/test/other/codesize/test_codesize_minimal_64.exports b/test/other/codesize/test_codesize_minimal_64.exports index cf1318048d1eb..95e9fb1bf4221 100644 --- a/test/other/codesize/test_codesize_minimal_64.exports +++ b/test/other/codesize/test_codesize_minimal_64.exports @@ -2,3 +2,6 @@ a (memory) b (__wasm_call_ctors) c (add) d (__indirect_function_table) +e (_emscripten_stack_restore) +f (_emscripten_stack_alloc) +g (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_minimal_64.funcs b/test/other/codesize/test_codesize_minimal_64.funcs index 08504a53bdb1b..819f7d5bf2b03 100644 --- a/test/other/codesize/test_codesize_minimal_64.funcs +++ b/test/other/codesize/test_codesize_minimal_64.funcs @@ -1,2 +1,5 @@ $__wasm_call_ctors +$_emscripten_stack_alloc +$_emscripten_stack_restore $add +$emscripten_stack_get_current diff --git a/test/other/codesize/test_codesize_minimal_64.gzsize b/test/other/codesize/test_codesize_minimal_64.gzsize index 641d5f59ecacf..f805915bf57ae 100644 --- a/test/other/codesize/test_codesize_minimal_64.gzsize +++ b/test/other/codesize/test_codesize_minimal_64.gzsize @@ -1 +1 @@ -1524 +1571 diff --git a/test/other/codesize/test_codesize_minimal_64.jssize b/test/other/codesize/test_codesize_minimal_64.jssize index 9af21432425ab..0d1a28c617edd 100644 --- a/test/other/codesize/test_codesize_minimal_64.jssize +++ b/test/other/codesize/test_codesize_minimal_64.jssize @@ -1 +1 @@ -3179 +3289 diff --git a/test/other/codesize/test_codesize_minimal_64.size b/test/other/codesize/test_codesize_minimal_64.size index d69c74c8b95c8..dee261df401d4 100644 --- a/test/other/codesize/test_codesize_minimal_64.size +++ b/test/other/codesize/test_codesize_minimal_64.size @@ -1 +1 @@ -73 +140 diff --git a/test/other/codesize/test_codesize_minimal_O0.gzsize b/test/other/codesize/test_codesize_minimal_O0.gzsize index 55f59784d48b1..e0613d3313dbf 100644 --- a/test/other/codesize/test_codesize_minimal_O0.gzsize +++ b/test/other/codesize/test_codesize_minimal_O0.gzsize @@ -1 +1 @@ -6570 +6670 diff --git a/test/other/codesize/test_codesize_minimal_O0.jssize b/test/other/codesize/test_codesize_minimal_O0.jssize index 5ef3302d75df9..c7799d46aedf6 100644 --- a/test/other/codesize/test_codesize_minimal_O0.jssize +++ b/test/other/codesize/test_codesize_minimal_O0.jssize @@ -1 +1 @@ -17544 +18223 diff --git a/test/other/codesize/test_codesize_minimal_O1.gzsize b/test/other/codesize/test_codesize_minimal_O1.gzsize index 4f6811f469b22..0632d50a60923 100644 --- a/test/other/codesize/test_codesize_minimal_O1.gzsize +++ b/test/other/codesize/test_codesize_minimal_O1.gzsize @@ -1 +1 @@ -1597 +1671 diff --git a/test/other/codesize/test_codesize_minimal_O1.jssize b/test/other/codesize/test_codesize_minimal_O1.jssize index 1f6788945a43a..e11a7374b2ca3 100644 --- a/test/other/codesize/test_codesize_minimal_O1.jssize +++ b/test/other/codesize/test_codesize_minimal_O1.jssize @@ -1 +1 @@ -3726 +4098 diff --git a/test/other/codesize/test_codesize_minimal_O2.gzsize b/test/other/codesize/test_codesize_minimal_O2.gzsize index 4b7816b5720e5..4aea0990d7290 100644 --- a/test/other/codesize/test_codesize_minimal_O2.gzsize +++ b/test/other/codesize/test_codesize_minimal_O2.gzsize @@ -1 +1 @@ -1452 +1526 diff --git a/test/other/codesize/test_codesize_minimal_O2.jssize b/test/other/codesize/test_codesize_minimal_O2.jssize index 049730c1f78a4..c3ea6eb1d983a 100644 --- a/test/other/codesize/test_codesize_minimal_O2.jssize +++ b/test/other/codesize/test_codesize_minimal_O2.jssize @@ -1 +1 @@ -2884 +3229 diff --git a/test/other/codesize/test_codesize_minimal_O3.exports b/test/other/codesize/test_codesize_minimal_O3.exports index cf1318048d1eb..95e9fb1bf4221 100644 --- a/test/other/codesize/test_codesize_minimal_O3.exports +++ b/test/other/codesize/test_codesize_minimal_O3.exports @@ -2,3 +2,6 @@ a (memory) b (__wasm_call_ctors) c (add) d (__indirect_function_table) +e (_emscripten_stack_restore) +f (_emscripten_stack_alloc) +g (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_minimal_O3.funcs b/test/other/codesize/test_codesize_minimal_O3.funcs index 08504a53bdb1b..819f7d5bf2b03 100644 --- a/test/other/codesize/test_codesize_minimal_O3.funcs +++ b/test/other/codesize/test_codesize_minimal_O3.funcs @@ -1,2 +1,5 @@ $__wasm_call_ctors +$_emscripten_stack_alloc +$_emscripten_stack_restore $add +$emscripten_stack_get_current diff --git a/test/other/codesize/test_codesize_minimal_O3.gzsize b/test/other/codesize/test_codesize_minimal_O3.gzsize index 06cf2f9c460e0..9d877e1547163 100644 --- a/test/other/codesize/test_codesize_minimal_O3.gzsize +++ b/test/other/codesize/test_codesize_minimal_O3.gzsize @@ -1 +1 @@ -1417 +1494 diff --git a/test/other/codesize/test_codesize_minimal_O3.jssize b/test/other/codesize/test_codesize_minimal_O3.jssize index 28520983963f1..d1b046a7fd29f 100644 --- a/test/other/codesize/test_codesize_minimal_O3.jssize +++ b/test/other/codesize/test_codesize_minimal_O3.jssize @@ -1 +1 @@ -2834 +3089 diff --git a/test/other/codesize/test_codesize_minimal_O3.size b/test/other/codesize/test_codesize_minimal_O3.size index d69c74c8b95c8..dee261df401d4 100644 --- a/test/other/codesize/test_codesize_minimal_O3.size +++ b/test/other/codesize/test_codesize_minimal_O3.size @@ -1 +1 @@ -73 +140 diff --git a/test/other/codesize/test_codesize_minimal_Os.exports b/test/other/codesize/test_codesize_minimal_Os.exports index cf1318048d1eb..95e9fb1bf4221 100644 --- a/test/other/codesize/test_codesize_minimal_Os.exports +++ b/test/other/codesize/test_codesize_minimal_Os.exports @@ -2,3 +2,6 @@ a (memory) b (__wasm_call_ctors) c (add) d (__indirect_function_table) +e (_emscripten_stack_restore) +f (_emscripten_stack_alloc) +g (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_minimal_Os.funcs b/test/other/codesize/test_codesize_minimal_Os.funcs index 08504a53bdb1b..819f7d5bf2b03 100644 --- a/test/other/codesize/test_codesize_minimal_Os.funcs +++ b/test/other/codesize/test_codesize_minimal_Os.funcs @@ -1,2 +1,5 @@ $__wasm_call_ctors +$_emscripten_stack_alloc +$_emscripten_stack_restore $add +$emscripten_stack_get_current diff --git a/test/other/codesize/test_codesize_minimal_Os.gzsize b/test/other/codesize/test_codesize_minimal_Os.gzsize index 06cf2f9c460e0..9d877e1547163 100644 --- a/test/other/codesize/test_codesize_minimal_Os.gzsize +++ b/test/other/codesize/test_codesize_minimal_Os.gzsize @@ -1 +1 @@ -1417 +1494 diff --git a/test/other/codesize/test_codesize_minimal_Os.jssize b/test/other/codesize/test_codesize_minimal_Os.jssize index 28520983963f1..d1b046a7fd29f 100644 --- a/test/other/codesize/test_codesize_minimal_Os.jssize +++ b/test/other/codesize/test_codesize_minimal_Os.jssize @@ -1 +1 @@ -2834 +3089 diff --git a/test/other/codesize/test_codesize_minimal_Os.size b/test/other/codesize/test_codesize_minimal_Os.size index d69c74c8b95c8..dee261df401d4 100644 --- a/test/other/codesize/test_codesize_minimal_Os.size +++ b/test/other/codesize/test_codesize_minimal_Os.size @@ -1 +1 @@ -73 +140 diff --git a/test/other/codesize/test_codesize_minimal_Os_mr.exports b/test/other/codesize/test_codesize_minimal_Os_mr.exports index cf1318048d1eb..95e9fb1bf4221 100644 --- a/test/other/codesize/test_codesize_minimal_Os_mr.exports +++ b/test/other/codesize/test_codesize_minimal_Os_mr.exports @@ -2,3 +2,6 @@ a (memory) b (__wasm_call_ctors) c (add) d (__indirect_function_table) +e (_emscripten_stack_restore) +f (_emscripten_stack_alloc) +g (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_minimal_Os_mr.funcs b/test/other/codesize/test_codesize_minimal_Os_mr.funcs index 08504a53bdb1b..819f7d5bf2b03 100644 --- a/test/other/codesize/test_codesize_minimal_Os_mr.funcs +++ b/test/other/codesize/test_codesize_minimal_Os_mr.funcs @@ -1,2 +1,5 @@ $__wasm_call_ctors +$_emscripten_stack_alloc +$_emscripten_stack_restore $add +$emscripten_stack_get_current diff --git a/test/other/codesize/test_codesize_minimal_Os_mr.size b/test/other/codesize/test_codesize_minimal_Os_mr.size index d69c74c8b95c8..dee261df401d4 100644 --- a/test/other/codesize/test_codesize_minimal_Os_mr.size +++ b/test/other/codesize/test_codesize_minimal_Os_mr.size @@ -1 +1 @@ -73 +140 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.exports b/test/other/codesize/test_codesize_minimal_Oz-ctors.exports index 96a732a960bff..cbd3f05489ee6 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.exports +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.exports @@ -1,3 +1,6 @@ a (memory) b (add) c (__indirect_function_table) +d (_emscripten_stack_restore) +e (_emscripten_stack_alloc) +f (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.funcs b/test/other/codesize/test_codesize_minimal_Oz-ctors.funcs index 66ddb2638a16b..6db0f5b2aede0 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.funcs +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.funcs @@ -1 +1,4 @@ +$_emscripten_stack_alloc +$_emscripten_stack_restore $add +$emscripten_stack_get_current diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize index 08507bb20953a..05746031b1cc9 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize @@ -1 +1 @@ -1409 +1486 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize index eebd44e48e8dd..09dcc412ebd0a 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize @@ -1 +1 @@ -2819 +3090 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.size b/test/other/codesize/test_codesize_minimal_Oz-ctors.size index a8fa06e1be7da..b0d73241cad26 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.size +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.size @@ -1 +1 @@ -62 +129 diff --git a/test/other/codesize/test_codesize_minimal_Oz.exports b/test/other/codesize/test_codesize_minimal_Oz.exports index cf1318048d1eb..95e9fb1bf4221 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.exports +++ b/test/other/codesize/test_codesize_minimal_Oz.exports @@ -2,3 +2,6 @@ a (memory) b (__wasm_call_ctors) c (add) d (__indirect_function_table) +e (_emscripten_stack_restore) +f (_emscripten_stack_alloc) +g (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_minimal_Oz.funcs b/test/other/codesize/test_codesize_minimal_Oz.funcs index 08504a53bdb1b..819f7d5bf2b03 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.funcs +++ b/test/other/codesize/test_codesize_minimal_Oz.funcs @@ -1,2 +1,5 @@ $__wasm_call_ctors +$_emscripten_stack_alloc +$_emscripten_stack_restore $add +$emscripten_stack_get_current diff --git a/test/other/codesize/test_codesize_minimal_Oz.gzsize b/test/other/codesize/test_codesize_minimal_Oz.gzsize index 06cf2f9c460e0..9d877e1547163 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz.gzsize @@ -1 +1 @@ -1417 +1494 diff --git a/test/other/codesize/test_codesize_minimal_Oz.jssize b/test/other/codesize/test_codesize_minimal_Oz.jssize index 28520983963f1..d1b046a7fd29f 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz.jssize @@ -1 +1 @@ -2834 +3089 diff --git a/test/other/codesize/test_codesize_minimal_Oz.size b/test/other/codesize/test_codesize_minimal_Oz.size index d69c74c8b95c8..dee261df401d4 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.size +++ b/test/other/codesize/test_codesize_minimal_Oz.size @@ -1 +1 @@ -73 +140 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.exports b/test/other/codesize/test_codesize_minimal_pthreads.exports index 0b1b4cd55866e..a1bc59975d17d 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.exports +++ b/test/other/codesize/test_codesize_minimal_pthreads.exports @@ -1,9 +1,11 @@ -A (_emscripten_thread_exit) -B (_emscripten_check_mailbox) -C (emscripten_stack_set_limits) -D (_emscripten_stack_restore) -E (_emscripten_stack_alloc) -F (emscripten_stack_get_current) +A (_emscripten_run_on_main_thread_js) +B (_emscripten_thread_free_data) +C (_emscripten_thread_exit) +D (_emscripten_check_mailbox) +E (emscripten_stack_set_limits) +F (_emscripten_stack_restore) +G (_emscripten_stack_alloc) +H (emscripten_stack_get_current) p (__wasm_call_ctors) q (add) r (main) @@ -13,5 +15,5 @@ u (pthread_self) v (_emscripten_proxy_main) w (_emscripten_thread_init) x (_emscripten_thread_crashed) -y (_emscripten_run_on_main_thread_js) -z (_emscripten_thread_free_data) +y (emscripten_main_thread_process_queued_calls) +z (emscripten_main_runtime_thread_id) diff --git a/test/other/codesize/test_codesize_minimal_pthreads.funcs b/test/other/codesize/test_codesize_minimal_pthreads.funcs index e33d074b756b5..5ec86e9bd4ed0 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.funcs +++ b/test/other/codesize/test_codesize_minimal_pthreads.funcs @@ -70,6 +70,8 @@ $emscripten_builtin_malloc $emscripten_current_thread_process_queued_calls $emscripten_futex_wait $emscripten_futex_wake +$emscripten_main_runtime_thread_id +$emscripten_main_thread_process_queued_calls $emscripten_stack_get_current $emscripten_stack_set_limits $free_ctx diff --git a/test/other/codesize/test_codesize_minimal_pthreads.gzsize b/test/other/codesize/test_codesize_minimal_pthreads.gzsize index 31a1f807b4325..f49fbd617340f 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.gzsize +++ b/test/other/codesize/test_codesize_minimal_pthreads.gzsize @@ -1 +1 @@ -4218 +4418 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.jssize b/test/other/codesize/test_codesize_minimal_pthreads.jssize index 5eb0c72aab653..2e7e82e0cdb50 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.jssize +++ b/test/other/codesize/test_codesize_minimal_pthreads.jssize @@ -1 +1 @@ -8696 +9605 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.size b/test/other/codesize/test_codesize_minimal_pthreads.size index 10b2d7f643c17..72f92d0141faf 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.size +++ b/test/other/codesize/test_codesize_minimal_pthreads.size @@ -1 +1 @@ -19501 +19522 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.exports b/test/other/codesize/test_codesize_minimal_wasmfs.exports index cf1318048d1eb..95e9fb1bf4221 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.exports +++ b/test/other/codesize/test_codesize_minimal_wasmfs.exports @@ -2,3 +2,6 @@ a (memory) b (__wasm_call_ctors) c (add) d (__indirect_function_table) +e (_emscripten_stack_restore) +f (_emscripten_stack_alloc) +g (emscripten_stack_get_current) diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.funcs b/test/other/codesize/test_codesize_minimal_wasmfs.funcs index 08504a53bdb1b..819f7d5bf2b03 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.funcs +++ b/test/other/codesize/test_codesize_minimal_wasmfs.funcs @@ -1,2 +1,5 @@ $__wasm_call_ctors +$_emscripten_stack_alloc +$_emscripten_stack_restore $add +$emscripten_stack_get_current diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize index 06cf2f9c460e0..9d877e1547163 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize @@ -1 +1 @@ -1417 +1494 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.jssize b/test/other/codesize/test_codesize_minimal_wasmfs.jssize index 28520983963f1..d1b046a7fd29f 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.jssize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.jssize @@ -1 +1 @@ -2834 +3089 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.size b/test/other/codesize/test_codesize_minimal_wasmfs.size index d69c74c8b95c8..dee261df401d4 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.size +++ b/test/other/codesize/test_codesize_minimal_wasmfs.size @@ -1 +1 @@ -73 +140 diff --git a/test/other/embind_jsgen_method_pointer_stability.cpp b/test/other/embind_jsgen_method_pointer_stability.cpp index 8031b86fd6483..59672d44af528 100644 --- a/test/other/embind_jsgen_method_pointer_stability.cpp +++ b/test/other/embind_jsgen_method_pointer_stability.cpp @@ -10,9 +10,9 @@ void malloc_in_static_constructor(void) { // that method pointers still work correctly. EM_ASM( if (typeof InvokerFunctions == 'undefined') { - _malloc(10); + malloc(10); } else { - _malloc(100); + malloc(100); } ); } diff --git a/test/other/test_jspi_wildcard.c b/test/other/test_jspi_wildcard.c index 39790d9b141ca..8c637028ef935 100644 --- a/test/other/test_jspi_wildcard.c +++ b/test/other/test_jspi_wildcard.c @@ -7,13 +7,13 @@ #include EM_ASYNC_JS(int, test, (), { - const promise1 = Module._async1(); + const promise1 = Module.async1(); assert(promise1 instanceof Promise); await promise1; - const promise2 = Module._async2(); + const promise2 = Module.async2(); assert(promise2 instanceof Promise); await promise2; - assert(!(Module._sync() instanceof Promise)); + assert(!(Module.sync() instanceof Promise)); }); EMSCRIPTEN_KEEPALIVE int async1() { diff --git a/test/other/test_memory64_proxies.js b/test/other/test_memory64_proxies.js index 748d0d2abd588..5e9389f90ee12 100644 --- a/test/other/test_memory64_proxies.js +++ b/test/other/test_memory64_proxies.js @@ -1,9 +1,9 @@ addOnPostRun(() => { // check >4gb alloc - const bigChunk = _malloc(4 * 1024 * 1024 * 1024 + 100); + const bigChunk = malloc(4 * 1024 * 1024 * 1024 + 100); assert(bigChunk > 0); - const littleChunk = _malloc(100); + const littleChunk = malloc(100); HEAP8[littleChunk] = 2; assert(HEAP8[littleChunk] === 2); diff --git a/test/other/test_parseTools.js b/test/other/test_parseTools.js index 09b9e25e8823e..a1db4d112fa73 100644 --- a/test/other/test_parseTools.js +++ b/test/other/test_parseTools.js @@ -102,35 +102,35 @@ addToLibrary({ test_makeSetValue__deps: ['$writeI53ToI64'], test_makeSetValue: function(ptr) { out('\ntest_makeSetValue:'); - _clearI64(ptr); + clearI64(ptr); {{{ makeSetValue('ptr', '0', 0x12345678AB, 'i64') }}}; - _printI64(ptr); + printI64(ptr); // This value doesn't fit into i64. The current behaviour truncate (i.e. // ignore the upper bits), in the same way that `BigInt64Array[X] = Y` does. // (see splitI16 in parseTools.js) - _clearI64(ptr); + clearI64(ptr); {{{ makeSetValue('ptr', '0', 0x1122334455667788AA, 'i64') }}}; - _printI64(ptr); + printI64(ptr); - _clearI64(ptr); + clearI64(ptr); {{{ makeSetValue('ptr', '0', -0x1122334455667788AA, 'i64') }}}; - _printI64(ptr); + printI64(ptr); - _clearI64(ptr); + clearI64(ptr); {{{ makeSetValue('ptr', '0', 0x12345678AB, 'i53') }}}; - _printI64(ptr); + printI64(ptr); - _clearI64(ptr); + clearI64(ptr); {{{ makeSetValue('ptr', '0', -1, 'i53') }}}; - _printI64(ptr); + printI64(ptr); - _clearI64(ptr); + clearI64(ptr); {{{ makeSetValue('ptr', '0', 0xff, 'i32') }}}; - _printI64(ptr); + printI64(ptr); - _clearI64(ptr); + clearI64(ptr); {{{ makeSetValue('ptr', '0', 0x12345678ab, 'i32') }}}; - _printI64(ptr); + printI64(ptr); }, }); diff --git a/test/other/test_split_module.post.js b/test/other/test_split_module.post.js index 4dba106b6759b..dc13abc5f8a46 100644 --- a/test/other/test_split_module.post.js +++ b/test/other/test_split_module.post.js @@ -2,7 +2,7 @@ function saveProfileData() { var __write_profile = wasmExports['__write_profile']; if (__write_profile) { var len = __write_profile(0, 0); - var offset = _malloc(len); + var offset = malloc(len); var actualLen = __write_profile(offset, len); var profile_data = HEAPU8.subarray(offset, offset + len); if (typeof fs === 'undefined') { @@ -14,11 +14,11 @@ function saveProfileData() { } console.log('profile size is', actualLen, 'bytes (allocated', len, 'bytes)'); console.log('wrote profile data') - _free(offset); + free(offset); } // Say hello *after* recording the profile so that all functions are deferred. - var result = _say_hello(); + var result = say_hello(); if (typeof Asyncify !== 'undefined') { console.log((result instanceof Promise) ? 'result is promise' : ''); } diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index a9702b35fe87e..00dcea7d4d8dc 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -54957 +56586 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..588d2cd068727 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 +31474 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index 93cc7231065b7..fea84213d0025 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -53753 +54266 diff --git a/test/return64bit/testbind.js b/test/return64bit/testbind.js index 9ca30d0d18977..8218bc8baac53 100644 --- a/test/return64bit/testbind.js +++ b/test/return64bit/testbind.js @@ -4,12 +4,12 @@ // returned via the accessor method getTempRet0() Module['runtest'] = function() { - var low = _test_return64(0x11223344, 0xaabbccdd); + var low = test_return64(0x11223344, 0xaabbccdd); var high = getTempRet0(); console.log("low = " + low); console.log("high = " + high); - var ptr = _get_func_ptr(); + var ptr = get_func_ptr(); low = dynCall_jj(ptr, 0x12345678, 0xabcdef19); high = getTempRet0(); console.log("low = " + low); diff --git a/test/return64bit/testbind_bigint.js b/test/return64bit/testbind_bigint.js index cd21d62a82967..5905e5358bd79 100644 --- a/test/return64bit/testbind_bigint.js +++ b/test/return64bit/testbind_bigint.js @@ -6,13 +6,13 @@ 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 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(); + var ptr = get_func_ptr(); bigint = dynCall('jj', ptr, [eval('0xabcdef1912345678n')]); low = Number(bigint & 0xffffffffn); high = Number(bigint >> 32n); diff --git a/test/test_browser.py b/test/test_browser.py index 9c9085d219c70..adb60cdd27cfb 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -1830,7 +1830,7 @@ def test_emscripten_api(self): def test_emscripten_async_load_script(self): def setup(): create_file('script1.js', ''' - Module._set(456); + Module.set(456); ''') create_file('file1.txt', 'first') create_file('file2.txt', 'second') diff --git a/test/test_core.py b/test/test_core.py index f0da30a4af1f6..a113e4f0238ee 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -1736,13 +1736,13 @@ def test_set_align(self): self.do_core_test('test_set_align.c') def test_emscripten_api(self): - self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_save_me_aimee']) + self.set_setting('EXPORTS', ['main', 'save_me_aimee']) self.do_core_test('test_emscripten_api.cpp') # Sanitizers are not compatible with LINKABLE (dynamic linking. if not is_sanitizing(self.emcc_args) and not self.is_wasm64(): # test EXPORT_ALL - self.clear_setting('EXPORTED_FUNCTIONS') + self.clear_setting('EXPORTS') self.set_setting('EXPORT_ALL') self.set_setting('LINKABLE') self.do_core_test('test_emscripten_api.cpp') @@ -1945,7 +1945,7 @@ def test_em_asm_side_module(self): def test_em_js(self, args, force_c): if '-sMAIN_MODULE=2' in args: self.check_dylink() - self.emcc_args += ['-sEXPORTED_FUNCTIONS=_main,_malloc'] + args + self.emcc_args += ['-sEXPORTS=main,malloc'] + args if '-pthread' in args: self.setup_node_pthreads() @@ -2823,7 +2823,7 @@ def prep_dlfcn_main(self, libs=None): self.set_setting('NO_AUTOLOAD_DYLIBS') self.emcc_args += libs # This means we can use MAIN_MODULE=2 without needing to explicitly - # specify EXPORTED_FUNCTIONS. + # specify EXPORTS. self.set_setting('MAIN_MODULE', 2) def build_dlfcn_lib(self, filename, outfile='liblib.so', emcc_args=None): @@ -3261,7 +3261,6 @@ def test_dlfcn_alignment_and_zeroing(self): @needs_dylink def test_dlfcn_self(self): self.set_setting('MAIN_MODULE') - self.set_setting('EXPORT_ALL') self.do_core_test('test_dlfcn_self.c') @@ -5638,8 +5637,7 @@ def test_futimens(self): @no_minimal_runtime('MINIMAL_RUNTIME does not have getValue() and setValue() (TODO add it to a JS library function to get it in)') @requires_node # only node handles utf well def test_utf(self): - self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc', '_free']) - self.set_setting('EXPORTED_RUNTIME_METHODS', ['getValue', 'setValue', 'UTF8ToString', 'stringToUTF8']) + self.set_setting('EXPORTS', ['main', 'malloc', 'free', 'getValue', 'setValue', 'UTF8ToString', 'stringToUTF8']) self.do_core_test('test_utf.c') def test_utf32(self): @@ -5839,7 +5837,7 @@ def test_fs_no_main(self, *args): assert(_foo() == 42); } ''') - self.set_setting('EXPORTED_FUNCTIONS', '_foo') + self.set_setting('EXPORTS', 'foo') self.set_setting('FORCE_FILESYSTEM') self.emcc_args += ['--pre-js', 'pre.js'] + list(args) self.do_run('int foo() { return 42; }', '', force_c=True) @@ -6924,7 +6922,6 @@ def test_autodebug_wasm(self): @crossplatform def test_ccall(self): self.emcc_args.append('-Wno-return-stack-address') - self.set_setting('EXPORTED_RUNTIME_METHODS', ['ccall', 'cwrap', 'STACK_SIZE']) self.set_setting('WASM_ASYNC_COMPILATION', 0) create_file('post.js', ''' out('*'); @@ -6960,7 +6957,7 @@ def test_ccall(self): ''') self.emcc_args += ['--post-js', 'post.js'] - self.set_setting('EXPORTED_FUNCTIONS', ['_get_int', '_get_float', '_get_bool', '_get_string', '_print_int', '_print_float', '_print_bool', '_print_string', '_multi', '_pointer', '_call_ccall_again', '_malloc']) + self.set_setting('EXPORTS', ['get_int', 'get_float', 'get_bool', 'get_string', 'print_int', 'print_float', 'print_bool', 'print_string', 'multi', 'pointer', 'call_ccall_again', 'malloc', 'ccall', 'cwrap', 'STACK_SIZE']) self.do_core_test('test_ccall.cpp') if self.maybe_closure(): @@ -6968,7 +6965,6 @@ def test_ccall(self): def test_ccall_cwrap_fast_path(self): self.emcc_args.append('-Wno-return-stack-address') - self.set_setting('EXPORTED_RUNTIME_METHODS', ['ccall', 'cwrap']) self.set_setting('WASM_ASYNC_COMPILATION', 0) self.set_setting('ASSERTIONS', 0) create_file('post.js', ''' @@ -6977,7 +6973,7 @@ def test_ccall_cwrap_fast_path(self): ''') self.emcc_args += ['--post-js', 'post.js'] - self.set_setting('EXPORTED_FUNCTIONS', ['_print_bool']) + self.set_setting('EXPORTS', ['print_bool', 'ccall', 'cwrap']) self.do_runf('core/test_ccall.cpp', 'true') def test_EXPORTED_RUNTIME_METHODS(self): @@ -7009,8 +7005,8 @@ def test_dyncall_specific(self, *args): else: cases += [ ('EXPORTED', []), - ('EXPORTED_DYNAMIC_SIG', ['-sDYNCALLS', '-sEXPORTED_RUNTIME_METHODS=dynCall']), - ('FROM_OUTSIDE', ['-sEXPORTED_RUNTIME_METHODS=dynCall_iiji']) + ('EXPORTED_DYNAMIC_SIG', ['-sDYNCALLS', '-sEXPORTS=dynCall,main']), + ('FROM_OUTSIDE', ['-sEXPORTS=dynCall_iiji,main']) ] for which, extra_args in cases: @@ -7054,13 +7050,12 @@ def test(args=None, asserts=False): test(args=['-DDIRECT', '-DASSERTIONS_2']) # see that with assertions, we get a nice error message - self.set_setting('EXPORTED_RUNTIME_METHODS', []) self.set_setting('ASSERTIONS') test(asserts=True) self.set_setting('ASSERTIONS', 0) # see that when we export them, things work on the module - self.set_setting('EXPORTED_RUNTIME_METHODS', ['getValue', 'setValue']) + self.set_setting('EXPORTS', ['main', 'getValue', 'setValue']) test() @parameterized({ @@ -7081,12 +7076,11 @@ def test(output_prefix='', args=None, assert_returncode=0): # keeps it alive through JSDCE test(args=['-DDIRECT', '-sFORCE_FILESYSTEM']) # see that with assertions, we get a nice error message - self.set_setting('EXPORTED_RUNTIME_METHODS', []) self.set_setting('ASSERTIONS') test('_assert', args=[], assert_returncode=NON_ZERO) self.set_setting('ASSERTIONS', 0) # see that when we export them, things work on the module - self.set_setting('EXPORTED_RUNTIME_METHODS', ['FS_createDataFile']) + self.set_setting('EXPORTS', ['FS_createDataFile', 'main']) test(args=['-sFORCE_FILESYSTEM']) def test_legacy_exported_runtime_numbers(self): @@ -7103,7 +7097,7 @@ def test(expected, args=None, assert_returncode=0): test('ALLOC_STACK is not defined', args=['-DDIRECT'], assert_returncode=NON_ZERO) # When assertions are enabled direct and indirect usage both abort with a useful error message. - not_exported = "Aborted('ALLOC_STACK' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ))" + not_exported = "Aborted('ALLOC_STACK' was not exported. add it to EXPORTS (see the Emscripten FAQ))" not_included = "`ALLOC_STACK` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='$ALLOC_STACK')" self.set_setting('ASSERTIONS') test(not_exported, assert_returncode=NON_ZERO) @@ -7149,15 +7143,15 @@ def test_exported_response(self): } int main() { - int x = EM_ASM_INT({ return Module._other_function() }); + int x = EM_ASM_INT({ return Module.other_function() }); emscripten_run_script_string(""); // Add a reference to a symbol that exists in src/deps_info.json to uncover issue #2836 in the test suite. printf("waka %d!\n", x); return 0; } ''' - create_file('exps', '_main\n_other_function\n') + create_file('exps', 'main\nother_function\n') - self.set_setting('EXPORTED_FUNCTIONS', '@exps') + self.set_setting('EXPORTS', '@exps') self.do_run(src, '''waka 5!''') assert 'other_function' in read_file('src.js') @@ -7175,14 +7169,14 @@ def test_large_exported_response(self): count = 0 while count < num_exports: src += 'int exported_func_from_response_file_%d () { return %d;}\n' % (count, count) - rsp_file_lines.append('_exported_func_from_response_file_%d' % count) + rsp_file_lines.append('exported_func_from_response_file_%d' % count) count += 1 src += r''' } int main() { - int x = EM_ASM_INT({ return Module._exported_func_from_response_file_4999() }); + int x = EM_ASM_INT({ return Module.exported_func_from_response_file_4999() }); // Add a reference to a symbol that exists in src/deps_info.json to uncover // issue #2836 in the test suite. emscripten_run_script_string(""); @@ -7191,12 +7185,12 @@ def test_large_exported_response(self): } ''' - rsp_file_lines.append('_main') + rsp_file_lines.append('main') create_file('large_exported_response.json', '\n'.join(rsp_file_lines) + '\n') - self.set_setting('EXPORTED_FUNCTIONS', '@large_exported_response.json') + self.set_setting('EXPORTS', '@large_exported_response.json') self.do_run(src, 'waka 4999!') - self.assertContained('_exported_func_from_response_file_1', read_file('src.js')) + self.assertContained('exported_func_from_response_file_1', read_file('src.js')) def test_emulate_function_pointer_casts(self): # Forcibly disable EXIT_RUNTIME due to: @@ -8141,7 +8135,7 @@ def test_async_ccall_promise(self, exit_runtime, asyncify): self.set_setting('ASSERTIONS') self.set_setting('INVOKE_RUN', 0) self.set_setting('EXIT_RUNTIME', exit_runtime) - self.set_setting('EXPORTED_FUNCTIONS', ['_stringf', '_floatf']) + self.set_setting('EXPORTS', ['stringf', 'floatf']) self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', ['$maybeExit', '$ccall']) create_file('main.c', r''' #include @@ -8493,13 +8487,14 @@ def test_memprof_requirements(self): create_file('lib.js', ''' addToLibrary({ check_memprof_requirements: () => { - if (typeof _emscripten_stack_get_base === 'function' && - typeof _emscripten_stack_get_end === 'function' && - typeof _emscripten_stack_get_current === 'function' && - typeof Module['___heap_base'] === 'number') { + if (typeof emscripten_stack_get_base === 'function' && + typeof emscripten_stack_get_end === 'function' && + typeof emscripten_stack_get_current === 'function' && + typeof Module['__heap_base'] === 'number') { out('able to run memprof'); return 0; } else { + out(Module['__heap_base']); out('missing the required variables to run memprof'); return 1; } @@ -9452,9 +9447,9 @@ def test_undefined_main(self): # In non-standalone mode exporting an empty list of functions signal that we don't # have a main and so should not generate an error. - self.set_setting('EXPORTED_FUNCTIONS', []) + self.set_setting('EXPORTS', []) self.do_core_test('test_ctors_no_main.cpp') - self.clear_setting('EXPORTED_FUNCTIONS') + self.clear_setting('EXPORTS') # Marked as impure since the WASI reactor modules (modules without main) # are not yet supported by the wasm engines we test against. @@ -9475,7 +9470,7 @@ def test_export_start(self): if not can_do_standalone(self): self.skipTest('standalone mode only') self.set_setting('STANDALONE_WASM') - self.set_setting('EXPORTED_FUNCTIONS', ['__start']) + self.set_setting('EXPORTS', ['_start']) self.do_core_test('test_hello_world.c') # Tests the operation of API found in #include @@ -9492,7 +9487,7 @@ def test_emscripten_stack(self): def test_abort_on_exceptions(self): self.set_setting('ABORT_ON_WASM_EXCEPTIONS') self.set_setting('ALLOW_TABLE_GROWTH') - self.set_setting('EXPORTED_RUNTIME_METHODS', ['ccall', 'cwrap']) + self.set_setting('EXPORTS', ['ccall', 'cwrap', 'main']) self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', ['$addFunction']) self.emcc_args += ['-lembind', '--post-js', test_file('core/test_abort_on_exceptions_post.js')] self.do_core_test('test_abort_on_exceptions.cpp', interleaved_output=False) @@ -9556,7 +9551,7 @@ def test_em_async_js(self): self.uses_es6 = True if not self.get_setting('ASYNCIFY'): self.set_setting('ASYNCIFY') - self.set_setting('EXPORTED_RUNTIME_METHODS', 'ccall') + self.set_setting('EXPORTS', 'ccall,main') self.maybe_closure() self.do_core_test('test_em_async_js.c') diff --git a/test/test_other.py b/test/test_other.py index bbef918ae4fa8..bfa6f11fd9e9e 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -1570,8 +1570,8 @@ def test_export_all(self): create_file('pre.js', ''' Module.onRuntimeInitialized = () => { - _libf1(); - _libf2(); + libf1(); + libf2(); }; ''') @@ -1588,7 +1588,7 @@ def test_export_keepalive(self): create_file('pre.js', ''' Module.onRuntimeInitialized = () => { - out(Module._libf1 ? Module._libf1() : 'unexported'); + out(Module.libf1 ? Module.libf1() : 'unexported'); }; ''') @@ -1611,12 +1611,12 @@ def test_minimal_modularize_export_keepalive(self): # an ES6 module. # Thus, it's impossible to use `require` or `import` and instead run the module # as part of --extern-post-js. - create_file('post.js', 'Module().then((mod) => console.log(mod._libf1()));') + create_file('post.js', 'Module().then((mod) => console.log(mod.libf1()));') self.emcc_args += ['--extern-post-js=post.js'] # By default, no symbols should be exported when using MINIMAL_RUNTIME. self.emcc('main.c', []) - self.assertContained('TypeError: mod._libf1 is not a function', self.run_js('a.out.js', assert_returncode=NON_ZERO)) + self.assertContained('TypeError: mod.libf1 is not a function', self.run_js('a.out.js', assert_returncode=NON_ZERO)) # Ensures that EXPORT_KEEPALIVE=1 exports the symbols. self.emcc('main.c', ['-sEXPORT_KEEPALIVE=1']) @@ -1652,8 +1652,8 @@ def test_minimal_runtime_export_all_modularize(self): import Test from './test.mjs'; async function main() { const mod = await Test(); - mod._libf1(); - mod._libf2(); + mod.libf1(); + mod.libf2(); } main(); ''') @@ -1662,7 +1662,7 @@ def test_minimal_runtime_export_all_modularize(self): def test_export_all_and_exported_functions(self): # EXPORT_ALL should not export library functions by default. # This means that to export library function you also need to explicitly - # list them in EXPORTED_FUNCTIONS. + # list them in EXPORTS. lib = r''' #include #include @@ -1672,17 +1672,17 @@ def test_export_all_and_exported_functions(self): create_file('lib.c', lib) create_file('pre.js', ''' Module.onRuntimeInitialized = () => { - _libfunc(); - _libfunc2(); + libfunc(); + libfunc2(); }; ''') # libfunc2 should not be linked by default, even with EXPORT_ALL self.emcc('lib.c', ['-sEXPORT_ALL', '--pre-js', 'pre.js'], output_filename='a.out.js') err = self.run_js('a.out.js', assert_returncode=NON_ZERO) - self.assertContained('_libfunc2 is not defined', err) + self.assertContained('libfunc2 is not defined', err) - self.emcc('lib.c', ['-sEXPORTED_FUNCTIONS=_libfunc2', '-sEXPORT_ALL', '--pre-js', 'pre.js'], output_filename='a.out.js') + self.emcc('lib.c', ['-sEXPORTS=libfunc2', '-sEXPORT_ALL', '--pre-js', 'pre.js'], output_filename='a.out.js') self.assertContained('libfunc\n', self.run_js('a.out.js')) @also_with_wasmfs @@ -1938,7 +1938,6 @@ def test_archive_duplicate_basenames(self): def test_export_from_archive(self): export_name = 'this_is_an_entry_point' - full_export_name = '_this_is_an_entry_point' create_file('export.c', r''' #include @@ -1960,7 +1959,7 @@ def test_export_from_archive(self): self.assertFalse(self.is_exported_in_wasm(export_name, 'a.out.wasm')) # Exporting it causes it to appear in the output. - self.run_process([EMCC, 'main.c', '-L.', '-lexport', '-sEXPORTED_FUNCTIONS=%s' % full_export_name]) + self.run_process([EMCC, 'main.c', '-L.', '-lexport', '-sEXPORTS=main,%s' % export_name]) self.assertTrue(self.is_exported_in_wasm(export_name, 'a.out.wasm')) @parameterized({ @@ -2654,8 +2653,8 @@ def test_undefined_exported_function(self, outfile): cmd = [EMCC, test_file('hello_world.c'), '-o', outfile] self.run_process(cmd) - # Adding a missing symbol to EXPORTED_FUNCTIONS should cause a link failure - cmd += ['-sEXPORTED_FUNCTIONS=_foobar'] + # Adding a missing symbol to EXPORTS should cause a link failure + cmd += ['-sEXPORTS=foobar'] err = self.expect_fail(cmd) self.assertContained('wasm-ld: error: symbol exported via --export not found: foobar', err) @@ -2663,7 +2662,7 @@ def test_undefined_exported_function(self, outfile): # by emscripten.py. cmd += ['-sERROR_ON_UNDEFINED_SYMBOLS=0'] err = self.expect_fail(cmd) - self.assertContained('undefined exported symbol: "_foobar"', err) + self.assertContained('undefined exported symbol: "foobar"', err) # setting `-Wno-undefined` should suppress the error cmd += ['-Wno-undefined'] @@ -2677,10 +2676,10 @@ def test_undefined_exported_js_function(self, outfile): cmd = [EMXX, test_file('hello_world.cpp'), '-o', outfile] self.run_process(cmd) - # adding a missing symbol to EXPORTED_FUNCTIONS should cause failure - cmd += ['-sEXPORTED_FUNCTIONS=foobar'] + # adding a missing symbol to EXPORTS should cause failure + cmd += ['-sEXPORTS=foobar'] err = self.expect_fail(cmd) - self.assertContained('undefined exported symbol: "foobar"', err) + self.assertContained('error: symbol exported via --export not found: foobar', err) # setting `-Wno-undefined` should suppress the error cmd += ['-Wno-undefined'] @@ -3952,8 +3951,7 @@ def test_module_exports_with_closure(self): # compile without --closure=1 self.run_process([EMCC, test_file('module_exports/test.c'), '-o', 'test.js', '-O2', - '-sEXPORTED_FUNCTIONS=_bufferTest,_malloc,_free', - '-sEXPORTED_RUNTIME_METHODS=ccall,cwrap', + '-sEXPORTS=bufferTest,malloc,free,ccall,cwrap', '-sWASM_ASYNC_COMPILATION=0']) # Check that test.js compiled without --closure=1 contains "module['exports'] = Module;" @@ -3970,8 +3968,7 @@ def test_module_exports_with_closure(self): # compile with --closure=1 self.run_process([EMCC, test_file('module_exports/test.c'), '-o', 'test.js', '-O2', '--closure=1', - '-sEXPORTED_FUNCTIONS=_bufferTest,_malloc,_free', - '-sEXPORTED_RUNTIME_METHODS=ccall,cwrap', + '-sEXPORTS=bufferTest,malloc,free,ccall,cwrap', '-sWASM_ASYNC_COMPILATION=0']) # Check that test.js compiled with --closure 1 contains "module.exports", we want to verify that @@ -4031,13 +4028,14 @@ def test_exported_runtime_methods(self): if (count.wasmExports && 'count' in count.wasmExports) { console.log('wasmExports found'); } else { + //console.log(Object.keys(count)); + //console.log(count.wasmExports); console.log('wasmExports NOT found'); } }; ''') - self.run_process([EMCC, 'count.c', '-sFORCE_FILESYSTEM', '-sEXPORTED_FUNCTIONS=_count', - '-sEXPORTED_RUNTIME_METHODS=FS_writeFile,wasmExports', '-o', 'count.js']) + self.run_process([EMCC, 'count.c', '-sFORCE_FILESYSTEM', '-sEXPORTS=count,FS_writeFile,wasmExports', '-o', 'count.js']) # Check that the Module.FS_writeFile exists out = self.run_js('index.js') @@ -4049,7 +4047,7 @@ def test_exported_runtime_methods(self): # Check that the Module.FS_writeFile is not exported out = self.run_js('index.js', assert_returncode=NON_ZERO) self.assertContained('undefined', out), - self.assertContained("Aborted('wasmExports' was not exported. add it to EXPORTED_RUNTIME_METHODS", out) + self.assertContained("Aborted('wasmExports' was not exported. add it to -sEXPORTS", out) def test_exported_runtime_methods_from_js_library(self): create_file('pre.js', ''' @@ -4597,7 +4595,7 @@ def test_js_lib_method_syntax(self): def test_js_lib_exported(self): create_file('lib.js', r''' addToLibrary({ - jslibfunc: (x) => 2 * x + jslibfunc: (x) => 2 * x }); ''') create_file('src.c', r''' @@ -4607,18 +4605,18 @@ def test_js_lib_exported(self): int main() { printf("c calling: %d\n", jslibfunc(6)); EM_ASM({ - out('js calling: ' + Module['_jslibfunc'](5) + '.'); + out('js calling: ' + Module['jslibfunc'](5) + '.'); }); } ''') self.do_runf('src.c', 'c calling: 12\njs calling: 10.', - emcc_args=['--js-library', 'lib.js', '-sEXPORTED_FUNCTIONS=_main,_jslibfunc']) + emcc_args=['--js-library', 'lib.js', '-sEXPORTS=main,jslibfunc']) def test_js_lib_using_asm_lib(self): create_file('lib.js', r''' addToLibrary({ jslibfunc__deps: ['asmlibfunc'], - jslibfunc: (x) => 2 * _asmlibfunc(x), + jslibfunc: (x) => 2 * asmlibfunc(x), asmlibfunc__asm: true, asmlibfunc__sig: 'ii', @@ -5316,7 +5314,7 @@ def guess_symbols_file_type(symbols_file): } int main() { -EM_ASM({ _middle() }); +EM_ASM({ middle() }); } ''') cmd = [EMCC, 'src.c', '--emit-symbol-map'] + opts @@ -5448,11 +5446,11 @@ def test_bad_function_pointer_cast(self, wasm, safe): def test_bad_export(self): for m in ('', ' '): self.clear() - cmd = [EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=["' + m + '_main"]'] + cmd = [EMCC, test_file('hello_world.c'), '-sEXPORTS=["' + m + 'main"]'] print(cmd) stderr = self.run_process(cmd, stderr=PIPE, check=False).stderr if m: - self.assertContained('undefined exported symbol: " _main"', stderr) + self.assertContained('symbol exported via --export not found: main', stderr) else: self.assertContained('hello, world!', self.run_js('a.out.js')) @@ -6486,7 +6484,7 @@ def test_js_main(self): # try to add a main() from JS, at runtime. this is not supported (the # compiler needs to know at compile time about main). create_file('pre_main.js', r''' - Module['_main'] = () => {}; + Module['main'] = () => {}; ''') create_file('src.cpp', '') self.emcc_args += ['--pre-js', 'pre_main.js'] @@ -6824,23 +6822,33 @@ def test_modularize_sync_compilation(self): // It should be an object. console.log('typeof result: ' + typeof result); // And it should have the exports that Module has, showing it is Module in fact. -console.log('typeof _main: ' + typeof result._main); +console.log('typeof main: ' + typeof result.main); // And it should not be a Promise. console.log('typeof result.then: ' + typeof result.then); console.log('after'); ''') - self.run_process([EMCC, test_file('hello_world.c'), - '-sMODULARIZE', - '-sWASM_ASYNC_COMPILATION=0', - '--extern-post-js', 'post.js']) - self.assertContained('''\ + expected = '''\ before hello, world! typeof result: object -typeof _main: function +typeof main: function typeof result.then: undefined after -''', self.run_js('a.out.js')) +''' + self.do_runf(test_file('hello_world.c'), expected, emcc_args=['-sMODULARIZE', '-sWASM_ASYNC_COMPILATION=0', '--extern-post-js', 'post.js']) + + def test_modularize_argument_misuse(self): + create_file('test.c', ''' + #include + EMSCRIPTEN_KEEPALIVE int foo() { return 42; }''') + + create_file('post.js', r''' + var arg = { bar: 1 }; + var promise = Module(arg); + arg.foo();''') + + expected = "Aborted(Access to module property ('foo') is no longer possible via the module constructor argument; Instead, use the result of the module constructor" + self.do_runf('test.c', expected, assert_returncode=NON_ZERO, emcc_args=['--no-entry', '-sMODULARIZE', '--extern-post-js=post.js']) def test_export_all_3142(self): create_file('src.cpp', r''' @@ -7001,7 +7009,7 @@ def test_failing_alloc(self, growth): self.add_pre_run('growMemory = (size) => false;') for pre_fail, post_fail, opts in [ ('', '', []), - ('EM_ASM( Module.temp = _sbrk() );', 'EM_ASM( assert(Module.temp === _sbrk(), "must not adjust brk when an alloc fails!") );', []), + ('EM_ASM( Module.temp = sbrk() );', 'EM_ASM( assert(Module.temp === sbrk(), "must not adjust brk when an alloc fails!") );', []), ]: for aborting_args in ([], ['-sABORTING_MALLOC=0']): create_file('main.cpp', r''' @@ -7213,13 +7221,13 @@ def percent_diff(x, y): test('dce', main_args=['-sMAIN_MODULE=2'], library_args=[], expected=('is not a function', 'cannot', 'undefined'), assert_returncode=NON_ZERO) # with exporting, it works - dce = test('dce', main_args=['-sMAIN_MODULE=2', '-sEXPORTED_FUNCTIONS=_main,_puts'], library_args=[]) + dce = test('dce', main_args=['-sMAIN_MODULE=2', '-sEXPORTS=main,puts'], library_args=[]) # printf is not used in main, and we dce, so we failz dce_fail = test('dce_fail', main_args=['-sMAIN_MODULE=2'], library_args=['-DUSE_PRINTF'], expected=('is not a function', 'cannot', 'undefined'), assert_returncode=NON_ZERO) # exporting printf in main keeps it alive for the library - test('dce_save', main_args=['-sMAIN_MODULE=2', '-sEXPORTED_FUNCTIONS=_main,_printf,_puts'], library_args=['-DUSE_PRINTF']) + test('dce_save', main_args=['-sMAIN_MODULE=2', '-sEXPORTS=main,printf,puts'], library_args=['-DUSE_PRINTF']) self.assertLess(percent_diff(full[0], printf[0]), 4) self.assertLess(percent_diff(dce[0], dce_fail[0]), 4) @@ -7230,7 +7238,7 @@ def percent_diff(x, y): # mode 2, so dce in side, but library_func is not exported, so it is dce'd side_dce_fail = test('side_dce_fail', main_args=['-sMAIN_MODULE'], library_args=['-sSIDE_MODULE=2'], expected='cannot find side function') # mode 2, so dce in side, and library_func is not exported - side_dce_work = test('side_dce_fail', main_args=['-sMAIN_MODULE'], library_args=['-sSIDE_MODULE=2', '-sEXPORTED_FUNCTIONS=_library_func'], expected='hello from library') + side_dce_work = test('side_dce_fail', main_args=['-sMAIN_MODULE'], library_args=['-sSIDE_MODULE=2', '-sEXPORTS=library_func'], expected='hello from library') self.assertLess(side_dce_fail[1], 0.95 * side_dce_work[1]) # removing that function saves a chunk @@ -7844,7 +7852,7 @@ def test_js_lib_native_deps(self): addToLibrary({ depper__deps: ['memset'], depper: (ptr) => { - _memset(ptr, 'd'.charCodeAt(0), 10); + memset(ptr, 'd'.charCodeAt(0), 10); }, }); ''') @@ -8404,7 +8412,7 @@ def test(contents, expected, args=[], assert_returncode=0): # noqa self.do_runf('src.c', expected, emcc_args=args, assert_returncode=assert_returncode) # error shown (when assertions are on) - error = 'was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)' + error = 'was not exported. add it to EXPORTS (see the Emscripten FAQ)' test("Module.out('x')", error, assert_returncode=NON_ZERO) test("Module['out']('x')", error, assert_returncode=NON_ZERO) test("Module.err('x')", error, assert_returncode=NON_ZERO) @@ -9219,7 +9227,7 @@ def test_exceptions_stack_trace_and_message(self): # at run (test.js:4636:5) stack_trace_checks = [ 'std::runtime_error[:,][ ]?my message', # 'std::runtime_error: my message' for Emscripten EH - 'at (src.wasm.)?_?__cxa_throw', # '___cxa_throw' (JS symbol) for Emscripten EH + 'at (src.wasm.)?__cxa_throw', 'at (src.wasm.)?bar', 'at (src.wasm.)?foo', 'at (src.wasm.)?main'] @@ -9315,7 +9323,7 @@ def test_exceptions_rethrow_stack_trace_and_message(self): ''' rethrow_stack_trace_checks = [ 'std::runtime_error[:,][ ]?my message', # 'std::runtime_error: my message' for Emscripten EH - 'at ((src.wasm.)?_?__cxa_rethrow|___resumeException)', # '___resumeException' (JS symbol) for Emscripten EH + 'at ((src.wasm.)?__cxa_rethrow|__resumeException)', # '__resumeException' (JS symbol) for Emscripten EH 'at (src.wasm.)?foo', 'at (src.wasm.)?main'] @@ -9788,7 +9796,7 @@ def test_closure_type_annotations(self): testobj.bar(); /** Also keep alive certain library functions */ - Module['keepalive'] = [_emscripten_start_fetch, _emscripten_pause_main_loop, _SDL_AudioQuit]; + Module['keepalive'] = [emscripten_start_fetch, emscripten_pause_main_loop, SDL_AudioQuit]; ''' % methods) self.build(test_file('hello_world.c'), emcc_args=[ @@ -9941,7 +9949,7 @@ def test_extern_weak_dynamic(self): self.do_other_test('test_extern_weak.c', out_suffix='.resolved', emcc_args=['-sMAIN_MODULE=2', 'libside.wasm']) def test_main_module_without_main(self): - create_file('pre.js', 'Module.onRuntimeInitialized = () => Module._foo();') + create_file('pre.js', 'Module.onRuntimeInitialized = () => Module.foo();') create_file('src.c', r''' #include #include @@ -10697,7 +10705,7 @@ def test_dash_s_list_parsing(self): print(proc.stderr) if not expected: js = read_file('a.out.js') - for sym in ('_a', '_b', '_c', '_d'): + for sym in ('a', 'b', 'c', 'd'): self.assertContained(f'var {sym} = ', js) else: self.assertNotEqual(proc.returncode, 0) @@ -11063,7 +11071,7 @@ def test_no_invoke_functions_are_generated_if_exception_catching_is_disabled(sel for args in ([], ['-sWASM=0']): self.run_process([EMXX, test_file('hello_world.cpp'), '-sDISABLE_EXCEPTION_CATCHING', '-o', 'a.html'] + args) output = read_file('a.js') - self.assertContained('_main', output) # Smoke test that we actually compiled + self.assertContained('var main =', output) # Smoke test that we actually compiled self.assertNotContained('invoke_', output) # Verifies that only the minimal needed set of invoke_*() functions will be generated when C++ exceptions are enabled @@ -11942,7 +11950,7 @@ def test_modularize_assertions_on_ready_promise(self): # the instance you must use .then() to get a callback with the instance. create_file('test.js', r''' try { - Module()._main; + Module().main; } catch(e) { console.log(e); } @@ -11956,8 +11964,8 @@ def test_modularize_assertions_on_ready_promise(self): # 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) + 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. @@ -12592,7 +12600,7 @@ def test_emcc_size_parsing(self): def test_native_call_before_init(self): self.set_setting('ASSERTIONS') self.set_setting('EXPORTED_FUNCTIONS', ['_foo']) - self.add_pre_run('out("calling foo"); Module["_foo"]();') + self.add_pre_run('out("calling foo"); Module["foo"]();') create_file('foo.c', '#include \nint foo() { puts("foo called"); return 3; }') self.build('foo.c') out = self.run_js('foo.js', assert_returncode=NON_ZERO) @@ -12601,7 +12609,7 @@ def test_native_call_before_init(self): def test_native_call_after_exit(self): self.set_setting('ASSERTIONS') self.set_setting('EXIT_RUNTIME') - self.add_on_exit('out("calling main again"); Module["_main"]();') + self.add_on_exit('out("calling main again"); Module["main"]();') create_file('foo.c', '#include \nint main() { puts("foo called"); return 0; }') self.build('foo.c') out = self.run_js('foo.js', assert_returncode=NON_ZERO) @@ -12614,7 +12622,7 @@ def test_native_call_nargs(self): #include void foo(int arg) {} int main() { - EM_ASM(_foo(99, 100)); + EM_ASM(foo(99, 100)); } ''') self.build('foo.c') @@ -12724,12 +12732,12 @@ def test_missing_malloc_export(self): int main() { EM_ASM({ try { - _malloc(1); + malloc(1); } catch(e) { out('exception:', e); } try { - _free(); + free(); } catch(e) { out('exception:', e); } @@ -12801,7 +12809,7 @@ def test_SYSCALL_DEBUG(self): def test_LIBRARY_DEBUG(self): self.set_setting('LIBRARY_DEBUG') - self.do_runf('hello_world.c', '[library call:_fd_write: 0x00000001 (1)') + self.do_runf('hello_world.c', '[library call:fd_write: 0x00000001 (1)') def test_SUPPORT_LONGJMP_executable(self): err = self.expect_fail([EMCC, test_file('core/test_longjmp.c'), '-sSUPPORT_LONGJMP=0']) @@ -13018,7 +13026,7 @@ def test_split_module(self, customLoader, jspi, opt): if jspi: self.require_jspi() self.emcc_args += ['-g', '-sJSPI_EXPORTS=say_hello'] - self.emcc_args += ['-sEXPORTED_FUNCTIONS=_malloc,_free'] + self.emcc_args += ['-sEXPORTS=malloc,free'] output = self.do_other_test('test_split_module.c') if jspi: # TODO remove this when https://chromium-review.googlesource.com/c/v8/v8/+/4159854 @@ -13060,7 +13068,7 @@ def test_split_main_module(self): self.emcc_args += ['-g'] self.emcc_args += ['-sMAIN_MODULE=2'] - self.emcc_args += ['-sEXPORTED_FUNCTIONS=_printf,_malloc,_free'] + self.emcc_args += ['-sEXPORTS=printf,malloc,free'] self.emcc_args += ['-sSPLIT_MODULE', '-Wno-experimental'] self.emcc_args += ['--embed-file', 'libhello.wasm'] self.emcc_args += ['--post-js', post_js] @@ -13160,7 +13168,7 @@ def test_em_js_side_module(self): def test_em_js_main_module(self): self.set_setting('MAIN_MODULE', 2) - self.set_setting('EXPORTED_FUNCTIONS', '_main,_malloc') + self.set_setting('EXPORTS', 'main,malloc') self.do_runf('core/test_em_js.cpp') def test_em_js_main_module_address(self): @@ -13840,7 +13848,7 @@ def test_hello_function(self): # (It seems odd that we ship the entire test/ directory to all our users and # reference them in our docs. Should we move this file to somewhere else such # as `examples/`?) - self.run_process([EMCC, test_file('hello_function.cpp'), '-o', 'function.html', '-sEXPORTED_FUNCTIONS=_int_sqrt', '-sEXPORTED_RUNTIME_METHODS=ccall,cwrap']) + self.run_process([EMCC, test_file('hello_function.cpp'), '-o', 'function.html', '-sEXPORTS=int_sqrt,ccall,cwrap']) @parameterized({ '': ([],), @@ -13998,7 +14006,7 @@ def test_fetch_init_node(self): puts("ok"); } ''') - self.do_runf('src.c', 'ok', emcc_args=['-sFETCH', '-sEXPORTED_RUNTIME_METHODS=Fetch']) + self.do_runf('src.c', 'ok', emcc_args=['-sFETCH', '-sEXPORTS=Fetch,main']) # Test that using llvm-nm works when response files are in use, and inputs are linked using relative paths. # llvm-nm has a quirk that it does not remove escape chars when printing out filenames. @@ -14036,7 +14044,7 @@ def test_stdint_limits(self): self.do_other_test('test_stdint_limits.c') def test_legacy_runtime(self): - self.set_setting('EXPORTED_FUNCTIONS', ['_malloc', '_main']) + self.set_setting('EXPORTS', ['malloc', 'main']) self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', ['$intArrayFromString', '$ALLOC_NORMAL']) # By default `LEGACY_RUNTIME` is disabled and `allocate` is not available. @@ -14153,7 +14161,7 @@ def test_unsafe_optimizations(self): def test_extended_const(self): self.v8_args += ['--experimental-wasm-extended-const'] # Export at least one global so that we exercise the parsing of the global section. - self.do_runf('hello_world.c', emcc_args=['-sEXPORTED_FUNCTIONS=_main,___stdout_used', '-mextended-const', '-sMAIN_MODULE=2']) + self.do_runf('hello_world.c', emcc_args=['-sEXPORTS=main,__stdout_used', '-mextended-const', '-sMAIN_MODULE=2']) wat = self.get_wasm_text('hello_world.wasm') # Test that extended-const expressions are used in the data segments. self.assertContained(r'\(data (\$\S+ )?\(offset \(i32.add\s+\(global.get \$\S+\)\s+\(i32.const \d+\)', wat, regex=True) @@ -14562,7 +14570,7 @@ def test_googletest(self): def test_parseTools_legacy(self): create_file('post.js', ''' - err(_foo()); + err(foo()); ''') create_file('lib.js', ''' addToLibrary({ @@ -14984,7 +14992,7 @@ def test_memory64_proxies(self): '-sINITIAL_MEMORY=5gb', '-sMAXIMUM_MEMORY=5gb', '-sALLOW_MEMORY_GROWTH', - '-sEXPORTED_FUNCTIONS=_malloc,_main', + '-sEXPORTS=malloc,main', '-Wno-experimental', '--extern-post-js', test_file('other/test_memory64_proxies.js')]) self.run_js('a.out.js') diff --git a/test/test_override_system_js_lib_symbol.js b/test/test_override_system_js_lib_symbol.js index eab127fa67dad..76b7bf5b7efac 100644 --- a/test/test_override_system_js_lib_symbol.js +++ b/test/test_override_system_js_lib_symbol.js @@ -6,9 +6,9 @@ addToLibrary({ glTexImage3D__deps: ['orig_glTexImage3D'], glTexImage3D: function(target, level, internalFormat, width, height, depth, border, format, type, pixels) { - _glTexImage3D.createdType = type; + glTexImage3D.createdType = type; // Check that the original fuction exists - assert(_orig_glTexImage3D); + assert(orig_glTexImage3D); // Also try invoking glTexImage3D to verify that it is actually the // underlying function from library_webgl2.js var texImage3D_called = false; @@ -18,11 +18,11 @@ addToLibrary({ texImage3D_called = true; }, }; - _orig_glTexImage3D(); + orig_glTexImage3D(); assert(texImage3D_called); }, what_got_created: function() { - return _glTexImage3D.createdType; + return glTexImage3D.createdType; } }); diff --git a/tools/acorn-optimizer.mjs b/tools/acorn-optimizer.mjs index e5e36f55edd11..3666082a6f893 100755 --- a/tools/acorn-optimizer.mjs +++ b/tools/acorn-optimizer.mjs @@ -658,15 +658,15 @@ function emitDCEGraph(ast) { // The exports are trickier, as they have a different form whether or not // async compilation is enabled. It can be either: // - // var _malloc = Module['_malloc'] = wasmExports['_malloc']; + // var malloc = Module['malloc'] = wasmExports['malloc']; // // or // - // var _malloc = wasmExports['_malloc']; + // var malloc = wasmExports['malloc']; // // or // - // var _malloc = Module['_malloc'] = (x) => wasmExports['_malloc'](x); + // var malloc = Module['malloc'] = (x) => wasmExports['malloc'](x); // // or, in the minimal runtime, it looks like // @@ -674,7 +674,7 @@ function emitDCEGraph(ast) { // var wasmExports = output.instance.exports; // may also not have "var", if // // declared outside and used elsewhere // .. - // _malloc = wasmExports["malloc"]; + // malloc = wasmExports["malloc"]; // .. // }); const imports = []; diff --git a/tools/building.py b/tools/building.py index c070e540636f1..17c3e154797b7 100644 --- a/tools/building.py +++ b/tools/building.py @@ -29,8 +29,8 @@ from .shared import run_process, check_call, exit_with_error from .shared import path_from_root from .shared import asmjs_mangle, DEBUG -from .shared import LLVM_DWARFDUMP, demangle_c_symbol_name -from .shared import get_emscripten_temp_dir, exe_suffix, is_c_symbol +from .shared import LLVM_DWARFDUMP +from .shared import get_emscripten_temp_dir, exe_suffix from .utils import WINDOWS from .settings import settings from .feature_matrix import UNSUPPORTED @@ -111,7 +111,6 @@ def side_module_external_deps(external_symbols): """ deps = set() for sym in settings.SIDE_MODULE_IMPORTS: - sym = demangle_c_symbol_name(sym) if sym in external_symbols: deps = deps.union(external_symbols[sym]) return sorted(list(deps)) @@ -174,16 +173,14 @@ def lld_flags_for_executable(external_symbols): # removed when __cxa_atexit is a no-op. cmd.append('-u__cxa_atexit') - c_exports = [e for e in settings.EXPORTED_FUNCTIONS if is_c_symbol(e)] - # Strip the leading underscores - c_exports = [demangle_c_symbol_name(e) for e in c_exports] # Filter out symbols external/JS symbols - c_exports = [e for e in c_exports if e not in external_symbols] + c_exports = [e for e in settings.EXPORTS if e not in external_symbols and '$' + e not in + external_symbols] c_exports += settings.REQUIRED_EXPORTS if settings.MAIN_MODULE: c_exports += side_module_external_deps(external_symbols) for export in c_exports: - if settings.ERROR_ON_UNDEFINED_SYMBOLS: + if settings.ERROR_ON_UNDEFINED_SYMBOLS and diagnostics.is_enabled('undefined'): cmd.append('--export=' + export) else: cmd.append('--export-if-defined=' + export) @@ -560,14 +557,25 @@ def closure_compiler(filename, advanced=True, extra_closure_args=None): if settings.USE_WEBGPU: CLOSURE_EXTERNS += [path_from_root('src/closure-externs/webgpu-externs.js')] - # Closure compiler needs to know about all exports that come from the wasm module, because to optimize for small code size, - # the exported symbols are added to global scope via a foreach loop in a way that evades Closure's static analysis. With an explicit - # externs file for the exports, Closure is able to reason about the exports. + # Closure compiler needs to know about all exports that come from the wasm module, because to + # optimize for small code size, the exported symbols are added to global scope via a foreach loop + # in a way that evades Closure's static analysis. With an explicit externs file for the exports, + # Closure is able to reason about the exports. if settings.WASM_EXPORTS and not settings.DECLARE_ASM_MODULE_EXPORTS: # Generate an exports file that records all the exported symbols from the wasm module. - module_exports_suppressions = '\n'.join(['/**\n * @suppress {duplicate, undefinedVars}\n */\nvar %s;\n' % asmjs_mangle(i) for i in settings.WASM_EXPORTS]) + module_exports_suppressions = [] + + def add_suppression(sym): + module_exports_suppressions.append('/**\n * @suppress {duplicate, undefinedVars}\n */\nvar %s;\n' % sym) + + for sym in settings.WASM_EXPORTS: + add_suppression(sym) + if sym == '__main_argc_argv': + add_suppression('main') + if settings.MANGLED_SYMBOLS: + add_suppression(asmjs_mangle(sym)) exports_file = shared.get_temp_files().get('.js', prefix='emcc_module_exports_') - exports_file.write(module_exports_suppressions.encode()) + exports_file.write('\n'.join(module_exports_suppressions).encode()) exports_file.close() CLOSURE_EXTERNS += [exports_file.name] @@ -783,7 +791,7 @@ def metadce(js_file, wasm_file, debug_info, last): # Ignore exported wasm globals. Those get inlined directly into the JS code. exports = sorted(set(settings.WASM_EXPORTS) - set(settings.WASM_GLOBAL_EXPORTS)) - extra_info = '{ "exports": [' + ','.join(f'["{asmjs_mangle(x)}", "{x}"]' for x in exports) + ']}' + extra_info = '{ "exports": [' + ','.join(f'["{x}", "{x}"]' for x in exports) + ']}' txt = acorn_optimizer(js_file, ['emitDCEGraph', '--no-print'], return_output=True, extra_info=extra_info) if shared.SKIP_SUBPROCS: @@ -794,7 +802,8 @@ def metadce(js_file, wasm_file, debug_info, last): required_symbols = user_requested_exports.union(set(settings.SIDE_MODULE_IMPORTS)) for item in graph: if 'export' in item: - export = asmjs_mangle(item['export']) + export = item['export'] + # export = asmjs_mangle(export) if settings.EXPORT_ALL or export in required_symbols: item['root'] = True @@ -1269,3 +1278,82 @@ def get_emcc_node_flags(node_version): # 10.1.7 will turn into "100107". str_node_version = "%02d%02d%02d" % node_version return [f'-sMIN_NODE_VERSION={str_node_version}'] + + +def get_runtime_symbols(): + runtime_symbols = [ + 'run', + 'addOnPreRun', + 'addOnInit', + 'addOnPreMain', + 'addOnExit', + 'addOnPostRun', + 'addRunDependency', + 'removeRunDependency', + 'out', + 'err', + 'callMain', + 'abort', + 'wasmMemory', + 'wasmExports', + 'HEAPF32', + 'HEAPF64', + 'HEAP_DATA_VIEW', + 'HEAP8', + 'HEAPU8', + 'HEAP16', + 'HEAPU16', + 'HEAP32', + 'HEAPU32', + 'HEAP64', + 'HEAPU64', + ] + + if settings.PTHREADS and settings.ALLOW_MEMORY_GROWTH: + runtime_symbols += [ + 'GROWABLE_HEAP_I8', + 'GROWABLE_HEAP_U8', + 'GROWABLE_HEAP_I16', + 'GROWABLE_HEAP_U16', + 'GROWABLE_HEAP_I32', + 'GROWABLE_HEAP_U32', + 'GROWABLE_HEAP_F32', + 'GROWABLE_HEAP_F64', + ] + + if settings.USE_OFFSET_CONVERTER: + runtime_symbols.append('WasmOffsetConverter') + + if settings.LOAD_SOURCE_MAP: + runtime_symbols.append('WasmSourceMap') + + if settings.STACK_OVERFLOW_CHECK: + runtime_symbols.append('writeStackCookie') + runtime_symbols.append('checkStackCookie') + + if settings.SUPPORT_BASE64_EMBEDDING: + runtime_symbols.append('intArrayFromBase64') + runtime_symbols.append('tryParseAsDataURI') + + if settings.RETAIN_COMPILER_SETTINGS: + runtime_symbols.append('getCompilerSetting') + + if settings.RUNTIME_DEBUG: + runtime_symbols.append('prettyPrint') + + # dynCall_* methods are not hardcoded here, as they + # depend on the file being compiled. check for them + # and add them. + for e in settings.EXPORTS: + if e.startswith('dynCall_'): + # a specific dynCall; add to the list + runtime_symbols.append(e) + + # Only export legacy runtime elements when explicitly + # requested. + # for e in settings.EXPORTS: + # if e in if legacyRuntimeElements: + # const newName = legacyRuntimeElements.get(name); + # warn(`deprecated item in EXPORTED_RUNTIME_METHODS: ${name} use ${newName} instead.`) + # runtimeElements.push(name) + return runtime_symbols diff --git a/tools/emscripten.py b/tools/emscripten.py index f13391b5be020..0b7657bc1991a 100644 --- a/tools/emscripten.py +++ b/tools/emscripten.py @@ -58,7 +58,15 @@ def compute_minimal_runtime_initializer_and_exports(post, exports, receiving): # way that minifies well with Closure # e.g. var a,b,c,d,e,f; - exports = [asmjs_mangle(x) for x in exports if x != building.WASM_CALL_CTORS] + exports = [x for x in exports if x != building.WASM_CALL_CTORS] + + # We export __main_argc_argv` as `main` + if '__main_argc_argv' in exports: + exports[exports.index('__main_argc_argv')] = 'main' + + if settings.MANGLED_SYMBOLS: + # We still support mangling the exports + exports += [asmjs_mangle(x) for x in exports] declares = 'var ' + ',\n '.join(exports) + ';' post = shared.do_replace(post, '<<< WASM_MODULE_EXPORTS_DECLARES >>>', declares) @@ -93,8 +101,7 @@ def maybe_disable_filesystem(imports): else: # TODO(sbc): Find a better way to identify wasi syscalls syscall_prefixes = ('__syscall_', 'fd_') - side_module_imports = [shared.demangle_c_symbol_name(s) for s in settings.SIDE_MODULE_IMPORTS] - all_imports = set(imports).union(side_module_imports) + all_imports = set(imports).union(settings.SIDE_MODULE_IMPORTS) syscalls = {d for d in all_imports if d.startswith(syscall_prefixes) or d == 'path_open'} # check if the only filesystem syscalls are in: close, ioctl, llseek, write # (without open, etc.. nothing substantial can be done, so we can disable @@ -231,11 +238,11 @@ def report_missing_exports_wasm_only(metadata): diagnostics.warning('undefined', f'undefined exported symbol: "{symbol}"') -def report_missing_exports(js_symbols): +def report_missing_exports(js_symbols, runtime_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 = set(settings.WASM_EXPORTS).union(js_symbols).union(runtime_symbols) missing = set(settings.USER_EXPORTS) - defined_symbols for symbol in sorted(missing): diagnostics.warning('undefined', f'undefined exported symbol: "{symbol}"') @@ -290,18 +297,23 @@ def trim_asm_const_body(body): def create_global_exports(global_exports): lines = [] - for k, v in global_exports.items(): - if building.is_internal_global(k): + for name, value in global_exports.items(): + if building.is_internal_global(name): continue - v = int(v) + value = int(value) if settings.RELOCATABLE: - v += settings.GLOBAL_BASE - mangled = asmjs_mangle(k) + value += settings.GLOBAL_BASE if settings.MINIMAL_RUNTIME: - lines.append("var %s = %s;" % (mangled, v)) + lines.append("var %s = %s;" % (name, value)) else: - lines.append("var %s = Module['%s'] = %s;" % (mangled, mangled, v)) + lines.append("var %s = Module['%s'] = %s;" % (name, name, value)) + if settings.MANGLED_SYMBOLS: + mangled = asmjs_mangle(name) + if settings.MINIMAL_RUNTIME: + lines.append("var %s = %s;" % (mangled, name)) + else: + lines.append("var %s = Module['%s'] = %s;" % (mangled, mangled, name)) return '\n'.join(lines) @@ -419,7 +431,15 @@ def emscript(in_wasm, out_wasm, outfile_js, js_syms, finalize=True, base_metadat pre += f" ignoredModuleProp('{sym}');\n" pre += "}\n" - report_missing_exports(forwarded_json['librarySymbols']) + runtime_symbols = set(building.get_runtime_symbols()) + js_symbols = set(s[1:] if s[0] == '$' else s for s in forwarded_json['librarySymbols']) + report_missing_exports(js_symbols, runtime_symbols) + + missing_exports = set(settings.EXPORTS) - js_symbols - set(settings.WASM_EXPORTS) + runtime_exports = '\n// exported runtime symbols\n' + for r in sorted(missing_exports): + if r in runtime_symbols: + runtime_exports += f"Module['{r}'] = {r};\n" if settings.MINIMAL_RUNTIME: # In MINIMAL_RUNTIME, atinit exists in the postamble part @@ -469,6 +489,8 @@ def emscript(in_wasm, out_wasm, outfile_js, js_syms, finalize=True, base_metadat write_output_file(out, module) + out.write(runtime_exports) + out.write(post) module = None @@ -578,7 +600,7 @@ def finalize_wasm(infile, outfile, js_syms): if settings.GENERATE_SOURCE_MAP: building.save_intermediate(outfile + '.map', 'post_finalize.map') - expected_exports = set(settings.EXPORTED_FUNCTIONS) + expected_exports = set(settings.EXPORTS) expected_exports.update(asmjs_mangle(s) for s in settings.REQUIRED_EXPORTS) expected_exports.update(asmjs_mangle(s) for s in settings.EXPORT_IF_DEFINED) # Assume that when JS symbol dependencies are exported it is because they @@ -592,27 +614,26 @@ def finalize_wasm(infile, outfile, js_syms): # These are any exports that were not requested on the command line and are # not known auto-generated system functions. unexpected_exports = [e for e in metadata.all_exports if treat_as_user_export(e)] - unexpected_exports = [asmjs_mangle(e) for e in unexpected_exports] unexpected_exports = [e for e in unexpected_exports if e not in expected_exports] if not settings.STANDALONE_WASM and 'main' in metadata.all_exports or '__main_argc_argv' in metadata.all_exports: - if 'EXPORTED_FUNCTIONS' in user_settings and '_main' not in settings.USER_EXPORTS: - # If `_main` was unexpectedly exported we assume it was added to + if 'EXPORTS' in user_settings and 'main' not in settings.USER_EXPORTS: + # If `main` was unexpectedly exported we assume it was added to # EXPORT_IF_DEFINED by `phase_linker_setup` in order that we can detect # it and report this warning. After reporting the warning we explicitly # ignore the export and run as if there was no main function since that - # is defined is behaviour for programs that don't include `_main` in - # EXPORTED_FUNCTIONS. - diagnostics.warning('unused-main', '`main` is defined in the input files, but `_main` is not in `EXPORTED_FUNCTIONS`. Add it to this list if you want `main` to run.') + # is defined is behaviour for programs that don't include `main` in + # EXPORTS. + diagnostics.warning('unused-main', '`main` is defined in the input files, but `main` is not in export list. Add it to this list if you want `main` to run.') if 'main' in metadata.all_exports: metadata.all_exports.remove('main') else: metadata.all_exports.remove('__main_argc_argv') else: - unexpected_exports.append('_main') + unexpected_exports.append('main') building.user_requested_exports.update(unexpected_exports) - settings.EXPORTED_FUNCTIONS.extend(unexpected_exports) + settings.EXPORTS.extend(unexpected_exports) return metadata @@ -661,14 +682,14 @@ def create_tsd(metadata, embind_tsd): # Manually generate defintions for any Wasm function exports. out += 'interface WasmModule {\n' for name, functype in metadata.function_exports.items(): - mangled = asmjs_mangle(name) - should_export = settings.EXPORT_KEEPALIVE and mangled in settings.EXPORTED_FUNCTIONS + should_export = settings.EXPORT_KEEPALIVE and name in settings.EXPORTS if not should_export: continue arguments = [] for index, type in enumerate(functype.params): arguments.append(f"_{index}: {type_to_ts_type(type)}") - out += f' {mangled}({", ".join(arguments)}): ' + name = asmjs_mangle(name) + out += f' {name}({", ".join(arguments)}): ' assert len(functype.returns) <= 1, 'One return type only supported' if functype.returns: out += f'{type_to_ts_type(functype.returns[0])}' @@ -832,41 +853,36 @@ def add_standard_wasm_imports(send_items_map): send_items_map[s] = s -def create_sending(metadata, library_symbols): +def is_c_library_symbol(s): + return not s.startswith('$') + + +def create_sending(metadata, js_symbols): # Map of wasm imports to mangled/external/JS names send_items_map = {} 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 - else: - send_items_map[name] = asmjs_mangle(name) + send_items_map[name] = name add_standard_wasm_imports(send_items_map) if settings.MAIN_MODULE: # When including dynamic linking support, also add any JS library functions - # that are part of EXPORTED_FUNCTIONS (or in the case of MAIN_MODULE=1 add + # that are part of EXPORTS (or in the case of MAIN_MODULE=1 add # all JS library functions). This allows `dlsym(RTLD_DEFAULT)` to lookup JS # library functions, since `wasmImports` acts as the global symbol table. wasm_exports = set(metadata.function_exports) - library_symbols = set(library_symbols) + js_symbols = set(js_symbols) if settings.MAIN_MODULE == 1: - for f in library_symbols: - if shared.is_c_symbol(f): - demangled = shared.demangle_c_symbol_name(f) - if demangled in wasm_exports: - continue - send_items_map[demangled] = f + for f in js_symbols: + if is_c_library_symbol(f) and f not in wasm_exports: + send_items_map[f] = f else: - for f in settings.EXPORTED_FUNCTIONS + settings.SIDE_MODULE_IMPORTS: - if f in library_symbols and shared.is_c_symbol(f): - demangled = shared.demangle_c_symbol_name(f) - if demangled in wasm_exports: - continue - send_items_map[demangled] = f + for f in settings.EXPORTS + settings.SIDE_MODULE_IMPORTS: + if f in js_symbols and f not in wasm_exports: + send_items_map[f] = f sorted_items = sorted(send_items_map.items()) prefix = '' @@ -907,20 +923,29 @@ def install_wrapper(sym): for name, types in function_exports.items(): nargs = len(types.params) - mangled = asmjs_mangle(name) - wrapper = 'var %s = ' % mangled + wrapper = 'var %s = ' % name # TODO(sbc): Can we avoid exporting the dynCall_ functions on the module. - should_export = settings.EXPORT_KEEPALIVE and mangled in settings.EXPORTED_FUNCTIONS + should_export = settings.EXPORT_KEEPALIVE and name in settings.EXPORTS + exported = '' if (name.startswith('dynCall_') and settings.MODULARIZE != 'instance') or should_export: + mangled = asmjs_mangle(name) + if settings.MANGLED_SYMBOLS: + export_name = mangled + else: + export_name = name if settings.MODULARIZE == 'instance': # Update the export declared at the top level. - wrapper += f" __exp_{mangled} = " + wrapper += f' __exp_{export_name} = ' else: - exported = "Module['%s'] = " % mangled - else: - exported = '' - wrapper += exported + exported += f"Module['{export_name}'] = " + if settings.MANGLED_SYMBOLS and name != mangled: + exported += f'{mangled} = ' + wrappers.append(f'var {mangled};') + if name == '__main_argc_argv': + wrappers.append('var main;') + exported += 'main = ' + wrapper += exported if settings.ASSERTIONS and install_wrapper(name): # With assertions enabled we create a wrapper that are calls get routed through, for @@ -931,7 +956,7 @@ def install_wrapper(sym): # first use. args = [f'a{i}' for i in range(nargs)] args = ', '.join(args) - wrapper += f"({args}) => ({mangled} = {exported}wasmExports['{name}'])({args});" + wrapper += f"({args}) => ({name} = {exported}wasmExports['{name}'])({args});" else: wrapper += f"wasmExports['{name}']" @@ -950,21 +975,29 @@ def create_receiving(function_exports): if settings.MINIMAL_RUNTIME: # In Wasm exports are assigned inside a function to variables # existing in top level JS scope, i.e. - # var _main; + # var main; # WebAssembly.instantiate(Module['wasm'], imports).then((output) => { # var wasmExports = output.instance.exports; - # _main = wasmExports["_main"]; + # main = wasmExports["main"]; generate_dyncall_assignment = settings.DYNCALLS and '$dynCall' in settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE exports_that_are_not_initializers = [x for x in function_exports if x != building.WASM_CALL_CTORS] - for s in exports_that_are_not_initializers: - mangled = asmjs_mangle(s) - dynCallAssignment = ('dynCalls["' + s.replace('dynCall_', '') + '"] = ') if generate_dyncall_assignment and mangled.startswith('dynCall_') else '' - should_export = settings.EXPORT_ALL or (settings.EXPORT_KEEPALIVE and mangled in settings.EXPORTED_FUNCTIONS) + for name in exports_that_are_not_initializers: + dynCallAssignment = ('dynCalls["' + name.replace('dynCall_', '') + '"] = ') if generate_dyncall_assignment and name.startswith('dynCall_') else '' + should_export = settings.EXPORT_ALL or (settings.EXPORT_KEEPALIVE and name in settings.EXPORTS) export_assignment = '' + if name == '__main_argc_argv': + export_name = 'main' + else: + export_name = name + mangled = asmjs_mangle(name) if settings.MODULARIZE and should_export: - export_assignment = f"Module['{mangled}'] = " - receiving += [f'{export_assignment}{dynCallAssignment}{mangled} = wasmExports["{s}"]'] + export_assignment += f"Module['{export_name}'] = " + if settings.MANGLED_SYMBOLS: + export_assignment += f"Module['{mangled}'] = " + if settings.MANGLED_SYMBOLS: + export_assignment += f'{mangled} = ' + receiving += [f"{export_assignment}{dynCallAssignment}{export_name} = wasmExports['{name}']"] else: receiving += make_export_wrappers(function_exports) @@ -974,11 +1007,11 @@ def create_receiving(function_exports): return '\n'.join(receiving) + '\n' -def create_module(receiving, metadata, global_exports, library_symbols): +def create_module(receiving, metadata, global_exports, js_symbols): receiving += create_global_exports(global_exports) module = [] - sending = create_sending(metadata, library_symbols) + sending = create_sending(metadata, js_symbols) if settings.PTHREADS: sending = textwrap.indent(sending, ' ').strip() module.append('''\ diff --git a/tools/js_manipulation.py b/tools/js_manipulation.py index 7790790b7c3f7..a8639f3e1fdbe 100644 --- a/tools/js_manipulation.py +++ b/tools/js_manipulation.py @@ -152,7 +152,7 @@ def make_invoke(sig): } catch(e) { stackRestore(sp); %s - _setThrew(1, 0);%s + setThrew(1, 0);%s } }''' % (sig, ','.join(args), body, maybe_rethrow, exceptional_ret) diff --git a/tools/link.py b/tools/link.py index c554bf3e1292c..5ada7f3accda0 100644 --- a/tools/link.py +++ b/tools/link.py @@ -636,6 +636,21 @@ def check_browser_versions(): @ToolchainProfiler.profile_block('linker_setup') def phase_linker_setup(options, state, newargs): + if 'EXPORTS' in user_settings: + if 'EXPORTED_FUNCTIONS' in user_settings: + exit_with_error('EXPORTS and EXPORTED_FUNCTIONS are mutually exclusive') + if 'EXPORTED_RUNTIME_METHODS' in user_settings: + exit_with_error('EXPORTS and EXPORTED_RUNTIME_METHODS are mutually exclusive') + if 'EXTRA_EXPORTED_RUNTIME_METHODS' in user_settings: + exit_with_error('EXPORTS and EXTRA_EXPORTED_RUNTIME_METHODS are mutually exclusive') + else: + settings.EXPORTS = [shared.demangle_legacy_symbol_name(s) for s in settings.EXPORTED_FUNCTIONS] + settings.EXPORTS += settings.EXPORTED_RUNTIME_METHODS + settings.EXPORTS += settings.EXTRA_EXPORTED_RUNTIME_METHODS + + # used for warnings in emscripten.py + settings.USER_EXPORTS = settings.EXPORTS.copy() + system_libpath = '-L' + str(cache.get_lib_dir(absolute=True)) state.append_link_flag(system_libpath) @@ -645,6 +660,10 @@ def phase_linker_setup(options, state, newargs): if not shared.SKIP_SUBPROCS: shared.check_llvm_version() + if settings.SAFE_HEAP: + settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.append('segfault') + settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.append('alignfault') + autoconf = os.environ.get('EMMAKEN_JUST_CONFIGURE') or 'conftest.c' in state.orig_args or 'conftest.cpp' in state.orig_args if autoconf: # configure tests want a more shell-like style, where we emit return codes on exit() @@ -720,9 +739,6 @@ def phase_linker_setup(options, state, newargs): if s in user_settings: diagnostics.warning('deprecated', f'{s} is deprecated ({reason}). Please open a bug if you have a continuing need for this setting') - if settings.EXTRA_EXPORTED_RUNTIME_METHODS: - settings.EXPORTED_RUNTIME_METHODS += settings.EXTRA_EXPORTED_RUNTIME_METHODS - # If no output format was specified we try to deduce the format based on # the output filename extension if not options.oformat and (options.relocatable or (options.shared and not settings.SIDE_MODULE)): @@ -799,7 +815,7 @@ def phase_linker_setup(options, state, newargs): settings.STANDALONE_WASM = 1 if settings.LZ4: - settings.EXPORTED_RUNTIME_METHODS += ['LZ4'] + settings.EXPORTS += ['LZ4'] if settings.PURE_WASI: settings.STANDALONE_WASM = 1 @@ -813,18 +829,18 @@ def phase_linker_setup(options, state, newargs): if options.no_entry: settings.EXPECT_MAIN = 0 elif settings.STANDALONE_WASM: - if '_main' in settings.EXPORTED_FUNCTIONS: + if 'main' in settings.EXPORTS: # TODO(sbc): Make this into a warning? - logger.debug('including `_main` in EXPORTED_FUNCTIONS is not necessary in standalone mode') + logger.debug('including `main` in export list is not necessary in standalone mode') else: - # In normal non-standalone mode we have special handling of `_main` in EXPORTED_FUNCTIONS. - # 1. If the user specifies exports, but doesn't include `_main` we assume they want to build a + # In normal non-standalone mode we have special handling of `main` in EXPORTS. + # 1. If the user specifies exports, but doesn't include `main` we assume they want to build a # reactor. - # 2. If the user doesn't export anything we default to exporting `_main` (unless `--no-entry` + # 2. If the user doesn't export anything we default to exporting `main` (unless `--no-entry` # is specified (see above). - if 'EXPORTED_FUNCTIONS' in user_settings: - if '_main' in settings.USER_EXPORTS: - settings.EXPORTED_FUNCTIONS.remove('_main') + if 'EXPORTS' in user_settings: + if 'main' in settings.USER_EXPORTS: + settings.EXPORTS.remove('main') settings.EXPORT_IF_DEFINED.append('main') else: settings.EXPECT_MAIN = 0 @@ -851,9 +867,9 @@ def phase_linker_setup(options, state, newargs): exit_with_error('MINIMAL_RUNTIME reduces JS size, and is incompatible with STANDALONE_WASM which focuses on ignoring JS anyhow and being 100% wasm') # Note the exports the user requested - building.user_requested_exports.update(settings.EXPORTED_FUNCTIONS) + building.user_requested_exports.update(settings.EXPORTS) - if '_main' in settings.EXPORTED_FUNCTIONS or 'main' in settings.EXPORT_IF_DEFINED: + if 'main' in settings.EXPORTS or 'main' in settings.EXPORT_IF_DEFINED: settings.EXPORT_IF_DEFINED.append('__main_argc_argv') elif settings.ASSERTIONS and not settings.STANDALONE_WASM: # In debug builds when `main` is not explicitly requested as an @@ -909,6 +925,7 @@ def phase_linker_setup(options, state, newargs): default_setting('DEFAULT_TO_CXX', 0) default_setting('IGNORE_MISSING_MAIN', 0) default_setting('AUTO_NATIVE_LIBRARIES', 0) + default_setting('MANGLED_SYMBOLS', 0) if settings.MAIN_MODULE != 1: # These two settings cannot be disabled with MAIN_MODULE=1 because all symbols # are needed in this mode. @@ -925,15 +942,17 @@ def phase_linker_setup(options, state, newargs): if not settings.MINIMAL_RUNTIME and not settings.STRICT: # Export the HEAP object by default, when not running in STRICT mode - settings.EXPORTED_RUNTIME_METHODS.extend([ + settings.EXPORTS.extend([ 'HEAPF32', 'HEAPF64', - 'HEAP_DATA_VIEW', 'HEAP8', 'HEAPU8', 'HEAP16', 'HEAPU16', 'HEAP32', 'HEAPU32', - 'HEAP64', 'HEAPU64', ]) + if settings.SUPPORT_BIG_ENDIAN: + settings.EXPORTS.append('HEAP_DATA_VIEW') + if settings.WASM_BIGINT: + settings.EXPORTS.extend(['HEAP64', 'HEAPU64']) # Default to TEXTDECODER=2 (always use TextDecoder to decode UTF-8 strings) # in -Oz builds, since custom decoder for UTF-8 takes up space. @@ -1021,7 +1040,7 @@ def phase_linker_setup(options, state, newargs): settings.LINKABLE = 1 if settings.LINKABLE and settings.USER_EXPORTS: - diagnostics.warning('unused-command-line-argument', 'EXPORTED_FUNCTIONS is not valid with LINKABLE set (normally due to SIDE_MODULE=1/MAIN_MODULE=1) since all functions are exported this mode. To export only a subset use SIDE_MODULE=2/MAIN_MODULE=2') + diagnostics.warning('unused-command-line-argument', 'specifying exports is not valid with LINKABLE set (normally due to SIDE_MODULE=1/MAIN_MODULE=1) since all functions are exported this mode. To export only a subset use SIDE_MODULE=2/MAIN_MODULE=2') if settings.MAIN_MODULE: settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += [ @@ -1118,8 +1137,8 @@ def phase_linker_setup(options, state, newargs): 'emscripten_stack_get_current', ] - # We call one of these two functions during startup which caches the stack limits - # in wasm globals allowing get_base/get_free to be super fast. + # stackCheckInit calls one of these two functions duing startup which caches + # the stack limits in wasm globals allowing get_base/get_free to be super fast. # See compiler-rt/stack_limits.S. if settings.RELOCATABLE: settings.REQUIRED_EXPORTS += ['emscripten_stack_set_limits'] @@ -1190,7 +1209,7 @@ def phase_linker_setup(options, state, newargs): if settings.STB_IMAGE: state.append_link_flag('-lstb_image') - settings.EXPORTED_FUNCTIONS += ['_stbi_load', '_stbi_load_from_memory', '_stbi_image_free'] + settings.EXPORTS += ['_stbi_load', '_stbi_load_from_memory', '_stbi_image_free'] if settings.USE_WEBGL2: settings.MAX_WEBGL_VERSION = 2 @@ -1397,14 +1416,14 @@ def phase_linker_setup(options, state, newargs): # all symbols that the audio worklet scope needs onto the Module object. # 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'] + settings.EXPORTS += ['stackSave', 'stackAlloc', 'stackRestore', 'wasmTable'] if settings.FORCE_FILESYSTEM and not settings.MINIMAL_RUNTIME: # when the filesystem is forced, we export by default methods that filesystem usage # may need, including filesystem usage from standalone file packager output (i.e. # file packages not built together with emcc, but that are loaded at runtime # separately, and they need emcc's output to contain the support they need) - settings.EXPORTED_RUNTIME_METHODS += [ + settings.EXPORTS += [ 'FS_createPath', 'FS_createDataFile', 'FS_createPreloadedFile', @@ -1412,12 +1431,12 @@ def phase_linker_setup(options, state, newargs): ] if not settings.WASMFS: # The old FS has some functionality that WasmFS lacks. - settings.EXPORTED_RUNTIME_METHODS += [ + settings.EXPORTS += [ 'FS_createLazyFile', 'FS_createDevice' ] - settings.EXPORTED_RUNTIME_METHODS += [ + settings.EXPORTS += [ 'addRunDependency', 'removeRunDependency', ] @@ -1515,7 +1534,7 @@ def phase_linker_setup(options, state, newargs): settings.REQUIRED_EXPORTS += ['__get_temp_ret', '__set_temp_ret'] if settings.SPLIT_MODULE and settings.ASYNCIFY == 2: - settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['_load_secondary_module'] + settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['__load_secondary_module'] # wasm side modules have suffix .wasm if settings.SIDE_MODULE and shared.suffix(target) == '.js': @@ -1818,7 +1837,7 @@ def get_full_import_name(name): # JS, you may need to manipulate the refcount manually not to leak memory. # What you need to do is different depending on the kind of EH you use # (https://github.com/emscripten-core/emscripten/issues/17115). - settings.EXPORTED_FUNCTIONS += ['getExceptionMessage', 'incrementExceptionRefcount', 'decrementExceptionRefcount'] + settings.EXPORTS += ['getExceptionMessage', 'incrementExceptionRefcount', 'decrementExceptionRefcount'] if settings.WASM_EXCEPTIONS: settings.REQUIRED_EXPORTS += ['__cpp_exception'] @@ -1866,10 +1885,10 @@ def phase_calculate_system_libraries(linker_arguments, newargs): def phase_link(linker_arguments, wasm_target, js_syms): logger.debug(f'linking: {linker_arguments}') - # Make a final pass over settings.EXPORTED_FUNCTIONS to remove any + # Make a final pass over settings.EXPORTS to remove any # duplication between functions added by the driver/libraries and function # specified by the user - settings.EXPORTED_FUNCTIONS = dedup_list(settings.EXPORTED_FUNCTIONS) + settings.EXPORTS = dedup_list(settings.EXPORTS) settings.REQUIRED_EXPORTS = dedup_list(settings.REQUIRED_EXPORTS) settings.EXPORT_IF_DEFINED = dedup_list(settings.EXPORT_IF_DEFINED) @@ -1877,7 +1896,7 @@ def phase_link(linker_arguments, wasm_target, js_syms): if settings.LINKABLE and not settings.EXPORT_ALL: # In LINKABLE mode we pass `--export-dynamic` along with `--whole-archive`. This results # in over 7000 exports, which cannot be distinguished from the few symbols we explicitly - # export via EMSCRIPTEN_KEEPALIVE or EXPORTED_FUNCTIONS. + # export via EMSCRIPTEN_KEEPALIVE or EXPORTS. # In order to avoid unnecessary exported symbols on the `Module` object we run the linker # twice in this mode: # 1. Without `--export-dynamic` to get the base exports @@ -2962,16 +2981,14 @@ def process_dynamic_libs(dylibs, lib_dirs): strong_imports = sorted(imports.difference(weak_imports)) logger.debug('Adding symbols requirements from `%s`: %s', dylib, imports) - mangled_imports = [shared.asmjs_mangle(e) for e in sorted(imports)] - mangled_strong_imports = [shared.asmjs_mangle(e) for e in strong_imports] for sym in weak_imports: mangled = shared.asmjs_mangle(sym) if mangled not in settings.SIDE_MODULE_IMPORTS and mangled not in building.user_requested_exports: settings.WEAK_IMPORTS.append(sym) - settings.SIDE_MODULE_IMPORTS.extend(mangled_imports) + settings.SIDE_MODULE_IMPORTS.extend(imports) settings.EXPORT_IF_DEFINED.extend(sorted(imports)) settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.extend(sorted(imports)) - building.user_requested_exports.update(mangled_strong_imports) + building.user_requested_exports.update(strong_imports) def unmangle_symbols_from_cmdline(symbols): @@ -3139,6 +3156,7 @@ def run(linker_inputs, options, state, newargs): js_info = get_js_sym_info() if not settings.SIDE_MODULE: js_syms = js_info['deps'] + if settings.LINKABLE: for native_deps in js_syms.values(): settings.REQUIRED_EXPORTS += native_deps @@ -3153,10 +3171,12 @@ def add_js_deps(sym): add_js_deps(sym) for sym in js_info['extraLibraryFuncs']: add_js_deps(sym) - for sym in settings.EXPORTED_RUNTIME_METHODS: - add_js_deps(shared.demangle_c_symbol_name(sym)) - for sym in settings.EXPORTED_FUNCTIONS: - add_js_deps(shared.demangle_c_symbol_name(sym)) + for sym in settings.EXPORTS: + add_js_deps(sym) + add_js_deps('$' + sym) + + for sym in building.get_runtime_symbols(): + js_syms['$' + sym] = [] if settings.ASYNCIFY: settings.ASYNCIFY_IMPORTS_EXCEPT_JS_LIBS = settings.ASYNCIFY_IMPORTS[:] settings.ASYNCIFY_IMPORTS += ['*.' + x for x in js_info['asyncFuncs']] diff --git a/tools/maint/gen_sig_info.py b/tools/maint/gen_sig_info.py index edda3de13e3e9..9713544a70634 100755 --- a/tools/maint/gen_sig_info.py +++ b/tools/maint/gen_sig_info.py @@ -175,7 +175,7 @@ def ignore_symbol(s, cxx): if s.startswith('gl') and any(s.endswith(x) for x in ('NV', 'EXT', 'WEBGL', 'ARB', 'ANGLE')): return True if s in {'__stack_base', '__memory_base', '__table_base', '__global_base', '__heap_base', - '__stack_pointer', '__stack_high', '__stack_low', '_load_secondary_module', + '__stack_pointer', '__stack_high', '__stack_low', '__load_secondary_module', '__asyncify_state', '__asyncify_data', # legacy aliases, not callable from native code. 'stackSave', 'stackRestore', 'stackAlloc', 'getTempRet0', 'setTempRet0', diff --git a/tools/settings.py b/tools/settings.py index 632c1d9e26ee5..a15f5f2f46dc3 100644 --- a/tools/settings.py +++ b/tools/settings.py @@ -130,6 +130,7 @@ # are not used by the JS compiler. INTERNAL_SETTINGS = { 'SIDE_MODULE_IMPORTS', + 'EXPORTED_FUNCTIONS', } user_settings: Dict[str, str] = {} diff --git a/tools/shared.py b/tools/shared.py index 88b8544b83df3..49653e046bd55 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -663,16 +663,15 @@ def maybe_quote(arg): sys.stderr.flush() -def demangle_c_symbol_name(name): +def demangle_legacy_symbol_name(name): + def is_c_symbol(name): + return name.startswith('_') + if not is_c_symbol(name): return '$' + name return name[1:] if name.startswith('_') else name -def is_c_symbol(name): - return name.startswith('_') - - def treat_as_user_export(name): return not name.startswith('dynCall_') @@ -683,11 +682,7 @@ def asmjs_mangle(name): Prepends '_' and replaces non-alphanumerics with '_'. Used by wasm backend for JS library consistency with asm.js. """ - # We also use this function to convert the clang-mangled `__main_argc_argv` - # to simply `main` which is expected by the emscripten JS glue code. - if name == '__main_argc_argv': - name = 'main' - if treat_as_user_export(name): + if treat_as_user_export(name) and not name.startswith('$'): return '_' + name return name diff --git a/tools/webidl_binder.py b/tools/webidl_binder.py index 12f2115fa5e94..c648273de8dd6 100644 --- a/tools/webidl_binder.py +++ b/tools/webidl_binder.py @@ -59,6 +59,8 @@ def getExtendedAttribute(self, _name): parser = argparse.ArgumentParser() parser.add_argument('--wasm64', action='store_true', default=False, help='Build for wasm64') +parser.add_argument('--no-mangled-exports', dest='mangle_exports', action='store_false', default=True, + help='Dont use mangled export names') parser.add_argument('infile') parser.add_argument('outfile') options = parser.parse_args() @@ -105,7 +107,7 @@ def getExtendedAttribute(self, _name): // Define custom allocator functions that we can force export using // EMSCRIPTEN_KEEPALIVE. This avoids all webidl users having to add -// malloc/free to -sEXPORTED_FUNCTIONS. +// malloc/free to -sEXPORTS. EMSCRIPTEN_KEEPALIVE void webidl_free(void* p) { free(p); } EMSCRIPTEN_KEEPALIVE void* webidl_malloc(size_t len) { return malloc(len); } @@ -122,6 +124,12 @@ def build_constructor(name): '''.format(name=name, implementing=implementing_name)] +def maybe_mangle(name): + if options.mangle_exports: + return '_' + name + return name + + mid_js = [''' // Bindings utilities @@ -201,11 +209,11 @@ def build_constructor(name): if (ensureCache.needed) { // clear the temps for (var i = 0; i < ensureCache.temps.length; i++) { - Module['_webidl_free'](ensureCache.temps[i]); + Module['%(webidl_free)s'](ensureCache.temps[i]); } ensureCache.temps.length = 0; // prepare to allocate a bigger buffer - Module['_webidl_free'](ensureCache.buffer); + Module['%(webidl_free)s'](ensureCache.buffer); ensureCache.buffer = 0; ensureCache.size += ensureCache.needed; // clean up @@ -213,7 +221,7 @@ def build_constructor(name): } if (!ensureCache.buffer) { // happens first time, or when we need to grow ensureCache.size += 128; // heuristic, avoid many small grow events - ensureCache.buffer = Module['_webidl_malloc'](ensureCache.size); + ensureCache.buffer = Module['%(webidl_malloc)s'](ensureCache.size); assert(ensureCache.buffer); } ensureCache.pos = 0; @@ -228,7 +236,7 @@ def build_constructor(name): // we failed to allocate in the buffer, ensureCache time around :( assert(len > 0); // null terminator, at least ensureCache.needed += len; - ret = Module['_webidl_malloc'](len); + ret = Module['%(webidl_malloc)s'](len); ensureCache.temps.push(ret); } else { // we can allocate in the buffer @@ -305,7 +313,7 @@ def build_constructor(name): } return value; } -'''] +''' % {'webidl_free': maybe_mangle('webidl_free'), 'webidl_malloc': maybe_mangle('webidl_malloc')}] C_FLOATS = ['float', 'double'] @@ -556,13 +564,13 @@ def make_call_args(i): else: after_call = '; ' + cache + 'return' args_for_call = make_call_args(i) - body += ' if (%s === undefined) { %s_%s(%s)%s%s }\n' % (args[i], call_prefix, c_names[i], - args_for_call, - call_postfix, after_call) + body += ' if (%s === undefined) { %s%s(%s)%s%s }\n' % (args[i], call_prefix, c_names[i], + args_for_call, + call_postfix, after_call) dbg(call_prefix) c_names[max_args] = f'emscripten_bind_{bindings_name}_{max_args}' args_for_call = make_call_args(len(args)) - body += ' %s_%s(%s)%s;\n' % (call_prefix, c_names[max_args], args_for_call, call_postfix) + body += ' %s%s(%s)%s;\n' % (call_prefix, c_names[max_args], args_for_call, call_postfix) if cache: body += f' {cache}\n' @@ -883,15 +891,15 @@ class %s : public %s { symbols = value.split('::') if len(symbols) == 1: identifier = symbols[0] - deferred_js += ["Module['%s'] = _%s();\n" % (identifier, function_id)] + deferred_js += ["Module['%s'] = %s();\n" % (identifier, function_id)] elif len(symbols) == 2: [namespace, identifier] = symbols if namespace in interfaces: # namespace is a class - deferred_js += ["Module['%s']['%s'] = _%s();\n" % (namespace, identifier, function_id)] + deferred_js += ["Module['%s']['%s'] = %s();\n" % (namespace, identifier, function_id)] else: # namespace is a namespace, so the enums get collapsed into the top level namespace. - deferred_js += ["Module['%s'] = _%s();\n" % (identifier, function_id)] + deferred_js += ["Module['%s'] = %s();\n" % (identifier, function_id)] else: raise Exception(f'Illegal enum value ${value}')