summary refs log tree commit diff stats
path: root/compiler/ic/ic.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-11-28 22:11:43 +0800
committerGitHub <noreply@github.com>2023-11-28 15:11:43 +0100
commit30cf33f04dfb768182accb3ad35ec6364c998664 (patch)
tree63dc0d6a36bc662b94246392e03a26b7eaeb116d /compiler/ic/ic.nim
parent8cad6ac0487800f7d41e38303e52129777e6c22e (diff)
downloadNim-30cf33f04dfb768182accb3ad35ec6364c998664.tar.gz
rework the vtable implementation embedding the vtable array directly with new strictions on methods (#22991)
**TODO**
- [x] fixes changelog
With the new option `nimPreviewVtables`, `methods` are confined in the
same module where the type of the first parameter is defined

- [x] make it opt in after CI checks its feasibility

## In the following-up PRs

- [ ] in the following PRs, refactor code into a more efficient one

- [ ] cpp needs special treatments since it cannot embed array in light
of the preceding limits: ref
https://github.com/nim-lang/Nim/pull/20977#discussion_r1035528927; we
can support cpp backends with vtable implementations later on the
comprise that uses indirect vtable access

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'compiler/ic/ic.nim')
-rw-r--r--compiler/ic/ic.nim12
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/ic/ic.nim b/compiler/ic/ic.nim
index 867bc95ae..2f03ffb43 100644
--- a/compiler/ic/ic.nim
+++ b/compiler/ic/ic.nim
@@ -51,8 +51,10 @@ type
     typeInstCache*: seq[(PackedItemId, PackedItemId)]
     procInstCache*: seq[PackedInstantiation]
     attachedOps*: seq[(PackedItemId, TTypeAttachedOp, PackedItemId)]
-    methodsPerType*: seq[(PackedItemId, int, PackedItemId)]
+    methodsPerGenericType*: seq[(PackedItemId, int, PackedItemId)]
     enumToStringProcs*: seq[(PackedItemId, PackedItemId)]
+    methodsPerType*: seq[(PackedItemId, PackedItemId)]
+    dispatchers*: seq[PackedItemId]
 
     emittedTypeInfo*: seq[string]
     backendFlags*: set[ModuleBackendFlag]
@@ -650,8 +652,10 @@ proc loadRodFile*(filename: AbsoluteFile; m: var PackedModule; config: ConfigRef
     loadSeqSection typeInstCacheSection, m.typeInstCache
     loadSeqSection procInstCacheSection, m.procInstCache
     loadSeqSection attachedOpsSection, m.attachedOps
-    loadSeqSection methodsPerTypeSection, m.methodsPerType
+    loadSeqSection methodsPerGenericTypeSection, m.methodsPerGenericType
     loadSeqSection enumToStringProcsSection, m.enumToStringProcs
+    loadSeqSection methodsPerTypeSection, m.methodsPerType
+    loadSeqSection dispatchersSection, m.dispatchers
     loadSeqSection typeInfoSection, m.emittedTypeInfo
 
     f.loadSection backendFlagsSection
@@ -718,8 +722,10 @@ proc saveRodFile*(filename: AbsoluteFile; encoder: var PackedEncoder; m: var Pac
   storeSeqSection typeInstCacheSection, m.typeInstCache
   storeSeqSection procInstCacheSection, m.procInstCache
   storeSeqSection attachedOpsSection, m.attachedOps
-  storeSeqSection methodsPerTypeSection, m.methodsPerType
+  storeSeqSection methodsPerGenericTypeSection, m.methodsPerGenericType
   storeSeqSection enumToStringProcsSection, m.enumToStringProcs
+  storeSeqSection methodsPerTypeSection, m.methodsPerType
+  storeSeqSection dispatchersSection, m.dispatchers
   storeSeqSection typeInfoSection, m.emittedTypeInfo
 
   f.storeSection backendFlagsSection