Skip to content

Commit

Permalink
[GR-30698] [GR-20751] Fix failing daily tests.
Browse files Browse the repository at this point in the history
PullRequest: graal/8782
  • Loading branch information
cstancu committed Apr 28, 2021
2 parents e0247bb + 4bc9b22 commit ec3ea38
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public class MethodTypeFlowBuilder {
private NodeBitMap processedNodes;
private Map<PhiNode, TypeFlowBuilder<?>> loopPhiFlows;

private final TypeFlowGraphBuilder typeFlowGraphBuilder;
protected final TypeFlowGraphBuilder typeFlowGraphBuilder;

public MethodTypeFlowBuilder(BigBang bb, MethodTypeFlow methodFlow) {
this.bb = bb;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public CompareAndSetVMThreadLocalNode(VMThreadLocalInfo threadLocalInfo, ValueNo
this.update = update;
}

public ValueNode getUpdate() {
return update;
}

@Override
public void lower(LoweringTool tool) {
assert threadLocalInfo.offset >= 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public StoreVMThreadLocalNode(VMThreadLocalInfo threadLocalInfo, ValueNode holde
this.value = value;
}

public ValueNode getValue() {
return value;
}

@Override
public void lower(LoweringTool tool) {
assert threadLocalInfo.offset >= 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.graal.pointsto.typestate.TypeState;
import com.oracle.svm.core.graal.jdk.SubstrateArraysCopyOf;
import com.oracle.svm.core.graal.thread.CompareAndSetVMThreadLocalNode;
import com.oracle.svm.core.graal.thread.LoadVMThreadLocalNode;
import com.oracle.svm.core.graal.thread.StoreVMThreadLocalNode;
import com.oracle.svm.core.meta.SubstrateObjectConstant;
import com.oracle.svm.core.util.UserError.UserException;
import com.oracle.svm.core.util.VMError;
Expand Down Expand Up @@ -182,7 +184,11 @@ protected void delegateNodeProcessing(FixedNode n, MethodTypeFlowBuilder.TypeFlo

TypeFlowBuilder<?> result;
if (objStamp.isExactType()) {
/* The node has an exact type. Create a source type flow. */
/*
* The node has an exact type. Create a source type flow. This works with
* allocation site sensitivity because the StoreVMThreadLocal is modeled by
* writing the objects to the all-instantiated.
*/
result = TypeFlowBuilder.create(bb, node, SourceTypeFlow.class, () -> {
SourceTypeFlow src = new SourceTypeFlow(node, TypeState.forExactType(bb, (AnalysisType) objStamp.type(), !objStamp.nonNull()));
methodFlow.addSource(src);
Expand All @@ -199,10 +205,33 @@ protected void delegateNodeProcessing(FixedNode n, MethodTypeFlowBuilder.TypeFlo
}
state.add(node, result);
}

} else if (n instanceof StoreVMThreadLocalNode) {
StoreVMThreadLocalNode node = (StoreVMThreadLocalNode) n;
storeVMThreadLocal(state, node, node.getValue());
} else if (n instanceof CompareAndSetVMThreadLocalNode) {
CompareAndSetVMThreadLocalNode node = (CompareAndSetVMThreadLocalNode) n;
storeVMThreadLocal(state, node, node.getUpdate());
} else if (n instanceof SubstrateArraysCopyOf) {
SubstrateArraysCopyOf node = (SubstrateArraysCopyOf) n;
processArraysCopyOf(n, node.getOriginal(), node.getNewObjectArrayType(), state);
}
}

private void storeVMThreadLocal(TypeFlowsOfNodes state, ValueNode storeNode, ValueNode value) {
Stamp stamp = value.stamp(NodeView.DEFAULT);
if (stamp instanceof ObjectStamp) {
/* Add the value object to the state of its declared type. */
TypeFlowBuilder<?> valueBuilder = state.lookup(value);
ObjectStamp valueStamp = (ObjectStamp) stamp;
AnalysisType valueType = (AnalysisType) (valueStamp.type() == null ? bb.getObjectType() : valueStamp.type());

TypeFlowBuilder<?> storeBuilder = TypeFlowBuilder.create(bb, storeNode, ProxyTypeFlow.class, () -> {
ProxyTypeFlow proxy = new ProxyTypeFlow(storeNode, valueType.getTypeFlow(bb, false));
methodFlow.addMiscEntry(proxy);
return proxy;
});
storeBuilder.addUseDependency(valueBuilder);
typeFlowGraphBuilder.registerSinkBuilder(storeBuilder);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ private static void unreachableInvoke(StructuredGraph graph, Invoke invoke, Subs
if (!callTarget.isStatic()) {
InliningUtil.nonNullReceiver(invoke);
}
AnalysisSpeculation speculation = new AnalysisSpeculation(new AnalysisSpeculationReason("The call to " + callTarget.targetMethod().format("%H.%n(%P)") + " is not reachable."));
HostedMethod targetMethod = (HostedMethod) callTarget.targetMethod();
String message = String.format("The call to %s is not reachable when called from %s.%n", targetMethod.format("%H.%n(%P)"), graph.method().format("%H.%n(%P)"));
AnalysisSpeculation speculation = new AnalysisSpeculation(new AnalysisSpeculationReason(message));
FixedGuardNode node = new FixedGuardNode(LogicConstantNode.forBoolean(true, graph), DeoptimizationReason.UnreachedCode, DeoptimizationAction.None, speculation, true);
graph.addBeforeFixed(invoke.asNode(), graph.add(node));
graph.getDebug().dump(DebugContext.VERY_DETAILED_LEVEL, graph, "After dead invoke %s", invoke);
Expand Down

0 comments on commit ec3ea38

Please sign in to comment.