mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-03 02:18:00 +00:00
revert to old GC; use --gc:v2 to activate the new GC
This commit is contained in:
@@ -427,14 +427,15 @@ proc resetMemory =
|
||||
# XXX: detect config reloading (implement as error/require restart)
|
||||
# XXX: options are appended (they will accumulate over time)
|
||||
# vis = visimpl
|
||||
gcDebugging = true
|
||||
echo "COLLECT 1"
|
||||
GC_fullCollect()
|
||||
echo "COLLECT 2"
|
||||
GC_fullCollect()
|
||||
echo "COLLECT 3"
|
||||
GC_fullCollect()
|
||||
echo GC_getStatistics()
|
||||
when compileOption("gc", "v2"):
|
||||
gcDebugging = true
|
||||
echo "COLLECT 1"
|
||||
GC_fullCollect()
|
||||
echo "COLLECT 2"
|
||||
GC_fullCollect()
|
||||
echo "COLLECT 3"
|
||||
GC_fullCollect()
|
||||
echo GC_getStatistics()
|
||||
|
||||
const
|
||||
SimiluateCaasMemReset = false
|
||||
|
||||
@@ -69,11 +69,12 @@ proc HandleCmdLine() =
|
||||
changeFileExt(gProjectFull, exeExt).prependCurDir)
|
||||
execExternalProgram(ex & ' ' & service.arguments)
|
||||
|
||||
#GC_disableMarkAndSweep()
|
||||
|
||||
when defined(GC_setMaxPause):
|
||||
GC_setMaxPause 2_000
|
||||
GC_disableMarkAndSweep()
|
||||
|
||||
when compileOption("gc", "v2"):
|
||||
# the new correct mark&sweet collector is too slow :-/
|
||||
GC_disableMarkAndSweep()
|
||||
condsyms.InitDefines()
|
||||
HandleCmdLine()
|
||||
quit(options.gExitcode)
|
||||
|
||||
1062
lib/system/gc.nim
Executable file → Normal file
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
1118
lib/system/oldgc.nim → lib/system/gc2.nim
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
@@ -307,10 +307,10 @@ else:
|
||||
include "system/cellsets"
|
||||
when not leakDetector:
|
||||
sysAssert(sizeof(TCell) == sizeof(TFreeCell), "sizeof TFreeCell")
|
||||
when true:
|
||||
include "system/gc"
|
||||
when compileOption("gc", "v2"):
|
||||
include "system/gc2"
|
||||
else:
|
||||
include "system/oldgc"
|
||||
include "system/gc"
|
||||
|
||||
{.pop.}
|
||||
|
||||
|
||||
@@ -203,16 +203,22 @@ proc setLengthSeq(seq: PGenericSeq, elemSize, newLen: int): PGenericSeq {.
|
||||
elif newLen < result.len:
|
||||
# we need to decref here, otherwise the GC leaks!
|
||||
when not defined(boehmGC) and not defined(nogc):
|
||||
for i in newLen..result.len-1:
|
||||
let len0 = gch.tempStack.len
|
||||
forAllChildrenAux(cast[pointer](cast[TAddress](result) +%
|
||||
GenericSeqSize +% (i*%elemSize)),
|
||||
extGetCellType(result).base, waPush)
|
||||
let len1 = gch.tempStack.len
|
||||
for i in len0 .. <len1:
|
||||
doDecRef(gch.tempStack.d[i], LocalHeap, MaybeCyclic)
|
||||
gch.tempStack.len = len0
|
||||
|
||||
when compileOption("gc", "v2"):
|
||||
for i in newLen..result.len-1:
|
||||
let len0 = gch.tempStack.len
|
||||
forAllChildrenAux(cast[pointer](cast[TAddress](result) +%
|
||||
GenericSeqSize +% (i*%elemSize)),
|
||||
extGetCellType(result).base, waPush)
|
||||
let len1 = gch.tempStack.len
|
||||
for i in len0 .. <len1:
|
||||
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
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user