diff --git a/compiler/lowerings.nim b/compiler/lowerings.nim index 0ca07e8285..efa3109c54 100644 --- a/compiler/lowerings.nim +++ b/compiler/lowerings.nim @@ -162,6 +162,7 @@ proc wrapProcForSpawn*(owner: PSym; n: PNode): PNode = argsParam.typ = ptrType argsParam.position = 1 var objType = createObj(owner, n.info) + incl(objType.flags, tfFinal) let castExpr = createCastExpr(argsParam, objType) var scratchObj = newSym(skVar, getIdent"scratch", owner, n.info) diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index b2b91490c0..72666e47dd 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -71,7 +71,7 @@ type init: seq[int] # list of initialized variables guards: TModel # nested guards locked: seq[PNode] # locked locations - gcUnsafe: bool + gcUnsafe, isRecursive: bool PEffects = var TEffects proc isLocalVar(a: PEffects, s: PSym): bool = @@ -502,7 +502,9 @@ proc track(tracked: PEffects, n: PNode) = # are indistinguishable from normal procs (both have tyProc type) and # we can detect them only by checking for attached nkEffectList. if op != nil and op.kind == tyProc and op.n.sons[0].kind == nkEffectList: - if notGcSafe(op) and not importedFromC(a): + if a.kind == nkSym and a.sym == tracked.owner: + tracked.isRecursive = true + elif notGcSafe(op) and not importedFromC(a): message(n.info, warnGcUnsafe, renderTree(n)) tracked.gcUnsafe = true var effectList = op.n.sons[0] diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 5d3ed05f76..673c7f0838 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -148,6 +148,9 @@ proc sumGeneric(t: PType): int = result = ord(t.kind == tyGenericInvokation) for i in 0 .. ".} elif defined(intelc): proc cpuRelax {.importc: "_mm_pause", header: "xmmintrin.h".} -else: +elif false: from os import sleep proc cpuRelax {.inline.} = os.sleep(1) -when defined(windows): +when defined(windows) and not defined(gcc): proc interlockedCompareExchange(p: pointer; exchange, comparand: int32): int32 {.importc: "InterlockedCompareExchange", header: "", cdecl.} @@ -70,6 +81,7 @@ proc await(cv: var FastCondVar) = # return # cpuRelax() #cv.slowPath = true + # XXX For some reason this crashes some test programs await(cv.slow) cv.event = false