Skip to content

Commit

Permalink
Expose compute effective sizes from the vm (#887)
Browse files Browse the repository at this point in the history
* expose compute effective sizes

* expose compute effective sizes
  • Loading branch information
Jrigada authored Mar 9, 2023
1 parent c326ba8 commit 17f467c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/vm/vm_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ impl VirtualMachine {
}
}

pub fn compute_segments_effective_sizes(&mut self) {
self.segments.compute_effective_sizes();
}

///Returns the encoded instruction (the value at pc) and the immediate value (the value at pc + 1, if it exists in the memory).
fn get_instruction_encoding(
&self,
Expand Down Expand Up @@ -4105,6 +4109,27 @@ mod tests {
assert_eq!(vm.segments.compute_effective_sizes(), &vec![4]);
}

/// Test that compute_segment_effective_sizes() works as intended.
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn compute_segment_effective_sizes() {
let mut vm = vm!();

let segment = vm.segments.add();
vm.load_data(
segment,
&vec![
mayberelocatable!(1),
mayberelocatable!(2),
mayberelocatable!(3),
mayberelocatable!(4),
],
)
.expect("Could not load data into memory.");

assert_eq!(vm.segments.compute_effective_sizes(), &vec![4]);
}

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn mark_as_accessed() {
Expand Down

0 comments on commit 17f467c

Please sign in to comment.