Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-51363] Remove ExtendedAsserts option. #8324

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public abstract class AbstractAnalysisEngine implements BigBang {
protected final AnalysisMetaAccess metaAccess;
protected final AnalysisPolicy analysisPolicy;

protected final Boolean extendedAsserts;
protected final int maxConstantObjectsPerType;
protected final boolean profileConstantObjects;
protected final boolean optimizeReturnedParameter;
Expand Down Expand Up @@ -120,7 +119,6 @@ public AbstractAnalysisEngine(OptionValues options, AnalysisUniverse universe, H
this.verifyHeapTimer = timerCollection.get(TimerCollection.Registry.VERIFY_HEAP);
this.analysisTimer = timerCollection.get(TimerCollection.Registry.ANALYSIS);

this.extendedAsserts = PointstoOptions.ExtendedAsserts.getValue(options);
maxConstantObjectsPerType = PointstoOptions.MaxConstantObjectsPerType.getValue(options);
profileConstantObjects = PointstoOptions.ProfileConstantObjects.getValue(options);
optimizeReturnedParameter = PointstoOptions.OptimizeReturnedParameter.getValue(options);
Expand Down Expand Up @@ -242,11 +240,6 @@ public void printTimerStatistics(PrintWriter out) {
StatisticsPrinter.printLast(out, "total_memory_bytes", analysisTimer.getTotalMemory());
}

@Override
public boolean extendedAsserts() {
return extendedAsserts;
}

public int maxConstantObjectsPerType() {
return maxConstantObjectsPerType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@

import java.util.BitSet;

import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.replacements.nodes.BasicArrayCopyNode;

import com.oracle.graal.pointsto.api.PointstoOptions;
import com.oracle.graal.pointsto.flow.AbstractSpecialInvokeTypeFlow;
import com.oracle.graal.pointsto.flow.AbstractStaticInvokeTypeFlow;
Expand All @@ -50,11 +47,12 @@
import com.oracle.graal.pointsto.typestate.MultiTypeState;
import com.oracle.graal.pointsto.typestate.SingleTypeState;
import com.oracle.graal.pointsto.typestate.TypeState;
import com.oracle.graal.pointsto.typestate.TypeStateUtils;
import com.oracle.graal.pointsto.typestore.ArrayElementsTypeStore;
import com.oracle.graal.pointsto.typestore.FieldTypeStore;
import com.oracle.svm.common.meta.MultiMethod;

import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.replacements.nodes.BasicArrayCopyNode;
import jdk.vm.ci.code.BytecodePosition;
import jdk.vm.ci.meta.JavaConstant;

Expand Down Expand Up @@ -217,9 +215,7 @@ public abstract InvokeTypeFlow createDeoptInvokeTypeFlow(BytecodePosition invoke

public abstract TypeState doUnion(PointsToAnalysis bb, MultiTypeState s1, MultiTypeState s2);

@SuppressWarnings("static-method")
public final TypeState doIntersection(PointsToAnalysis bb, SingleTypeState s1, SingleTypeState s2) {
assert !bb.extendedAsserts() || TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";
public TypeState doIntersection(PointsToAnalysis bb, SingleTypeState s1, SingleTypeState s2) {
boolean resultCanBeNull = s1.canBeNull() && s2.canBeNull();
if (s1.exactType().equals(s2.exactType())) {
/* The inputs have the same type, the result will be s1. */
Expand All @@ -230,9 +226,7 @@ public final TypeState doIntersection(PointsToAnalysis bb, SingleTypeState s1, S
}
}

@SuppressWarnings("static-method")
public final TypeState doIntersection(PointsToAnalysis bb, SingleTypeState s1, MultiTypeState s2) {
assert !bb.extendedAsserts() || TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";
public TypeState doIntersection(PointsToAnalysis bb, SingleTypeState s1, MultiTypeState s2) {
boolean resultCanBeNull = s1.canBeNull() && s2.canBeNull();
if (s2.containsType(s1.exactType())) {
return s1.forCanBeNull(bb, resultCanBeNull);
Expand All @@ -245,9 +239,7 @@ public final TypeState doIntersection(PointsToAnalysis bb, SingleTypeState s1, M

public abstract TypeState doIntersection(PointsToAnalysis bb, MultiTypeState s1, MultiTypeState s2);

@SuppressWarnings("static-method")
public final TypeState doSubtraction(PointsToAnalysis bb, SingleTypeState s1, SingleTypeState s2) {
assert !bb.extendedAsserts() || TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";
public TypeState doSubtraction(PointsToAnalysis bb, SingleTypeState s1, SingleTypeState s2) {
boolean resultCanBeNull = s1.canBeNull() && !s2.canBeNull();
if (s1.exactType().equals(s2.exactType())) {
return TypeState.forEmpty().forCanBeNull(bb, resultCanBeNull);
Expand All @@ -256,9 +248,7 @@ public final TypeState doSubtraction(PointsToAnalysis bb, SingleTypeState s1, Si
}
}

@SuppressWarnings("static-method")
public final TypeState doSubtraction(PointsToAnalysis bb, SingleTypeState s1, MultiTypeState s2) {
assert !bb.extendedAsserts() || TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";
public TypeState doSubtraction(PointsToAnalysis bb, SingleTypeState s1, MultiTypeState s2) {
boolean resultCanBeNull = s1.canBeNull() && !s2.canBeNull();
if (s2.containsType(s1.exactType())) {
return TypeState.forEmpty().forCanBeNull(bb, resultCanBeNull);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ default HostedProviders getProviders(AnalysisMethod method) {

DebugContext getDebug();

boolean extendedAsserts();

void runAnalysis(DebugContext debug, Function<AnalysisUniverse, Boolean> duringAnalysisAction) throws InterruptedException;

boolean trackPrimitiveValues();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
import static jdk.graal.compiler.options.OptionType.Expert;
import static jdk.vm.ci.common.JVMCIError.shouldNotReachHere;

import java.util.Locale;

import org.graalvm.collections.EconomicMap;

import jdk.graal.compiler.options.Option;
import jdk.graal.compiler.options.OptionKey;

import java.util.Locale;

public class PointstoOptions {

@Option(help = "Track primitive values using the infrastructure of points-to analysis.")//
Expand Down Expand Up @@ -91,9 +91,6 @@ public class PointstoOptions {
@Option(help = "Analysis: Detect methods that return one of their parameters and hardwire the parameter straight to the return.")//
public static final OptionKey<Boolean> OptimizeReturnedParameter = new OptionKey<>(true);

@Option(help = "Enable extended asserts which slow down analysis.")//
public static final OptionKey<Boolean> ExtendedAsserts = new OptionKey<>(false);

@Option(help = "Track the callers for methods and accessing methods for fields.")//
public static final OptionKey<Boolean> TrackAccessChain = new OptionKey<>(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import java.util.Arrays;
import java.util.BitSet;

import jdk.graal.compiler.options.OptionValues;

import com.oracle.graal.pointsto.AnalysisPolicy;
import com.oracle.graal.pointsto.BigBang;
import com.oracle.graal.pointsto.PointsToAnalysis;
Expand Down Expand Up @@ -76,6 +74,7 @@
import com.oracle.graal.pointsto.util.ListUtils.UnsafeArrayListClosable;
import com.oracle.svm.common.meta.MultiMethod;

import jdk.graal.compiler.options.OptionValues;
import jdk.vm.ci.code.BytecodePosition;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
Expand Down Expand Up @@ -464,7 +463,7 @@ public TypeState doUnion(PointsToAnalysis bb, SingleTypeState state1, SingleType
}

/* Due to the test above the union set cannot be equal to any of the two arrays. */
assert !bb.extendedAsserts() || !Arrays.equals(resultObjects, s1.objects) && !Arrays.equals(resultObjects, s2.objects) : resultObjects;
assert !Arrays.equals(resultObjects, s1.objects) && !Arrays.equals(resultObjects, s2.objects) : resultObjects;

/* Create the resulting exact type state. */
SingleTypeState result = new ContextSensitiveSingleTypeState(bb, resultCanBeNull, s1.exactType(), resultObjects);
Expand Down Expand Up @@ -529,7 +528,7 @@ public TypeState doUnion(PointsToAnalysis bb, MultiTypeState state1, SingleTypeS
* Due to the test above and to the fact that TypeStateUtils.union checks if one array
* contains the other the union set cannot be equal to s1's objects slice.
*/
assert !bb.extendedAsserts() || !Arrays.equals(unionObjects, s1ObjectsSlice) : unionObjects;
assert !Arrays.equals(unionObjects, s1ObjectsSlice) : unionObjects;

/*
* Replace the s1 objects slice of the same type as s2 with the union objects and create
Expand Down Expand Up @@ -852,10 +851,22 @@ private TypeState doUnion2(PointsToAnalysis bb, ContextSensitiveMultiTypeState s
* must only contain context insensitive objects.
*/

@Override
public TypeState doIntersection(PointsToAnalysis bb, SingleTypeState s1, SingleTypeState s2) {
assert TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";
return super.doIntersection(bb, s1, s2);
}

@Override
public TypeState doIntersection(PointsToAnalysis bb, SingleTypeState s1, MultiTypeState s2) {
assert TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";
return super.doIntersection(bb, s1, s2);
}

@Override
public TypeState doIntersection(PointsToAnalysis bb, MultiTypeState s1, SingleTypeState s2) {
/* See comment above for the limitation explanation. */
assert !bb.extendedAsserts() || TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";
assert TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";

boolean resultCanBeNull = s1.canBeNull() && s2.canBeNull();
if (s1.containsType(s2.exactType())) {
Expand All @@ -874,7 +885,7 @@ public TypeState doIntersection(PointsToAnalysis bb, MultiTypeState state1, Mult
ContextSensitiveMultiTypeState s1 = (ContextSensitiveMultiTypeState) state1;
ContextSensitiveMultiTypeState s2 = (ContextSensitiveMultiTypeState) state2;

assert !bb.extendedAsserts() || TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";
assert TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";

boolean resultCanBeNull = s1.canBeNull() && s2.canBeNull();

Expand Down Expand Up @@ -1033,8 +1044,19 @@ private static TypeState doIntersection2(PointsToAnalysis bb, ContextSensitiveMu
*/

@Override
public TypeState doSubtraction(PointsToAnalysis bb, MultiTypeState state1, SingleTypeState state2) {
public TypeState doSubtraction(PointsToAnalysis bb, SingleTypeState s1, SingleTypeState s2) {
assert TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";
return super.doSubtraction(bb, s1, s2);
}

@Override
public TypeState doSubtraction(PointsToAnalysis bb, SingleTypeState s1, MultiTypeState s2) {
assert TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";
return super.doSubtraction(bb, s1, s2);
}

@Override
public TypeState doSubtraction(PointsToAnalysis bb, MultiTypeState state1, SingleTypeState state2) {
ContextSensitiveMultiTypeState s1 = (ContextSensitiveMultiTypeState) state1;
ContextSensitiveSingleTypeState s2 = (ContextSensitiveSingleTypeState) state2;

Expand All @@ -1043,7 +1065,7 @@ public TypeState doSubtraction(PointsToAnalysis bb, MultiTypeState state1, Singl
/* s2 is contained in s1, so remove all objects of the same type from s1. */

/* See comment above for the limitation explanation. */
assert !bb.extendedAsserts() || TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";
assert TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";

/* Find the range of objects of s2.exactType() in s1. */
ContextSensitiveMultiTypeState.Range typeRange = s1.findTypeRange(s2.exactType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ContextSensitiveMultiTypeState(PointsToAnalysis bb, boolean canBeNull, Bi
super(bb, canBeNull, typesBitSet, typesCount);
this.objects = objects;
assert objects.length > 1 : "Multi type state with single object.";
assert checkObjects(bb);
assert checkObjects();
}

/** Create a type state with the same content and a reversed canBeNull value. */
Expand Down Expand Up @@ -79,11 +79,7 @@ public int[] getObjectTypeIds() {
return objectTypeIds;
}

private boolean checkObjects(PointsToAnalysis bb) {
if (!bb.extendedAsserts()) {
return true;
}

private boolean checkObjects() {
for (int idx = 0; idx < objects.length - 1; idx++) {
AnalysisObject o0 = objects[idx];
AnalysisObject o1 = objects[idx + 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ContextSensitiveSingleTypeState extends SingleTypeState {
public ContextSensitiveSingleTypeState(PointsToAnalysis bb, boolean canBeNull, AnalysisType type, AnalysisObject... objects) {
super(bb, canBeNull, type);
this.objects = objects;
assert checkObjects(bb);
assert checkObjects();
}

/** Create a type state with the same content and a reversed canBeNull value. */
Expand All @@ -54,11 +54,7 @@ protected ContextSensitiveSingleTypeState(PointsToAnalysis bb, boolean canBeNull
this.objects = other.objects;
}

protected boolean checkObjects(BigBang bb) {
if (!bb.extendedAsserts()) {
return true;
}

protected boolean checkObjects() {
/* Check that the objects array are sorted by type. */
for (int idx = 0; idx < objects.length - 1; idx++) {
AnalysisObject o0 = objects[idx];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import java.util.BitSet;
import java.util.Objects;

import jdk.graal.compiler.options.OptionValues;

import com.oracle.graal.pointsto.AnalysisPolicy;
import com.oracle.graal.pointsto.PointsToAnalysis;
import com.oracle.graal.pointsto.flow.AbstractSpecialInvokeTypeFlow;
Expand Down Expand Up @@ -57,6 +55,7 @@
import com.oracle.graal.pointsto.util.AnalysisError;
import com.oracle.svm.common.meta.MultiMethod;

import jdk.graal.compiler.options.OptionValues;
import jdk.vm.ci.code.BytecodePosition;
import jdk.vm.ci.meta.JavaConstant;

Expand Down Expand Up @@ -376,8 +375,6 @@ public TypeState doUnion(PointsToAnalysis bb, MultiTypeState s1, MultiTypeState

@Override
public TypeState doIntersection(PointsToAnalysis bb, MultiTypeState s1, SingleTypeState s2) {
assert !bb.extendedAsserts() || TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";

boolean resultCanBeNull = s1.canBeNull() && s2.canBeNull();
if (s1.containsType(s2.exactType())) {
/* s1 contains s2's type, return s2. */
Expand Down Expand Up @@ -427,7 +424,6 @@ public TypeState doIntersection(PointsToAnalysis bb, MultiTypeState s1, MultiTyp

@Override
public TypeState doSubtraction(PointsToAnalysis bb, MultiTypeState s1, SingleTypeState s2) {
assert !bb.extendedAsserts() || TypeStateUtils.isContextInsensitiveTypeState(bb, s2) : "Current implementation limitation.";
boolean resultCanBeNull = s1.canBeNull() && !s2.canBeNull();
if (s1.containsType(s2.exactType())) {
/* s2 is contained in s1, so remove s2's type from s1. */
Expand Down
Loading