DEV Community

COMMENTERTHE9
COMMENTERTHE9

Posted on • Originally published at cx-lang.com

Cx Dev Log — 2026-06-10

Four type-checking and optimization-focused commits hit Cx's submain, unexpectedly shifting focus towards the D1 audit arc. Instead of prioritizing previous CR range-check fixes or backend development, we took a hard left into soundness and structural improvements. The changes added 11 more matrix fixtures, bumping submain from 261 to 272 without a hitch.

Taming the JIT with Unseen Crash Classes

Kickstarting the D1 audit, five new verification fixtures (D1.0) were added to explore JIT crash behaviors, previously untested in the 261-fixture net. Here's a breakdown:

  • Division/Modulo by Zero: The usual exit 1 error in the interpreter caused hardware traps like SIGILL on JIT. These traps are locked down with .jit_known_unsound sidecars.
  • Edge Case in Overflow: t8 -128 / -1 (an interpreter wrap to -128) triggers overflow in JIT. t8 -128 % -1, though, skips the overflow, unexpectedly reaching arithmetic agreement.

Five fixtures later, these cases are now pinned down so any regressions can't sneak past unnoticed. Parity stayed healthy at 165 PASS / 101 SKIP / 0 FAIL, post D1.0.

Nailing a Performance Baseline

Can't improve what you can't measure, right? Before any heady changes, we nailed down a wall-time performance benchmark. Think arithmetic loops, recursive fibonacci, conditionals, and more. Eight programs ran through a PowerShell script doing 1 warmup and 7 real runs, taking medians and spreads.

Key insight: While raw instruction flow suggested even faster speeds, JIT was only 9-13x quicker when counting start-up and compile times, as short runs saw startup costs dominate. A procedural eye-opener arrived too: benchmarks spiked due to thermal throttling; hence, the baseline must now rest on within-session A/B comparisons.

The benchmarking exercise flagged a legitimate fault, directing our efforts to the subsequent commit.

Tweaking Array Index Element Types

The unexpected rises again: array indexing stumbled during benchmarking when acc + a:[k] on t8 arrays output incorrect values. Here’s the screw-up:

  • Expr::Index defaulted to SemanticType::Unknown regardless of actual array base types, tossing proper wrapping on integer arithmetic at sub-64-bit sizes.

The fix unfolded in semantic.rs, rewriting five lines to discern element type from Array(_, elem). Six new tests now define t8/t16 wrapping, typed binding narrowing, and return-value wrapping. This tweak let bench_array_loop drop previously necessary workarounds, aligning with expected natural form execution.

Final matrix post-fix: 272 fixtures, all stable across both backends.

Integrating Integer-Width Facts

The penultimate effort was extracting integer-width consistency from three hard-to-sync places: semantic.rs, runtime.rs, and lower.rs. Each worked off its own inline constants to determine value bounds, which was less than ideal.

Enter frontend/int_facts.rs, our new comprehensive data store. It introduces IntWidth (W8 through W128), IntFacts (inclusive of truncation mechanics), and a truncate(i128) method, ensuring a singular, central source that all modules are now tapping.

Design boons?

  • It stands alone — a data-only module untouched by other dependencies.
  • No unnecessary clutter, such as Bool inclusion, keeping it purely numeric.
  • Streamlined by skipped over a bits field given its lack of current utility.

Measured efficiency: 129 insertions and 26 deletions across seven files, no change in operational behavior, proving the integration seamlessly.

What's Next

The D1 arc’s evolution will naturally target memory safety for JIT, following today’s .jit_known_unsound reveals. Further unifying measures, akin to int_facts, likely loom ahead.

Currently, submain strides eight commits ahead of main, tracing the path for a coherent merge that boosts matrix integrity from 230 to 272. Yet, the daily-log PR backlog and backend development have seen deferral — though inevitable, they remain on the horizon as the D1 audit arc continues to unfold.


Follow the Cx language project:

Originally published at https://cx-lang.com/blog/2026-06-10

Top comments (0)