diff options
author | Araq <rumpf_a@web.de> | 2013-12-16 22:26:17 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-12-16 22:26:17 +0100 |
commit | 132b6b3efee8d1be7f94545ed5fefaf64de741dc (patch) | |
tree | cc2a24dd33eadc48a621d12e89294ecd451710c9 /lib/system | |
parent | 01661daf76daa713d25d06d202f83c842a6f1fe3 (diff) | |
download | Nim-132b6b3efee8d1be7f94545ed5fefaf64de741dc.tar.gz |
implemented 'injectStmt'; more debug support
Diffstat (limited to 'lib/system')
-rw-r--r-- | lib/system/alloc.nim | 2 | ||||
-rw-r--r-- | lib/system/gc.nim | 13 | ||||
-rw-r--r-- | lib/system/mmdisp.nim | 3 |
3 files changed, 11 insertions, 7 deletions
diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim index 2bab79212..17258cf68 100644 --- a/lib/system/alloc.nim +++ b/lib/system/alloc.nim @@ -760,7 +760,7 @@ proc getOccupiedMem(a: TMemRegion): int {.inline.} = # ---------------------- thread memory region ------------------------------- template InstantiateForRegion(allocator: expr) = - when false: + when defined(fulldebug): proc interiorAllocatedPtr*(p: pointer): pointer = result = interiorAllocatedPtr(allocator, p) diff --git a/lib/system/gc.nim b/lib/system/gc.nim index d2b065d6b..68e8b423d 100644 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -345,8 +345,9 @@ proc forAllChildrenAux(dest: Pointer, mt: PNimType, op: TWalkOp) = proc forAllChildren(cell: PCell, op: TWalkOp) = gcAssert(cell != nil, "forAllChildren: 1") - gcAssert(cell.typ != nil, "forAllChildren: 2") - gcAssert cell.typ.kind in {tyRef, tySequence, tyString}, "forAllChildren: 3" + gcAssert(isAllocatedPtr(gch.region, cell), "forAllChildren: 2") + gcAssert(cell.typ != nil, "forAllChildren: 3") + gcAssert cell.typ.kind in {tyRef, tySequence, tyString}, "forAllChildren: 4" let marker = cell.typ.marker if marker != nil: marker(cellToUsr(cell), op.int) @@ -361,7 +362,7 @@ proc forAllChildren(cell: PCell, op: TWalkOp) = for i in 0..s.len-1: forAllChildrenAux(cast[pointer](d +% i *% cell.typ.base.size +% GenericSeqSize), cell.typ.base, op) - else: nil + else: discard proc addNewObjToZCT(res: PCell, gch: var TGcHeap) {.inline.} = # we check the last 8 entries (cache line) for a slot that could be reused. @@ -408,8 +409,10 @@ proc addNewObjToZCT(res: PCell, gch: var TGcHeap) {.inline.} = add(gch.zct, res) {.push stackTrace: off, profiler:off.} -proc gcInvariant*(msg: string) = - sysAssert(allocInv(gch.region), msg) +proc gcInvariant*() = + sysAssert(allocInv(gch.region), "injected") + when defined(markForDebug): + markForDebug(gch) {.pop.} proc rawNewObj(typ: PNimType, size: int, gch: var TGcHeap): pointer = diff --git a/lib/system/mmdisp.nim b/lib/system/mmdisp.nim index 118272ee3..942b6778e 100644 --- a/lib/system/mmdisp.nim +++ b/lib/system/mmdisp.nim @@ -18,7 +18,8 @@ const logGC = false traceGC = false # extensive debugging alwaysCycleGC = false - alwaysGC = false # collect after every memory allocation (for debugging) + alwaysGC = defined(fulldebug) # collect after every memory + # allocation (for debugging) leakDetector = false overwriteFree = false trackAllocationSource = leakDetector |