Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[graph]
targets = [
{ triple = "x86_64-unknown-linux-gnu" },
{ triple = "x86_64-apple-darwin" },
Expand All @@ -7,8 +8,6 @@ targets = [

# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
[advisories]
vulnerability = "deny"
unmaintained = "deny"
yanked = "deny"
ignore = []

Expand All @@ -19,6 +18,7 @@ allow = [
"Apache-2.0",
"MIT",
"Unicode-DFS-2016",
"Unicode-3.0",
]

# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
Expand Down
30 changes: 22 additions & 8 deletions src/ion/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,33 @@ impl<'a, F: Function> Env<'a, F> {
ranges_to
);

// Two non-empty lists of LiveRanges: concatenate and
// sort. This is faster than a mergesort-like merge into a new
// list, empirically.
let empty_vec = LiveRangeList::new_in(self.ctx.bump());
let from_list = core::mem::replace(&mut self.bundles[from].ranges, empty_vec);
let mut from_list = core::mem::replace(&mut self.bundles[from].ranges, empty_vec);
for entry in &from_list {
self.ranges[entry.index].bundle = to;
}

self.bundles[to].ranges.extend_from_slice(&from_list[..]);
self.bundles[to]
.ranges
.sort_unstable_by_key(|entry| entry.range.from);
if from_list.len() == 1 {
// Optimize for the common case where `from_list` contains a single
// item. Using a binary search to find the insertion point and then
// calling `insert` is more efficient than re-sorting the entire
// list, specially after the changes in sorting algorithms introduced
// in rustc 1.81.
// See: https://github.com/bytecodealliance/regalloc2/issues/203
let single_entry = from_list.pop().unwrap();
let pos = self.bundles[to]
.ranges
.binary_search_by_key(&single_entry.range.from, |entry| entry.range.from)
.unwrap_or_else(|pos| pos);
self.bundles[to].ranges.insert(pos, single_entry);
} else {
// Two non-empty lists of LiveRanges: concatenate and sort. This is
// faster than a mergesort-like merge into a new list, empirically.
self.bundles[to].ranges.extend_from_slice(&from_list[..]);
self.bundles[to]
.ranges
.sort_unstable_by_key(|entry| entry.range.from);
}

if self.annotations_enabled {
trace!("merging: merged = {:?}", self.bundles[to].ranges);
Expand Down
Loading