|
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 | + global.maybeExport = function(x) { |
| 11 | + return MODULARIZE && EXPORT_ALL ? `Module['${x}'] = ` : ''; |
| 12 | + }; |
| 13 | + null; |
| 14 | +}}} |
| 15 | + |
7 | 16 | #if SAFE_HEAP |
8 | 17 | #include "runtime_safe_heap.js" |
9 | 18 | #endif |
@@ -56,26 +65,25 @@ var HEAP8, HEAP16, HEAP32, HEAPU8, HEAPU16, HEAPU32, HEAPF32, HEAPF64, |
56 | 65 | #endif |
57 | 66 | wasmMemory, wasmTable; |
58 | 67 |
|
59 | | - |
60 | 68 | function updateMemoryViews() { |
61 | 69 | var b = wasmMemory.buffer; |
62 | 70 | #if ASSERTIONS && SHARED_MEMORY |
63 | 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'); |
64 | 72 | #endif |
65 | 73 | #if SUPPORT_BIG_ENDIAN |
66 | | - HEAP_DATA_VIEW = new DataView(b); |
67 | | -#endif |
68 | | - HEAP8 = new Int8Array(b); |
69 | | - HEAP16 = new Int16Array(b); |
70 | | - HEAP32 = new Int32Array(b); |
71 | | - HEAPU8 = new Uint8Array(b); |
72 | | - HEAPU16 = new Uint16Array(b); |
73 | | - HEAPU32 = new Uint32Array(b); |
74 | | - HEAPF32 = new Float32Array(b); |
75 | | - HEAPF64 = new Float64Array(b); |
| 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('HEAP32') }}}HEAP32 = new Int32Array(b); |
| 79 | + {{{ maybeExport('HEAPU8') }}}HEAPU8 = new Uint8Array(b); |
| 80 | + {{{ maybeExport('HEAPU16') }}}HEAPU16 = new Uint16Array(b); |
| 81 | + {{{ maybeExport('HEAPU32') }}}HEAPU32 = new Uint32Array(b); |
| 82 | + {{{ maybeExport('HEAPF32') }}}HEAPF32 = new Float32Array(b); |
| 83 | + {{{ maybeExport('HEAPF64') }}}HEAPF64 = new Float64Array(b); |
76 | 84 | #if WASM_BIGINT |
77 | | - HEAP64 = new BigInt64Array(b); |
78 | | - HEAPU64 = new BigUint64Array(b); |
| 85 | + {{{ maybeExport('HEAP64') }}}HEAP64 = new BigInt64Array(b); |
| 86 | + {{{ maybeExport('HEAPU64') }}}HEAPU64 = new BigUint64Array(b); |
79 | 87 | #endif |
80 | 88 | } |
81 | 89 |
|
|
0 commit comments