Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cranelift-frontend
: Support moving GCs with user stack maps (byteco…
…dealliance#8978) * cranelift-frontend: Support moving GCs with user stack maps This refactors the way that user stack maps work such that they are compatible with moving GCs. We now keep every GC value in a stack slot, spill to the stack slot on the value's definition, and reload from the stack slot on every use. This means that we can generate a bunch of redundant loads, but we let the mid-end's alias analysis clean that up. This has the added benefit of reducing the length of live ranges for GC values and also means we don't need to proactively spill every single live GC values at each safepoint, because we know they are already spilled. This latter bit actually helps us avoid an accidentally quadratic issue with many, long, overlapping live ranges where we would do `O(n^2)` spills for a series of safepoints that keep creating more GC refs. We also implement two further optimizations: 1. We lazily allocate slots for live GC values, which means that if a GC value is not ever live across a safepoint, then we do never allocate a stack slot for it and never spill it to the stack slot. If we didn't do this, then frames would be larger and we'd have a dead store to the stack slot that would otherwise require the mid-end to grow a dead-store-elimination pass. 2. We keep a free list of available slots that will never be used again, and we reuse slots from here when possible. This means that a chain of non-overlapping live ranges, each of which still needs to appear in some safepoint's stack map, will all reuse the same stack slot, keeping frames from being bloated. Finally, this commit also introduces some logs for the liveness analysis to ease future debugging. Co-Authored-By: Trevor Elliott <telliott@fastly.com> * review feedback --------- Co-authored-by: Trevor Elliott <telliott@fastly.com>
- Loading branch information