Mercurial > hg > graal-compiler
changeset 13804:3840d61e0e68
Merge.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 28 Jan 2014 12:52:57 +0100 |
parents | e076c87ab175 |
children | 739194d1e813 |
files | graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleInliningImpl.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/CallNode.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FunctionCallNode.java |
diffstat | 4 files changed, 52 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleInliningImpl.java Fri Jan 24 15:55:41 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleInliningImpl.java Tue Jan 28 12:52:57 2014 +0100 @@ -84,7 +84,7 @@ if (inlined) { for (InlinableCallSiteInfo callSite : inlinableCallSites) { - if (callSite.getCallSite().isInlinable()) { + if (callSite.getCallSite().isInlinable() && !callSite.getCallSite().isInlined()) { CallNode.internalResetCallCount(callSite.getCallSite()); } } @@ -215,7 +215,7 @@ public boolean visit(Node node) { if (node instanceof CallNode) { CallNode callNode = (CallNode) node; - if (callNode.isInlinable()) { + if (callNode.isInlinable() && !callNode.isInlined()) { inlinableCallSites.add(new InlinableCallSiteInfo(callNode)); } }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/CallNode.java Fri Jan 24 15:55:41 2014 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/CallNode.java Tue Jan 28 12:52:57 2014 +0100 @@ -29,9 +29,9 @@ import com.oracle.truffle.api.impl.*; /** - * This node represents a call to a constant {@link CallTarget} in the Truffle AST. This node should - * be used whenever a {@link CallTarget} is considered constant at a certain location. This enables - * the Truffle runtime to perform inlining or other optimizations for this call-site. + * This node represents a call to a static {@link CallTarget}. This node should be used whenever a + * {@link CallTarget} is considered constant at a certain location in the tree. This enables the + * Truffle runtime to perform inlining or other optimizations for this call-site. * * @see #create(CallTarget) to create a CallNode instance. */ @@ -44,7 +44,7 @@ } /** - * Returns the constant {@link CallTarget} that is associated with this {@link CallNode}. + * @return the constant {@link CallTarget} that is associated with this {@link CallNode}. */ public CallTarget getCallTarget() { return callTarget; @@ -60,44 +60,34 @@ public abstract Object call(PackedFrame caller, Arguments arguments); /** - * Returns <code>true</code> if this {@link CallNode} can be inlined. A {@link CallTarget} is - * considered inlinable if it was created using + * Returns <code>true</code> if the {@link CallTarget} contained in this {@link CallNode} can be + * inlined. A {@link CallTarget} is considered inlinable if it was created using * {@link TruffleRuntime#createCallTarget(RootNode)} and if the enclosed {@link RootNode} * returns <code>true</code> for {@link RootNode#isInlinable()}. */ - public boolean isInlinable() { - return false; - } + public abstract boolean isInlinable(); /** - * Returns true if this {@link CallNode} was already inlined. + * @return true if this {@link CallNode} was already inlined. */ - public boolean isInlined() { - return false; - } + public abstract boolean isInlined(); /** * Enforces an inlining optimization on this {@link CallNode} instance. If not performed * manually the Truffle runtime may perform inlining using an heuristic to optimize the - * performance of the execution. It is recommended to implement an optimized version of - * {@link RootNode#inline()}. + * performance of the execution. It is recommended to implement an version of + * {@link RootNode#inline()} that adapts the inlining for possible guest language specific + * behavior. If the this {@link CallNode} is not inlinable or is already inlined + * <code>false</code> is returned. * - * @return true if the inlining operation was successful. - * @throws IllegalStateException if {@link #isInlinable()} is false. + * @return <code>true</code> if the inlining operation was successful. */ - public boolean inline() { - CompilerDirectives.transferToInterpreter(); - if (!isInlinable()) { - throw new IllegalStateException("Invoked inline on a non inlinable CallNode."); - } - assert !isInlined(); - return false; - } + public abstract boolean inline(); /** - * Creates a new {@link CallNode} using a constant {@link CallTarget}. + * Creates a new {@link CallNode} using a {@link CallTarget}. * - * @param target the {@link CallTarget} the {@link CallNode} should call + * @param target the {@link CallTarget} to call * @return a call node that calls the provided target */ public static CallNode create(CallTarget target) { @@ -112,7 +102,7 @@ * Warning: this is internal API and may change without notice. */ public static int internalGetCallCount(CallNode callNode) { - if (callNode.isInlinable()) { + if (callNode.isInlinable() && !callNode.isInlined()) { return ((InlinableCallNode) callNode).getCallCount(); } throw new UnsupportedOperationException(); @@ -122,7 +112,7 @@ * Warning: this is internal API and may change without notice. */ public static void internalResetCallCount(CallNode callNode) { - if (callNode.isInlinable()) { + if (callNode.isInlinable() && !callNode.isInlined()) { ((InlinableCallNode) callNode).resetCallCount(); return; } @@ -147,6 +137,21 @@ return callTarget.call(caller, arguments); } + @Override + public boolean inline() { + return false; + } + + @Override + public boolean isInlinable() { + return false; + } + + @Override + public boolean isInlined() { + return false; + } + } static final class InlinableCallNode extends CallNode { @@ -167,7 +172,6 @@ @Override public boolean inline() { - super.inline(); DefaultCallTarget defaultTarget = (DefaultCallTarget) getCallTarget(); RootNode originalRootNode = defaultTarget.getRootNode(); boolean inlined = false; @@ -180,6 +184,11 @@ } @Override + public boolean isInlined() { + return false; + } + + @Override public boolean isInlinable() { return true; } @@ -216,8 +225,13 @@ } @Override + public boolean inline() { + return false; + } + + @Override public boolean isInlinable() { - return false; + return true; } @Override
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java Fri Jan 24 15:55:41 2014 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java Tue Jan 28 12:52:57 2014 +0100 @@ -77,7 +77,7 @@ /** * Returns the number of nodes that would be returned if {@link #inline()} would get invoked. - * This node count may be used for the calculation of a smart inlining heuristic. + * This node count may be used for the calculation in a smart inlining heuristic. * * @see RootNode#inline() * @see RootNode#isInlinable() @@ -93,9 +93,9 @@ } /** - * Returns true if this RootNode can be inlined. If this method returns true proper - * implementations of {@link #inline()} and {@link #getInlineNodeCount()} must be provided. - * Returns true by default. + * Returns true if this RootNode can be inlined. If this method returns true implementations of + * {@link #inline()} and {@link #getInlineNodeCount()} must be provided. Returns + * <code>true</code> by default. * * @see RootNode#inline() * @see RootNode#getInlineNodeCount()
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FunctionCallNode.java Fri Jan 24 15:55:41 2014 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FunctionCallNode.java Tue Jan 28 12:52:57 2014 +0100 @@ -105,9 +105,7 @@ // inline usually known functions that should always be inlined if (findSLFunctionRoot(cachedFunction).isInlineImmediatly()) { - if (callNode.isInlinable() && !callNode.isInlined()) { - callNode.inline(); - } + callNode.inline(); } }