Building a graph manually
Christian Wimmer
christian.wimmer at oracle.com
Tue Jun 14 18:24:53 UTC 2016
Seems like you are not adding the ConstantNode to the graph.
ValueNode valueNode1 = new ConstantNode(JavaConstant.forInt(154),
StampFactory.intValue());
should be
ValueNode valueNode1 = graph.unique(new
ConstantNode(JavaConstant.forInt(154), StampFactory.intValue()));
Since constants are floating nodes, you need to use unique() instead of
add() - but they still need to be made part of the graph.
-Christian
On 06/14/2016 01:44 AM, Bahram Yarahmadi wrote:
> Hello guys,
>
> I want to build a graph manually but when I want to add an invokeNode to
> the graph I get an error
> this is my code :
> StructuredGraph graph = new StructuredGraph(AllowAssumptions.YES);
> ReturnNode returnNode = graph.add(new ReturnNode(null));
> ValueNode valueNode1 = new ConstantNode(JavaConstant.forInt(154),
> StampFactory.intValue());
> ValueNode valueNode2 = new ConstantNode(JavaConstant.forInt(25),
> StampFactory.intValue());
> ValueNode[] valueNodes = new ValueNode[2];
> valueNodes[0] = valueNode1;
> valueNodes[1] = valueNode2;
> ResolvedJavaMethod method = findMethod(AA.class, "SubInt");
> MethodCallTargetNode callTarget = graph.add(new
> MethodCallTargetNode(MethodCallTargetNode.InvokeKind.Static,
> method, valueNodes,
> StampFactory.forDeclaredType(null,
> method.getSignature().getReturnType(null), false), null));
> InvokeNode ink = graph.add(new InvokeNode(callTarget,
> BytecodeFrame.UNWIND_BCI));
> graph.start().setNext(ink);
> ink.setNext(returnNode);
> Debug.dump(Debug.BASIC_LOG_LEVEL, graph, "Graph");
> and my SubInt method is
>
> public static void SubInt(int a, int b) {
> System.out.println("///");
> }
> but when I try to test with inittest I get this error :
> testPrintBytecodes(com.oracle.graal.compiler.test.tutorial.GraalTutorial)
> java.lang.AssertionError: Input not alive
> at
> com.oracle.graal.graph.NodeClass.registerAtInputsAsUsageHelper(NodeClass.java:1257)
> at
> com.oracle.graal.graph.NodeClass.registerAtInputsAsUsage(NodeClass.java:1245)
> at com.oracle.graal.graph.Node.initialize(Node.java:593)
> at com.oracle.graal.graph.Graph.addHelper(Graph.java:446)
> at com.oracle.graal.graph.Graph.add(Graph.java:398)
> at
> com.oracle.graal.compiler.test.tutorial.GraalTutorial.testPrintBytecodes(GraalTutorial.java:278)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
>
>
>
> Thanks again
>
> Bahram,
>
More information about the graal-dev
mailing list