[lld][WebAssembly] Relax limitations on multithreaded instantiation
For multithreaded modules (i.e. modules with a shared memory), lld injects a synthetic Wasm start function that is automatically called during instantiation to initialize memory from passive data segments. Even though the module will be instantiated separately on each thread, memory initialization should happen only once. Furthermore, memory initialization should be finished by the time each thread finishes instantiation. Since multiple threads may be instantiating their modules at the same time, the synthetic function must synchronize them. The current synchronization tries to atomically increment a flag from 0 to 1 in memory then enters one of two cases. First, if the increment was successful, the current thread is responsible for initializing memory. It does so, increments the flag to 2 to signify that memory has been initialized, then notifies all threads waiting on the flag. Otherwise, the thread atomically waits on the flag with an...
parent
ce6d5120
Please register or sign in to comment