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

Function getMemoryBuffer

src/runtime_common.js:115–141  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113// When ALLOW_MEMORY_GROWTH is enabled, the conversion from Wasm
114// memory to ArrayBuffer requires some additional logic.
115function getMemoryBuffer() {
116#if GROWABLE_ARRAYBUFFERS == 2
117 return wasmMemory.toResizableBuffer();
118#else
119#if GROWABLE_ARRAYBUFFERS == 1
120#if SHARED_MEMORY && (MIN_FIREFOX_VERSION < 154)
121 // Deserializing a growable SharedArrayBuffer was broken until Firefox 154
122 // See: https://bugzilla.mozilla.org/show_bug.cgi?id=2021136
123 var firefoxMatch = globalThis.navigator?.userAgent?.match(/Firefox\/(\d+)/);
124 if (!firefoxMatch || Number(firefoxMatch[1]) >= 154) {
125#endif
126 try {
127 // This method may be missing or could fail with `Memory must have a maximum`
128 var b = wasmMemory.toResizableBuffer();
129#if SHARED_MEMORY
130 growMemViews = () => {};
131#endif
132 return b;
133
134 } catch {}
135#if SHARED_MEMORY && (MIN_FIREFOX_VERSION < 154)
136 }
137#endif
138#endif // GROWABLE_ARRAYBUFFERS == 1
139 return wasmMemory.buffer;
140#endif // GROWABLE_ARRAYBUFFERS == 2
141}
142#endif // ALLOW_MEMORY_GROWTH
143
144function updateMemoryViews() {

Callers 1

updateMemoryViewsFunction · 0.85

Calls 1

matchMethod · 0.45

Tested by

no test coverage detected