Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FunctionRootNode.java @ 13338:652f24858aad
SL: simplified call nodes. aligned builtin inlining with user function inlining.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Sun, 15 Dec 2013 23:32:41 +0100 |
parents | 71991b7a0f14 |
children | 40fd9958cdf5 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FunctionRootNode.java Sun Dec 15 22:43:45 2013 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FunctionRootNode.java Sun Dec 15 23:32:41 2013 +0100 @@ -35,14 +35,14 @@ private final TypedNode uninitializedBody; private final String name; - private final boolean alwaysInline; + private final boolean inlineImmediatly; - private FunctionRootNode(TypedNode body, String name, boolean alwaysInline) { + private FunctionRootNode(TypedNode body, String name, boolean inlineImmediatly) { super(null); this.uninitializedBody = NodeUtil.cloneNode(body); this.body = adoptChild(body); this.name = name; - this.alwaysInline = alwaysInline; + this.inlineImmediatly = inlineImmediatly; } public static CallTarget createBuiltin(SLContext context, NodeFactory<? extends BuiltinNode> factory, String name) { @@ -67,36 +67,12 @@ return body.executeGeneric(frame); } - public boolean isAlwaysInline() { - return alwaysInline; - } - - public TypedNode inline(ArgumentsNode clonedArgs) { - TypedNode clonedBody = NodeUtil.cloneNode(uninitializedBody); - if (clonedBody instanceof BuiltinNode) { - return inlineBuiltin(clonedArgs, (BuiltinNode) clonedBody); - } else if (clonedBody instanceof FunctionBodyNode) { - return inlineFunction(clonedArgs, (FunctionBodyNode) clonedBody); - } else { - throw new UnsupportedOperationException(); - } + public boolean isInlineImmediatly() { + return inlineImmediatly; } - private InlinedFunctionNode inlineFunction(ArgumentsNode clonedArgs, FunctionBodyNode clonedBody) { - return new InlinedFunctionNode(getCallTarget(), clonedBody, clonedArgs); - } - - private static TypedNode inlineBuiltin(ArgumentsNode clonedArgs, BuiltinNode builtin) { - TypedNode[] callerArgs = clonedArgs.getArguments(); - TypedNode[] builtinArgs = builtin.getArguments(); - for (int i = 0; i < builtinArgs.length; i++) { - if (i < callerArgs.length) { - builtinArgs[i].replace(callerArgs[i]); - } else { - builtinArgs[i].replace(new NullLiteralNode()); - } - } - return builtin; + public TypedNode inline() { + return NodeUtil.cloneNode(uninitializedBody); } public Node getUninitializedBody() { @@ -108,34 +84,6 @@ return "function " + name; } - private static final class InlinedFunctionNode extends TypedNode implements InlinedCallSite { - - @Child private FunctionBodyNode body; - @Child private ArgumentsNode arguments; - - private final CallTarget callTarget; - private final FrameDescriptor frameDescriptor; - - public InlinedFunctionNode(CallTarget callTarget, FunctionBodyNode body, ArgumentsNode arguments) { - this.callTarget = callTarget; - this.body = adoptChild(body); - this.frameDescriptor = body.getFrameDescriptor(); - this.arguments = adoptChild(arguments); - } - - @Override - public Object executeGeneric(VirtualFrame frame) { - SLArguments args = new SLArguments(arguments.executeArray(frame)); - VirtualFrame childFrame = Truffle.getRuntime().createVirtualFrame(frame.pack(), args, frameDescriptor); - return body.executeGeneric(childFrame); - } - - public CallTarget getCallTarget() { - return callTarget; - } - - } - public String getName() { return name; }