diff options
author | Araq <rumpf_a@web.de> | 2014-10-25 22:01:23 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-10-25 22:01:23 +0200 |
commit | a639824e5e3ec2a6eca97f31f55623254144ca81 (patch) | |
tree | bbde13d5df6bc705a70d2b704d22eb1e71291ca6 /lib/system | |
parent | 2dba3acfa94097937ea9c9d664d89a9d610a0131 (diff) | |
download | Nim-a639824e5e3ec2a6eca97f31f55623254144ca81.tar.gz |
introduced 'benign' pragma
Diffstat (limited to 'lib/system')
-rw-r--r-- | lib/system/alloc.nim | 2 | ||||
-rw-r--r-- | lib/system/assign.nim | 12 | ||||
-rw-r--r-- | lib/system/avltree.nim | 4 | ||||
-rw-r--r-- | lib/system/cgprocs.nim | 4 | ||||
-rw-r--r-- | lib/system/channels.nim | 18 | ||||
-rw-r--r-- | lib/system/deepcopy.nim | 4 | ||||
-rw-r--r-- | lib/system/excpt.nim | 12 | ||||
-rw-r--r-- | lib/system/gc.nim | 20 | ||||
-rw-r--r-- | lib/system/gc_ms.nim | 16 | ||||
-rw-r--r-- | lib/system/hti.nim | 4 | ||||
-rw-r--r-- | lib/system/inclrtl.nim | 5 |
11 files changed, 53 insertions, 48 deletions
diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim index 9f227f0c5..fd3ced832 100644 --- a/lib/system/alloc.nim +++ b/lib/system/alloc.nim @@ -514,7 +514,7 @@ proc getSmallChunk(a: var TMemRegion): PSmallChunk = result = cast[PSmallChunk](res) # ----------------------------------------------------------------------------- -proc isAllocatedPtr(a: TMemRegion, p: pointer): bool +proc isAllocatedPtr(a: TMemRegion, p: pointer): bool {.benign.} proc allocInv(a: TMemRegion): bool = ## checks some (not all yet) invariants of the allocator's data structures. diff --git a/lib/system/assign.nim b/lib/system/assign.nim index 6c58c24c2..8d53e127c 100644 --- a/lib/system/assign.nim +++ b/lib/system/assign.nim @@ -7,11 +7,11 @@ # distribution, for details about the copyright. # -proc genericResetAux(dest: pointer, n: ptr TNimNode) {.gcsafe.} +proc genericResetAux(dest: pointer, n: ptr TNimNode) {.benign.} -proc genericAssignAux(dest, src: pointer, mt: PNimType, shallow: bool) {.gcsafe.} +proc genericAssignAux(dest, src: pointer, mt: PNimType, shallow: bool) {.benign.} proc genericAssignAux(dest, src: pointer, n: ptr TNimNode, - shallow: bool) {.gcsafe.} = + shallow: bool) {.benign.} = var d = cast[ByteAddress](dest) s = cast[ByteAddress](src) @@ -136,8 +136,8 @@ proc genericAssignOpenArray(dest, src: pointer, len: int, genericAssign(cast[pointer](d +% i*% mt.base.size), cast[pointer](s +% i*% mt.base.size), mt.base) -proc objectInit(dest: pointer, typ: PNimType) {.compilerProc, gcsafe.} -proc objectInitAux(dest: pointer, n: ptr TNimNode) {.gcsafe.} = +proc objectInit(dest: pointer, typ: PNimType) {.compilerProc, benign.} +proc objectInitAux(dest: pointer, n: ptr TNimNode) {.benign.} = var d = cast[ByteAddress](dest) case n.kind of nkNone: sysAssert(false, "objectInitAux") @@ -182,7 +182,7 @@ else: mixin destroy for i in countup(0, r.len - 1): destroy(r[i]) -proc genericReset(dest: pointer, mt: PNimType) {.compilerProc, gcsafe.} +proc genericReset(dest: pointer, mt: PNimType) {.compilerProc, benign.} proc genericResetAux(dest: pointer, n: ptr TNimNode) = var d = cast[ByteAddress](dest) case n.kind diff --git a/lib/system/avltree.nim b/lib/system/avltree.nim index 157799b28..292097062 100644 --- a/lib/system/avltree.nim +++ b/lib/system/avltree.nim @@ -51,7 +51,7 @@ proc split(t: var PAvlNode) = t.link[0] = temp inc t.level -proc add(a: var TMemRegion, t: var PAvlNode, key, upperBound: int) {.gcsafe.} = +proc add(a: var TMemRegion, t: var PAvlNode, key, upperBound: int) {.benign.} = if t == bottom: t = allocAvlNode(a, key, upperBound) else: @@ -64,7 +64,7 @@ proc add(a: var TMemRegion, t: var PAvlNode, key, upperBound: int) {.gcsafe.} = skew(t) split(t) -proc del(a: var TMemRegion, t: var PAvlNode, x: int) {.gcsafe.} = +proc del(a: var TMemRegion, t: var PAvlNode, x: int) {.benign.} = if t == bottom: return a.last = t if x <% t.key: diff --git a/lib/system/cgprocs.nim b/lib/system/cgprocs.nim index d46e715f1..089846578 100644 --- a/lib/system/cgprocs.nim +++ b/lib/system/cgprocs.nim @@ -9,7 +9,7 @@ # Headers for procs that the code generator depends on ("compilerprocs") -proc addChar(s: NimString, c: char): NimString {.compilerProc, gcsafe.} +proc addChar(s: NimString, c: char): NimString {.compilerProc, benign.} type TLibHandle = pointer # private type @@ -21,5 +21,5 @@ proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr {.compilerproc.} proc nimLoadLibraryError(path: string) {.compilerproc, noinline.} -proc setStackBottom(theStackBottom: pointer) {.compilerRtl, noinline, gcsafe.} +proc setStackBottom(theStackBottom: pointer) {.compilerRtl, noinline, benign.} diff --git a/lib/system/channels.nim b/lib/system/channels.nim index 4796ebb82..3e5ca0795 100644 --- a/lib/system/channels.nim +++ b/lib/system/channels.nim @@ -49,9 +49,9 @@ proc deinitRawChannel(p: pointer) = deinitSysCond(c.cond) proc storeAux(dest, src: pointer, mt: PNimType, t: PRawChannel, - mode: TLoadStoreMode) {.gcsafe.} + mode: TLoadStoreMode) {.benign.} proc storeAux(dest, src: pointer, n: ptr TNimNode, t: PRawChannel, - mode: TLoadStoreMode) {.gcsafe.} = + mode: TLoadStoreMode) {.benign.} = var d = cast[ByteAddress](dest) s = cast[ByteAddress](src) @@ -225,15 +225,15 @@ proc recv*[TMsg](c: var TChannel[TMsg]): TMsg = acquireSys(q.lock) llRecv(q, addr(result), cast[PNimType](getTypeInfo(result))) releaseSys(q.lock) - -proc tryRecv*[TMsg](c: var TChannel[TMsg]): tuple[dataAvailable: bool, - msg: TMsg] = - ## try to receives a message from the channel `c` if available. Otherwise - ## it returns ``(false, default(msg))``. + +proc tryRecv*[TMsg](c: var TChannel[TMsg]): tuple[dataAvailable: bool, + msg: TMsg] = + ## try to receives a message from the channel `c` if available. Otherwise + ## it returns ``(false, default(msg))``. var q = cast[PRawChannel](addr(c)) - if q.mask != ChannelDeadMask: + if q.mask != ChannelDeadMask: if tryAcquireSys(q.lock): - llRecv(q, addr(result.msg), cast[PNimType](getTypeInfo(result.msg))) + llRecv(q, addr(result.msg), cast[PNimType](getTypeInfo(result.msg))) result.dataAvailable = true releaseSys(q.lock) diff --git a/lib/system/deepcopy.nim b/lib/system/deepcopy.nim index e4356a25d..fbebb17a8 100644 --- a/lib/system/deepcopy.nim +++ b/lib/system/deepcopy.nim @@ -7,8 +7,8 @@ # distribution, for details about the copyright. # -proc genericDeepCopyAux(dest, src: pointer, mt: PNimType) {.gcsafe.} -proc genericDeepCopyAux(dest, src: pointer, n: ptr TNimNode) {.gcsafe.} = +proc genericDeepCopyAux(dest, src: pointer, mt: PNimType) {.benign.} +proc genericDeepCopyAux(dest, src: pointer, n: ptr TNimNode) {.benign.} = var d = cast[ByteAddress](dest) s = cast[ByteAddress](src) diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim index c0e99a5e2..e21eeca6a 100644 --- a/lib/system/excpt.nim +++ b/lib/system/excpt.nim @@ -11,7 +11,7 @@ # use the heap (and nor exceptions) do not include the GC or memory allocator. var - errorMessageWriter*: (proc(msg: string) {.tags: [WriteIOEffect], gcsafe.}) + errorMessageWriter*: (proc(msg: string) {.tags: [WriteIOEffect], benign.}) ## Function that will be called ## instead of stdmsg.write when printing stacktrace. ## Unstable API. @@ -32,10 +32,10 @@ proc showErrorMessage(data: cstring) = else: writeToStdErr(data) -proc chckIndx(i, a, b: int): int {.inline, compilerproc, gcsafe.} -proc chckRange(i, a, b: int): int {.inline, compilerproc, gcsafe.} -proc chckRangeF(x, a, b: float): float {.inline, compilerproc, gcsafe.} -proc chckNil(p: pointer) {.noinline, compilerproc, gcsafe.} +proc chckIndx(i, a, b: int): int {.inline, compilerproc, benign.} +proc chckRange(i, a, b: int): int {.inline, compilerproc, benign.} +proc chckRangeF(x, a, b: float): float {.inline, compilerproc, benign.} +proc chckNil(p: pointer) {.noinline, compilerproc, benign.} var framePtr {.threadvar.}: PFrame @@ -343,5 +343,5 @@ when not defined(noSignalHandler): proc setControlCHook(hook: proc () {.noconv.}) = # ugly cast, but should work on all architectures: - type TSignalHandler = proc (sig: cint) {.noconv, gcsafe.} + type TSignalHandler = proc (sig: cint) {.noconv, benign.} c_signal(SIGINT, cast[TSignalHandler](hook)) diff --git a/lib/system/gc.nim b/lib/system/gc.nim index c4b3a4928..fe4b40903 100644 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -51,7 +51,7 @@ type waZctDecRef, waPush, waCycleDecRef, waMarkGray, waScan, waScanBlack, waCollectWhite, - TFinalizer {.compilerproc.} = proc (self: pointer) {.nimcall, gcsafe.} + TFinalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign.} # A ref type can have a finalizer that is called before the object's # storage is freed. @@ -152,11 +152,11 @@ template gcTrace(cell, state: expr): stmt {.immediate.} = when traceGC: traceCell(cell, state) # forward declarations: -proc collectCT(gch: var TGcHeap) {.gcsafe.} -proc isOnStack*(p: pointer): bool {.noinline, gcsafe.} -proc forAllChildren(cell: PCell, op: TWalkOp) {.gcsafe.} -proc doOperation(p: pointer, op: TWalkOp) {.gcsafe.} -proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) {.gcsafe.} +proc collectCT(gch: var TGcHeap) {.benign.} +proc isOnStack*(p: pointer): bool {.noinline, benign.} +proc forAllChildren(cell: PCell, op: TWalkOp) {.benign.} +proc doOperation(p: pointer, op: TWalkOp) {.benign.} +proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) {.benign.} # we need the prototype here for debugging purposes when hasThreadSupport and hasSharedHeap: @@ -294,7 +294,7 @@ proc initGC() = when useMarkForDebug or useBackupGc: type - TGlobalMarkerProc = proc () {.nimcall, gcsafe.} + TGlobalMarkerProc = proc () {.nimcall, benign.} var globalMarkersLen: int globalMarkers: array[0.. 7_000, TGlobalMarkerProc] @@ -311,7 +311,7 @@ proc cellsetReset(s: var TCellSet) = deinit(s) init(s) -proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) {.gcsafe.} = +proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) {.benign.} = var d = cast[ByteAddress](dest) case n.kind of nkSlot: forAllChildrenAux(cast[pointer](d +% n.offset), n.typ, op) @@ -680,11 +680,11 @@ proc doOperation(p: pointer, op: TWalkOp) = proc nimGCvisit(d: pointer, op: int) {.compilerRtl.} = doOperation(d, TWalkOp(op)) -proc collectZCT(gch: var TGcHeap): bool {.gcsafe.} +proc collectZCT(gch: var TGcHeap): bool {.benign.} when useMarkForDebug or useBackupGc: proc markStackAndRegistersForSweep(gch: var TGcHeap) {.noinline, cdecl, - gcsafe.} + benign.} proc collectRoots(gch: var TGcHeap) = for s in elements(gch.cycleRoots): diff --git a/lib/system/gc_ms.nim b/lib/system/gc_ms.nim index f90000a1c..242ca1608 100644 --- a/lib/system/gc_ms.nim +++ b/lib/system/gc_ms.nim @@ -32,11 +32,11 @@ type # local waMarkPrecise # fast precise marking - TFinalizer {.compilerproc.} = proc (self: pointer) {.nimcall, gcsafe.} + TFinalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign.} # A ref type can have a finalizer that is called before the object's # storage is freed. - TGlobalMarkerProc = proc () {.nimcall, gcsafe.} + TGlobalMarkerProc = proc () {.nimcall, benign.} TGcStat = object collections: int # number of performed full collections @@ -116,11 +116,11 @@ when BitsPerPage mod (sizeof(int)*8) != 0: {.error: "(BitsPerPage mod BitsPerUnit) should be zero!".} # forward declarations: -proc collectCT(gch: var TGcHeap) {.gcsafe.} -proc isOnStack*(p: pointer): bool {.noinline, gcsafe.} -proc forAllChildren(cell: PCell, op: TWalkOp) {.gcsafe.} -proc doOperation(p: pointer, op: TWalkOp) {.gcsafe.} -proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) {.gcsafe.} +proc collectCT(gch: var TGcHeap) {.benign.} +proc isOnStack*(p: pointer): bool {.noinline, benign.} +proc forAllChildren(cell: PCell, op: TWalkOp) {.benign.} +proc doOperation(p: pointer, op: TWalkOp) {.benign.} +proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) {.benign.} # we need the prototype here for debugging purposes proc prepareDealloc(cell: PCell) = @@ -168,7 +168,7 @@ proc initGC() = Init(gch.allocated) init(gch.marked) -proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) {.gcsafe.} = +proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) {.benign.} = var d = cast[ByteAddress](dest) case n.kind of nkSlot: forAllChildrenAux(cast[pointer](d +% n.offset), n.typ, op) diff --git a/lib/system/hti.nim b/lib/system/hti.nim index 4a8ab2485..e599668a7 100644 --- a/lib/system/hti.nim +++ b/lib/system/hti.nim @@ -85,8 +85,8 @@ type base: ptr TNimType node: ptr TNimNode # valid for tyRecord, tyObject, tyTuple, tyEnum finalizer: pointer # the finalizer for the type - marker: proc (p: pointer, op: int) {.nimcall, gcsafe.} # marker proc for GC - deepcopy: proc (p: pointer): pointer {.nimcall, gcsafe.} + marker: proc (p: pointer, op: int) {.nimcall, benign.} # marker proc for GC + deepcopy: proc (p: pointer): pointer {.nimcall, benign.} PNimType = ptr TNimType # node.len may be the ``first`` element of a set diff --git a/lib/system/inclrtl.nim b/lib/system/inclrtl.nim index a975bb7c2..aac802229 100644 --- a/lib/system/inclrtl.nim +++ b/lib/system/inclrtl.nim @@ -46,3 +46,8 @@ else: when not defined(nimsuperops): {.pragma: operator.} + +when defined(nimlocks): + {.pragma: benign, gcsafe, locks: 0.} +else: + {.pragma: benign, gcsafe.} |