Skip to content

Commit

Permalink
Add toIndexType when calling Memory.grow
Browse files Browse the repository at this point in the history
This was missing from emscripten-core#22497 and is currently causing
test_embind_o2_mem_growth_wasm64 to fail with the latest nightly version
of d8.
  • Loading branch information
sbc100 committed Oct 1, 2024
1 parent 214e851 commit 94461fa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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') {
Expand Down

0 comments on commit 94461fa

Please sign in to comment.