Class RegisterAllocator


  • public class RegisterAllocator
    extends java.lang.Object
    RegisterAllocator performs analysis on a control flow graph and determines the minimum amount of local variables needed in a method.
    See Also:
    LocalVariable
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int maxLocals()
      Returns the maximum number of local variables used by the cfg after its "registers" (local variables) have been allocated.
      LocalVariable newLocal​(Type type)
      Creates a new local variable in this method (as modeled by the cfg).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RegisterAllocator

        public RegisterAllocator​(FlowGraph cfg,
                                 Liveness liveness)
        Constructor. Builds an interference graph based on the expression nodes found in liveness. Traverses the graph and determines which nodes needs to be precolored and which nodes can be coalesced (move statements). Nodes are coalesced and local variables are assigned to expressions.
        See Also:
        FlowGraph, LocalVariable
    • Method Detail

      • maxLocals

        public int maxLocals()
        Returns the maximum number of local variables used by the cfg after its "registers" (local variables) have been allocated.
      • newLocal

        public LocalVariable newLocal​(Type type)
        Creates a new local variable in this method (as modeled by the cfg). Updates the number of local variables appropriately.