revert to old GC; use --gc:v2 to activate the new GC

This commit is contained in:
Araq 2013-01-31 17:24:55 +01:00
commit 65fdd641a9
6 changed files with 1067 additions and 1169 deletions

View file

@ -427,14 +427,15 @@ proc resetMemory =
# XXX: detect config reloading (implement as error/require restart) # XXX: detect config reloading (implement as error/require restart)
# XXX: options are appended (they will accumulate over time) # XXX: options are appended (they will accumulate over time)
# vis = visimpl # vis = visimpl
gcDebugging = true when compileOption("gc", "v2"):
echo "COLLECT 1" gcDebugging = true
GC_fullCollect() echo "COLLECT 1"
echo "COLLECT 2" GC_fullCollect()
GC_fullCollect() echo "COLLECT 2"
echo "COLLECT 3" GC_fullCollect()
GC_fullCollect() echo "COLLECT 3"
echo GC_getStatistics() GC_fullCollect()
echo GC_getStatistics()
const const
SimiluateCaasMemReset = false SimiluateCaasMemReset = false

View file

@ -69,11 +69,12 @@ proc HandleCmdLine() =
changeFileExt(gProjectFull, exeExt).prependCurDir) changeFileExt(gProjectFull, exeExt).prependCurDir)
execExternalProgram(ex & ' ' & service.arguments) execExternalProgram(ex & ' ' & service.arguments)
#GC_disableMarkAndSweep()
when defined(GC_setMaxPause): when defined(GC_setMaxPause):
GC_setMaxPause 2_000 GC_setMaxPause 2_000
GC_disableMarkAndSweep()
when compileOption("gc", "v2"):
# the new correct mark&sweet collector is too slow :-/
GC_disableMarkAndSweep()
condsyms.InitDefines() condsyms.InitDefines()
HandleCmdLine() HandleCmdLine()
quit(options.gExitcode) quit(options.gExitcode)

1062
lib/system/gc.nim Executable file → Normal file

File diff suppressed because it is too large Load diff

1118
lib/system/oldgc.nim → lib/system/gc2.nim Normal file → Executable file

File diff suppressed because it is too large Load diff

View file

@ -307,10 +307,10 @@ else:
include "system/cellsets" include "system/cellsets"
when not leakDetector: when not leakDetector:
sysAssert(sizeof(TCell) == sizeof(TFreeCell), "sizeof TFreeCell") sysAssert(sizeof(TCell) == sizeof(TFreeCell), "sizeof TFreeCell")
when true: when compileOption("gc", "v2"):
include "system/gc" include "system/gc2"
else: else:
include "system/oldgc" include "system/gc"
{.pop.} {.pop.}

View file

@ -203,16 +203,22 @@ proc setLengthSeq(seq: PGenericSeq, elemSize, newLen: int): PGenericSeq {.
elif newLen < result.len: elif newLen < result.len:
# we need to decref here, otherwise the GC leaks! # we need to decref here, otherwise the GC leaks!
when not defined(boehmGC) and not defined(nogc): when not defined(boehmGC) and not defined(nogc):
for i in newLen..result.len-1: when compileOption("gc", "v2"):
let len0 = gch.tempStack.len for i in newLen..result.len-1:
forAllChildrenAux(cast[pointer](cast[TAddress](result) +% let len0 = gch.tempStack.len
GenericSeqSize +% (i*%elemSize)), forAllChildrenAux(cast[pointer](cast[TAddress](result) +%
extGetCellType(result).base, waPush) GenericSeqSize +% (i*%elemSize)),
let len1 = gch.tempStack.len extGetCellType(result).base, waPush)
for i in len0 .. <len1: let len1 = gch.tempStack.len
doDecRef(gch.tempStack.d[i], LocalHeap, MaybeCyclic) for i in len0 .. <len1:
gch.tempStack.len = len0 doDecRef(gch.tempStack.d[i], LocalHeap, MaybeCyclic)
gch.tempStack.len = len0
else:
for i in newLen..result.len-1:
forAllChildrenAux(cast[pointer](cast[TAddress](result) +%
GenericSeqSize +% (i*%elemSize)),
extGetCellType(result).base, waZctDecRef)
# XXX: zeroing out the memory can still result in crashes if a wiped-out # XXX: zeroing out the memory can still result in crashes if a wiped-out
# cell is aliased by another pointer (ie proc paramter or a let variable). # cell is aliased by another pointer (ie proc paramter or a let variable).
# This is a tought problem, because even if we don't zeroMem here, in the # This is a tought problem, because even if we don't zeroMem here, in the