Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rust toolchain to v1.81.0 #442

Merged
merged 4 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.24.0"
license = "MIT"
authors = ["Nervos Core Dev <[email protected]>"]
edition = "2021"
rust-version = "1.75.0"
rust-version = "1.81.0"
build = "build.rs"
exclude = ["/benches", "/tests"]
homepage = "https://github.com/nervosnetwork/ckb-vm"
Expand Down Expand Up @@ -54,3 +54,6 @@ harness = false
name = "vm_benchmark"
path = "benches/vm_benchmark.rs"
harness = false

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(has_asm)'] }
12 changes: 6 additions & 6 deletions benches/vm_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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::<Box<AsmCoreMachine>>::new(asm_core)
.build();
let mut machine = AsmMachine::new(core);
Expand All @@ -83,15 +83,15 @@ fn mop_memoized_benchmark(c: &mut Criterion) {
"foo",
"bar"].into_iter().map(|a| a.into()).collect();
let mut decoder = MemoizedFixedTraceDecoder::new(build_decoder::<u64>(isa, version));
let asm_core = AsmCoreMachine::new(isa, version, u64::max_value());
let asm_core = AsmCoreMachine::new(isa, version, u64::MAX);
let core = DefaultMachineBuilder::<Box<AsmCoreMachine>>::new(asm_core)
.build();
let mut machine = AsmMachine::new(core);
machine.load_program(&buffer, &args).unwrap();
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::<Box<AsmCoreMachine>>::new(asm_core)
.build();
let mut machine = AsmMachine::new(core);
Expand All @@ -114,15 +114,15 @@ fn mop_memoized_dynamic_benchmark(c: &mut Criterion) {
"foo",
"bar"].into_iter().map(|a| a.into()).collect();
let mut decoder = MemoizedDynamicTraceDecoder::new(build_decoder::<u64>(isa, version));
let asm_core = AsmCoreMachine::new(isa, version, u64::max_value());
let asm_core = AsmCoreMachine::new(isa, version, u64::MAX);
let core = DefaultMachineBuilder::<Box<AsmCoreMachine>>::new(asm_core)
.build();
let mut machine = AsmMachine::new(core);
machine.load_program(&buffer, &args).unwrap();
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::<Box<AsmCoreMachine>>::new(asm_core)
.build();
let mut machine = AsmMachine::new(core);
Expand Down
2 changes: 1 addition & 1 deletion definitions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.24.0"
license = "MIT"
authors = ["Nervos Core Dev <[email protected]>"]
edition = "2021"
rust-version = "1.75.0"
rust-version = "1.81.0"
autobins = false
homepage = "https://github.com/nervosnetwork/ckb-vm"
repository = "https://github.com/nervosnetwork/ckb-vm"
Expand Down
4 changes: 2 additions & 2 deletions definitions/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<u8>(machine.memory_size as usize).unwrap();
machine.memory_ptr = unsafe { alloc(memory_layout) } as u64;
Expand Down
6 changes: 2 additions & 4 deletions examples/check_real_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/snapshot2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl DataSource<u32> for DummyData {

fn build_machine() -> DefaultMachine<Box<AsmCoreMachine>> {
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()
}

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.75.0
1.81.0
6 changes: 3 additions & 3 deletions src/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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! {
Expand Down
4 changes: 2 additions & 2 deletions src/instructions/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/instructions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,14 @@ mod tests {
fn test_stype_display() {
// This is "sd a5,568(sp)"
let sd_inst = 0x22f13c23;
let decoded = factory::<u64>(sd_inst, u32::max_value()).expect("decoding");
let decoded = factory::<u64>(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::<u64>(sd_inst, u32::max_value()).expect("decoding");
let decoded = factory::<u64>(sd_inst, u32::MAX).expect("decoding");
let stype = Stype(decoded);

assert_eq!("beq a0,a5,-192", format!("{}", stype));
Expand Down
12 changes: 6 additions & 6 deletions src/instructions/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn run<R: Register, M: Memory<REG = R> + Default>(
let core_machine = DefaultCoreMachine::<R, WXorXMemory<M>>::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());
Expand All @@ -59,7 +59,7 @@ pub fn run_with_memory<R: Register, M: Memory<REG = R>>(
let core_machine = DefaultCoreMachine::<R, WXorXMemory<M>>::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());
Expand Down
12 changes: 6 additions & 6 deletions src/machine/asm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ impl Memory for Box<AsmCoreMachine> {
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(())
}

Expand Down Expand Up @@ -421,8 +421,8 @@ impl Memory for Box<AsmCoreMachine> {
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(())
}

Expand All @@ -443,7 +443,7 @@ impl Memory for Box<AsmCoreMachine> {
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(
Expand All @@ -458,7 +458,7 @@ impl Memory for Box<AsmCoreMachine> {
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(
Expand Down
12 changes: 6 additions & 6 deletions tests/machine_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<Mac: SupportMachine> Syscalls<Mac> 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::<Box<AsmCoreMachine>>::new(asm_core)
.instruction_cycle_func(Box::new(constant_cycles))
.syscall(Box::new(SleepSyscall {}))
Expand All @@ -51,7 +51,7 @@ pub fn int_v1_imcb(
let core_machine = DefaultCoreMachine::<u64, WXorXMemory<SparseMemory<u64>>>::new(
ISA_IMC | ISA_B,
VERSION1,
u64::max_value(),
u64::MAX,
);
let mut machine = TraceMachine::new(
DefaultMachineBuilder::new(core_machine)
Expand All @@ -73,7 +73,7 @@ pub fn asm_v1_mop(path: &str, args: Vec<Bytes>) -> AsmMachine {
#[cfg(has_asm)]
pub fn asm_mop(path: &str, args: Vec<Bytes>, 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::<Box<AsmCoreMachine>>::new(asm_core)
.instruction_cycle_func(Box::new(constant_cycles))
.syscall(Box::new(SleepSyscall {}))
Expand Down Expand Up @@ -101,7 +101,7 @@ pub fn int_mop(
let core_machine = DefaultCoreMachine::<u64, WXorXMemory<SparseMemory<u64>>>::new(
ISA_IMC | ISA_B | ISA_MOP,
version,
u64::max_value(),
u64::MAX,
);
let mut machine = TraceMachine::new(
DefaultMachineBuilder::new(core_machine)
Expand All @@ -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::<Box<AsmCoreMachine>>::new(asm_core)
.instruction_cycle_func(Box::new(constant_cycles))
.syscall(Box::new(SleepSyscall {}))
Expand All @@ -137,7 +137,7 @@ pub fn int_v2_imacb(
let core_machine = DefaultCoreMachine::<u64, WXorXMemory<SparseMemory<u64>>>::new(
ISA_IMC | ISA_A | ISA_B,
VERSION2,
u64::max_value(),
u64::MAX,
);
let mut machine = TraceMachine::new(
DefaultMachineBuilder::new(core_machine)
Expand Down
Loading
Loading