mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-24 07:31:41 +00:00
refactor memory management structures for consistency across modules
This commit is contained in:
@@ -104,6 +104,8 @@ type
|
||||
zeroField: int # 0 means cell is not used (overlaid with typ field)
|
||||
# 1 means cell is manually managed pointer
|
||||
# otherwise a PNimType is stored in there
|
||||
when sizeof(int) == 4: # 32-bit only
|
||||
headerAlignPad: array[8, byte] # so addr(data) ≡ 8 (mod 16)
|
||||
else:
|
||||
alignment: int
|
||||
|
||||
|
||||
@@ -48,7 +48,23 @@ when defined(gcOrc) or defined(gcArc) or defined(gcAtomicArc) or defined(gcYrc):
|
||||
|
||||
when not declaredInScope(PageShift):
|
||||
include bitmasks
|
||||
else:
|
||||
type
|
||||
RefCount = int
|
||||
|
||||
Cell {.pure.} = object
|
||||
refcount: RefCount # the refcount and some flags
|
||||
typ: PNimType
|
||||
|
||||
when trackAllocationSource:
|
||||
filename: cstring
|
||||
line: int
|
||||
elif useCellIds:
|
||||
id: int
|
||||
elif defined(cpu32):
|
||||
headerAlignPad: array[8, byte] # so addr(data) ≡ 8 (mod 16)
|
||||
|
||||
PCell = ptr Cell
|
||||
|
||||
type
|
||||
PPageDesc = ptr PageDesc
|
||||
|
||||
@@ -38,24 +38,6 @@ type
|
||||
PByte = ptr ByteArray
|
||||
PString = ptr string
|
||||
|
||||
when not defined(nimV2):
|
||||
type
|
||||
RefCount = int
|
||||
|
||||
Cell {.pure.} = object
|
||||
refcount: RefCount # the refcount and some flags
|
||||
typ: PNimType
|
||||
when sizeof(int) == 4: # 32-bit only
|
||||
headerAlignPad: array[8, byte] # so addr(data) ≡ 8 (mod 16)
|
||||
|
||||
when trackAllocationSource:
|
||||
filename: cstring
|
||||
line: int
|
||||
when useCellIds:
|
||||
id: int
|
||||
|
||||
PCell = ptr Cell
|
||||
|
||||
when declared(IntsPerTrunk):
|
||||
discard
|
||||
else:
|
||||
@@ -96,7 +78,7 @@ else:
|
||||
when not usesDestructors:
|
||||
include "system/cellsets"
|
||||
when not leakDetector and not useCellIds and not defined(nimV2):
|
||||
sysAssert(sizeof(FreeCell) <= sizeof(Cell), "sizeof FreeCell")
|
||||
sysAssert(sizeof(FreeCell) == sizeof(Cell), "sizeof FreeCell")
|
||||
when defined(gcRegions):
|
||||
# XXX due to bootstrapping reasons, we cannot use compileOption("gc", "stack") here
|
||||
include "system/gc_regions"
|
||||
|
||||
Reference in New Issue
Block a user