time to make IC work with ORC (here we go again...) (#20538)
works for me
This commit is contained in:
parent
666a0e34cd
commit
7587371554
3 changed files with 40 additions and 11 deletions
|
|
@ -46,7 +46,7 @@ type
|
||||||
|
|
||||||
typeInstCache*: seq[(PackedItemId, PackedItemId)]
|
typeInstCache*: seq[(PackedItemId, PackedItemId)]
|
||||||
procInstCache*: seq[PackedInstantiation]
|
procInstCache*: seq[PackedInstantiation]
|
||||||
attachedOps*: seq[(TTypeAttachedOp, PackedItemId, PackedItemId)]
|
attachedOps*: seq[(PackedItemId, TTypeAttachedOp, PackedItemId)]
|
||||||
methodsPerType*: seq[(PackedItemId, int, PackedItemId)]
|
methodsPerType*: seq[(PackedItemId, int, PackedItemId)]
|
||||||
enumToStringProcs*: seq[(PackedItemId, PackedItemId)]
|
enumToStringProcs*: seq[(PackedItemId, PackedItemId)]
|
||||||
|
|
||||||
|
|
@ -528,6 +528,15 @@ proc toPackedGeneratedProcDef*(s: PSym, encoder: var PackedEncoder; m: var Packe
|
||||||
toPackedProcDef(s.ast, m.topLevel, encoder, m)
|
toPackedProcDef(s.ast, m.topLevel, encoder, m)
|
||||||
#flush encoder, m
|
#flush encoder, m
|
||||||
|
|
||||||
|
proc storeAttachedProcDef*(t: PType; op: TTypeAttachedOp; s: PSym,
|
||||||
|
encoder: var PackedEncoder; m: var PackedModule) =
|
||||||
|
assert s.kind in routineKinds
|
||||||
|
assert isActive(encoder)
|
||||||
|
let tid = storeTypeLater(t, encoder, m)
|
||||||
|
let sid = storeSymLater(s, encoder, m)
|
||||||
|
m.attachedOps.add (tid, op, sid)
|
||||||
|
toPackedGeneratedProcDef(s, encoder, m)
|
||||||
|
|
||||||
proc storeInstantiation*(c: var PackedEncoder; m: var PackedModule; s: PSym; i: PInstantiation) =
|
proc storeInstantiation*(c: var PackedEncoder; m: var PackedModule; s: PSym; i: PInstantiation) =
|
||||||
var t = newSeq[PackedItemId](i.concreteTypes.len)
|
var t = newSeq[PackedItemId](i.concreteTypes.len)
|
||||||
for j in 0..high(i.concreteTypes):
|
for j in 0..high(i.concreteTypes):
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,20 @@ proc replayStateChanges*(module: PSym; g: ModuleGraph) =
|
||||||
else:
|
else:
|
||||||
internalAssert g.config, false
|
internalAssert g.config, false
|
||||||
|
|
||||||
|
proc replayBackendProcs*(g: ModuleGraph; module: int) =
|
||||||
|
for it in mitems(g.packed[module].fromDisk.attachedOps):
|
||||||
|
let key = translateId(it[0], g.packed, module, g.config)
|
||||||
|
let op = it[1]
|
||||||
|
let tmp = translateId(it[2], g.packed, module, g.config)
|
||||||
|
let symId = FullId(module: tmp.module, packed: it[2])
|
||||||
|
g.attachedOps[op][key] = LazySym(id: symId, sym: nil)
|
||||||
|
|
||||||
|
for it in mitems(g.packed[module].fromDisk.enumToStringProcs):
|
||||||
|
let key = translateId(it[0], g.packed, module, g.config)
|
||||||
|
let tmp = translateId(it[1], g.packed, module, g.config)
|
||||||
|
let symId = FullId(module: tmp.module, packed: it[1])
|
||||||
|
g.enumToStringProcs[key] = LazySym(id: symId, sym: nil)
|
||||||
|
|
||||||
proc replayGenericCacheInformation*(g: ModuleGraph; module: int) =
|
proc replayGenericCacheInformation*(g: ModuleGraph; module: int) =
|
||||||
## We remember the generic instantiations a module performed
|
## We remember the generic instantiations a module performed
|
||||||
## in order to to avoid the code bloat that generic code tends
|
## in order to to avoid the code bloat that generic code tends
|
||||||
|
|
@ -120,11 +134,7 @@ proc replayGenericCacheInformation*(g: ModuleGraph; module: int) =
|
||||||
let symId = FullId(module: tmp.module, packed: it[2])
|
let symId = FullId(module: tmp.module, packed: it[2])
|
||||||
g.methodsPerType.mgetOrPut(key, @[]).add (col, LazySym(id: symId, sym: nil))
|
g.methodsPerType.mgetOrPut(key, @[]).add (col, LazySym(id: symId, sym: nil))
|
||||||
|
|
||||||
for it in mitems(g.packed[module].fromDisk.enumToStringProcs):
|
replayBackendProcs(g, module)
|
||||||
let key = translateId(it[0], g.packed, module, g.config)
|
|
||||||
let tmp = translateId(it[1], g.packed, module, g.config)
|
|
||||||
let symId = FullId(module: tmp.module, packed: it[1])
|
|
||||||
g.enumToStringProcs[key] = LazySym(id: symId, sym: nil)
|
|
||||||
|
|
||||||
for it in mitems(g.packed[module].fromDisk.methods):
|
for it in mitems(g.packed[module].fromDisk.methods):
|
||||||
let sym = loadSymFromId(g.config, g.cache, g.packed, module,
|
let sym = loadSymFromId(g.config, g.cache, g.packed, module,
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ type
|
||||||
|
|
||||||
typeInstCache*: Table[ItemId, seq[LazyType]] # A symbol's ItemId.
|
typeInstCache*: Table[ItemId, seq[LazyType]] # A symbol's ItemId.
|
||||||
procInstCache*: Table[ItemId, seq[LazyInstantiation]] # A symbol's ItemId.
|
procInstCache*: Table[ItemId, seq[LazyInstantiation]] # A symbol's ItemId.
|
||||||
attachedOps*: array[TTypeAttachedOp, Table[ItemId, PSym]] # Type ID, destructors, etc.
|
attachedOps*: array[TTypeAttachedOp, Table[ItemId, LazySym]] # Type ID, destructors, etc.
|
||||||
methodsPerType*: Table[ItemId, seq[(int, LazySym)]] # Type ID, attached methods
|
methodsPerType*: Table[ItemId, seq[(int, LazySym)]] # Type ID, attached methods
|
||||||
enumToStringProcs*: Table[ItemId, LazySym]
|
enumToStringProcs*: Table[ItemId, LazySym]
|
||||||
emittedTypeInfo*: Table[string, FileIndex]
|
emittedTypeInfo*: Table[string, FileIndex]
|
||||||
|
|
@ -285,6 +285,13 @@ proc resolveInst(g: ModuleGraph; t: var LazyInstantiation): PInstantiation =
|
||||||
t.inst = result
|
t.inst = result
|
||||||
assert result != nil
|
assert result != nil
|
||||||
|
|
||||||
|
proc resolveAttachedOp(g: ModuleGraph; t: var LazySym): PSym =
|
||||||
|
result = t.sym
|
||||||
|
if result == nil:
|
||||||
|
result = loadSymFromId(g.config, g.cache, g.packed, t.id.module, t.id.packed)
|
||||||
|
t.sym = result
|
||||||
|
assert result != nil
|
||||||
|
|
||||||
iterator typeInstCacheItems*(g: ModuleGraph; s: PSym): PType =
|
iterator typeInstCacheItems*(g: ModuleGraph; s: PSym): PType =
|
||||||
if g.typeInstCache.contains(s.itemId):
|
if g.typeInstCache.contains(s.itemId):
|
||||||
let x = addr(g.typeInstCache[s.itemId])
|
let x = addr(g.typeInstCache[s.itemId])
|
||||||
|
|
@ -300,22 +307,25 @@ iterator procInstCacheItems*(g: ModuleGraph; s: PSym): PInstantiation =
|
||||||
proc getAttachedOp*(g: ModuleGraph; t: PType; op: TTypeAttachedOp): PSym =
|
proc getAttachedOp*(g: ModuleGraph; t: PType; op: TTypeAttachedOp): PSym =
|
||||||
## returns the requested attached operation for type `t`. Can return nil
|
## returns the requested attached operation for type `t`. Can return nil
|
||||||
## if no such operation exists.
|
## if no such operation exists.
|
||||||
result = g.attachedOps[op].getOrDefault(t.itemId)
|
if g.attachedOps[op].contains(t.itemId):
|
||||||
|
result = resolveAttachedOp(g, g.attachedOps[op][t.itemId])
|
||||||
|
else:
|
||||||
|
result = nil
|
||||||
|
|
||||||
proc setAttachedOp*(g: ModuleGraph; module: int; t: PType; op: TTypeAttachedOp; value: PSym) =
|
proc setAttachedOp*(g: ModuleGraph; module: int; t: PType; op: TTypeAttachedOp; value: PSym) =
|
||||||
## we also need to record this to the packed module.
|
## we also need to record this to the packed module.
|
||||||
g.attachedOps[op][t.itemId] = value
|
g.attachedOps[op][t.itemId] = LazySym(sym: value)
|
||||||
|
|
||||||
proc setAttachedOpPartial*(g: ModuleGraph; module: int; t: PType; op: TTypeAttachedOp; value: PSym) =
|
proc setAttachedOpPartial*(g: ModuleGraph; module: int; t: PType; op: TTypeAttachedOp; value: PSym) =
|
||||||
## we also need to record this to the packed module.
|
## we also need to record this to the packed module.
|
||||||
g.attachedOps[op][t.itemId] = value
|
g.attachedOps[op][t.itemId] = LazySym(sym: value)
|
||||||
# XXX Also add to the packed module!
|
|
||||||
|
|
||||||
proc completePartialOp*(g: ModuleGraph; module: int; t: PType; op: TTypeAttachedOp; value: PSym) =
|
proc completePartialOp*(g: ModuleGraph; module: int; t: PType; op: TTypeAttachedOp; value: PSym) =
|
||||||
if g.config.symbolFiles != disabledSf:
|
if g.config.symbolFiles != disabledSf:
|
||||||
assert module < g.encoders.len
|
assert module < g.encoders.len
|
||||||
assert isActive(g.encoders[module])
|
assert isActive(g.encoders[module])
|
||||||
toPackedGeneratedProcDef(value, g.encoders[module], g.packed[module].fromDisk)
|
toPackedGeneratedProcDef(value, g.encoders[module], g.packed[module].fromDisk)
|
||||||
|
#storeAttachedProcDef(t, op, value, g.encoders[module], g.packed[module].fromDisk)
|
||||||
|
|
||||||
proc getToStringProc*(g: ModuleGraph; t: PType): PSym =
|
proc getToStringProc*(g: ModuleGraph; t: PType): PSym =
|
||||||
result = resolveSym(g, g.enumToStringProcs[t.itemId])
|
result = resolveSym(g, g.enumToStringProcs[t.itemId])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue