annotate graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FunctionCallNode.java @ 13803:e076c87ab175

Truffle: refactored inlining interfaces to a more compact CallNode.
author Christian Humer <christian.humer@gmail.com>
date Fri, 24 Jan 2014 15:55:41 +0100
parents graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/CallNode.java@c2ed2ce2cfe0
children 3840d61e0e68
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
1 /*
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
4 *
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
8 *
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
13 * accompanied this code).
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
14 *
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
18 *
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
21 * questions.
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
22 */
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
23 package com.oracle.truffle.sl.nodes;
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
24
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
25 import com.oracle.truffle.api.*;
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
26 import com.oracle.truffle.api.frame.*;
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
27 import com.oracle.truffle.api.impl.*;
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
28 import com.oracle.truffle.api.nodes.*;
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
29 import com.oracle.truffle.sl.runtime.*;
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
30
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
31 public abstract class FunctionCallNode extends TypedNode {
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
32
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
33 private static final int INLINE_CACHE_SIZE = 2;
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
34
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
35 @Child protected TypedNode functionNode;
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
36 @Child protected ArgumentsNode argumentsNode;
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
37
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
38 public FunctionCallNode(TypedNode functionNode, ArgumentsNode argumentsNode) {
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
39 this.functionNode = adoptChild(functionNode);
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
40 this.argumentsNode = adoptChild(argumentsNode);
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
41 }
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
42
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
43 @Override
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
44 public final Object executeGeneric(VirtualFrame frame) {
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
45 CallTarget function;
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
46 try {
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
47 function = functionNode.executeCallTarget(frame);
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
48 } catch (UnexpectedResultException e) {
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
49 throw new UnsupportedOperationException("Call to " + e.getMessage() + " not supported.");
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
50 }
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
51 Object[] arguments = argumentsNode.executeArray(frame);
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
52 return executeCall(frame, function, new SLArguments(arguments));
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
53 }
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
54
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
55 public abstract Object executeCall(VirtualFrame frame, CallTarget function, SLArguments arguments);
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
56
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
57 public static FunctionCallNode create(TypedNode function, TypedNode[] arguments) {
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
58 return new UninitializedCallNode(function, new ArgumentsNode(arguments), 0);
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
59 }
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
60
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
61 private static final class UninitializedCallNode extends FunctionCallNode {
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
62
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
63 protected final int depth;
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
64
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
65 UninitializedCallNode(TypedNode function, ArgumentsNode args, int depth) {
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
66 super(function, args);
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
67 this.depth = depth;
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
68 }
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
69
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
70 UninitializedCallNode(UninitializedCallNode copy) {
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
71 super(null, null);
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
72 this.depth = copy.depth + 1;
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
73 }
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
74
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
75 @Override
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
76 public Object executeCall(VirtualFrame frame, CallTarget function, SLArguments arguments) {
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
77 CompilerDirectives.transferToInterpreter();
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
78 return specialize(function).executeCall(frame, function, arguments);
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
79 }
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
80
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
81 private FunctionCallNode specialize(CallTarget function) {
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
82 CompilerAsserts.neverPartOfCompilation();
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
83 if (depth < INLINE_CACHE_SIZE) {
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
84 return replace(new CachedCallNode(functionNode, argumentsNode, function, new UninitializedCallNode(this)));
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
85 } else {
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
86 FunctionCallNode topMost = (FunctionCallNode) NodeUtil.getNthParent(this, depth);
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
87 return topMost.replace(new GenericCallNode(topMost.functionNode, topMost.argumentsNode));
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
88 }
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
89 }
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
90
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
91 }
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
92
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
93 private static final class CachedCallNode extends FunctionCallNode {
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
94
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
95 protected final CallTarget cachedFunction;
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
96
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
97 @Child protected CallNode callNode;
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
98 @Child protected FunctionCallNode nextNode;
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
99
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
100 public CachedCallNode(TypedNode function, ArgumentsNode arguments, CallTarget cachedFunction, FunctionCallNode next) {
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
101 super(function, arguments);
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
102 this.cachedFunction = cachedFunction;
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
103 this.callNode = adoptChild(CallNode.create(cachedFunction));
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
104 this.nextNode = adoptChild(next);
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
105
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
106 // inline usually known functions that should always be inlined
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
107 if (findSLFunctionRoot(cachedFunction).isInlineImmediatly()) {
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
108 if (callNode.isInlinable() && !callNode.isInlined()) {
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
109 callNode.inline();
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
110 }
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
111 }
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
112 }
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
113
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
114 @Override
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
115 public Object executeCall(VirtualFrame frame, CallTarget function, SLArguments arguments) {
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
116 if (this.cachedFunction == function) {
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
117 return callNode.call(frame.pack(), arguments);
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
118 }
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
119 return nextNode.executeCall(frame, function, arguments);
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
120 }
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
121
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
122 private static FunctionRootNode findSLFunctionRoot(CallTarget target) {
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
123 return (FunctionRootNode) ((DefaultCallTarget) target).getRootNode();
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
124 }
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
125
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
126 }
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
127
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
128 private static final class GenericCallNode extends FunctionCallNode {
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
129
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
130 GenericCallNode(TypedNode functionNode, ArgumentsNode arguments) {
13338
652f24858aad SL: simplified call nodes. aligned builtin inlining with user function inlining.
Christian Humer <christian.humer@gmail.com>
parents: 13276
diff changeset
131 super(functionNode, arguments);
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
132 }
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
133
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
134 @Override
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
135 public Object executeCall(VirtualFrame frame, CallTarget function, SLArguments arguments) {
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13709
diff changeset
136 return function.call(frame.pack(), arguments);
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
137 }
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
138 }
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
139
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
140 }