◄ WORLD V · SONNY 5DART 240 · a helldive at the net

THE INLINING paste the callee in; delete the call

Inlining replaces a function call with a copy of the callee's body, wiring the arguments in directly. It removes the call/return overhead, but the real prize is what it enables: once the body is in the caller, constant propagation, CSE, and dead-code elimination can see across the old boundary and specialize the code to this call site. The cost is size (the body is duplicated at every inlined site) and a call stack that no longer matches the source — the callee has vanished into its caller.

THE TECHNIQUE replace call f(x) with f's body → call depth drops

A leaf function f(x)=x*x+1 is called, then inlined. The demo shows the value is identical and the call depth drops from 1 to 0: live demo


HISTORY & CREDIT Scheifler, 1977

“Inlining just saves the cost of a call.” — the call cost is the small win; the big one is that the optimizer can now see through the call and specialize. Inlining is less about speed than about removing a wall the other passes could not look past. cited

1977 · Robert W. Scheifler — “An Analysis of Inline Substitution for a Structured Programming Language” (CACM): inlining as an enabling transformation, with a cost model.
lineage · the trade the whole field re-litigates: code size vs the optimizations inlining unlocks.
now · inlining heuristics are among the most tuned decisions in LLVM, GCC, and JITs.

Inlining is the enabler of enablers: it does little by itself and much by what it lets other passes reach. Its danger is the same — inline everything and the code explodes. Scheifler 1977

RECOMMEND FOR I-13 call vs inlined, both computed

On the canonical compiler, f(6)=37 via a call (call depth 1) equals the inlined 6*6+1=37 (call depth 0) — same value, one less frame:

$ i13 run inline.i13 # f(x)=x*x+1 called, then inlined called = 37 (RUN OK, call depth 1) inlined = 37 (call depth 0 -- the frame is gone)
Recommend: inlining is a real but double-edged fit for I-13 — it would lower call depth, and i13's hard ceiling is exactly that (E0503 at 4096 frames), so inlining a leaf could let a deeper recursion run. But it collides with the spot-awareness log, where an I-frame per call is the whole point (dominant scope in, subordinate spot out). Inlining erases a frame the log is designed to witness. Offer it opt-in, never default: i13 would rather keep the call visible than hide it for speed.