fixes channels for --gc:regions

This commit is contained in:
Andreas Rumpf
2018-05-25 16:21:33 +02:00
parent cc9e94cd96
commit c0024fa587
3 changed files with 10 additions and 7 deletions

View File

@@ -32,8 +32,6 @@ type
PRawChannel = ptr RawChannel
LoadStoreMode = enum mStore, mLoad
Channel* {.gcsafe.}[TMsg] = RawChannel ## a channel for thread communication
{.deprecated: [TRawChannel: RawChannel, TLoadStoreMode: LoadStoreMode,
TChannel: Channel].}
const ChannelDeadMask = -2

View File

@@ -144,7 +144,7 @@ proc allocSlowPath(r: var MemRegion; size: int) =
r.tail = fresh
r.remaining = s - sizeof(BaseChunk)
proc alloc(r: var MemRegion; size: int): pointer =
proc allocFast(r: var MemRegion; size: int): pointer =
if size <= MaxSmallObject:
var it = r.freeLists[size div MemAlign]
if it != nil:
@@ -270,7 +270,7 @@ proc isOnHeap*(r: MemRegion; p: pointer): bool =
it = it.next
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
if typ.finalizer != nil:
res.nextFinal = r.head.head
@@ -278,7 +278,7 @@ proc rawNewObj(r: var MemRegion, typ: PNimType, size: int): pointer =
result = res +! sizeof(ObjHeader)
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.region = addr(r)
result = res +! sizeof(SeqHeader)
@@ -351,6 +351,11 @@ proc alloc0(r: var MemRegion; size: Natural): pointer =
# but incorrect in general. XXX
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 allocShared(size: Natural): pointer =

View File

@@ -5,9 +5,9 @@ discard """
type
TMsgKind = enum
mLine, mEof
TMsg = object {.pure, final.}
TMsg = object
case k: TMsgKind
of mEof: nil
of mEof: discard
of mLine: data: string
var