forward type alignment information to seqs (#12430)

This commit is contained in:
Arne Döring 2020-04-19 07:52:01 +02:00 • committed by GitHub
commit 4005f0d0e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 152 additions and 114 deletions

View file

@ -1,4 +1,6 @@
proc boehmGCinit {.importc: "GC_init", boehmGC.}
proc boehmGC_disable {.importc: "GC_disable", boehmGC.}
proc boehmGC_enable {.importc: "GC_enable", boehmGC.}
@ -96,6 +98,7 @@ proc initGC() =
proc boehmgc_finalizer(obj: pointer, typedFinalizer: (proc(x: pointer) {.cdecl.})) =
typedFinalizer(obj)
proc newObj(typ: PNimType, size: int): pointer {.compilerproc.} =
if ntfNoRefs in typ.flags: result = allocAtomic(size)
else: result = alloc(size)
@ -103,7 +106,7 @@ proc newObj(typ: PNimType, size: int): pointer {.compilerproc.} =
boehmRegisterFinalizer(result, boehmgc_finalizer, typ.finalizer, nil, nil)
{.push overflowChecks: on.}
proc newSeq(typ: PNimType, len: int): pointer {.compilerproc.} =
result = newObj(typ, len * typ.base.size + GenericSeqSize)
result = newObj(typ, align(GenericSeqSize, typ.base.align) + len * typ.base.size)
cast[PGenericSeq](result).len = len
cast[PGenericSeq](result).reserved = len
{.pop.}
@ -135,4 +138,3 @@ proc deallocOsPages(r: var MemRegion) {.inline.} = discard
proc deallocOsPages() {.inline.} = discard
include "system/cellsets"