Merge pull request from GHSA-5fhj-g3p3-pq9g

* Improve cranelift disassembly of stack maps

Print out extra information about stack maps such as their contents and
other related metadata available. Additionally also print out addresses
in hex to line up with the disassembly otherwise printed as well.

* Improve the `table_ops` fuzzer

* Generate more instructions by default
* Fix negative indices appearing in `table.{get,set}`
* Assert that the traps generated are expected to prevent accidental
  other errors reporting a fuzzing success.

* Fix `reftype_vregs` reported to `regalloc2`

This fixes a mistake in the register allocation of Cranelift functions
where functions using reference-typed arguments incorrectly report which
virtual registers are reference-typed values if there are vreg aliases
in play. The fix here is to apply the vreg aliases to the final list of
reftyped regs which is eventually passed to `regalloc2`.

The main consequence of this fix is that functions which previously
accidentally didn't have correct stack maps should now have the missing
stack maps.

* Add a test that `table_ops` gc's eventually

* Add a comment about new alias resolution

* Update crates/fuzzing/src/oracles.rs

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>

* Add some comments

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
This commit is contained in:
Alex Crichton
2022-07-20 11:52:23 -05:00
committed by GitHub
parent 839c4cce17
commit 2154c63de9
4 changed files with 143 additions and 26 deletions

View File

@@ -26,20 +26,39 @@ pub fn print_relocs(relocs: &[MachReloc]) -> String {
pub fn print_traps(traps: &[MachTrap]) -> String {
let mut text = String::new();
for &MachTrap { offset, code } in traps {
writeln!(text, "trap: {} at {}", code, offset).unwrap();
writeln!(text, "trap: {code} at {offset:#x}").unwrap();
}
text
}
pub fn print_stack_maps(traps: &[MachStackMap]) -> String {
let mut text = String::new();
for &MachStackMap {
for MachStackMap {
offset,
offset_end: _,
stack_map: _,
offset_end,
stack_map,
} in traps
{
writeln!(text, "add_stack_map at {}", offset).unwrap();
writeln!(
text,
"add_stack_map at {offset:#x}-{offset_end:#x} mapped_words={}",
stack_map.mapped_words()
)
.unwrap();
write!(text, " entries: ").unwrap();
let mut first = true;
for i in 0..stack_map.mapped_words() {
if !stack_map.get_bit(i as usize) {
continue;
}
if !first {
write!(text, ", ").unwrap();
} else {
first = false;
}
write!(text, "{i}").unwrap();
}
}
text
}