From 1898f006b268bcb1eecff859d62c086948f29347 Mon Sep 17 00:00:00 2001 From: "g. nicholas d'andrea" Date: Thu, 2 Jul 2026 20:10:29 -0400 Subject: [PATCH] docs: add inlineDemo tracing example (leaf helper, two sites) A small leaf helper square(x) called from two sites with storage-read args. At O2/O3 both sites inline into the caller -> two virtual activations in the tracer (the inline showcase, as sum/factorial were for tailcall). Args are non-constant (storage reads) so L1 fold can't collapse the inlined bodies. Verified against bugc: correct result (3^2 + 4^2 = 25) at O0-O3; zero inline marks at O0/O1, both sites inlined at O2 (108 -> 50 runtime instrs) and O3. Prose + TraceExample wiring to follow (writer/docs). --- .../core-schemas/programs/tracing-examples.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/web/docs/core-schemas/programs/tracing-examples.ts b/packages/web/docs/core-schemas/programs/tracing-examples.ts index a6c67fc5d..24fecdfec 100644 --- a/packages/web/docs/core-schemas/programs/tracing-examples.ts +++ b/packages/web/docs/core-schemas/programs/tracing-examples.ts @@ -138,3 +138,27 @@ create { code { result = fact(5, 1); }`; + +export const inlineDemo = `name InlineDemo; + +define { + function square(x: uint256) -> uint256 { + return x * x; + }; +} + +storage { + [0] a: uint256; + [1] b: uint256; + [2] sumOfSquares: uint256; +} + +create { + a = 3; + b = 4; + sumOfSquares = 0; +} + +code { + sumOfSquares = square(a) + square(b); +}`;