@@ -226,10 +226,6 @@ 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
@@ -246,6 +242,13 @@ function initRuntime() {
246242 callRuntimeCallbacks ( __RELOC_FUNCS__ ) ;
247243#endif
248244 < << ATINITS >>>
245+
246+ #if WASM_WORKERS
247+ if ( ENVIRONMENT_IS_WASM_WORKER ) {
248+ return _wasmWorkerInitializeRuntime ( ) ;
249+ }
250+ #endif
251+
249252 callRuntimeCallbacks ( __ATINIT__ ) ;
250253}
251254
@@ -792,7 +795,7 @@ function instantiateSync(file, info) {
792795}
793796#endif
794797
795- #if PTHREADS && ( LOAD_SOURCE_MAP || USE_OFFSET_CONVERTER )
798+ #if ( PTHREADS || WASM_WORKERS ) && ( LOAD_SOURCE_MAP || USE_OFFSET_CONVERTER )
796799// When using postMessage to send an object, it is processed by the structured
797800// clone algorithm. The prototype, and hence methods, on that object is then
798801// lost. This function adds back the lost prototype. This does not work with
@@ -1090,22 +1093,18 @@ function createWasm() {
10901093 // path.
10911094 if ( Module [ 'instantiateWasm' ] ) {
10921095
1093- #if USE_OFFSET_CONVERTER && PTHREADS
1094- if ( ENVIRONMENT_IS_PTHREAD ) {
1096+ #if USE_OFFSET_CONVERTER
10951097#if ASSERTIONS
1096- assert ( Module [ 'wasmOffsetData' ] , 'wasmOffsetData not found on Module object' ) ;
1098+ { { { runIfWorkerThread ( " assert(Module['wasmOffsetData'], 'wasmOffsetData not found on Module object');" ) } } }
10971099#endif
1098- wasmOffsetConverter = resetPrototype ( WasmOffsetConverter , Module [ 'wasmOffsetData' ] ) ;
1099- }
1100+ { { { runIfWorkerThread ( "wasmOffsetConverter = resetPrototype(WasmOffsetConverter, Module['wasmOffsetData']);" ) } } }
11001101#endif
11011102
1102- #if LOAD_SOURCE_MAP && PTHREADS
1103- if ( ENVIRONMENT_IS_PTHREAD ) {
1103+ #if LOAD_SOURCE_MAP
11041104#if ASSERTIONS
1105- assert ( Module [ 'wasmSourceMapData' ] , 'wasmSourceMapData not found on Module object' ) ;
1105+ { { { runIfWorkerThread ( " assert(Module['wasmSourceMapData'], 'wasmSourceMapData not found on Module object');" ) } } }
11061106#endif
1107- wasmSourceMap = resetPrototype ( WasmSourceMap , Module [ 'wasmSourceMapData' ] ) ;
1108- }
1107+ { { { runIfWorkerThread ( "wasmSourceMap = resetPrototype(WasmSourceMap, Module['wasmSourceMapData']);" ) } } }
11091108#endif
11101109
11111110 try {
0 commit comments