first version of a simple mark&sweep GC; activate with --gc:markAndSweep
This commit is contained in:
parent
f96d612e98
commit
ab6f793408
12 changed files with 834 additions and 89 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2012 Andreas Rumpf
|
||||
# (c) Copyright 2013 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
# included from cgen.nim
|
||||
|
||||
type
|
||||
TTraversalClosure {.pure, final.} = object
|
||||
TTraversalClosure = object
|
||||
p: BProc
|
||||
visitorFrmt: string
|
||||
|
||||
|
|
@ -127,3 +127,20 @@ proc genTraverseProc(m: BModule, typ: PType, reason: TTypeInfoReason): PRope =
|
|||
m.s[cfsProcs].app(generatedProc)
|
||||
|
||||
|
||||
proc genTraverseProcForGlobal(m: BModule, s: PSym): PRope =
|
||||
discard genTypeInfo(m, s.loc.t)
|
||||
|
||||
var c: TTraversalClosure
|
||||
var p = newProc(nil, m)
|
||||
result = getGlobalTempName()
|
||||
|
||||
c.visitorFrmt = "#nimGCvisit((void*)$1, 0);$n"
|
||||
c.p = p
|
||||
let header = ropef("N_NIMCALL(void, $1)()", result)
|
||||
genTraverseProc(c, s.loc.r, s.loc.t)
|
||||
|
||||
let generatedProc = ropef("$1 {$n$2$3$4}$n",
|
||||
[header, p.s(cpsLocals), p.s(cpsInit), p.s(cpsStmts)])
|
||||
|
||||
m.s[cfsProcHeaders].appf("$1;$n", header)
|
||||
m.s[cfsProcs].app(generatedProc)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue