Skip to content

Commit

Permalink
refactor(processor_table): remove never-triggered panics
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed Oct 23, 2023
1 parent 4b38d01 commit 6ced006
Showing 1 changed file with 9 additions and 33 deletions.
42 changes: 9 additions & 33 deletions triton-vm/src/table/processor_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,44 +47,20 @@ impl ProcessorTable {
clk_jump_diffs_ram: &[BFieldElement],
clk_jump_diffs_jump_stack: &[BFieldElement],
) {
// compute the lookup multiplicities of the clock jump differences
let num_rows = aet.processor_trace.nrows();
let mut clk_jump_diff_multiplicities = Array1::zeros([num_rows]);
for clk_jump_diff in clk_jump_diffs_op_stack.iter() {
let clk = clk_jump_diff.value() as usize;
match clk < num_rows {
true => clk_jump_diff_multiplicities[clk] += BFIELD_ONE,
false => panic!(
"Op Stack: clock jump diff {clk} must fit in trace with {num_rows} rows."
),
}
}
for clk_jump_diff in clk_jump_diffs_ram.iter() {
let clk = clk_jump_diff.value() as usize;
match clk < num_rows {
true => clk_jump_diff_multiplicities[clk] += BFIELD_ONE,
false => {
panic!("RAM: clock jump diff {clk} must fit in trace with {num_rows} rows.")
}
}
}
for clk_jump_diff in clk_jump_diffs_jump_stack.iter() {
for clk_jump_diff in clk_jump_diffs_op_stack
.iter()
.chain(clk_jump_diffs_ram)
.chain(clk_jump_diffs_jump_stack)
{
let clk = clk_jump_diff.value() as usize;
match clk < num_rows {
true => clk_jump_diff_multiplicities[clk] += BFIELD_ONE,
false => panic!(
"Jump Stack: clock jump diff {clk} must fit in trace with {num_rows} rows."
),
}
clk_jump_diff_multiplicities[clk] += BFIELD_ONE;
}

// fill the processor table from the AET and the lookup multiplicities
let mut processor_table_to_fill =
processor_table.slice_mut(s![0..aet.processor_trace.nrows(), ..]);
aet.processor_trace
.clone()
.move_into(&mut processor_table_to_fill);
processor_table_to_fill
let mut processor_table = processor_table.slice_mut(s![0..num_rows, ..]);
processor_table.assign(&aet.processor_trace);
processor_table
.column_mut(ClockJumpDifferenceLookupMultiplicity.base_table_index())
.assign(&clk_jump_diff_multiplicities);
}
Expand Down

0 comments on commit 6ced006

Please sign in to comment.