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
commit f561afae41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 # 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) = template bootSwitch(name, expr, userString) =
# Helper to build boot constants, for debugging you can 'echo' the else part. # Helper to build boot constants, for debugging you can 'echo' the else part.
const name = if expr: " " & userString else: "" 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(useLinenoise, defined(nimUseLinenoise) or defined(useLinenoise), "-d:nimUseLinenoise")
bootSwitch(usedBoehm, defined(boehmgc), "--gc:boehm") bootSwitch(usedBoehm, defined(boehmgc), "--gc:boehm")
bootSwitch(usedMarkAndSweep, defined(gcmarkandsweep), "--gc:markAndSweep") bootSwitch(usedMarkAndSweep, defined(gcmarkandsweep), "--gc:markAndSweep")
bootSwitch(usedGenerational, defined(gcgenerational), "--gc:generational")
bootSwitch(usedGoGC, defined(gogc), "--gc:go") bootSwitch(usedGoGC, defined(gogc), "--gc:go")
bootSwitch(usedNoGC, defined(nogc), "--gc:none") bootSwitch(usedNoGC, defined(nogc), "--gc:none")
@ -97,12 +96,13 @@ proc writeVersionInfo(conf: ConfigRef; pass: TCmdLinePass) =
{msgStdout}) {msgStdout})
const gitHash {.strdefine.} = gorge("git log -n 1 --format=%H").strip const gitHash {.strdefine.} = gorge("git log -n 1 --format=%H").strip
# xxx move this logic to std/private/gitutils
when gitHash.len == 40: when gitHash.len == 40:
msgWriteln(conf, "git hash: " & gitHash, {msgStdout}) msgWriteln(conf, "git hash: " & gitHash, {msgStdout})
msgWriteln(conf, "active boot switches:" & usedRelease & usedDanger & msgWriteln(conf, "active boot switches:" & usedRelease & usedDanger &
usedTinyC & useLinenoise & usedNativeStacktrace & usedTinyC & useLinenoise & usedNativeStacktrace &
usedFFI & usedBoehm & usedMarkAndSweep & usedGenerational & usedGoGC & usedNoGC, usedFFI & usedBoehm & usedMarkAndSweep & usedGoGC & usedNoGC,
{msgStdout}) {msgStdout})
msgQuit(0) msgQuit(0)
@ -247,13 +247,13 @@ proc testCompileOptionArg*(conf: ConfigRef; switch, arg: string, info: TLineInfo
of "boehm": result = conf.selectedGC == gcBoehm of "boehm": result = conf.selectedGC == gcBoehm
of "refc": result = conf.selectedGC == gcRefc of "refc": result = conf.selectedGC == gcRefc
of "markandsweep": result = conf.selectedGC == gcMarkAndSweep of "markandsweep": result = conf.selectedGC == gcMarkAndSweep
of "v2", "generational": warningOptionNoop(arg)
of "destructors", "arc": result = conf.selectedGC == gcArc of "destructors", "arc": result = conf.selectedGC == gcArc
of "orc": result = conf.selectedGC == gcOrc of "orc": result = conf.selectedGC == gcOrc
of "hooks": result = conf.selectedGC == gcHooks of "hooks": result = conf.selectedGC == gcHooks
of "go": result = conf.selectedGC == gcGo of "go": result = conf.selectedGC == gcGo
of "none": result = conf.selectedGC == gcNone of "none": result = conf.selectedGC == gcNone
of "stack", "regions": result = conf.selectedGC == gcRegions of "stack", "regions": result = conf.selectedGC == gcRegions
of "v2", "generational": warningOptionNoop(arg)
else: localError(conf, info, errNoneBoehmRefcExpectedButXFound % arg) else: localError(conf, info, errNoneBoehmRefcExpectedButXFound % arg)
of "opt": of "opt":
case arg.normalize 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 incl conf.globalOptions, optTlsEmulation # Boehm GC doesn't scan the real TLS
of "refc": of "refc":
conf.selectedGC = gcRefc conf.selectedGC = gcRefc
of "v2":
message(conf, info, warnDeprecated, "--gc:v2 is deprecated; using default gc")
of "markandsweep": of "markandsweep":
conf.selectedGC = gcMarkAndSweep conf.selectedGC = gcMarkAndSweep
defineSymbol(conf.symbols, "gcmarkandsweep") defineSymbol(conf.symbols, "gcmarkandsweep")
@ -603,6 +601,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
of "stack", "regions": of "stack", "regions":
conf.selectedGC = gcRegions conf.selectedGC = gcRegions
defineSymbol(conf.symbols, "gcregions") defineSymbol(conf.symbols, "gcregions")
of "v2": warningOptionNoop(arg)
else: localError(conf, info, errNoneBoehmRefcExpectedButXFound % arg) else: localError(conf, info, errNoneBoehmRefcExpectedButXFound % arg)
of "warnings", "w": of "warnings", "w":
if processOnOffSwitchOrList(conf, {optWarns}, arg, pass, info): listWarnings(conf) 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): when declared(GC_setMaxPause):
GC_setMaxPause 2_000 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 :-/ # the new correct mark&sweet collector is too slow :-/
GC_disableMarkAndSweep() GC_disableMarkAndSweep()

View file

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

View file

@ -1271,7 +1271,7 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =
mainCommand(graph) mainCommand(graph)
if conf.hasHint(hintGCStats): echo(GC_getStatistics()) 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 :-/ # the new correct mark&sweep collector is too slow :-/
GC_disableMarkAndSweep() GC_disableMarkAndSweep()

View file

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

View file

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

View file

@ -68,9 +68,7 @@ else:
include "system/cellsets" include "system/cellsets"
when not leakDetector and not useCellIds and not defined(nimV2): when not leakDetector and not useCellIds and not defined(nimV2):
sysAssert(sizeof(Cell) == sizeof(FreeCell), "sizeof FreeCell") sysAssert(sizeof(Cell) == sizeof(FreeCell), "sizeof FreeCell")
when compileOption("gc", "v2"): when defined(gcRegions):
include "system/gc2"
elif defined(gcRegions):
# XXX due to bootstrapping reasons, we cannot use compileOption("gc", "stack") here # XXX due to bootstrapping reasons, we cannot use compileOption("gc", "stack") here
include "system/gc_regions" include "system/gc_regions"
elif defined(nimV2) or usesDestructors: 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 when not defined(boehmGC) and not defined(nogc) and
not defined(gcMarkAndSweep) and not defined(gogc) and not defined(gcMarkAndSweep) and not defined(gogc) and
not defined(gcRegions): not defined(gcRegions):
when false: # compileOption("gc", "v2"): when false: # deadcode: was used by `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(dataPointer(result, elemAlign, elemSize, i), forAllChildrenAux(dataPointer(result, elemAlign, elemSize, i),