Skip to content

Conversation

@Schaeff
Copy link

@Schaeff Schaeff commented Nov 14, 2025

Gives the prover the power to chose whether to run software or apc at runtime.

TODO:

  • Support runtime conditions: which ones?
  • Clean up
  • Check that there is no performance regression

}

pub fn add_apc_instruction_at_pc_index(&mut self, pc_index: usize, opcode: VmOpcode) {
pub fn add_apc_instruction_at_pc_index(&mut self, pc_index: usize, opcode: VmOpcode, condition: ApcCondition) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the user facing change, where the client specifies the conditions under which the apc should be chosen

)]
pub instructions_and_debug_infos: Vec<Option<(Instruction<F>, Option<DebugInfo>)>>,
pub apc_by_pc_index: HashMap<usize, (Instruction<F>, Option<DebugInfo>)>,
pub instructions_and_debug_infos: Vec<Option<(Decision<Instruction<F>>, Option<DebugInfo>)>>,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify the program to keep track of software and apc in the same vector. This reduces our diff vs upstream.

}

#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub struct Decision<H> {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now used across the codebase for situations where we have the choice between software and apc: handlers, pc_entries, etc.

/// Handler function pointers for tail call optimization.
#[cfg(feature = "tco")]
handlers: Vec<Handler<F, Ctx>>,
handlers: Vec<Decision<Handler<F, Ctx>>>,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes is possible to pick a tco handler at runtime.

#[cfg_attr(feature = "tco", allow(dead_code))]
struct PreComputeInstruction<'a, F, Ctx> {
pub handler: ExecuteFunc<F, Ctx>,
pub handler: Decision<ExecuteFunc<F, Ctx>>,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for a non-tco execution function.

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.

2 participants