Fix spillslot allocation to actually reuse spillslots. (#56)

* Fix spillslot allocation to actually reuse spillslots.

The old logic, which did some linked-list rearranging to try to probe
more-likely-to-be-free slots first and which was inherited straight from
the original IonMonkey allocator, was slightly broken (error in
translation and not in IonMonkey, to be clear): it did not get the
list-splicing right, so quite often dropped a slot on the floor and
failed to consider it for further reuse.

On some experimentation, it seems to work just as well to keep a
SmallVec of spillslot indices per size class instead, and save the last
probe-point in order to spread load throughout the allocated slots while
limiting the number of probes (to bound quadratic behavior).

This change moves the maximum slot count from 285 to 92 in `python.wasm`
from bytecodealliance/wasmtime#4214, and the maximum frame size from
2384 bytes to 752 bytes.
This commit is contained in:
Chris Fallin
2022-06-03 16:01:10 -07:00
committed by GitHub
parent 257c5ccc18
commit 427e041f1c
2 changed files with 38 additions and 47 deletions

View File

@@ -439,13 +439,25 @@ pub struct SpillSlotData {
pub ranges: LiveRangeSet,
pub class: RegClass,
pub alloc: Allocation,
pub next_spillslot: SpillSlotIndex,
}
#[derive(Clone, Debug)]
pub struct SpillSlotList {
pub first_spillslot: SpillSlotIndex,
pub last_spillslot: SpillSlotIndex,
pub slots: SmallVec<[SpillSlotIndex; 32]>,
pub probe_start: usize,
}
impl SpillSlotList {
/// Get the next spillslot index in probing order, wrapping around
/// at the end of the slots list.
pub(crate) fn next_index(&self, index: usize) -> usize {
debug_assert!(index < self.slots.len());
if index == self.slots.len() - 1 {
0
} else {
index + 1
}
}
}
#[derive(Clone, Debug)]