Skip to content

Commit 31728d2

Browse files
committed
[GR-41842] CTW phase plan fuzzing fixes
PullRequest: graal/12956
2 parents bcdf565 + 0a77ea9 commit 31728d2

File tree

66 files changed

+261
-260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+261
-260
lines changed

compiler/src/org.graalvm.compiler.core.amd64/src/org/graalvm/compiler/core/amd64/UseTrappingDivPhase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private static boolean conditionIsZeroCheck(LogicNode condition, ValueNode divis
8080
}
8181

8282
@Override
83-
public Optional<NotApplicable> canApply(GraphState graphState) {
83+
public Optional<NotApplicable> notApplicableTo(GraphState graphState) {
8484
return ALWAYS_APPLICABLE;
8585
}
8686

@@ -209,7 +209,7 @@ public void actionBeforeGuardRewrite(DeoptimizingFixedWithNextNode trappingVersi
209209
}
210210

211211
@Override
212-
public Optional<NotApplicable> canApply(GraphState graphState) {
212+
public Optional<NotApplicable> notApplicableTo(GraphState graphState) {
213213
return ALWAYS_APPLICABLE;
214214
}
215215

compiler/src/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/SingleRunSubphaseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static class EmptyPhase extends SingleRunSubphase<CoreProviders> {
4949
int mutableCounter = 0;
5050

5151
@Override
52-
public Optional<NotApplicable> canApply(GraphState graphState) {
52+
public Optional<NotApplicable> notApplicableTo(GraphState graphState) {
5353
return ALWAYS_APPLICABLE;
5454
}
5555

compiler/src/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/TestBasePhase.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
import org.graalvm.compiler.phases.BasePhase;
3131

3232
/**
33-
* Base class for {@link BasePhase}s used in tests. The {@link BasePhase#canApply(GraphState)}
34-
* method of this class always returns {@link Optional#empty}.
33+
* Base class for {@link BasePhase}s used in tests. The
34+
* {@link BasePhase#notApplicableTo(GraphState)} method of this class always returns
35+
* {@link Optional#empty}.
3536
*/
3637
public abstract class TestBasePhase<C> extends BasePhase<C> {
3738
@Override
38-
public Optional<NotApplicable> canApply(GraphState graphState) {
39+
public Optional<NotApplicable> notApplicableTo(GraphState graphState) {
3940
return ALWAYS_APPLICABLE;
4041
}
4142
}

compiler/src/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/TestPhase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
import org.graalvm.compiler.phases.Phase;
3232

3333
/**
34-
* Base class for {@link Phase}s used in tests. The {@link BasePhase#canApply(GraphState)} method of
35-
* this class always returns {@link Optional#empty}.
34+
* Base class for {@link Phase}s used in tests. The {@link BasePhase#notApplicableTo(GraphState)}
35+
* method of this class always returns {@link Optional#empty}.
3636
*/
3737
public abstract class TestPhase extends Phase {
3838
@Override
39-
public Optional<NotApplicable> canApply(GraphState graphState) {
39+
public Optional<NotApplicable> notApplicableTo(GraphState graphState) {
4040
return ALWAYS_APPLICABLE;
4141
}
4242
}

compiler/src/org.graalvm.compiler.core/src/org/graalvm/compiler/core/phases/fuzzing/AbstractCompilationPlan.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ protected AbstractCompilationPlan(AbstractTierPlan<HighTierContext> highTier,
9696
public void verifyCompilationPlan(GraphState graphState) {
9797
GraphState simulationGraphState = graphState.copy();
9898
addInitialRequiredStages(simulationGraphState);
99-
Optional<NotApplicable> canApplyTier = highTier.getPhaseSuite().canApply(simulationGraphState);
100-
GraalError.guarantee(canApplyTier.isEmpty(), "Cannot apply the high tier of this compilation plan because %s.%n%s", canApplyTier.orElse(null), this);
99+
Optional<NotApplicable> tierNotApplicable = highTier.getPhaseSuite().notApplicableTo(simulationGraphState);
100+
GraalError.guarantee(tierNotApplicable.isEmpty(), "Cannot apply the high tier of this compilation plan because %s.%n%s", tierNotApplicable.orElse(null), this);
101101
highTier.updateGraphState(simulationGraphState);
102-
canApplyTier = midTier.getPhaseSuite().canApply(simulationGraphState);
103-
GraalError.guarantee(canApplyTier.isEmpty(), "Cannot apply the mid tier of this compilation plan because %s.%n%s", canApplyTier.orElse(null), this);
102+
tierNotApplicable = midTier.getPhaseSuite().notApplicableTo(simulationGraphState);
103+
GraalError.guarantee(tierNotApplicable.isEmpty(), "Cannot apply the mid tier of this compilation plan because %s.%n%s", tierNotApplicable.orElse(null), this);
104104
midTier.updateGraphState(simulationGraphState);
105-
canApplyTier = lowTier.getPhaseSuite().canApply(simulationGraphState);
106-
GraalError.guarantee(canApplyTier.isEmpty(), "Cannot apply the low tier of this compilation plan because %s.%n%s", canApplyTier.orElse(null), this);
105+
tierNotApplicable = lowTier.getPhaseSuite().notApplicableTo(simulationGraphState);
106+
GraalError.guarantee(tierNotApplicable.isEmpty(), "Cannot apply the low tier of this compilation plan because %s.%n%s", tierNotApplicable.orElse(null), this);
107107
lowTier.updateGraphState(simulationGraphState);
108108
GraalError.guarantee(simulationGraphState.hasAllMandatoryStages(getMandatoryStages()), "This compilation plan does not apply all mandatory stages.%n%s", this);
109109
GraalError.guarantee(!simulationGraphState.requiresFutureStages(), "This compilation plan:%n%s%nhas remaining requirements: %s", this, simulationGraphState.getFutureRequiredStages());

compiler/src/org.graalvm.compiler.core/src/org/graalvm/compiler/core/phases/fuzzing/MinimalFuzzedTierPlan.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected static <C> MinimalFuzzedTierPlan<C> create(List<BasePhase<? super C>>
112112
* <li>Loop over the phases that modify the {@link GraphState} (see
113113
* {@link #getSingleApplyPhases()}) by applying a mandatory stage and insert them in the tier
114114
* plan if the resulting {@link MinimalFuzzedTierPlan#getPhaseSuite} can be applied (see
115-
* {@link PhaseSuite#canApply}). <br>
115+
* {@link PhaseSuite#notApplicableTo(GraphState)}). <br>
116116
* This is done until all the {@code mandatoryStages} are applied by one of the phase in the
117117
* tier plan or the maximum number of attempts has been reached. <br>
118118
* </li>
@@ -258,15 +258,15 @@ protected void insertPhasesThatMustApply(GraphState graphState) {
258258

259259
/**
260260
* Inserts a phase at the given index in the tier plan if it results in a correct plan (see
261-
* {@link BasePhase#canApply(GraphState)}).
261+
* {@link BasePhase#notApplicableTo(GraphState)}).
262262
*
263263
* @return {@code true} if the phase was inserted successfully, {@code false} otherwise.
264264
*/
265265
protected boolean insertPhaseAtIndex(BasePhase<? super C> phase, int index, GraphState graphState) {
266266
PhaseSuite<C> newFuzzedPhaseSuite = getPhaseSuite().copy();
267267
newFuzzedPhaseSuite.insertAtIndex(index, phase);
268-
Optional<NotApplicable> canNewSuiteBeApplied = newFuzzedPhaseSuite.canApply(graphState.copy());
269-
if (canNewSuiteBeApplied.isEmpty()) {
268+
Optional<NotApplicable> suiteNotApplicable = newFuzzedPhaseSuite.notApplicableTo(graphState.copy());
269+
if (suiteNotApplicable.isEmpty()) {
270270
getIgnoredPhases().remove(phase);
271271
setPhaseSuite(newFuzzedPhaseSuite);
272272
return true;

compiler/src/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotSuitesProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected PhaseSuite<HighTierContext> createGraphBuilderSuite() {
102102
private boolean appendGraphEncoderTest(PhaseSuite<HighTierContext> suite) {
103103
suite.appendPhase(new BasePhase<HighTierContext>() {
104104
@Override
105-
public Optional<NotApplicable> canApply(GraphState graphState) {
105+
public Optional<NotApplicable> notApplicableTo(GraphState graphState) {
106106
return ALWAYS_APPLICABLE;
107107
}
108108

compiler/src/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/phases/OnStackReplacementPhase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private static boolean supportOSRWithLocks(OptionValues options) {
107107
private static final SpeculationReasonGroup OSR_LOCAL_SPECULATIONS = new SpeculationReasonGroup("OSRLocal", int.class, Stamp.class, int.class);
108108

109109
@Override
110-
public Optional<NotApplicable> canApply(GraphState graphState) {
110+
public Optional<NotApplicable> notApplicableTo(GraphState graphState) {
111111
return ALWAYS_APPLICABLE;
112112
}
113113

compiler/src/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/stubs/Stub.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ protected void checkSafeDataReference(DataPatch data) {
301301

302302
private static class EmptyHighTier extends BasePhase<HighTierContext> {
303303
@Override
304-
public Optional<NotApplicable> canApply(GraphState graphState) {
304+
public Optional<NotApplicable> notApplicableTo(GraphState graphState) {
305305
return ALWAYS_APPLICABLE;
306306
}
307307

compiler/src/org.graalvm.compiler.java/src/org/graalvm/compiler/java/GraphBuilderPhase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public boolean checkContract() {
5454
}
5555

5656
@Override
57-
public Optional<NotApplicable> canApply(GraphState graphState) {
57+
public Optional<NotApplicable> notApplicableTo(GraphState graphState) {
5858
return ALWAYS_APPLICABLE;
5959
}
6060

@@ -88,7 +88,7 @@ public boolean checkContract() {
8888
}
8989

9090
@Override
91-
public Optional<NotApplicable> canApply(GraphState graphState) {
91+
public Optional<NotApplicable> notApplicableTo(GraphState graphState) {
9292
return ALWAYS_APPLICABLE;
9393
}
9494

0 commit comments

Comments
 (0)