Skip to content

Commit 304fef1

Browse files
committed
refactor reallocBuffer assignment location, it is not technically part of mergeMemory
1 parent 88e8b71 commit 304fef1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/js/wasm.js-post.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,6 @@ function integrateWasmJS(Module) {
110110
newView.set(oldView);
111111
updateGlobalBuffer(newBuffer);
112112
updateGlobalBufferViews();
113-
Module['reallocBuffer'] = function(size) {
114-
size = Math.ceil(size / wasmPageSize) * wasmPageSize; // round up to wasm page size
115-
var old = Module['buffer'];
116-
exports['__growWasmMemory'](size / wasmPageSize); // tiny wasm method that just does grow_memory
117-
return Module['buffer'] !== old ? Module['buffer'] : null; // if it was reallocated, it changed
118-
};
119113
}
120114

121115
var WasmTypes = {
@@ -264,6 +258,14 @@ function integrateWasmJS(Module) {
264258
// We may have a preloaded value in Module.asm, save it
265259
Module['asmPreload'] = Module['asm'];
266260

261+
// Memory growth integration code
262+
Module['reallocBuffer'] = function(size) {
263+
size = Math.ceil(size / wasmPageSize) * wasmPageSize; // round up to wasm page size
264+
var old = Module['buffer'];
265+
exports['__growWasmMemory'](size / wasmPageSize); // tiny wasm method that just does grow_memory
266+
return Module['buffer'] !== old ? Module['buffer'] : null; // if it was reallocated, it changed
267+
};
268+
267269
// Provide an "asm.js function" for the application, called to "link" the asm.js module. We instantiate
268270
// the wasm module at that time, and it receives imports and provides exports and so forth, the app
269271
// doesn't need to care that it is wasm or olyfilled wasm or asm.js.

0 commit comments

Comments
 (0)