ARC: cycle detector (#12823)
* first implementation of the =trace and =dispose hooks for the cycle collector * a cycle collector for ARC: progress * manual: the .acyclic pragma is a thing once again * gcbench: adaptations for --gc:arc * enable valgrind tests for the strutils tests * testament: better valgrind support * ARC refactoring: growable jumpstacks * ARC cycle detector: non-recursive algorithm * moved and renamed core/ files back to system/ * refactoring: --gc:arc vs --gc:orc since 'orc' is even more experimental and we want to ship --gc:arc soonish
This commit is contained in:
parent
5848f0042c
commit
83a736a34a
45 changed files with 939 additions and 229 deletions
26
tests/destructor/tselect.nim
Normal file
26
tests/destructor/tselect.nim
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
discard """
|
||||
output: '''abcsuffix
|
||||
xyzsuffix'''
|
||||
cmd: '''nim c --gc:arc $file'''
|
||||
"""
|
||||
|
||||
proc select(cond: bool; a, b: sink string): string =
|
||||
if cond:
|
||||
result = a # moves a into result
|
||||
else:
|
||||
result = b # moves b into result
|
||||
|
||||
proc test(param: string; cond: bool) =
|
||||
var x = "abc" & param
|
||||
var y = "xyz" & param
|
||||
|
||||
# possible self-assignment:
|
||||
x = select(cond, x, y)
|
||||
|
||||
echo x
|
||||
# 'select' must communicate what parameter has been
|
||||
# consumed. We cannot simply generate:
|
||||
# (select(...); wasMoved(x); wasMoved(y))
|
||||
|
||||
test("suffix", true)
|
||||
test("suffix", false)
|
||||
Loading…
Add table
Add a link
Reference in a new issue