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,6 +427,7 @@ 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
when compileOption("gc", "v2"):
gcDebugging = true gcDebugging = true
echo "COLLECT 1" echo "COLLECT 1"
GC_fullCollect() GC_fullCollect()

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)

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

File diff suppressed because it is too large Load diff

1050
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,6 +203,7 @@ 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):
when compileOption("gc", "v2"):
for i in newLen..result.len-1: for i in newLen..result.len-1:
let len0 = gch.tempStack.len let len0 = gch.tempStack.len
forAllChildrenAux(cast[pointer](cast[TAddress](result) +% forAllChildrenAux(cast[pointer](cast[TAddress](result) +%
@ -212,6 +213,11 @@ proc setLengthSeq(seq: PGenericSeq, elemSize, newLen: int): PGenericSeq {.
for i in len0 .. <len1: for i in len0 .. <len1:
doDecRef(gch.tempStack.d[i], LocalHeap, MaybeCyclic) doDecRef(gch.tempStack.d[i], LocalHeap, MaybeCyclic)
gch.tempStack.len = len0 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).