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 b36624a commit 1fa5ab1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 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
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3_grow.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2558
2559
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3_grow.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5294
5296

0 comments on commit 1fa5ab1

Please sign in to comment.