diff --git a/src/library.js b/src/library.js index 20a5ed468ea4..a33161c9ead0 100644 --- a/src/library.js +++ b/src/library.js @@ -186,7 +186,7 @@ addToLibrary({ // it. Returns 1 on success, 0 on error. $growMemory: (size) => { var b = wasmMemory.buffer; - var pages = (size - b.byteLength + {{{ WASM_PAGE_SIZE - 1 }}}) / {{{ WASM_PAGE_SIZE }}}; + var pages = ((size - b.byteLength + {{{ WASM_PAGE_SIZE - 1 }}}) / {{{ WASM_PAGE_SIZE }}}) | 0; #if RUNTIME_DEBUG dbg(`growMemory: ${size} (+${size - b.byteLength} bytes / ${pages} pages)`); #endif @@ -195,7 +195,7 @@ addToLibrary({ #endif try { // round size grow request up to wasm page size (fixed 64KB per spec) - wasmMemory.grow(pages); // .grow() takes a delta compared to the previous size + wasmMemory.grow({{{ toIndexType('pages') }}}); // .grow() takes a delta compared to the previous size updateMemoryViews(); #if MEMORYPROFILER if (typeof emscriptenMemoryProfiler != 'undefined') { diff --git a/test/other/codesize/test_codesize_mem_O3_grow.gzsize b/test/other/codesize/test_codesize_mem_O3_grow.gzsize index aed4b56065d9..12fda76f5d0c 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow.gzsize @@ -1 +1 @@ -2558 +2559 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.jssize b/test/other/codesize/test_codesize_mem_O3_grow.jssize index 5de804a0900c..e596651c0985 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow.jssize @@ -1 +1 @@ -5294 +5296