From 2fcaaa531358bd83bcb179e6673b024440c8d8dd Mon Sep 17 00:00:00 2001 From: lax1dude Date: Sat, 9 Nov 2024 20:19:37 -0800 Subject: [PATCH] Fix max heap size and hugeAlloc --- core/src/main/java/org/teavm/backend/wasm/WasmGCTarget.java | 3 +-- core/src/main/java/org/teavm/runtime/LaxMalloc.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/teavm/backend/wasm/WasmGCTarget.java b/core/src/main/java/org/teavm/backend/wasm/WasmGCTarget.java index 4c2ce9111..ec4d469da 100644 --- a/core/src/main/java/org/teavm/backend/wasm/WasmGCTarget.java +++ b/core/src/main/java/org/teavm/backend/wasm/WasmGCTarget.java @@ -439,8 +439,7 @@ public class WasmGCTarget implements TeaVMTarget, TeaVMWasmGCHost { if (enableDirectMallocSupport) { var minPages = (memorySize - 1) / WasmHeap.PAGE_SIZE + 1; - var maxPages = (memorySize - directMallocMinHeapSize + directMallocMaxHeapSize - 1) - / WasmHeap.PAGE_SIZE + 1; + var maxPages = (memorySize + directMallocMaxHeapSize - WasmHeap.PAGE_SIZE - 1) / WasmHeap.PAGE_SIZE + 1; module.setMinMemorySize(minPages); module.setMaxMemorySize(maxPages); } else { diff --git a/core/src/main/java/org/teavm/runtime/LaxMalloc.java b/core/src/main/java/org/teavm/runtime/LaxMalloc.java index d6216e230..c924ebce8 100644 --- a/core/src/main/java/org/teavm/runtime/LaxMalloc.java +++ b/core/src/main/java/org/teavm/runtime/LaxMalloc.java @@ -283,7 +283,7 @@ public final class LaxMalloc { allocateMemoryFromChunk(addrIterator, chunkSize, sizeBytes); // +4 bytes to skip size int - Address ret = chunkPtr.add(4); + Address ret = addrIterator.add(4); // clear if requested if (cleared) {