Top Description Fields Constructors Methods
org.jruby.ir.passes

public abstract Class CompilerPass

extends Object
Class Inheritance
Known Direct Subclasses
org.jruby.ir.passes.DeadCodeElimination, org.jruby.ir.passes.DominatorTreeBuilder, org.jruby.ir.passes.EnsureTempsAssigned, org.jruby.ir.passes.LiveVariableAnalysis, org.jruby.ir.passes.LocalOptimizationPass, org.jruby.ir.passes.OptimizeDelegationPass, org.jruby.ir.passes.OptimizeDynScopesPass, org.jruby.ir.passes.UnboxingPass, org.jruby.ir.passes.AddCallProtocolInstructions, org.jruby.ir.passes.AddLocalVarLoadStoreInstructions, org.jruby.ir.passes.AddMissingInitsPass
Imports
org.jruby.ir.interpreter.FullInterpreterContext, org.jruby.util.StringSupport, org.jruby.util.cli.Options, org.jruby.util.log.Logger, .LoggerFactory, java.lang.reflect.InvocationTargetException, java.util.ArrayList, .Collections, .List

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().

Field Summary

Modifier and TypeField and Description
pack-priv static final Logger
private static final List<Class<? extends CompilerPass>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static CompilerPass
createPassInstance(Class<? extends CompilerPass> passClass)

public static CompilerPass
createPassInstance(String passClassName)

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public abstract Object
execute(FullInterpreterContext
is the FullInterpreterContext to run this pass on
fic
,
Object...
is the data supplied to this pass to use to execute the pass
dependencyData
)

Meat of an individual pass.

public List<Class<? extends CompilerPass>>
public abstract String
getLabel()

What is the user-friendly name of this compiler pass

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

public String
getShortLabel()

Shorter label

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean

Returns:

true if invalidation succeeded, false otherwise.
invalidate
(FullInterpreterContext
is where the pass stores its data.
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.

private Object
makeSureDependencyHasRunOnce(Class<? extends CompilerPass> passClass, FullInterpreterContext fic, boolean childScope)

public Object

Returns:

data or null if it needs to be run
previouslyRun
(FullInterpreterContext fic)

If this pass has been previous run, then return the data from that last run.

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

public Object
run(FullInterpreterContext fic, boolean force)

public Object
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
pack-priv static final Logger LOG
NO_DEPENDENCIESback to summary
private static final List<Class<? extends CompilerPass>> NO_DEPENDENCIES

Constructor Detail

CompilerPassback to summary
public CompilerPass()

Method Detail

createPassInstanceback to summary
public static CompilerPass createPassInstance(Class<? extends CompilerPass> passClass)
createPassInstanceback to summary
public static CompilerPass createPassInstance(String passClassName)
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
executeback to summary
public abstract Object execute(FullInterpreterContext fic, Object... dependencyData)

Meat of an individual pass. run will call this after dependency resolution.

Parameters
fic:FullInterpreterContext

is the FullInterpreterContext to run this pass on

dependencyData:Object[]

is the data supplied to this pass to use to execute the pass

getDependenciesback to summary
public List<Class<? extends CompilerPass>> getDependencies()
getLabelback to summary
public abstract String getLabel()

What is the user-friendly name of this compiler pass

getPassesFromStringback to summary
public static List<CompilerPass> getPassesFromString(String passList, String defaultPassList)
getShortLabelback to summary
public String getShortLabel()

Shorter label

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
invalidateback to summary
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:FullInterpreterContext

is where the pass stores its data.

Returns:boolean

true if invalidation succeeded, false otherwise.

makeSureDependencyHasRunOnceback to summary
private Object makeSureDependencyHasRunOnce(Class<? extends CompilerPass> passClass, FullInterpreterContext fic, boolean childScope)
previouslyRunback to summary
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:Object

data or null if it needs to be run

runback to summary
protected Object run(FullInterpreterContext fic, boolean force, boolean childScope)
runback to summary
public Object run(FullInterpreterContext fic, boolean force)
runback to summary
public Object run(FullInterpreterContext fic)