Fixed GC issues
This commit is contained in:
parent
709b40341c
commit
d09b72694e
|
@ -161,9 +161,15 @@ template free*(self: var PeonVM, kind: typedesc, p: pointer): untyped =
|
|||
discard reallocate(self, p, sizeof(kind), 0)
|
||||
|
||||
|
||||
template setKind*[T, K](t: var T, kind: untyped, target: K) =
|
||||
## Thanks to https://forum.nim-lang.org/t/8312
|
||||
cast[ptr K](cast[int](addr t) + offsetOf(typeof(t), kind))[] = target
|
||||
|
||||
|
||||
proc allocate*(self: var PeonVM, kind: ObjectKind, size: typedesc, count: int): ptr HeapObject {.inline.} =
|
||||
## Allocates an object on the heap
|
||||
result = cast[ptr HeapObject](self.reallocate(nil, 0, sizeof(HeapObject)))
|
||||
setkind(result[], kind, kind)
|
||||
result.marked = false
|
||||
self.gc.bytesAllocated.total += sizeof(HeapObject)
|
||||
self.gc.bytesAllocated.current += sizeof(HeapObject)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import std;
|
||||
|
||||
|
||||
var x = 10000;
|
||||
var x = 1000000;
|
||||
var y = "just a test";
|
||||
print(y);
|
||||
print("Starting GC torture test");
|
||||
|
|
Loading…
Reference in New Issue