Step2: fixes #13781, fixes #13805 (#13897)

* Fix sym owner in wrapper proc
* threadpool changes
* revert lowerings
* add newFastMoveStmt
* try fixing test by switching to cpp

Co-authored-by: cooldome <ariabushenko@bk.ru>
This commit is contained in:
cooldome 2020-04-16 22:27:08 +01:00 • committed by GitHub
commit d3b0132061
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 111 additions and 45 deletions

View file

@ -44,7 +44,7 @@ type
graph: ModuleGraph
emptyNode: PNode
otherRead: PNode
inLoop, hasUnstructuredCf, inDangerousBranch: int
inLoop, inSpawn, hasUnstructuredCf, inDangerousBranch: int
declaredVars: IntSet # variables we already moved to the top level
uninit: IntSet # set of uninit'ed vars
uninitComputed: bool
@ -398,7 +398,7 @@ proc passCopyToSink(n: PNode; c: var Con): PNode =
var m = genCopy(c, tmp, n)
m.add p(n, c, normal)
result.add m
if isLValue(n) and not isClosureEnv(n) and n.typ.skipTypes(abstractInst).kind != tyRef:
if isLValue(n) and not isClosureEnv(n) and n.typ.skipTypes(abstractInst).kind != tyRef and c.inSpawn == 0:
message(c.graph.config, n.info, hintPerformance,
("passing '$1' to a sink parameter introduces an implicit copy; " &
"use 'move($1)' to prevent it") % $n)
@ -830,6 +830,12 @@ proc p(n: PNode; c: var Con; mode: ProcessMode): PNode =
if mode == normal and isRefConstr:
result = ensureDestruction(result, c)
of nkCallKinds:
let inSpawn = c.inSpawn
if n[0].kind == nkSym and n[0].sym.magic == mSpawn:
c.inSpawn.inc
elif c.inSpawn > 0:
c.inSpawn.dec
let parameters = n[0].typ
let L = if parameters != nil: parameters.len else: 0
@ -840,7 +846,7 @@ proc p(n: PNode; c: var Con; mode: ProcessMode): PNode =
result = shallowCopy(n)
for i in 1..<n.len:
if i < L and isSinkTypeForParam(parameters[i]):
if i < L and (isSinkTypeForParam(parameters[i]) or inSpawn > 0):
result[i] = p(n[i], c, sinkArg)
else:
result[i] = p(n[i], c, normal)
@ -1085,7 +1091,6 @@ proc injectDestructorCalls*(g: ModuleGraph; owner: PSym; n: PNode): PNode =
let t = params[i].sym.typ
if isSinkTypeForParam(t) and hasDestructor(t.skipTypes({tySink})):
c.destroys.add genDestroy(c, params[i])
#if optNimV2 in c.graph.config.globalOptions:
# injectDefaultCalls(n, c)
let body = p(n, c, normal)