Make ./koch temp --gc:arc work (#14186)

This commit is contained in:
Clyybber 2020-05-01 20:25:18 +02:00 • committed by GitHub
commit 1f1e4de3bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 11 deletions

View file

@ -1824,7 +1824,10 @@ template injectG() {.dirty.} =
graph.backend = newModuleList(graph) graph.backend = newModuleList(graph)
let g = BModuleList(graph.backend) let g = BModuleList(graph.backend)
proc myOpen(graph: ModuleGraph; module: PSym): PPassContext = when not defined(nimHasSinkInference):
{.pragma: nosinks.}
proc myOpen(graph: ModuleGraph; module: PSym): PPassContext {.nosinks.} =
injectG() injectG()
result = newModule(g, module, graph.config) result = newModule(g, module, graph.config)
if optGenIndex in graph.config.globalOptions and g.generatedHeader == nil: if optGenIndex in graph.config.globalOptions and g.generatedHeader == nil:

View file

@ -51,7 +51,10 @@ proc generateDot*(graph: ModuleGraph; project: AbsoluteFile) =
rope(project.splitFile.name), b.dotGraph], rope(project.splitFile.name), b.dotGraph],
changeFileExt(project, "dot")) changeFileExt(project, "dot"))
proc myOpen(graph: ModuleGraph; module: PSym): PPassContext = when not defined(nimHasSinkInference):
{.pragma: nosinks.}
proc myOpen(graph: ModuleGraph; module: PSym): PPassContext {.nosinks.} =
var g: PGen var g: PGen
new(g) new(g)
g.module = module g.module = module

View file

@ -377,6 +377,9 @@ proc semExprFlagDispatched(c: PContext, n: PNode, flags: TExprFlags): PNode =
evaluated = evalAtCompileTime(c, result) evaluated = evalAtCompileTime(c, result)
if evaluated != nil: return evaluated if evaluated != nil: return evaluated
when not defined(nimHasSinkInference):
{.pragma: nosinks.}
include hlo, seminst, semcall include hlo, seminst, semcall
when false: when false:
@ -501,7 +504,7 @@ proc addCodeForGenerics(c: PContext, n: PNode) =
n.add prc.ast n.add prc.ast
c.lastGenericIdx = c.generics.len c.lastGenericIdx = c.generics.len
proc myOpen(graph: ModuleGraph; module: PSym): PPassContext = proc myOpen(graph: ModuleGraph; module: PSym): PPassContext {.nosinks.} =
var c = newContext(graph, module) var c = newContext(graph, module)
if c.p != nil: internalError(graph.config, module.info, "sem.myOpen") if c.p != nil: internalError(graph.config, module.info, "sem.myOpen")
c.semConstExpr = semConstExpr c.semConstExpr = semConstExpr
@ -592,7 +595,7 @@ proc recoverContext(c: PContext) =
while getCurrOwner(c).kind != skModule: popOwner(c) while getCurrOwner(c).kind != skModule: popOwner(c)
while c.p != nil and c.p.owner.kind != skModule: c.p = c.p.next while c.p != nil and c.p.owner.kind != skModule: c.p = c.p.next
proc myProcess(context: PPassContext, n: PNode): PNode = proc myProcess(context: PPassContext, n: PNode): PNode {.nosinks.} =
var c = PContext(context) var c = PContext(context)
# no need for an expensive 'try' if we stop after the first error anyway: # no need for an expensive 'try' if we stop after the first error anyway:
if c.config.errorMax <= 1: if c.config.errorMax <= 1:

View file

@ -549,7 +549,7 @@ proc tryDeref(n: PNode): PNode =
result.add n result.add n
proc semOverloadedCall(c: PContext, n, nOrig: PNode, proc semOverloadedCall(c: PContext, n, nOrig: PNode,
filter: TSymKinds, flags: TExprFlags): PNode = filter: TSymKinds, flags: TExprFlags): PNode {.nosinks.} =
var errors: CandidateErrors = @[] # if efExplain in flags: @[] else: nil var errors: CandidateErrors = @[] # if efExplain in flags: @[] else: nil
var r = resolveOverloads(c, n, nOrig, filter, flags, errors, efExplain in flags) var r = resolveOverloads(c, n, nOrig, filter, flags, errors, efExplain in flags)
if r.state == csMatch: if r.state == csMatch:

View file

@ -320,7 +320,7 @@ proc instantiateProcType(c: PContext, pt: TIdTable,
popInfoContext(c.config) popInfoContext(c.config)
proc generateInstance(c: PContext, fn: PSym, pt: TIdTable, proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
info: TLineInfo): PSym = info: TLineInfo): PSym {.nosinks.} =
## Generates a new instance of a generic procedure. ## Generates a new instance of a generic procedure.
## The `pt` parameter is a type-unsafe mapping table used to link generic ## The `pt` parameter is a type-unsafe mapping table used to link generic
## parameters to their concrete types within the generic instance. ## parameters to their concrete types within the generic instance.

View file

@ -1594,7 +1594,7 @@ proc semLambda(c: PContext, n: PNode, flags: TExprFlags): PNode =
if optOwnedRefs in c.config.globalOptions: if optOwnedRefs in c.config.globalOptions:
result.typ = makeVarType(c, result.typ, tyOwned) result.typ = makeVarType(c, result.typ, tyOwned)
proc semInferredLambda(c: PContext, pt: TIdTable, n: PNode): PNode = proc semInferredLambda(c: PContext, pt: TIdTable, n: PNode): PNode {.nosinks.} =
var n = n var n = n
let original = n[namePos].sym let original = n[namePos].sym

View file

@ -2584,8 +2584,11 @@ proc argtypeMatches*(c: PContext, f, a: PType, fromHlo = false): bool =
# pattern templates do not allow for conversions except from int literal # pattern templates do not allow for conversions except from int literal
res != nil and m.convMatches == 0 and m.intConvMatches in [0, 256] res != nil and m.convMatches == 0 and m.intConvMatches in [0, 256]
when not defined(nimHasSinkInference):
{.pragma: nosinks.}
proc instTypeBoundOp*(c: PContext; dc: PSym; t: PType; info: TLineInfo; proc instTypeBoundOp*(c: PContext; dc: PSym; t: PType; info: TLineInfo;
op: TTypeAttachedOp; col: int): PSym = op: TTypeAttachedOp; col: int): PSym {.nosinks.} =
var m = newCandidate(c, dc.typ) var m = newCandidate(c, dc.typ)
if col >= dc.typ.len: if col >= dc.typ.len:
localError(c.config, info, "cannot instantiate: '" & dc.name.s & "'") localError(c.config, info, "cannot instantiate: '" & dc.name.s & "'")

View file

@ -527,6 +527,9 @@ template maybeHandlePtr(node2: PNode, reg: TFullReg, isAssign2: bool): bool =
else: else:
false false
when not defined(nimHasSinkInference):
{.pragma: nosinks.}
proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
var pc = start var pc = start
var tos = tos var tos = tos
@ -1722,7 +1725,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
var error: string var error: string
let ast = parseString(regs[rb].node.strVal, c.cache, c.config, let ast = parseString(regs[rb].node.strVal, c.cache, c.config,
toFullPath(c.config, c.debug[pc]), c.debug[pc].line.int, toFullPath(c.config, c.debug[pc]), c.debug[pc].line.int,
proc (conf: ConfigRef; info: TLineInfo; msg: TMsgKind; arg: string) = proc (conf: ConfigRef; info: TLineInfo; msg: TMsgKind; arg: string) {.nosinks.} =
if error.len == 0 and msg <= errMax: if error.len == 0 and msg <= errMax:
error = formatMsg(conf, info, msg, arg)) error = formatMsg(conf, info, msg, arg))
if error.len > 0: if error.len > 0:
@ -1737,7 +1740,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
var error: string var error: string
let ast = parseString(regs[rb].node.strVal, c.cache, c.config, let ast = parseString(regs[rb].node.strVal, c.cache, c.config,
toFullPath(c.config, c.debug[pc]), c.debug[pc].line.int, toFullPath(c.config, c.debug[pc]), c.debug[pc].line.int,
proc (conf: ConfigRef; info: TLineInfo; msg: TMsgKind; arg: string) = proc (conf: ConfigRef; info: TLineInfo; msg: TMsgKind; arg: string) {.nosinks.} =
if error.len == 0 and msg <= errMax: if error.len == 0 and msg <= errMax:
error = formatMsg(conf, info, msg, arg)) error = formatMsg(conf, info, msg, arg))
if error.len > 0: if error.len > 0:
@ -2137,7 +2140,7 @@ proc setupGlobalCtx*(module: PSym; graph: ModuleGraph) =
else: else:
refresh(PCtx graph.vm, module) refresh(PCtx graph.vm, module)
proc myOpen(graph: ModuleGraph; module: PSym): PPassContext = proc myOpen(graph: ModuleGraph; module: PSym): PPassContext {.nosinks.} =
#var c = newEvalContext(module, emRepl) #var c = newEvalContext(module, emRepl)
#c.features = {allowCast, allowInfiniteLoops} #c.features = {allowCast, allowInfiniteLoops}
#pushStackFrame(c, newStackFrame()) #pushStackFrame(c, newStackFrame())