Skip to content

[WIP] Add __traits(vtblSymbol) and __traits(interfaceSymbol), as __SymbolSlice - #23993

Draft
dkorpel wants to merge 2 commits into
dlang:masterfrom
dkorpel:symbol-slice-minimal
Draft

dkorpel wants to merge 2 commits into
dlang:masterfrom
dkorpel:symbol-slice-minimal

Conversation

@dkorpel

@dkorpel dkorpel commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Illustration for #23991

dkorpel and others added 2 commits October 7, 2026 19:13
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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dkorpel dkorpel added the AI Generated Code that is generated by an LLM AI. label Oct 7, 2026
Comment thread druntime/src/object.d
*/
struct __SymbolSlice(T)
{
@system size_t _length;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be immutable too? and if we're here, why not just make the instance immutable?

@TurkeyMan

Copy link
Copy Markdown
Contributor

Oh, I have another one with a bunch of edits going too... should I abandon mine?
I'm not certain this is better...

@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.7 M +0.215%
compile hello.d -O -release (instr) 227.9 M 228.6 M +0.323%
dmd binary size (stripped) 8.15 MB 8.14 MB -0.14%
Breakdown — compile hello.d
Phase (wall, self time) Base PR Δ
sema_other 13.9 ms 14.1 ms +1.85%
parse 34.3 ms 34.0 ms -0.66%
sema1 10.5 ms 10.6 ms +1.66%
sema3 5.5 ms 5.6 ms +1.97%
codegen 2.0 ms 2.1 ms +3.79%
All measurements
Metric Base PR Δ
compile hello.d (instr) 210.3 M 210.7 M +0.215%
compile hello.d -O -release (instr) 227.9 M 228.6 M +0.323%
compile Phobos (instr) 4,891.1 M 4,894.7 M +0.075%
compile Phobos codegen (instr) 1,426.1 M 1,426.8 M +0.050%
compile vibe.d (instr) 14,257.4 M 14,269.3 M +0.083%
dmd binary size (stripped) 8.15 MB 8.14 MB -0.14%
hello binary size (stripped) 0.72 MB 0.72 MB 0.00%
peak RSS (compile hello.d) 43.89 MB 44.11 MB +0.51%
peak RSS (compile Phobos) 605.0 MB 603.7 MB -0.22%
peak RSS (compile vibe.d) 1858 MB 1859 MB +0.09%
page faults (compile hello.d) 8,894 8,915 +0.24%
page faults (compile Phobos) 151,174 150,834 -0.22%
page faults (compile vibe.d) 465,192 464,532 -0.14%
compile dmd itself (wall) 12.1 s 12.2 s +0.73%
compile hello.d (wall) 66.1 ms 66.5 ms +0.59%
compile Phobos (wall) 1,473 ms 1,471 ms -0.14%

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

@dkorpel

dkorpel commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Oh, I have another one with a bunch of edits going too... should I abandon mine? I'm not certain this is better...

I don't know if it's better either, I just wanted to test if the new determineVtbl code addition is redundant and I didn't want to push directly to your branch. Feel free to incorporate changes and I'll close this.

@TurkeyMan

TurkeyMan commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

I think determineVtbl was redundant; my Claude decided the reasons he did it was to facilitate some additional use cases, which yours here rejects as a forward reference.

Like, I think your one here will fail if you do some variation of:

class C
{
  enum x = __traits(xxSymbol, C).length;
}

There was a series of cases like this which determineVtbl solved, but I'm not sure they add value, and a forward-reference error is probably fine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Code that is generated by an LLM AI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants