annotate truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java @ 22135:e70b20f4bb00

Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Mon, 07 Sep 2015 17:07:20 +0200
parents 78c3d3d8d86e
children d5f809827bf1 3aad794eec0e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 */
22066
78c3d3d8d86e Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
39 @SuppressWarnings("rawtypes")
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
40 public abstract class RootNode extends Node {
22003
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
41 final Class<? extends TruffleLanguage> language;
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
42 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
43 @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
44
22003
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
45 /**
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
46 * @deprecated each RootNode should be associated with a {@link TruffleLanguage} use constructor
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
47 * that allows you to specify it. This method will be removed on Aug 15, 2015.
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
48 */
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
49 @Deprecated
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
50 protected RootNode() {
22003
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
51 this(null, null, null, false);
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
52 }
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
53
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
54 /**
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
55 * @deprecated each RootNode should be associated with a {@link TruffleLanguage} use constructor
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
56 * that allows you to specify it. This method will be removed on Aug 15, 2015.
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
57 */
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
58 @Deprecated
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
59 protected RootNode(SourceSection sourceSection) {
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
60 this(null, sourceSection, null, false);
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
61 }
8f0fb0ade839 Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 11279
diff changeset
62
22003
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
63 /**
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
64 * @deprecated each RootNode should be associated with a {@link TruffleLanguage} use constructor
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
65 * that allows you to specify it. This method will be removed on Aug 15, 2015.
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
66 */
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
67 @Deprecated
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
68 protected RootNode(SourceSection sourceSection, FrameDescriptor frameDescriptor) {
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
69 this(null, sourceSection, frameDescriptor, false);
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
70 }
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
71
22003
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
72 /**
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
73 * Creates new root node. Each {@link RootNode} is associated with a particular language - if
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
74 * the root node represents a method it is assumed the method is written in such language.
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
75 *
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
76 * @param language the language of the node, <b>cannot be</b> <code>null</code>
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
77 * @param sourceSection a part of source associated with this node, can be <code>null</code>
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
78 * @param frameDescriptor descriptor of slots, can be <code>null</code>
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
79 */
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
80 protected RootNode(Class<? extends TruffleLanguage> language, SourceSection sourceSection, FrameDescriptor frameDescriptor) {
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
81 this(language, sourceSection, frameDescriptor, true);
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
82 }
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
83
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
84 private RootNode(Class<? extends TruffleLanguage> language, SourceSection sourceSection, FrameDescriptor frameDescriptor, boolean checkLanguage) {
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
85 super(sourceSection);
22003
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
86 if (checkLanguage) {
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
87 if (!TruffleLanguage.class.isAssignableFrom(language)) {
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
88 throw new IllegalStateException();
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
89 }
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
90 }
5bc7f7b867ab Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
91 this.language = language;
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
92 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
93 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
94 } 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
95 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
96 }
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
97 }
8f0fb0ade839 Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 11279
diff changeset
98
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
99 @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
100 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
101 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
102 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
103 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
104 }
f46cab39a9a2 Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13835
diff changeset
105
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
106 /**
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
107 * 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
108 * 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
109 * 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
110 * 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
111 * 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
112 * .
19507
1cde96b96673 Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents: 18845
diff changeset
113 *
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
114 * @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
115 */
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
116 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
117 return false;
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13705
diff changeset
118 }
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13705
diff changeset
119
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13705
diff changeset
120 /**
13835
67e4e7f56911 Truffle: add a simple API to report loop counts
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13811
diff changeset
121 * 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
122 * 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
123 */
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
124 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
125 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
126 ((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
127 }
67e4e7f56911 Truffle: add a simple API to report loop counts
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13811
diff changeset
128 }
67e4e7f56911 Truffle: add a simple API to report loop counts
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13811
diff changeset
129
67e4e7f56911 Truffle: add a simple API to report loop counts
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13811
diff changeset
130 /**
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
131 * Executes this function using the specified frame and returns the result value.
19507
1cde96b96673 Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents: 18845
diff changeset
132 *
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
133 * @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
134 * @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
135 */
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
136 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
137
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
138 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
139 return callTarget;
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
140 }
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
141
13803
e076c87ab175 Truffle: refactored inlining interfaces to a more compact CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13705
diff changeset
142 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
143 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
144 }
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
145
14566
6681b9eb3f4c Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents: 14565
diff changeset
146 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
147 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
148 }
13811
641f22b1c6b8 Truffle: further fixes to the new CallNode.
Christian Humer <christian.humer@gmail.com>
parents: 13804
diff changeset
149
18311
3343ed66de79 Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents: 18169
diff changeset
150 /**
3343ed66de79 Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents: 18169
diff changeset
151 * 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
152 * 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
153 * 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
154 * stack) without prior knowledge of the language it has come from.
19507
1cde96b96673 Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents: 18845
diff changeset
155 *
18311
3343ed66de79 Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents: 18169
diff changeset
156 * Used for instance to determine the language of a <code>RootNode<code>:
22135
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
157 *
18311
3343ed66de79 Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents: 18169
diff changeset
158 * <pre>
3343ed66de79 Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents: 18169
diff changeset
159 * <code>
3343ed66de79 Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents: 18169
diff changeset
160 * rootNode.getExecutionContext().getLanguageShortName();
3343ed66de79 Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents: 18169
diff changeset
161 * </code> </pre>
19507
1cde96b96673 Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents: 18845
diff changeset
162 *
18311
3343ed66de79 Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents: 18169
diff changeset
163 * Returns <code>null</code> by default.
3343ed66de79 Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents: 18169
diff changeset
164 */
3343ed66de79 Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents: 18169
diff changeset
165 public ExecutionContext getExecutionContext() {
3343ed66de79 Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents: 18169
diff changeset
166 return null;
3343ed66de79 Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents: 18169
diff changeset
167 }
3343ed66de79 Truffle: RootNode#getExecutionContext.
Chris Seaton <chris.seaton@oracle.com>
parents: 18169
diff changeset
168
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
169 /**
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
170 * 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
171 */
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
172 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
173 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
174
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
175 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
176 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
177 } 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
178 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
179 }
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
180 }
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
181
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
182 /**
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
183 * 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
184 * 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
185 * 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
186 * <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
187 * 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
188 * 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
189 * <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
190 * 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
191 * as this is not guaranteed to be error-free.
19507
1cde96b96673 Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents: 18845
diff changeset
192 *
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
193 * @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
194 */
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
195 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
196 }
22135
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
197
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
198 /**
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
199 * Helper method to create a root node that always returns the same value. Certain operations
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
200 * (expecially {@link com.oracle.api.truffle.api.interop inter-operability} API) require return
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
201 * of stable {@link RootNode root nodes}. To simplify creation of such nodes, here is a factory
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
202 * method that can create {@link RootNode} that returns always the same value.
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
203 *
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
204 * @param constant the constant to return
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
205 * @return root node returning the constant
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
206 */
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
207 public static RootNode createConstantNode(Object constant) {
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
208 return new Constant(constant);
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
209 }
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
210
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
211 private static final class Constant extends RootNode {
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
212
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
213 private final Object value;
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
214
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
215 public Constant(Object value) {
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
216 super(TruffleLanguage.class, null, null);
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
217 this.value = value;
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
218 }
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
219
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
220 @Override
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
221 public Object execute(VirtualFrame vf) {
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
222 return value;
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
223 }
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
224 }
e70b20f4bb00 Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
225
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
226 }