Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java @ 21615:838f005f9aec
handle service filtering that returns an empty result
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sun, 31 May 2015 14:30:13 +0200 |
parents | e3c95cbbb50c |
children |
rev | line source |
---|---|
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
1 /* |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13807
diff
changeset
|
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
4 * |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
8 * |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
14 * |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
18 * |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
21 * questions. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
22 */ |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.sl.nodes; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
24 |
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:
18311
diff
changeset
|
25 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; |
18311
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18163
diff
changeset
|
26 import com.oracle.truffle.api.*; |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
27 import com.oracle.truffle.api.frame.*; |
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:
18311
diff
changeset
|
28 import com.oracle.truffle.api.instrument.*; |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.truffle.api.nodes.*; |
12752
71991b7a0f14
SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
11906
diff
changeset
|
30 import com.oracle.truffle.sl.builtins.*; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13707
diff
changeset
|
31 import com.oracle.truffle.sl.nodes.controlflow.*; |
16958
997899955e72
Instrumentation: removed ExecutionContext parameter from probe method in Instrumentable
David Piorkowski <david.piorkowski@oracle.com>
parents:
15776
diff
changeset
|
32 import com.oracle.truffle.sl.runtime.*; |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
33 |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13807
diff
changeset
|
34 /** |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13807
diff
changeset
|
35 * The root of all SL execution trees. It is a Truffle requirement that the tree root extends the |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13807
diff
changeset
|
36 * class {@link RootNode}. This class is used for both builtin and user-defined functions. For |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13807
diff
changeset
|
37 * builtin functions, the {@link #bodyNode} is a subclass of {@link SLBuiltinNode}. For user-defined |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13807
diff
changeset
|
38 * functions, the {@link #bodyNode} is a {@link SLFunctionBodyNode}. |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13807
diff
changeset
|
39 */ |
15776
111bf82514ca
SL: adding NodeInfo.descriptions to SL statements
Christian Wirth <christian.wirth@oracle.com>
parents:
14628
diff
changeset
|
40 @NodeInfo(language = "Simple Language", description = "The root of all Simple Language execution trees") |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13707
diff
changeset
|
41 public final class SLRootNode extends RootNode { |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
42 |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13807
diff
changeset
|
43 /** The function body that is executed, and specialized during execution. */ |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13807
diff
changeset
|
44 @Child private SLExpressionNode bodyNode; |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
7292
diff
changeset
|
45 |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13807
diff
changeset
|
46 /** The name of the function, for printing purposes only. */ |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13807
diff
changeset
|
47 private final String name; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13707
diff
changeset
|
48 |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
18162
diff
changeset
|
49 /** The Simple execution context for this tree. **/ |
16958
997899955e72
Instrumentation: removed ExecutionContext parameter from probe method in Instrumentable
David Piorkowski <david.piorkowski@oracle.com>
parents:
15776
diff
changeset
|
50 private final SLContext context; |
997899955e72
Instrumentation: removed ExecutionContext parameter from probe method in Instrumentable
David Piorkowski <david.piorkowski@oracle.com>
parents:
15776
diff
changeset
|
51 |
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:
17006
diff
changeset
|
52 @CompilationFinal private boolean isCloningAllowed; |
17006
e9c119927199
SL: added internal APIs to SL for the Graal runtime tests.
Christian Humer <christian.humer@gmail.com>
parents:
17004
diff
changeset
|
53 |
16958
997899955e72
Instrumentation: removed ExecutionContext parameter from probe method in Instrumentable
David Piorkowski <david.piorkowski@oracle.com>
parents:
15776
diff
changeset
|
54 public SLRootNode(SLContext context, FrameDescriptor frameDescriptor, SLExpressionNode bodyNode, String name) { |
13707
40fd9958cdf5
SL: required fixes for moving FrameDescriptor to the RootNode.
Christian Humer <christian.humer@gmail.com>
parents:
13338
diff
changeset
|
55 super(null, frameDescriptor); |
14628
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
13985
diff
changeset
|
56 this.bodyNode = bodyNode; |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
57 this.name = name; |
16958
997899955e72
Instrumentation: removed ExecutionContext parameter from probe method in Instrumentable
David Piorkowski <david.piorkowski@oracle.com>
parents:
15776
diff
changeset
|
58 this.context = context; |
12752
71991b7a0f14
SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
11906
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:
11906
diff
changeset
|
60 |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
61 @Override |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
62 public Object execute(VirtualFrame frame) { |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13807
diff
changeset
|
63 return bodyNode.executeGeneric(frame); |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
64 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
65 |
17004
158c9ba66e45
SL: added support for guest language stack traces to SLException; added SLAssertionError.
Christian Humer <christian.humer@gmail.com>
parents:
16958
diff
changeset
|
66 public String getName() { |
158c9ba66e45
SL: added support for guest language stack traces to SLException; added SLAssertionError.
Christian Humer <christian.humer@gmail.com>
parents:
16958
diff
changeset
|
67 return name; |
158c9ba66e45
SL: added support for guest language stack traces to SLException; added SLAssertionError.
Christian Humer <christian.humer@gmail.com>
parents:
16958
diff
changeset
|
68 } |
158c9ba66e45
SL: added support for guest language stack traces to SLException; added SLAssertionError.
Christian Humer <christian.humer@gmail.com>
parents:
16958
diff
changeset
|
69 |
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:
17006
diff
changeset
|
70 public void setCloningAllowed(boolean isCloningAllowed) { |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17006
diff
changeset
|
71 this.isCloningAllowed = isCloningAllowed; |
17006
e9c119927199
SL: added internal APIs to SL for the Graal runtime tests.
Christian Humer <christian.humer@gmail.com>
parents:
17004
diff
changeset
|
72 } |
e9c119927199
SL: added internal APIs to SL for the Graal runtime tests.
Christian Humer <christian.humer@gmail.com>
parents:
17004
diff
changeset
|
73 |
e9c119927199
SL: added internal APIs to SL for the Graal runtime tests.
Christian Humer <christian.humer@gmail.com>
parents:
17004
diff
changeset
|
74 public SLExpressionNode getBodyNode() { |
e9c119927199
SL: added internal APIs to SL for the Graal runtime tests.
Christian Humer <christian.humer@gmail.com>
parents:
17004
diff
changeset
|
75 return bodyNode; |
e9c119927199
SL: added internal APIs to SL for the Graal runtime tests.
Christian Humer <christian.humer@gmail.com>
parents:
17004
diff
changeset
|
76 } |
e9c119927199
SL: added internal APIs to SL for the Graal runtime tests.
Christian Humer <christian.humer@gmail.com>
parents:
17004
diff
changeset
|
77 |
13803
e076c87ab175
Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents:
13707
diff
changeset
|
78 @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:
17006
diff
changeset
|
79 public boolean isCloningAllowed() { |
ab62800259ff
Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
17006
diff
changeset
|
80 return isCloningAllowed; |
12752
71991b7a0f14
SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
11906
diff
changeset
|
81 } |
71991b7a0f14
SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
11906
diff
changeset
|
82 |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
83 @Override |
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:
18311
diff
changeset
|
84 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:
18311
diff
changeset
|
85 Probe.applyASTProbers(bodyNode); |
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:
18311
diff
changeset
|
86 } |
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:
18311
diff
changeset
|
87 |
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:
18311
diff
changeset
|
88 @Override |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
89 public String toString() { |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13807
diff
changeset
|
90 return "root " + name; |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
91 } |
16958
997899955e72
Instrumentation: removed ExecutionContext parameter from probe method in Instrumentable
David Piorkowski <david.piorkowski@oracle.com>
parents:
15776
diff
changeset
|
92 |
997899955e72
Instrumentation: removed ExecutionContext parameter from probe method in Instrumentable
David Piorkowski <david.piorkowski@oracle.com>
parents:
15776
diff
changeset
|
93 public SLContext getSLContext() { |
997899955e72
Instrumentation: removed ExecutionContext parameter from probe method in Instrumentable
David Piorkowski <david.piorkowski@oracle.com>
parents:
15776
diff
changeset
|
94 return this.context; |
997899955e72
Instrumentation: removed ExecutionContext parameter from probe method in Instrumentable
David Piorkowski <david.piorkowski@oracle.com>
parents:
15776
diff
changeset
|
95 } |
18311
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18163
diff
changeset
|
96 |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18163
diff
changeset
|
97 @Override |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18163
diff
changeset
|
98 public ExecutionContext getExecutionContext() { |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18163
diff
changeset
|
99 return this.context; |
3343ed66de79
Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents:
18163
diff
changeset
|
100 } |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
101 } |