Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java @ 21557:31fc2fce38f3
Merge.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 27 May 2015 13:32:18 +0200 |
parents | 1cde96b96673 |
children |
rev | line source |
---|---|
7267
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
11535
8f0fb0ade839
Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11279
diff
changeset
|
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
7267
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
11279
494b818b527c
Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9258
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
494b818b527c
Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9258
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
494b818b527c
Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9258
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
7267
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * accompanied this code). |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 * questions. |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 */ |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 package com.oracle.truffle.api.nodes; |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 |
18485
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
27 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; |
7267
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.truffle.api.*; |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.truffle.api.frame.*; |
18386
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18311
diff
changeset
|
30 import com.oracle.truffle.api.impl.*; |
18485
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
31 import com.oracle.truffle.api.instrument.*; |
16067
915ebb306fcc
Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
15094
diff
changeset
|
32 import com.oracle.truffle.api.source.*; |
7267
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
35 * A root node is a node with a method to execute it given only a frame as a parameter. Therefore, a |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
36 * root node can be used to create a call target using |
13705
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
37 * {@link TruffleRuntime#createCallTarget(RootNode)}. |
7267
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 */ |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 public abstract class RootNode extends Node { |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 |
14566
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14565
diff
changeset
|
41 private RootCallTarget callTarget; |
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:
16067
diff
changeset
|
42 @CompilationFinal private FrameDescriptor frameDescriptor; |
13705
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
43 |
11535
8f0fb0ade839
Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11279
diff
changeset
|
44 protected RootNode() { |
13705
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
45 this(null, null); |
11535
8f0fb0ade839
Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11279
diff
changeset
|
46 } |
8f0fb0ade839
Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11279
diff
changeset
|
47 |
8f0fb0ade839
Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11279
diff
changeset
|
48 protected RootNode(SourceSection sourceSection) { |
13705
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
49 this(sourceSection, null); |
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
50 } |
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
51 |
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
52 protected RootNode(SourceSection sourceSection, FrameDescriptor frameDescriptor) { |
11535
8f0fb0ade839
Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11279
diff
changeset
|
53 super(sourceSection); |
13705
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
54 if (frameDescriptor == null) { |
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
55 this.frameDescriptor = new FrameDescriptor(); |
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
56 } else { |
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
57 this.frameDescriptor = frameDescriptor; |
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
58 } |
11535
8f0fb0ade839
Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11279
diff
changeset
|
59 } |
8f0fb0ade839
Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11279
diff
changeset
|
60 |
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:
16067
diff
changeset
|
61 @Override |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
16067
diff
changeset
|
62 public Node copy() { |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
16067
diff
changeset
|
63 RootNode root = (RootNode) super.copy(); |
18169
be1316e633b5
Truffle: share frame descriptor among cloned call targets
Andreas Woess <andreas.woess@jku.at>
parents:
18162
diff
changeset
|
64 root.frameDescriptor = frameDescriptor; |
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:
16067
diff
changeset
|
65 return root; |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13835
diff
changeset
|
66 } |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13835
diff
changeset
|
67 |
14566
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14565
diff
changeset
|
68 /** |
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:
16067
diff
changeset
|
69 * Returns <code>true</code> if this {@link RootNode} is allowed to be cloned. The runtime |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
16067
diff
changeset
|
70 * system might decide to create deep copies of the {@link RootNode} in order to gather context |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
16067
diff
changeset
|
71 * sensitive profiling feedback. The default implementation returns <code>false</code>. Guest |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
16067
diff
changeset
|
72 * language specific implementations may want to return <code>true</code> here to indicate that |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
16067
diff
changeset
|
73 * gathering call site specific profiling information might make sense for this {@link RootNode} |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
16067
diff
changeset
|
74 * . |
19510
1cde96b96673
Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents:
18845
diff
changeset
|
75 * |
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:
16067
diff
changeset
|
76 * @return <code>true</code> if cloning is allowed else <code>false</code>. |
14566
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14565
diff
changeset
|
77 */ |
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:
16067
diff
changeset
|
78 public boolean isCloningAllowed() { |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13835
diff
changeset
|
79 return false; |
13803
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13705
diff
changeset
|
80 } |
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13705
diff
changeset
|
81 |
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13705
diff
changeset
|
82 /** |
13835
67e4e7f56911
Truffle: add a simple API to report loop counts
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13811
diff
changeset
|
83 * Reports the execution count of a loop that is a child of this node. The optimization |
67e4e7f56911
Truffle: add a simple API to report loop counts
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13811
diff
changeset
|
84 * heuristics can use the loop count to guide compilation and inlining. |
67e4e7f56911
Truffle: add a simple API to report loop counts
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13811
diff
changeset
|
85 */ |
14566
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14565
diff
changeset
|
86 public final void reportLoopCount(int count) { |
14073
c5411233cdf8
Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents:
13983
diff
changeset
|
87 if (getCallTarget() instanceof LoopCountReceiver) { |
c5411233cdf8
Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
Christian Humer <christian.humer@gmail.com>
parents:
13983
diff
changeset
|
88 ((LoopCountReceiver) getCallTarget()).reportLoopCount(count); |
13835
67e4e7f56911
Truffle: add a simple API to report loop counts
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13811
diff
changeset
|
89 } |
67e4e7f56911
Truffle: add a simple API to report loop counts
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13811
diff
changeset
|
90 } |
67e4e7f56911
Truffle: add a simple API to report loop counts
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13811
diff
changeset
|
91 |
67e4e7f56911
Truffle: add a simple API to report loop counts
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13811
diff
changeset
|
92 /** |
7267
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 * Executes this function using the specified frame and returns the result value. |
19510
1cde96b96673
Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents:
18845
diff
changeset
|
94 * |
7267
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 * @param frame the frame of the currently executing guest language method |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 * @return the value of the execution |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 */ |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 public abstract Object execute(VirtualFrame frame); |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
99 |
14566
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14565
diff
changeset
|
100 public final RootCallTarget getCallTarget() { |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
101 return callTarget; |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
102 } |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
103 |
13803
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13705
diff
changeset
|
104 public final FrameDescriptor getFrameDescriptor() { |
13705
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
105 return frameDescriptor; |
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
106 } |
ac5b0f31f7a2
Truffle API-change: FrameDescriptors are now stored in the RootNode in a final field instead of the CallTarget.
Christian Humer <christian.humer@gmail.com>
parents:
11535
diff
changeset
|
107 |
14566
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14565
diff
changeset
|
108 public final void setCallTarget(RootCallTarget callTarget) { |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
109 this.callTarget = callTarget; |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
110 } |
13811
641f22b1c6b8
Truffle: further fixes to the new CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13804
diff
changeset
|
111 |
18311
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
112 /** |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
113 * Returns the {@link ExecutionContext} associated with this <code>RootNode</code>. This allows |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
114 * the correct <code>ExecutionContext</code> to be determined for a <code>RootNode</code> (and |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
115 * so also for a {@link RootCallTarget} and a {@link FrameInstance} obtained from the call |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
116 * stack) without prior knowledge of the language it has come from. |
19510
1cde96b96673
Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents:
18845
diff
changeset
|
117 * |
18311
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
118 * Used for instance to determine the language of a <code>RootNode<code>: |
19510
1cde96b96673
Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents:
18845
diff
changeset
|
119 * |
18311
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
120 * <pre> |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
121 * <code> |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
122 * rootNode.getExecutionContext().getLanguageShortName(); |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
123 * </code> </pre> |
19510
1cde96b96673
Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents:
18845
diff
changeset
|
124 * |
18311
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
125 * Returns <code>null</code> by default. |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
126 */ |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
127 public ExecutionContext getExecutionContext() { |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
128 return null; |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
129 } |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18169
diff
changeset
|
130 |
18386
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18311
diff
changeset
|
131 /** |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18311
diff
changeset
|
132 * Get compiler options specific to this <code>RootNode</code>. |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18311
diff
changeset
|
133 */ |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18311
diff
changeset
|
134 public CompilerOptions getCompilerOptions() { |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18311
diff
changeset
|
135 final ExecutionContext context = getExecutionContext(); |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18311
diff
changeset
|
136 |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18311
diff
changeset
|
137 if (context == null) { |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18311
diff
changeset
|
138 return DefaultCompilerOptions.INSTANCE; |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18311
diff
changeset
|
139 } else { |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18311
diff
changeset
|
140 return context.getCompilerOptions(); |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18311
diff
changeset
|
141 } |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18311
diff
changeset
|
142 } |
656331a61829
Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents:
18311
diff
changeset
|
143 |
18485
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
144 /** |
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
145 * Apply all registered instances of {@link ASTProber} to the AST, if any, held by this root |
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
146 * node. This can only be done once the AST is complete, notably once all parent pointers are |
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
147 * correctly assigned. But it also must be done before any AST cloning or execution. |
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
148 * <p> |
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
149 * If this is not done, then the AST will not be subject to debugging or any other |
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
150 * instrumentation-supported tooling. |
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
151 * <p> |
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
152 * Implementations should ensure that instrumentation is never applied more than once to an AST, |
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
153 * as this is not guaranteed to be error-free. |
19510
1cde96b96673
Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents:
18845
diff
changeset
|
154 * |
18485
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
155 * @see Probe#registerASTProber(com.oracle.truffle.api.instrument.ASTProber) |
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
156 */ |
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
157 public void applyInstrumentation() { |
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
158 } |
7267
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 } |