parent
a7d6ba4526
commit
bd7807de4c
5 changed files with 22 additions and 22 deletions
|
|
@ -192,7 +192,7 @@ compiled with the `-d:useNimRtl` option and they will depend on both
|
||||||
the `nimrtl` library and the `nimhcr` library which implements the
|
the `nimrtl` library and the `nimhcr` library which implements the
|
||||||
hot code reloading run-time. Both libraries can be found in the `lib`
|
hot code reloading run-time. Both libraries can be found in the `lib`
|
||||||
folder of Nim and can be compiled into dynamic libraries to satisfy
|
folder of Nim and can be compiled into dynamic libraries to satisfy
|
||||||
runtime demands of the example code above. An example of compiling
|
runtime demands of the example code above. An example of compiling
|
||||||
`nimhcr.nim` and `nimrtl.nim` when the source dir of Nim is installed
|
`nimhcr.nim` and `nimrtl.nim` when the source dir of Nim is installed
|
||||||
with choosenim follows.
|
with choosenim follows.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ when not defined(js) and (defined(hotcodereloading) or
|
||||||
else: "so"
|
else: "so"
|
||||||
type
|
type
|
||||||
HcrProcGetter* = proc (libHandle: pointer, procName: cstring): pointer {.nimcall.}
|
HcrProcGetter* = proc (libHandle: pointer, procName: cstring): pointer {.nimcall.}
|
||||||
HcrGcMarkerProc = proc () {.nimcall.}
|
HcrGcMarkerProc = proc () {.nimcall, raises: [].}
|
||||||
HcrModuleInitializer* = proc () {.nimcall.}
|
HcrModuleInitializer* = proc () {.nimcall.}
|
||||||
|
|
||||||
when defined(createNimHcr):
|
when defined(createNimHcr):
|
||||||
|
|
@ -606,7 +606,7 @@ when defined(createNimHcr):
|
||||||
proc hcrGeneration*(): int {.nimhcr.} =
|
proc hcrGeneration*(): int {.nimhcr.} =
|
||||||
generation
|
generation
|
||||||
|
|
||||||
proc hcrMarkGlobals*() {.nimhcr, nimcall, gcsafe.} =
|
proc hcrMarkGlobals*() {.compilerproc, exportc, dynlib, nimcall, gcsafe.} =
|
||||||
# This is gcsafe, because it will be registered
|
# This is gcsafe, because it will be registered
|
||||||
# only in the GC of the main thread.
|
# only in the GC of the main thread.
|
||||||
{.gcsafe.}:
|
{.gcsafe.}:
|
||||||
|
|
@ -648,10 +648,10 @@ elif defined(hotcodereloading) or defined(testNimHcr):
|
||||||
|
|
||||||
proc hcrAddEventHandler*(isBefore: bool, cb: proc ()) {.nimhcr.}
|
proc hcrAddEventHandler*(isBefore: bool, cb: proc ()) {.nimhcr.}
|
||||||
|
|
||||||
proc hcrMarkGlobals*() {.nimhcr, nimcall, gcsafe.}
|
proc hcrMarkGlobals*() {.raises: [], nimhcr, nimcall, gcsafe.}
|
||||||
|
|
||||||
when declared(nimRegisterGlobalMarker):
|
when declared(nimRegisterGlobalMarker):
|
||||||
nimRegisterGlobalMarker(hcrMarkGlobals)
|
nimRegisterGlobalMarker(cast[GlobalMarkerProc](hcrMarkGlobals))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
proc hcrHasModuleChanged*(moduleHash: string): bool =
|
proc hcrHasModuleChanged*(moduleHash: string): bool =
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ type
|
||||||
waZctDecRef, waPush
|
waZctDecRef, waPush
|
||||||
#, waDebug
|
#, waDebug
|
||||||
|
|
||||||
Finalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign.}
|
Finalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign, raises: [].}
|
||||||
# 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
|
||||||
# storage is freed.
|
# storage is freed.
|
||||||
|
|
||||||
|
|
@ -219,11 +219,11 @@ template gcTrace(cell, state: untyped) =
|
||||||
when traceGC: traceCell(cell, state)
|
when traceGC: traceCell(cell, state)
|
||||||
|
|
||||||
# forward declarations:
|
# forward declarations:
|
||||||
proc collectCT(gch: var GcHeap) {.benign.}
|
proc collectCT(gch: var GcHeap) {.benign, raises: [].}
|
||||||
proc isOnStack(p: pointer): bool {.noinline, benign.}
|
proc isOnStack(p: pointer): bool {.noinline, benign, raises: [].}
|
||||||
proc forAllChildren(cell: PCell, op: WalkOp) {.benign.}
|
proc forAllChildren(cell: PCell, op: WalkOp) {.benign, raises: [].}
|
||||||
proc doOperation(p: pointer, op: WalkOp) {.benign.}
|
proc doOperation(p: pointer, op: WalkOp) {.benign, raises: [].}
|
||||||
proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) {.benign.}
|
proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) {.benign, raises: [].}
|
||||||
# we need the prototype here for debugging purposes
|
# we need the prototype here for debugging purposes
|
||||||
|
|
||||||
proc incRef(c: PCell) {.inline.} =
|
proc incRef(c: PCell) {.inline.} =
|
||||||
|
|
@ -636,7 +636,7 @@ proc markS(gch: var GcHeap, c: PCell) =
|
||||||
if not containsOrIncl(gch.marked, d):
|
if not containsOrIncl(gch.marked, d):
|
||||||
forAllChildren(d, waMarkPrecise)
|
forAllChildren(d, waMarkPrecise)
|
||||||
|
|
||||||
proc markGlobals(gch: var GcHeap) =
|
proc markGlobals(gch: var GcHeap) {.raises: [].} =
|
||||||
if gch.gcThreadId == 0:
|
if gch.gcThreadId == 0:
|
||||||
for i in 0 .. globalMarkersLen-1: globalMarkers[i]()
|
for i in 0 .. globalMarkersLen-1: globalMarkers[i]()
|
||||||
for i in 0 .. threadLocalMarkersLen-1: threadLocalMarkers[i]()
|
for i in 0 .. threadLocalMarkersLen-1: threadLocalMarkers[i]()
|
||||||
|
|
@ -691,9 +691,9 @@ proc doOperation(p: pointer, op: WalkOp) =
|
||||||
proc nimGCvisit(d: pointer, op: int) {.compilerRtl.} =
|
proc nimGCvisit(d: pointer, op: int) {.compilerRtl.} =
|
||||||
doOperation(d, WalkOp(op))
|
doOperation(d, WalkOp(op))
|
||||||
|
|
||||||
proc collectZCT(gch: var GcHeap): bool {.benign.}
|
proc collectZCT(gch: var GcHeap): bool {.benign, raises: [].}
|
||||||
|
|
||||||
proc collectCycles(gch: var GcHeap) =
|
proc collectCycles(gch: var GcHeap) {.raises: [].} =
|
||||||
when hasThreadSupport:
|
when hasThreadSupport:
|
||||||
for c in gch.toDispose:
|
for c in gch.toDispose:
|
||||||
nimGCunref(c)
|
nimGCunref(c)
|
||||||
|
|
@ -800,7 +800,7 @@ proc unmarkStackAndRegisters(gch: var GcHeap) =
|
||||||
decRef(d[i])
|
decRef(d[i])
|
||||||
gch.decStack.len = 0
|
gch.decStack.len = 0
|
||||||
|
|
||||||
proc collectCTBody(gch: var GcHeap) =
|
proc collectCTBody(gch: var GcHeap) {.raises: [].} =
|
||||||
when withRealTime:
|
when withRealTime:
|
||||||
let t0 = getticks()
|
let t0 = getticks()
|
||||||
sysAssert(allocInv(gch.region), "collectCT: begin")
|
sysAssert(allocInv(gch.region), "collectCT: begin")
|
||||||
|
|
|
||||||
|
|
@ -415,7 +415,7 @@ else:
|
||||||
# end of non-portable code
|
# end of non-portable code
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
proc prepareDealloc(cell: PCell) =
|
proc prepareDealloc(cell: PCell) {.raises: [].} =
|
||||||
when declared(useMarkForDebug):
|
when declared(useMarkForDebug):
|
||||||
when useMarkForDebug:
|
when useMarkForDebug:
|
||||||
gcAssert(cell notin gch.marked, "Cell still alive!")
|
gcAssert(cell notin gch.marked, "Cell still alive!")
|
||||||
|
|
@ -458,7 +458,7 @@ proc deallocHeap*(runFinalizers = true; allowGcAfterwards = true) =
|
||||||
initGC()
|
initGC()
|
||||||
|
|
||||||
type
|
type
|
||||||
GlobalMarkerProc = proc () {.nimcall, benign.}
|
GlobalMarkerProc = proc () {.nimcall, benign, raises: [].}
|
||||||
var
|
var
|
||||||
globalMarkersLen {.exportc.}: int
|
globalMarkersLen {.exportc.}: int
|
||||||
globalMarkers {.exportc.}: array[0..3499, GlobalMarkerProc]
|
globalMarkers {.exportc.}: array[0..3499, GlobalMarkerProc]
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ type
|
||||||
# local
|
# local
|
||||||
waMarkPrecise # fast precise marking
|
waMarkPrecise # fast precise marking
|
||||||
|
|
||||||
Finalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign.}
|
Finalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign, raises: [].}
|
||||||
# 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
|
||||||
# storage is freed.
|
# storage is freed.
|
||||||
|
|
||||||
|
|
@ -115,10 +115,10 @@ when BitsPerPage mod (sizeof(int)*8) != 0:
|
||||||
{.error: "(BitsPerPage mod BitsPerUnit) should be zero!".}
|
{.error: "(BitsPerPage mod BitsPerUnit) should be zero!".}
|
||||||
|
|
||||||
# forward declarations:
|
# forward declarations:
|
||||||
proc collectCT(gch: var GcHeap; size: int) {.benign.}
|
proc collectCT(gch: var GcHeap; size: int) {.benign, raises: [].}
|
||||||
proc forAllChildren(cell: PCell, op: WalkOp) {.benign.}
|
proc forAllChildren(cell: PCell, op: WalkOp) {.benign, raises: [].}
|
||||||
proc doOperation(p: pointer, op: WalkOp) {.benign.}
|
proc doOperation(p: pointer, op: WalkOp) {.benign, raises: [].}
|
||||||
proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) {.benign.}
|
proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) {.benign, raises: [].}
|
||||||
# we need the prototype here for debugging purposes
|
# we need the prototype here for debugging purposes
|
||||||
|
|
||||||
when defined(nimGcRefLeak):
|
when defined(nimGcRefLeak):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue