|
4 | 4 | * SPDX-License-Identifier: MIT
|
5 | 5 | */
|
6 | 6 |
|
7 |
| -{{{ |
8 |
| - // Helper function to export a symbol on the module object |
9 |
| - // if requested. |
10 |
| - globalThis.maybeExport = (x) => MODULARIZE && EXPORT_ALL ? `Module['${x}'] = ` : ''; |
11 |
| - // Export to the AudioWorkletGlobalScope the needed variables to access |
12 |
| - // the heap. AudioWorkletGlobalScope is unable to access global JS vars |
13 |
| - // in the compiled main JS file. |
14 |
| - globalThis.maybeExportIfAudioWorklet = (x) => (MODULARIZE && EXPORT_ALL) || AUDIO_WORKLET ? `Module['${x}'] = ` : ''; |
15 |
| - null; |
16 |
| -}}} |
17 |
| - |
18 | 7 | #if SAFE_HEAP
|
19 | 8 | #include "runtime_safe_heap.js"
|
20 | 9 | #endif
|
@@ -65,27 +54,7 @@ var HEAP8, HEAP16, HEAP32, HEAPU8, HEAPU16, HEAPU32, HEAPF32, HEAPF64,
|
65 | 54 | #endif
|
66 | 55 | wasmMemory;
|
67 | 56 |
|
68 |
| -function updateMemoryViews() { |
69 |
| - var b = wasmMemory.buffer; |
70 |
| -#if ASSERTIONS && SHARED_MEMORY |
71 |
| - assert(b instanceof SharedArrayBuffer, 'requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag'); |
72 |
| -#endif |
73 |
| -#if SUPPORT_BIG_ENDIAN |
74 |
| - {{{ maybeExport('HEAP_DATA_VIEW') }}} HEAP_DATA_VIEW = new DataView(b); |
75 |
| -#endif |
76 |
| - {{{ maybeExport('HEAP8') }}} HEAP8 = new Int8Array(b); |
77 |
| - {{{ maybeExport('HEAP16') }}} HEAP16 = new Int16Array(b); |
78 |
| - {{{ maybeExport('HEAPU8') }}} HEAPU8 = new Uint8Array(b); |
79 |
| - {{{ maybeExport('HEAPU16') }}} HEAPU16 = new Uint16Array(b); |
80 |
| - {{{ maybeExport('HEAP32') }}} HEAP32 = new Int32Array(b); |
81 |
| - {{{ maybeExportIfAudioWorklet('HEAPU32') }}} HEAPU32 = new Uint32Array(b); |
82 |
| - {{{ maybeExportIfAudioWorklet('HEAPF32') }}} HEAPF32 = new Float32Array(b); |
83 |
| - {{{ maybeExport('HEAPF64') }}} HEAPF64 = new Float64Array(b); |
84 |
| -#if WASM_BIGINT |
85 |
| - {{{ maybeExport('HEAP64') }}} HEAP64 = new BigInt64Array(b); |
86 |
| - {{{ maybeExport('HEAPU64') }}} HEAPU64 = new BigUint64Array(b); |
87 |
| -#endif |
88 |
| -} |
| 57 | +#include "runtime_shared.js" |
89 | 58 |
|
90 | 59 | #if IMPORTED_MEMORY
|
91 | 60 | #if PTHREADS
|
@@ -116,6 +85,10 @@ else {
|
116 | 85 | #endif // MODULARIZE
|
117 | 86 | #endif // PTHREADS
|
118 | 87 |
|
| 88 | +#if ASSERTIONS && SHARED_MEMORY |
| 89 | +assert(wasmMemory.buffer instanceof SharedArrayBuffer, 'requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag'); |
| 90 | +#endif |
| 91 | + |
119 | 92 | updateMemoryViews();
|
120 | 93 | #endif // IMPORTED_MEMORY
|
121 | 94 |
|
|
0 commit comments