Skip to content
Merged
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
13 changes: 5 additions & 8 deletions tools/emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,18 +778,15 @@ def create_em_js(metadata):
def add_standard_wasm_imports(send_items_map):
extra_sent_items = []

if settings.IMPORTED_MEMORY:
memory_import = 'wasmMemory'
if settings.MODULARIZE and settings.PTHREADS:
# Pthreads assign wasmMemory in their worker startup. In MODULARIZE mode, they cannot assign inside the
# Module scope, so lookup via Module as well.
memory_import += " || Module['wasmMemory']"
send_items_map['memory'] = memory_import

if settings.SAFE_HEAP:
extra_sent_items.append('segfault')
extra_sent_items.append('alignfault')

# Special case for importing memory and table
# TODO(sbc): can we make these into normal library symbols?
Copy link
Member

Choose a reason for hiding this comment

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

Are there symbol types for memories?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, we could add memories and tables to this list:

imports = [i.field for i in imports if i.kind in (webassembly.ExternType.FUNC, webassembly.ExternType.GLOBAL, webassembly.ExternType.TAG)]

My initial attempt to do that didn't work but I hope to figure it out at some point.

if settings.IMPORTED_MEMORY:
send_items_map['memory'] = 'wasmMemory'

if settings.RELOCATABLE:
send_items_map['__indirect_function_table'] = 'wasmTable'

Expand Down