cleaned up GC tests; fixes object variant re-assign bug
This commit is contained in:
parent
865d341b32
commit
eec18896b7
3 changed files with 11 additions and 5 deletions
|
|
@ -205,9 +205,13 @@ proc genericReset(dest: pointer, mt: PNimType) =
|
||||||
case mt.kind
|
case mt.kind
|
||||||
of tyString, tyRef, tySequence:
|
of tyString, tyRef, tySequence:
|
||||||
unsureAsgnRef(cast[PPointer](dest), nil)
|
unsureAsgnRef(cast[PPointer](dest), nil)
|
||||||
of tyObject, tyTuple:
|
of tyTuple:
|
||||||
# we don't need to reset m_type field for tyObject
|
|
||||||
genericResetAux(dest, mt.node)
|
genericResetAux(dest, mt.node)
|
||||||
|
of tyObject:
|
||||||
|
genericResetAux(dest, mt.node)
|
||||||
|
# also reset the type field for tyObject, for correct branch switching!
|
||||||
|
var pint = cast[ptr PNimType](dest)
|
||||||
|
pint[] = nil
|
||||||
of tyArray, tyArrayConstr:
|
of tyArray, tyArrayConstr:
|
||||||
for i in 0..(mt.size div mt.base.size)-1:
|
for i in 0..(mt.size div mt.base.size)-1:
|
||||||
genericReset(cast[pointer](d +% i*% mt.base.size), mt.base)
|
genericReset(cast[pointer](d +% i*% mt.base.size), mt.base)
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,14 @@ proc newPlus(a, b: ref TExpr): ref TPlusExpr =
|
||||||
result.b = b
|
result.b = b
|
||||||
result.op2 = $getOccupiedMem()
|
result.op2 = $getOccupiedMem()
|
||||||
|
|
||||||
|
const Limit = when compileOption("gc", "markAndSweep"): 5*1024*1024 else: 500_000
|
||||||
|
|
||||||
for i in 0..100_000:
|
for i in 0..100_000:
|
||||||
var s: array[0..11, ref TExpr]
|
var s: array[0..11, ref TExpr]
|
||||||
for j in 0..high(s):
|
for j in 0..high(s):
|
||||||
s[j] = newPlus(newPlus(newLit(j), newLit(2)), newLit(4))
|
s[j] = newPlus(newPlus(newLit(j), newLit(2)), newLit(4))
|
||||||
if eval(s[j]) != j+6:
|
if eval(s[j]) != j+6:
|
||||||
quit "error: wrong result"
|
quit "error: wrong result"
|
||||||
if getOccupiedMem() > 500_000: quit("still a leak!")
|
if getOccupiedMem() > Limit: quit("still a leak!")
|
||||||
|
|
||||||
echo "no leak: ", getOccupiedMem()
|
echo "no leak: ", getOccupiedMem()
|
||||||
|
|
|
||||||
2
todo.txt
2
todo.txt
|
|
@ -5,6 +5,7 @@ version 0.10.4
|
||||||
- improve GC-unsafety warnings
|
- improve GC-unsafety warnings
|
||||||
- get rid of 'mget'; aka priority of 'var' needs to be 'var{lvalue}'
|
- get rid of 'mget'; aka priority of 'var' needs to be 'var{lvalue}'
|
||||||
- improve documentation (theindex!)
|
- improve documentation (theindex!)
|
||||||
|
- ensure (ref T)(a, b) works as a type conversion and type constructor
|
||||||
|
|
||||||
|
|
||||||
version 1.0
|
version 1.0
|
||||||
|
|
@ -66,7 +67,6 @@ version 0.9.x
|
||||||
- memory manager: add a measure of fragmentation
|
- memory manager: add a measure of fragmentation
|
||||||
- implement 'bits' pragmas
|
- implement 'bits' pragmas
|
||||||
- we need a magic thisModule symbol
|
- we need a magic thisModule symbol
|
||||||
- ensure (ref T)(a, b) works as a type conversion and type constructor
|
|
||||||
- optimize 'genericReset'; 'newException' leads to code bloat
|
- optimize 'genericReset'; 'newException' leads to code bloat
|
||||||
- The 'do' notation might be trimmed so that its only purpose is to pass
|
- The 'do' notation might be trimmed so that its only purpose is to pass
|
||||||
multiple multi line constructs to a macro.
|
multiple multi line constructs to a macro.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue