Skip to content

Updating LLD to use bulk memory for threads #1631

Closed
@tlively

Description

@tlively

In the near future I plan to update LLD to emit passive segments when a shared memory is requested. This will prevent memory from being reinitialized every time a thread is spawned. Currently toolchains need to do something like separate the contents of memory into a separate file and manually initialize memory on the main thread. With this update to LLD, the linker will synthesize a function called __wasm_init_memory. This function will automatically be called at the beginning of __wasm_call_ctors, but @fitzgen reminded me that Rust does not have any global constructors, so you will probably be able to call __wasm_init_memory directly.

The existing memory separation code will probably break since the data segments will no longer declare their own offsets, so I just wanted to give a heads up that this change is coming. It also means that enabling shared memory in Firefox will be insufficient to test multithreaded modules, which may affect your workflow or testing. I filed a Firefox bug about this at https://bugzilla.mozilla.org/show_bug.cgi?id=1561747.

I will update this issue once the change has landed upstream in LLD and when I update the tool-conventions repo with details about this arrangement.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions