From af7f6ead43a268a2f822b34872d5991f0eb91932 Mon Sep 17 00:00:00 2001 From: Adam Goode Date: Sun, 25 Feb 2024 13:17:02 -0500 Subject: [PATCH] wasi: Implement GC_displayMem All we have is the builtin memory.size, which is exposed by sbrk(0). --- runtime/platform/wasi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runtime/platform/wasi.c b/runtime/platform/wasi.c index 133c13bc6..42dc82b44 100644 --- a/runtime/platform/wasi.c +++ b/runtime/platform/wasi.c @@ -44,7 +44,10 @@ void GC_release (void *base, __attribute__ ((unused)) size_t length) { } void GC_displayMem (void) { - printf ("GC_displayMem() not implemented on WASI\n"); + size_t memory_size = (size_t) sbrk(0); + size_t pages = memory_size / PAGESIZE; + printf ("memory.size: pages=%zu, pagesize=%d, total=%zu\n", + pages, PAGESIZE, memory_size); } void GC_diskBack_close (__attribute__ ((unused)) void *data) {