ORC: improvements (#17993)
* ORC: improvements * ORC: fix .acyclic annotation for ref objects
This commit is contained in:
parent
1e080eb9b4
commit
39ad9a69a9
6 changed files with 18 additions and 12 deletions
|
|
@ -742,7 +742,7 @@ proc hash*(x: ItemId): Hash =
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TIdObj* = object of RootObj
|
TIdObj* {.acyclic.} = object of RootObj
|
||||||
itemId*: ItemId
|
itemId*: ItemId
|
||||||
PIdObj* = ref TIdObj
|
PIdObj* = ref TIdObj
|
||||||
|
|
||||||
|
|
@ -841,7 +841,7 @@ type
|
||||||
|
|
||||||
PInstantiation* = ref TInstantiation
|
PInstantiation* = ref TInstantiation
|
||||||
|
|
||||||
TScope* = object
|
TScope* {.acyclic.} = object
|
||||||
depthLevel*: int
|
depthLevel*: int
|
||||||
symbols*: TStrTable
|
symbols*: TStrTable
|
||||||
parent*: PScope
|
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)
|
result = newTree(nkCall, newSymNode(op, x.info), x, lenCall)
|
||||||
|
|
||||||
proc forallElements(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
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 i = declareCounter(c, body, toInt64(firstOrd(c.g.config, t)))
|
||||||
let whileLoop = genWhileLoop(c, i, x)
|
let whileLoop = genWhileLoop(c, i, x)
|
||||||
let elemType = t.lastSon
|
let elemType = t.lastSon
|
||||||
let b = if c.kind == attachedTrace: y else: y.at(i, elemType)
|
let b = if c.kind == attachedTrace: y else: y.at(i, elemType)
|
||||||
fillBody(c, elemType, whileLoop[1], x.at(i, elemType), b)
|
fillBody(c, elemType, whileLoop[1], x.at(i, elemType), b)
|
||||||
addIncStmt(c, whileLoop[1], i)
|
if whileLoop[1].len > 0:
|
||||||
body.add whileLoop
|
addIncStmt(c, whileLoop[1], i)
|
||||||
|
body.add whileLoop
|
||||||
|
else:
|
||||||
|
body.sons.setLen counterIdx
|
||||||
|
|
||||||
proc fillSeqOp(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
proc fillSeqOp(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||||
case c.kind
|
case c.kind
|
||||||
|
|
@ -660,6 +664,7 @@ proc atomicRefOp(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||||
else:
|
else:
|
||||||
# If the ref is polymorphic we have to account for this
|
# If the ref is polymorphic we have to account for this
|
||||||
body.add callCodegenProc(c.g, "nimTraceRefDyn", c.info, genAddrOf(x, c.idgen), y)
|
body.add callCodegenProc(c.g, "nimTraceRefDyn", c.info, genAddrOf(x, c.idgen), y)
|
||||||
|
#echo "can follow ", elemType, " static ", isFinal(elemType)
|
||||||
of attachedDispose:
|
of attachedDispose:
|
||||||
# this is crucial! dispose is like =destroy but we don't follow refs
|
# this is crucial! dispose is like =destroy but we don't follow refs
|
||||||
# as that is dealt within the cycle collector.
|
# as that is dealt within the cycle collector.
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ type
|
||||||
concreteTypes*: seq[FullId]
|
concreteTypes*: seq[FullId]
|
||||||
inst*: PInstantiation
|
inst*: PInstantiation
|
||||||
|
|
||||||
ModuleGraph* = ref object
|
ModuleGraph* {.acyclic.} = ref object
|
||||||
ifaces*: seq[Iface] ## indexed by int32 fileIdx
|
ifaces*: seq[Iface] ## indexed by int32 fileIdx
|
||||||
packed*: PackedModuleGraph
|
packed*: PackedModuleGraph
|
||||||
encoders*: seq[PackedEncoder]
|
encoders*: seq[PackedEncoder]
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,7 @@ type
|
||||||
foName # lastPathPart, e.g.: foo.nim
|
foName # lastPathPart, e.g.: foo.nim
|
||||||
foStacktrace # if optExcessiveStackTrace: foAbs else: foName
|
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
|
## fields marked with '*' are subject to
|
||||||
## the incremental compilation mechanisms
|
## the incremental compilation mechanisms
|
||||||
## (+) means "part of the dependency"
|
## (+) 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)
|
addInheritedFields(c, check, pos, obj[0].skipGenericInvocation)
|
||||||
addInheritedFieldsAux(c, check, pos, obj.n)
|
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:
|
if n.len == 0:
|
||||||
return newConstraint(c, tyObject)
|
return newConstraint(c, tyObject)
|
||||||
var check = initIntSet()
|
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")
|
if n.kind != nkObjectTy: internalError(c.config, n.info, "semObjectNode")
|
||||||
result = newOrPrevType(tyObject, prev, c)
|
result = newOrPrevType(tyObject, prev, c)
|
||||||
rawAddSon(result, realBase)
|
rawAddSon(result, realBase)
|
||||||
if realBase == nil and isInheritable:
|
if realBase == nil and tfInheritable in flags:
|
||||||
result.flags.incl tfInheritable
|
result.flags.incl tfInheritable
|
||||||
|
if tfAcyclic in flags: result.flags.incl tfAcyclic
|
||||||
if result.n.isNil:
|
if result.n.isNil:
|
||||||
result.n = newNodeI(nkRecList, n.info)
|
result.n = newNodeI(nkRecList, n.info)
|
||||||
else:
|
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
|
let n = if n[0].kind == nkBracket: n[0] else: n
|
||||||
checkMinSonsLen(n, 1, c.config)
|
checkMinSonsLen(n, 1, c.config)
|
||||||
let body = n.lastSon
|
let body = n.lastSon
|
||||||
var t = if prev != nil and body.kind == nkObjectTy and tfInheritable in prev.flags:
|
var t = if prev != nil and body.kind == nkObjectTy:
|
||||||
semObjectNode(c, body, nil, isInheritable=true)
|
semObjectNode(c, body, nil, prev.flags)
|
||||||
else:
|
else:
|
||||||
semTypeNode(c, body, nil)
|
semTypeNode(c, body, nil)
|
||||||
if t.kind == tyTypeDesc and tfUnresolved notin t.flags:
|
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'" %
|
localError(c.config, n.info, "type expected, but got symbol '$1' of kind '$2'" %
|
||||||
[s.name.s, s.kind.toHumanStr])
|
[s.name.s, s.kind.toHumanStr])
|
||||||
result = newOrPrevType(tyError, prev, c)
|
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 nkTupleTy: result = semTuple(c, n, prev)
|
||||||
of nkTupleClassTy: result = newConstraint(c, tyTuple)
|
of nkTupleClassTy: result = newConstraint(c, tyTuple)
|
||||||
of nkTypeClassTy: result = semTypeClass(c, n, prev)
|
of nkTypeClassTy: result = semTypeClass(c, n, prev)
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ proc cacheTypeInst(c: PContext; inst: PType) =
|
||||||
addToGenericCache(c, gt.sym, inst)
|
addToGenericCache(c, gt.sym, inst)
|
||||||
|
|
||||||
type
|
type
|
||||||
LayeredIdTable* = ref object
|
LayeredIdTable* {.acyclic.} = ref object
|
||||||
topLayer*: TIdTable
|
topLayer*: TIdTable
|
||||||
nextLayer*: LayeredIdTable
|
nextLayer*: LayeredIdTable
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue