public abstract class BasePhase<C> extends Object implements PhaseSizeContract
SingleRunSubphase
. There will be one global instance for each compiler phase that is
shared for all compilations. VM-, target- and compilation-specific data can be passed with a
context object.Modifier and Type | Class and Description |
---|---|
static interface |
BasePhase.ApplyScope
Similar to a
DebugCloseable but the BasePhase.ApplyScope.close(java.lang.Throwable) operation gets a Throwable
argument indicating whether the call to BasePhase.run(org.graalvm.compiler.nodes.StructuredGraph, C) completed normally or with an exception. |
static class |
BasePhase.BasePhaseStatistics |
static class |
BasePhase.NotApplicable
Explains why a phase cannot be applied to a given graph.
|
static class |
BasePhase.PhaseOptions |
static interface |
BasePhase.SharedGlobalPhaseState
Marker interface for fields inside phase classes that capture some state that is shared
across all compilations.
|
Modifier and Type | Field and Description |
---|---|
static Optional<BasePhase.NotApplicable> |
ALWAYS_APPLICABLE
Represents that a phase is applicable and will have
BasePhase.canApply(org.graalvm.compiler.nodes.GraphState) that will return
Optional.empty() . |
Modifier | Constructor and Description |
---|---|
protected |
BasePhase() |
Modifier and Type | Method and Description |
---|---|
void |
apply(StructuredGraph graph,
C context) |
void |
apply(StructuredGraph graph,
C context,
boolean dumpGraph) |
protected BasePhase.ApplyScope |
applyScope(StructuredGraph graph,
C context)
Return an
BasePhase.ApplyScope which will surround all the work performed by the call to
BasePhase.run(org.graalvm.compiler.nodes.StructuredGraph, C) in BasePhase.apply(StructuredGraph, Object, boolean) . |
Optional<BasePhase.NotApplicable> |
canApply(GraphState graphState)
Checks if all the preconditions to
BasePhase.apply(StructuredGraph, Object, boolean) the phase
are met. |
float |
codeSizeIncrease()
Returns a factor
>=1 that determines what the final code size in terms of the sum of
the node code sizes NodeSize of all nodes is. |
String |
contractorName() |
boolean |
equals(Object obj) |
CharSequence |
getName() |
int |
hashCode()
Hashing a phase is used to implement and test phase plan serialization.
|
boolean |
mustApply(GraphState graphState)
Checks if a phase must be applied at some point in the future for the compilation of a
StructuredGraph to be correct. |
protected abstract void |
run(StructuredGraph graph,
C context) |
protected boolean |
shouldDumpAfterAtBasicLevel() |
protected boolean |
shouldDumpBeforeAtBasicLevel() |
void |
updateGraphState(GraphState graphState)
Applies all the changes on the
GraphState caused by
BasePhase.apply(StructuredGraph, Object, boolean) . |
clone, getClass, notify, notifyAll, toString, wait, wait, wait
checkContract
public static final Optional<BasePhase.NotApplicable> ALWAYS_APPLICABLE
BasePhase.canApply(org.graalvm.compiler.nodes.GraphState)
that will return
Optional.empty()
.public boolean mustApply(GraphState graphState)
StructuredGraph
to be correct.graphState
- represents the state of the StructuredGraph
used for compilation
and contains the required stages
that help in determining if a phase must be applied.public Optional<BasePhase.NotApplicable> canApply(GraphState graphState)
BasePhase.apply(StructuredGraph, Object, boolean)
the phase
are met.graphState
- represents the state of the StructuredGraph
used for compilation
and contains the required information to determine if a phase can be applied.Optional.empty()
if all the checks pass, Optional#of(NotApplicable)
containing why this phase is not applicable on this graphState
otherwise.public final void apply(StructuredGraph graph, C context)
public void updateGraphState(GraphState graphState)
GraphState
caused by
BasePhase.apply(StructuredGraph, Object, boolean)
.graphState
- represents the state of the StructuredGraph
used for compilation.protected boolean shouldDumpBeforeAtBasicLevel()
protected boolean shouldDumpAfterAtBasicLevel()
protected BasePhase.ApplyScope applyScope(StructuredGraph graph, C context)
BasePhase.ApplyScope
which will surround all the work performed by the call to
BasePhase.run(org.graalvm.compiler.nodes.StructuredGraph, C)
in BasePhase.apply(StructuredGraph, Object, boolean)
. This allows subclaseses to
inject work which will performed before and after the application of this phase.public final void apply(StructuredGraph graph, C context, boolean dumpGraph)
public CharSequence getName()
protected abstract void run(StructuredGraph graph, C context)
public String contractorName()
contractorName
in interface PhaseSizeContract
public float codeSizeIncrease()
PhaseSizeContract
>=1
that determines what the final code size in terms of the sum of
the node code sizes NodeSize
of all nodes is.codeSizeIncrease
in interface PhaseSizeContract
public int hashCode()
PhaseInfo
annotation is introduced (c.f. NodeInfo
). The hash code returned
needs to be stable across VM executions.public boolean equals(Object obj)
equals
in class Object
BasePhase.hashCode()