Skip to content

Commit 8edeed6

Browse files
author
Christian Wimmer
committed
Remove concept of frozen unsafe accessed fields
1 parent 9e3787f commit 8edeed6

File tree

10 files changed

+7
-180
lines changed

10 files changed

+7
-180
lines changed

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,6 @@ public boolean registerAsUnsafeAccessed(AnalysisField aField, Object reason) {
221221
return false;
222222
}
223223

224-
public void registerAsFrozenUnsafeAccessed(Field field) {
225-
registerAsFrozenUnsafeAccessed(getMetaAccess().lookupJavaField(field));
226-
}
227-
228-
public void registerAsFrozenUnsafeAccessed(AnalysisField aField) {
229-
aField.registerAsFrozenUnsafeAccessed();
230-
registerAsUnsafeAccessed(aField, "registered from standalone feature");
231-
}
232-
233224
public void registerAsUnsafeAccessed(Field field, Object reason) {
234225
registerAsUnsafeAccessed(getMetaAccess().lookupJavaField(field), reason);
235226
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ private static TypeState initialFieldState(AnalysisField field) {
5555
}
5656

5757
/** The holder of the field flow (null for static fields). */
58-
private AnalysisObject object;
58+
private final AnalysisObject object;
5959

6060
/** A filter flow used for unsafe writes. */
6161
private volatile FieldFilterTypeFlow filterFlow;
6262

6363
public FieldTypeFlow(AnalysisField field, AnalysisType type) {
64-
super(field, filterUncheckedInterface(type), initialFieldState(field));
64+
this(field, type, null);
6565
}
6666

6767
public FieldTypeFlow(AnalysisField field, AnalysisType type, AnalysisObject object) {
68-
this(field, type);
68+
super(field, filterUncheckedInterface(type), initialFieldState(field));
6969
this.object = object;
7070
}
7171

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

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

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,20 +213,14 @@ public void forceUpdate(PointsToAnalysis bb) {
213213
* can write to any of the static fields marked for unsafe access.
214214
*/
215215
for (AnalysisField field : bb.getUniverse().getUnsafeAccessedStaticFields()) {
216-
this.addUse(bb, field.getStaticFieldFlow().filterFlow(bb));
216+
addUse(bb, field.getStaticFieldFlow().filterFlow(bb));
217217
}
218218
}
219219

220220
void handleUnsafeAccessedFields(PointsToAnalysis bb, Collection<AnalysisField> unsafeAccessedFields, AnalysisObject object) {
221221
for (AnalysisField field : unsafeAccessedFields) {
222222
/* Write through the field filter flow. */
223-
if (field.hasUnsafeFrozenTypeState()) {
224-
UnsafeWriteSinkTypeFlow unsafeWriteSink = object.getUnsafeWriteSinkFrozenFilterFlow(bb, objectFlow, source, field);
225-
this.addUse(bb, unsafeWriteSink);
226-
} else {
227-
FieldFilterTypeFlow fieldFilterFlow = object.getInstanceFieldFilterFlow(bb, objectFlow, source, field);
228-
this.addUse(bb, fieldFilterFlow);
229-
}
223+
addUse(bb, object.getInstanceFieldFilterFlow(bb, objectFlow, source, field));
230224
}
231225
}
232226
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/context/object/AnalysisObject.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import com.oracle.graal.pointsto.flow.FieldFilterTypeFlow;
3636
import com.oracle.graal.pointsto.flow.FieldTypeFlow;
3737
import com.oracle.graal.pointsto.flow.TypeFlow;
38-
import com.oracle.graal.pointsto.flow.UnsafeWriteSinkTypeFlow;
3938
import com.oracle.graal.pointsto.meta.AnalysisField;
4039
import com.oracle.graal.pointsto.meta.AnalysisType;
4140
import com.oracle.graal.pointsto.meta.AnalysisUniverse;
@@ -198,21 +197,15 @@ public ArrayElementsTypeFlow getArrayElementsFlow(PointsToAnalysis bb, boolean i
198197
return isStore ? arrayElementsTypeStore.writeFlow() : arrayElementsTypeStore.readFlow();
199198
}
200199

201-
/** Returns the filter field flow corresponding to an unsafe accessed filed. */
200+
/** Returns the filter field flow corresponding to an unsafe accessed field. */
202201
public FieldFilterTypeFlow getInstanceFieldFilterFlow(PointsToAnalysis bb, TypeFlow<?> objectFlow, BytecodePosition context, AnalysisField field) {
203202
assert !Modifier.isStatic(field.getModifiers()) && field.isUnsafeAccessed() : field;
204203

205204
FieldTypeStore fieldTypeStore = getInstanceFieldTypeStore(bb, objectFlow, context, field);
206205
return fieldTypeStore.writeFlow().filterFlow(bb);
207206
}
208207

209-
public UnsafeWriteSinkTypeFlow getUnsafeWriteSinkFrozenFilterFlow(PointsToAnalysis bb, TypeFlow<?> objectFlow, BytecodePosition context, AnalysisField field) {
210-
assert !Modifier.isStatic(field.getModifiers()) && field.hasUnsafeFrozenTypeState() : field;
211-
FieldTypeStore fieldTypeStore = getInstanceFieldTypeStore(bb, objectFlow, context, field);
212-
return fieldTypeStore.unsafeWriteSinkFlow(bb);
213-
}
214-
215-
/** Returns the instance field flow corresponding to a filed of the object's type. */
208+
/** Returns the instance field flow corresponding to a field of the object's type. */
216209
public FieldTypeFlow getInstanceFieldFlow(PointsToAnalysis bb, AnalysisField field, boolean isStore) {
217210
return getInstanceFieldFlow(bb, null, null, field, isStore);
218211
}

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.List;
3030
import java.util.concurrent.ConcurrentHashMap;
3131
import java.util.concurrent.ConcurrentMap;
32-
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
3332
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
3433

3534
import com.oracle.graal.pointsto.api.HostVM;
@@ -68,9 +67,6 @@ public abstract class AnalysisField extends AnalysisElement implements WrappedJa
6867
private static final AtomicReferenceFieldUpdater<AnalysisField, Object> isUnsafeAccessedUpdater = AtomicReferenceFieldUpdater
6968
.newUpdater(AnalysisField.class, Object.class, "isUnsafeAccessed");
7069

71-
private static final AtomicIntegerFieldUpdater<AnalysisField> unsafeFrozenTypeStateUpdater = AtomicIntegerFieldUpdater
72-
.newUpdater(AnalysisField.class, "unsafeFrozenTypeState");
73-
7470
private final int id;
7571
/** Marks a field loaded from a base layer. */
7672
private final boolean isInBaseLayer;
@@ -94,12 +90,7 @@ public abstract class AnalysisField extends AnalysisElement implements WrappedJa
9490
@SuppressWarnings("unused") private volatile Object isAccessed;
9591
@SuppressWarnings("unused") private volatile Object isWritten;
9692
@SuppressWarnings("unused") private volatile Object isFolded;
97-
98-
private boolean isJNIAccessed;
99-
10093
@SuppressWarnings("unused") private volatile Object isUnsafeAccessed;
101-
@SuppressWarnings("unused") private volatile int unsafeFrozenTypeState;
102-
@SuppressWarnings("unused") private volatile Object observers;
10394

10495
/**
10596
* By default all instance fields are null before are initialized. It can be specified by
@@ -110,8 +101,6 @@ public abstract class AnalysisField extends AnalysisElement implements WrappedJa
110101
private ConcurrentMap<Object, Boolean> readBy;
111102
private ConcurrentMap<Object, Boolean> writtenBy;
112103

113-
protected TypeState instanceFieldTypeState;
114-
115104
/** Field's position in the list of declaring type's fields, including inherited fields. */
116105
protected int position;
117106

@@ -254,7 +243,6 @@ public void cleanupAfterAnalysis() {
254243
initialInstanceFieldFlow = null;
255244
readBy = null;
256245
writtenBy = null;
257-
instanceFieldTypeState = null;
258246
}
259247

260248
public boolean registerAsAccessed(Object reason) {
@@ -361,22 +349,6 @@ public boolean isUnsafeAccessed() {
361349
return AtomicUtils.isSet(this, isUnsafeAccessedUpdater);
362350
}
363351

364-
public void registerAsJNIAccessed() {
365-
isJNIAccessed = true;
366-
}
367-
368-
public boolean isJNIAccessed() {
369-
return isJNIAccessed;
370-
}
371-
372-
public void registerAsFrozenUnsafeAccessed() {
373-
unsafeFrozenTypeStateUpdater.set(this, 1);
374-
}
375-
376-
public boolean hasUnsafeFrozenTypeState() {
377-
return AtomicUtils.isSet(this, unsafeFrozenTypeStateUpdater);
378-
}
379-
380352
public Object getReadBy() {
381353
return isReadUpdater.get(this);
382354
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/typestate/PointsToStats.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
import com.oracle.graal.pointsto.flow.FilterTypeFlow;
5858
import com.oracle.graal.pointsto.flow.FormalParamTypeFlow;
5959
import com.oracle.graal.pointsto.flow.FormalReturnTypeFlow;
60-
import com.oracle.graal.pointsto.flow.FrozenFieldFilterTypeFlow;
6160
import com.oracle.graal.pointsto.flow.InvokeTypeFlow;
6261
import com.oracle.graal.pointsto.flow.LoadFieldTypeFlow.LoadInstanceFieldTypeFlow;
6362
import com.oracle.graal.pointsto.flow.LoadFieldTypeFlow.LoadStaticFieldTypeFlow;
@@ -485,9 +484,6 @@ private static String asString(TypeFlow<?> flow) {
485484
} else if (flow instanceof FieldFilterTypeFlow) {
486485
FieldFilterTypeFlow filter = (FieldFilterTypeFlow) flow;
487486
return "FieldFilter(" + formatField(filter.getSource()) + ")";
488-
} else if (flow instanceof FrozenFieldFilterTypeFlow) {
489-
FrozenFieldFilterTypeFlow filter = (FrozenFieldFilterTypeFlow) flow;
490-
return "FrozenFieldFilter(" + formatField(filter.getSource()) + ")";
491487
} else if (flow instanceof NewInstanceTypeFlow) {
492488
return "NewInstance(" + flow.getDeclaredType().toJavaName(false) + ")@" + formatSource(flow);
493489
} else if (flow instanceof DynamicNewInstanceTypeFlow) {

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/typestore/FieldTypeStore.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,8 @@
2424
*/
2525
package com.oracle.graal.pointsto.typestore;
2626

27-
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
28-
2927
import com.oracle.graal.pointsto.PointsToAnalysis;
3028
import com.oracle.graal.pointsto.flow.FieldTypeFlow;
31-
import com.oracle.graal.pointsto.flow.FrozenFieldFilterTypeFlow;
32-
import com.oracle.graal.pointsto.flow.UnsafeWriteSinkTypeFlow;
3329
import com.oracle.graal.pointsto.flow.context.object.AnalysisObject;
3430
import com.oracle.graal.pointsto.meta.AnalysisField;
3531

@@ -38,18 +34,9 @@
3834
*/
3935
public abstract class FieldTypeStore {
4036

41-
private static final AtomicReferenceFieldUpdater<FieldTypeStore, FrozenFieldFilterTypeFlow> FROZEN_FILTER_FLOW_UPDATER = AtomicReferenceFieldUpdater.newUpdater(FieldTypeStore.class,
42-
FrozenFieldFilterTypeFlow.class, "frozenFilterFlow");
43-
private static final AtomicReferenceFieldUpdater<FieldTypeStore, UnsafeWriteSinkTypeFlow> UNSAFE_WRITE_SINK_FLOW_UPDATER = AtomicReferenceFieldUpdater.newUpdater(FieldTypeStore.class,
44-
UnsafeWriteSinkTypeFlow.class, "unsafeWriteSinkFlow");
45-
4637
/** The holder of the field flow. */
4738
protected final AnalysisObject object;
4839
protected final AnalysisField field;
49-
/** A filter flow used for unsafe writes on frozen type state. */
50-
private volatile FrozenFieldFilterTypeFlow frozenFilterFlow;
51-
/** A sink used for unsafe writes on frozen type state. */
52-
private volatile UnsafeWriteSinkTypeFlow unsafeWriteSinkFlow;
5340

5441
protected FieldTypeStore(AnalysisField field, AnalysisObject object) {
5542
this.field = field;
@@ -71,22 +58,4 @@ public AnalysisField field() {
7158
/** Overridden for field type stores that need lazy initialization. */
7259
public void init(@SuppressWarnings("unused") PointsToAnalysis bb) {
7360
}
74-
75-
public UnsafeWriteSinkTypeFlow unsafeWriteSinkFlow(PointsToAnalysis bb) {
76-
assert field.hasUnsafeFrozenTypeState() : "Unsafe write sink flow requested for non unsafe accessed frozen field.";
77-
// first we create the unsafe write sink
78-
if (unsafeWriteSinkFlow == null) {
79-
UNSAFE_WRITE_SINK_FLOW_UPDATER.compareAndSet(this, null, new UnsafeWriteSinkTypeFlow(bb, field));
80-
}
81-
// then we build the filter for it.
82-
if (frozenFilterFlow == null) {
83-
if (FROZEN_FILTER_FLOW_UPDATER.compareAndSet(this, null, new FrozenFieldFilterTypeFlow(bb, field, unsafeWriteSinkFlow))) {
84-
frozenFilterFlow.addUse(bb, writeFlow());
85-
unsafeWriteSinkFlow.addUse(bb, frozenFilterFlow);
86-
}
87-
}
88-
89-
return unsafeWriteSinkFlow;
90-
}
91-
9261
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/FeatureImpl.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,6 @@ public boolean registerAsUnsafeAccessed(AnalysisField aField, Object reason) {
418418
return aField.registerAsUnsafeAccessed(reason);
419419
}
420420

421-
public void registerAsFrozenUnsafeAccessed(Field field, Object reason) {
422-
registerAsFrozenUnsafeAccessed(getMetaAccess().lookupJavaField(field), reason);
423-
}
424-
425-
public void registerAsFrozenUnsafeAccessed(AnalysisField aField, Object reason) {
426-
aField.registerAsFrozenUnsafeAccessed();
427-
registerAsUnsafeAccessed(aField, reason);
428-
}
429-
430421
public void registerAsRoot(Executable method, boolean invokeSpecial, String reason, MultiMethod.MultiMethodKey... otherRoots) {
431422
bb.addRootMethod(method, invokeSpecial, reason, otherRoots);
432423
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jni/JNIAccessFeature.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,6 @@ private static void addField(Field reflField, boolean writable, DuringAnalysisAc
497497
JNIAccessibleClass jniClass = addClass(reflField.getDeclaringClass(), access);
498498
AnalysisField field = access.getMetaAccess().lookupJavaField(reflField);
499499
jniClass.addFieldIfAbsent(field.getName(), name -> new JNIAccessibleField(jniClass, field.getJavaKind(), field.getModifiers()));
500-
field.registerAsJNIAccessed();
501500
field.registerAsRead("it is registered for as JNI accessed");
502501
if (writable) {
503502
field.registerAsWritten("it is registered as JNI writable");

0 commit comments

Comments
 (0)