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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -606,3 +606,4 @@ a license to everyone to use it as detailed in LICENSE.)
* Abdelrahman Teima <abdelrahmanteima@gmail.com>
* Jaap Aarts <jaap.aarts1@gmail.com>
* Dimokritos Kolitsos <dkolitsos@protonmail.com>
* Bas van Dijk <bas@van.dijk.ch>
19 changes: 9 additions & 10 deletions src/lib/libdylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -1307,27 +1307,22 @@ var LibraryDylink = {
#if DYLINK_DEBUG
dbg('dlsym_js:', symbol);
#endif
var result;
var newSymIndex;

var lib = LDSO.loadedLibsByHandle[handle];
#if ASSERTIONS
assert(lib, `Tried to dlsym() from an unopened handle: ${handle}`);
#endif
newSymIndex = Object.keys(lib.exports).indexOf(symbol);
if (newSymIndex == -1 || lib.exports[symbol].stub) {
if (!hasOwn(lib.exports, symbol) || lib.exports[symbol].stub) {
dlSetError(`Tried to lookup unknown symbol "${symbol}" in dynamic lib: ${lib.name}`)
return 0;
}
var exportName = symbol;
#if !WASM_BIGINT
var origSym = 'orig$' + symbol;
result = lib.exports[origSym];
if (result) {
newSymIndex = Object.keys(lib.exports).indexOf(origSym);
if (lib.exports[origSym]) {
exportName = origSym;
}
else
#endif
result = lib.exports[symbol];
var result = lib.exports[exportName];

if (typeof result === 'function') {
#if DYLINK_DEBUG
Expand Down Expand Up @@ -1355,6 +1350,10 @@ var LibraryDylink = {
#if DYLINK_DEBUG
dbg('adding symbol to table:', symbol);
#endif
// Other threads replay this insertion by the symbol's enumeration index
// (`_dlsym_catchup_js`). Using `indexOf` here is O(N),
// so only do so when a slot was actually allocated.
var newSymIndex = Object.keys(lib.exports).indexOf(exportName);
{{{ makeSetValue('symbolIndex', 0, 'newSymIndex', '*') }}};
}
}
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": 272930,
"a.out.js": 272950,
"a.out.nodebug.wasm": 589512,
"total": 862442,
"total": 862462,
"sent": [
"IMG_Init",
"IMG_Load",
Expand Down
Loading