annotate graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/SpecializationNode.java @ 19291:f4792a544170

Truffle-DSL: implement new assumptions semantics.
author Christian Humer <christian.humer@gmail.com>
date Wed, 11 Feb 2015 12:13:44 +0100
parents 62c43fcf5be2
children e8d2f3f95dcd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
1 /*
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
4 *
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
7 * published by the Free Software Foundation. Oracle designates this
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
8 * particular file as subject to the "Classpath" exception as provided
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
10 *
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
11 * This code is distributed in the hope that it will be useful, but WITHOUT
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
14 * version 2 for more details (a copy is included in the LICENSE file that
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
15 * accompanied this code).
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
16 *
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License version
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
18 * 2 along with this work; if not, write to the Free Software Foundation,
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
20 *
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
22 * or visit www.oracle.com if you need additional information or have any
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
23 * questions.
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
24 */
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
25 package com.oracle.truffle.api.dsl.internal;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
26
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
27 import java.lang.reflect.*;
19291
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
28 import java.util.*;
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
29 import java.util.concurrent.*;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
30
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
31 import com.oracle.truffle.api.*;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
32 import com.oracle.truffle.api.dsl.*;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
33 import com.oracle.truffle.api.dsl.internal.RewriteEvent.RewriteEvent0;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
34 import com.oracle.truffle.api.dsl.internal.RewriteEvent.RewriteEvent1;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
35 import com.oracle.truffle.api.dsl.internal.RewriteEvent.RewriteEvent2;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
36 import com.oracle.truffle.api.dsl.internal.RewriteEvent.RewriteEvent3;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
37 import com.oracle.truffle.api.dsl.internal.RewriteEvent.RewriteEvent4;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
38 import com.oracle.truffle.api.dsl.internal.RewriteEvent.RewriteEventN;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
39 import com.oracle.truffle.api.frame.*;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
40 import com.oracle.truffle.api.nodes.*;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
41 import com.oracle.truffle.api.nodes.NodeUtil.NodeClass;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
42 import com.oracle.truffle.api.nodes.NodeUtil.NodeField;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
43
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
44 /**
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
45 * Internal implementation dependent base class for generated specialized nodes.
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
46 */
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
47 @SuppressWarnings("unused")
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
48 @NodeInfo(cost = NodeCost.NONE)
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
49 public abstract class SpecializationNode extends Node {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
50
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
51 @Child protected SpecializationNode next;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
52
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
53 private final int index;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
54
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
55 public SpecializationNode() {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
56 this(-1);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
57 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
58
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
59 public SpecializationNode(int index) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
60 this.index = index;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
61 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
62
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
63 @Override
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
64 public final NodeCost getCost() {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
65 return NodeCost.NONE;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
66 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
67
19281
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
68 public void reset() {
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
69 SpecializationNode start = findStart();
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
70 SpecializationNode end = findEnd();
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
71 if (start != end) {
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
72 start.replace(end, "reset specialization");
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
73 }
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
74 }
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
75
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
76 public static Node updateRoot(Node node) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
77 updateRootImpl(((SpecializedNode) node).getSpecializationNode(), node);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
78 return node;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
79 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
80
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
81 private static void updateRootImpl(SpecializationNode start, Node node) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
82 NodeField[] fields = NodeClass.get(start.getClass()).getFields();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
83 for (int i = fields.length - 1; i >= 0; i--) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
84 NodeField f = fields[i];
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
85 if (f.getName().equals("root")) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
86 f.putObject(start, node);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
87 break;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
88 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
89 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
90 if (start.next != null) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
91 updateRootImpl(start.next, node);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
92 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
93 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
94
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
95 protected final SpecializationNode polymorphicMerge(SpecializationNode newNode) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
96 SpecializationNode merged = next.merge(newNode);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
97 if (merged == newNode && !isSame(newNode) && count() <= 2) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
98 return removeSame(new RewriteEvent0(findRoot(), "merged polymorphic to monomorphic"));
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
99 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
100 return merged;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
101 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
102
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
103 public final NodeCost getNodeCost() {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
104 switch (count()) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
105 case 0:
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
106 case 1:
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
107 return NodeCost.UNINITIALIZED;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
108 case 2:
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
109 return NodeCost.MONOMORPHIC;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
110 default:
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
111 return NodeCost.POLYMORPHIC;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
112 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
113 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
114
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
115 protected abstract Node[] getSuppliedChildren();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
116
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
117 protected SpecializationNode merge(SpecializationNode newNode) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
118 if (this.isSame(newNode)) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
119 return this;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
120 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
121 return next != null ? next.merge(newNode) : newNode;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
122 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
123
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
124 protected SpecializationNode mergeNoSame(SpecializationNode newNode) {
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
125 return next != null ? next.merge(newNode) : newNode;
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
126 }
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
127
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
128 protected final int countSame(SpecializationNode node) {
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
129 return findStart().countSameImpl(node);
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
130 }
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
131
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
132 private int countSameImpl(SpecializationNode node) {
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
133 if (next != null) {
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
134 return next.countSameImpl(node) + (isSame(node) ? 1 : 0);
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
135 } else {
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
136 return 0;
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
137 }
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
138 }
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
139
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
140 @Override
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
141 public final boolean equals(Object obj) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
142 if (obj instanceof SpecializationNode) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
143 return ((SpecializationNode) obj).isSame(this);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
144 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
145 return super.equals(obj);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
146 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
147
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
148 @Override
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
149 public final int hashCode() {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
150 return index;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
151 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
152
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
153 protected boolean isSame(SpecializationNode other) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
154 return getClass() == other.getClass();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
155 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
156
18766
a720bf2e2f43 Truffle-DSL: checkstyle fixes.
Christian Humer <christian.humer@gmail.com>
parents: 18761
diff changeset
157 private int count() {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
158 return next != null ? next.count() + 1 : 1;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
159 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
160
19281
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
161 private SpecializationNode findEnd() {
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
162 SpecializationNode node = this;
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
163 while (node.next != null) {
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
164 node = node.next;
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
165 }
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
166 return node;
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
167 }
92880b0f7fed Truffle-DSL: add internal API support to reset the specialization chain.
Christian Humer <christian.humer@gmail.com>
parents: 18802
diff changeset
168
19291
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
169 protected final Object removeThis(final CharSequence reason, Frame frame) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
170 return removeThisImpl(reason).acceptAndExecute(frame);
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
171 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
172
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
173 protected final Object removeThis(final CharSequence reason, Frame frame, Object o1) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
174 return removeThisImpl(reason).acceptAndExecute(frame, o1);
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
175 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
176
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
177 protected final Object removeThis(final CharSequence reason, Frame frame, Object o1, Object o2) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
178 return removeThisImpl(reason).acceptAndExecute(frame, o1, o2);
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
179 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
180
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
181 protected final Object removeThis(final CharSequence reason, Frame frame, Object o1, Object o2, Object o3) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
182 return removeThisImpl(reason).acceptAndExecute(frame, o1, o2, o3);
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
183 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
184
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
185 protected final Object removeThis(final CharSequence reason, Frame frame, Object o1, Object o2, Object o3, Object o4) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
186 return removeThisImpl(reason).acceptAndExecute(frame, o1, o2, o3, o4);
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
187 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
188
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
189 protected final Object removeThis(final CharSequence reason, Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
190 return removeThisImpl(reason).acceptAndExecute(frame, o1, o2, o3, o4, o5);
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
191 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
192
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
193 protected final Object removeThis(final CharSequence reason, Frame frame, Object... args) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
194 return removeThisImpl(reason).acceptAndExecute(frame, args);
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
195 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
196
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
197 private SpecializationNode removeThisImpl(final CharSequence reason) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
198 this.replace(this.next, reason);
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
199 return findEnd().findStart();
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
200 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
201
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
202 protected final SpecializationNode removeSame(final CharSequence reason) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
203 return atomic(new Callable<SpecializationNode>() {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
204 public SpecializationNode call() throws Exception {
19291
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
205 return removeSameImpl(SpecializationNode.this, reason);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
206 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
207 });
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
208 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
209
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
210 /** Find the topmost of the specialization chain. */
18766
a720bf2e2f43 Truffle-DSL: checkstyle fixes.
Christian Humer <christian.humer@gmail.com>
parents: 18761
diff changeset
211 private SpecializationNode findStart() {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
212 SpecializationNode node = this;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
213 Node parent = this.getParent();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
214 while (parent instanceof SpecializationNode) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
215 SpecializationNode parentCast = ((SpecializationNode) parent);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
216 if (parentCast.next != node) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
217 break;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
218 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
219 node = parentCast;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
220 parent = node.getParent();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
221 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
222 return node;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
223 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
224
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
225 private Node findRoot() {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
226 return findStart().getParent();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
227 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
228
19291
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
229 private SpecializationNode removeSameImpl(SpecializationNode toRemove, CharSequence reason) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
230 SpecializationNode start = findStart();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
231 SpecializationNode current = start;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
232 while (current != null) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
233 if (current.isSame(toRemove)) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
234 current.replace(current.next, reason);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
235 if (current == start) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
236 start = start.next;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
237 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
238 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
239 current = current.next;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
240 }
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
241 return findEnd().findStart();
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
242 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
243
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
244 public Object acceptAndExecute(Frame frame) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
245 throw new UnsupportedOperationException();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
246 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
247
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
248 public Object acceptAndExecute(Frame frame, Object o1) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
249 throw new UnsupportedOperationException();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
250 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
251
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
252 public Object acceptAndExecute(Frame frame, Object o1, Object o2) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
253 throw new UnsupportedOperationException();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
254 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
255
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
256 public Object acceptAndExecute(Frame frame, Object o1, Object o2, Object o3) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
257 throw new UnsupportedOperationException();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
258 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
259
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
260 public Object acceptAndExecute(Frame frame, Object o1, Object o2, Object o3, Object o4) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
261 throw new UnsupportedOperationException();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
262 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
263
18802
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
264 public Object acceptAndExecute(Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
265 throw new UnsupportedOperationException();
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
266 }
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
267
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
268 public Object acceptAndExecute(Frame frame, Object... args) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
269 throw new UnsupportedOperationException();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
270 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
271
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
272 protected SpecializationNode createFallback() {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
273 return null;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
274 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
275
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
276 protected SpecializationNode createPolymorphic() {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
277 return null;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
278 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
279
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
280 protected SpecializationNode createNext(Frame frame) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
281 throw new UnsupportedOperationException();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
282 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
283
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
284 protected SpecializationNode createNext(Frame frame, Object o1) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
285 throw new UnsupportedOperationException();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
286 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
287
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
288 protected SpecializationNode createNext(Frame frame, Object o1, Object o2) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
289 throw new UnsupportedOperationException();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
290 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
291
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
292 protected SpecializationNode createNext(Frame frame, Object o1, Object o2, Object o3) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
293 throw new UnsupportedOperationException();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
294 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
295
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
296 protected SpecializationNode createNext(Frame frame, Object o1, Object o2, Object o3, Object o4) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
297 throw new UnsupportedOperationException();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
298 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
299
18802
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
300 protected SpecializationNode createNext(Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
301 throw new UnsupportedOperationException();
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
302 }
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
303
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
304 protected SpecializationNode createNext(Frame frame, Object... args) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
305 throw new UnsupportedOperationException();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
306 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
307
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
308 protected final Object uninitialized(Frame frame) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
309 CompilerDirectives.transferToInterpreterAndInvalidate();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
310 SpecializationNode nextSpecialization = createNext(frame);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
311 if (nextSpecialization == null) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
312 nextSpecialization = createFallback();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
313 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
314 if (nextSpecialization == null) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
315 return unsupported(frame);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
316 }
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
317 return insertSpecialization(nextSpecialization, new RewriteEvent0(findRoot(), "inserted new specialization")).acceptAndExecute(frame);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
318 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
319
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
320 protected final Object uninitialized(Frame frame, Object o1) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
321 CompilerDirectives.transferToInterpreterAndInvalidate();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
322 SpecializationNode nextSpecialization = createNext(frame, o1);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
323 if (nextSpecialization == null) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
324 nextSpecialization = createFallback();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
325 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
326 if (nextSpecialization == null) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
327 return unsupported(frame, o1);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
328 }
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
329 return insertSpecialization(nextSpecialization, new RewriteEvent1(findRoot(), "inserted new specialization", o1)).acceptAndExecute(frame, o1);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
330 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
331
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
332 protected final Object uninitialized(Frame frame, Object o1, Object o2) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
333 CompilerDirectives.transferToInterpreterAndInvalidate();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
334 SpecializationNode nextSpecialization = createNext(frame, o1, o2);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
335 if (nextSpecialization == null) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
336 nextSpecialization = createFallback();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
337 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
338 if (nextSpecialization == null) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
339 return unsupported(frame, o1, o2);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
340 }
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
341 return insertSpecialization(nextSpecialization, new RewriteEvent2(findRoot(), "inserted new specialization", o1, o2)).acceptAndExecute(frame, o1, o2);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
342 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
343
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
344 protected final Object uninitialized(Frame frame, Object o1, Object o2, Object o3) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
345 CompilerDirectives.transferToInterpreterAndInvalidate();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
346 SpecializationNode nextSpecialization = createNext(frame, o1, o2, o3);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
347 if (nextSpecialization == null) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
348 nextSpecialization = createFallback();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
349 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
350 if (nextSpecialization == null) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
351 return unsupported(frame, o1, o2, o3);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
352 }
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
353 return insertSpecialization(nextSpecialization, new RewriteEvent3(findRoot(), "inserted new specialization", o1, o2, o3)).acceptAndExecute(frame, o1, o2, o3);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
354 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
355
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
356 protected final Object uninitialized(Frame frame, Object o1, Object o2, Object o3, Object o4) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
357 CompilerDirectives.transferToInterpreterAndInvalidate();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
358 SpecializationNode nextSpecialization = createNext(frame, o1, o2, o3, o4);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
359 if (nextSpecialization == null) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
360 nextSpecialization = createFallback();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
361 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
362 if (nextSpecialization == null) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
363 return unsupported(frame, o1, o2, o3, o4);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
364 }
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
365 return insertSpecialization(nextSpecialization, new RewriteEvent4(findRoot(), "inserts new specialization", o1, o2, o3, o4)).acceptAndExecute(frame, o1, o2, o3, o4);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
366 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
367
18802
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
368 protected final Object uninitialized(Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
369 CompilerDirectives.transferToInterpreterAndInvalidate();
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
370 SpecializationNode nextSpecialization = createNext(frame, o1, o2, o3, o4, o5);
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
371 if (nextSpecialization == null) {
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
372 nextSpecialization = createFallback();
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
373 }
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
374 if (nextSpecialization == null) {
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
375 unsupported(frame, o1, o2, o3, o4, o5);
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
376 }
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
377 return insertSpecialization(nextSpecialization, new RewriteEventN(findRoot(), "inserts new specialization", o1, o2, o3, o4, o5)).acceptAndExecute(frame, o1, o2, o3, o4, o5);
18802
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
378 }
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
379
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
380 protected final Object uninitialized(Frame frame, Object... args) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
381 CompilerDirectives.transferToInterpreterAndInvalidate();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
382 SpecializationNode nextSpecialization = createNext(frame, args);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
383 if (nextSpecialization == null) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
384 nextSpecialization = createFallback();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
385 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
386 if (nextSpecialization == null) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
387 unsupported(frame, args);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
388 }
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
389 return insertSpecialization(nextSpecialization, new RewriteEventN(findRoot(), "inserts new specialization", args)).acceptAndExecute(frame, args);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
390 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
391
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
392 private boolean needsPolymorphic() {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
393 return findStart().count() == 2;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
394 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
395
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
396 protected final Object remove(String reason, Frame frame) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
397 return removeSame(new RewriteEvent0(findRoot(), reason)).acceptAndExecute(frame);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
398 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
399
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
400 protected final Object remove(String reason, Frame frame, Object o1) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
401 return removeSame(new RewriteEvent1(findRoot(), reason, o1)).acceptAndExecute(frame, o1);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
402 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
403
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
404 protected final Object remove(String reason, Frame frame, Object o1, Object o2) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
405 return removeSame(new RewriteEvent2(findRoot(), reason, o1, o2)).acceptAndExecute(frame, o1, o2);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
406 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
407
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
408 protected final Object remove(String reason, Frame frame, Object o1, Object o2, Object o3) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
409 return removeSame(new RewriteEvent3(findRoot(), reason, o1, o2, o3)).acceptAndExecute(frame, o1, o2, o3);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
410 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
411
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
412 protected final Object remove(String reason, Frame frame, Object o1, Object o2, Object o3, Object o4) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
413 return removeSame(new RewriteEvent4(findRoot(), reason, o1, o2, o3, o4)).acceptAndExecute(frame, o1, o2, o3, o4);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
414 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
415
18802
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
416 protected final Object remove(String reason, Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
417 return removeSame(new RewriteEventN(findRoot(), reason, o1, o2, o3, o4, o5)).acceptAndExecute(frame, o1, o2, o3, o4, o5);
18802
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
418 }
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
419
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
420 protected final Object remove(String reason, Frame frame, Object... args) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
421 return removeSame(new RewriteEventN(findRoot(), reason, args)).acceptAndExecute(frame, args);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
422 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
423
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
424 protected Object unsupported(Frame frame) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
425 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren());
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
426 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
427
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
428 protected Object unsupported(Frame frame, Object o1) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
429 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
430 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
431
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
432 protected Object unsupported(Frame frame, Object o1, Object o2) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
433 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
434 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
435
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
436 protected Object unsupported(Frame frame, Object o1, Object o2, Object o3) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
437 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2, o3);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
438 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
439
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
440 protected Object unsupported(Frame frame, Object o1, Object o2, Object o3, Object o4) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
441 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2, o3, o4);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
442 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
443
18802
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
444 protected Object unsupported(Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
445 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2, o3, o4, o5);
18802
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
446 }
71e372cae32e Truffle-DSL: increase maximum number of acceptAndExecute arguments to 5.
Christian Humer <christian.humer@gmail.com>
parents: 18776
diff changeset
447
18776
c0fb70634640 Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents: 18766
diff changeset
448 protected Object unsupported(Frame frame, Object... args) {
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
449 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), args);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
450 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
451
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
452 private SpecializationNode insertSpecialization(final SpecializationNode generated, final CharSequence message) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
453 return atomic(new Callable<SpecializationNode>() {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
454 public SpecializationNode call() {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
455 return insert(generated, message);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
456 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
457 });
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
458 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
459
18766
a720bf2e2f43 Truffle-DSL: checkstyle fixes.
Christian Humer <christian.humer@gmail.com>
parents: 18761
diff changeset
460 private SpecializationNode insert(final SpecializationNode generated, CharSequence message) {
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
461 SpecializationNode start = findStart();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
462 if (start == this) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
463 // fast path for first insert
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
464 return insertBefore(this, generated, message);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
465 } else {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
466 return slowSortedInsert(start, generated, message);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
467 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
468 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
469
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
470 private static <T> SpecializationNode slowSortedInsert(SpecializationNode start, final SpecializationNode generated, final CharSequence message) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
471 final SpecializationNode merged = start.merge(generated);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
472 if (merged == generated) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
473 // new node
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
474 if (start.count() == 2) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
475 insertBefore(start, start.createPolymorphic(), "insert polymorphic");
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
476 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
477 SpecializationNode insertBefore = findInsertBeforeNode(generated.index, start);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
478 return insertBefore(insertBefore, generated, message);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
479 } else {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
480 // existing node
19289
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
481 merged.replace(merged, new RewriteEvent0(merged.findRoot(), "merged specialization"));
62c43fcf5be2 Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 19281
diff changeset
482 return start;
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
483 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
484 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
485
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
486 private static SpecializationNode findInsertBeforeNode(int generatedIndex, SpecializationNode start) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
487 SpecializationNode current = start;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
488 while (current != null && current.index < generatedIndex) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
489 current = current.next;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
490 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
491 return current;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
492 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
493
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
494 private static <T> SpecializationNode insertBefore(SpecializationNode node, SpecializationNode insertBefore, CharSequence message) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
495 insertBefore.next = node;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
496 return node.replace(insertBefore, message);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
497 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
498
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
499 @Override
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
500 public final String toString() {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
501 Class<?> clazz = getClass();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
502 StringBuilder b = new StringBuilder();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
503 b.append(clazz.getSimpleName());
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
504
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
505 appendFields(b, clazz);
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
506 if (next != null) {
19291
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
507 b.append("\n -> ").append(next.toString());
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
508 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
509 return b.toString();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
510 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
511
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
512 private void appendFields(StringBuilder b, Class<?> clazz) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
513 Field[] fields = clazz.getDeclaredFields();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
514 if (fields.length == 0) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
515 return;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
516 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
517 b.append("(");
19291
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
518 String sep = "";
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
519 for (Field field : fields) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
520 if (Modifier.isStatic(field.getModifiers())) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
521 continue;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
522 }
19291
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
523 b.append(sep);
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
524 String name = field.getName();
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
525 if (name.equals("root")) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
526 continue;
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
527 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
528 b.append(field.getName());
19291
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
529 b.append(" = ");
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
530 try {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
531 field.setAccessible(true);
19291
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
532 Object value = field.get(this);
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
533 if (value instanceof Object[]) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
534 b.append(Arrays.toString((Object[]) field.get(this)));
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
535 } else {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
536 b.append(field.get(this));
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
537 }
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
538 } catch (IllegalArgumentException e) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
539 b.append(e.toString());
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
540 } catch (IllegalAccessException e) {
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
541 b.append(e.toString());
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
542 }
19291
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
543 sep = ", ";
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
544 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
545 b.append(")");
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
546 }
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
547
19291
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
548 // utilities for generated code
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
549 protected static void check(Assumption assumption) throws InvalidAssumptionException {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
550 if (assumption != null) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
551 assumption.check();
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
552 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
553 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
554
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
555 @ExplodeLoop
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
556 protected static void check(Assumption[] assumptions) throws InvalidAssumptionException {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
557 if (assumptions != null) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
558 CompilerAsserts.compilationConstant(assumptions.length);
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
559 for (Assumption assumption : assumptions) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
560 check(assumption);
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
561 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
562 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
563 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
564
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
565 protected static boolean isValid(Assumption assumption) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
566 if (assumption != null) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
567 return assumption.isValid();
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
568 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
569 return true;
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
570 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
571
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
572 protected static boolean isValid(Assumption[] assumptions) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
573 if (assumptions != null) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
574 for (Assumption assumption : assumptions) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
575 if (!isValid(assumption)) {
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
576 return false;
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
577 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
578 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
579 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
580 return true;
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
581 }
f4792a544170 Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents: 19289
diff changeset
582
18761
a665483c3881 Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
583 }