From 94461fa14c11f312f3b92a3f0dd6244d5dcc44b2 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 1 Oct 2024 14:52:32 -0700 Subject: [PATCH] Add `toIndexType` when calling Memory.grow This was missing from #22497 and is currently causing test_embind_o2_mem_growth_wasm64 to fail with the latest nightly version of d8. --- src/library.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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') {