MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / updateMemoryViews

Function updateMemoryViews

src/runtime_common.js:144–180  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

142#endif // ALLOW_MEMORY_GROWTH
143
144function updateMemoryViews() {
145#if RUNTIME_DEBUG
146 dbg(`updateMemoryViews: first=${!HEAP8} size=${wasmMemory.buffer.byteLength}`);
147#endif
148#if ALLOW_MEMORY_GROWTH
149 // If we already have a heap that is resizeable/growable buffer we don't
150 // need to do anything in updateMemoryViews.
151#if SHARED_MEMORY
152 if (HEAP8?.buffer?.growable) return;
153#else
154 if (HEAP8?.buffer?.resizable) return;
155#endif
156 var b = getMemoryBuffer();
157#else
158#if ASSERTIONS
159 // When memory growth is disabled this function should be called exactly once.
160 assert(!HEAP8, 'updateMemoryViews should only be called once when ALLOW_MEMORY_GROWTH=0');
161#endif
162 var b = wasmMemory.buffer;
163#endif
164 {{{ maybeExportHeap('HEAP8') }}}HEAP8 = new Int8Array(b);
165 {{{ maybeExportHeap('HEAP16') }}}HEAP16 = new Int16Array(b);
166 {{{ maybeExportHeap('HEAPU8') }}}HEAPU8 = new Uint8Array(b);
167 {{{ maybeExportHeap('HEAPU16') }}}HEAPU16 = new Uint16Array(b);
168 {{{ maybeExportHeap('HEAP32') }}}HEAP32 = new Int32Array(b);
169 {{{ maybeExportHeap('HEAPU32') }}}HEAPU32 = new Uint32Array(b);
170 {{{ maybeExportHeap('HEAPF32') }}}HEAPF32 = new Float32Array(b);
171 {{{ maybeExportHeap('HEAPF64') }}}HEAPF64 = new Float64Array(b);
172#if WASM_BIGINT
173 {{{ maybeExportHeap('HEAP64') }}}HEAP64 = new BigInt64Array(b);
174 {{{ maybeExportHeap('HEAPU64') }}}HEAPU64 = new BigUint64Array(b);
175#endif
176#if SUPPORT_BIG_ENDIAN
177 {{{ maybeExportHeap('HEAP_DATA_VIEW') }}} HEAP_DATA_VIEW = new DataView(b);
178 LE_HEAP_UPDATE();
179#endif
180}
181
182#if IMPORTED_MEMORY
183// In non-standalone/normal mode, we create the memory here.

Callers 9

runtime_pthread.jsFile · 0.70
initMemoryFunction · 0.70
startWasmWorkerFunction · 0.70
initFunction · 0.70
growMemViewsFunction · 0.70
receiveInstanceFunction · 0.70
libcore.jsFile · 0.50

Calls 4

getMemoryBufferFunction · 0.85
maybeExportHeapFunction · 0.85
assertFunction · 0.70
dbgFunction · 0.50

Tested by

no test coverage detected