public class PartialEscapePhase extends EffectsPhase<CoreProviders>
StructuredGraph
. Partial Escape Analysis on individual branches allows Graal to determine
whether an object is accessible (="escapes") outside the allocating method or thread. This
information is used to perform scalar replacement of an object allocation. This allows the
compiler to replace an allocation with its scalar field values which can then reside in
registers. Enabling the removal of memory allocation, field accesses etc.
PEA traverses a StructuredGraph
in reverse post order (ReentrantBlockIterator
),
i.e., every basic block is visited as soon as all its predecessor blocks have been visited.
PEA is built upon the machinery of EffectsPhase
and EffectsClosure
: during
traversal it collects a list of EffectList.Effect
that is applied in reverse post order
on the graph after analysis. This is necessary, as virtualized allocations can be materialized at
a later point in time of the traversal algorithm, which may causes a materialization at an early
point in the IR.
If PEA traversal encounters a VirtualizableAllocation
it tries to virtualize it, i.e.,
enqueue an effect that replaces the allocation with a VirtualInstanceNode
. If the
allocation stays virtual until the end of the traversal it can be completely scalar replaced, if
it materializes at a later point in the CFG, the phase materializes the allocation as late as
possible in the final program. This can often shift allocations inside less frequently executed
branches.
Details for the algorithm can be found in
this thesis.EffectsPhase.Closure<T>
BasePhase.ApplyScope, BasePhase.BasePhaseStatistics, BasePhase.NotApplicable, BasePhase.PhaseOptions, BasePhase.SharedGlobalPhaseState
canonicalizer
ALWAYS_APPLICABLE
Constructor and Description |
---|
PartialEscapePhase(boolean iterative,
boolean readElimination,
CanonicalizerPhase canonicalizer,
BasePhase<CoreProviders> cleanupPhase,
OptionValues options) |
PartialEscapePhase(boolean iterative,
boolean readElimination,
CanonicalizerPhase canonicalizer,
BasePhase<CoreProviders> cleanupPhase,
OptionValues options,
SchedulePhase.SchedulingStrategy strategy) |
PartialEscapePhase(boolean iterative,
CanonicalizerPhase canonicalizer,
BasePhase<CoreProviders> cleanupPhase,
OptionValues options) |
PartialEscapePhase(boolean iterative,
CanonicalizerPhase canonicalizer,
OptionValues options) |
PartialEscapePhase(int iterations,
boolean readElimination,
CanonicalizerPhase canonicalizer,
BasePhase<CoreProviders> cleanupPhase) |
Modifier and Type | Method and Description |
---|---|
Optional<BasePhase.NotApplicable> |
canApply(GraphState graphState)
Checks if all the preconditions to
BasePhase.apply(StructuredGraph, Object, boolean) the phase
are met. |
boolean |
checkContract() |
protected EffectsPhase.Closure<?> |
createEffectsClosure(CoreProviders context,
StructuredGraph.ScheduleResult schedule,
ControlFlowGraph cfg) |
protected void |
postIteration(StructuredGraph graph,
CoreProviders context,
org.graalvm.collections.EconomicSet<Node> changedNodes) |
protected void |
run(StructuredGraph graph,
CoreProviders context) |
runAnalysis
apply, apply, applyScope, codeSizeIncrease, contractorName, equals, getName, hashCode, mustApply, shouldDumpAfterAtBasicLevel, shouldDumpBeforeAtBasicLevel, updateGraphState
public PartialEscapePhase(boolean iterative, CanonicalizerPhase canonicalizer, OptionValues options)
public PartialEscapePhase(boolean iterative, CanonicalizerPhase canonicalizer, BasePhase<CoreProviders> cleanupPhase, OptionValues options)
public PartialEscapePhase(boolean iterative, boolean readElimination, CanonicalizerPhase canonicalizer, BasePhase<CoreProviders> cleanupPhase, OptionValues options)
public PartialEscapePhase(int iterations, boolean readElimination, CanonicalizerPhase canonicalizer, BasePhase<CoreProviders> cleanupPhase)
public PartialEscapePhase(boolean iterative, boolean readElimination, CanonicalizerPhase canonicalizer, BasePhase<CoreProviders> cleanupPhase, OptionValues options, SchedulePhase.SchedulingStrategy strategy)
protected void postIteration(StructuredGraph graph, CoreProviders context, org.graalvm.collections.EconomicSet<Node> changedNodes)
postIteration
in class EffectsPhase<CoreProviders>
public Optional<BasePhase.NotApplicable> canApply(GraphState graphState)
BasePhase
BasePhase.apply(StructuredGraph, Object, boolean)
the phase
are met.canApply
in class EffectsPhase<CoreProviders>
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.protected void run(StructuredGraph graph, CoreProviders context)
run
in class EffectsPhase<CoreProviders>
protected EffectsPhase.Closure<?> createEffectsClosure(CoreProviders context, StructuredGraph.ScheduleResult schedule, ControlFlowGraph cfg)
createEffectsClosure
in class EffectsPhase<CoreProviders>
public boolean checkContract()