digitalmars.D - [SAOC 2026] CTFE Performance Weekly Update #4
- Abul Hossain Khan (49/49) Oct 19 Hi everyone,
Hi everyone, This week was mostly bug fixing. Dennis filed a bunch of CTFE bugs his wasm experiment found and suggested I fix some of them to get a better understanding of the interpreter before writing the interface. So that's what I did. - `s[1]` on a one-element slice read the parent array instead of erroring. An off-by-one in the bounds check, and two asserts in `interpret3.d` relied on it - https://github.com/dlang/dmd/pull/24040 - `s ~= cast(dchar) 0x110000` crashed the compiler. Now an error, surrogates included - https://github.com/dlang/dmd/pull/24046 - `foreach_reverse` over a string skipped a stray byte at the end instead of erroring. The error now prints the byte that failed to decode - https://github.com/dlang/dmd/pull/24054 - `c && true` with a class reference gave `null` - https://github.com/dlang/dmd/pull/24062 - `int /= uint` was folded in `int`, so `-5 /= 7u` gave a different result than at run time. The cast semantic inserts on the left side was thrown away - https://github.com/dlang/dmd/pull/24069 - That one exposed a frontend bug: `x >>= y` took the type of the shift count, unlike `x = x >> y`, so `int >>= uint` was a logical shift with `-O`. Filed and fixed - https://github.com/dlang/dmd/pull/24076 What I got out of it, in terms of the project: the interpreter re-implements run time piece by piece. Appending a dchar goes through the compiler's own UTF encoder, `foreach` over a string is a hand-written decode loop standing in for `_aApplyRcd1`, op-assign has its own typing. Every one of these is a place where CTFE and run time can drift, and every one is something a new engine has to provide again or route through druntime. That list goes into the design doc. Also the perf bot's new CTFE workload did its job on the first of these PRs: one extra compare on the path every CTFE assignment takes showed up as +0.13% instructions on the ctRegex tests, invisible on the other workloads. - The three valid programs that the semantic-upfront experiment broke had no coverage in the test suite, so they will be upstream soon - https://github.com/dlang/dmd/pull/24077 - The code examples per expression kind going in and out of `ctfeInterpret` that are here - https://gist.github.com/abulgit/256ad4b52c2795806a1b369e5ef40004 - The design doc for the interface. - The rest of the bug list. Thanks to Dennis for mentoring this. As always, feel free to leave any feedback or suggestions!
Oct 19








Abul Hossain Khan <abulkhan19175 gmail.com>