summary refs log tree commit diff stats
path: root/lib/system/arc.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 /lib/system/arc.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 'lib/system/arc.nim')
-rw-r--r--lib/system/arc.nim5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/system/arc.nim b/lib/system/arc.nim
index b49a6a63b..88d21643a 100644
--- a/lib/system/arc.nim
+++ b/lib/system/arc.nim
@@ -243,3 +243,8 @@ template tearDownForeignThreadGc* =
 
 proc isObjDisplayCheck(source: PNimTypeV2, targetDepth: int16, token: uint32): bool {.compilerRtl, inl.} =
   result = targetDepth <= source.depth and source.display[targetDepth] == token
+
+when defined(nimPreviewVtables) and not defined(cpp):
+  proc nimGetVTable(p: pointer, index: int): pointer
+        {.compilerRtl, inline, raises: [].} =
+    result = cast[ptr PNimTypeV2](p).vTable[index]
v>
e25474154 ^








f46870fe1 ^

e25474154 ^

ceb1f5e21 ^

e25474154 ^





f530bbd63 ^

e25474154 ^



3b7ef2288 ^
e25474154 ^





































a58a2f382 ^
e25474154 ^




























134f24f57 ^
e25474154 ^




a58a2f382 ^
e25474154 ^

a58a2f382 ^
e25474154 ^


a58a2f382 ^
e25474154 ^

f46870fe1 ^
a58a2f382 ^

e25474154 ^




















e25474154 ^


a58a2f382 ^
e25474154 ^
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199