Skip to content

Commit

Permalink
Automatic merge of master into galahad
Browse files Browse the repository at this point in the history
  • Loading branch information
OracleLabsAutomation committed Jun 13, 2024
2 parents 664d054 + d441091 commit c4cd029
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,6 @@ public boolean registerAsUnsafeAccessed(AnalysisField aField, Object reason) {
return false;
}

public void registerAsFrozenUnsafeAccessed(Field field) {
registerAsFrozenUnsafeAccessed(getMetaAccess().lookupJavaField(field));
}

public void registerAsFrozenUnsafeAccessed(AnalysisField aField) {
aField.registerAsFrozenUnsafeAccessed();
registerAsUnsafeAccessed(aField, "registered from standalone feature");
}

public void registerAsUnsafeAccessed(Field field, Object reason) {
registerAsUnsafeAccessed(getMetaAccess().lookupJavaField(field), reason);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ private static TypeState initialFieldState(AnalysisField field) {
}

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

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

public FieldTypeFlow(AnalysisField field, AnalysisType type) {
super(field, filterUncheckedInterface(type), initialFieldState(field));
this(field, type, null);
}

public FieldTypeFlow(AnalysisField field, AnalysisType type, AnalysisObject object) {
this(field, type);
super(field, filterUncheckedInterface(type), initialFieldState(field));
this.object = object;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -213,20 +213,14 @@ public void forceUpdate(PointsToAnalysis bb) {
* can write to any of the static fields marked for unsafe access.
*/
for (AnalysisField field : bb.getUniverse().getUnsafeAccessedStaticFields()) {
this.addUse(bb, field.getStaticFieldFlow().filterFlow(bb));
addUse(bb, field.getStaticFieldFlow().filterFlow(bb));
}
}

void handleUnsafeAccessedFields(PointsToAnalysis bb, Collection<AnalysisField> unsafeAccessedFields, AnalysisObject object) {
for (AnalysisField field : unsafeAccessedFields) {
/* Write through the field filter flow. */
if (field.hasUnsafeFrozenTypeState()) {
UnsafeWriteSinkTypeFlow unsafeWriteSink = object.getUnsafeWriteSinkFrozenFilterFlow(bb, objectFlow, source, field);
this.addUse(bb, unsafeWriteSink);
} else {
FieldFilterTypeFlow fieldFilterFlow = object.getInstanceFieldFilterFlow(bb, objectFlow, source, field);
this.addUse(bb, fieldFilterFlow);
}
addUse(bb, object.getInstanceFieldFilterFlow(bb, objectFlow, source, field));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.oracle.graal.pointsto.flow.FieldFilterTypeFlow;
import com.oracle.graal.pointsto.flow.FieldTypeFlow;
import com.oracle.graal.pointsto.flow.TypeFlow;
import com.oracle.graal.pointsto.flow.UnsafeWriteSinkTypeFlow;
import com.oracle.graal.pointsto.meta.AnalysisField;
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.graal.pointsto.meta.AnalysisUniverse;
Expand Down Expand Up @@ -198,21 +197,15 @@ public ArrayElementsTypeFlow getArrayElementsFlow(PointsToAnalysis bb, boolean i
return isStore ? arrayElementsTypeStore.writeFlow() : arrayElementsTypeStore.readFlow();
}

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

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

public UnsafeWriteSinkTypeFlow getUnsafeWriteSinkFrozenFilterFlow(PointsToAnalysis bb, TypeFlow<?> objectFlow, BytecodePosition context, AnalysisField field) {
assert !Modifier.isStatic(field.getModifiers()) && field.hasUnsafeFrozenTypeState() : field;
FieldTypeStore fieldTypeStore = getInstanceFieldTypeStore(bb, objectFlow, context, field);
return fieldTypeStore.unsafeWriteSinkFlow(bb);
}

/** Returns the instance field flow corresponding to a filed of the object's type. */
/** Returns the instance field flow corresponding to a field of the object's type. */
public FieldTypeFlow getInstanceFieldFlow(PointsToAnalysis bb, AnalysisField field, boolean isStore) {
return getInstanceFieldFlow(bb, null, null, field, isStore);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

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

private static final AtomicIntegerFieldUpdater<AnalysisField> unsafeFrozenTypeStateUpdater = AtomicIntegerFieldUpdater
.newUpdater(AnalysisField.class, "unsafeFrozenTypeState");

private final int id;
/** Marks a field loaded from a base layer. */
private final boolean isInBaseLayer;
Expand All @@ -94,12 +90,7 @@ public abstract class AnalysisField extends AnalysisElement implements WrappedJa
@SuppressWarnings("unused") private volatile Object isAccessed;
@SuppressWarnings("unused") private volatile Object isWritten;
@SuppressWarnings("unused") private volatile Object isFolded;

private boolean isJNIAccessed;

@SuppressWarnings("unused") private volatile Object isUnsafeAccessed;
@SuppressWarnings("unused") private volatile int unsafeFrozenTypeState;
@SuppressWarnings("unused") private volatile Object observers;

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

protected TypeState instanceFieldTypeState;

/** Field's position in the list of declaring type's fields, including inherited fields. */
protected int position;

Expand Down Expand Up @@ -254,7 +243,6 @@ public void cleanupAfterAnalysis() {
initialInstanceFieldFlow = null;
readBy = null;
writtenBy = null;
instanceFieldTypeState = null;
}

public boolean registerAsAccessed(Object reason) {
Expand Down Expand Up @@ -361,22 +349,6 @@ public boolean isUnsafeAccessed() {
return AtomicUtils.isSet(this, isUnsafeAccessedUpdater);
}

public void registerAsJNIAccessed() {
isJNIAccessed = true;
}

public boolean isJNIAccessed() {
return isJNIAccessed;
}

public void registerAsFrozenUnsafeAccessed() {
unsafeFrozenTypeStateUpdater.set(this, 1);
}

public boolean hasUnsafeFrozenTypeState() {
return AtomicUtils.isSet(this, unsafeFrozenTypeStateUpdater);
}

public Object getReadBy() {
return isReadUpdater.get(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import com.oracle.graal.pointsto.flow.FilterTypeFlow;
import com.oracle.graal.pointsto.flow.FormalParamTypeFlow;
import com.oracle.graal.pointsto.flow.FormalReturnTypeFlow;
import com.oracle.graal.pointsto.flow.FrozenFieldFilterTypeFlow;
import com.oracle.graal.pointsto.flow.InvokeTypeFlow;
import com.oracle.graal.pointsto.flow.LoadFieldTypeFlow.LoadInstanceFieldTypeFlow;
import com.oracle.graal.pointsto.flow.LoadFieldTypeFlow.LoadStaticFieldTypeFlow;
Expand Down Expand Up @@ -485,9 +484,6 @@ private static String asString(TypeFlow<?> flow) {
} else if (flow instanceof FieldFilterTypeFlow) {
FieldFilterTypeFlow filter = (FieldFilterTypeFlow) flow;
return "FieldFilter(" + formatField(filter.getSource()) + ")";
} else if (flow instanceof FrozenFieldFilterTypeFlow) {
FrozenFieldFilterTypeFlow filter = (FrozenFieldFilterTypeFlow) flow;
return "FrozenFieldFilter(" + formatField(filter.getSource()) + ")";
} else if (flow instanceof NewInstanceTypeFlow) {
return "NewInstance(" + flow.getDeclaredType().toJavaName(false) + ")@" + formatSource(flow);
} else if (flow instanceof DynamicNewInstanceTypeFlow) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@
*/
package com.oracle.graal.pointsto.typestore;

import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

import com.oracle.graal.pointsto.PointsToAnalysis;
import com.oracle.graal.pointsto.flow.FieldTypeFlow;
import com.oracle.graal.pointsto.flow.FrozenFieldFilterTypeFlow;
import com.oracle.graal.pointsto.flow.UnsafeWriteSinkTypeFlow;
import com.oracle.graal.pointsto.flow.context.object.AnalysisObject;
import com.oracle.graal.pointsto.meta.AnalysisField;

Expand All @@ -38,18 +34,9 @@
*/
public abstract class FieldTypeStore {

private static final AtomicReferenceFieldUpdater<FieldTypeStore, FrozenFieldFilterTypeFlow> FROZEN_FILTER_FLOW_UPDATER = AtomicReferenceFieldUpdater.newUpdater(FieldTypeStore.class,
FrozenFieldFilterTypeFlow.class, "frozenFilterFlow");
private static final AtomicReferenceFieldUpdater<FieldTypeStore, UnsafeWriteSinkTypeFlow> UNSAFE_WRITE_SINK_FLOW_UPDATER = AtomicReferenceFieldUpdater.newUpdater(FieldTypeStore.class,
UnsafeWriteSinkTypeFlow.class, "unsafeWriteSinkFlow");

/** The holder of the field flow. */
protected final AnalysisObject object;
protected final AnalysisField field;
/** A filter flow used for unsafe writes on frozen type state. */
private volatile FrozenFieldFilterTypeFlow frozenFilterFlow;
/** A sink used for unsafe writes on frozen type state. */
private volatile UnsafeWriteSinkTypeFlow unsafeWriteSinkFlow;

protected FieldTypeStore(AnalysisField field, AnalysisObject object) {
this.field = field;
Expand All @@ -71,22 +58,4 @@ public AnalysisField field() {
/** Overridden for field type stores that need lazy initialization. */
public void init(@SuppressWarnings("unused") PointsToAnalysis bb) {
}

public UnsafeWriteSinkTypeFlow unsafeWriteSinkFlow(PointsToAnalysis bb) {
assert field.hasUnsafeFrozenTypeState() : "Unsafe write sink flow requested for non unsafe accessed frozen field.";
// first we create the unsafe write sink
if (unsafeWriteSinkFlow == null) {
UNSAFE_WRITE_SINK_FLOW_UPDATER.compareAndSet(this, null, new UnsafeWriteSinkTypeFlow(bb, field));
}
// then we build the filter for it.
if (frozenFilterFlow == null) {
if (FROZEN_FILTER_FLOW_UPDATER.compareAndSet(this, null, new FrozenFieldFilterTypeFlow(bb, field, unsafeWriteSinkFlow))) {
frozenFilterFlow.addUse(bb, writeFlow());
unsafeWriteSinkFlow.addUse(bb, frozenFilterFlow);
}
}

return unsafeWriteSinkFlow;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,6 @@ public boolean registerAsUnsafeAccessed(AnalysisField aField, Object reason) {
return aField.registerAsUnsafeAccessed(reason);
}

public void registerAsFrozenUnsafeAccessed(Field field, Object reason) {
registerAsFrozenUnsafeAccessed(getMetaAccess().lookupJavaField(field), reason);
}

public void registerAsFrozenUnsafeAccessed(AnalysisField aField, Object reason) {
aField.registerAsFrozenUnsafeAccessed();
registerAsUnsafeAccessed(aField, reason);
}

public void registerAsRoot(Executable method, boolean invokeSpecial, String reason, MultiMethod.MultiMethodKey... otherRoots) {
bb.addRootMethod(method, invokeSpecial, reason, otherRoots);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ private static void addField(Field reflField, boolean writable, DuringAnalysisAc
JNIAccessibleClass jniClass = addClass(reflField.getDeclaringClass(), access);
AnalysisField field = access.getMetaAccess().lookupJavaField(reflField);
jniClass.addFieldIfAbsent(field.getName(), name -> new JNIAccessibleField(jniClass, field.getJavaKind(), field.getModifiers()));
field.registerAsJNIAccessed();
field.registerAsRead("it is registered for as JNI accessed");
if (writable) {
field.registerAsWritten("it is registered as JNI writable");
Expand Down

0 comments on commit c4cd029

Please sign in to comment.