Skip to content

Commit 126bcc8

Browse files
author
Christian Wimmer
committed
[GR-53705] Remove the concept of "Unsafe partitions".
PullRequest: graal/17621
2 parents e3d8479 + 2c795c5 commit 126bcc8

File tree

18 files changed

+40
-593
lines changed

18 files changed

+40
-593
lines changed

substratevm/src/com.oracle.graal.pointsto.standalone/src/com/oracle/graal/pointsto/standalone/features/StandaloneAnalysisFeatureImpl.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import com.oracle.graal.pointsto.meta.AnalysisType;
5050
import com.oracle.graal.pointsto.meta.AnalysisUniverse;
5151
import com.oracle.graal.pointsto.standalone.StandaloneHost;
52-
import com.oracle.svm.util.UnsafePartitionKind;
5352

5453
import jdk.graal.compiler.debug.DebugContext;
5554

@@ -226,14 +225,8 @@ public void registerAsFrozenUnsafeAccessed(AnalysisField aField) {
226225
registerAsUnsafeAccessed(aField, "registered from standalone feature");
227226
}
228227

229-
public void registerAsUnsafeAccessed(Field field, UnsafePartitionKind partitionKind, Object reason) {
230-
registerAsUnsafeAccessed(getMetaAccess().lookupJavaField(field), partitionKind, reason);
231-
}
232-
233-
public void registerAsUnsafeAccessed(AnalysisField aField, UnsafePartitionKind partitionKind, Object reason) {
234-
if (!aField.isUnsafeAccessed()) {
235-
aField.registerAsUnsafeAccessed(partitionKind, reason);
236-
}
228+
public void registerAsUnsafeAccessed(Field field, Object reason) {
229+
registerAsUnsafeAccessed(getMetaAccess().lookupJavaField(field), reason);
237230
}
238231

239232
public void registerAsInvoked(Executable method, boolean invokeSpecial, Object reason) {

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/PointsToAnalysis.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@
8080
import jdk.graal.compiler.api.replacements.SnippetReflectionProvider;
8181
import jdk.graal.compiler.debug.DebugContext;
8282
import jdk.graal.compiler.debug.Indent;
83-
import jdk.graal.compiler.graph.Node;
84-
import jdk.graal.compiler.graph.NodeList;
8583
import jdk.graal.compiler.options.OptionValues;
8684
import jdk.graal.compiler.word.WordTypes;
8785
import jdk.vm.ci.meta.ConstantReflectionProvider;
@@ -280,14 +278,6 @@ public AnalysisType getObjectArrayType() {
280278
return metaAccess.lookupJavaType(Object[].class);
281279
}
282280

283-
public AnalysisType getGraalNodeType() {
284-
return metaAccess.lookupJavaType(Node.class);
285-
}
286-
287-
public AnalysisType getGraalNodeListType() {
288-
return metaAccess.lookupJavaType(NodeList.class);
289-
}
290-
291281
public TypeFlow<?> getAllInstantiatedTypeFlow() {
292282
return objectType.getTypeFlow(this, true);
293283
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/api/DefaultUnsafePartition.java

Lines changed: 0 additions & 47 deletions
This file was deleted.

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/MethodTypeFlowBuilder.java

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@
4444
import com.oracle.graal.pointsto.flow.MethodFlowsGraph.GraphKind;
4545
import com.oracle.graal.pointsto.flow.OffsetLoadTypeFlow.LoadIndexedTypeFlow;
4646
import com.oracle.graal.pointsto.flow.OffsetLoadTypeFlow.UnsafeLoadTypeFlow;
47-
import com.oracle.graal.pointsto.flow.OffsetLoadTypeFlow.UnsafePartitionLoadTypeFlow;
4847
import com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.StoreIndexedTypeFlow;
49-
import com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.UnsafePartitionStoreTypeFlow;
5048
import com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.UnsafeStoreTypeFlow;
5149
import com.oracle.graal.pointsto.flow.StoreFieldTypeFlow.StoreInstanceFieldTypeFlow;
5250
import com.oracle.graal.pointsto.flow.StoreFieldTypeFlow.StoreStaticFieldTypeFlow;
@@ -57,8 +55,6 @@
5755
import com.oracle.graal.pointsto.meta.AnalysisType;
5856
import com.oracle.graal.pointsto.meta.HostedProviders;
5957
import com.oracle.graal.pointsto.meta.PointsToAnalysisMethod;
60-
import com.oracle.graal.pointsto.nodes.UnsafePartitionLoadNode;
61-
import com.oracle.graal.pointsto.nodes.UnsafePartitionStoreNode;
6258
import com.oracle.graal.pointsto.phases.InlineBeforeAnalysis;
6359
import com.oracle.graal.pointsto.results.StrengthenGraphs;
6460
import com.oracle.graal.pointsto.typestate.TypeState;
@@ -1060,65 +1056,6 @@ protected void node(FixedNode n) {
10601056
processStoreIndexed(node, node.array(), node.value(), node.value().getStackKind(), state);
10611057
processImplicitNonNull(node.array(), state);
10621058

1063-
} else if (n instanceof UnsafePartitionLoadNode) {
1064-
UnsafePartitionLoadNode node = (UnsafePartitionLoadNode) n;
1065-
assert node.object().getStackKind() == JavaKind.Object : node.object();
1066-
1067-
checkUnsafeOffset(node.object(), node.offset());
1068-
1069-
AnalysisType partitionType = (AnalysisType) node.partitionType();
1070-
1071-
AnalysisType objectType = (AnalysisType) StampTool.typeOrNull(node.object(), bb.getMetaAccess());
1072-
assert bb.getGraalNodeType().isAssignableFrom(objectType) : objectType;
1073-
1074-
/* Use the Object type as a conservative type for the values loaded. */
1075-
AnalysisType componentType = bb.getObjectType();
1076-
1077-
TypeFlowBuilder<?> objectBuilder = state.lookup(node.object());
1078-
TypeFlowBuilder<?> unsafeLoadBuilder = TypeFlowBuilder.create(bb, node, UnsafePartitionLoadTypeFlow.class, () -> {
1079-
UnsafePartitionLoadTypeFlow loadTypeFlow = new UnsafePartitionLoadTypeFlow(AbstractAnalysisEngine.sourcePosition(node), objectType, componentType, objectBuilder.get(),
1080-
node.unsafePartitionKind(), partitionType);
1081-
flowsGraph.addMiscEntryFlow(loadTypeFlow);
1082-
return loadTypeFlow;
1083-
});
1084-
unsafeLoadBuilder.addObserverDependency(objectBuilder);
1085-
state.add(node, unsafeLoadBuilder);
1086-
1087-
} else if (n instanceof UnsafePartitionStoreNode) {
1088-
UnsafePartitionStoreNode node = (UnsafePartitionStoreNode) n;
1089-
1090-
assert node.object().getStackKind() == JavaKind.Object : node.object();
1091-
assert node.value().getStackKind() == JavaKind.Object : node.value();
1092-
1093-
checkUnsafeOffset(node.object(), node.offset());
1094-
1095-
AnalysisType partitionType = (AnalysisType) node.partitionType();
1096-
1097-
AnalysisType objectType = (AnalysisType) StampTool.typeOrNull(node.object(), bb.getMetaAccess());
1098-
assert bb.getGraalNodeType().isAssignableFrom(objectType) : objectType;
1099-
1100-
/* Use the Object type as a conservative type for the values stored. */
1101-
AnalysisType componentType = bb.getObjectType();
1102-
1103-
AnalysisType valueType = (AnalysisType) StampTool.typeOrNull(node.value(), bb.getMetaAccess());
1104-
assert valueType.isJavaLangObject() || bb.getGraalNodeType().isAssignableFrom(valueType) || bb.getGraalNodeListType().isAssignableFrom(valueType) : valueType;
1105-
1106-
TypeFlowBuilder<?> objectBuilder = state.lookup(node.object());
1107-
TypeFlowBuilder<?> valueBuilder = state.lookup(node.value());
1108-
1109-
TypeFlowBuilder<?> unsafeStoreBuilder = TypeFlowBuilder.create(bb, node, UnsafePartitionStoreTypeFlow.class, () -> {
1110-
UnsafePartitionStoreTypeFlow storeTypeFlow = new UnsafePartitionStoreTypeFlow(AbstractAnalysisEngine.sourcePosition(node), objectType, componentType, objectBuilder.get(),
1111-
valueBuilder.get(),
1112-
node.partitionKind(), partitionType);
1113-
flowsGraph.addMiscEntryFlow(storeTypeFlow);
1114-
return storeTypeFlow;
1115-
});
1116-
unsafeStoreBuilder.addUseDependency(valueBuilder);
1117-
unsafeStoreBuilder.addObserverDependency(objectBuilder);
1118-
1119-
/* Unsafe stores must not be removed. */
1120-
typeFlowGraphBuilder.registerSinkBuilder(unsafeStoreBuilder);
1121-
11221059
} else if (n instanceof RawLoadNode node) {
11231060
modelUnsafeReadOnlyFlow(node, node.object(), node.offset());
11241061
} else if (n instanceof RawStoreNode node) {

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/OffsetLoadTypeFlow.java

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import com.oracle.graal.pointsto.meta.AnalysisField;
3030
import com.oracle.graal.pointsto.meta.AnalysisType;
3131
import com.oracle.graal.pointsto.typestate.TypeState;
32-
import com.oracle.svm.util.UnsafePartitionKind;
3332

3433
import jdk.vm.ci.code.BytecodePosition;
3534

@@ -250,58 +249,4 @@ public String toString() {
250249
return "UnsafeLoadTypeFlow<" + getState() + ">";
251250
}
252251
}
253-
254-
public static class UnsafePartitionLoadTypeFlow extends AbstractUnsafeLoadTypeFlow {
255-
256-
protected final UnsafePartitionKind partitionKind;
257-
protected final AnalysisType partitionType;
258-
259-
public UnsafePartitionLoadTypeFlow(BytecodePosition loadLocation, AnalysisType objectType, AnalysisType componentType, TypeFlow<?> arrayFlow,
260-
UnsafePartitionKind partitionKind, AnalysisType partitionType) {
261-
super(loadLocation, objectType, componentType, arrayFlow);
262-
this.partitionKind = partitionKind;
263-
this.partitionType = partitionType;
264-
}
265-
266-
private UnsafePartitionLoadTypeFlow(PointsToAnalysis bb, MethodFlowsGraph methodFlows, UnsafePartitionLoadTypeFlow original) {
267-
super(bb, methodFlows, original);
268-
this.partitionKind = original.partitionKind;
269-
this.partitionType = original.partitionType;
270-
}
271-
272-
@Override
273-
public AbstractUnsafeLoadTypeFlow copy(PointsToAnalysis bb, MethodFlowsGraph methodFlows) {
274-
return new UnsafePartitionLoadTypeFlow(bb, methodFlows, this);
275-
}
276-
277-
@Override
278-
public TypeState filter(PointsToAnalysis bb, TypeState update) {
279-
if (partitionType.equals(bb.getObjectType())) {
280-
/* No need to filter. */
281-
return update;
282-
} else {
283-
/* Filter the incoming state with the partition type. */
284-
return TypeState.forIntersection(bb, update, partitionType.getAssignableTypes(true));
285-
}
286-
}
287-
288-
@Override
289-
public void onObservedUpdate(PointsToAnalysis bb) {
290-
TypeState objectState = getObjectState();
291-
292-
for (AnalysisObject object : objectState.objects(bb)) {
293-
AnalysisType objectType = object.type();
294-
assert !objectType.isArray() : objectType;
295-
296-
for (AnalysisField field : objectType.unsafeAccessedFields(partitionKind)) {
297-
processField(bb, object, field);
298-
}
299-
}
300-
}
301-
302-
@Override
303-
public String toString() {
304-
return "UnsafePartitionLoadTypeFlow<" + getState() + "> : " + partitionKind;
305-
}
306-
}
307252
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/OffsetStoreTypeFlow.java

Lines changed: 3 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@
2424
*/
2525
package com.oracle.graal.pointsto.flow;
2626

27-
import java.util.List;
27+
import java.util.Collection;
2828

2929
import com.oracle.graal.pointsto.PointsToAnalysis;
30-
import com.oracle.graal.pointsto.api.DefaultUnsafePartition;
3130
import com.oracle.graal.pointsto.flow.context.object.AnalysisObject;
3231
import com.oracle.graal.pointsto.meta.AnalysisField;
3332
import com.oracle.graal.pointsto.meta.AnalysisType;
3433
import com.oracle.graal.pointsto.meta.PointsToAnalysisType;
3534
import com.oracle.graal.pointsto.typestate.TypeState;
36-
import com.oracle.svm.util.UnsafePartitionKind;
3735

3836
import jdk.vm.ci.code.BytecodePosition;
3937

@@ -219,7 +217,7 @@ public void forceUpdate(PointsToAnalysis bb) {
219217
}
220218
}
221219

222-
void handleUnsafeAccessedFields(PointsToAnalysis bb, List<AnalysisField> unsafeAccessedFields, AnalysisObject object) {
220+
void handleUnsafeAccessedFields(PointsToAnalysis bb, Collection<AnalysisField> unsafeAccessedFields, AnalysisObject object) {
223221
for (AnalysisField field : unsafeAccessedFields) {
224222
/* Write through the field filter flow. */
225223
if (field.hasUnsafeFrozenTypeState()) {
@@ -271,7 +269,7 @@ public void onObservedUpdate(PointsToAnalysis bb) {
271269
TypeFlow<?> elementsFlow = object.getArrayElementsFlow(bb, true);
272270
this.addUse(bb, elementsFlow);
273271
} else {
274-
handleUnsafeAccessedFields(bb, type.unsafeAccessedFields(DefaultUnsafePartition.get()), object);
272+
handleUnsafeAccessedFields(bb, type.unsafeAccessedFields(), object);
275273
}
276274
}
277275
}
@@ -305,63 +303,4 @@ public String toString() {
305303
return "UnsafeStoreTypeFlow<" + getState() + ">";
306304
}
307305
}
308-
309-
public static class UnsafePartitionStoreTypeFlow extends AbstractUnsafeStoreTypeFlow {
310-
311-
protected final UnsafePartitionKind partitionKind;
312-
protected final AnalysisType partitionType;
313-
314-
public UnsafePartitionStoreTypeFlow(BytecodePosition storeLocation, AnalysisType objectType, AnalysisType componentType, TypeFlow<?> objectFlow, TypeFlow<?> valueFlow,
315-
UnsafePartitionKind partitionKind, AnalysisType partitionType) {
316-
super(storeLocation, objectType, componentType, objectFlow, valueFlow);
317-
this.partitionKind = partitionKind;
318-
this.partitionType = partitionType;
319-
}
320-
321-
public UnsafePartitionStoreTypeFlow(PointsToAnalysis bb, MethodFlowsGraph methodFlows, UnsafePartitionStoreTypeFlow original) {
322-
super(bb, methodFlows, original);
323-
this.partitionKind = original.partitionKind;
324-
this.partitionType = original.partitionType;
325-
}
326-
327-
@Override
328-
public UnsafePartitionStoreTypeFlow makeCopy(PointsToAnalysis bb, MethodFlowsGraph methodFlows) {
329-
return new UnsafePartitionStoreTypeFlow(bb, methodFlows, this);
330-
}
331-
332-
@Override
333-
public TypeState filter(PointsToAnalysis bb, TypeState update) {
334-
if (partitionType.equals(bb.getObjectType())) {
335-
/* No need to filter. */
336-
return update;
337-
} else {
338-
/* Filter the incoming state with the partition type. */
339-
return TypeState.forIntersection(bb, update, partitionType.getAssignableTypes(true));
340-
}
341-
}
342-
343-
@Override
344-
public void onObservedUpdate(PointsToAnalysis bb) {
345-
TypeState objectState = objectFlow.getState();
346-
347-
/* Iterate over the receiver objects. */
348-
for (AnalysisObject object : objectState.objects(bb)) {
349-
AnalysisType type = object.type();
350-
assert !type.isArray() : type;
351-
352-
handleUnsafeAccessedFields(bb, type.unsafeAccessedFields(partitionKind), object);
353-
}
354-
}
355-
356-
@Override
357-
public void onObservedSaturated(PointsToAnalysis bb, TypeFlow<?> observed) {
358-
/* When receiver object flow saturates start observing the flow of the object type. */
359-
replaceObservedWith(bb, objectType);
360-
}
361-
362-
@Override
363-
public String toString() {
364-
return "UnsafePartitionStoreTypeFlow<" + getState() + "> : " + partitionKind;
365-
}
366-
}
367306
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisField.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
3333
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
3434

35-
import com.oracle.graal.pointsto.api.DefaultUnsafePartition;
3635
import com.oracle.graal.pointsto.api.HostVM;
3736
import com.oracle.graal.pointsto.api.PointstoOptions;
3837
import com.oracle.graal.pointsto.flow.ContextInsensitiveFieldTypeFlow;
@@ -44,7 +43,6 @@
4443
import com.oracle.graal.pointsto.util.AnalysisError;
4544
import com.oracle.graal.pointsto.util.AnalysisFuture;
4645
import com.oracle.graal.pointsto.util.AtomicUtils;
47-
import com.oracle.svm.util.UnsafePartitionKind;
4846

4947
import jdk.graal.compiler.debug.GraalError;
5048
import jdk.vm.ci.code.BytecodePosition;
@@ -323,11 +321,7 @@ public void registerAsFolded(Object reason) {
323321
}
324322
}
325323

326-
public void registerAsUnsafeAccessed(Object reason) {
327-
registerAsUnsafeAccessed(DefaultUnsafePartition.get(), reason);
328-
}
329-
330-
public boolean registerAsUnsafeAccessed(UnsafePartitionKind partitionKind, Object reason) {
324+
public boolean registerAsUnsafeAccessed(Object reason) {
331325
assert isValidReason(reason) : "Registering a field as unsafe accessed needs to provide a valid reason.";
332326
registerAsAccessed(reason);
333327
/*
@@ -356,7 +350,7 @@ public boolean registerAsUnsafeAccessed(UnsafePartitionKind partitionKind, Objec
356350
} else {
357351
/* Register the instance field as unsafe accessed on the declaring type. */
358352
AnalysisType declaringType = getDeclaringClass();
359-
declaringType.registerUnsafeAccessedField(this, partitionKind);
353+
declaringType.registerUnsafeAccessedField(this);
360354
}
361355
return true;
362356
}

0 commit comments

Comments
 (0)