Surfaced by the CM14 fused-while review (follow-up to #163).
The compiled eval path decides how to run a program by scanning its top-level instructions for a while at eval time, in two places:
// c_src/program.cpp:427 eval_program_nif — host-controlled-fused vs whole-program compile
if (contains_top_level_while(*prog)) { ... }
// c_src/program.cpp:215 the While arm — whether to fuse this body
const bool fuse_body = ctx.fuse_loops && !contains_top_level_while(body_p);
contains_top_level_while (c_src/program.cpp:106) is an O(instrs) scan, but whether a program contains a top-level while is a static property of the IR, known at compile_program time. Computing it once and storing a bool has_while (or a richer compilable/fusable property) on Program would:
Severity: low (refactor / altitude). Correctness is fine today; this is about deciding the "compilable" property once at the right layer rather than re-deriving it on every eval.
Surfaced by the CM14 fused-while review (follow-up to #163).
The compiled eval path decides how to run a program by scanning its top-level instructions for a
whileat eval time, in two places:contains_top_level_while(c_src/program.cpp:106) is an O(instrs) scan, but whether a program contains a top-levelwhileis a static property of the IR, known atcompile_programtime. Computing it once and storing abool has_while(or a richercompilable/fusableproperty) onProgramwould:eval_program_nif,while-entry scan in the replay, including the per-iteration rescan for nested loops (Fused-while micro-optimisations: nested-while rescan and redundant final eval #170),ReplayCtx.fuse_loops+ eval-time scan with a property the lowering owns.Severity: low (refactor / altitude). Correctness is fine today; this is about deciding the "compilable" property once at the right layer rather than re-deriving it on every eval.