Commit 0362b37
feat(specializer): cranelift backend — full IR coverage, 500-seed differential green, wired behind DuckDBInferFn (TASK-44 stretches 1-3)
One JIT'd function per program, called per row: extern "C"
fn(*mut Cx) -> i64 (0 emit / 1 skip / 2 helper trap / 3+k term trap).
Coverage-first: float arith, int compares, logic, select, itof, fabs,
and consts map inline to CLIF; everything nontrivial — checked int
arith, all string ops, loads/stores, statics, probes — calls extern
helpers that delegate to the interpreter's own semantic functions
(casemap, substr_window, duck_fcmp, DuckF64, the arena), so the
backends cannot drift where they share code. Strings travel as
(offset, length) i64 pairs; trap_flag at Cx offset 0 is checked after
every fallible helper call. CraneliftFn owns a compiled InterpFn for
input/state checks, prepared statics, and the always-available
fallback.
The 500-seed random-IR differential (fuzz_cranelift_agrees_with_
interpreter) demands byte-identical outputs and traps — it caught two
real bugs before landing: load.opt and sload.opt must NORMALIZE
payloads to type defaults under a false flag, exactly as the
interpreter documents.
DuckDBInferFn now compiles cranelift-first with interpreter fallback
(AC #2) and exposes .backend; the whole pytest suite — 32 duck_check
differentials and the 678-case corpus replay at 0 FAILs — now
exercises the JIT.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 6fd137b commit 0362b37
5 files changed
Lines changed: 1484 additions & 18 deletions
File tree
- src
- duckdb
- specializer/exec
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
169 | 171 | | |
170 | 172 | | |
171 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
172 | 203 | | |
173 | 204 | | |
174 | | - | |
| 205 | + | |
175 | 206 | | |
176 | 207 | | |
177 | 208 | | |
| |||
293 | 324 | | |
294 | 325 | | |
295 | 326 | | |
296 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
297 | 347 | | |
298 | 348 | | |
299 | 349 | | |
| |||
310 | 360 | | |
311 | 361 | | |
312 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
313 | 372 | | |
314 | 373 | | |
315 | 374 | | |
| |||
0 commit comments