Class CompilerPass

java.lang.Object
org.jruby.ir.passes.CompilerPass
Direct Known Subclasses:
AddCallProtocolInstructions, AddLocalVarLoadStoreInstructions, AddMissingInitsPass, DeadCodeElimination, DominatorTreeBuilder, EnsureTempsAssigned, LiveVariableAnalysis, LocalOptimizationPass, OptimizeDelegationPass, OptimizeDynScopesPass, UnboxingPass

public abstract class CompilerPass extends Object
A mechanism for executing code against an IRScope or transforming the IRScopes dependent data. A Compiler pass may or may not affect the state of an IRScope (possibly including any child IRScopes) and it may or may not depend on other compiler passes to execute first. For dependencies between compiler passes, getDependencies will return a list of all dependent passes. Those passes in turn will end up having their own dependencies. The order of execution is depth-first, but if the pass recognizes that the data it depends on already exists, then it does not run the pass. It will just return the existing data. If you want to guarantee (re)execution, then you should call invalidate().
  • Constructor Details

    • CompilerPass

      public CompilerPass()
  • Method Details

    • getLabel

      public abstract String getLabel()
      What is the user-friendly name of this compiler pass
    • getShortLabel

      public String getShortLabel()
      Shorter label
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • execute

      public abstract Object execute(FullInterpreterContext fic, Object... dependencyData)
      Meat of an individual pass. run will call this after dependency resolution.
      Parameters:
      fic - is the FullInterpreterContext to run this pass on
      dependencyData - is the data supplied to this pass to use to execute the pass
    • getDependencies

      public List<Class<? extends CompilerPass>> getDependencies()
    • previouslyRun

      public Object previouslyRun(FullInterpreterContext fic)
      If this pass has been previous run, then return the data from that last run. Specific scopes can override this behavior.
      Returns:
      data or null if it needs to be run
    • invalidate

      public boolean invalidate(FullInterpreterContext fic)
      The data that this pass is responsible for will get invalidated so that if this pass is then executed it will generate new pass data. Note that some data will destructively manipulate dependent compiler pass data. In that case, the pass may wipe more than just it's data. In that case, an execute() should still rebuild everything fine because all compiler passes list their dependencies.
      Parameters:
      fic - is where the pass stores its data.
      Returns:
      true if invalidation succeeded, false otherwise.
    • run

      protected Object run(FullInterpreterContext fic, boolean force, boolean childScope)
    • run

      public Object run(FullInterpreterContext fic, boolean force)
    • run

      public Object run(FullInterpreterContext fic)
    • createPassInstance

      public static CompilerPass createPassInstance(Class<? extends CompilerPass> passClass)
    • createPassInstance

      public static CompilerPass createPassInstance(String passClassName)
    • getPassesFromString

      public static List<CompilerPass> getPassesFromString(String passList, String defaultPassList)