summary refs log tree commit diff stats
path: root/compiler/ic
diff options
context:
space:
mode:
authorJuan M Gómez <info@jmgomez.me>2023-09-09 09:34:20 +0100
committerGitHub <noreply@github.com>2023-09-09 10:34:20 +0200
commite6ca13ec857dc065ebf3297129cc1538d4698f87 (patch)
tree1558f221071299fae8082ba23d069719c0c9aead /compiler/ic
parent5f13e15e0a6f90c462a71cd30addc677f688c4dc (diff)
downloadNim-e6ca13ec857dc065ebf3297129cc1538d4698f87.tar.gz
Instantiates generics in the module that uses it (#22513)
Attempts to move the generic instantiation to the module that uses it.
This should decrease re-compilation times as the source module where the
generic lives doesnt need to be recompiled

---------

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'compiler/ic')
-rw-r--r--compiler/ic/ic.nim2
-rw-r--r--compiler/ic/packed_ast.nim1
2 files changed, 3 insertions, 0 deletions
diff --git a/compiler/ic/ic.nim b/compiler/ic/ic.nim
index 845e3d1fa..8b0a31054 100644
--- a/compiler/ic/ic.nim
+++ b/compiler/ic/ic.nim
@@ -413,6 +413,7 @@ proc storeSym*(s: PSym; c: var PackedEncoder; m: var PackedModule): PackedItemId
     p.annex = toPackedLib(s.annex, c, m)
     when hasFFI:
       p.cname = toLitId(s.cname, m)
+    p.instantiatedFrom = s.instantiatedFrom.safeItemId(c, m)
 
     # fill the reserved slot, nothing else:
     m.syms[s.itemId.item] = p
@@ -876,6 +877,7 @@ proc symBodyFromPacked(c: var PackedDecoder; g: var PackedModuleGraph;
   if externalName != "":
     result.loc.r = rope externalName
   result.loc.flags = s.locFlags
+  result.instantiatedFrom = loadSym(c, g, si, s.instantiatedFrom)
 
 proc loadSym(c: var PackedDecoder; g: var PackedModuleGraph; thisModule: int; s: PackedItemId): PSym =
   if s == nilItemId:
diff --git a/compiler/ic/packed_ast.nim b/compiler/ic/packed_ast.nim
index 8eafa5e96..b87348c5a 100644
--- a/compiler/ic/packed_ast.nim
+++ b/compiler/ic/packed_ast.nim
@@ -71,6 +71,7 @@ type
     when hasFFI:
       cname*: LitId
     constraint*: NodeId
+    instantiatedFrom*: PackedItemId
 
   PackedType* = object
     kind*: TTypeKind