From 07531b41b9a3f1441c66ee157138915b34789ec1 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Fri, 22 Sep 2017 11:12:14 +0200 Subject: make gc:v2 compile again --- lib/system/gc_common.nim | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'lib/system/gc_common.nim') diff --git a/lib/system/gc_common.nim b/lib/system/gc_common.nim index 220331e96..484a4db9a 100644 --- a/lib/system/gc_common.nim +++ b/lib/system/gc_common.nim @@ -373,12 +373,22 @@ proc deallocHeap*(runFinalizers = true; allowGcAfterwards = true) = ## is true. If ``allowGcAfterwards`` is true, a minimal amount of allocation ## happens to ensure the GC can continue to work after the call ## to ``deallocHeap``. + template deallocCell(x) = + if isCell(x): + # cast to PCell is correct here: + prepareDealloc(cast[PCell](x)) + if runFinalizers: - for x in allObjects(gch.region): - if isCell(x): - # cast to PCell is correct here: - var c = cast[PCell](x) - prepareDealloc(c) + when not declared(allObjectsAsProc): + for x in allObjects(gch.region): + deallocCell(x) + else: + var spaceIter: ObjectSpaceIter + while true: + let x = allObjectsAsProc(gch.region, addr spaceIter) + if spaceIter.state < 0: break + deallocCell(x) + deallocOsPages(gch.region) zeroMem(addr gch.region, sizeof(gch.region)) if allowGcAfterwards: -- cgit 1.4.1-2-gfad0