diff --git a/benches/vm_benchmark.rs b/benches/vm_benchmark.rs index 7d9b9717..81ac8999 100644 --- a/benches/vm_benchmark.rs +++ b/benches/vm_benchmark.rs @@ -42,7 +42,7 @@ fn asm_benchmark(c: &mut Criterion) { "bar"].into_iter().map(|a| a.into()).collect(); b.iter(|| { - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine.load_program(&buffer, &args[..]).unwrap(); @@ -61,7 +61,7 @@ fn mop_benchmark(c: &mut Criterion) { "foo", "bar"].into_iter().map(|a| a.into()).collect(); b.iter(|| { - let asm_core = AsmCoreMachine::new(ISA_IMC | ISA_B | ISA_MOP, VERSION2, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC | ISA_B | ISA_MOP, VERSION2, u64::MAX); let core = DefaultMachineBuilder::>::new(asm_core) .build(); let mut machine = AsmMachine::new(core); @@ -83,7 +83,7 @@ fn mop_memoized_benchmark(c: &mut Criterion) { "foo", "bar"].into_iter().map(|a| a.into()).collect(); let mut decoder = MemoizedFixedTraceDecoder::new(build_decoder::(isa, version)); - let asm_core = AsmCoreMachine::new(isa, version, u64::max_value()); + let asm_core = AsmCoreMachine::new(isa, version, u64::MAX); let core = DefaultMachineBuilder::>::new(asm_core) .build(); let mut machine = AsmMachine::new(core); @@ -91,7 +91,7 @@ fn mop_memoized_benchmark(c: &mut Criterion) { machine.run_with_decoder(&mut decoder).unwrap(); b.iter(|| { - let asm_core = AsmCoreMachine::new(isa, version, u64::max_value()); + let asm_core = AsmCoreMachine::new(isa, version, u64::MAX); let core = DefaultMachineBuilder::>::new(asm_core) .build(); let mut machine = AsmMachine::new(core); @@ -114,7 +114,7 @@ fn mop_memoized_dynamic_benchmark(c: &mut Criterion) { "foo", "bar"].into_iter().map(|a| a.into()).collect(); let mut decoder = MemoizedDynamicTraceDecoder::new(build_decoder::(isa, version)); - let asm_core = AsmCoreMachine::new(isa, version, u64::max_value()); + let asm_core = AsmCoreMachine::new(isa, version, u64::MAX); let core = DefaultMachineBuilder::>::new(asm_core) .build(); let mut machine = AsmMachine::new(core); @@ -122,7 +122,7 @@ fn mop_memoized_dynamic_benchmark(c: &mut Criterion) { machine.run_with_decoder(&mut decoder).unwrap(); b.iter(|| { - let asm_core = AsmCoreMachine::new(isa, version, u64::max_value()); + let asm_core = AsmCoreMachine::new(isa, version, u64::MAX); let core = DefaultMachineBuilder::>::new(asm_core) .build(); let mut machine = AsmMachine::new(core); diff --git a/definitions/src/asm.rs b/definitions/src/asm.rs index f1b43525..6e97a943 100644 --- a/definitions/src/asm.rs +++ b/definitions/src/asm.rs @@ -147,8 +147,8 @@ impl AsmCoreMachine { machine.frames_size = (memory_size / MEMORY_FRAMESIZE) as u64; machine.flags_size = (memory_size / RISCV_PAGESIZE) as u64; - machine.last_read_frame = u64::max_value(); - machine.last_write_page = u64::max_value(); + machine.last_read_frame = u64::MAX; + machine.last_write_page = u64::MAX; let memory_layout = Layout::array::(machine.memory_size as usize).unwrap(); machine.memory_ptr = unsafe { alloc(memory_layout) } as u64; diff --git a/examples/check_real_memory.rs b/examples/check_real_memory.rs index d76b4d87..d556c7b3 100644 --- a/examples/check_real_memory.rs +++ b/examples/check_real_memory.rs @@ -168,8 +168,7 @@ fn check_asm(memory_size: usize) -> Result<(), ()> { ); println!("Base memory: {}", get_current_memory()); for _ in 0..G_CHECK_LOOP { - let asm_core = - AsmCoreMachine::new_with_memory(ISA_IMC, VERSION0, u64::max_value(), memory_size); + let asm_core = AsmCoreMachine::new_with_memory(ISA_IMC, VERSION0, u64::MAX, memory_size); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -193,8 +192,7 @@ fn check_asm_in_thread(memory_size: usize) -> Result<(), ()> { ); println!("Base memory: {}", get_current_memory()); for _ in 0..G_CHECK_LOOP { - let asm_core = - AsmCoreMachine::new_with_memory(ISA_IMC, VERSION0, u64::max_value(), memory_size); + let asm_core = AsmCoreMachine::new_with_memory(ISA_IMC, VERSION0, u64::MAX, memory_size); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine diff --git a/fuzz/fuzz_targets/snapshot2.rs b/fuzz/fuzz_targets/snapshot2.rs index 2d495113..4f598cac 100644 --- a/fuzz/fuzz_targets/snapshot2.rs +++ b/fuzz/fuzz_targets/snapshot2.rs @@ -65,7 +65,7 @@ impl DataSource for DummyData { fn build_machine() -> DefaultMachine> { let isa = ISA_IMC | ISA_A | ISA_B | ISA_MOP; - let core_machine = AsmCoreMachine::new(isa, VERSION2, u64::max_value()); + let core_machine = AsmCoreMachine::new(isa, VERSION2, u64::MAX); DefaultMachineBuilder::new(core_machine).build() } diff --git a/src/bits.rs b/src/bits.rs index d9e173b0..e25b1efc 100644 --- a/src/bits.rs +++ b/src/bits.rs @@ -24,8 +24,8 @@ mod tests { assert_eq!(16, roundup(15, 16)); assert_eq!(16, roundup(16, 16)); assert_eq!(32, roundup(17, 16)); - assert_eq!(u64::max_value() - 15, roundup(u64::max_value() - 15, 16)); - assert_eq!(0, roundup(u64::max_value(), 16)); + assert_eq!(u64::MAX - 15, roundup(u64::MAX - 15, 16)); + assert_eq!(0, roundup(u64::MAX, 16)); } #[test] @@ -35,7 +35,7 @@ mod tests { assert_eq!(0, rounddown(15, 16)); assert_eq!(16, rounddown(16, 16)); assert_eq!(16, rounddown(17, 16)); - assert_eq!(u64::max_value() - 15, rounddown(u64::max_value(), 16)); + assert_eq!(u64::MAX - 15, rounddown(u64::MAX, 16)); } proptest! { diff --git a/src/instructions/ast.rs b/src/instructions/ast.rs index 82484c89..974ef80d 100644 --- a/src/instructions/ast.rs +++ b/src/instructions/ast.rs @@ -149,11 +149,11 @@ impl Register for Value { } fn min_value() -> Value { - Value::Imm(u64::min_value()) + Value::Imm(u64::MIN) } fn max_value() -> Value { - Value::Imm(u64::max_value()) + Value::Imm(u64::MAX) } fn eq(&self, other: &Value) -> Value { diff --git a/src/instructions/mod.rs b/src/instructions/mod.rs index afd3dec4..6cc88423 100644 --- a/src/instructions/mod.rs +++ b/src/instructions/mod.rs @@ -457,14 +457,14 @@ mod tests { fn test_stype_display() { // This is "sd a5,568(sp)" let sd_inst = 0x22f13c23; - let decoded = factory::(sd_inst, u32::max_value()).expect("decoding"); + let decoded = factory::(sd_inst, u32::MAX).expect("decoding"); let stype = Stype(decoded); assert_eq!("sd a5,568(sp)", format!("{}", stype)); // This is "beq a0,a5,1012e" let sd_inst = 0xf4f500e3; - let decoded = factory::(sd_inst, u32::max_value()).expect("decoding"); + let decoded = factory::(sd_inst, u32::MAX).expect("decoding"); let stype = Stype(decoded); assert_eq!("beq a0,a5,-192", format!("{}", stype)); diff --git a/src/instructions/register.rs b/src/instructions/register.rs index 0028840d..2ae50c85 100644 --- a/src/instructions/register.rs +++ b/src/instructions/register.rs @@ -138,11 +138,11 @@ impl Register for u32 { } fn min_value() -> u32 { - u32::min_value() + u32::MIN } fn max_value() -> u32 { - u32::max_value() + u32::MAX } fn eq(&self, other: &u32) -> u32 { @@ -183,7 +183,7 @@ impl Register for u32 { fn overflowing_div(&self, rhs: &u32) -> u32 { if *rhs == 0 { - Self::max_value() + Self::MAX } else { (*self).overflowing_div(*rhs).0 } @@ -423,11 +423,11 @@ impl Register for u64 { } fn min_value() -> u64 { - u64::min_value() + u64::MIN } fn max_value() -> u64 { - u64::max_value() + u64::MAX } fn eq(&self, other: &u64) -> u64 { @@ -468,7 +468,7 @@ impl Register for u64 { fn overflowing_div(&self, rhs: &u64) -> u64 { if *rhs == 0 { - Self::max_value() + Self::MAX } else { (*self).overflowing_div(*rhs).0 } diff --git a/src/lib.rs b/src/lib.rs index d6563a72..9fe637b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,7 +43,7 @@ pub fn run + Default>( let core_machine = DefaultCoreMachine::>::new_with_memory( ISA_IMC | ISA_A | ISA_B | ISA_MOP, machine::VERSION2, - u64::max_value(), + u64::MAX, WXorXMemory::new(M::default()), ); let mut machine = TraceMachine::new(DefaultMachineBuilder::new(core_machine).build()); @@ -59,7 +59,7 @@ pub fn run_with_memory>( let core_machine = DefaultCoreMachine::>::new_with_memory( ISA_IMC | ISA_A | ISA_B | ISA_MOP, machine::VERSION2, - u64::max_value(), + u64::MAX, WXorXMemory::new(memory), ); let mut machine = TraceMachine::new(DefaultMachineBuilder::new(core_machine).build()); diff --git a/src/machine/asm/mod.rs b/src/machine/asm/mod.rs index 668abd07..2f718cd6 100644 --- a/src/machine/asm/mod.rs +++ b/src/machine/asm/mod.rs @@ -366,8 +366,8 @@ impl Memory for Box { let slice = self.cast_ptr_to_slice_mut(self.frames_ptr, 0, self.frames_size as usize); memset(slice, 0); self.load_reservation_address = u64::MAX; - self.last_read_frame = u64::max_value(); - self.last_write_page = u64::max_value(); + self.last_read_frame = u64::MAX; + self.last_write_page = u64::MAX; Ok(()) } @@ -421,8 +421,8 @@ impl Memory for Box { current_addr += RISCV_PAGESIZE as u64; } // Clear last read/write page cache - self.last_read_frame = u64::max_value(); - self.last_write_page = u64::max_value(); + self.last_read_frame = u64::MAX; + self.last_write_page = u64::MAX; Ok(()) } @@ -443,7 +443,7 @@ impl Memory for Box { let slice = self.cast_ptr_to_slice_mut(self.flags_ptr, page as usize, 1); slice[0] |= flag; // Clear last write page cache - self.last_write_page = u64::max_value(); + self.last_write_page = u64::MAX; Ok(()) } else { Err(Error::MemOutOfBound( @@ -458,7 +458,7 @@ impl Memory for Box { let slice = self.cast_ptr_to_slice_mut(self.flags_ptr, page as usize, 1); slice[0] &= !flag; // Clear last write page cache - self.last_write_page = u64::max_value(); + self.last_write_page = u64::MAX; Ok(()) } else { Err(Error::MemOutOfBound( diff --git a/tests/machine_build.rs b/tests/machine_build.rs index 9ae2ad51..74e0c9b2 100644 --- a/tests/machine_build.rs +++ b/tests/machine_build.rs @@ -32,7 +32,7 @@ impl Syscalls for SleepSyscall { #[cfg(has_asm)] pub fn asm_v1_imcb(path: &str) -> AsmMachine { let buffer: Bytes = std::fs::read(path).unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC | ISA_B, VERSION1, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC | ISA_B, VERSION1, u64::MAX); let core = DefaultMachineBuilder::>::new(asm_core) .instruction_cycle_func(Box::new(constant_cycles)) .syscall(Box::new(SleepSyscall {})) @@ -51,7 +51,7 @@ pub fn int_v1_imcb( let core_machine = DefaultCoreMachine::>>::new( ISA_IMC | ISA_B, VERSION1, - u64::max_value(), + u64::MAX, ); let mut machine = TraceMachine::new( DefaultMachineBuilder::new(core_machine) @@ -73,7 +73,7 @@ pub fn asm_v1_mop(path: &str, args: Vec) -> AsmMachine { #[cfg(has_asm)] pub fn asm_mop(path: &str, args: Vec, version: u32) -> AsmMachine { let buffer: Bytes = std::fs::read(path).unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC | ISA_B | ISA_MOP, version, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC | ISA_B | ISA_MOP, version, u64::MAX); let core = DefaultMachineBuilder::>::new(asm_core) .instruction_cycle_func(Box::new(constant_cycles)) .syscall(Box::new(SleepSyscall {})) @@ -101,7 +101,7 @@ pub fn int_mop( let core_machine = DefaultCoreMachine::>>::new( ISA_IMC | ISA_B | ISA_MOP, version, - u64::max_value(), + u64::MAX, ); let mut machine = TraceMachine::new( DefaultMachineBuilder::new(core_machine) @@ -118,7 +118,7 @@ pub fn int_mop( #[cfg(has_asm)] pub fn asm_v2_imacb(path: &str) -> AsmMachine { let buffer: Bytes = std::fs::read(path).unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC | ISA_A | ISA_B, VERSION2, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC | ISA_A | ISA_B, VERSION2, u64::MAX); let core = DefaultMachineBuilder::>::new(asm_core) .instruction_cycle_func(Box::new(constant_cycles)) .syscall(Box::new(SleepSyscall {})) @@ -137,7 +137,7 @@ pub fn int_v2_imacb( let core_machine = DefaultCoreMachine::>>::new( ISA_IMC | ISA_A | ISA_B, VERSION2, - u64::max_value(), + u64::MAX, ); let mut machine = TraceMachine::new( DefaultMachineBuilder::new(core_machine) diff --git a/tests/test_asm.rs b/tests/test_asm.rs index 1fe93313..14e0e2b7 100644 --- a/tests/test_asm.rs +++ b/tests/test_asm.rs @@ -18,7 +18,7 @@ pub mod machine_build; #[test] pub fn test_asm_simple64() { let buffer = fs::read("tests/programs/simple64").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -55,7 +55,7 @@ impl Syscalls for CustomSyscall { #[test] pub fn test_asm_with_custom_syscall() { let buffer = fs::read("tests/programs/syscall64").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core) .syscall(Box::new(CustomSyscall {})) .build(); @@ -89,7 +89,7 @@ pub fn test_asm_ebreak() { let buffer = fs::read("tests/programs/ebreak64").unwrap().into(); let value = Arc::new(AtomicU8::new(0)); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core) .debugger(Box::new(CustomDebugger { value: Arc::clone(&value), @@ -143,7 +143,7 @@ pub fn test_asm_simple_max_cycles_reached() { #[test] pub fn test_asm_trace() { let buffer = fs::read("tests/programs/trace64").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -157,7 +157,7 @@ pub fn test_asm_trace() { #[test] pub fn test_asm_jump0() { let buffer = fs::read("tests/programs/jump0_64").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -173,7 +173,7 @@ pub fn test_asm_write_large_address() { let buffer = fs::read("tests/programs/write_large_address64") .unwrap() .into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -190,7 +190,7 @@ pub fn test_asm_write_large_address() { #[test] pub fn test_misaligned_jump64() { let buffer = fs::read("tests/programs/misaligned_jump64").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -203,7 +203,7 @@ pub fn test_misaligned_jump64() { #[test] pub fn test_mulw64() { let buffer = fs::read("tests/programs/mulw64").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -217,7 +217,7 @@ pub fn test_mulw64() { #[test] pub fn test_invalid_read64() { let buffer = fs::read("tests/programs/invalid_read64").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -237,7 +237,7 @@ pub fn test_invalid_read64() { #[test] pub fn test_asm_load_elf_crash_64() { let buffer = fs::read("tests/programs/load_elf_crash_64").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -250,7 +250,7 @@ pub fn test_asm_load_elf_crash_64() { #[test] pub fn test_asm_wxorx_crash_64() { let buffer = fs::read("tests/programs/wxorx_crash_64").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -269,7 +269,7 @@ pub fn test_asm_wxorx_crash_64() { #[test] pub fn test_asm_alloc_many() { let buffer = fs::read("tests/programs/alloc_many").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -282,7 +282,7 @@ pub fn test_asm_alloc_many() { #[test] pub fn test_asm_chaos_seed() { let buffer = fs::read("tests/programs/read_memory").unwrap().into(); - let mut asm_core1 = AsmCoreMachine::new(ISA_IMC, VERSION1, u64::max_value()); + let mut asm_core1 = AsmCoreMachine::new(ISA_IMC, VERSION1, u64::MAX); asm_core1.chaos_mode = 1; asm_core1.chaos_seed = 100; let core1 = DefaultMachineBuilder::>::new(asm_core1).build(); @@ -293,7 +293,7 @@ pub fn test_asm_chaos_seed() { let result1 = machine1.run(); let exit1 = result1.unwrap(); - let mut asm_core2 = AsmCoreMachine::new(ISA_IMC, VERSION1, u64::max_value()); + let mut asm_core2 = AsmCoreMachine::new(ISA_IMC, VERSION1, u64::MAX); asm_core2.chaos_mode = 1; asm_core2.chaos_seed = 100; let core2 = DefaultMachineBuilder::>::new(asm_core2).build(); @@ -313,7 +313,7 @@ pub fn test_asm_chaos_seed() { #[test] pub fn test_asm_rvc_pageend() { let buffer = fs::read("tests/programs/rvc_pageend").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -409,7 +409,7 @@ pub fn test_decoder_instructions_cache_pc_out_of_bound_timeout() { #[test] fn test_asm_step() { let buffer = fs::read("tests/programs/simple64").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -432,7 +432,7 @@ fn test_asm_step() { #[test] fn test_asm_thread_safe() { let buffer = fs::read("tests/programs/mulw64").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -449,7 +449,7 @@ fn test_asm_thread_safe() { #[test] fn test_zero_address() { let buffer = fs::read("tests/programs/zero_address").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION1, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION1, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine.load_program(&buffer, &vec!["zero".into()]).unwrap(); @@ -463,7 +463,7 @@ fn test_memoized_secp256k1() { let isa = ISA_IMC; let version = VERSION1; let buffer = fs::read("benches/data/secp256k1_bench").unwrap().into(); - let asm_core = AsmCoreMachine::new(isa, version, u64::max_value()); + let asm_core = AsmCoreMachine::new(isa, version, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); let args: Vec = vec!["secp256k1_bench", @@ -482,7 +482,7 @@ fn test_memoized_dynamic_secp256k1() { let isa = ISA_IMC; let version = VERSION1; let buffer = fs::read("benches/data/secp256k1_bench").unwrap().into(); - let asm_core = AsmCoreMachine::new(isa, version, u64::max_value()); + let asm_core = AsmCoreMachine::new(isa, version, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); let args: Vec = vec!["secp256k1_bench", @@ -499,7 +499,7 @@ fn test_memoized_dynamic_secp256k1() { #[test] pub fn test_big_binary() { let buffer = fs::read("tests/programs/big_binary").unwrap().into(); - let asm_core = AsmCoreMachine::new_with_memory(ISA_IMC, VERSION2, u64::max_value(), 1024 * 512); + let asm_core = AsmCoreMachine::new_with_memory(ISA_IMC, VERSION2, u64::MAX, 1024 * 512); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); let result = machine.load_program(&buffer, &vec!["simple".into()]); @@ -515,7 +515,7 @@ fn test_fast_memory_initialization_bug() { let isa = ISA_IMC; let version = VERSION1; let buffer = fs::read("benches/data/secp256k1_bench").unwrap().into(); - let asm_core = AsmCoreMachine::new(isa, version, u64::max_value()); + let asm_core = AsmCoreMachine::new(isa, version, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); unsafe { @@ -529,7 +529,7 @@ fn test_fast_memory_initialization_bug() { #[test] pub fn test_memory_load_crash() { let buffer = fs::read("tests/programs/memory_crash").unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); let result = machine.load_program(&buffer, &vec!["memory_crash".into()]); diff --git a/tests/test_auipc_fusion.rs b/tests/test_auipc_fusion.rs index 09209f35..4a0b6396 100644 --- a/tests/test_auipc_fusion.rs +++ b/tests/test_auipc_fusion.rs @@ -55,7 +55,7 @@ pub fn test_rust_auipc_fusion() { .into(); let core_machine = - DefaultCoreMachine::>::new(ISA_IMC, VERSION1, u64::max_value()); + DefaultCoreMachine::>::new(ISA_IMC, VERSION1, u64::MAX); let mut machine = DefaultMachineBuilder::new(core_machine).build(); machine .load_program(&buffer, &vec!["auipc_no_sign_extend".into()]) @@ -73,7 +73,7 @@ pub fn test_asm_auipc_fusion() { .unwrap() .into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION1, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION1, u64::MAX); let core = DefaultMachineBuilder::>::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine diff --git a/tests/test_dy_memory.rs b/tests/test_dy_memory.rs index d5b8c6d4..92d99c40 100644 --- a/tests/test_dy_memory.rs +++ b/tests/test_dy_memory.rs @@ -29,8 +29,7 @@ fn run_memory_suc(memory_size: usize, bin_path: String, bin_name: String) { #[cfg(has_asm)] { - let asm_core = - AsmCoreMachine::new_with_memory(ISA_IMC, VERSION0, u64::max_value(), memory_size); + let asm_core = AsmCoreMachine::new_with_memory(ISA_IMC, VERSION0, u64::MAX, memory_size); let core = DefaultMachineBuilder::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -82,7 +81,7 @@ fn test_memory_out_of_bounds() { let asm_core = AsmCoreMachine::new_with_memory( ISA_IMC | ISA_A | ISA_B | ISA_MOP, VERSION2, - u64::max_value(), + u64::MAX, memory_size, ); let core = DefaultMachineBuilder::new(asm_core).build(); diff --git a/tests/test_misc.rs b/tests/test_misc.rs index b4c9874d..0f8a50a5 100644 --- a/tests/test_misc.rs +++ b/tests/test_misc.rs @@ -58,7 +58,7 @@ impl Syscalls for CustomSyscall { pub fn test_custom_syscall() { let buffer = fs::read("tests/programs/syscall64").unwrap().into(); let core_machine = - DefaultCoreMachine::>::new(ISA_IMC, VERSION0, u64::max_value()); + DefaultCoreMachine::>::new(ISA_IMC, VERSION0, u64::MAX); let mut machine = DefaultMachineBuilder::new(core_machine) .syscall(Box::new(CustomSyscall {})) .build(); @@ -91,7 +91,7 @@ pub fn test_ebreak() { let buffer = fs::read("tests/programs/ebreak64").unwrap().into(); let value = Arc::new(AtomicU8::new(0)); let core_machine = - DefaultCoreMachine::>::new(ISA_IMC, VERSION0, u64::max_value()); + DefaultCoreMachine::>::new(ISA_IMC, VERSION0, u64::MAX); let mut machine = DefaultMachineBuilder::new(core_machine) .debugger(Box::new(CustomDebugger { value: Arc::clone(&value), @@ -201,8 +201,7 @@ pub fn test_wxorx_crash_64() { #[test] pub fn test_flat_crash_64() { let buffer = fs::read("tests/programs/flat_crash_64").unwrap().into(); - let core_machine = - DefaultCoreMachine::>::new(ISA_IMC, VERSION0, u64::max_value()); + let core_machine = DefaultCoreMachine::>::new(ISA_IMC, VERSION0, u64::MAX); let mut machine = DefaultMachineBuilder::new(core_machine).build(); let result = machine.load_program(&buffer, &vec!["flat_crash_64".into()]); assert_eq!( @@ -367,7 +366,7 @@ pub fn test_rvc_pageend() { // The last instruction of a executable memory page is an RVC instruction. let buffer = fs::read("tests/programs/rvc_pageend").unwrap().into(); let core_machine = - DefaultCoreMachine::>::new(ISA_IMC, VERSION0, u64::max_value()); + DefaultCoreMachine::>::new(ISA_IMC, VERSION0, u64::MAX); let mut machine = DefaultMachineBuilder::new(core_machine).build(); machine .load_program(&buffer, &vec!["rvc_end".into()]) diff --git a/tests/test_reset.rs b/tests/test_reset.rs index 0f034de2..442d6e70 100644 --- a/tests/test_reset.rs +++ b/tests/test_reset.rs @@ -46,7 +46,7 @@ fn test_reset_int() { let core_machine = DefaultCoreMachine::>>::new( ISA_IMC | ISA_MOP, VERSION1, - u64::max_value(), + u64::MAX, ); let mut machine = DefaultMachineBuilder::new(core_machine) .instruction_cycle_func(Box::new(constant_cycles)) @@ -68,7 +68,7 @@ fn test_reset_int_with_trace() { let core_machine = DefaultCoreMachine::>>::new( ISA_IMC | ISA_MOP, VERSION1, - u64::max_value(), + u64::MAX, ); let mut machine = TraceMachine::new( DefaultMachineBuilder::new(core_machine) @@ -90,7 +90,7 @@ fn test_reset_asm() { let code_data = std::fs::read("tests/programs/reset_caller").unwrap(); let code = Bytes::from(code_data); - let asm_core = AsmCoreMachine::new(ISA_IMC | ISA_MOP, VERSION1, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC | ISA_MOP, VERSION1, u64::MAX); let core = DefaultMachineBuilder::>::new(asm_core) .instruction_cycle_func(Box::new(constant_cycles)) .syscall(Box::new(CustomSyscall {})) diff --git a/tests/test_resume.rs b/tests/test_resume.rs index f0200195..2abf7732 100644 --- a/tests/test_resume.rs +++ b/tests/test_resume.rs @@ -311,7 +311,7 @@ pub fn test_sc_after_snapshot() { DefaultCoreMachine::>>::new( ISA_IMC | ISA_A, VERSION2, - u64::max_value(), + u64::MAX, ), ) .instruction_cycle_func(Box::new(constant_cycles)) diff --git a/tests/test_simple.rs b/tests/test_simple.rs index abb8ae15..f11daf57 100644 --- a/tests/test_simple.rs +++ b/tests/test_simple.rs @@ -80,7 +80,7 @@ pub fn test_simple_invalid_bits() { pub fn test_simple_loaded_bytes() { let buffer = fs::read("tests/programs/simple64").unwrap().into(); let core_machine = - DefaultCoreMachine::>::new(ISA_IMC, VERSION0, u64::max_value()); + DefaultCoreMachine::>::new(ISA_IMC, VERSION0, u64::MAX); let mut machine = DefaultMachineBuilder::new(core_machine).build(); let bytes = machine .load_program(&buffer, &vec!["simple".into()]) diff --git a/tests/test_spawn.rs b/tests/test_spawn.rs index 53988996..650d323d 100644 --- a/tests/test_spawn.rs +++ b/tests/test_spawn.rs @@ -82,7 +82,7 @@ impl Syscalls for IntSpawnSyscall { let machine_core = DefaultCoreMachine::>>::new( ISA_IMC | ISA_A | ISA_B | ISA_MOP, VERSION2, - u64::max_value(), + u64::MAX, ); let mut machine_child = TraceMachine::new( DefaultMachineBuilder::new(machine_core) @@ -141,11 +141,8 @@ impl Syscalls for AsmSpawnSyscall { addr += 8; } let buffer: Bytes = std::fs::read(path).unwrap().into(); - let machine_core_asm = AsmCoreMachine::new( - ISA_IMC | ISA_A | ISA_B | ISA_MOP, - VERSION2, - u64::max_value(), - ); + let machine_core_asm = + AsmCoreMachine::new(ISA_IMC | ISA_A | ISA_B | ISA_MOP, VERSION2, u64::MAX); let machine_core = DefaultMachineBuilder::>::new(machine_core_asm) .instruction_cycle_func(Box::new(constant_cycles)) .syscall(Box::new(AsmSpawnSyscall { @@ -168,7 +165,7 @@ pub fn test_spawn_int() { let machine_core = DefaultCoreMachine::>>::new( ISA_IMC | ISA_A | ISA_B | ISA_MOP, VERSION2, - u64::max_value(), + u64::MAX, ); let mut machine = TraceMachine::new( DefaultMachineBuilder::new(machine_core) @@ -193,11 +190,8 @@ pub fn test_spawn_asm() { let buffer = std::fs::read("tests/programs/spawn").unwrap().into(); let cur_sp = stack_depth(); let min_sp = Arc::new(Mutex::new(u64::MAX)); - let machine_core_asm = AsmCoreMachine::new( - ISA_IMC | ISA_A | ISA_B | ISA_MOP, - VERSION2, - u64::max_value(), - ); + let machine_core_asm = + AsmCoreMachine::new(ISA_IMC | ISA_A | ISA_B | ISA_MOP, VERSION2, u64::MAX); let machine_core = DefaultMachineBuilder::>::new(machine_core_asm) .instruction_cycle_func(Box::new(constant_cycles)) .syscall(Box::new(AsmSpawnSyscall { diff --git a/tests/test_versions.rs b/tests/test_versions.rs index 820ca699..5ab0b164 100644 --- a/tests/test_versions.rs +++ b/tests/test_versions.rs @@ -18,7 +18,7 @@ fn create_rust_machine( ) -> DefaultMachine> { let path = format!("tests/programs/{}", program); let buffer = fs::read(path).unwrap().into(); - let core_machine = DefaultCoreMachine::::new(ISA_IMC, version, u64::max_value()); + let core_machine = DefaultCoreMachine::::new(ISA_IMC, version, u64::MAX); let mut machine = DefaultMachineBuilder::>::new(core_machine).build(); machine @@ -30,7 +30,7 @@ fn create_rust_machine( fn create_asm_machine(program: String, version: u32) -> AsmMachine { let path = format!("tests/programs/{}", program); let buffer = fs::read(path).unwrap().into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, version, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, version, u64::MAX); let core = DefaultMachineBuilder::>::new(asm_core).build(); let mut machine = AsmMachine::new(core); machine @@ -243,7 +243,7 @@ pub fn test_rust_version0_unaligned64() { let buffer = fs::read(format!("tests/programs/{}", program)) .unwrap() .into(); - let core_machine = DefaultCoreMachine::::new(ISA_IMC, VERSION0, u64::max_value()); + let core_machine = DefaultCoreMachine::::new(ISA_IMC, VERSION0, u64::MAX); let mut machine = DefaultMachineBuilder::>::new(core_machine).build(); let result = machine.load_program(&buffer, &vec![program.into()]); @@ -265,7 +265,7 @@ pub fn test_asm_version0_unaligned64() { let buffer = fs::read(format!("tests/programs/{}", program)) .unwrap() .into(); - let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value()); + let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX); let core = DefaultMachineBuilder::>::new(asm_core).build(); let mut machine = AsmMachine::new(core); let result = machine.load_program(&buffer, &vec![program.into()]);