Skip to content

Add __traits(vtblSymbol), __traits(interfaceSymbol) - #23990

Closed
TurkeyMan wants to merge 1 commit into
masterfrom
symbol_slice_struct
Closed

TurkeyMan wants to merge 1 commit into
masterfrom
symbol_slice_struct

Conversation

@TurkeyMan

Copy link
Copy Markdown
Contributor

This is an alternative take on #23940, it creates an artificial slice SymbolSlice!T instead of a real proper one, that way the compiler doesn't need any extra tricks.
The disadvantage is that expressions like typeof(__traits(vtblSymbol, C)) and friends will not report (void*)[], but instead SymbolSlice!(void*), which means they may not interact completely naturally with some set of meta, but these are super-niche things, and really just to facilitate lib-defined ClassInfo; so I think we can live with that imperfection.
__traits(vtblSymbol, C)[] would cause it to present as a natural slice and work through any meta correctly.

__traits(vtblSymbol, C) is the vtbl of class C, and __traits(interfaceSymbol, C)
is the Interface[] array of class or interface C, which follows its ClassInfo.

Their results, and __traits(initSymbol), are now SymbolSlice!T:
a length and the address of the symbol. The special cases for the old slice-typed
__traits(initSymbol) in CTFE and the glue layer are removed.
@TurkeyMan
TurkeyMan requested a review from ibuclaw as a code owner October 7, 2026 12:30
@thewilsonator

thewilsonator commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

try closing this and reopening this PR from your own fork. That should kill off those failing bootstrap CI runs.

@TurkeyMan TurkeyMan closed this Oct 7, 2026
@TurkeyMan
TurkeyMan deleted the symbol_slice_struct branch October 7, 2026 12:40
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

DMD perf check

Metric Base PR Δ
compile hello.d (instr) 210.3 M 210.6 M +0.146%
compile hello.d -O -release (instr) 227.9 M 228.2 M +0.158%
compile Phobos (instr) 4,891.2 M 4,899.1 M +0.160%
compile Phobos codegen (instr) 1,426.1 M 1,429.7 M +0.253%
compile vibe.d (instr) 14,258.0 M 14,278.6 M +0.144%
Breakdown — compile hello.d
Phase (wall, self time) Base PR Δ
sema1 8.4 ms 9.5 ms +13.36%
sema_other 12.5 ms 13.5 ms +7.24%
parse 24.0 ms 24.6 ms +2.54%
sema3 4.4 ms 4.2 ms -5.41%
codegen 1.6 ms 1.8 ms +9.84%
Breakdown — compile Phobos

+7.8 M instructions: frontend +4.2 M (+0.12%), codegen +3.6 M (+0.25%)

Phase (wall, self time) Base PR Δ
codegen 340 ms 325 ms -4.54%
sema3 412 ms 415 ms +0.76%
sema1 164 ms 161 ms -1.40%
parse 82.1 ms 84.1 ms +2.50%
sema_other 176 ms 178 ms +1.05%
ctfe 9.9 ms 9.4 ms -4.48%
inline 4.2 ms 4.1 ms -3.89%
sema2 0.8 ms 0.9 ms +6.40%
All measurements
Metric Base PR Δ
compile hello.d (instr) 210.3 M 210.6 M +0.146%
compile hello.d -O -release (instr) 227.9 M 228.2 M +0.158%
compile Phobos (instr) 4,891.2 M 4,899.1 M +0.160%
compile Phobos codegen (instr) 1,426.1 M 1,429.7 M +0.253%
compile vibe.d (instr) 14,258.0 M 14,278.6 M +0.144%
dmd binary size (stripped) 8.15 MB 8.15 MB -0.09%
hello binary size (stripped) 0.72 MB 0.72 MB 0.00%
peak RSS (compile hello.d) 44.10 MB 44.18 MB +0.18%
peak RSS (compile Phobos) 605.1 MB 605.4 MB +0.04%
peak RSS (compile vibe.d) 1858 MB 1857 MB -0.04%
page faults (compile hello.d) 8,897 8,910 +0.15%
page faults (compile Phobos) 151,179 150,732 -0.30%
page faults (compile vibe.d) 464,216 466,100 +0.41%
compile dmd itself (wall) 10.0 s 10.1 s +1.27%
compile hello.d (wall) 51.0 ms 53.6 ms +5.03%
compile Phobos (wall) 1,189 ms 1,177 ms -0.95%

0aab637 vs merge-base 92ac966 · about these metrics

dkorpel added a commit to dkorpel/dmd that referenced this pull request Oct 7, 2026
Minimal, sound variant of dlang#23990: __SymbolSlice fields are immutable and only
@System code can construct one, the class must have completed semantic,
interfaceSymbol requires a generated ClassInfo, and symbol declarations are
cached on the aggregate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dkorpel added a commit to dkorpel/dmd that referenced this pull request Oct 7, 2026
Minimal, sound variant of dlang#23990: __SymbolSlice fields are immutable and only
@System code can construct one, the class must have completed semantic,
interfaceSymbol requires a generated ClassInfo, and symbol declarations are
cached on the aggregate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants