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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/lib/libcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ addToLibrary({
setTempRet0: '$setTempRet0',
getTempRet0: '$getTempRet0',

// Assign a name to a given function. This is mostly useful for debugging
// purposes in cases where new functions are created at runtime.
$createNamedFunction: (name, func) => Object.defineProperty(func, 'name', { value: name }),

$ptrToString: (ptr) => {
#if ASSERTIONS
assert(typeof ptr === 'number', `ptrToString expects a number, got ${typeof ptr}`);
Expand Down
8 changes: 4 additions & 4 deletions src/lib/libdylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ var LibraryDylink = {
// the canonical name of the symbol (in some cases is modify the symbol as
// part of the loop process, so that actual symbol looked up has a different
// name).
$resolveGlobalSymbol__deps: ['$isSymbolDefined',
$resolveGlobalSymbol__deps: ['$isSymbolDefined', '$createNamedFunction',
#if !DISABLE_EXCEPTION_CATCHING || SUPPORT_LONGJMP == 'emscripten'
'$createInvokeFunction',
#endif
Expand All @@ -138,7 +138,7 @@ var LibraryDylink = {
// Asm.js-style exception handling: invoke wrapper generation
else if (symName.startsWith('invoke_')) {
// Create (and cache) new invoke_ functions on demand.
sym = wasmImports[symName] = createInvokeFunction(symName.split('_')[1]);
sym = wasmImports[symName] = createNamedFunction(symName, createInvokeFunction(symName.split('_')[1]));
}
#endif
#if !DISABLE_EXCEPTION_CATCHING
Expand All @@ -147,13 +147,13 @@ var LibraryDylink = {
// `__cxa_find_matching_catch_` (see jsifier.js) that we know are needed,
// but a side module loaded at runtime might need different/additional
// variants so we create those dynamically.
sym = wasmImports[symName] = (...args) => {
sym = wasmImports[symName] = createNamedFunction(symName, (...args) => {
#if MEMORY64
args = args.map(Number);
#endif
var rtn = findMatchingCatch(args);
return {{{ to64('rtn') }}};
}
});
}
#endif
return {sym, name: symName};
Expand Down
2 changes: 0 additions & 2 deletions src/lib/libembind.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ var LibraryEmbind = {
}
},

$createNamedFunction: (name, func) => Object.defineProperty(func, 'name', { value: name }),

$embindRepr: (v) => {
if (v === null) {
return 'null';
Expand Down
1 change: 0 additions & 1 deletion src/lib/libembind_gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,6 @@ var LibraryEmbind = {
// Stub functions used by eval, but not needed for TS generation:
$makeLegalFunctionName: () => { throw new Error('stub function should not be called'); },
$runDestructors: () => { throw new Error('stub function should not be called'); },
$createNamedFunction: () => { throw new Error('stub function should not be called'); },
$flushPendingDeletes: () => { throw new Error('stub function should not be called'); },
$setDelayFunction: () => { throw new Error('stub function should not be called'); },
$PureVirtualError: () => { throw new Error('stub function should not be called'); },
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_O0.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 22458,
"a.out.js.gz": 8308,
"a.out.js": 22478,
"a.out.js.gz": 8314,
"a.out.nodebug.wasm": 15127,
"a.out.nodebug.wasm.gz": 7450,
"total": 37585,
"total_gz": 15758,
"total": 37605,
"total_gz": 15764,
"sent": [
"fd_write"
],
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_dylink.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 26946,
"a.out.js.gz": 11478,
"a.out.js": 26985,
"a.out.js.gz": 11495,
"a.out.nodebug.wasm": 18567,
"a.out.nodebug.wasm.gz": 9199,
"total": 45513,
"total_gz": 20677,
"total": 45552,
"total_gz": 20694,
"sent": [
"__heap_base",
"__indirect_function_table",
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_hello_dylink_all.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"a.out.js": 245989,
"a.out.js": 246028,
"a.out.nodebug.wasm": 597755,
"total": 843744,
"total": 843783,
"sent": [
"IMG_Init",
"IMG_Load",
Expand Down
1 change: 1 addition & 0 deletions test/codesize/test_codesize_minimal_O0.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
'stackAlloc',
'getTempRet0',
'setTempRet0',
'createNamedFunction',
'zeroMemory',
'exitJS',
'getHeapMax',
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_minimal_O0.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 17734,
"a.out.js.gz": 6610,
"a.out.js": 17754,
"a.out.js.gz": 6617,
"a.out.nodebug.wasm": 1136,
"a.out.nodebug.wasm.gz": 659,
"total": 18870,
"total_gz": 7269,
"total": 18890,
"total_gz": 7276,
"sent": [],
"imports": [],
"exports": [
Expand Down
12 changes: 6 additions & 6 deletions test/codesize/test_unoptimized_code_size.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"hello_world.js": 54108,
"hello_world.js.gz": 17086,
"hello_world.js": 54133,
"hello_world.js.gz": 17091,
"hello_world.wasm": 15127,
"hello_world.wasm.gz": 7450,
"no_asserts.js": 26513,
"no_asserts.js.gz": 8864,
"no_asserts.wasm": 12227,
"no_asserts.wasm.gz": 6010,
"strict.js": 52146,
"strict.js.gz": 16420,
"strict.js": 52171,
"strict.js.gz": 16426,
"strict.wasm": 15127,
"strict.wasm.gz": 7447,
"total": 175248,
"total_gz": 63277
"total": 175298,
"total_gz": 63288
}