fixes exhaustion bug and missing GC_ref code generation
This commit is contained in:
parent
b5586264a0
commit
06e9932e8a
2 changed files with 10 additions and 5 deletions
|
|
@ -286,6 +286,12 @@ proc createWrapperProc(f: PNode; threadParam, argsParam: PSym;
|
||||||
typeToString(fv.typ.sons[1]))
|
typeToString(fv.typ.sons[1]))
|
||||||
body.add newAsgnStmt(indirectAccess(threadLocalProm.newSymNode,
|
body.add newAsgnStmt(indirectAccess(threadLocalProm.newSymNode,
|
||||||
if fk == fvGC: "data" else: "blob", fv.info), call)
|
if fk == fvGC: "data" else: "blob", fv.info), call)
|
||||||
|
if fk == fvGC:
|
||||||
|
let incRefCall = newNodeI(nkCall, fv.info, 2)
|
||||||
|
incRefCall.sons[0] = newSymNode(createMagic("GCref", mGCref))
|
||||||
|
incRefCall.sons[1] = indirectAccess(threadLocalProm.newSymNode,
|
||||||
|
"data", fv.info)
|
||||||
|
body.add incRefCall
|
||||||
if barrier == nil:
|
if barrier == nil:
|
||||||
# by now 'fv' is shared and thus might have beeen overwritten! we need
|
# by now 'fv' is shared and thus might have beeen overwritten! we need
|
||||||
# to use the thread-local view instead:
|
# to use the thread-local view instead:
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,8 @@ type
|
||||||
# for 'awaitAny' support
|
# for 'awaitAny' support
|
||||||
ai: ptr AwaitInfo
|
ai: ptr AwaitInfo
|
||||||
idx: int
|
idx: int
|
||||||
data: RootRef # we incRef and unref it to keep it alive
|
data: pointer # we incRef and unref it to keep it alive; note this MUST NOT
|
||||||
|
# be RootRef here otherwise the wrong GC keeps track of it!
|
||||||
owner: pointer # ptr Worker
|
owner: pointer # ptr Worker
|
||||||
|
|
||||||
FlowVarObj[T] = object of FlowVarBaseObj
|
FlowVarObj[T] = object of FlowVarBaseObj
|
||||||
|
|
@ -162,10 +163,8 @@ proc finished(fv: FlowVarBase) =
|
||||||
var waited = false
|
var waited = false
|
||||||
acquire(q.lock)
|
acquire(q.lock)
|
||||||
while not (q.len < q.data.len):
|
while not (q.len < q.data.len):
|
||||||
echo "EXHAUSTED!"
|
#echo "EXHAUSTED!"
|
||||||
release(q.lock)
|
|
||||||
wakeupWorkerToProcessQueue(owner)
|
wakeupWorkerToProcessQueue(owner)
|
||||||
acquire(q.lock)
|
|
||||||
wait(q.empty, q.lock)
|
wait(q.empty, q.lock)
|
||||||
waited = true
|
waited = true
|
||||||
q.data[q.len] = cast[pointer](fv.data)
|
q.data[q.len] = cast[pointer](fv.data)
|
||||||
|
|
@ -180,7 +179,7 @@ proc cleanFlowVars(w: ptr Worker) =
|
||||||
acquire(q.lock)
|
acquire(q.lock)
|
||||||
for i in 0 .. <q.len:
|
for i in 0 .. <q.len:
|
||||||
GC_unref(cast[RootRef](q.data[i]))
|
GC_unref(cast[RootRef](q.data[i]))
|
||||||
echo "GC_unref"
|
#echo "GC_unref"
|
||||||
q.len = 0
|
q.len = 0
|
||||||
release(q.lock)
|
release(q.lock)
|
||||||
signal(q.empty)
|
signal(q.empty)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue