serious allocator bugfixes
This commit is contained in:
parent
4f1b89c30c
commit
d849463af2
2 changed files with 11 additions and 4 deletions
|
|
@ -219,7 +219,10 @@ proc allocAvlNode(a: var TMemRegion, key, upperBound: int): PAvlNode =
|
||||||
result.upperBound = upperBound
|
result.upperBound = upperBound
|
||||||
result.link[0] = bottom
|
result.link[0] = bottom
|
||||||
result.link[1] = bottom
|
result.link[1] = bottom
|
||||||
result.level = 0
|
result.level = 1
|
||||||
|
sysAssert(bottom == addr(bottomData), "bottom data")
|
||||||
|
sysAssert(bottom.link[0] == bottom, "bottom link[0]")
|
||||||
|
sysAssert(bottom.link[1] == bottom, "bottom link[1]")
|
||||||
|
|
||||||
proc deallocAvlNode(a: var TMemRegion, n: PAvlNode) {.inline.} =
|
proc deallocAvlNode(a: var TMemRegion, n: PAvlNode) {.inline.} =
|
||||||
n.link[0] = a.freeAvlNodes
|
n.link[0] = a.freeAvlNodes
|
||||||
|
|
@ -632,7 +635,11 @@ proc interiorAllocatedPtr(a: TMemRegion, p: pointer): pointer =
|
||||||
|
|
||||||
proc ptrSize(p: pointer): int =
|
proc ptrSize(p: pointer): int =
|
||||||
var x = cast[pointer](cast[TAddress](p) -% sizeof(TFreeCell))
|
var x = cast[pointer](cast[TAddress](p) -% sizeof(TFreeCell))
|
||||||
result = pageAddr(x).size - sizeof(TFreeCell)
|
var c = pageAddr(p)
|
||||||
|
sysAssert(not chunkUnused(c), "ptrSize")
|
||||||
|
result = c.size -% sizeof(TFreeCell)
|
||||||
|
if not isSmallChunk(c):
|
||||||
|
dec result, bigChunkOverhead()
|
||||||
|
|
||||||
proc alloc(allocator: var TMemRegion, size: int): pointer =
|
proc alloc(allocator: var TMemRegion, size: int): pointer =
|
||||||
result = rawAlloc(allocator, size+sizeof(TFreeCell))
|
result = rawAlloc(allocator, size+sizeof(TFreeCell))
|
||||||
|
|
@ -652,7 +659,7 @@ proc dealloc(allocator: var TMemRegion, p: pointer) =
|
||||||
|
|
||||||
proc realloc(allocator: var TMemRegion, p: pointer, newsize: int): pointer =
|
proc realloc(allocator: var TMemRegion, p: pointer, newsize: int): pointer =
|
||||||
if newsize > 0:
|
if newsize > 0:
|
||||||
result = alloc(allocator, newsize)
|
result = alloc0(allocator, newsize)
|
||||||
if p != nil:
|
if p != nil:
|
||||||
copyMem(result, p, ptrSize(p))
|
copyMem(result, p, ptrSize(p))
|
||||||
dealloc(allocator, p)
|
dealloc(allocator, p)
|
||||||
|
|
|
||||||
2
todo.txt
2
todo.txt
|
|
@ -5,7 +5,7 @@ version 0.8.14
|
||||||
- BUG: type TX = TTable[string, int]
|
- BUG: type TX = TTable[string, int]
|
||||||
- BUG: len(openArray) breaks symbol files
|
- BUG: len(openArray) breaks symbol files
|
||||||
- BUG: temp3.nim triggers weird compiler bug
|
- BUG: temp3.nim triggers weird compiler bug
|
||||||
- BUG: --debugger:on does not work the talloc.nim
|
- BUG: --debugger:on does not work with talloc.nim
|
||||||
- warning for implicit openArray -> varargs conversion
|
- warning for implicit openArray -> varargs conversion
|
||||||
- implement explicit varargs; **but** ``len(varargs)`` problem remains!
|
- implement explicit varargs; **but** ``len(varargs)`` problem remains!
|
||||||
--> solve by implicit conversion from varargs to openarray
|
--> solve by implicit conversion from varargs to openarray
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue