Skip to content

Commit 9ff4d02

Browse files
committed
[WIP] Add fixed stack slots to the fuzzer
This doesn't work yet due to bytecodealliance#14
1 parent 23c739d commit 9ff4d02

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/fuzzing/func.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ impl Func {
465465
let mut fixed = vec![];
466466
for _ in 0..u.int_in_range(0..=operands.len() - 1)? {
467467
// Pick an operand and make it a fixed reg.
468-
let fixed_reg = PReg::new(u.int_in_range(0..=30)?, RegClass::Int);
468+
let fixed_reg = PReg::new(u.int_in_range(0..=63)?, RegClass::Int);
469469
if fixed.contains(&fixed_reg) {
470470
break;
471471
}
@@ -582,15 +582,18 @@ impl std::fmt::Debug for Func {
582582
}
583583

584584
pub fn machine_env() -> MachineEnv {
585-
// Reg 31 is the scratch reg.
586-
let regs: Vec<PReg> = (0..31).map(|i| PReg::new(i, RegClass::Int)).collect();
587-
let preferred_regs_by_class: [Vec<PReg>; 2] = [regs.iter().cloned().take(24).collect(), vec![]];
588-
let non_preferred_regs_by_class: [Vec<PReg>; 2] =
589-
[regs.iter().cloned().skip(24).collect(), vec![]];
590-
let scratch_by_class: [PReg; 2] = [PReg::new(31, RegClass::Int), PReg::new(0, RegClass::Float)];
585+
// Reg 63 is the scratch reg.
586+
fn regs(r: std::ops::Range<usize>) -> Vec<PReg> {
587+
r.map(|i| PReg::new(i, RegClass::Int)).collect()
588+
}
589+
let preferred_regs_by_class: [Vec<PReg>; 2] = [regs(0..24), vec![]];
590+
let non_preferred_regs_by_class: [Vec<PReg>; 2] = [regs(24..32), vec![]];
591+
let scratch_by_class: [PReg; 2] = [PReg::new(63, RegClass::Int), PReg::new(0, RegClass::Float)];
592+
let fixed_stack_slots = regs(32..63);
591593
MachineEnv {
592594
preferred_regs_by_class,
593595
non_preferred_regs_by_class,
594596
scratch_by_class,
597+
fixed_stack_slots,
595598
}
596599
}

0 commit comments

Comments
 (0)