deadalnix writes:
The current layout of objects is as follow:
+-----------+ +-----------+ +-----------+
| __vtbl +--->| typeid +--->| ClassInfo |
+-----------+ +-----------+ | |
| __monitor | | method0 | | ... |
+-----------+ +-----------+ | |
| field0 | | method1 | +-----------+
+-----------+ +-----------+
| field1 | | ... |
+-----------+ +-----------+
| ... |
+-----------+
This causes a ton of extra indirections that are not necessary. instead the following layout ought to be used:
+-----------+ +-----------+
| __vtbl +--->| ClassInfo |
+-----------+ | |
| __monitor | | ... |
+-----------+ | |
| field0 | +-----------+
+-----------+ | method0 |
| field1 | +-----------+
+-----------+ | method1 |
| ... | +-----------+
+-----------+ | ... |
+-----------+
Alternatively, it is possible to have the pointer point at the first method and subtract to get the typeid. The important part is that there is only one indirection now.
https://forum.dlang.org/post/[email protected]
Comment #1 by bugzilla — 2024-01-16T08:14:31Z
This is a challenging problem because the ClassInfo is of variable size. Embedding it with the vtbl[] would mean the variable parts would then have to be indirect.
Comment #2 by alphaglosined — 2024-01-16T08:57:37Z
Not necessarily.
You could reverse ClassInfo members, so that the fixed header goes after the variable length members.
It is the reverse of how you would normally want to work, where you increment the pointer, whereas this would decrement instead.
Comment #3 by robert.schadek — 2024-12-13T19:32:33Z