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.PhaseOptions, BasePhase.SharedGlobalPhaseStatecanonicalizer| 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) |
| Modifier and Type | Method and Description |
|---|---|
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) |
runAnalysisapply, apply, applyScope, codeSizeIncrease, contractorName, equals, getName, hashCode, shouldDumpAfterAtBasicLevel, shouldDumpBeforeAtBasicLevelpublic 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(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>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()