Skip to content

Commit 1fa5ab1

Browse files
committed
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.
1 parent b36624a commit 1fa5ab1

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/library.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ addToLibrary({
186186
// it. Returns 1 on success, 0 on error.
187187
$growMemory: (size) => {
188188
var b = wasmMemory.buffer;
189-
var pages = (size - b.byteLength + {{{ WASM_PAGE_SIZE - 1 }}}) / {{{ WASM_PAGE_SIZE }}};
189+
var pages = ((size - b.byteLength + {{{ WASM_PAGE_SIZE - 1 }}}) / {{{ WASM_PAGE_SIZE }}}) | 0;
190190
#if RUNTIME_DEBUG
191191
dbg(`growMemory: ${size} (+${size - b.byteLength} bytes / ${pages} pages)`);
192192
#endif
@@ -195,7 +195,7 @@ addToLibrary({
195195
#endif
196196
try {
197197
// round size grow request up to wasm page size (fixed 64KB per spec)
198-
wasmMemory.grow(pages); // .grow() takes a delta compared to the previous size
198+
wasmMemory.grow({{{ toIndexType('pages') }}}); // .grow() takes a delta compared to the previous size
199199
updateMemoryViews();
200200
#if MEMORYPROFILER
201201
if (typeof emscriptenMemoryProfiler != 'undefined') {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2558
1+
2559
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5294
1+
5296

0 commit comments

Comments
 (0)