diff --git a/compiler/noirc_evaluator/src/acir/acir_variable.rs b/compiler/noirc_evaluator/src/acir/acir_variable.rs index fdf19e77414..6e1c2c450de 100644 --- a/compiler/noirc_evaluator/src/acir/acir_variable.rs +++ b/compiler/noirc_evaluator/src/acir/acir_variable.rs @@ -1656,135 +1656,3 @@ fn fits_in_one_identity(expr: &Expression, width: ExpressionWid /// A Reference to an `AcirVarData` #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub(crate) struct AcirVar(usize); -<<<<<<< HEAD -||||||| parent of 91f98735b2 (feat: remove foreign calls array from `BrilligVM` constructor) - -/// Attempts to execute the provided [`Brillig`][`acvm::acir::brillig`] bytecode -/// -/// Returns the finished state of the Brillig VM if execution can complete. -/// -/// Returns `None` if complete execution of the Brillig bytecode is not possible. -fn execute_brillig>( - code: &[BrilligOpcode], - blackbox_solver: &B, - inputs: &[BrilligInputs], -) -> Option>> { - // Set input values - let mut calldata: Vec = Vec::new(); - - // Each input represents a constant or array of constants. - // Iterate over each input and push it into registers and/or memory. - for input in inputs { - match input { - BrilligInputs::Single(expr) => { - calldata.push(*expr.to_const()?); - } - BrilligInputs::Array(expr_arr) => { - // Attempt to fetch all array input values - for expr in expr_arr.iter() { - calldata.push(*expr.to_const()?); - } - } - BrilligInputs::MemoryArray(_) => { - return None; - } - } - } - - // Instantiate a Brillig VM given the solved input registers and memory, along with the Brillig bytecode. - let profiling_active = false; - let mut vm = VM::new(calldata, code, Vec::new(), blackbox_solver, profiling_active); - - // Run the Brillig VM on these inputs, bytecode, etc! - let vm_status = vm.process_opcodes(); - - // Check the status of the Brillig VM. - // It may be finished, in-progress, failed, or may be waiting for results of a foreign call. - // If it's finished then we can omit the opcode and just write in the return values. - match vm_status { - VMStatus::Finished { return_data_offset, return_data_size } => Some( - vm.get_memory()[return_data_offset..(return_data_offset + return_data_size)].to_vec(), - ), - VMStatus::InProgress => unreachable!("Brillig VM has not completed execution"), - VMStatus::Failure { .. } => { - // TODO: Return an error stating that the brillig function failed. - None - } - VMStatus::ForeignCallWait { .. } => { - // If execution can't complete then keep the opcode - - // TODO: We could bake in all the execution up to this point by replacing the inputs - // such that they initialize the registers/memory to the current values and then discard - // any opcodes prior to the one which performed this foreign call. - // - // Seems overkill for now however. - None - } - } -} -======= - -/// Attempts to execute the provided [`Brillig`][`acvm::acir::brillig`] bytecode -/// -/// Returns the finished state of the Brillig VM if execution can complete. -/// -/// Returns `None` if complete execution of the Brillig bytecode is not possible. -fn execute_brillig>( - code: &[BrilligOpcode], - blackbox_solver: &B, - inputs: &[BrilligInputs], -) -> Option>> { - // Set input values - let mut calldata: Vec = Vec::new(); - - // Each input represents a constant or array of constants. - // Iterate over each input and push it into registers and/or memory. - for input in inputs { - match input { - BrilligInputs::Single(expr) => { - calldata.push(*expr.to_const()?); - } - BrilligInputs::Array(expr_arr) => { - // Attempt to fetch all array input values - for expr in expr_arr.iter() { - calldata.push(*expr.to_const()?); - } - } - BrilligInputs::MemoryArray(_) => { - return None; - } - } - } - - // Instantiate a Brillig VM given the solved input registers and memory, along with the Brillig bytecode. - let profiling_active = false; - let mut vm = VM::new(calldata, code, blackbox_solver, profiling_active); - - // Run the Brillig VM on these inputs, bytecode, etc! - let vm_status = vm.process_opcodes(); - - // Check the status of the Brillig VM. - // It may be finished, in-progress, failed, or may be waiting for results of a foreign call. - // If it's finished then we can omit the opcode and just write in the return values. - match vm_status { - VMStatus::Finished { return_data_offset, return_data_size } => Some( - vm.get_memory()[return_data_offset..(return_data_offset + return_data_size)].to_vec(), - ), - VMStatus::InProgress => unreachable!("Brillig VM has not completed execution"), - VMStatus::Failure { .. } => { - // TODO: Return an error stating that the brillig function failed. - None - } - VMStatus::ForeignCallWait { .. } => { - // If execution can't complete then keep the opcode - - // TODO: We could bake in all the execution up to this point by replacing the inputs - // such that they initialize the registers/memory to the current values and then discard - // any opcodes prior to the one which performed this foreign call. - // - // Seems overkill for now however. - None - } - } -} ->>>>>>> 91f98735b2 (feat: remove foreign calls array from `BrilligVM` constructor) diff --git a/compiler/noirc_evaluator/src/acir/brillig_call.rs b/compiler/noirc_evaluator/src/acir/brillig_call.rs index f927aabbdc2..f027a7b62f8 100644 --- a/compiler/noirc_evaluator/src/acir/brillig_call.rs +++ b/compiler/noirc_evaluator/src/acir/brillig_call.rs @@ -311,7 +311,7 @@ fn execute_brillig>( // Instantiate a Brillig VM given the solved input registers and memory, along with the Brillig bytecode. let profiling_active = false; - let mut vm = VM::new(calldata, code, Vec::new(), blackbox_solver, profiling_active); + let mut vm = VM::new(calldata, code, blackbox_solver, profiling_active); // Run the Brillig VM on these inputs, bytecode, etc! let vm_status = vm.process_opcodes();