|
24 | 24 | */ |
25 | 25 | package com.oracle.graal.pointsto; |
26 | 26 |
|
| 27 | +import java.util.BitSet; |
| 28 | + |
27 | 29 | import org.graalvm.compiler.options.OptionValues; |
28 | 30 |
|
29 | 31 | import com.oracle.graal.pointsto.api.PointstoOptions; |
|
41 | 43 | import com.oracle.graal.pointsto.meta.AnalysisType; |
42 | 44 | import com.oracle.graal.pointsto.meta.AnalysisUniverse; |
43 | 45 | import com.oracle.graal.pointsto.meta.PointsToAnalysisMethod; |
| 46 | +import com.oracle.graal.pointsto.typestate.MultiTypeState; |
| 47 | +import com.oracle.graal.pointsto.typestate.SingleTypeState; |
44 | 48 | import com.oracle.graal.pointsto.typestate.TypeState; |
| 49 | +import com.oracle.graal.pointsto.typestate.TypeStateUtils; |
45 | 50 | import com.oracle.graal.pointsto.typestore.ArrayElementsTypeStore; |
46 | 51 | import com.oracle.graal.pointsto.typestore.FieldTypeStore; |
47 | 52 |
|
@@ -169,4 +174,75 @@ public int makePropertiesForUnion(TypeState s1, TypeState s2) { |
169 | 174 | /* The default analysis policy doesn't use properties. */ |
170 | 175 | return 0; |
171 | 176 | } |
| 177 | + |
| 178 | + /** |
| 179 | + * Simplifies a type state by replacing all context sensitive objects with context insensitive |
| 180 | + * objects. |
| 181 | + */ |
| 182 | + public abstract TypeState forContextInsensitiveTypeState(PointsToAnalysis bb, TypeState state); |
| 183 | + |
| 184 | + public abstract SingleTypeState singleTypeState(PointsToAnalysis bb, boolean canBeNull, int properties, AnalysisType type, AnalysisObject... objects); |
| 185 | + |
| 186 | + public abstract MultiTypeState multiTypeState(PointsToAnalysis bb, boolean canBeNull, int properties, BitSet typesBitSet, AnalysisObject... objects); |
| 187 | + |
| 188 | + public abstract TypeState doUnion(PointsToAnalysis bb, SingleTypeState s1, SingleTypeState s2); |
| 189 | + |
| 190 | + public abstract TypeState doUnion(PointsToAnalysis bb, MultiTypeState s1, SingleTypeState s2); |
| 191 | + |
| 192 | + public abstract TypeState doUnion(PointsToAnalysis bb, MultiTypeState s1, MultiTypeState s2); |
| 193 | + |
| 194 | + @SuppressWarnings("static-method") |
| 195 | + public final TypeState doIntersection(PointsToAnalysis bb, SingleTypeState s1, SingleTypeState s2) { |
| 196 | + assert !bb.extendedAsserts() || TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation."; |
| 197 | + boolean resultCanBeNull = s1.canBeNull() && s2.canBeNull(); |
| 198 | + if (s1.exactType().equals(s2.exactType())) { |
| 199 | + /* The inputs have the same type, the result will be s1. */ |
| 200 | + return s1.forCanBeNull(bb, resultCanBeNull); |
| 201 | + } else { |
| 202 | + /* The inputs have different types then the result is empty or null. */ |
| 203 | + return TypeState.forEmpty().forCanBeNull(bb, resultCanBeNull); |
| 204 | + } |
| 205 | + } |
| 206 | + |
| 207 | + @SuppressWarnings("static-method") |
| 208 | + public final TypeState doIntersection(PointsToAnalysis bb, SingleTypeState s1, MultiTypeState s2) { |
| 209 | + assert !bb.extendedAsserts() || TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation."; |
| 210 | + boolean resultCanBeNull = s1.canBeNull() && s2.canBeNull(); |
| 211 | + if (s2.containsType(s1.exactType())) { |
| 212 | + return s1.forCanBeNull(bb, resultCanBeNull); |
| 213 | + } else { |
| 214 | + return TypeState.forEmpty().forCanBeNull(bb, resultCanBeNull); |
| 215 | + } |
| 216 | + } |
| 217 | + |
| 218 | + public abstract TypeState doIntersection(PointsToAnalysis bb, MultiTypeState s1, SingleTypeState s2); |
| 219 | + |
| 220 | + public abstract TypeState doIntersection(PointsToAnalysis bb, MultiTypeState s1, MultiTypeState s2); |
| 221 | + |
| 222 | + @SuppressWarnings("static-method") |
| 223 | + public final TypeState doSubtraction(PointsToAnalysis bb, SingleTypeState s1, SingleTypeState s2) { |
| 224 | + assert !bb.extendedAsserts() || TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation."; |
| 225 | + boolean resultCanBeNull = s1.canBeNull() && !s2.canBeNull(); |
| 226 | + if (s1.exactType().equals(s2.exactType())) { |
| 227 | + return TypeState.forEmpty().forCanBeNull(bb, resultCanBeNull); |
| 228 | + } else { |
| 229 | + return s1.forCanBeNull(bb, resultCanBeNull); |
| 230 | + } |
| 231 | + } |
| 232 | + |
| 233 | + @SuppressWarnings("static-method") |
| 234 | + public final TypeState doSubtraction(PointsToAnalysis bb, SingleTypeState s1, MultiTypeState s2) { |
| 235 | + assert !bb.extendedAsserts() || TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation."; |
| 236 | + boolean resultCanBeNull = s1.canBeNull() && !s2.canBeNull(); |
| 237 | + if (s2.containsType(s1.exactType())) { |
| 238 | + return TypeState.forEmpty().forCanBeNull(bb, resultCanBeNull); |
| 239 | + } else { |
| 240 | + return s1.forCanBeNull(bb, resultCanBeNull); |
| 241 | + } |
| 242 | + } |
| 243 | + |
| 244 | + public abstract TypeState doSubtraction(PointsToAnalysis bb, MultiTypeState s1, SingleTypeState s2); |
| 245 | + |
| 246 | + public abstract TypeState doSubtraction(PointsToAnalysis bb, MultiTypeState s1, MultiTypeState s2); |
| 247 | + |
172 | 248 | } |
0 commit comments