fixes channels for --gc:regions
This commit is contained in:
parent
cc9e94cd96
commit
c0024fa587
3 changed files with 10 additions and 7 deletions
|
|
@ -32,8 +32,6 @@ type
|
||||||
PRawChannel = ptr RawChannel
|
PRawChannel = ptr RawChannel
|
||||||
LoadStoreMode = enum mStore, mLoad
|
LoadStoreMode = enum mStore, mLoad
|
||||||
Channel* {.gcsafe.}[TMsg] = RawChannel ## a channel for thread communication
|
Channel* {.gcsafe.}[TMsg] = RawChannel ## a channel for thread communication
|
||||||
{.deprecated: [TRawChannel: RawChannel, TLoadStoreMode: LoadStoreMode,
|
|
||||||
TChannel: Channel].}
|
|
||||||
|
|
||||||
const ChannelDeadMask = -2
|
const ChannelDeadMask = -2
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ proc allocSlowPath(r: var MemRegion; size: int) =
|
||||||
r.tail = fresh
|
r.tail = fresh
|
||||||
r.remaining = s - sizeof(BaseChunk)
|
r.remaining = s - sizeof(BaseChunk)
|
||||||
|
|
||||||
proc alloc(r: var MemRegion; size: int): pointer =
|
proc allocFast(r: var MemRegion; size: int): pointer =
|
||||||
if size <= MaxSmallObject:
|
if size <= MaxSmallObject:
|
||||||
var it = r.freeLists[size div MemAlign]
|
var it = r.freeLists[size div MemAlign]
|
||||||
if it != nil:
|
if it != nil:
|
||||||
|
|
@ -270,7 +270,7 @@ proc isOnHeap*(r: MemRegion; p: pointer): bool =
|
||||||
it = it.next
|
it = it.next
|
||||||
|
|
||||||
proc rawNewObj(r: var MemRegion, typ: PNimType, size: int): pointer =
|
proc rawNewObj(r: var MemRegion, typ: PNimType, size: int): pointer =
|
||||||
var res = cast[ptr ObjHeader](alloc(r, size + sizeof(ObjHeader)))
|
var res = cast[ptr ObjHeader](allocFast(r, size + sizeof(ObjHeader)))
|
||||||
res.typ = typ
|
res.typ = typ
|
||||||
if typ.finalizer != nil:
|
if typ.finalizer != nil:
|
||||||
res.nextFinal = r.head.head
|
res.nextFinal = r.head.head
|
||||||
|
|
@ -278,7 +278,7 @@ proc rawNewObj(r: var MemRegion, typ: PNimType, size: int): pointer =
|
||||||
result = res +! sizeof(ObjHeader)
|
result = res +! sizeof(ObjHeader)
|
||||||
|
|
||||||
proc rawNewSeq(r: var MemRegion, typ: PNimType, size: int): pointer =
|
proc rawNewSeq(r: var MemRegion, typ: PNimType, size: int): pointer =
|
||||||
var res = cast[ptr SeqHeader](alloc(r, size + sizeof(SeqHeader)))
|
var res = cast[ptr SeqHeader](allocFast(r, size + sizeof(SeqHeader)))
|
||||||
res.typ = typ
|
res.typ = typ
|
||||||
res.region = addr(r)
|
res.region = addr(r)
|
||||||
result = res +! sizeof(SeqHeader)
|
result = res +! sizeof(SeqHeader)
|
||||||
|
|
@ -351,6 +351,11 @@ proc alloc0(r: var MemRegion; size: Natural): pointer =
|
||||||
# but incorrect in general. XXX
|
# but incorrect in general. XXX
|
||||||
result = alloc0(size)
|
result = alloc0(size)
|
||||||
|
|
||||||
|
proc alloc(r: var MemRegion; size: Natural): pointer =
|
||||||
|
# ignore the region. That is correct for the channels module
|
||||||
|
# but incorrect in general. XXX
|
||||||
|
result = alloc(size)
|
||||||
|
|
||||||
proc dealloc(r: var MemRegion; p: pointer) = dealloc(p)
|
proc dealloc(r: var MemRegion; p: pointer) = dealloc(p)
|
||||||
|
|
||||||
proc allocShared(size: Natural): pointer =
|
proc allocShared(size: Natural): pointer =
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ discard """
|
||||||
type
|
type
|
||||||
TMsgKind = enum
|
TMsgKind = enum
|
||||||
mLine, mEof
|
mLine, mEof
|
||||||
TMsg = object {.pure, final.}
|
TMsg = object
|
||||||
case k: TMsgKind
|
case k: TMsgKind
|
||||||
of mEof: nil
|
of mEof: discard
|
||||||
of mLine: data: string
|
of mLine: data: string
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue