diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2017-10-02 08:31:38 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-10-02 08:31:38 +0200 |
commit | e9243a16167b24899d4fcf051f3252b3a5804811 (patch) | |
tree | dc4733a6f178d4f04ee4da33c50ca807eb7e9dd0 /lib/system/gc_common.nim | |
parent | fc7961d4ccd31ab6e7eabbeb7aa22b5488924b4f (diff) | |
parent | 02ff5f596c330b68927f843814ecb9b86c2eee67 (diff) | |
download | Nim-e9243a16167b24899d4fcf051f3252b3a5804811.tar.gz |
Merge branch 'devel' into araq
Diffstat (limited to 'lib/system/gc_common.nim')
-rw-r--r-- | lib/system/gc_common.nim | 20 |
1 files changed, 15 insertions, 5 deletions
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: |