Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java @ 15372:2cea065e419d
Truffle: print the source section in the rewrite trace.
author | Chris Seaton <chris.seaton@oracle.com> |
---|---|
date | Thu, 24 Apr 2014 23:29:28 +0100 |
parents | 1cd02b4d90d1 |
children | dd624471bd30 |
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.*; |
14629
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
30 import java.util.concurrent.*; |
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
|
31 |
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
|
32 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
|
33 |
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
|
34 /** |
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 * 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
|
36 */ |
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 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
|
38 |
a4b84ba6dc2e
Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 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
|
40 |
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
|
41 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
|
42 |
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
|
43 /** |
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 * 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
|
45 */ |
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 @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
|
47 @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
|
48 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
|
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 /** |
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 * 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
|
53 */ |
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 @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
|
55 @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
|
56 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
|
57 } |
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
|
58 |
10481
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
59 protected Node() { |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
60 CompilerAsserts.neverPartOfCompilation(); |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
61 } |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
62 |
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
|
63 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
|
64 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
|
65 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
|
66 } |
8f0fb0ade839
Truffle: add alternate Node/RootNode constructors with SourceSection argument.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11279
diff
changeset
|
67 |
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
|
68 /** |
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
|
69 * Assigns a link to a guest language source section to this node. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
70 * |
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
|
71 * @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
|
72 */ |
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 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
|
74 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
|
75 // 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
|
76 // 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
|
77 // 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
|
78 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
|
79 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
|
80 } |
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
|
81 } |
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 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
|
83 } |
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
|
84 |
14566
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14564
diff
changeset
|
85 /** |
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14564
diff
changeset
|
86 * 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
|
87 * 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
|
88 * 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
|
89 * {@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
|
90 * {@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
|
91 * default value. |
6681b9eb3f4c
Truffle: API cleanup and javadoc for CallNodes.
Christian Humer <christian.humer@gmail.com>
parents:
14564
diff
changeset
|
92 */ |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
93 public NodeCost getCost() { |
13994
989f58d6a0ca
Truffle: Added API for Node.getKind().
Christian Humer <christian.humer@gmail.com>
parents:
13983
diff
changeset
|
94 NodeInfo info = getClass().getAnnotation(NodeInfo.class); |
989f58d6a0ca
Truffle: Added API for Node.getKind().
Christian Humer <christian.humer@gmail.com>
parents:
13983
diff
changeset
|
95 if (info != null) { |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
96 return info.cost(); |
13994
989f58d6a0ca
Truffle: Added API for Node.getKind().
Christian Humer <christian.humer@gmail.com>
parents:
13983
diff
changeset
|
97 } |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
98 return NodeCost.MONOMORPHIC; |
13994
989f58d6a0ca
Truffle: Added API for Node.getKind().
Christian Humer <christian.humer@gmail.com>
parents:
13983
diff
changeset
|
99 } |
989f58d6a0ca
Truffle: Added API for Node.getKind().
Christian Humer <christian.humer@gmail.com>
parents:
13983
diff
changeset
|
100 |
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
|
101 /** |
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 * 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
|
103 */ |
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 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
|
105 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
|
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 /** |
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 * Retrieves the guest language source code section that is currently assigned to this node. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
110 * |
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
|
111 * @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
|
112 */ |
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 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
|
114 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
|
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 |
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
|
117 /** |
10481
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
118 * Retrieves the guest language source code section that is currently assigned to this node. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
119 * |
10481
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
120 * @return the assigned source code section |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
121 */ |
11818
793743715dc1
put Node.getEncapsulatedSourceSection() on slow path
Michael Haupt <michael.haupt@oracle.com>
parents:
11648
diff
changeset
|
122 @CompilerDirectives.SlowPath |
10481
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
123 public final SourceSection getEncapsulatingSourceSection() { |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
124 if (sourceSection == null && getParent() != null) { |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
125 return getParent().getEncapsulatingSourceSection(); |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
126 } |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
127 return sourceSection; |
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 |
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
130 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
131 * 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
|
132 * node. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
133 * |
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
|
134 * @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
|
135 * @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
|
136 */ |
14628
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
137 @SuppressWarnings("static-method") |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
138 @Deprecated |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
139 protected final <T extends Node> T[] adoptChildren(final T[] newChildren) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
140 return newChildren; |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
141 } |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
142 |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
143 /** |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
144 * Method that updates the link to the parent in the specified new child node to this node. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
145 * |
14628
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
146 * @param newChild the new child whose parent should be updated |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
147 * @return the new child |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
148 */ |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
149 @SuppressWarnings("static-method") |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
150 @Deprecated |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
151 protected final <T extends Node> T adoptChild(final T newChild) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
152 return newChild; |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
153 } |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
154 |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
155 /** |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
156 * Method that updates the link to the parent in the array of specified new child nodes to this |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
157 * node. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
158 * |
14628
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
159 * @param newChildren the array of new children whose parent should be updated |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
160 * @return the array of new children |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
161 */ |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
162 protected final <T extends Node> T[] insert(final T[] newChildren) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
163 CompilerDirectives.transferToInterpreterAndInvalidate(); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
164 assert newChildren != null; |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
165 for (Node newChild : newChildren) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
166 adoptHelper(newChild); |
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
|
167 } |
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 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
|
169 } |
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 * Method that updates the link to the parent in the specified new child node to this node. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
173 * |
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
|
174 * @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
|
175 * @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
|
176 */ |
14628
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
177 protected final <T extends Node> T insert(final T newChild) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
178 CompilerDirectives.transferToInterpreterAndInvalidate(); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
179 assert newChild != null; |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
180 adoptHelper(newChild); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
181 return newChild; |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
182 } |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
183 |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
184 public final void adoptChildren() { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
185 CompilerDirectives.transferToInterpreterAndInvalidate(); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
186 adoptHelper(); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
187 } |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
188 |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
189 private void adoptHelper(final Node newChild) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
190 assert newChild != null; |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
191 if (newChild == this) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
192 throw new IllegalStateException("The parent of a node can never be the node itself."); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
193 } |
15346
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
194 boolean isInserted = newChild.parent == null; |
14628
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
195 newChild.parent = this; |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
196 newChild.adoptHelper(); |
15346
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
197 if (isInserted) { |
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
198 newChild.onAdopt(); |
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
199 } |
14628
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
200 } |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
201 |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
202 private void adoptHelper() { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
203 Iterable<Node> children = this.getChildren(); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
204 for (Node child : children) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
205 if (child != null && child.getParent() != this) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
206 this.adoptHelper(child); |
10481
29e9a5d18c70
Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9782
diff
changeset
|
207 } |
14628
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
208 } |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
209 } |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
210 |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
211 private void adoptUnadoptedHelper(final Node newChild) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
212 assert newChild != null; |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
213 if (newChild == this) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
214 throw new IllegalStateException("The parent of a node can never be the node itself."); |
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
|
215 } |
15346
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
216 boolean isInserted = newChild.parent == null; |
14628
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
217 newChild.parent = this; |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
218 newChild.adoptUnadoptedHelper(); |
15346
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
219 if (isInserted) { |
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
220 newChild.onAdopt(); |
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
221 } |
14628
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
222 } |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
223 |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
224 private void adoptUnadoptedHelper() { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
225 Iterable<Node> children = this.getChildren(); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
226 for (Node child : children) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
227 if (child != null && child.getParent() == null) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
228 this.adoptUnadoptedHelper(child); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
229 } |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
230 } |
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
|
231 } |
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
|
232 |
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
|
233 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
234 * 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
|
235 * subclasses to add their own custom properties. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
236 * |
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
|
237 * @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
|
238 */ |
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
|
239 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
|
240 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
|
241 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
|
242 } |
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
|
243 |
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 /** |
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 * The current parent node of this node. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
246 * |
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
|
247 * @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
|
248 */ |
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
|
249 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
|
250 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
|
251 } |
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
|
252 |
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
|
253 /** |
9256
9640bb930327
Preserve the source section during node rewrites.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9255
diff
changeset
|
254 * 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
|
255 * {@link #getSourceSection()}) associated with this node, it is transferred to the new node. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
256 * |
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
|
257 * @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
|
258 * @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
|
259 * @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
|
260 */ |
14628
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
261 public final <T extends Node> T replace(final T newNode, final CharSequence reason) { |
13915
d6b340b757a2
Truffle: refactorings
Andreas Woess <andreas.woess@jku.at>
parents:
13811
diff
changeset
|
262 CompilerDirectives.transferToInterpreterAndInvalidate(); |
14629
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
263 atomic(new Runnable() { |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
264 public void run() { |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
265 replaceHelper(newNode, reason); |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
266 } |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
267 }); |
12494
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
268 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
|
269 } |
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
|
270 |
12494
57b8a41c0e18
Truffle: fix possible node rewrite failures after recursive calls.
Andreas Woess <andreas.woess@jku.at>
parents:
11951
diff
changeset
|
271 /** |
9256
9640bb930327
Preserve the source section during node rewrites.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9255
diff
changeset
|
272 * 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
|
273 * {@link #getSourceSection()}) associated with this node, it is transferred to the new node. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
274 * |
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
|
275 * @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
|
276 * @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
|
277 */ |
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
|
278 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
|
279 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
|
280 } |
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
|
281 |
14628
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
282 private void replaceHelper(Node newNode, CharSequence reason) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
283 CompilerAsserts.neverPartOfCompilation(); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
284 if (this.getParent() == null) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
285 throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent."); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
286 } |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
287 if (sourceSection != null && newNode.getSourceSection() == null) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
288 // Pass on the source section to the new node. |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
289 newNode.assignSourceSection(sourceSection); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
290 } |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
291 // (aw) need to set parent *before* replace, so that (unsynchronized) getRootNode() |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
292 // will always find the root node |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
293 newNode.parent = this.parent; |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
294 if (NodeUtil.replaceChild(this.parent, this, newNode)) { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
295 this.parent.adoptHelper(newNode); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
296 } else { |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
297 this.parent.adoptUnadoptedHelper(newNode); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
298 } |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
299 reportReplace(this, newNode, reason); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
300 onReplace(newNode, reason); |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
301 } |
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
14584
diff
changeset
|
302 |
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
|
303 /** |
10846
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
304 * Checks if this node is properly adopted by a parent and can be replaced. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
305 * |
10846
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
306 * @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
|
307 */ |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
308 public final boolean isReplaceable() { |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
309 if (getParent() != null) { |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
310 for (Node sibling : getParent().getChildren()) { |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
311 if (sibling == this) { |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
312 return true; |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
313 } |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
314 } |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
315 } |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
316 return false; |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
317 } |
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
318 |
14584
6189c1983cd3
Truffle: make Node#replace accept any CharSequence as reason
Andreas Woess <andreas.woess@jku.at>
parents:
14566
diff
changeset
|
319 private void reportReplace(Node oldNode, Node newNode, CharSequence 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
|
320 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
|
321 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
|
322 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
|
323 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
|
324 ((ReplaceObserver) target).nodeReplaced(oldNode, newNode, reason); |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
325 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
326 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
327 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
328 |
10846
e87d56a51047
Truffle: add Node.isReplaceable()
Andreas Woess <andreas.woess@jku.at>
parents:
10843
diff
changeset
|
329 /** |
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
|
330 * 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
|
331 * node is rewritten. This method is invoked before the actual replace has happened. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
332 * |
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
|
333 * @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
|
334 * @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
|
335 */ |
14584
6189c1983cd3
Truffle: make Node#replace accept any CharSequence as reason
Andreas Woess <andreas.woess@jku.at>
parents:
14566
diff
changeset
|
336 protected void onReplace(Node newNode, CharSequence reason) { |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
337 if (TruffleOptions.TraceRewrites) { |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
338 traceRewrite(newNode, reason); |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
339 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
340 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
341 |
14584
6189c1983cd3
Truffle: make Node#replace accept any CharSequence as reason
Andreas Woess <andreas.woess@jku.at>
parents:
14566
diff
changeset
|
342 private void traceRewrite(Node newNode, CharSequence reason) { |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
343 if (TruffleOptions.TraceRewritesFilterFromCost != null) { |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
344 if (filterByKind(this, TruffleOptions.TraceRewritesFilterFromCost)) { |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
345 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
|
346 } |
8c570011b86f
Truffle: when a node is replaced, notify optimized call target and delay compilation.
Andreas Woess <andreas.woess@jku.at>
parents:
10846
diff
changeset
|
347 } |
10590
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
348 |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
349 if (TruffleOptions.TraceRewritesFilterToCost != null) { |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
350 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
|
351 return; |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
352 } |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
353 } |
10590
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
354 |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
355 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
|
356 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
|
357 Class<? extends Node> to = newNode.getClass(); |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
358 if (filter != null && (filterByContainsClassName(from, filter) || filterByContainsClassName(to, filter))) { |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
359 return; |
10590
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
360 } |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
361 |
15372
2cea065e419d
Truffle: print the source section in the rewrite trace.
Chris Seaton <chris.seaton@oracle.com>
parents:
15346
diff
changeset
|
362 final SourceSection reportedSourceSection = getEncapsulatingSourceSection(); |
2cea065e419d
Truffle: print the source section in the rewrite trace.
Chris Seaton <chris.seaton@oracle.com>
parents:
15346
diff
changeset
|
363 |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
364 PrintStream out = System.out; |
15372
2cea065e419d
Truffle: print the source section in the rewrite trace.
Chris Seaton <chris.seaton@oracle.com>
parents:
15346
diff
changeset
|
365 out.printf("[truffle] rewrite %-50s |From %-40s |To %-40s |Reason %s%s%n", this.toString(), formatNodeInfo(this), formatNodeInfo(newNode), reason != null && reason.length() > 0 ? reason |
2cea065e419d
Truffle: print the source section in the rewrite trace.
Chris Seaton <chris.seaton@oracle.com>
parents:
15346
diff
changeset
|
366 : "unknown", reportedSourceSection != null ? " at " + reportedSourceSection.getShortDescription() : ""); |
10590
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
367 } |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
368 |
15346
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
369 /** |
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
370 * Subclasses of {@link Node} can implement this method to execute extra functionality when a |
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
371 * node is effectively inserted into the AST. The {@code onAdopt} callback is called after the |
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
372 * node has been effectively inserted, and it is guaranteed to be called only once for any given |
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
373 * node. |
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
374 */ |
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
375 protected void onAdopt() { |
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
376 // empty default |
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
377 } |
1cd02b4d90d1
onAdopt callback for ASTs
Michael Haupt <michael.haupt@oracle.com>
parents:
14991
diff
changeset
|
378 |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
379 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
|
380 String cost = "?"; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
381 switch (node.getCost()) { |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
382 case NONE: |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
383 cost = "G"; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
384 break; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
385 case MONOMORPHIC: |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
386 cost = "M"; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
387 break; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
388 case POLYMORPHIC: |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
389 cost = "P"; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
390 break; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
391 case MEGAMORPHIC: |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
392 cost = "G"; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
393 break; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
394 default: |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
395 cost = "?"; |
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
396 break; |
10590
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
397 } |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
398 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
|
399 } |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
400 |
14564
5d1308c78ddc
Truffle: Introduced NodeCost as a replacement for NodeInfo.Kind.
Christian Humer <christian.humer@gmail.com>
parents:
14073
diff
changeset
|
401 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
|
402 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
|
403 } |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
404 |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
405 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
|
406 Class<?> currentFrom = from; |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
407 while (currentFrom != null) { |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
408 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
|
409 return false; |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
410 } |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
411 currentFrom = currentFrom.getSuperclass(); |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
412 } |
6eb8d63cea34
Added a feature to trace rewrites of truffle nodes.
Christian Humer <christian.humer@gmail.com>
parents:
10481
diff
changeset
|
413 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
|
414 } |
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
|
415 |
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
|
416 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
417 * 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
|
418 * child nodes. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
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 * @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
|
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 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
|
423 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
|
424 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
|
425 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
|
426 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
|
427 } |
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 } |
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 } |
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 } |
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 /** |
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 * Iterator over the children of this node. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
434 * |
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
|
435 * @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
|
436 */ |
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 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
|
438 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
|
439 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
|
440 |
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
|
441 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
|
442 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
|
443 } |
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
|
444 }; |
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
|
445 } |
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
|
446 |
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
|
447 /** |
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
|
448 * Creates a shallow copy of this node. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
449 * |
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
|
450 * @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
|
451 */ |
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
|
452 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
|
453 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
|
454 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
|
455 } 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
|
456 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
|
457 } |
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
|
458 } |
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
|
459 |
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
|
460 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
461 * 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
|
462 * 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
|
463 */ |
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
|
464 @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
|
465 @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
|
466 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
|
467 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
|
468 } |
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
|
469 |
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
|
470 /** |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
471 * Get the root node of the tree a node belongs to. |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14629
diff
changeset
|
472 * |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
473 * @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
|
474 */ |
13983
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13915
diff
changeset
|
475 public final RootNode getRootNode() { |
12692
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
476 Node rootNode = this; |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
477 while (rootNode.getParent() != null) { |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
478 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
|
479 rootNode = rootNode.getParent(); |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
480 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
481 if (rootNode instanceof RootNode) { |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
482 return (RootNode) rootNode; |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
483 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
484 return null; |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
485 } |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
486 |
ffd4b6b4ae68
Truffle Node class refactoring.
Andreas Woess <andreas.woess@jku.at>
parents:
12495
diff
changeset
|
487 /** |
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
|
488 * 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
|
489 */ |
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
|
490 @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
|
491 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
|
492 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
|
493 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
|
494 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
|
495 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
|
496 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
|
497 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
|
498 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
|
499 } |
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
|
500 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
|
501 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
|
502 } |
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
|
503 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
|
504 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
|
505 } |
14629
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
506 |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
507 public final void atomic(Runnable closure) { |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
508 RootNode rootNode = getRootNode(); |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
509 if (rootNode != null) { |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
510 synchronized (rootNode) { |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
511 closure.run(); |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
512 } |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
513 } else { |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
514 closure.run(); |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
515 } |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
516 } |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
517 |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
518 public final <T> T atomic(Callable<T> closure) { |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
519 try { |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
520 RootNode rootNode = getRootNode(); |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
521 if (rootNode != null) { |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
522 synchronized (rootNode) { |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
523 return closure.call(); |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
524 } |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
525 } else { |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
526 return closure.call(); |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
527 } |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
528 } catch (RuntimeException e) { |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
529 throw e; |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
530 } catch (Exception e) { |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
531 throw new RuntimeException(e); |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
532 } |
ba52fbec5b6c
Truffle: atomic node rewriting
Andreas Woess <andreas.woess@jku.at>
parents:
14628
diff
changeset
|
533 } |
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
|
534 } |