diff --git a/runtime/gc/heap.c b/runtime/gc/heap.c index af1d9f8bb..668315d51 100644 --- a/runtime/gc/heap.c +++ b/runtime/gc/heap.c @@ -183,7 +183,9 @@ void shrinkHeap (GC_state s, GC_heap h, size_t keepSize) { } assert (isAligned (keepWithMapsSize, s->sysvals.pageSize)); assert (keepWithMapsSize <= h->withMapsSize); +#if HAS_SHRINK_HEAP GC_release (h->start + keepWithMapsSize, h->withMapsSize - keepWithMapsSize); +#endif h->size = keepSize; h->withMapsSize = keepWithMapsSize; } diff --git a/runtime/platform.h b/runtime/platform.h index 6c3a44cfd..c88ea3b85 100644 --- a/runtime/platform.h +++ b/runtime/platform.h @@ -35,6 +35,10 @@ #error HAS_REMAP not defined #endif +#ifndef HAS_SHRINK_HEAP +#error HAS_SHRINK_HEAP not defined +#endif + #ifndef HAS_SIGALTSTACK #error HAS_SIGALTSTACK not defined #else diff --git a/runtime/platform/aix.h b/runtime/platform/aix.h index 4869551f3..f7bb19037 100644 --- a/runtime/platform/aix.h +++ b/runtime/platform/aix.h @@ -34,6 +34,7 @@ #define HAS_MSG_DONTWAIT FALSE #define HAS_PTRACE FALSE #define HAS_REMAP FALSE +#define HAS_SHRINK_HEAP TRUE #define HAS_SIGALTSTACK TRUE #define NEEDS_SIGALTSTACK_EXEC FALSE #define HAS_SPAWN FALSE diff --git a/runtime/platform/cygwin.h b/runtime/platform/cygwin.h index 644fec5aa..29a0e7bae 100644 --- a/runtime/platform/cygwin.h +++ b/runtime/platform/cygwin.h @@ -35,6 +35,7 @@ #define HAS_FEROUND FALSE #define HAS_REMAP TRUE +#define HAS_SHRINK_HEAP TRUE #define HAS_SIGALTSTACK FALSE #define NEEDS_SIGALTSTACK_EXEC FALSE #define HAS_SPAWN TRUE diff --git a/runtime/platform/darwin.h b/runtime/platform/darwin.h index e5af03e32..ac2a0d936 100644 --- a/runtime/platform/darwin.h +++ b/runtime/platform/darwin.h @@ -34,6 +34,7 @@ #define HAS_FEROUND TRUE #define HAS_MSG_DONTWAIT TRUE #define HAS_REMAP FALSE +#define HAS_SHRINK_HEAP TRUE #define HAS_SIGALTSTACK TRUE #define NEEDS_SIGALTSTACK_EXEC FALSE #define HAS_SPAWN FALSE diff --git a/runtime/platform/freebsd.h b/runtime/platform/freebsd.h index 85d685df0..919127ec1 100644 --- a/runtime/platform/freebsd.h +++ b/runtime/platform/freebsd.h @@ -30,6 +30,7 @@ #define HAS_FEROUND TRUE #define HAS_MSG_DONTWAIT TRUE #define HAS_REMAP FALSE +#define HAS_SHRINK_HEAP TRUE #define HAS_SIGALTSTACK TRUE #define NEEDS_SIGALTSTACK_EXEC FALSE #define HAS_SPAWN FALSE diff --git a/runtime/platform/hpux.h b/runtime/platform/hpux.h index 62d83b649..aa8de42de 100644 --- a/runtime/platform/hpux.h +++ b/runtime/platform/hpux.h @@ -52,6 +52,7 @@ #define HAS_FEROUND TRUE #define HAS_MSG_DONTWAIT FALSE #define HAS_REMAP FALSE +#define HAS_SHRINK_HEAP TRUE #define HAS_SIGALTSTACK TRUE #define NEEDS_SIGALTSTACK_EXEC FALSE #define HAS_SPAWN FALSE diff --git a/runtime/platform/hurd.h b/runtime/platform/hurd.h index 7dbc46d5c..68fc44e88 100644 --- a/runtime/platform/hurd.h +++ b/runtime/platform/hurd.h @@ -30,6 +30,7 @@ #define HAS_FEROUND TRUE #define HAS_MSG_DONTWAIT TRUE #define HAS_REMAP TRUE +#define HAS_SHRINK_HEAP TRUE #define HAS_SIGALTSTACK TRUE #define NEEDS_SIGALTSTACK_EXEC FALSE #define HAS_SPAWN FALSE diff --git a/runtime/platform/linux.h b/runtime/platform/linux.h index 3f1ce7a60..423f9e11b 100644 --- a/runtime/platform/linux.h +++ b/runtime/platform/linux.h @@ -38,6 +38,7 @@ #endif #define HAS_MSG_DONTWAIT TRUE #define HAS_REMAP TRUE +#define HAS_SHRINK_HEAP TRUE #define HAS_SIGALTSTACK TRUE #if (defined (__hppa__)) #define NEEDS_SIGALTSTACK_EXEC TRUE diff --git a/runtime/platform/mingw.h b/runtime/platform/mingw.h index f99352eb0..7441ee5e2 100644 --- a/runtime/platform/mingw.h +++ b/runtime/platform/mingw.h @@ -33,6 +33,7 @@ #define HAS_FEROUND FALSE #define HAS_MSG_DONTWAIT FALSE #define HAS_REMAP TRUE +#define HAS_SHRINK_HEAP TRUE #define HAS_SIGALTSTACK FALSE #define NEEDS_SIGALTSTACK_EXEC FALSE #define HAS_SPAWN TRUE diff --git a/runtime/platform/netbsd.h b/runtime/platform/netbsd.h index d2aef2e84..6bea1a501 100644 --- a/runtime/platform/netbsd.h +++ b/runtime/platform/netbsd.h @@ -30,6 +30,7 @@ #define HAS_FEROUND FALSE #define HAS_MSG_DONTWAIT TRUE #define HAS_REMAP FALSE +#define HAS_SHRINK_HEAP TRUE #define HAS_SIGALTSTACK TRUE #define NEEDS_SIGALTSTACK_EXEC FALSE #define HAS_SPAWN FALSE diff --git a/runtime/platform/openbsd.h b/runtime/platform/openbsd.h index c6ca591e6..ffb816e0c 100644 --- a/runtime/platform/openbsd.h +++ b/runtime/platform/openbsd.h @@ -30,6 +30,7 @@ #define HAS_FEROUND FALSE #define HAS_MSG_DONTWAIT TRUE #define HAS_REMAP FALSE +#define HAS_SHRINK_HEAP TRUE #define HAS_SIGALTSTACK TRUE #define NEEDS_SIGALTSTACK_EXEC FALSE #define HAS_SPAWN FALSE diff --git a/runtime/platform/solaris.h b/runtime/platform/solaris.h index 456d7fc7e..b752f3454 100644 --- a/runtime/platform/solaris.h +++ b/runtime/platform/solaris.h @@ -34,6 +34,7 @@ #define HAS_FEROUND TRUE #define HAS_MSG_DONTWAIT TRUE #define HAS_REMAP FALSE +#define HAS_SHRINK_HEAP TRUE #define HAS_SIGALTSTACK TRUE #define NEEDS_SIGALTSTACK_EXEC FALSE #define HAS_SPAWN FALSE diff --git a/runtime/platform/wasi.h b/runtime/platform/wasi.h index 6b046d2e3..e978246bf 100644 --- a/runtime/platform/wasi.h +++ b/runtime/platform/wasi.h @@ -20,6 +20,7 @@ #define HAS_FEROUND TRUE #define HAS_MSG_DONTWAIT TRUE #define HAS_REMAP FALSE +#define HAS_SHRINK_HEAP FALSE #define HAS_SIGALTSTACK FALSE #define NEEDS_SIGALTSTACK_EXEC FALSE #define HAS_SPAWN FALSE