mmdisp: code cleanups
This commit is contained in:
parent
8f0c9b2fdd
commit
16d8fab310
1 changed files with 59 additions and 64 deletions
|
|
@ -175,8 +175,7 @@ when defined(boehmgc):
|
||||||
dest[] = src
|
dest[] = src
|
||||||
|
|
||||||
type
|
type
|
||||||
MemRegion = object {.final, pure.}
|
MemRegion = object
|
||||||
{.deprecated: [TMemRegion: MemRegion].}
|
|
||||||
|
|
||||||
proc alloc(r: var MemRegion, size: int): pointer =
|
proc alloc(r: var MemRegion, size: int): pointer =
|
||||||
result = boehmAlloc(size)
|
result = boehmAlloc(size)
|
||||||
|
|
@ -215,8 +214,6 @@ elif defined(gogc):
|
||||||
goNumSizeClasses = 67
|
goNumSizeClasses = 67
|
||||||
|
|
||||||
type
|
type
|
||||||
cbool {.importc: "_Bool", nodecl.} = bool
|
|
||||||
|
|
||||||
goMStats_inner_struct = object
|
goMStats_inner_struct = object
|
||||||
size: uint32
|
size: uint32
|
||||||
nmalloc: uint64
|
nmalloc: uint64
|
||||||
|
|
@ -259,8 +256,8 @@ elif defined(gogc):
|
||||||
numgc: uint32
|
numgc: uint32
|
||||||
numforcedgc: uint32 # number of user-forced GCs
|
numforcedgc: uint32 # number of user-forced GCs
|
||||||
gc_cpu_fraction: float64 # fraction of CPU time used by GC
|
gc_cpu_fraction: float64 # fraction of CPU time used by GC
|
||||||
enablegc: cbool
|
enablegc: bool
|
||||||
debuggc: cbool
|
debuggc: bool
|
||||||
# Statistics about allocation size classes.
|
# Statistics about allocation size classes.
|
||||||
by_size: array[goNumSizeClasses, goMStats_inner_struct]
|
by_size: array[goNumSizeClasses, goMStats_inner_struct]
|
||||||
# Statistics below here are not exported to MemStats directly.
|
# Statistics below here are not exported to MemStats directly.
|
||||||
|
|
@ -341,9 +338,12 @@ elif defined(gogc):
|
||||||
proc getOccupiedSharedMem(): int = discard
|
proc getOccupiedSharedMem(): int = discard
|
||||||
|
|
||||||
const goFlagNoZero: uint32 = 1 shl 3
|
const goFlagNoZero: uint32 = 1 shl 3
|
||||||
proc goRuntimeMallocGC(size: uint, typ: uint, flag: uint32): pointer {.importc: "runtime_mallocgc", dynlib: goLib.}
|
proc goRuntimeMallocGC(size: uint, typ: uint, flag: uint32): pointer {.
|
||||||
|
importc: "runtime_mallocgc", dynlib: goLib.}
|
||||||
|
|
||||||
proc goSetFinalizer(obj: pointer, f: pointer) {.importc: "set_finalizer", codegenDecl:"$1 $2$3 __asm__ (\"main.Set_finalizer\");\n$1 $2$3", dynlib: goLib.}
|
proc goSetFinalizer(obj: pointer, f: pointer) {.
|
||||||
|
importc: "set_finalizer", codegenDecl: "$1 $2$3 __asm__ (\"main.Set_finalizer\");\n$1 $2$3",
|
||||||
|
dynlib: goLib.}
|
||||||
|
|
||||||
proc newObj(typ: PNimType, size: int): pointer {.compilerproc.} =
|
proc newObj(typ: PNimType, size: int): pointer {.compilerproc.} =
|
||||||
result = goRuntimeMallocGC(roundup(size, sizeof(pointer)).uint, 0.uint, 0.uint32)
|
result = goRuntimeMallocGC(roundup(size, sizeof(pointer)).uint, 0.uint, 0.uint32)
|
||||||
|
|
@ -369,8 +369,7 @@ elif defined(gogc):
|
||||||
|
|
||||||
proc growObj(old: pointer, newsize: int): pointer =
|
proc growObj(old: pointer, newsize: int): pointer =
|
||||||
# the Go GC doesn't have a realloc
|
# the Go GC doesn't have a realloc
|
||||||
var
|
let oldsize = cast[PGenericSeq](old).len * cast[PGenericSeq](old).elemSize + GenericSeqSize
|
||||||
oldsize = cast[PGenericSeq](old).len * cast[PGenericSeq](old).elemSize + GenericSeqSize
|
|
||||||
result = goRuntimeMallocGC(roundup(newsize, sizeof(pointer)).uint, 0.uint, goFlagNoZero)
|
result = goRuntimeMallocGC(roundup(newsize, sizeof(pointer)).uint, 0.uint, goFlagNoZero)
|
||||||
copyMem(result, old, oldsize)
|
copyMem(result, old, oldsize)
|
||||||
zeroMem(cast[pointer](cast[ByteAddress](result) +% oldsize), newsize - oldsize)
|
zeroMem(cast[pointer](cast[ByteAddress](result) +% oldsize), newsize - oldsize)
|
||||||
|
|
@ -386,8 +385,7 @@ elif defined(gogc):
|
||||||
dest[] = src
|
dest[] = src
|
||||||
|
|
||||||
type
|
type
|
||||||
MemRegion = object {.final, pure.}
|
MemRegion = object
|
||||||
{.deprecated: [TMemRegion: MemRegion].}
|
|
||||||
|
|
||||||
proc alloc(r: var MemRegion, size: int): pointer =
|
proc alloc(r: var MemRegion, size: int): pointer =
|
||||||
result = alloc(size)
|
result = alloc(size)
|
||||||
|
|
@ -477,8 +475,7 @@ elif defined(nogc) and defined(useMalloc):
|
||||||
dest[] = src
|
dest[] = src
|
||||||
|
|
||||||
type
|
type
|
||||||
MemRegion = object {.final, pure.}
|
MemRegion = object
|
||||||
{.deprecated: [TMemRegion: MemRegion].}
|
|
||||||
|
|
||||||
proc alloc(r: var MemRegion, size: int): pointer =
|
proc alloc(r: var MemRegion, size: int): pointer =
|
||||||
result = alloc(size)
|
result = alloc(size)
|
||||||
|
|
@ -551,11 +548,9 @@ else:
|
||||||
elif defined(gcRegions):
|
elif defined(gcRegions):
|
||||||
# XXX due to bootstrapping reasons, we cannot use compileOption("gc", "stack") here
|
# XXX due to bootstrapping reasons, we cannot use compileOption("gc", "stack") here
|
||||||
include "system/gc_regions"
|
include "system/gc_regions"
|
||||||
elif defined(gcMarkAndSweep):
|
elif defined(gcMarkAndSweep) or defined(gcDestructors):
|
||||||
# XXX use 'compileOption' here
|
# XXX use 'compileOption' here
|
||||||
include "system/gc_ms"
|
include "system/gc_ms"
|
||||||
elif defined(gcGenerational):
|
|
||||||
include "system/gc"
|
|
||||||
else:
|
else:
|
||||||
include "system/gc"
|
include "system/gc"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue