Skip to content

Commit 714c97a

Browse files
committed
fix: missing handler for is_eq
1 parent 6e2b0a2 commit 714c97a

File tree

1 file changed

+30
-20
lines changed
  • extensions/algebra/circuit/src/modular_chip

1 file changed

+30
-20
lines changed

extensions/algebra/circuit/src/modular_chip/is_eq.rs

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,16 @@ impl<const NUM_LANES: usize, const LANE_SIZE: usize, const TOTAL_READ_SIZE: usiz
523523
}
524524
}
525525

526+
macro_rules! dispatch {
527+
($execute_impl:ident, $is_setup:ident) => {
528+
Ok(if $is_setup {
529+
$execute_impl::<_, _, NUM_LANES, LANE_SIZE, TOTAL_READ_SIZE, true>
530+
} else {
531+
$execute_impl::<_, _, NUM_LANES, LANE_SIZE, TOTAL_READ_SIZE, false>
532+
})
533+
};
534+
}
535+
526536
impl<F, const NUM_LANES: usize, const LANE_SIZE: usize, const TOTAL_READ_SIZE: usize> Executor<F>
527537
for VmModularIsEqualExecutor<NUM_LANES, LANE_SIZE, TOTAL_READ_SIZE>
528538
where
@@ -540,15 +550,9 @@ where
540550
data: &mut [u8],
541551
) -> Result<ExecuteFunc<F, Ctx>, StaticProgramError> {
542552
let pre_compute: &mut ModularIsEqualPreCompute<TOTAL_READ_SIZE> = data.borrow_mut();
543-
544553
let is_setup = self.pre_compute_impl(pc, inst, pre_compute)?;
545-
let fn_ptr = if is_setup {
546-
execute_e1_impl::<_, _, NUM_LANES, LANE_SIZE, TOTAL_READ_SIZE, true>
547-
} else {
548-
execute_e1_impl::<_, _, NUM_LANES, LANE_SIZE, TOTAL_READ_SIZE, false>
549-
};
550554

551-
Ok(fn_ptr)
555+
dispatch!(execute_e1_impl, is_setup)
552556
}
553557

554558
#[cfg(feature = "tco")]
@@ -562,15 +566,9 @@ where
562566
Ctx: ExecutionCtxTrait,
563567
{
564568
let pre_compute: &mut ModularIsEqualPreCompute<TOTAL_READ_SIZE> = data.borrow_mut();
565-
566569
let is_setup = self.pre_compute_impl(pc, inst, pre_compute)?;
567-
let fn_ptr = if is_setup {
568-
execute_e1_tco_handler::<_, _, NUM_LANES, LANE_SIZE, TOTAL_READ_SIZE, true>
569-
} else {
570-
execute_e1_tco_handler::<_, _, NUM_LANES, LANE_SIZE, TOTAL_READ_SIZE, false>
571-
};
572570

573-
Ok(fn_ptr)
571+
dispatch!(execute_e1_tco_handler, is_setup)
574572
}
575573
}
576574

@@ -596,13 +594,24 @@ where
596594
pre_compute.chip_idx = chip_idx as u32;
597595

598596
let is_setup = self.pre_compute_impl(pc, inst, &mut pre_compute.data)?;
599-
let fn_ptr = if is_setup {
600-
execute_e2_impl::<_, _, NUM_LANES, LANE_SIZE, TOTAL_READ_SIZE, true>
601-
} else {
602-
execute_e2_impl::<_, _, NUM_LANES, LANE_SIZE, TOTAL_READ_SIZE, false>
603-
};
604597

605-
Ok(fn_ptr)
598+
dispatch!(execute_e2_impl, is_setup)
599+
}
600+
601+
fn metered_handler<Ctx: MeteredExecutionCtxTrait>(
602+
&self,
603+
chip_idx: usize,
604+
pc: u32,
605+
inst: &Instruction<F>,
606+
data: &mut [u8],
607+
) -> Result<Handler<F, Ctx>, StaticProgramError> {
608+
let pre_compute: &mut E2PreCompute<ModularIsEqualPreCompute<TOTAL_READ_SIZE>> =
609+
data.borrow_mut();
610+
pre_compute.chip_idx = chip_idx as u32;
611+
612+
let is_setup = self.pre_compute_impl(pc, inst, &mut pre_compute.data)?;
613+
614+
dispatch!(execute_e2_tco_handler, is_setup)
606615
}
607616
}
608617

@@ -626,6 +635,7 @@ unsafe fn execute_e1_impl<
626635
);
627636
}
628637

638+
#[create_tco_handler]
629639
unsafe fn execute_e2_impl<
630640
F: PrimeField32,
631641
CTX: MeteredExecutionCtxTrait,

0 commit comments

Comments
 (0)