Codegen intercepts: fold stem-prefix carve-out into registry (raw-buf.1 follow-up) #36

Open
opened 2026-05-29 11:07:23 +02:00 by Brummel · 0 comments
Owner

raw-buf.1 (commit 140a0c0) consolidated the legacy
try_emit_primitive_instance_body arms into a registry table.
The companion predicate intercept_emit_wants_alwaysinline at
crates/ailang-codegen/src/lib.rs:1172 now consults the registry
for branch 1 (the 13-name literal list) — one source of truth.

Branch 2 of that predicate stays hardcoded: a stem-prefix carve-out
matching {ne|lt|le|gt|ge}__* that returns wants_alwaysinline = true
for polymorphic-body monomorphizations like lt__Bool, ne__Str,
ne__MyADT. These are NOT registry entries (they're generated by
the mono pass, not by a hand-written intercept) and never were.
Their alwaysinline attribute matters for the bench-perf parity
established in iter operator-routing-eq-ord.1.

Two ways to dissolve the carve-out:

  1. Extend Intercept to support predicate-only entries. Add a
    variant like Intercept { name_predicate: fn(&str) -> bool, wants_alwaysinline: bool, ... } or split the type into
    NamedIntercept + PredicateIntercept. Register the
    {ne|lt|le|gt|ge}__* carve-out as a predicate-only entry with
    no emit (the dispatch site already handles "registered but no
    body" via the existing fallback).

  2. Accept the carve-out as final shape. Branch 2 is short
    (~6 lines), well-commented, and the carve-out is a closed set
    under the current operator-routing design. Living with two
    branches is cheap if no third class is anticipated.

Option 1 is the architecturally complete fold; option 2 is
pragmatic. No urgency — branch 2 is correct as-is. Worth raising
when a third carve-out class shows up, or when raw-buf.3's RawBuf
intercepts surface a similar pattern that wants similar treatment.

Refs #7.


Verification 2026-06-02: Still VALID. intercept_emit_wants_alwaysinline now at crates/ailang-codegen/src/lib.rs:1247 (was 1172). Branch 1 still consults the registry; branch 2's stem-prefix carve-out for {ne|lt|le|gt|ge}__* is unchanged and still hardcoded separate from the registry.

raw-buf.1 (commit 140a0c0) consolidated the legacy `try_emit_primitive_instance_body` arms into a registry table. The companion predicate `intercept_emit_wants_alwaysinline` at `crates/ailang-codegen/src/lib.rs:1172` now consults the registry for branch 1 (the 13-name literal list) — one source of truth. Branch 2 of that predicate stays hardcoded: a stem-prefix carve-out matching `{ne|lt|le|gt|ge}__*` that returns `wants_alwaysinline = true` for polymorphic-body monomorphizations like `lt__Bool`, `ne__Str`, `ne__MyADT`. These are NOT registry entries (they're generated by the mono pass, not by a hand-written intercept) and never were. Their `alwaysinline` attribute matters for the bench-perf parity established in iter `operator-routing-eq-ord.1`. Two ways to dissolve the carve-out: 1. **Extend `Intercept` to support predicate-only entries.** Add a variant like `Intercept { name_predicate: fn(&str) -> bool, wants_alwaysinline: bool, ... }` or split the type into `NamedIntercept` + `PredicateIntercept`. Register the `{ne|lt|le|gt|ge}__*` carve-out as a predicate-only entry with no `emit` (the dispatch site already handles "registered but no body" via the existing fallback). 2. **Accept the carve-out as final shape.** Branch 2 is short (~6 lines), well-commented, and the carve-out is a closed set under the current operator-routing design. Living with two branches is cheap if no third class is anticipated. Option 1 is the architecturally complete fold; option 2 is pragmatic. No urgency — branch 2 is correct as-is. Worth raising when a third carve-out class shows up, or when raw-buf.3's RawBuf intercepts surface a similar pattern that wants similar treatment. Refs #7. --- **Verification 2026-06-02:** Still VALID. `intercept_emit_wants_alwaysinline` now at `crates/ailang-codegen/src/lib.rs:1247` (was 1172). Branch 1 still consults the registry; branch 2's stem-prefix carve-out for `{ne|lt|le|gt|ge}__*` is unchanged and still hardcoded separate from the registry.
Brummel added the idea label 2026-05-29 11:07:23 +02:00
Sign in to join this conversation.