followup #17225: simplify code after removing gc2, generational (#17242)

This commit is contained in:
Timothee Cour
2021-03-03 04:37:42 -08:00
committed by GitHub
parent 6391f6e861
commit f561afae41
8 changed files with 15 additions and 16 deletions

View File

@@ -11,7 +11,7 @@
# We do this here before the 'import' statement so 'defined' does not get
# confused with 'TGCMode.gcGenerational' etc.
# confused with 'TGCMode.gcMarkAndSweep' etc.
template bootSwitch(name, expr, userString) =
# Helper to build boot constants, for debugging you can 'echo' the else part.
const name = if expr: " " & userString else: ""
@@ -22,7 +22,6 @@ bootSwitch(usedDanger, defined(danger), "-d:danger")
bootSwitch(useLinenoise, defined(nimUseLinenoise) or defined(useLinenoise), "-d:nimUseLinenoise")
bootSwitch(usedBoehm, defined(boehmgc), "--gc:boehm")
bootSwitch(usedMarkAndSweep, defined(gcmarkandsweep), "--gc:markAndSweep")
bootSwitch(usedGenerational, defined(gcgenerational), "--gc:generational")
bootSwitch(usedGoGC, defined(gogc), "--gc:go")
bootSwitch(usedNoGC, defined(nogc), "--gc:none")
@@ -97,12 +96,13 @@ proc writeVersionInfo(conf: ConfigRef; pass: TCmdLinePass) =
{msgStdout})
const gitHash {.strdefine.} = gorge("git log -n 1 --format=%H").strip
# xxx move this logic to std/private/gitutils
when gitHash.len == 40:
msgWriteln(conf, "git hash: " & gitHash, {msgStdout})
msgWriteln(conf, "active boot switches:" & usedRelease & usedDanger &
usedTinyC & useLinenoise & usedNativeStacktrace &
usedFFI & usedBoehm & usedMarkAndSweep & usedGenerational & usedGoGC & usedNoGC,
usedFFI & usedBoehm & usedMarkAndSweep & usedGoGC & usedNoGC,
{msgStdout})
msgQuit(0)
@@ -247,13 +247,13 @@ proc testCompileOptionArg*(conf: ConfigRef; switch, arg: string, info: TLineInfo
of "boehm": result = conf.selectedGC == gcBoehm
of "refc": result = conf.selectedGC == gcRefc
of "markandsweep": result = conf.selectedGC == gcMarkAndSweep
of "v2", "generational": warningOptionNoop(arg)
of "destructors", "arc": result = conf.selectedGC == gcArc
of "orc": result = conf.selectedGC == gcOrc
of "hooks": result = conf.selectedGC == gcHooks
of "go": result = conf.selectedGC == gcGo
of "none": result = conf.selectedGC == gcNone
of "stack", "regions": result = conf.selectedGC == gcRegions
of "v2", "generational": warningOptionNoop(arg)
else: localError(conf, info, errNoneBoehmRefcExpectedButXFound % arg)
of "opt":
case arg.normalize
@@ -560,8 +560,6 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
incl conf.globalOptions, optTlsEmulation # Boehm GC doesn't scan the real TLS
of "refc":
conf.selectedGC = gcRefc
of "v2":
message(conf, info, warnDeprecated, "--gc:v2 is deprecated; using default gc")
of "markandsweep":
conf.selectedGC = gcMarkAndSweep
defineSymbol(conf.symbols, "gcmarkandsweep")
@@ -603,6 +601,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
of "stack", "regions":
conf.selectedGC = gcRegions
defineSymbol(conf.symbols, "gcregions")
of "v2": warningOptionNoop(arg)
else: localError(conf, info, errNoneBoehmRefcExpectedButXFound % arg)
of "warnings", "w":
if processOnOffSwitchOrList(conf, {optWarns}, arg, pass, info): listWarnings(conf)

View File

@@ -116,7 +116,7 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =
when declared(GC_setMaxPause):
GC_setMaxPause 2_000
when compileOption("gc", "v2") or compileOption("gc", "refc"):
when compileOption("gc", "refc"):
# the new correct mark&sweet collector is too slow :-/
GC_disableMarkAndSweep()

View File

@@ -103,7 +103,7 @@ proc handleCmdLine(config: ConfigRef) =
processCmdLine(passCmd2, "", config)
mainCommand()
when compileOption("gc", "v2") or compileOption("gc", "refc"):
when compileOption("gc", "refc"):
GC_disableMarkAndSweep()
condsyms.initDefines()

View File

@@ -1271,7 +1271,7 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =
mainCommand(graph)
if conf.hasHint(hintGCStats): echo(GC_getStatistics())
when compileOption("gc", "v2") or compileOption("gc", "refc"):
when compileOption("gc", "refc"):
# the new correct mark&sweep collector is too slow :-/
GC_disableMarkAndSweep()

View File

@@ -1909,9 +1909,8 @@ include "system/gc_interface"
const NimStackTrace = compileOption("stacktrace")
template coroutinesSupportedPlatform(): bool =
when defined(sparc) or defined(ELATE) or compileOption("gc", "v2") or
defined(boehmgc) or defined(gogc) or defined(nogc) or defined(gcRegions) or
defined(gcMarkAndSweep):
when defined(sparc) or defined(ELATE) or defined(boehmgc) or defined(gogc) or
defined(nogc) or defined(gcRegions) or defined(gcMarkAndSweep):
false
else:
true

View File

@@ -7,6 +7,9 @@
# distribution, for details about the copyright.
#
# xxx deadcode, consider removing unless something could be reused.
# Garbage Collector
#
# The basic algorithm is an incremental mark

View File

@@ -68,9 +68,7 @@ else:
include "system/cellsets"
when not leakDetector and not useCellIds and not defined(nimV2):
sysAssert(sizeof(Cell) == sizeof(FreeCell), "sizeof FreeCell")
when compileOption("gc", "v2"):
include "system/gc2"
elif defined(gcRegions):
when defined(gcRegions):
# XXX due to bootstrapping reasons, we cannot use compileOption("gc", "stack") here
include "system/gc_regions"
elif defined(nimV2) or usesDestructors:

View File

@@ -304,7 +304,7 @@ proc setLengthSeq(seq: PGenericSeq, elemSize, elemAlign, newLen: int): PGenericS
when not defined(boehmGC) and not defined(nogc) and
not defined(gcMarkAndSweep) and not defined(gogc) and
not defined(gcRegions):
when false: # compileOption("gc", "v2"):
when false: # deadcode: was used by `compileOption("gc", "v2")`
for i in newLen..result.len-1:
let len0 = gch.tempStack.len
forAllChildrenAux(dataPointer(result, elemAlign, elemSize, i),