Skip to main content

call_frame_cost

Function call_frame_cost 

Source
pub fn call_frame_cost(code_len: u32, ro_units: u32) -> u64
Expand description

Category-#3 cost of materializing a callee sub-invocation at an in-kernel CALL, charged to the caller’s meter in addition to the ecall_dynamic_cost floor, and computed statically from the callee Image so both engines agree:

  • JIT compileO(code): ceil(code_len / PAGE_SIZE) pages × COMPILE_COST_PER_PAGE.
  • Eager read-only page-in — one PAGE_IN_COST per declared 2 MiB read-only unit (the callee’s code region plus its pinned mappings) — the cost that used to be charged lazily per touched unit at a fault.
  • Frame-setup baseCALL_FRAME_COST.

Always charged in full: the compiled image and its page table are memoized as a node-local performance optimization, never a gas discount — so a re-CALL into a warm Image pays identically and gas stays independent of the cache (the architectural “eager compile + eager RO-map at CALL” model; the implementation may stay lazy/demand-paged without changing this charge). TODO(gas-calibration): placeholder coefficients.