got a Truffle Exception
Grace Wang
huohuohuomumu at gmail.com
Mon Jun 1 16:10:37 UTC 2015
Hello Chris,
Yes the testBuilder calls execute directly!
private static void testBuilder(String src, VirtualFrame frame) {
Builder builder = parse(src, Builder.builderBuilder(MumAlg.class));
MumblerNode eval = builder.build(new MumExec(frame.getFrameDescriptor()));
System.out.println("exec " + src + " = " + eval.execute(frame));
}
But I don’t know how to create the ‘RootNode’ or ‘CallTarget’.
Thank you for providing these tutorials, I’ll watch them :)
Regards,
Grace
On June 1, 2015 at 11:53:51 PM, Chris Seaton (chris.seaton at oracle.com) wrote:
Hello Grace,
I looks like your program is missing some key concepts of how programs using Truffle need to be structured to work correctly.
The point of failure here looks to be that you are executing a node without any kind of CallTarget or RootNode.
I guess that testBuilder calls execute on a node directly?
It is the RootNode which walks the AST and assigns parent nodes, so if you aren’t using a RootNode that won’t happen and nodes will not know what their parents are (they need to know so they can tell them when they are replaced).
Have you watched the Truffle tutorials? They might be a good place to start.
http://youtu.be/N_sOxGkZfTg
http://youtu.be/EXzaBTLlS9I
Regards,
Chris
On 1 Jun 2015, at 16:35, Grace Wang <huohuohuomumu at gmail.com> wrote:
Hi,
I’m using truffle in a testing project, but somehow got the following exception. I’m not familiar with the code, but I’d like to know what could possibly cause this exception?
Thank you very much!
Regards,
Grace Wang
Exception in thread "main" java.lang.IllegalStateException: This node cannot be replaced, because it does not yet have a parent.
at com.oracle.truffle.api.nodes.Node.replaceHelper(Node.java:272)
at com.oracle.truffle.api.nodes.NodeUtil.nonAtomicReplace(NodeUtil.java:195)
at com.oracle.truffle.api.dsl.internal.SpecializationNode.insertAt(SpecializationNode.java:523)
at com.oracle.truffle.api.dsl.internal.SpecializationNode$InsertionEvent1.call(SpecializationNode.java:649)
at com.oracle.truffle.api.dsl.internal.SpecializationNode$InsertionEvent1.call(SpecializationNode.java:633)
at com.oracle.truffle.api.nodes.Node.atomic(Node.java:521)
at com.oracle.truffle.api.dsl.internal.SpecializationNode.uninitialized(SpecializationNode.java:395)
at mumbler.truffle.node.special.QuoteNodeGen$UninitializedNode_.acceptAndExecute(QuoteNodeGen.java:160)
at mumbler.truffle.node.special.QuoteNodeGen$BaseNode_.executeGeneric(QuoteNodeGen.java:91)
at mumbler.truffle.node.special.QuoteNodeGen.execute(QuoteNodeGen.java:41)
at mumbler.truffle.newparser.TruffleMumblerMain2.testBuilder(TruffleMumblerMain2.java:127)
at mumbler.truffle.newparser.TruffleMumblerMain2.testMumExec(TruffleMumblerMain2.java:75)
at mumbler.truffle.newparser.TruffleMumblerMain2.main(TruffleMumblerMain2.java:49)
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:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
I also show the related code causing the exception here (although these are probably not helpful):
(1) QuoteNodeGen.java
@GeneratedBy(QuoteNode.class)
private static final class UninitializedNode_ extends BaseNode_ {
UninitializedNode_(QuoteNodeGen root) {
super(root, 2147483647);
}
@Override
public Object acceptAndExecute(Frame frameValue, Object literalNodeValue) {
return uninitialized(frameValue, literalNodeValue);
}
static BaseNode_ create(QuoteNodeGen root) {
return new UninitializedNode_(root);
}
}
(2)QuoteNodeGen.java
public Object executeGeneric(Frame frameValue) {
Object literalNodeValue_ = executeLiteralNode_(frameValue);
return acceptAndExecute(frameValue, literalNodeValue_);
}
(3) QuoteNodeGen.java
@Override
public Object execute(VirtualFrame frameValue) {
return specialization_.executeGeneric(frameValue);
}
More information about the graal-dev
mailing list