From 1d1752cac75fd0c607624df7ca40b7a8cd9f54ce Mon Sep 17 00:00:00 2001 From: Araq Date: Sun, 15 Jan 2012 11:54:38 +0100 Subject: removed nimKeepAlive as it's not necessary with interior pointer checking --- compiler/ccgcalls.nim | 64 ++++++++++++++++----------------------------------- lib/system/gc.nim | 7 ------ 2 files changed, 20 insertions(+), 51 deletions(-) diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim index f8c26aa58..23dd05b50 100644 --- a/compiler/ccgcalls.nim +++ b/compiler/ccgcalls.nim @@ -7,9 +7,6 @@ # distribution, for details about the copyright. # -type - TAfterCallActions = tuple[p: BProc, actions: PRope] - proc leftAppearsOnRightSide(le, ri: PNode): bool = if le != nil: for i in 1 .. data, $1->$2", [a.rdLoc, lenField()]) - genKeepAlive(aca, n, a) of tyArray, tyArrayConstr: result = ropef("$1, $2", [rdLoc(a), toRope(lengthOrd(a.t))]) else: InternalError("openArrayLoc: " & typeToString(a.t)) -proc genArgStringToCString(aca: var TAfterCallActions, +proc genArgStringToCString(p: BProc, n: PNode): PRope {.inline.} = var a: TLoc - initLocExpr(aca.p, n.sons[0], a) + initLocExpr(p, n.sons[0], a) result = ropef("$1->data", [a.rdLoc]) - # we don't guarantee save string->cstring conversions anyway, so we use - # an additional check to improve performance: - if isInCurrentFrame(aca.p, n): genKeepAlive(aca, n, a) -proc genArg(aca: var TAfterCallActions, n: PNode, param: PSym): PRope = +proc genArg(p: BProc, n: PNode, param: PSym): PRope = var a: TLoc if n.kind == nkStringToCString: - result = genArgStringToCString(aca, n) + result = genArgStringToCString(p, n) elif skipTypes(param.typ, abstractVar).kind == tyOpenArray: var n = if n.kind != nkHiddenAddr: n else: n.sons[0] - result = openArrayLoc(aca, n) + result = openArrayLoc(p, n) elif ccgIntroducedPtr(param): - initLocExpr(aca.p, n, a) + initLocExpr(p, n, a) result = addrLoc(a) else: - initLocExpr(aca.p, n, a) + initLocExpr(p, n, a) result = rdLoc(a) -proc genArgNoParam(aca: var TAfterCallActions, n: PNode): PRope = +proc genArgNoParam(p: BProc, n: PNode): PRope = var a: TLoc if n.kind == nkStringToCString: - result = genArgStringToCString(aca, n) + result = genArgStringToCString(p, n) else: - initLocExpr(aca.p, n, a) + initLocExpr(p, n, a) result = rdLoc(a) proc genPrefixCall(p: BProc, le, ri: PNode, d: var TLoc) = var op: TLoc - var aca: TAfterCallActions - aca.p = p # this is a hotspot in the compiler initLocExpr(p, ri.sons[0], op) var pl = con(op.r, "(") @@ -145,17 +128,14 @@ proc genPrefixCall(p: BProc, le, ri: PNode, d: var TLoc) = assert(sonsLen(typ) == sonsLen(typ.n)) if i < sonsLen(typ): assert(typ.n.sons[i].kind == nkSym) - app(pl, genArg(aca, ri.sons[i], typ.n.sons[i].sym)) + app(pl, genArg(p, ri.sons[i], typ.n.sons[i].sym)) else: - app(pl, genArgNoParam(aca, ri.sons[i])) + app(pl, genArgNoParam(p, ri.sons[i])) if i < length - 1: app(pl, ", ") fixupCall(p, le, ri, d, pl) - emitAfterCallActions(aca) proc genInfixCall(p: BProc, le, ri: PNode, d: var TLoc) = var op, a: TLoc - var aca: TAfterCallActions - aca.p = p initLocExpr(p, ri.sons[0], op) var pl: PRope = nil var typ = ri.sons[0].typ # getUniqueType() is too expensive here! @@ -164,7 +144,7 @@ proc genInfixCall(p: BProc, le, ri: PNode, d: var TLoc) = assert(sonsLen(typ) == sonsLen(typ.n)) var param = typ.n.sons[1].sym - app(pl, genArg(aca, ri.sons[1], param)) + app(pl, genArg(p, ri.sons[1], param)) if skipTypes(param.typ, {tyGenericInst}).kind == tyPtr: app(pl, "->") else: app(pl, ".") @@ -174,18 +154,15 @@ proc genInfixCall(p: BProc, le, ri: PNode, d: var TLoc) = assert(sonsLen(typ) == sonsLen(typ.n)) if i < sonsLen(typ): assert(typ.n.sons[i].kind == nkSym) - app(pl, genArg(aca, ri.sons[i], typ.n.sons[i].sym)) + app(pl, genArg(p, ri.sons[i], typ.n.sons[i].sym)) else: - app(pl, genArgNoParam(aca, ri.sons[i])) + app(pl, genArgNoParam(p, ri.sons[i])) if i < length - 1: app(pl, ", ") fixupCall(p, le, ri, d, pl) - emitAfterCallActions(aca) proc genNamedParamCall(p: BProc, ri: PNode, d: var TLoc) = # generates a crappy ObjC call var op, a: TLoc - var aca: TAfterCallActions - aca.p = p initLocExpr(p, ri.sons[0], op) var pl = toRope"[" var typ = ri.sons[0].typ # getUniqueType() is too expensive here! @@ -194,12 +171,12 @@ proc genNamedParamCall(p: BProc, ri: PNode, d: var TLoc) = assert(sonsLen(typ) == sonsLen(typ.n)) if length > 1: - app(pl, genArg(aca, ri.sons[1], typ.n.sons[1].sym)) + app(pl, genArg(p, ri.sons[1], typ.n.sons[1].sym)) app(pl, " ") app(pl, op.r) if length > 2: app(pl, ": ") - app(pl, genArg(aca, ri.sons[2], typ.n.sons[2].sym)) + app(pl, genArg(p, ri.sons[2], typ.n.sons[2].sym)) for i in countup(3, length-1): assert(sonsLen(typ) == sonsLen(typ.n)) if i >= sonsLen(typ): @@ -209,7 +186,7 @@ proc genNamedParamCall(p: BProc, ri: PNode, d: var TLoc) = app(pl, " ") app(pl, param.name.s) app(pl, ": ") - app(pl, genArg(aca, ri.sons[i], param)) + app(pl, genArg(p, ri.sons[i], param)) if typ.sons[0] != nil: if isInvalidReturnType(typ.sons[0]): if sonsLen(ri) > 1: app(pl, " ") @@ -242,7 +219,6 @@ proc genNamedParamCall(p: BProc, ri: PNode, d: var TLoc) = app(pl, "]") app(p.s[cpsStmts], pl) appf(p.s[cpsStmts], ";$n") - emitAfterCallActions(aca) proc genCall(p: BProc, e: PNode, d: var TLoc) = if e.sons[0].kind == nkSym and sfInfixCall in e.sons[0].sym.flags and diff --git a/lib/system/gc.nim b/lib/system/gc.nim index 262ca9971..1aae16f1a 100755 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -34,8 +34,6 @@ const rcWhite = 0b010 # member of a garbage cycle rcPurple = 0b011 # possible root of a cycle rcZct = 0b100 # in ZCT - rcMarked = 0b101 # dummy write to keep C code generator from - # eliminating the root rcRed = 0b101 # Candidate cycle undergoing sigma-computation rcOrange = 0b110 # Candidate cycle awaiting epoch boundary rcShift = 3 # shift by rcShift to get the reference counter @@ -588,11 +586,6 @@ proc gcMark(gch: var TGcHeap, p: pointer) {.inline.} = add(gch.decStack, cell) sysAssert(allocInv(gch.region), "gcMark end") -proc nimKeepAlive(p: PGenericSeq) {.compilerRtl, noinline.} = - var c = usrToCell(p) - if isAllocatedPtr(gch.region, c): - c.refcount = c.refcount or rcMarked - proc markThreadStacks(gch: var TGcHeap) = when hasThreadSupport and hasSharedHeap: {.error: "not fully implemented".} -- cgit 1.4.1-2-gfad0