Make gc v2 compile with --threads:on

This commit is contained in:
Yuriy Glukhov 2016-10-05 20:36:22 +03:00
commit 1bfcea5d5c
2 changed files with 10 additions and 4 deletions

View file

@ -2731,7 +2731,7 @@ when not defined(JS): #and not defined(nimscript):
proc setStdIoUnbuffered*() {.tags: [], benign.} proc setStdIoUnbuffered*() {.tags: [], benign.}
## Configures `stdin`, `stdout` and `stderr` to be unbuffered. ## Configures `stdin`, `stdout` and `stderr` to be unbuffered.
proc close*(f: File) {.tags: [].} proc close*(f: File) {.tags: [], gcsafe.}
## Closes the file. ## Closes the file.
proc endOfFile*(f: File): bool {.tags: [], benign.} proc endOfFile*(f: File): bool {.tags: [], benign.}

View file

@ -33,6 +33,9 @@ when withRealTime and not declared(getTicks):
when defined(memProfiler): when defined(memProfiler):
proc nimProfile(requestedSize: int) {.benign.} proc nimProfile(requestedSize: int) {.benign.}
when hasThreadSupport:
include sharedlist
type type
ObjectSpaceIter = object ObjectSpaceIter = object
state: range[-1..0] state: range[-1..0]
@ -96,7 +99,7 @@ type
stat: GcStat stat: GcStat
additionalRoots: CellSeq # dummy roots for GC_ref/unref additionalRoots: CellSeq # dummy roots for GC_ref/unref
spaceIter: ObjectSpaceIter spaceIter: ObjectSpaceIter
dumpHeapFile: File # File that is used for GC_dumpHeap pDumpHeapFile: pointer # File that is used for GC_dumpHeap
when hasThreadSupport: when hasThreadSupport:
toDispose: SharedList[pointer] toDispose: SharedList[pointer]
@ -612,6 +615,9 @@ template checkTime {.dirty.} =
# ---------------- dump heap ---------------- # ---------------- dump heap ----------------
template dumpHeapFile(gch: var GcHeap): File =
cast[File](gch.pDumpHeapFile)
proc debugGraph(s: PCell) = proc debugGraph(s: PCell) =
c_fprintf(gch.dumpHeapFile, "child %p\n", s) c_fprintf(gch.dumpHeapFile, "child %p\n", s)
@ -625,7 +631,7 @@ proc GC_dumpHeap*(file: File) =
## Dumps the GCed heap's content to a file. Can be useful for ## Dumps the GCed heap's content to a file. Can be useful for
## debugging. Produces an undocumented text file format that ## debugging. Produces an undocumented text file format that
## can be translated into "dot" syntax via the "heapdump2dot" tool. ## can be translated into "dot" syntax via the "heapdump2dot" tool.
gch.dumpHeapFile = file gch.pDumpHeapFile = file
var spaceIter: ObjectSpaceIter var spaceIter: ObjectSpaceIter
var d = gch.decStack.d var d = gch.decStack.d
for i in 0 .. < gch.decStack.len: for i in 0 .. < gch.decStack.len:
@ -643,7 +649,7 @@ proc GC_dumpHeap*(file: File) =
writeCell(file, "cell ", c) writeCell(file, "cell ", c)
forAllChildren(c, waDebug) forAllChildren(c, waDebug)
c_fprintf(file, "end\n") c_fprintf(file, "end\n")
gch.dumpHeapFile = nil gch.pDumpHeapFile = nil
proc GC_dumpHeap() = proc GC_dumpHeap() =
var f: File var f: File