Bug 24333 – Inline ClassInfo with the vtbl

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-01-11T22:59:39Z
Last change time
2024-12-13T19:32:33Z
Keywords
industry, performance
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=24336
Moved to GitHub: dmd#20381 →

Comments

Comment #0 by bugzilla — 2024-01-11T22:59:39Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20381 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB