@@ -226,14 +226,16 @@ function initRuntime() {
226226#endif
227227 runtimeInitialized = true ;
228228
229- #if WASM_WORKERS
230- if ( ENVIRONMENT_IS_WASM_WORKER ) return _wasmWorkerInitializeRuntime ( ) ;
231- #endif
232-
233229#if PTHREADS
234230 if ( ENVIRONMENT_IS_PTHREAD ) return ;
235231#endif
236232
233+ #if WASM_WORKERS
234+ if ( ENVIRONMENT_IS_WASM_WORKER ) {
235+ _wasmWorkerInitializeRuntime ( ) ;
236+ } else {
237+ #endif
238+
237239#if STACK_OVERFLOW_CHECK
238240 checkStackCookie ( ) ;
239241#endif
@@ -245,7 +247,19 @@ function initRuntime() {
245247#if RELOCATABLE
246248 callRuntimeCallbacks ( __RELOC_FUNCS__ ) ;
247249#endif
250+
251+ #if WASM_WORKERS
252+ }
253+ #endif
254+
248255 < << ATINITS >>>
256+
257+ #if WASM_WORKERS
258+ if ( ENVIRONMENT_IS_WASM_WORKER ) {
259+ return ;
260+ }
261+ #endif
262+
249263 callRuntimeCallbacks ( __ATINIT__ ) ;
250264}
251265
@@ -792,7 +806,7 @@ function instantiateSync(file, info) {
792806}
793807#endif
794808
795- #if PTHREADS && ( LOAD_SOURCE_MAP || USE_OFFSET_CONVERTER )
809+ #if ( PTHREADS || WASM_WORKERS ) && ( LOAD_SOURCE_MAP || USE_OFFSET_CONVERTER )
796810// When using postMessage to send an object, it is processed by the structured
797811// clone algorithm. The prototype, and hence methods, on that object is then
798812// lost. This function adds back the lost prototype. This does not work with
@@ -1089,22 +1103,18 @@ function createWasm() {
10891103 // path.
10901104 if ( Module [ 'instantiateWasm' ] ) {
10911105
1092- #if USE_OFFSET_CONVERTER && PTHREADS
1093- if ( ENVIRONMENT_IS_PTHREAD ) {
1106+ #if USE_OFFSET_CONVERTER
10941107#if ASSERTIONS
1095- assert ( Module [ 'wasmOffsetData' ] , 'wasmOffsetData not found on Module object' ) ;
1108+ { { { runIfWorkerThread ( " assert(Module['wasmOffsetData'], 'wasmOffsetData not found on Module object');" ) } } }
10961109#endif
1097- wasmOffsetConverter = resetPrototype ( WasmOffsetConverter , Module [ 'wasmOffsetData' ] ) ;
1098- }
1110+ { { { runIfWorkerThread ( "wasmOffsetConverter = resetPrototype(WasmOffsetConverter, Module['wasmOffsetData']);" ) } } }
10991111#endif
11001112
1101- #if LOAD_SOURCE_MAP && PTHREADS
1102- if ( ENVIRONMENT_IS_PTHREAD ) {
1113+ #if LOAD_SOURCE_MAP
11031114#if ASSERTIONS
1104- assert ( Module [ 'wasmSourceMapData' ] , 'wasmSourceMapData not found on Module object' ) ;
1115+ { { { runIfWorkerThread ( " assert(Module['wasmSourceMapData'], 'wasmSourceMapData not found on Module object');" ) } } }
11051116#endif
1106- wasmSourceMap = resetPrototype ( WasmSourceMap , Module [ 'wasmSourceMapData' ] ) ;
1107- }
1117+ { { { runIfWorkerThread ( "wasmSourceMap = resetPrototype(WasmSourceMap, Module['wasmSourceMapData']);" ) } } }
11081118#endif
11091119
11101120 try {
0 commit comments