diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-04-22 17:34:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-22 17:34:35 +0200 |
commit | 269a458d74e9abbc126d96c506b730c37af0932a (patch) | |
tree | f9ab5629c6dcdbda8bec40bec32056252161e3f7 /compiler | |
parent | 01523b2b58c8007cc2595f6bcf33cf2ba1d9e38a (diff) | |
download | Nim-269a458d74e9abbc126d96c506b730c37af0932a.tar.gz |
cycle collector (#14071)
* figured out the wrong cycle trace proc problem * cycle collector/break refactorings and minor improvements
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ccgtypes.nim | 3 | ||||
-rw-r--r-- | compiler/liftdestructors.nim | 6 |
2 files changed, 5 insertions, 4 deletions
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index b116a9aa6..46949831e 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -1297,7 +1297,8 @@ proc genHook(m: BModule; t: PType; info: TLineInfo; op: TTypeAttachedOp): Rope = if op == attachedTrace and m.config.selectedGC == gcOrc and containsGarbageCollectedRef(t): when false: - # re-enable this check + # unfortunately this check is wrong for an object type that only contains + # .cursor fields like 'Node' inside 'cycleleak'. internalError(m.config, info, "no attached trace proc found") result = rope("NIM_NIL") diff --git a/compiler/liftdestructors.nim b/compiler/liftdestructors.nim index a64857765..61034ef03 100644 --- a/compiler/liftdestructors.nim +++ b/compiler/liftdestructors.nim @@ -91,7 +91,7 @@ proc genWhileLoop(c: var TLiftCtx; i, dest: PNode): PNode = proc genIf(c: var TLiftCtx; cond, action: PNode): PNode = result = newTree(nkIfStmt, newTree(nkElifBranch, cond, action)) -proc genContainerOf(c: TLiftCtx; objType: PType, field, x: PSym): PNode = +proc genContainerOf(c: TLiftCtx; objType: PType, field, x: PSym): PNode = # generate: cast[ptr ObjType](cast[int](addr(x)) - offsetOf(objType.field)) let intType = getSysType(c.g, unknownLineInfo, tyInt) @@ -104,7 +104,7 @@ proc genContainerOf(c: TLiftCtx; objType: PType, field, x: PSym): PNode = let dotExpr = newNodeIT(nkDotExpr, c.info, x.typ) dotExpr.add newNodeIT(nkType, c.info, objType) dotExpr.add newSymNode(field) - + let offsetOf = genBuiltin(c.g, mOffsetOf, "offsetof", dotExpr) offsetOf.typ = intType @@ -174,7 +174,7 @@ proc fillBodyObj(c: var TLiftCtx; n, body, x, y: PNode; enforceDefaultOp: bool) caseStmt.add(branch) if emptyBranches != n.len-1: body.add(caseStmt) - c.filterDiscriminator = oldfilterDiscriminator + c.filterDiscriminator = oldfilterDiscriminator of nkRecList: for t in items(n): fillBodyObj(c, t, body, x, y, enforceDefaultOp) else: |