diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2021-05-12 22:00:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-12 22:00:37 +0200 |
commit | 3bc625aff1664eb4206ae90d0a132c8f717e651d (patch) | |
tree | 5ffd5edee1fd4dbc1cc76f00f1dd3131dd332076 /compiler | |
parent | 60b4fa71a8ce1abc43b6f6bba3c3aa1f69b15092 (diff) | |
download | Nim-3bc625aff1664eb4206ae90d0a132c8f717e651d.tar.gz |
ORC: progress (#18000)
* ORC: progress * ORC: bugfix; don't follow acyclic data even if only at runtime the subtype is marked as acyclic * progress * minor style changes
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/btrees.nim | 2 | ||||
-rw-r--r-- | compiler/ccgtypes.nim | 11 | ||||
-rw-r--r-- | compiler/dfa.nim | 2 | ||||
-rw-r--r-- | compiler/liftdestructors.nim | 14 | ||||
-rw-r--r-- | compiler/semdata.nim | 4 | ||||
-rw-r--r-- | compiler/types.nim | 6 | ||||
-rw-r--r-- | compiler/vm.nim | 2 | ||||
-rw-r--r-- | compiler/vmdef.nim | 2 |
8 files changed, 26 insertions, 17 deletions
diff --git a/compiler/btrees.nim b/compiler/btrees.nim index 5f78c07fe..d5e7e8099 100644 --- a/compiler/btrees.nim +++ b/compiler/btrees.nim @@ -16,7 +16,7 @@ const Mhalf = M div 2 type - Node[Key, Val] = ref object + Node[Key, Val] {.acyclic.} = ref object entries: int keys: array[M, Key] case isInternal: bool diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 767525fd5..6e5ffeaa4 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -1301,6 +1301,10 @@ proc genHook(m: BModule; t: PType; info: TLineInfo; op: TTypeAttachedOp): Rope = genProc(m, theProc) result = theProc.loc.r + + when false: + if not canFormAcycle(t) and op == attachedTrace: + echo "ayclic but has this =trace ", t, " ", theProc.ast else: when false: if op == attachedTrace and m.config.selectedGC == gcOrc and @@ -1326,9 +1330,12 @@ proc genTypeInfoV2Impl(m: BModule, t, origType: PType, name: Rope; info: TLineIn let traceImpl = genHook(m, t, info, attachedTrace) let disposeImpl = genHook(m, t, info, attachedDispose) - addf(m.s[cfsTypeInit3], "$1.destructor = (void*)$2; $1.size = sizeof($3); $1.align = NIM_ALIGNOF($3); $1.name = $4;$n; $1.traceImpl = (void*)$5; $1.disposeImpl = (void*)$6;", [ + var flags = 0 + if not canFormAcycle(t): flags = flags or 1 + + addf(m.s[cfsTypeInit3], "$1.destructor = (void*)$2; $1.size = sizeof($3); $1.align = NIM_ALIGNOF($3); $1.name = $4;$n; $1.traceImpl = (void*)$5; $1.disposeImpl = (void*)$6; $1.flags = $7;", [ name, destroyImpl, getTypeDesc(m, t), typeName, - traceImpl, disposeImpl]) + traceImpl, disposeImpl, rope(flags)]) if t.kind == tyObject and t.len > 0 and t[0] != nil and optEnableDeepCopy in m.config.globalOptions: discard genTypeInfoV1(m, t, info) diff --git a/compiler/dfa.nim b/compiler/dfa.nim index 501d39f45..ea60dbc59 100644 --- a/compiler/dfa.nim +++ b/compiler/dfa.nim @@ -467,7 +467,7 @@ proc genCase(c: var Con; n: PNode) = # treat the last branch as 'else' if this is an exhaustive case statement. c.gen(it.lastSon) if endings.len != 0: - c.patch(endings[^1]) + c.patch(endings[^1]) else: forkT(it.lastSon): c.gen(it.lastSon) diff --git a/compiler/liftdestructors.nim b/compiler/liftdestructors.nim index de45beb52..43f87e179 100644 --- a/compiler/liftdestructors.nim +++ b/compiler/liftdestructors.nim @@ -513,8 +513,9 @@ proc fillSeqOp(c: var TLiftCtx; t: PType; body, x, y: PNode) = forallElements(c, t, body, x, y) body.add genBuiltin(c, mDestroy, "destroy", x) of attachedTrace: - # follow all elements: - forallElements(c, t, body, x, y) + if canFormAcycle(t.elemType): + # follow all elements: + forallElements(c, t, body, x, y) of attachedDispose: forallElements(c, t, body, x, y) body.add genBuiltin(c, mDestroy, "destroy", x) @@ -550,10 +551,11 @@ proc useSeqOrStrOp(c: var TLiftCtx; t: PType; body, x, y: PNode) = doAssert t.destructor != nil body.add destructorCall(c, t.destructor, x) of attachedTrace: - let op = getAttachedOp(c.g, t, c.kind) - if op == nil: - return # protect from recursion - body.add newHookCall(c, op, x, y) + if t.kind != tyString and canFormAcycle(t.elemType): + let op = getAttachedOp(c.g, t, c.kind) + if op == nil: + return # protect from recursion + body.add newHookCall(c, op, x, y) of attachedDispose: let op = getAttachedOp(c.g, t, c.kind) if op == nil: diff --git a/compiler/semdata.nim b/compiler/semdata.nim index d26e57320..f763a00e4 100644 --- a/compiler/semdata.nim +++ b/compiler/semdata.nim @@ -29,8 +29,8 @@ type POptionEntry* = ref TOptionEntry PProcCon* = ref TProcCon - TProcCon* = object # procedure context; also used for top-level - # statements + TProcCon* {.acyclic.} = object # procedure context; also used for top-level + # statements owner*: PSym # the symbol this context belongs to resultSym*: PSym # the result symbol (if we are in a proc) selfSym*: PSym # the 'self' symbol (if available) diff --git a/compiler/types.nim b/compiler/types.nim index cd67d1ad9..bc970a6d2 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -359,13 +359,13 @@ proc canFormAcycleAux(marker: var IntSet, typ: PType, startId: int): bool = if tfAcyclic in t.flags: return case t.kind of tyTuple, tyObject, tyRef, tySequence, tyArray, tyOpenArray, tyVarargs: - if not containsOrIncl(marker, t.id): + if t.id == startId: + result = true + elif not containsOrIncl(marker, t.id): for i in 0..<t.len: result = canFormAcycleAux(marker, t[i], startId) if result: return if t.n != nil: result = canFormAcycleNode(marker, t.n, startId) - else: - result = t.id == startId # Inheritance can introduce cyclic types, however this is not relevant # as the type that is passed to 'new' is statically known! # er but we use it also for the write barrier ... diff --git a/compiler/vm.nim b/compiler/vm.nim index e13fc5bb7..b540ac071 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -524,7 +524,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = # Used to keep track of where the execution is resumed. var savedPC = -1 var savedFrame: PStackFrame - when defined(gcArc): + when defined(gcArc) or defined(gcOrc): template updateRegsAlias = discard template regs: untyped = tos.slots else: diff --git a/compiler/vmdef.nim b/compiler/vmdef.nim index 5c1d30a52..2044b860a 100644 --- a/compiler/vmdef.nim +++ b/compiler/vmdef.nim @@ -270,7 +270,7 @@ type procToCodePos*: Table[int, int] PStackFrame* = ref TStackFrame - TStackFrame* = object + TStackFrame* {.acyclic.} = object prc*: PSym # current prc; proc that is evaluated slots*: seq[TFullReg] # parameters passed to the proc + locals; # parameters come first |