Skip to content

Commit

Permalink
Round the number of pages passed to Memory.grow. NFC
Browse files Browse the repository at this point in the history
Without this the trace line below prints (somewhat confusingly):

```
growMemory: 80740352 (+1048576 bytes / 16.999984741210938 pages)
```
  • Loading branch information
sbc100 committed Aug 12, 2024
1 parent 02577a5 commit 6770ee4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,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 Down
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3_grow.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2570
2571
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3_grow.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5344
5346

0 comments on commit 6770ee4

Please sign in to comment.