The phase defined by this transform
A standard phase template
A standard phase template
A Tail Call Transformer
A Tail Call Transformer
1.1
What it does:
Finds method calls in tail-position and replaces them with jumps. A call is in a tail-position if it is the last instruction to be executed in the body of a method. This is done by recursing over the trees that may contain calls in tail-position (trees that can't contain such calls are not transformed). However, they are not that many.
Self-recursive calls in tail-position are replaced by jumps to a label at the beginning of the method. As the JVM provides no way to jump from a method to another one, non-recursive calls in tail-position are not optimized.
A method call is self-recursive if it calls the current method and the method is final (otherwise, it could be a call to an overridden method in a subclass). Furthermore, If the method has type parameters, the call must contain these parameters as type arguments. Recursive calls on a different instance are optimized. Since 'this' is not a local variable, a dummy local val is added and used as a label parameter. The backend knows to load the corresponding argument in the 'this' (local at index 0). This dummy local is never used and should be cleand up by dead code elimination (when enabled).
This phase has been moved before pattern matching to catch more of the common cases of tail recursive functions. This means that more cases should be taken into account (like nested function, and pattern cases).
If a method contains self-recursive calls, a label is added to at the beginning of its body and the calls are replaced by jumps to that label.
Assumes: Uncurry
has been run already, and no multiple
parameter lists exit.
The global environment; overridden by instantiation in Global.
The global environment; overridden by instantiation in Global.
Names of phases that must run before this phase.
Names of phases that must run before this phase.
Name of the phase that this phase must follow immediately.
Name of the phase that this phase must follow immediately.
Is this component enabled? Default is true.
Is this component enabled? Default is true.
SubComponent are added to a HashSet and two phases are the same if they have the same name
SubComponent are added to a HashSet and two phases are the same if they have the same name
True if this phase runs before all other phases.
True if this phase runs before all other phases. Usually, parser
.
True if this phase is not provided by a plug-in.
True if this phase is not provided by a plug-in.
Create a new phase which applies transformer
Create a new phase which applies transformer
The transformer factory
The phase corresponding to this subcomponent in the current compiler run
The phase corresponding to this subcomponent in the current compiler run
The name of the phase
The name of the phase
New flags defined by the phase which are not valid before
New flags defined by the phase which are not valid before
New flags defined by the phase which are not valid until immediately after it
New flags defined by the phase which are not valid until immediately after it
Names of phases required by this component.
Names of phases required by this component. Default is Nil
.
Names of phases that must run after this phase.
Names of phases that must run after this phase. Default is Nil
.
True if this phase runs after all other phases.
True if this phase runs after all other phases. Usually, terminal
.
Perform tail recursive call elimination.
1.0