forward type alignment information to seqs (#12430)
This commit is contained in:
parent
a8f030fea2
commit
4005f0d0e4
25 changed files with 152 additions and 114 deletions
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue