use of org.graalvm.compiler.nodes.ValueNode in project graal by oracle.
the class EarlyReadEliminationTest method testBadLoop.
@Test
public void testBadLoop() {
ValueNode result = getReturn("testBadLoopSnippet", false).result();
assertDeepEquals(0, result.graph().getNodes().filter(LoadFieldNode.class).count());
assertTrue(result instanceof ProxyNode);
assertTrue(((ProxyNode) result).value() instanceof ValuePhiNode);
}
use of org.graalvm.compiler.nodes.ValueNode in project graal by oracle.
the class EarlyReadEliminationTest method testSimpleLoop.
@Test
public void testSimpleLoop() {
// Test without lowering.
ValueNode result = getReturn("testSimpleLoopSnippet", false).result();
assertTrue(result.graph().getNodes().filter(LoadFieldNode.class).isEmpty());
assertDeepEquals(result.graph().getParameter(1), result);
// Now test with lowering.
result = getReturn("testSimpleLoopSnippet", true).result();
assertTrue(result.graph().getNodes().filter(ReadNode.class).isEmpty());
assertDeepEquals(result.graph().getParameter(1), result);
}
use of org.graalvm.compiler.nodes.ValueNode in project graal by oracle.
the class EarlyReadEliminationTest method testMaterialized.
@Test
public void testMaterialized() {
ValueNode result = getReturn("testMaterializedSnippet", false).result();
assertTrue(result.graph().getNodes().filter(LoadFieldNode.class).isEmpty());
assertDeepEquals(result.graph().getParameter(0), result);
}
use of org.graalvm.compiler.nodes.ValueNode in project graal by oracle.
the class LongNodeChainTest method longAddChain.
private void longAddChain(boolean reverse) {
HighTierContext context = getDefaultHighTierContext();
OptionValues options = getInitialOptions();
StructuredGraph graph = new StructuredGraph.Builder(options, DebugContext.create(options, DebugHandlersFactory.LOADER)).build();
ValueNode constant = graph.unique(ConstantNode.forPrimitive(JavaConstant.INT_1));
ValueNode value = null;
if (reverse) {
// Make sure the constant's stamp is not used to infer the add node's stamp.
OpaqueNode opaque = graph.unique(new OpaqueNode(constant));
constant = opaque;
AddNode addNode = graph.unique(new AddNode(constant, constant));
value = addNode;
for (int i = 1; i < N; ++i) {
AddNode newAddNode = graph.addWithoutUnique(new AddNode(constant, constant));
addNode.setY(newAddNode);
addNode = newAddNode;
}
opaque.replaceAndDelete(opaque.getValue());
} else {
value = constant;
for (int i = 0; i < N; ++i) {
value = graph.unique(new AddNode(constant, value));
}
}
ReturnNode returnNode = graph.add(new ReturnNode(value));
graph.start().setNext(returnNode);
for (SchedulingStrategy s : Strategies) {
new SchedulePhase(s).apply(graph);
}
new CanonicalizerPhase().apply(graph, context);
JavaConstant asConstant = (JavaConstant) returnNode.result().asConstant();
Assert.assertEquals(N + 1, asConstant.asInt());
}
use of org.graalvm.compiler.nodes.ValueNode in project graal by oracle.
the class PointsToStats method formatSource.
private static String formatSource(TypeFlow<?> flow) {
Object source = flow.getSource();
if (source instanceof ValueNode) {
ValueNode node = (ValueNode) source;
NodeSourcePosition nodeSource = node.getNodeSourcePosition();
if (nodeSource != null) {
return formatMethod(nodeSource.getMethod()) + ":" + nodeSource.getBCI();
} else if (flow.graphRef() != null) {
return formatMethod(flow.graphRef().getMethod());
} else {
return "<unknown-source>";
}
} else if (source instanceof AnalysisType) {
return formatType((AnalysisType) source);
} else if (source instanceof AnalysisField) {
return formatField((AnalysisField) source);
} else if (source == null) {
return "<no-source>";
} else {
return source.getClass().getSimpleName();
}
}
Aggregations