Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use exported memory when building a MAIN_MODULE. NFC #22332

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
9 changes: 2 additions & 7 deletions src/library_dylink.js
Original file line number Diff line number Diff line change
@@ -233,8 +233,6 @@ var LibraryDylink = {
#endif
} else if (typeof value == {{{ POINTER_JS_TYPE }}}) {
GOT[symName].value = value;
} else {
err(`unhandled export type for '${symName}': ${typeof value}`);
}
#if DYLINK_DEBUG == 2
dbg(`updateGOT: after: ${symName} : ${GOT[symName].value} (${value})`);
@@ -267,9 +265,8 @@ var LibraryDylink = {
continue;
}
#endif
if (typeof value == 'object') {
// a breaking change in the wasm spec, globals are now objects
// https://github.com/WebAssembly/mutable-global/issues/1
if (typeof value == 'object' && value.value) {
// For Wasm globals, extract the inner value.
value = value.value;
}
if (typeof value == {{{ POINTER_JS_TYPE }}}) {
@@ -315,8 +312,6 @@ var LibraryDylink = {
} else if (typeof value == 'bigint') {
entry.value = value;
#endif
} else {
throw new Error(`bad export type for '${symName}': ${typeof value}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing these changes are to do with handling a Memory export. But I see only removals. Where is the code that handles it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should should just ignore exports such as memories and tables. Its only interesting in handling globals and functions.

}
}
}
1 change: 0 additions & 1 deletion src/preamble.js
Original file line number Diff line number Diff line change
@@ -154,7 +154,6 @@ assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' &
#endif

#if IMPORTED_MEMORY
// In non-standalone/normal mode, we create the memory here.
#include "runtime_init_memory.js"
#elif ASSERTIONS
// If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY
1 change: 1 addition & 0 deletions test/other/metadce/test_metadce_hello_dylink.exports
Original file line number Diff line number Diff line change
@@ -6,4 +6,5 @@ dynCall_jiji
emscripten_stack_get_current
main
malloc
memory
setThrew
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_dylink.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6306
6216
1 change: 0 additions & 1 deletion test/other/metadce/test_metadce_hello_dylink.imports
Original file line number Diff line number Diff line change
@@ -5,5 +5,4 @@ env.__stack_pointer
env.__table_base
env._emscripten_memcpy_js
env.emscripten_resize_heap
env.memory
wasi_snapshot_preview1.fd_write
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_dylink.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13895
13655
1 change: 0 additions & 1 deletion test/other/metadce/test_metadce_hello_dylink.sent
Original file line number Diff line number Diff line change
@@ -6,4 +6,3 @@ __table_base
_emscripten_memcpy_js
emscripten_resize_heap
fd_write
memory
2 changes: 1 addition & 1 deletion tools/link.py
Original file line number Diff line number Diff line change
@@ -1408,7 +1408,7 @@ def phase_linker_setup(options, state, newargs):
'removeRunDependency',
]

if settings.SHARED_MEMORY or settings.RELOCATABLE or settings.ASYNCIFY_LAZY_LOAD_CODE:
if settings.SHARED_MEMORY or settings.SIDE_MODULE or settings.ASYNCIFY_LAZY_LOAD_CODE:
settings.IMPORTED_MEMORY = 1

set_initial_memory()
Loading
Oops, something went wrong.