Merge pull request #4548 from arnetheduck/gc-cleanup
clean up a few stray c_stdout's in gc debug code
This commit is contained in:
commit
ff351105fb
5 changed files with 20 additions and 19 deletions
|
|
@ -311,7 +311,7 @@ proc freeOsChunks(a: var MemRegion, p: pointer, size: int) =
|
||||||
osDeallocPages(p, size)
|
osDeallocPages(p, size)
|
||||||
decCurrMem(a, size)
|
decCurrMem(a, size)
|
||||||
dec(a.freeMem, size)
|
dec(a.freeMem, size)
|
||||||
#c_fprintf(c_stdout, "[Alloc] back to OS: %ld\n", size)
|
#c_fprintf(stdout, "[Alloc] back to OS: %ld\n", size)
|
||||||
|
|
||||||
proc isAccessible(a: MemRegion, p: pointer): bool {.inline.} =
|
proc isAccessible(a: MemRegion, p: pointer): bool {.inline.} =
|
||||||
result = contains(a.chunkStarts, pageIndex(p))
|
result = contains(a.chunkStarts, pageIndex(p))
|
||||||
|
|
@ -472,7 +472,7 @@ proc rawAlloc(a: var MemRegion, requestedSize: int): pointer =
|
||||||
sysAssert(requestedSize >= sizeof(FreeCell), "rawAlloc: requested size too small")
|
sysAssert(requestedSize >= sizeof(FreeCell), "rawAlloc: requested size too small")
|
||||||
var size = roundup(requestedSize, MemAlign)
|
var size = roundup(requestedSize, MemAlign)
|
||||||
sysAssert(size >= requestedSize, "insufficient allocated size!")
|
sysAssert(size >= requestedSize, "insufficient allocated size!")
|
||||||
#c_fprintf(c_stdout, "alloc; size: %ld; %ld\n", requestedSize, size)
|
#c_fprintf(stdout, "alloc; size: %ld; %ld\n", requestedSize, size)
|
||||||
if size <= SmallChunkSize-smallChunkOverhead():
|
if size <= SmallChunkSize-smallChunkOverhead():
|
||||||
# allocate a small block: for small chunks, we use only its next pointer
|
# allocate a small block: for small chunks, we use only its next pointer
|
||||||
var s = size div MemAlign
|
var s = size div MemAlign
|
||||||
|
|
@ -493,7 +493,7 @@ proc rawAlloc(a: var MemRegion, requestedSize: int): pointer =
|
||||||
sysAssert(allocInv(a), "rawAlloc: begin c != nil")
|
sysAssert(allocInv(a), "rawAlloc: begin c != nil")
|
||||||
sysAssert c.next != c, "rawAlloc 5"
|
sysAssert c.next != c, "rawAlloc 5"
|
||||||
#if c.size != size:
|
#if c.size != size:
|
||||||
# c_fprintf(c_stdout, "csize: %lld; size %lld\n", c.size, size)
|
# c_fprintf(stdout, "csize: %lld; size %lld\n", c.size, size)
|
||||||
sysAssert c.size == size, "rawAlloc 6"
|
sysAssert c.size == size, "rawAlloc 6"
|
||||||
if c.freeList == nil:
|
if c.freeList == nil:
|
||||||
sysAssert(c.acc + smallChunkOverhead() + size <= SmallChunkSize,
|
sysAssert(c.acc + smallChunkOverhead() + size <= SmallChunkSize,
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ type
|
||||||
waMarkGlobal, # part of the backup/debug mark&sweep
|
waMarkGlobal, # part of the backup/debug mark&sweep
|
||||||
waMarkPrecise, # part of the backup/debug mark&sweep
|
waMarkPrecise, # part of the backup/debug mark&sweep
|
||||||
waZctDecRef, waPush
|
waZctDecRef, waPush
|
||||||
|
#, waDebug
|
||||||
|
|
||||||
Finalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign.}
|
Finalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign.}
|
||||||
# A ref type can have a finalizer that is called before the object's
|
# A ref type can have a finalizer that is called before the object's
|
||||||
|
|
@ -654,7 +655,7 @@ when logGC:
|
||||||
else:
|
else:
|
||||||
writeCell("cell {", s)
|
writeCell("cell {", s)
|
||||||
forAllChildren(s, waDebug)
|
forAllChildren(s, waDebug)
|
||||||
c_fprintf(c_stdout, "}\n")
|
c_fprintf(stdout, "}\n")
|
||||||
|
|
||||||
proc doOperation(p: pointer, op: WalkOp) =
|
proc doOperation(p: pointer, op: WalkOp) =
|
||||||
if p == nil: return
|
if p == nil: return
|
||||||
|
|
@ -665,7 +666,7 @@ proc doOperation(p: pointer, op: WalkOp) =
|
||||||
case op
|
case op
|
||||||
of waZctDecRef:
|
of waZctDecRef:
|
||||||
#if not isAllocatedPtr(gch.region, c):
|
#if not isAllocatedPtr(gch.region, c):
|
||||||
# c_fprintf(c_stdout, "[GC] decref bug: %p", c)
|
# c_fprintf(stdout, "[GC] decref bug: %p", c)
|
||||||
gcAssert(isAllocatedPtr(gch.region, c), "decRef: waZctDecRef")
|
gcAssert(isAllocatedPtr(gch.region, c), "decRef: waZctDecRef")
|
||||||
gcAssert(c.refcount >=% rcIncrement, "doOperation 2")
|
gcAssert(c.refcount >=% rcIncrement, "doOperation 2")
|
||||||
#c.refcount = c.refcount -% rcIncrement
|
#c.refcount = c.refcount -% rcIncrement
|
||||||
|
|
@ -828,7 +829,7 @@ proc collectCTBody(gch: var GcHeap) =
|
||||||
gch.stat.maxPause = max(gch.stat.maxPause, duration)
|
gch.stat.maxPause = max(gch.stat.maxPause, duration)
|
||||||
when defined(reportMissedDeadlines):
|
when defined(reportMissedDeadlines):
|
||||||
if gch.maxPause > 0 and duration > gch.maxPause:
|
if gch.maxPause > 0 and duration > gch.maxPause:
|
||||||
c_fprintf(c_stdout, "[GC] missed deadline: %ld\n", duration)
|
c_fprintf(stdout, "[GC] missed deadline: %ld\n", duration)
|
||||||
|
|
||||||
when defined(nimCoroutines):
|
when defined(nimCoroutines):
|
||||||
proc currentStackSizes(): int =
|
proc currentStackSizes(): int =
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ proc writeCell(file: File; msg: cstring, c: PCell) =
|
||||||
msg, id, kind, c.refcount shr rcShift, col)
|
msg, id, kind, c.refcount shr rcShift, col)
|
||||||
|
|
||||||
proc writeCell(msg: cstring, c: PCell) =
|
proc writeCell(msg: cstring, c: PCell) =
|
||||||
c_stdout.writeCell(msg, c)
|
stdout.writeCell(msg, c)
|
||||||
|
|
||||||
proc myastToStr[T](x: T): string {.magic: "AstToStr", noSideEffect.}
|
proc myastToStr[T](x: T): string {.magic: "AstToStr", noSideEffect.}
|
||||||
|
|
||||||
|
|
@ -263,7 +263,7 @@ proc nimGCunref(p: pointer) {.compilerProc.} =
|
||||||
template markGrey(x: PCell) =
|
template markGrey(x: PCell) =
|
||||||
if x.color != 1-gch.black and gch.phase == Phase.Marking:
|
if x.color != 1-gch.black and gch.phase == Phase.Marking:
|
||||||
if not isAllocatedPtr(gch.region, x):
|
if not isAllocatedPtr(gch.region, x):
|
||||||
c_fprintf(c_stdout, "[GC] markGrey proc: %p\n", x)
|
c_fprintf(stdout, "[GC] markGrey proc: %p\n", x)
|
||||||
#GC_dumpHeap()
|
#GC_dumpHeap()
|
||||||
sysAssert(false, "wtf")
|
sysAssert(false, "wtf")
|
||||||
x.setColor(rcGrey)
|
x.setColor(rcGrey)
|
||||||
|
|
@ -679,7 +679,7 @@ proc sweep(gch: var GcHeap): bool =
|
||||||
takeStartTime(100)
|
takeStartTime(100)
|
||||||
#echo "loop start"
|
#echo "loop start"
|
||||||
let white = 1-gch.black
|
let white = 1-gch.black
|
||||||
#cfprintf(cstdout, "black is %d\n", black)
|
#c_fprintf(stdout, "black is %d\n", black)
|
||||||
while true:
|
while true:
|
||||||
let x = allObjectsAsProc(gch.region, addr gch.spaceIter)
|
let x = allObjectsAsProc(gch.region, addr gch.spaceIter)
|
||||||
if gch.spaceIter.state < 0: break
|
if gch.spaceIter.state < 0: break
|
||||||
|
|
@ -719,7 +719,7 @@ proc markIncremental(gch: var GcHeap): bool =
|
||||||
while L[] > 0:
|
while L[] > 0:
|
||||||
var c = gch.greyStack.d[0]
|
var c = gch.greyStack.d[0]
|
||||||
if not isAllocatedPtr(gch.region, c):
|
if not isAllocatedPtr(gch.region, c):
|
||||||
c_fprintf(c_stdout, "[GC] not allocated anymore: %p\n", c)
|
c_fprintf(stdout, "[GC] not allocated anymore: %p\n", c)
|
||||||
#GC_dumpHeap()
|
#GC_dumpHeap()
|
||||||
sysAssert(false, "wtf")
|
sysAssert(false, "wtf")
|
||||||
|
|
||||||
|
|
@ -764,7 +764,7 @@ proc doOperation(p: pointer, op: WalkOp) =
|
||||||
case op
|
case op
|
||||||
of waZctDecRef:
|
of waZctDecRef:
|
||||||
#if not isAllocatedPtr(gch.region, c):
|
#if not isAllocatedPtr(gch.region, c):
|
||||||
# c_fprintf(c_stdout, "[GC] decref bug: %p", c)
|
# c_fprintf(stdout, "[GC] decref bug: %p", c)
|
||||||
gcAssert(isAllocatedPtr(gch.region, c), "decRef: waZctDecRef")
|
gcAssert(isAllocatedPtr(gch.region, c), "decRef: waZctDecRef")
|
||||||
gcAssert(c.refcount >=% rcIncrement, "doOperation 2")
|
gcAssert(c.refcount >=% rcIncrement, "doOperation 2")
|
||||||
#c.refcount = c.refcount -% rcIncrement
|
#c.refcount = c.refcount -% rcIncrement
|
||||||
|
|
@ -783,14 +783,14 @@ proc doOperation(p: pointer, op: WalkOp) =
|
||||||
else:
|
else:
|
||||||
#gcAssert(isAllocatedPtr(gch.region, c), "doOperation: waMarkGlobal")
|
#gcAssert(isAllocatedPtr(gch.region, c), "doOperation: waMarkGlobal")
|
||||||
if not isAllocatedPtr(gch.region, c):
|
if not isAllocatedPtr(gch.region, c):
|
||||||
c_fprintf(c_stdout, "[GC] not allocated anymore: MarkGlobal %p\n", c)
|
c_fprintf(stdout, "[GC] not allocated anymore: MarkGlobal %p\n", c)
|
||||||
#GC_dumpHeap()
|
#GC_dumpHeap()
|
||||||
sysAssert(false, "wtf")
|
sysAssert(false, "wtf")
|
||||||
handleRoot()
|
handleRoot()
|
||||||
discard allocInv(gch.region)
|
discard allocInv(gch.region)
|
||||||
of waMarkGrey:
|
of waMarkGrey:
|
||||||
if not isAllocatedPtr(gch.region, c):
|
if not isAllocatedPtr(gch.region, c):
|
||||||
c_fprintf(c_stdout, "[GC] not allocated anymore: MarkGrey %p\n", c)
|
c_fprintf(stdout, "[GC] not allocated anymore: MarkGrey %p\n", c)
|
||||||
#GC_dumpHeap()
|
#GC_dumpHeap()
|
||||||
sysAssert(false, "wtf")
|
sysAssert(false, "wtf")
|
||||||
if c.color == 1-gch.black:
|
if c.color == 1-gch.black:
|
||||||
|
|
@ -816,7 +816,7 @@ proc collectCycles(gch: var GcHeap): bool =
|
||||||
gch.phase = Phase.Marking
|
gch.phase = Phase.Marking
|
||||||
markGlobals(gch)
|
markGlobals(gch)
|
||||||
|
|
||||||
cfprintf(stdout, "collectCycles: introduced bug E %ld\n", gch.phase)
|
c_fprintf(stdout, "collectCycles: introduced bug E %ld\n", gch.phase)
|
||||||
discard allocInv(gch.region)
|
discard allocInv(gch.region)
|
||||||
of Phase.Marking:
|
of Phase.Marking:
|
||||||
# since locals do not have a write barrier, we need
|
# since locals do not have a write barrier, we need
|
||||||
|
|
@ -930,7 +930,7 @@ proc collectCTBody(gch: var GcHeap) =
|
||||||
gch.stat.maxPause = max(gch.stat.maxPause, duration)
|
gch.stat.maxPause = max(gch.stat.maxPause, duration)
|
||||||
when defined(reportMissedDeadlines):
|
when defined(reportMissedDeadlines):
|
||||||
if gch.maxPause > 0 and duration > gch.maxPause:
|
if gch.maxPause > 0 and duration > gch.maxPause:
|
||||||
c_fprintf(c_stdout, "[GC] missed deadline: %ld\n", duration)
|
c_fprintf(stdout, "[GC] missed deadline: %ld\n", duration)
|
||||||
|
|
||||||
when defined(nimCoroutines):
|
when defined(nimCoroutines):
|
||||||
proc currentStackSizes(): int =
|
proc currentStackSizes(): int =
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ when defined(nimCoroutines):
|
||||||
stack.next = gch.stack
|
stack.next = gch.stack
|
||||||
gch.stack.prev = stack
|
gch.stack.prev = stack
|
||||||
gch.stack = stack
|
gch.stack = stack
|
||||||
# c_fprintf(c_stdout, "[GC] added stack 0x%016X\n", starts)
|
# c_fprintf(stdout, "[GC] added stack 0x%016X\n", starts)
|
||||||
|
|
||||||
proc GC_removeStack*(starts: pointer) {.cdecl, exportc.} =
|
proc GC_removeStack*(starts: pointer) {.cdecl, exportc.} =
|
||||||
var stack = gch.stack
|
var stack = gch.stack
|
||||||
|
|
@ -143,7 +143,7 @@ else:
|
||||||
when not defined(useNimRtl):
|
when not defined(useNimRtl):
|
||||||
{.push stack_trace: off.}
|
{.push stack_trace: off.}
|
||||||
proc setStackBottom(theStackBottom: pointer) =
|
proc setStackBottom(theStackBottom: pointer) =
|
||||||
#c_fprintf(c_stdout, "stack bottom: %p;\n", theStackBottom)
|
#c_fprintf(stdout, "stack bottom: %p;\n", theStackBottom)
|
||||||
# the first init must be the one that defines the stack bottom:
|
# the first init must be the one that defines the stack bottom:
|
||||||
when defined(nimCoroutines):
|
when defined(nimCoroutines):
|
||||||
GC_addStack(theStackBottom)
|
GC_addStack(theStackBottom)
|
||||||
|
|
@ -152,7 +152,7 @@ when not defined(useNimRtl):
|
||||||
else:
|
else:
|
||||||
var a = cast[ByteAddress](theStackBottom) # and not PageMask - PageSize*2
|
var a = cast[ByteAddress](theStackBottom) # and not PageMask - PageSize*2
|
||||||
var b = cast[ByteAddress](gch.stackBottom)
|
var b = cast[ByteAddress](gch.stackBottom)
|
||||||
#c_fprintf(c_stdout, "old: %p new: %p;\n",gch.stackBottom,theStackBottom)
|
#c_fprintf(stdout, "old: %p new: %p;\n",gch.stackBottom,theStackBottom)
|
||||||
when stackIncreases:
|
when stackIncreases:
|
||||||
gch.stackBottom = cast[pointer](min(a, b))
|
gch.stackBottom = cast[pointer](min(a, b))
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ when defined(emscripten):
|
||||||
mmapDescr.realSize = realSize
|
mmapDescr.realSize = realSize
|
||||||
mmapDescr.realPointer = realPointer
|
mmapDescr.realPointer = realPointer
|
||||||
|
|
||||||
#c_fprintf(c_stdout, "[Alloc] size %d %d realSize:%d realPos:%d\n", block_size, cast[int](result), realSize, cast[int](realPointer))
|
#c_fprintf(stdout, "[Alloc] size %d %d realSize:%d realPos:%d\n", block_size, cast[int](result), realSize, cast[int](realPointer))
|
||||||
|
|
||||||
proc osTryAllocPages(size: int): pointer = osAllocPages(size)
|
proc osTryAllocPages(size: int): pointer = osAllocPages(size)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue