make memory regions robust; disable free lists for now
This commit is contained in:
parent
1c478db375
commit
88bc2d8df4
1 changed files with 32 additions and 28 deletions
|
|
@ -70,6 +70,7 @@ type
|
|||
bump: pointer
|
||||
head, tail: Chunk
|
||||
nextChunkSize, totalSize: int
|
||||
when false:
|
||||
freeLists: array[MaxSmallObject div MemAlign, FreeEntry]
|
||||
holes: SizedFreeEntry
|
||||
when hasThreadSupport:
|
||||
|
|
@ -145,6 +146,7 @@ proc allocSlowPath(r: var MemRegion; size: int) =
|
|||
r.remaining = s - sizeof(BaseChunk)
|
||||
|
||||
proc allocFast(r: var MemRegion; size: int): pointer =
|
||||
when false:
|
||||
if size <= MaxSmallObject:
|
||||
var it = r.freeLists[size div MemAlign]
|
||||
if it != nil:
|
||||
|
|
@ -184,7 +186,8 @@ proc dealloc(r: var MemRegion; p: pointer; size: int) =
|
|||
# it is benefitial to not use the free lists here:
|
||||
if r.bump -! size == p:
|
||||
dec r.bump, size
|
||||
elif size <= MaxSmallObject:
|
||||
when false:
|
||||
if size <= MaxSmallObject:
|
||||
let it = cast[FreeEntry](p)
|
||||
it.next = r.freeLists[size div MemAlign]
|
||||
r.freeLists[size div MemAlign] = it
|
||||
|
|
@ -220,6 +223,7 @@ proc setObstackPtr*(r: var MemRegion; sp: StackPtr) =
|
|||
if sp.current.next != nil:
|
||||
deallocAll(r, sp.current.next)
|
||||
sp.current.next = nil
|
||||
when false:
|
||||
# better leak this memory than be sorry:
|
||||
for i in 0..high(r.freeLists): r.freeLists[i] = nil
|
||||
r.holes = nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue