From f454f00ad4c046efbc67a417ca4b0523cdc865d2 Mon Sep 17 00:00:00 2001 From: lax1dude Date: Sat, 9 Nov 2024 22:02:05 -0800 Subject: [PATCH] Add heap dump function --- .../java/org/teavm/runtime/LaxMalloc.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/src/main/java/org/teavm/runtime/LaxMalloc.java b/core/src/main/java/org/teavm/runtime/LaxMalloc.java index e83ea2bda..deffaffe6 100644 --- a/core/src/main/java/org/teavm/runtime/LaxMalloc.java +++ b/core/src/main/java/org/teavm/runtime/LaxMalloc.java @@ -578,4 +578,24 @@ public final class LaxMalloc { return a < b ? a : b; } +// @Import(name = "dumpHeapHelper") +// private static native void dumpHeapHelper(Address chunkStart, Address chunkEnd, int size, +// int free, Address endAddr); +// +// public static void heapDump() { +// Address curAddr = addrHeap(ADDR_HEAP_DATA_START); +// Address endAddr = addrHeap(ADDR_HEAP_INNER_LIMIT).getAddress(); +// while (curAddr.isLessThan(endAddr)) { +// int sizeStat = readChunkSizeStatus(curAddr); +// int size = sizeStat & 0x7FFFFFFF; +// int stat = sizeStat >>> 31; +// dumpHeapHelper(curAddr, curAddr.add(size), size, stat, endAddr); +// if (size == 0) { +// //NOTE: size 0 would be a bug +// return; +// } +// curAddr = curAddr.add(size); +// } +// } + }