Skip to content

Commit 8f0f345

Browse files
committed
Backport #442
1 parent 704f410 commit 8f0f345

25 files changed

+82
-82
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version = "0.24.12"
55
license = "MIT"
66
authors = ["Nervos Core Dev <dev@nervos.org>"]
77
edition = "2021"
8-
rust-version = "1.75.0"
8+
rust-version = "1.81.0"
99
build = "build.rs"
1010
exclude = ["/benches", "/tests"]
1111
homepage = "https://github.com/nervosnetwork/ckb-vm"
@@ -54,3 +54,6 @@ harness = false
5454
name = "vm_benchmark"
5555
path = "benches/vm_benchmark.rs"
5656
harness = false
57+
58+
[lints.rust]
59+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(has_asm)'] }

benches/vm_benchmark.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn asm_benchmark(c: &mut Criterion) {
4040
"bar",
4141
].into_iter().map(|a| Ok(a.into()));
4242
b.iter(|| {
43-
let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::max_value());
43+
let asm_core = AsmCoreMachine::new(ISA_IMC, VERSION0, u64::MAX);
4444
let core = DefaultMachineBuilder::new(asm_core).build();
4545
let mut machine = AsmMachine::new(core);
4646
machine.load_program(&buffer, args.clone()).unwrap();
@@ -61,7 +61,7 @@ fn mop_benchmark(c: &mut Criterion) {
6161
"bar",
6262
].into_iter().map(|a| Ok(a.into()));
6363
b.iter(|| {
64-
let asm_core = AsmCoreMachine::new(ISA_IMC | ISA_B | ISA_MOP, VERSION2, u64::max_value());
64+
let asm_core = AsmCoreMachine::new(ISA_IMC | ISA_B | ISA_MOP, VERSION2, u64::MAX);
6565
let core = DefaultMachineBuilder::<Box<AsmCoreMachine>>::new(asm_core)
6666
.build();
6767
let mut machine = AsmMachine::new(core);

definitions/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version = "0.24.12"
55
license = "MIT"
66
authors = ["Nervos Core Dev <dev@nervos.org>"]
77
edition = "2021"
8-
rust-version = "1.75.0"
8+
rust-version = "1.81.0"
99
autobins = false
1010
homepage = "https://github.com/nervosnetwork/ckb-vm"
1111
repository = "https://github.com/nervosnetwork/ckb-vm"

definitions/src/asm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ impl AsmCoreMachine {
117117
machine.frames_size = (memory_size / MEMORY_FRAMESIZE) as u64;
118118
machine.flags_size = (memory_size / RISCV_PAGESIZE) as u64;
119119

120-
machine.last_read_frame = u64::max_value();
121-
machine.last_write_page = u64::max_value();
120+
machine.last_read_frame = u64::MAX;
121+
machine.last_write_page = u64::MAX;
122122

123123
machine
124124
}

definitions/src/instructions.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ macro_rules! __for_each_inst_inner {
292292
/// a callback macro that takes (at least) 3 arguments:
293293
///
294294
/// 1. $name: an identifier containing the full defined opcode name,
295-
/// e.g., OP_ADD
295+
/// e.g., OP_ADD
296296
/// 2. $real_name: an identifier containing just the opcode part, e.g., ADD
297297
/// 3. $code: an expr containing the actual opcode number
298298
///
@@ -323,10 +323,10 @@ macro_rules! for_each_inst2 {
323323
/// arguments:
324324
///
325325
/// * A callback macro that takes the exact same arguments as callback
326-
/// macro in +for_each_inst+
326+
/// macro in +for_each_inst+
327327
/// * A value expression containing the actual value to match against.
328328
/// * An expression used as wildcard matches when the passed value does
329-
/// not match any opcode
329+
/// not match any opcode
330330
///
331331
/// * Free variables are attached to the variants ending with match1, match2, etc.
332332
#[macro_export]
@@ -356,7 +356,7 @@ macro_rules! for_each_inst_match2 {
356356
/// Generates an array on all instructions
357357
///
358358
/// * A callback macro that takes the exact same arguments as callback
359-
/// macro in +for_each_inst+
359+
/// macro in +for_each_inst+
360360
///
361361
/// * Free variables are attached to the variants ending with fold1, fold2, etc.
362362
#[macro_export]

examples/check_real_memory.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn get_current_memory_linux() -> usize {
6969
}
7070

7171
fn get_current_memory() -> usize {
72-
if !cfg!(linux) {
72+
if !cfg!(target_os = "linux") {
7373
get_current_memory_linux()
7474
} else {
7575
let pid = format!("{}", id());
@@ -168,8 +168,7 @@ fn check_asm(memory_size: usize) -> Result<(), ()> {
168168
);
169169
println!("Base memory: {}", get_current_memory());
170170
for _ in 0..G_CHECK_LOOP {
171-
let asm_core =
172-
AsmCoreMachine::new_with_memory(ISA_IMC, VERSION0, u64::max_value(), memory_size);
171+
let asm_core = AsmCoreMachine::new_with_memory(ISA_IMC, VERSION0, u64::MAX, memory_size);
173172
let core = DefaultMachineBuilder::new(asm_core).build();
174173
let mut machine = AsmMachine::new(core);
175174
machine
@@ -193,8 +192,7 @@ fn check_asm_in_thread(memory_size: usize) -> Result<(), ()> {
193192
);
194193
println!("Base memory: {}", get_current_memory());
195194
for _ in 0..G_CHECK_LOOP {
196-
let asm_core =
197-
AsmCoreMachine::new_with_memory(ISA_IMC, VERSION0, u64::max_value(), memory_size);
195+
let asm_core = AsmCoreMachine::new_with_memory(ISA_IMC, VERSION0, u64::MAX, memory_size);
198196
let core = DefaultMachineBuilder::new(asm_core).build();
199197
let mut machine = AsmMachine::new(core);
200198
machine

fuzz/fuzz_targets/snapshot2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl DataSource<u32> for DummyData {
6565

6666
fn build_machine() -> DefaultMachine<Box<AsmCoreMachine>> {
6767
let isa = ISA_IMC | ISA_A | ISA_B | ISA_MOP;
68-
let core_machine = AsmCoreMachine::new(isa, VERSION2, u64::max_value());
68+
let core_machine = AsmCoreMachine::new(isa, VERSION2, u64::MAX);
6969
DefaultMachineBuilder::new(core_machine).build()
7070
}
7171

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.75.0
1+
1.81.0

src/bits.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ mod tests {
2424
assert_eq!(16, roundup(15, 16));
2525
assert_eq!(16, roundup(16, 16));
2626
assert_eq!(32, roundup(17, 16));
27-
assert_eq!(u64::max_value() - 15, roundup(u64::max_value() - 15, 16));
28-
assert_eq!(0, roundup(u64::max_value(), 16));
27+
assert_eq!(u64::MAX - 15, roundup(u64::MAX - 15, 16));
28+
assert_eq!(0, roundup(u64::MAX, 16));
2929
}
3030

3131
#[test]
@@ -35,7 +35,7 @@ mod tests {
3535
assert_eq!(0, rounddown(15, 16));
3636
assert_eq!(16, rounddown(16, 16));
3737
assert_eq!(16, rounddown(17, 16));
38-
assert_eq!(u64::max_value() - 15, rounddown(u64::max_value(), 16));
38+
assert_eq!(u64::MAX - 15, rounddown(u64::MAX, 16));
3939
}
4040

4141
proptest! {

src/instructions/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ impl Register for Value {
147147
}
148148

149149
fn min_value() -> Value {
150-
Value::Imm(u64::min_value())
150+
Value::Imm(u64::MIN)
151151
}
152152

153153
fn max_value() -> Value {
154-
Value::Imm(u64::max_value())
154+
Value::Imm(u64::MAX)
155155
}
156156

157157
fn eq(&self, other: &Value) -> Value {

0 commit comments

Comments
 (0)