still playing with threads
This commit is contained in:
parent
9207492bb9
commit
b0b2c233ae
3 changed files with 17 additions and 15 deletions
|
|
@ -82,7 +82,7 @@ gcc.options.debug = "-g"
|
||||||
@end
|
@end
|
||||||
@else:
|
@else:
|
||||||
@if not release:
|
@if not release:
|
||||||
gcc.options.always = "-w -O1"
|
gcc.options.always = "-w"
|
||||||
@else:
|
@else:
|
||||||
gcc.options.always = "-w"
|
gcc.options.always = "-w"
|
||||||
@end
|
@end
|
||||||
|
|
|
||||||
|
|
@ -80,15 +80,13 @@ var
|
||||||
|
|
||||||
proc aquire(gch: var TGcHeap) {.inline.} =
|
proc aquire(gch: var TGcHeap) {.inline.} =
|
||||||
when hasThreadSupport:
|
when hasThreadSupport:
|
||||||
if isMultiThreaded:
|
aquireSys(gch.zctLock)
|
||||||
aquireSys(gch.zctLock)
|
aquireSys(gch.cycleRootsLock)
|
||||||
aquireSys(gch.cycleRootsLock)
|
|
||||||
|
|
||||||
proc release(gch: var TGcHeap) {.inline.} =
|
proc release(gch: var TGcHeap) {.inline.} =
|
||||||
when hasThreadSupport:
|
when hasThreadSupport:
|
||||||
if isMultiThreaded:
|
releaseSys(gch.cycleRootsLock)
|
||||||
releaseSys(gch.zctLock)
|
releaseSys(gch.zctLock)
|
||||||
releaseSys(gch.cycleRootsLock)
|
|
||||||
|
|
||||||
proc addZCT(s: var TCellSeq, c: PCell) {.noinline.} =
|
proc addZCT(s: var TCellSeq, c: PCell) {.noinline.} =
|
||||||
if (c.refcount and rcZct) == 0:
|
if (c.refcount and rcZct) == 0:
|
||||||
|
|
@ -207,18 +205,18 @@ proc prepareDealloc(cell: PCell) =
|
||||||
proc rtlAddCycleRoot(c: PCell) {.rtl, inl.} =
|
proc rtlAddCycleRoot(c: PCell) {.rtl, inl.} =
|
||||||
# we MUST access gch as a global here, because this crosses DLL boundaries!
|
# we MUST access gch as a global here, because this crosses DLL boundaries!
|
||||||
when hasThreadSupport:
|
when hasThreadSupport:
|
||||||
if isMultiThreaded: AquireSys(gch.cycleRootsLock)
|
AquireSys(gch.cycleRootsLock)
|
||||||
incl(gch.cycleRoots, c)
|
incl(gch.cycleRoots, c)
|
||||||
when hasThreadSupport:
|
when hasThreadSupport:
|
||||||
if isMultiThreaded: ReleaseSys(gch.cycleRootsLock)
|
ReleaseSys(gch.cycleRootsLock)
|
||||||
|
|
||||||
proc rtlAddZCT(c: PCell) {.rtl, inl.} =
|
proc rtlAddZCT(c: PCell) {.rtl, inl.} =
|
||||||
# we MUST access gch as a global here, because this crosses DLL boundaries!
|
# we MUST access gch as a global here, because this crosses DLL boundaries!
|
||||||
when hasThreadSupport:
|
when hasThreadSupport:
|
||||||
if isMultiThreaded: AquireSys(gch.zctLock)
|
AquireSys(gch.zctLock)
|
||||||
addZCT(gch.zct, c)
|
addZCT(gch.zct, c)
|
||||||
when hasThreadSupport:
|
when hasThreadSupport:
|
||||||
if isMultiThreaded: ReleaseSys(gch.zctLock)
|
ReleaseSys(gch.zctLock)
|
||||||
|
|
||||||
proc decRef(c: PCell) {.inline.} =
|
proc decRef(c: PCell) {.inline.} =
|
||||||
when stressGC:
|
when stressGC:
|
||||||
|
|
@ -561,8 +559,9 @@ proc stackSize(): int {.noinline.} =
|
||||||
when defined(sparc): # For SPARC architecture.
|
when defined(sparc): # For SPARC architecture.
|
||||||
proc isOnStack(p: pointer): bool =
|
proc isOnStack(p: pointer): bool =
|
||||||
var stackTop {.volatile.}: pointer
|
var stackTop {.volatile.}: pointer
|
||||||
|
stackTop = addr(stackTop)
|
||||||
var b = cast[TAddress](stackBottom)
|
var b = cast[TAddress](stackBottom)
|
||||||
var a = cast[TAddress](addr(stackTop))
|
var a = cast[TAddress](stackTop)
|
||||||
var x = cast[TAddress](p)
|
var x = cast[TAddress](p)
|
||||||
result = a <=% x and x <=% b
|
result = a <=% x and x <=% b
|
||||||
|
|
||||||
|
|
@ -591,8 +590,9 @@ elif stackIncreases:
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
proc isOnStack(p: pointer): bool =
|
proc isOnStack(p: pointer): bool =
|
||||||
var stackTop {.volatile.}: pointer
|
var stackTop {.volatile.}: pointer
|
||||||
|
stackTop = addr(stackTop)
|
||||||
var a = cast[TAddress](stackBottom)
|
var a = cast[TAddress](stackBottom)
|
||||||
var b = cast[TAddress](addr(stackTop))
|
var b = cast[TAddress](stackTop)
|
||||||
var x = cast[TAddress](p)
|
var x = cast[TAddress](p)
|
||||||
result = a <=% x and x <=% b
|
result = a <=% x and x <=% b
|
||||||
|
|
||||||
|
|
@ -618,8 +618,9 @@ else:
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
proc isOnStack(p: pointer): bool =
|
proc isOnStack(p: pointer): bool =
|
||||||
var stackTop {.volatile.}: pointer
|
var stackTop {.volatile.}: pointer
|
||||||
|
stackTop = addr(stackTop)
|
||||||
var b = cast[TAddress](stackBottom)
|
var b = cast[TAddress](stackBottom)
|
||||||
var a = cast[TAddress](addr(stackTop))
|
var a = cast[TAddress](stackTop)
|
||||||
var x = cast[TAddress](p)
|
var x = cast[TAddress](p)
|
||||||
result = a <=% x and x <=% b
|
result = a <=% x and x <=% b
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,8 @@ when defined(Windows):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
type
|
type
|
||||||
TSysLock {.importc: "pthread_mutex_t", header: "<sys/types.h>".} = int
|
TSysLock {.importc: "pthread_mutex_t", pure, final,
|
||||||
|
header: "<sys/types.h>".} = object
|
||||||
|
|
||||||
proc InitSysLock(L: var TSysLock, attr: pointer = nil) {.
|
proc InitSysLock(L: var TSysLock, attr: pointer = nil) {.
|
||||||
importc: "pthread_mutex_init", header: "<pthread.h>".}
|
importc: "pthread_mutex_init", header: "<pthread.h>".}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue