added GC_addCycleRoot

This commit is contained in:
Araq
2013-02-12 08:45:01 +01:00
parent 5e7dd69b00
commit 0f2aa053d9
3 changed files with 16 additions and 4 deletions

View File

@@ -207,6 +207,12 @@ proc incRef(c: PCell) {.inline.} =
proc nimGCref(p: pointer) {.compilerProc, inline.} = incRef(usrToCell(p))
proc nimGCunref(p: pointer) {.compilerProc, inline.} = decRef(usrToCell(p))
proc GC_addCycleRoot*[T](p: ref T) {.inline.} =
## adds 'p' to the cycle candidate set for the cycle collector. It is
## necessary if you used the 'acyclic' pragma for optimization
## purposes and need to break cycles manually.
rtlAddCycleRoot(usrToCell(cast[pointer](p)))
proc nimGCunrefNoCycle(p: pointer) {.compilerProc, inline.} =
sysAssert(allocInv(gch.region), "begin nimGCunrefNoCycle")
var c = usrToCell(p)