mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-04 19:04:46 +00:00
ORC: improvements (#17993)
* ORC: improvements * ORC: fix .acyclic annotation for ref objects
This commit is contained in:
@@ -742,7 +742,7 @@ proc hash*(x: ItemId): Hash =
|
||||
|
||||
|
||||
type
|
||||
TIdObj* = object of RootObj
|
||||
TIdObj* {.acyclic.} = object of RootObj
|
||||
itemId*: ItemId
|
||||
PIdObj* = ref TIdObj
|
||||
|
||||
@@ -841,7 +841,7 @@ type
|
||||
|
||||
PInstantiation* = ref TInstantiation
|
||||
|
||||
TScope* = object
|
||||
TScope* {.acyclic.} = object
|
||||
depthLevel*: int
|
||||
symbols*: TStrTable
|
||||
parent*: PScope
|
||||
|
||||
@@ -480,13 +480,17 @@ proc setLenSeqCall(c: var TLiftCtx; t: PType; x, y: PNode): PNode =
|
||||
result = newTree(nkCall, newSymNode(op, x.info), x, lenCall)
|
||||
|
||||
proc forallElements(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||
let counterIdx = body.len
|
||||
let i = declareCounter(c, body, toInt64(firstOrd(c.g.config, t)))
|
||||
let whileLoop = genWhileLoop(c, i, x)
|
||||
let elemType = t.lastSon
|
||||
let b = if c.kind == attachedTrace: y else: y.at(i, elemType)
|
||||
fillBody(c, elemType, whileLoop[1], x.at(i, elemType), b)
|
||||
addIncStmt(c, whileLoop[1], i)
|
||||
body.add whileLoop
|
||||
if whileLoop[1].len > 0:
|
||||
addIncStmt(c, whileLoop[1], i)
|
||||
body.add whileLoop
|
||||
else:
|
||||
body.sons.setLen counterIdx
|
||||
|
||||
proc fillSeqOp(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||
case c.kind
|
||||
@@ -660,6 +664,7 @@ proc atomicRefOp(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||
else:
|
||||
# If the ref is polymorphic we have to account for this
|
||||
body.add callCodegenProc(c.g, "nimTraceRefDyn", c.info, genAddrOf(x, c.idgen), y)
|
||||
#echo "can follow ", elemType, " static ", isFinal(elemType)
|
||||
of attachedDispose:
|
||||
# this is crucial! dispose is like =destroy but we don't follow refs
|
||||
# as that is dealt within the cycle collector.
|
||||
|
||||
@@ -50,7 +50,7 @@ type
|
||||
concreteTypes*: seq[FullId]
|
||||
inst*: PInstantiation
|
||||
|
||||
ModuleGraph* = ref object
|
||||
ModuleGraph* {.acyclic.} = ref object
|
||||
ifaces*: seq[Iface] ## indexed by int32 fileIdx
|
||||
packed*: PackedModuleGraph
|
||||
encoders*: seq[PackedEncoder]
|
||||
|
||||
@@ -268,7 +268,7 @@ type
|
||||
foName # lastPathPart, e.g.: foo.nim
|
||||
foStacktrace # if optExcessiveStackTrace: foAbs else: foName
|
||||
|
||||
ConfigRef* = ref object ## every global configuration
|
||||
ConfigRef* {.acyclic.} = ref object ## every global configuration
|
||||
## fields marked with '*' are subject to
|
||||
## the incremental compilation mechanisms
|
||||
## (+) means "part of the dependency"
|
||||
|
||||
@@ -854,7 +854,7 @@ proc addInheritedFields(c: PContext, check: var IntSet, pos: var int,
|
||||
addInheritedFields(c, check, pos, obj[0].skipGenericInvocation)
|
||||
addInheritedFieldsAux(c, check, pos, obj.n)
|
||||
|
||||
proc semObjectNode(c: PContext, n: PNode, prev: PType; isInheritable: bool): PType =
|
||||
proc semObjectNode(c: PContext, n: PNode, prev: PType; flags: TTypeFlags): PType =
|
||||
if n.len == 0:
|
||||
return newConstraint(c, tyObject)
|
||||
var check = initIntSet()
|
||||
@@ -890,8 +890,9 @@ proc semObjectNode(c: PContext, n: PNode, prev: PType; isInheritable: bool): PTy
|
||||
if n.kind != nkObjectTy: internalError(c.config, n.info, "semObjectNode")
|
||||
result = newOrPrevType(tyObject, prev, c)
|
||||
rawAddSon(result, realBase)
|
||||
if realBase == nil and isInheritable:
|
||||
if realBase == nil and tfInheritable in flags:
|
||||
result.flags.incl tfInheritable
|
||||
if tfAcyclic in flags: result.flags.incl tfAcyclic
|
||||
if result.n.isNil:
|
||||
result.n = newNodeI(nkRecList, n.info)
|
||||
else:
|
||||
@@ -916,8 +917,8 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
|
||||
let n = if n[0].kind == nkBracket: n[0] else: n
|
||||
checkMinSonsLen(n, 1, c.config)
|
||||
let body = n.lastSon
|
||||
var t = if prev != nil and body.kind == nkObjectTy and tfInheritable in prev.flags:
|
||||
semObjectNode(c, body, nil, isInheritable=true)
|
||||
var t = if prev != nil and body.kind == nkObjectTy:
|
||||
semObjectNode(c, body, nil, prev.flags)
|
||||
else:
|
||||
semTypeNode(c, body, nil)
|
||||
if t.kind == tyTypeDesc and tfUnresolved notin t.flags:
|
||||
@@ -1957,7 +1958,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
||||
localError(c.config, n.info, "type expected, but got symbol '$1' of kind '$2'" %
|
||||
[s.name.s, s.kind.toHumanStr])
|
||||
result = newOrPrevType(tyError, prev, c)
|
||||
of nkObjectTy: result = semObjectNode(c, n, prev, isInheritable=false)
|
||||
of nkObjectTy: result = semObjectNode(c, n, prev, {})
|
||||
of nkTupleTy: result = semTuple(c, n, prev)
|
||||
of nkTupleClassTy: result = newConstraint(c, tyTuple)
|
||||
of nkTypeClassTy: result = semTypeClass(c, n, prev)
|
||||
|
||||
@@ -64,7 +64,7 @@ proc cacheTypeInst(c: PContext; inst: PType) =
|
||||
addToGenericCache(c, gt.sym, inst)
|
||||
|
||||
type
|
||||
LayeredIdTable* = ref object
|
||||
LayeredIdTable* {.acyclic.} = ref object
|
||||
topLayer*: TIdTable
|
||||
nextLayer*: LayeredIdTable
|
||||
|
||||
|
||||
Reference in New Issue
Block a user