use of org.graalvm.compiler.nodes.spi.LimitedValueProxy in project graal by oracle.
the class StrengthenStampsPhase method run.
@Override
protected void run(StructuredGraph graph) {
for (Node n : graph.getNodes()) {
if (n instanceof ValueNode && !(n instanceof LimitedValueProxy) && !(n instanceof PhiNode)) {
/*
* The stamp of proxy nodes and phi nodes is inferred automatically, so we do not
* need to improve them.
*/
ValueNode node = (ValueNode) n;
/*
* First ask the node to improve the stamp itself, to incorporate already improved
* input stamps.
*/
node.inferStamp();
Stamp newStamp = strengthen(node.stamp(NodeView.DEFAULT));
if (newStamp != null) {
node.setStamp(newStamp);
}
}
if (n instanceof LoadFieldNode) {
LoadFieldNode node = (LoadFieldNode) n;
updateStamp(node, toHosted(node.field()).getFieldTypeProfile());
} else if (n instanceof InstanceOfNode) {
InstanceOfNode node = (InstanceOfNode) n;
ObjectStamp newStamp = (ObjectStamp) strengthen(node.getCheckedStamp());
if (newStamp != null) {
node.strengthenCheckedStamp(newStamp);
}
} else if (n instanceof PiNode) {
PiNode node = (PiNode) n;
Stamp newStamp = strengthen(node.piStamp());
if (newStamp != null) {
node.strengthenPiStamp(newStamp);
}
}
}
}
use of org.graalvm.compiler.nodes.spi.LimitedValueProxy in project graal by oracle.
the class GraphUtil method originalValueSimple.
private static ValueNode originalValueSimple(ValueNode value) {
/* The very simple case: look through proxies. */
ValueNode cur = originalValueForProxy(value);
while (cur instanceof PhiNode) {
/*
* We found a phi function. Check if we can analyze it without allocating temporary data
* structures.
*/
PhiNode phi = (PhiNode) cur;
ValueNode phiSingleValue = null;
int count = phi.valueCount();
for (int i = 0; i < count; ++i) {
ValueNode phiCurValue = originalValueForProxy(phi.valueAt(i));
if (phiCurValue == phi) {
/* Simple cycle, we can ignore the input value. */
} else if (phiSingleValue == null) {
/* The first input. */
phiSingleValue = phiCurValue;
} else if (phiSingleValue != phiCurValue) {
if (phiSingleValue instanceof PhiNode || phiCurValue instanceof PhiNode) {
/*
* We have two different input values for the phi function, and at least one
* of the inputs is another phi function. We need to do a complicated
* exhaustive check.
*/
return originalValueForComplicatedPhi(phi, new NodeBitMap(value.graph()));
} else {
/*
* We have two different input values for the phi function, but none of them
* is another phi function. This phi function cannot be reduce any further,
* so the phi function is the original value.
*/
return phi;
}
}
}
/*
* Successfully reduced the phi function to a single input value. The single input value
* can itself be a phi function again, so we might take another loop iteration.
*/
assert phiSingleValue != null;
cur = phiSingleValue;
}
/* We reached a "normal" node, which is the original value. */
assert !(cur instanceof LimitedValueProxy) && !(cur instanceof PhiNode);
return cur;
}
Aggregations