ORC: critical bugfix for mixing acyclic refs with cyclic refs [backport:1.4] (#17991)
This commit is contained in:
parent
45490497e3
commit
2c2ec48bc4
2 changed files with 12 additions and 8 deletions
|
|
@ -652,16 +652,19 @@ proc atomicRefOp(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||||
body.add genIf(c, cond, actions)
|
body.add genIf(c, cond, actions)
|
||||||
of attachedDeepCopy: assert(false, "cannot happen")
|
of attachedDeepCopy: assert(false, "cannot happen")
|
||||||
of attachedTrace:
|
of attachedTrace:
|
||||||
if isFinal(elemType):
|
if isCyclic:
|
||||||
let typInfo = genBuiltin(c, mGetTypeInfoV2, "getTypeInfoV2", newNodeIT(nkType, x.info, elemType))
|
if isFinal(elemType):
|
||||||
typInfo.typ = getSysType(c.g, c.info, tyPointer)
|
let typInfo = genBuiltin(c, mGetTypeInfoV2, "getTypeInfoV2", newNodeIT(nkType, x.info, elemType))
|
||||||
body.add callCodegenProc(c.g, "nimTraceRef", c.info, genAddrOf(x, c.idgen), typInfo, y)
|
typInfo.typ = getSysType(c.g, c.info, tyPointer)
|
||||||
else:
|
body.add callCodegenProc(c.g, "nimTraceRef", c.info, genAddrOf(x, c.idgen), typInfo, y)
|
||||||
# If the ref is polymorphic we have to account for this
|
else:
|
||||||
body.add callCodegenProc(c.g, "nimTraceRefDyn", c.info, genAddrOf(x, c.idgen), y)
|
# If the ref is polymorphic we have to account for this
|
||||||
|
body.add callCodegenProc(c.g, "nimTraceRefDyn", c.info, genAddrOf(x, c.idgen), y)
|
||||||
of attachedDispose:
|
of attachedDispose:
|
||||||
# this is crucial! dispose is like =destroy but we don't follow refs
|
# this is crucial! dispose is like =destroy but we don't follow refs
|
||||||
# as that is dealt within the cycle collector.
|
# as that is dealt within the cycle collector.
|
||||||
|
if not isCyclic:
|
||||||
|
body.add genIf(c, cond, actions)
|
||||||
when false:
|
when false:
|
||||||
let cond = copyTree(x)
|
let cond = copyTree(x)
|
||||||
cond.typ = getSysType(c.g, x.info, tyBool)
|
cond.typ = getSysType(c.g, x.info, tyBool)
|
||||||
|
|
|
||||||
|
|
@ -381,7 +381,8 @@ proc isFinal*(t: PType): bool =
|
||||||
|
|
||||||
proc canFormAcycle*(typ: PType): bool =
|
proc canFormAcycle*(typ: PType): bool =
|
||||||
var marker = initIntSet()
|
var marker = initIntSet()
|
||||||
result = canFormAcycleAux(marker, typ, typ.id)
|
let t = skipTypes(typ, abstractInst+{tyOwned}-{tyTypeDesc})
|
||||||
|
result = canFormAcycleAux(marker, t, t.id)
|
||||||
|
|
||||||
proc mutateTypeAux(marker: var IntSet, t: PType, iter: TTypeMutator,
|
proc mutateTypeAux(marker: var IntSet, t: PType, iter: TTypeMutator,
|
||||||
closure: RootRef): PType
|
closure: RootRef): PType
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue