Skip to content

fix(engine): unify loop fuel enforcement and reporting (#43) - #64

Merged
siktec-lab merged 3 commits into
mainfrom
fix/issue-43-loop-fuel-parity
Nov 11, 2026
Merged

siktec-lab merged 3 commits into
mainfrom
fix/issue-43-loop-fuel-parity

Conversation

@siktec-lab

Copy link
Copy Markdown
Collaborator

Fixes #43

Summary

  • Unified Loop Fuel Enforcement & Reporting (#43):
    • Aligned SliceIsolate::apply_boa_realm_runtime_limits (set_loop_iteration_limit(remaining_fuel)) and SliceIsolate::finish_boa_compartment_execution (consume_fuel(loop_iters)) to the exact same 1 fuel unit per 1 iteration scale, and moved apply_boa_realm_runtime_limits to run immediately before guest script evaluation (after cold-realm prelude/shard initialization).
    • Replaced CallFrame::loop_iteration_count (context.vm.frame_mut() heap dereference on every loop iteration) with inline RuntimeLimits::check_and_increment_loop_iteration() (next > self.loop_iteration), shrinking CallFrame by 8 bytes and eliminating off-by-one boundary drift.
    • Emitted IncrementLoopIteration after the loop exit branch in compile_while_loop, compile_for_in_loop, and compile_for_of_loop, and routed top-level while loops (in_function_depth == 0) to Boa's bytecode VM.
    • Verified exact reported fuelUsed == smallest budget that completes parity across for (4005 == 4005), while (1000010 == 1000010), and do-while (1000010 == 1000010).
  • Full 33-Workload Benchmark Suite (v0.10.8):

@siktec-lab
siktec-lab merged commit 7497b51 into main Nov 11, 2026
3 checks passed
@siktec-lab
siktec-lab deleted the fix/issue-43-loop-fuel-parity branch November 11, 2026 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fuelUsed is a constant 10 for while and do...while loops that finish under the budget

2 participants