-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GR-43361] [GR-50205] Whole-Program Sparse Conditional Constant Propa…
…gation PullRequest: graal/18609
- Loading branch information
Showing
52 changed files
with
2,295 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
....oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/AlwaysEnabledPredicateFlow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Oracle designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Oracle in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
package com.oracle.graal.pointsto.flow; | ||
|
||
import com.oracle.graal.pointsto.typestate.TypeState; | ||
|
||
import jdk.vm.ci.code.BytecodePosition; | ||
|
||
/** | ||
* Always-enabled global flow that is used as a predicate before any other suitable flow is | ||
* available. | ||
*/ | ||
public class AlwaysEnabledPredicateFlow extends TypeFlow<BytecodePosition> implements GlobalFlow { | ||
|
||
public AlwaysEnabledPredicateFlow() { | ||
/* We use any primitive state here just to make sure the state is always non-empty. */ | ||
super(TypeState.anyPrimitiveState()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...rc/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/BooleanCheckTypeFlow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Oracle designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Oracle in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
package com.oracle.graal.pointsto.flow; | ||
|
||
import com.oracle.graal.pointsto.PointsToAnalysis; | ||
import com.oracle.graal.pointsto.meta.AnalysisType; | ||
import com.oracle.graal.pointsto.typestate.TypeState; | ||
import com.oracle.graal.pointsto.util.AnalysisError; | ||
|
||
import jdk.vm.ci.code.BytecodePosition; | ||
|
||
/** | ||
* This flow represents a boolean check, i.e. a null check, type check, or primitive check that | ||
* converts its inputs into boolean values. Instances of this class are used as conditions for | ||
* {@link ConditionalFlow}. | ||
*/ | ||
public abstract class BooleanCheckTypeFlow extends TypeFlow<BytecodePosition> { | ||
|
||
public BooleanCheckTypeFlow(BytecodePosition position, AnalysisType declaredType) { | ||
super(position, declaredType); | ||
} | ||
|
||
protected BooleanCheckTypeFlow(BooleanCheckTypeFlow original, MethodFlowsGraph methodFlows) { | ||
super(original, methodFlows); | ||
} | ||
|
||
protected static TypeState convertToBoolean(boolean canBeTrue, boolean canBeFalse) { | ||
if (canBeTrue && canBeFalse) { | ||
return TypeState.anyPrimitiveState(); | ||
} else if (canBeTrue) { | ||
return TypeState.forBoolean(true); | ||
} else if (canBeFalse) { | ||
return TypeState.forBoolean(false); | ||
} | ||
return TypeState.forEmpty(); | ||
} | ||
|
||
protected static TypeState convertToBoolean(TypeState trueState, TypeState falseState) { | ||
return convertToBoolean(trueState.isNotEmpty(), falseState.isNotEmpty()); | ||
} | ||
|
||
@Override | ||
public void addPredicated(PointsToAnalysis bb, TypeFlow<?> predicatedFlow) { | ||
AnalysisError.shouldNotReachHere(getClass() + " shouldn't act as a predicate."); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
...cle.graal.pointsto/src/com/oracle/graal/pointsto/flow/BooleanInstanceOfCheckTypeFlow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Oracle designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Oracle in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
package com.oracle.graal.pointsto.flow; | ||
|
||
import com.oracle.graal.pointsto.PointsToAnalysis; | ||
import com.oracle.graal.pointsto.meta.AnalysisType; | ||
import com.oracle.graal.pointsto.typestate.TypeState; | ||
|
||
import jdk.vm.ci.code.BytecodePosition; | ||
|
||
/** | ||
* This flow represents a type check used by {@link ConditionalFlow}. | ||
*/ | ||
public class BooleanInstanceOfCheckTypeFlow extends BooleanCheckTypeFlow { | ||
private final AnalysisType checkedType; | ||
private final boolean isExact; | ||
private final boolean includeNull; | ||
|
||
public BooleanInstanceOfCheckTypeFlow(BytecodePosition position, AnalysisType checkedType, boolean isExact, boolean includeNull, AnalysisType longType) { | ||
super(position, longType); | ||
this.checkedType = checkedType; | ||
this.isExact = isExact; | ||
this.includeNull = includeNull; | ||
} | ||
|
||
private BooleanInstanceOfCheckTypeFlow(MethodFlowsGraph methodFlows, BooleanInstanceOfCheckTypeFlow original) { | ||
super(original, methodFlows); | ||
this.checkedType = original.checkedType; | ||
this.isExact = original.isExact; | ||
this.includeNull = original.includeNull; | ||
} | ||
|
||
@Override | ||
public TypeFlow<BytecodePosition> copy(PointsToAnalysis bb, MethodFlowsGraph methodFlows) { | ||
return new BooleanInstanceOfCheckTypeFlow(methodFlows, this); | ||
} | ||
|
||
@Override | ||
public TypeState filter(PointsToAnalysis bb, TypeState update) { | ||
TypeState canBeTrue; | ||
TypeState canBeFalse; | ||
if (isExact) { | ||
canBeTrue = TypeState.forIntersection(bb, update, TypeState.forExactType(bb, checkedType, includeNull)); | ||
canBeFalse = TypeState.forSubtraction(bb, update, TypeState.forExactType(bb, checkedType, includeNull)); | ||
} else { | ||
canBeTrue = TypeState.forIntersection(bb, update, checkedType.getAssignableTypes(includeNull)); | ||
canBeFalse = TypeState.forSubtraction(bb, update, checkedType.getAssignableTypes(includeNull)); | ||
} | ||
return convertToBoolean(canBeTrue, canBeFalse); | ||
} | ||
} |
Oops, something went wrong.