diff options
author | Zahary Karadjov <zahary@gmail.com> | 2012-12-01 15:24:32 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2012-12-01 15:37:13 +0200 |
commit | e9e22ccb2adfe1a44e998405b2dfed9b46ddcb95 (patch) | |
tree | f157d6c1bc8e3b908c8175a3729ce2f8e7bc48f4 /tests | |
parent | c67520a7c5d474be409bee98d9b258030115c259 (diff) | |
download | Nim-e9e22ccb2adfe1a44e998405b2dfed9b46ddcb95.tar.gz |
track the "owner" heap object in the ref write barrier
See the papers for reference counting with heap sliding views for details:
Diffstat (limited to 'tests')
-rw-r--r-- | tests/compile/theaproots.nim | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/compile/theaproots.nim b/tests/compile/theaproots.nim new file mode 100644 index 000000000..aec140f42 --- /dev/null +++ b/tests/compile/theaproots.nim @@ -0,0 +1,71 @@ +type + Bar = object + x: int + + Foo = object + rheap: ref Bar + rmaybe: ref Bar + rstack: ref Bar + list: seq[ref Bar] + listarr: array[0..5, ref Bar] + nestedtup: Tup + inner: TInner + inref: ref TInner + + TInner = object + inref: ref Bar + + Tup = tuple + tupbar: ref Bar + inner: TInner + +proc acc(x: var Foo): var ref Bar = + result = x.rheap + +proc test(maybeFoo: var Foo, + maybeSeq: var seq[ref Bar], + bars: var openarray[ref Bar], + maybeTup: var Tup) = + var bb: ref Bar + maybeFoo.rmaybe = bb + maybeFoo.list[3] = bb + maybeFoo.listarr[3] = bb + acc(maybeFoo) = bb + + var localFoo: Foo + localFoo.rstack = bb + localFoo.list[3] = bb + localFoo.listarr[3] = bb + acc(localFoo) = bb + + var heapFoo: ref Foo + heapFoo.rheap = bb + heapFoo.list[3] = bb + heapFoo.listarr[3] = bb + acc(heapFoo[]) = bb + + heapFoo.nestedtup.tupbar = bb + heapFoo.nestedtup.inner.inref = bb + heapFoo.inner.inref = bb + heapFoo.inref.inref = bb + + var locseq: seq[ref Bar] + locseq[3] = bb + + var locarr: array[0..4, ref Bar] + locarr[3] = bb + + maybeSeq[3] = bb + + bars[3] = bb + + maybeTup[0] = bb + +var + ff: ref Foo + tt: Tup + gseq: seq[ref Bar] + +new(ff) + +test(ff[], gseq, gseq, tt) |