Class RegisterAllocator


  • public class RegisterAllocator
    extends Object
    Linear scan register allocator.
    • Constructor Detail

      • RegisterAllocator

        public RegisterAllocator​(IRMethod method,
                                 LivenessAnalysis liveness)
        Creates an allocator; nothing is assigned until allocate() runs.
        Parameters:
        method - the method whose values need slots
        liveness - the liveness result driving interval construction
    • Method Detail

      • getMethod

        public IRMethod getMethod()
        Returns:
        the method
      • getMaxLocals

        public int getMaxLocals()
        Returns:
        the max locals
      • getReservedSlotCount

        public int getReservedSlotCount()
        Returns:
        the reserved slot count
      • allocate

        public void allocate()
        Runs the linear scan, pinning parameters to the leading slots and letting later values reuse a slot only when no named source variable already owns it.
      • getHomeSlotGroups

        public Map<IRMethod.SourceLocal,​Set<SSAValue>> getHomeSlotGroups()
        The values sharing each source variable's home slot, phi results included.
        Returns:
        the live map from source variable to the values in its home slot
      • getAffinityPinnedValues

        public Set<SSAValue> getAffinityPinnedValues()
        Returns:
        the affinity pinned values
      • getRegister

        public int getRegister​(SSAValue value)
        Looks up a value's slot, allocating a fresh one and growing max locals if the main pass missed it.
        Parameters:
        value - the value to look up
        Returns:
        the slot index