Revert "fix #22173 sink paramers not moved into closure (refc) (#22… (#22376)

Revert "fix #22173 `sink` paramers not moved into closure (refc) (#22359)"

This reverts commit b40da812f7.
This commit is contained in:
Bung
2023-08-04 01:56:05 +08:00
committed by GitHub
parent b40da812f7
commit 6b913b4741
2 changed files with 6 additions and 29 deletions

View File

@@ -342,15 +342,12 @@ proc genAssignment(p: BProc, dest, src: TLoc, flags: TAssignmentFlags) =
if (dest.storage == OnStack and p.config.selectedGC != gcGo) or not usesWriteBarrier(p.config):
linefmt(p, cpsStmts, "$1 = #copyString($2);$n", [dest.rdLoc, src.rdLoc])
elif dest.storage == OnHeap:
if dest.lode.typ.kind == tySink:
genRefAssign(p, dest, src)
else:
# we use a temporary to care for the dreaded self assignment:
var tmp: TLoc
getTemp(p, ty, tmp)
linefmt(p, cpsStmts, "$3 = $1; $1 = #copyStringRC1($2);$n",
[dest.rdLoc, src.rdLoc, tmp.rdLoc])
linefmt(p, cpsStmts, "if ($1) #nimGCunrefNoCycle($1);$n", [tmp.rdLoc])
# we use a temporary to care for the dreaded self assignment:
var tmp: TLoc
getTemp(p, ty, tmp)
linefmt(p, cpsStmts, "$3 = $1; $1 = #copyStringRC1($2);$n",
[dest.rdLoc, src.rdLoc, tmp.rdLoc])
linefmt(p, cpsStmts, "if ($1) #nimGCunrefNoCycle($1);$n", [tmp.rdLoc])
else:
linefmt(p, cpsStmts, "#unsureAsgnRef((void**) $1, #copyString($2));$n",
[addrLoc(p.config, dest), rdLoc(src)])

View File

@@ -1,20 +0,0 @@
discard """
cmd: '''nim c --gc:refc -r $file'''
"""
const Memo = 100 * 1024
proc fff(v: sink string): iterator(): char =
return iterator(): char =
for c in v:
yield c
var tmp = newString(Memo)
let iter = fff(move(tmp))
while true:
let v = iter()
if finished(iter):
break
doAssert getOccupiedMem() < Memo * 3