Class ReadEliminationPhase
java.lang.Object
jdk.graal.compiler.phases.BasePhase<CoreProviders>
jdk.graal.compiler.virtual.phases.ea.EffectsPhase<CoreProviders>
jdk.graal.compiler.virtual.phases.ea.ReadEliminationPhase
- All Implemented Interfaces:
PhaseSizeContract
This phase performs read and (simple) write elimination on a graph. It operates on multiple
granularities, i.e., before and after high-tier lowering. The phase iterates the graph in a
reverse-post-order fashion ReentrantBlockIterator and tracks the currently active
value for a specific LocationIdentity, which allows the removal of subsequent reads
if no writes happen in between, etc. if the value read from memory is in a virtual register
(node).
A trivial example for read elimination can be seen below:
int i = object.fieldValue; // code not changing object.fieldValue but using i consume(object.fieldValue);Read elimination will transform this piece of code to the code below and remove the second, unnecessary, memory read of the field:
int i = object.fieldValue; // code not changing object.fieldValue but using i consume(i);
-
Nested Class Summary
Nested classes/interfaces inherited from class jdk.graal.compiler.virtual.phases.ea.EffectsPhase
EffectsPhase.Closure<T>
Nested classes/interfaces inherited from class jdk.graal.compiler.phases.BasePhase
BasePhase.ApplyScope, BasePhase.BasePhaseStatistics, BasePhase.NotApplicable, BasePhase.PhaseOptions, BasePhase.SharedGlobalPhaseState
-
Field Summary
FieldsFields inherited from class jdk.graal.compiler.virtual.phases.ea.EffectsPhase
canonicalizer
Fields inherited from class jdk.graal.compiler.phases.BasePhase
ALWAYS_APPLICABLE
-
Constructor Summary
ConstructorsConstructorDescriptionReadEliminationPhase
(CanonicalizerPhase canonicalizer) ReadEliminationPhase
(CanonicalizerPhase canonicalizer, boolean considerGuards) -
Method Summary
Modifier and TypeMethodDescriptionfloat
Returns a factor>=1
that determines what the final code size in terms of the sum of the node code sizesNodeSize
of all nodes is.protected EffectsPhase.Closure
<?> createEffectsClosure
(CoreProviders context, StructuredGraph.ScheduleResult schedule, ControlFlowGraph cfg, OptionValues options) notApplicableTo
(GraphState graphState) Gets a precondition that prevents applying this phase to a graph whose state isgraphState
.protected void
run
(StructuredGraph graph, CoreProviders context) Methods inherited from class jdk.graal.compiler.virtual.phases.ea.EffectsPhase
postIteration, runAnalysis
Methods inherited from class jdk.graal.compiler.phases.BasePhase
apply, apply, applyScope, contractorName, equals, getName, hashCode, mustApply, shouldApply, shouldDumpAfterAtBasicLevel, shouldDumpBeforeAtBasicLevel, updateGraphState
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface jdk.graal.compiler.phases.contract.PhaseSizeContract
checkContract
-
Field Details
-
considerGuards
protected final boolean considerGuards
-
-
Constructor Details
-
ReadEliminationPhase
-
ReadEliminationPhase
-
-
Method Details
-
notApplicableTo
Description copied from class:BasePhase
Gets a precondition that prevents applying this phase to a graph whose state isgraphState
.- Overrides:
notApplicableTo
in classEffectsPhase<CoreProviders>
- Parameters:
graphState
- the state of graph to which the caller wants to apply this phase- Returns:
- a
BasePhase.NotApplicable
detailing why this phase cannot be applied or a value equal toOptional.empty()
if the phase can be applied
-
run
- Overrides:
run
in classEffectsPhase<CoreProviders>
-
createEffectsClosure
protected EffectsPhase.Closure<?> createEffectsClosure(CoreProviders context, StructuredGraph.ScheduleResult schedule, ControlFlowGraph cfg, OptionValues options) - Specified by:
createEffectsClosure
in classEffectsPhase<CoreProviders>
-
codeSizeIncrease
public float codeSizeIncrease()Description copied from interface:PhaseSizeContract
Returns a factor>=1
that determines what the final code size in terms of the sum of the node code sizesNodeSize
of all nodes is.- Specified by:
codeSizeIncrease
in interfacePhaseSizeContract
- Overrides:
codeSizeIncrease
in classBasePhase<CoreProviders>
- Returns:
- a factor that determines how much the code size can be increased by this phase
-