In wasmtime's `gc::many_live_refs` unit-test, approximately ~1K vregs are live over ~1K safepoints (actually, each vreg is live over half the safepoints on average, in a LIFO sort of arrangement). This causes a huge slowdown with the current heuristics. Basically, each vreg had a `Conflict` requirement because it had both stack uses (safepoints) and register uses (the actual def and normal use). The action in this case when processing the vreg's bundle is to split off the first use -- a conservative-but-correct approach that will always eventually split bundles far enough to get non-conflicting-requirement pieces. However, because each vreg had N stack uses followed by one register use, this meant that each had to be split N times (!) -- so we had O(n^2) splits and O(n^2) bundles by the end of the allocation. This instead implements another simple heuristic that is much better: when the requirements are conflicting, scan forward and find the exact point at which the requirements become conflicting, such that the prefix (first half prior to the split) still has no conflict, and split there. This turns the above test-case into an O(n)-bundle / O(n)-split situation.
regalloc2: another register allocator
This is a register allocator that started life as, and is about 50% still, a port of IonMonkey's backtracking register allocator to Rust. In many regards, it has been generalized, optimized, and improved since the initial port, and now supports both SSA and non-SSA use-cases.
In addition, it contains substantial amounts of testing infrastructure (fuzzing harnesses and checkers) that does not exist in the original IonMonkey allocator.
See the design overview for (much!) more detail on how the allocator works.
License
Unless otherwise specified, code in this crate is licensed under the Apache 2.0
License with LLVM Exception. This license text can be found in the file
LICENSE.
Files in the src/ion/ directory are directly ported from original C++ code in
IonMonkey, a part of the Firefox codebase. Parts of src/lib.rs are also
definitions that are directly translated from this original code. As a result,
these files are derivative works and are covered by the Mozilla Public License
(MPL) 2.0, as described in license headers in those files. Please see the
notices in relevant files for links to the original IonMonkey source files from
which they have been translated/derived. The MPL text can be found in
src/ion/LICENSE.
Parts of the code are derived from regalloc.rs: in particular,
src/checker.rs and src/domtree.rs. This crate has the same license
as regalloc.rs, so the license on these files does not differ.