Inlining, Unrolling, Tail Calls, And Low-Level Control
This page explains the native optimizer controls that decide when 0x0 may
inline a call, unroll a loop, or verify a required no-stack-growth tail call.
The bounded gates are:
make native-inlining-check
make loop-unroll-check
make tail-call-check
They validate the source-owned control rules, positive and negative fixtures,
generated explain report, benchmark rows, compatibility contract, public docs,
and ADR/RFC records.
Evidence Files
optimizer/native-control/schema.tsv;optimizer/native-control/attributes.tsv;optimizer/native-control/inline-costs.tsv;optimizer/native-control/unroll-rules.tsv;optimizer/native-control/tail-call-rules.tsv;optimizer/native-control/verification-cases.tsv;optimizer/native-control/fixtures/valid-native-control.json;release/native-control-decisions.tsv;perf/native-control-benchmarks.tsv;compat/native-control-contract.tsv;tools/native-control-check.py.
release/native-control-decisions.tsv is the explain report. It records every
accepted and rejected inline, unroll, and tail-call decision with cost, size,
stack, factor, proof, guard, and reason fields.
Inlining
Inlining replaces a call with the callee body only when the call is small enough
and safe enough. The current production policy checks:
always-inlineandnever-inlinesource controls;- hot and cold call sites;
- recursive callees;
- effectful calls;
- volatile calls;
- hard inline cost and always-inline cost budgets.
The default policy rejects effectful and volatile inlining because moving a call
body can change when effects happen or how many volatile operations execute.
Important diagnostics:
NATIVE_CONTROL_INLINE_RECURSIVE
NATIVE_CONTROL_INLINE_BUDGET
NATIVE_CONTROL_EFFECT
NATIVE_CONTROL_VOLATILE
NATIVE_CONTROL_ATTRIBUTE
Loop Unrolling
Loop unrolling duplicates a loop body a fixed number of times. The bounded
unroller only accepts finite known trip counts with a factor inside the
configured budget.
The current policy rejects:
- unknown trip counts;
no-unrollsource controls;- volatile loops without volatile-preserving proof;
- effectful loops;
- code growth above the configured budget.
Important diagnostics:
NATIVE_CONTROL_UNROLL_BOUNDS
NATIVE_CONTROL_UNROLL_BUDGET
NATIVE_CONTROL_VOLATILE
NATIVE_CONTROL_EFFECT
NATIVE_CONTROL_ATTRIBUTE
Required Tail Calls
A required tail call is a correctness promise: it must not grow the stack. 0x0
therefore treats no-stack-growth as a verifier requirement, not a hint.
The verifier accepts a required tail call only when all of these are true:
- the call is in tail position;
- the caller and callee ABI are compatible;
- no cleanup or destructor must run after the call;
- no by-value argument or return lifetime escapes the frame;
- the target supports the required tail-call shape;
- verified stack delta is exactly zero.
Important diagnostics:
NATIVE_CONTROL_TAIL_POSITION
NATIVE_CONTROL_TAIL_ABI
NATIVE_CONTROL_TAIL_CLEANUP
NATIVE_CONTROL_TAIL_LIFETIME
NATIVE_CONTROL_TAIL_TARGET
NATIVE_CONTROL_TAIL_STACK
What This Does Not Overpromise
These gates prove the optimizer-control decisions and required-tail verifier
rules. Later native machine-code and backend milestones must still prove the
actual emitted instruction sequences, stack-depth behavior, and target-specific
machine constraints before a release can claim machine-code parity across all
targets.