Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java @ 14566:6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 17 Mar 2014 14:29:45 +0100 |
parents | 5d1308c78ddc |
children | 6189c1983cd3 |
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:
10862
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:
10862
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:
10862
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 |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
27 import java.io.*; |
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 java.lang.annotation.*; |
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 java.util.*; |
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
|
30 |
9254
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
31 import com.oracle.truffle.api.*; |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
32 |
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 * Abstract base class for all Truffle 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
|
35 */ |
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
|
36 public abstract class Node implements Cloneable { |
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
|
37 |
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 private Node parent; |
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 |
9254
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
40 private SourceSection sourceSection; |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
41 |
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
|
42 /** |
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
|
43 * Marks array fields that are children of this 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
|
44 */ |
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
|
45 @Retention(RetentionPolicy.RUNTIME) |
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
|
46 @Target({ElementType.FIELD}) |
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
|
47 public @interface Children { |
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
|
48 } |
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
|
49 |
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
|
50 /** |
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
|
51 * Marks fields that represent child nodes of this 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
|
52 */ |
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
|
53 @Retention(RetentionPolicy.RUNTIME) |
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
|
54 @Target({ElementType.FIELD}) |
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
|
55 public @interface Child { |
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
|
56 } |
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
|
57 |
10481
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
58 protected Node() { |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
59 CompilerAsserts.neverPartOfCompilation(); |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
60 } |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
61 |
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
|
62 protected Node(SourceSection sourceSection) { |
8f0fb0ade839
Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11279
diff
changeset
|
63 CompilerAsserts.neverPartOfCompilation(); |
8f0fb0ade839
Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11279
diff
changeset
|
64 this.sourceSection = sourceSection; |
8f0fb0ade839
Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11279
diff
changeset
|
65 } |
8f0fb0ade839
Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11279
diff
changeset
|
66 |
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
|
67 /** |
9254
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
68 * Assigns a link to a guest language source section to this node. |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
69 * |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
70 * @param section the object representing a section in guest language source code |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
71 */ |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
72 public final void assignSourceSection(SourceSection section) { |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
73 if (sourceSection != null) { |
11610
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
11535
diff
changeset
|
74 // Patch this test during the transition to constructor-based |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
11535
diff
changeset
|
75 // source attribution, which would otherwise trigger this |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
11535
diff
changeset
|
76 // exception. This method will eventually be deprecated. |
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
11535
diff
changeset
|
77 if (getSourceSection() != section) { |
11648
4ab1f371adc8
Do not assign new source section if replacing node already has source section assigned.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11610
diff
changeset
|
78 throw new IllegalStateException("Source section is already assigned. Old: " + getSourceSection() + ", new: " + section); |
11610
5f532ea846fb
applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents:
11535
diff
changeset
|
79 } |
9254
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
80 } |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
81 this.sourceSection = section; |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
82 } |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
83 |
14566
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14564
diff
changeset
|
84 /** |
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14564
diff
changeset
|
85 * Returns a rough estimate for the cost of this {@link Node}. This estimate can be used by |
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14564
diff
changeset
|
86 * runtime systems or guest languages to implement heuristics based on Truffle ASTs. This method |
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14564
diff
changeset
|
87 * is intended to be overridden by subclasses. The default implementation returns the value of |
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14564
diff
changeset
|
88 * {@link NodeInfo#cost()} of the {@link NodeInfo} annotation declared at the subclass. If no |
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14564
diff
changeset
|
89 * {@link NodeInfo} annotation is declared the method returns {@link NodeCost#MONOMORPHIC} as a |
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14564
diff
changeset
|
90 * default value. |
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14564
diff
changeset
|
91 */ |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
92 public NodeCost getCost() { |
13994
989f58d6a0ca
Truffle: Added API for Node.getKind().
Christian Humer <christian.humer@gmail.com>
parents:
13983
diff
changeset
|
93 NodeInfo info = getClass().getAnnotation(NodeInfo.class); |
989f58d6a0ca
Truffle: Added API for Node.getKind().
Christian Humer <christian.humer@gmail.com>
parents:
13983
diff
changeset
|
94 if (info != null) { |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
95 return info.cost(); |
13994
989f58d6a0ca
Truffle: Added API for Node.getKind().
Christian Humer <christian.humer@gmail.com>
parents:
13983
diff
changeset
|
96 } |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
97 return NodeCost.MONOMORPHIC; |
13994
989f58d6a0ca
Truffle: Added API for Node.getKind().
Christian Humer <christian.humer@gmail.com>
parents:
13983
diff
changeset
|
98 } |
989f58d6a0ca
Truffle: Added API for Node.getKind().
Christian Humer <christian.humer@gmail.com>
parents:
13983
diff
changeset
|
99 |
9254
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
100 /** |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
101 * Clears any previously assigned guest language source code from this node. |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
102 */ |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
103 public final void clearSourceSection() { |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
104 this.sourceSection = null; |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
105 } |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
106 |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
107 /** |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
108 * Retrieves the guest language source code section that is currently assigned to this node. |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
109 * |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
110 * @return the assigned source code section |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
111 */ |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
112 public final SourceSection getSourceSection() { |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
113 return sourceSection; |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
114 } |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
115 |
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
116 /** |
10481
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
117 * Retrieves the guest language source code section that is currently assigned to this node. |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
118 * |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
119 * @return the assigned source code section |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
120 */ |
11818
793743715dc1
put Node.getEncapsulatedSourceSection() on slow path
Michael Haupt <michael.haupt@oracle.com>
parents:
11648
diff
changeset
|
121 @CompilerDirectives.SlowPath |
10481
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
122 public final SourceSection getEncapsulatingSourceSection() { |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
123 if (sourceSection == null && getParent() != null) { |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
124 return getParent().getEncapsulatingSourceSection(); |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
125 } |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
126 return sourceSection; |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
127 } |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
128 |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
129 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
130 * Method that updates the link to the parent in the array of specified new child nodes to this |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
131 * node. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
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 newChildren the array of new children whose parent should be updated |
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 array of new children |
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 protected final <T extends Node> T[] adoptChildren(T[] newChildren) { |
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
|
137 if (newChildren != null) { |
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
|
138 for (T n : newChildren) { |
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
|
139 adoptChild(n); |
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
|
140 } |
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
|
141 } |
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
|
142 return newChildren; |
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
|
143 } |
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
|
144 |
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
|
145 /** |
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
|
146 * Method that updates the link to the parent in the specified new child node to this node. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
147 * |
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
|
148 * @param newChild the new child whose parent should be updated |
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
|
149 * @return the new child |
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
|
150 */ |
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
|
151 protected final <T extends Node> T adoptChild(T newChild) { |
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
|
152 if (newChild != null) { |
10481
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
153 if (newChild == this) { |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
154 throw new IllegalStateException("The parent of a node can never be the node itself."); |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
155 } |
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
|
156 ((Node) newChild).parent = this; |
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
|
157 } |
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
|
158 return newChild; |
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 } |
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
|
160 |
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
|
161 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
162 * Returns properties of this node interesting for debugging and can be overwritten by |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
163 * subclasses to add their own custom properties. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
164 * |
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
|
165 * @return the properties as a key/value hash map |
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
|
166 */ |
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
|
167 public Map<String, Object> getDebugProperties() { |
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
|
168 Map<String, Object> properties = new HashMap<>(); |
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
|
169 return properties; |
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
|
170 } |
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
|
171 |
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
|
172 /** |
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
|
173 * The current parent node of this node. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
174 * |
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
|
175 * @return the parent 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
|
176 */ |
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
|
177 public final Node getParent() { |
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
|
178 return parent; |
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
|
179 } |
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
|
180 |
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
|
181 /** |
9256
9640bb930327
Preserve the source section during node rewrites.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9255
diff
changeset
|
182 * Replaces this node with another node. If there is a source section (see |
9640bb930327
Preserve the source section during node rewrites.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9255
diff
changeset
|
183 * {@link #getSourceSection()}) associated with this node, it is transferred to the new node. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
184 * |
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
|
185 * @param newNode the new node that is the replacement |
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
|
186 * @param reason a description of the reason for the replacement |
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
|
187 * @return the new 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
|
188 */ |
9254
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
189 public final <T extends Node> T replace(T newNode, String reason) { |
13915
d6b340b757a2
Truffle: refactorings
Andreas Woess <andreas.woess@jku.at>
parents:
13811
diff
changeset
|
190 CompilerDirectives.transferToInterpreterAndInvalidate(); |
10481
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
191 if (this.getParent() == null) { |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
192 throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent."); |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
193 } |
11648
4ab1f371adc8
Do not assign new source section if replacing node already has source section assigned.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11610
diff
changeset
|
194 if (sourceSection != null && newNode.getSourceSection() == null) { |
9256
9640bb930327
Preserve the source section during node rewrites.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9255
diff
changeset
|
195 // Pass on the source section to the new node. |
9640bb930327
Preserve the source section during node rewrites.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9255
diff
changeset
|
196 newNode.assignSourceSection(sourceSection); |
9640bb930327
Preserve the source section during node rewrites.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9255
diff
changeset
|
197 } |
9782
ba02d19dd3cc
Added an onReplace method to Node to provide a way for a guest language implementation to use replace tracing.
Christian Humer <christian.humer@gmail.com>
parents:
9256
diff
changeset
|
198 onReplace(newNode, reason); |
12494
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
199 ((Node) newNode).parent = this.parent; |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
200 if (!NodeUtil.replaceChild(this.parent, this, newNode)) { |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
201 fixupTree(); |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
202 } |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
203 reportReplace(this, newNode, reason); |
12494
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
204 return newNode; |
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
|
205 } |
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
|
206 |
12494
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
207 /** |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
208 * Rewrite has failed; the tree is likely inconsistent, so fix any stale parent references. |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
209 * |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
210 * This is a rather expensive operation but rare to occur. |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
211 */ |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
212 private void fixupTree() { |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
213 Node rootNode = getRootNode(); |
12494
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
214 if (rootNode == null) { |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
215 throw new UnsupportedOperationException("Tree does not have a root node."); |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
216 } |
12495
b7c8b843dc7b
Truffle: add sanity check.
Andreas Woess <andreas.woess@jku.at>
parents:
12494
diff
changeset
|
217 int fixCount = rootNode.fixupChildren(); |
b7c8b843dc7b
Truffle: add sanity check.
Andreas Woess <andreas.woess@jku.at>
parents:
12494
diff
changeset
|
218 assert fixCount != 0 : "sanity check failed: missing @Child[ren] or adoptChild?"; |
b7c8b843dc7b
Truffle: add sanity check.
Andreas Woess <andreas.woess@jku.at>
parents:
12494
diff
changeset
|
219 // if nothing had to be fixed, rewrite failed due to node not being a proper child. |
12494
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
220 } |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
221 |
12495
b7c8b843dc7b
Truffle: add sanity check.
Andreas Woess <andreas.woess@jku.at>
parents:
12494
diff
changeset
|
222 private int fixupChildren() { |
b7c8b843dc7b
Truffle: add sanity check.
Andreas Woess <andreas.woess@jku.at>
parents:
12494
diff
changeset
|
223 int fixCount = 0; |
12494
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
224 for (Node child : getChildren()) { |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
225 if (child != null) { |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
226 if (child.parent != this) { |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
227 child.parent = this; |
12495
b7c8b843dc7b
Truffle: add sanity check.
Andreas Woess <andreas.woess@jku.at>
parents:
12494
diff
changeset
|
228 fixCount++; |
12494
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
229 } |
12495
b7c8b843dc7b
Truffle: add sanity check.
Andreas Woess <andreas.woess@jku.at>
parents:
12494
diff
changeset
|
230 fixCount += child.fixupChildren(); |
12494
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
231 } |
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
232 } |
12495
b7c8b843dc7b
Truffle: add sanity check.
Andreas Woess <andreas.woess@jku.at>
parents:
12494
diff
changeset
|
233 return fixCount; |
9255
cdf10fb20022
Remove Node.replaceChild method from the public API. Node.replace remains as the only method in the API to modify the AST.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9254
diff
changeset
|
234 } |
cdf10fb20022
Remove Node.replaceChild method from the public API. Node.replace remains as the only method in the API to modify the AST.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9254
diff
changeset
|
235 |
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
|
236 /** |
9256
9640bb930327
Preserve the source section during node rewrites.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9255
diff
changeset
|
237 * Replaces this node with another node. If there is a source section (see |
9640bb930327
Preserve the source section during node rewrites.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9255
diff
changeset
|
238 * {@link #getSourceSection()}) associated with this node, it is transferred to the new node. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
239 * |
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
|
240 * @param newNode the new node that is the replacement |
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
|
241 * @return the new 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
|
242 */ |
9254
4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
243 public final <T extends Node> T replace(T newNode) { |
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
|
244 return replace(newNode, ""); |
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
|
245 } |
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
|
246 |
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
|
247 /** |
10846
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
248 * Checks if this node is properly adopted by a parent and can be replaced. |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
249 * |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
250 * @return {@code true} if it is safe to replace this node. |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
251 */ |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
252 public final boolean isReplaceable() { |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
253 if (getParent() != null) { |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
254 for (Node sibling : getParent().getChildren()) { |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
255 if (sibling == this) { |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
256 return true; |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
257 } |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
258 } |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
259 } |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
260 return false; |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
261 } |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
262 |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
263 private void reportReplace(Node oldNode, Node newNode, String reason) { |
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:
13994
diff
changeset
|
264 RootNode rootNode = getRootNode(); |
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:
13994
diff
changeset
|
265 if (rootNode != null) { |
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:
13994
diff
changeset
|
266 CallTarget target = rootNode.getCallTarget(); |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
267 if (target instanceof ReplaceObserver) { |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
268 ((ReplaceObserver) target).nodeReplaced(oldNode, newNode, reason); |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
269 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
270 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
271 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
272 |
10846
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
273 /** |
9782
ba02d19dd3cc
Added an onReplace method to Node to provide a way for a guest language implementation to use replace tracing.
Christian Humer <christian.humer@gmail.com>
parents:
9256
diff
changeset
|
274 * Intended to be implemented by subclasses of {@link Node} to receive a notification when the |
ba02d19dd3cc
Added an onReplace method to Node to provide a way for a guest language implementation to use replace tracing.
Christian Humer <christian.humer@gmail.com>
parents:
9256
diff
changeset
|
275 * node is rewritten. This method is invoked before the actual replace has happened. |
ba02d19dd3cc
Added an onReplace method to Node to provide a way for a guest language implementation to use replace tracing.
Christian Humer <christian.humer@gmail.com>
parents:
9256
diff
changeset
|
276 * |
ba02d19dd3cc
Added an onReplace method to Node to provide a way for a guest language implementation to use replace tracing.
Christian Humer <christian.humer@gmail.com>
parents:
9256
diff
changeset
|
277 * @param newNode the replacement node |
ba02d19dd3cc
Added an onReplace method to Node to provide a way for a guest language implementation to use replace tracing.
Christian Humer <christian.humer@gmail.com>
parents:
9256
diff
changeset
|
278 * @param reason the reason the replace supplied |
ba02d19dd3cc
Added an onReplace method to Node to provide a way for a guest language implementation to use replace tracing.
Christian Humer <christian.humer@gmail.com>
parents:
9256
diff
changeset
|
279 */ |
ba02d19dd3cc
Added an onReplace method to Node to provide a way for a guest language implementation to use replace tracing.
Christian Humer <christian.humer@gmail.com>
parents:
9256
diff
changeset
|
280 protected void onReplace(Node newNode, String reason) { |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
281 if (TruffleOptions.TraceRewrites) { |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
282 traceRewrite(newNode, reason); |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
283 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
284 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
285 |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
286 private void traceRewrite(Node newNode, String reason) { |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
287 |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
288 if (TruffleOptions.TraceRewritesFilterFromCost != null) { |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
289 if (filterByKind(this, TruffleOptions.TraceRewritesFilterFromCost)) { |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
290 return; |
10862
8c570011b86f
Truffle: when a node is replaced, notify optimized call target and delay compilation.
Andreas Woess <andreas.woess@jku.at>
parents:
10846
diff
changeset
|
291 } |
8c570011b86f
Truffle: when a node is replaced, notify optimized call target and delay compilation.
Andreas Woess <andreas.woess@jku.at>
parents:
10846
diff
changeset
|
292 } |
10590
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
293 |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
294 if (TruffleOptions.TraceRewritesFilterToCost != null) { |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
295 if (filterByKind(newNode, TruffleOptions.TraceRewritesFilterToCost)) { |
10590
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
296 return; |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
297 } |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
298 } |
10590
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
299 |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
300 String filter = TruffleOptions.TraceRewritesFilterClass; |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
301 Class<? extends Node> from = getClass(); |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
302 Class<? extends Node> to = newNode.getClass(); |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
303 if (filter != null && (filterByContainsClassName(from, filter) || filterByContainsClassName(to, filter))) { |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
304 return; |
10590
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
305 } |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
306 |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
307 PrintStream out = System.out; |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
308 out.printf("[truffle] rewrite %-50s |From %-40s |To %-40s |Reason %s.%n", this.toString(), formatNodeInfo(this), formatNodeInfo(newNode), reason); |
10590
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
309 } |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
310 |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
311 private static String formatNodeInfo(Node node) { |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
312 String cost = "?"; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
313 switch (node.getCost()) { |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
314 case NONE: |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
315 cost = "G"; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
316 break; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
317 case MONOMORPHIC: |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
318 cost = "M"; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
319 break; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
320 case POLYMORPHIC: |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
321 cost = "P"; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
322 break; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
323 case MEGAMORPHIC: |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
324 cost = "G"; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
325 break; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
326 default: |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
327 cost = "?"; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
328 break; |
10590
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
329 } |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
330 return cost + " " + node.getClass().getSimpleName(); |
10590
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
331 } |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
332 |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
333 private static boolean filterByKind(Node node, NodeCost cost) { |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
334 return node.getCost() == cost; |
10590
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
335 } |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
336 |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
337 private static boolean filterByContainsClassName(Class<? extends Node> from, String filter) { |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
338 Class<?> currentFrom = from; |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
339 while (currentFrom != null) { |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
340 if (currentFrom.getName().contains(filter)) { |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
341 return false; |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
342 } |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
343 currentFrom = currentFrom.getSuperclass(); |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
344 } |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
345 return true; |
9782
ba02d19dd3cc
Added an onReplace method to Node to provide a way for a guest language implementation to use replace tracing.
Christian Humer <christian.humer@gmail.com>
parents:
9256
diff
changeset
|
346 } |
ba02d19dd3cc
Added an onReplace method to Node to provide a way for a guest language implementation to use replace tracing.
Christian Humer <christian.humer@gmail.com>
parents:
9256
diff
changeset
|
347 |
ba02d19dd3cc
Added an onReplace method to Node to provide a way for a guest language implementation to use replace tracing.
Christian Humer <christian.humer@gmail.com>
parents:
9256
diff
changeset
|
348 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
349 * Invokes the {@link NodeVisitor#visit(Node)} method for this node and recursively also for all |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
350 * child nodes. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
351 * |
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
|
352 * @param nodeVisitor the visitor |
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
|
353 */ |
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
|
354 public final void accept(NodeVisitor nodeVisitor) { |
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
|
355 if (nodeVisitor.visit(this)) { |
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
|
356 for (Node child : this.getChildren()) { |
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
|
357 if (child != null) { |
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
|
358 child.accept(nodeVisitor); |
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
|
359 } |
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
|
360 } |
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
|
361 } |
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
|
362 } |
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
|
363 |
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
|
364 /** |
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
|
365 * Iterator over the children of this node. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
366 * |
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
|
367 * @return the iterator |
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
|
368 */ |
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
|
369 public final Iterable<Node> getChildren() { |
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
|
370 final Node node = this; |
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
|
371 return new Iterable<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
|
372 |
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
|
373 public Iterator<Node> iterator() { |
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
|
374 return new NodeUtil.NodeIterator(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
|
375 } |
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
|
376 }; |
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
|
377 } |
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
|
378 |
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
|
379 /** |
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
|
380 * Creates a shallow copy of this node. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
381 * |
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
|
382 * @return the new copy |
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
|
383 */ |
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
|
384 public Node copy() { |
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
|
385 try { |
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
|
386 return (Node) super.clone(); |
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
|
387 } catch (CloneNotSupportedException e) { |
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
|
388 return null; |
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
|
389 } |
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
|
390 } |
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
|
391 |
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
|
392 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
393 * This method must never be called. It enforces that {@link Object#clone} is not directly |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
394 * called by subclasses. Use the {@link #copy()} method instead. |
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
|
395 */ |
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
|
396 @Override |
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
|
397 @Deprecated |
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
|
398 protected final Object clone() throws CloneNotSupportedException { |
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
|
399 throw new IllegalStateException("This method should never be called, use the copy method instead!"); |
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
|
400 } |
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
|
401 |
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
|
402 /** |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
403 * Get the root node of the tree a node belongs to. |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
404 * |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
405 * @return the {@link RootNode} or {@code null} if there is none. |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
406 */ |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
407 public final RootNode getRootNode() { |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
408 Node rootNode = this; |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
409 while (rootNode.getParent() != null) { |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
410 assert !(rootNode instanceof RootNode) : "root node must not have a parent"; |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
411 rootNode = rootNode.getParent(); |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
412 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
413 if (rootNode instanceof RootNode) { |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
414 return (RootNode) rootNode; |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
415 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
416 return null; |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
417 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
418 |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
419 /** |
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
|
420 * Converts this node to a textual representation useful for debugging. |
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
|
421 */ |
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
|
422 @Override |
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
|
423 public String toString() { |
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
|
424 StringBuilder sb = new StringBuilder(getClass().getSimpleName()); |
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
|
425 Map<String, Object> properties = getDebugProperties(); |
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
|
426 boolean hasProperties = false; |
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
|
427 for (Map.Entry<String, Object> entry : properties.entrySet()) { |
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
|
428 sb.append(hasProperties ? "," : "<"); |
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
|
429 hasProperties = true; |
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
|
430 sb.append(entry.getKey()).append("=").append(entry.getValue()); |
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
|
431 } |
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
|
432 if (hasProperties) { |
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
|
433 sb.append(">"); |
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
|
434 } |
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
|
435 sb.append("@").append(Integer.toHexString(hashCode())); |
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
|
436 return sb.toString(); |
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
|
437 } |
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
|
438 } |