Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultDirectCallNode.java @ 20131:4b12d5355811
Truffle: do not use iterators for visitors.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Thu, 02 Apr 2015 01:27:27 +0200 |
parents | 36fb9592c13b |
children |
rev | line source |
---|---|
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * accompanied this code). |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 * questions. |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 */ |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 package com.oracle.truffle.api.impl; |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import com.oracle.truffle.api.*; |
15064
f675818d9ad0
new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
28 import com.oracle.truffle.api.frame.*; |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 import com.oracle.truffle.api.nodes.*; |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 |
15093
5634b199c4da
Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents:
15091
diff
changeset
|
31 /** |
5634b199c4da
Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents:
15091
diff
changeset
|
32 * This is runtime specific API. Do not use in a guest language. |
5634b199c4da
Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents:
15091
diff
changeset
|
33 */ |
5634b199c4da
Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents:
15091
diff
changeset
|
34 public final class DefaultDirectCallNode extends DirectCallNode { |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 |
15089
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
36 private boolean inliningForced; |
448338c9ce96
Truffle: Made inlining context-insensitive again to reduce complexity.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
37 |
17149
0a35e2789735
Truffle: remove unnecessary DefaultTruffleRuntime fields
Andreas Woess <andreas.woess@jku.at>
parents:
15564
diff
changeset
|
38 public DefaultDirectCallNode(CallTarget target) { |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 super(target); |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 } |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 @Override |
15564
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
43 public Object call(final VirtualFrame frame, Object[] arguments) { |
17149
0a35e2789735
Truffle: remove unnecessary DefaultTruffleRuntime fields
Andreas Woess <andreas.woess@jku.at>
parents:
15564
diff
changeset
|
44 final CallTarget currentCallTarget = defaultTruffleRuntime().getCurrentFrame().getCallTarget(); |
15564
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
45 FrameInstance frameInstance = new FrameInstance() { |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
46 |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
47 public Frame getFrame(FrameAccess access, boolean slowPath) { |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
48 return frame; |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
49 } |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
50 |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
51 public boolean isVirtualFrame() { |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
52 return false; |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
53 } |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
54 |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
55 public Node getCallNode() { |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
56 return DefaultDirectCallNode.this; |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
57 } |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
58 |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
59 public CallTarget getCallTarget() { |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
60 return currentCallTarget; |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
61 } |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
62 }; |
17149
0a35e2789735
Truffle: remove unnecessary DefaultTruffleRuntime fields
Andreas Woess <andreas.woess@jku.at>
parents:
15564
diff
changeset
|
63 defaultTruffleRuntime().pushFrame(frameInstance); |
15564
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
64 try { |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
65 return getCurrentCallTarget().call(arguments); |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
66 } finally { |
17149
0a35e2789735
Truffle: remove unnecessary DefaultTruffleRuntime fields
Andreas Woess <andreas.woess@jku.at>
parents:
15564
diff
changeset
|
67 defaultTruffleRuntime().popFrame(); |
15564
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
68 } |
15064
f675818d9ad0
new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
69 } |
f675818d9ad0
new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
70 |
f675818d9ad0
new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
71 @Override |
15093
5634b199c4da
Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents:
15091
diff
changeset
|
72 public void forceInlining() { |
5634b199c4da
Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents:
15091
diff
changeset
|
73 inliningForced = true; |
15064
f675818d9ad0
new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
74 } |
f675818d9ad0
new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
75 |
f675818d9ad0
new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
76 @Override |
15093
5634b199c4da
Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents:
15091
diff
changeset
|
77 public boolean isInliningForced() { |
5634b199c4da
Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents:
15091
diff
changeset
|
78 return inliningForced; |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
79 } |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
80 |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
81 @Override |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
82 public CallTarget getClonedCallTarget() { |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
83 return null; |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
84 } |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
85 |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
86 @Override |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
87 public boolean cloneCallTarget() { |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
88 return false; |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
89 } |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
90 |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
91 @Override |
18162
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17400
diff
changeset
|
92 public boolean isCallTargetCloningAllowed() { |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
93 return false; |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
94 } |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
95 |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
96 @Override |
14566
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14078
diff
changeset
|
97 public boolean isInlinable() { |
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14078
diff
changeset
|
98 return false; |
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14078
diff
changeset
|
99 } |
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14078
diff
changeset
|
100 |
17149
0a35e2789735
Truffle: remove unnecessary DefaultTruffleRuntime fields
Andreas Woess <andreas.woess@jku.at>
parents:
15564
diff
changeset
|
101 private static DefaultTruffleRuntime defaultTruffleRuntime() { |
0a35e2789735
Truffle: remove unnecessary DefaultTruffleRuntime fields
Andreas Woess <andreas.woess@jku.at>
parents:
15564
diff
changeset
|
102 return (DefaultTruffleRuntime) Truffle.getRuntime(); |
0a35e2789735
Truffle: remove unnecessary DefaultTruffleRuntime fields
Andreas Woess <andreas.woess@jku.at>
parents:
15564
diff
changeset
|
103 } |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
104 } |