Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java @ 20984:6361fa2e3321
Truffle-DSL: further fixes for polymorphic execute signatures.
author | Christian Humer <christian.humer@oracle.com> |
---|---|
date | Wed, 15 Apr 2015 21:13:43 +0200 |
parents | 476374f3fe9a |
children |
rev | line source |
---|---|
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
16759
23415229349b
Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents:
16755
diff
changeset
|
23 package com.oracle.truffle.dsl.processor.model; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import java.util.*; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
27 import javax.lang.model.element.*; |
20938
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
28 import javax.lang.model.type.*; |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
29 |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 import com.oracle.truffle.dsl.processor.*; |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
31 import com.oracle.truffle.dsl.processor.expression.*; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
32 import com.oracle.truffle.dsl.processor.java.*; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
34 public final class SpecializationData extends TemplateMethod { |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 |
13528
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
36 public enum SpecializationKind { |
14908
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13532
diff
changeset
|
37 UNINITIALIZED, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13532
diff
changeset
|
38 SPECIALIZED, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13532
diff
changeset
|
39 POLYMORPHIC, |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
17251
diff
changeset
|
40 FALLBACK |
13528
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
41 } |
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
42 |
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
43 private final NodeData node; |
20940
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
20938
diff
changeset
|
44 private SpecializationKind kind; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 private final List<SpecializationThrowsData> exceptions; |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
46 private List<GuardExpression> guards = Collections.emptyList(); |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
47 private List<CacheExpression> caches = Collections.emptyList(); |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
48 private List<AssumptionExpression> assumptionExpressions = Collections.emptyList(); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 private List<ShortCircuitData> shortCircuits; |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
50 private final Set<SpecializationData> contains = new TreeSet<>(); |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
51 private final Set<String> containsNames = new TreeSet<>(); |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
52 private final Set<SpecializationData> excludedBy = new TreeSet<>(); |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
53 private String insertBeforeName; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
54 private SpecializationData insertBefore; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 private boolean reachable; |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
56 private int index; |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
57 private DSLExpression limitExpression; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
59 public SpecializationData(NodeData node, TemplateMethod template, SpecializationKind kind, List<SpecializationThrowsData> exceptions) { |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 super(template); |
13528
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
61 this.node = node; |
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
62 this.kind = kind; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
63 this.exceptions = exceptions; |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
64 this.index = template.getNaturalOrder(); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
66 for (SpecializationThrowsData exception : exceptions) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
67 exception.setSpecialization(this); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
68 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
69 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
70 |
19293
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
71 public boolean isCacheBoundByGuard(CacheExpression cacheExpression) { |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
72 for (GuardExpression expression : getGuards()) { |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
73 if (expression.getExpression().findBoundVariableElements().contains(cacheExpression.getParameter().getVariableElement())) { |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
74 return true; |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
75 } |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
76 } |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
77 |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
78 // check all next binding caches if they are bound by guard |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
79 Set<VariableElement> boundVariables = cacheExpression.getExpression().findBoundVariableElements(); |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
80 boolean found = false; |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
81 for (CacheExpression expression : getCaches()) { |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
82 if (cacheExpression == expression) { |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
83 found = true; |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
84 } else if (found) { |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
85 if (boundVariables.contains(expression.getParameter().getVariableElement())) { |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
86 if (isCacheBoundByGuard(expression)) { |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
87 return true; |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
88 } |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
89 } |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
90 } |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
91 } |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
92 return false; |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
93 } |
21b9b9941775
Truffle-DSL: initialize caches late if possible; fix assumption arrays need a @CompilationFinal to be checked.
Christian Humer <christian.humer@gmail.com>
parents:
19291
diff
changeset
|
94 |
20940
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
20938
diff
changeset
|
95 public void setKind(SpecializationKind kind) { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
20938
diff
changeset
|
96 this.kind = kind; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
20938
diff
changeset
|
97 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
20938
diff
changeset
|
98 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
99 public boolean isDynamicParameterBound(DSLExpression expression) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
100 Set<VariableElement> boundVariables = expression.findBoundVariableElements(); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
101 for (Parameter parameter : getDynamicParameters()) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
102 if (boundVariables.contains(parameter.getVariableElement())) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
103 return true; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
104 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
105 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
106 return false; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
107 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
108 |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
109 public Parameter findByVariable(VariableElement variable) { |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
110 for (Parameter parameter : getParameters()) { |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
111 if (ElementUtils.variableEquals(parameter.getVariableElement(), variable)) { |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
112 return parameter; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
113 } |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
114 } |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
115 return null; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
116 } |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
117 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
118 public DSLExpression getLimitExpression() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
119 return limitExpression; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
120 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
121 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
122 public void setLimitExpression(DSLExpression limitExpression) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
123 this.limitExpression = limitExpression; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
124 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
125 |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
126 public void setInsertBefore(SpecializationData insertBefore) { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
127 this.insertBefore = insertBefore; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
128 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
129 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
130 public void setInsertBeforeName(String insertBeforeName) { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
131 this.insertBeforeName = insertBeforeName; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
132 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
133 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
134 public SpecializationData getInsertBefore() { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
135 return insertBefore; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
136 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
137 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
138 public String getInsertBeforeName() { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
139 return insertBeforeName; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
140 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
141 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
142 public Set<String> getContainsNames() { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
143 return containsNames; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
144 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
145 |
13528
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
146 public SpecializationData(NodeData node, TemplateMethod template, SpecializationKind kind) { |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
147 this(node, template, kind, new ArrayList<SpecializationThrowsData>()); |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
148 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
149 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
150 public Set<SpecializationData> getContains() { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
151 return contains; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
152 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
153 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
154 public Set<SpecializationData> getExcludedBy() { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
155 return excludedBy; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
156 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
157 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
158 public void setReachable(boolean reachable) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
159 this.reachable = reachable; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
160 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
161 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
162 public boolean isReachable() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
163 return reachable; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
164 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
165 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
166 public boolean isPolymorphic() { |
13528
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
167 return kind == SpecializationKind.POLYMORPHIC; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
168 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
169 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
170 @Override |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
171 protected List<MessageContainer> findChildContainers() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
172 List<MessageContainer> sinks = new ArrayList<>(); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
173 if (exceptions != null) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
174 sinks.addAll(exceptions); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
175 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
176 if (guards != null) { |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
177 sinks.addAll(guards); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
178 } |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
179 if (caches != null) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
180 sinks.addAll(caches); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
181 } |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
19289
diff
changeset
|
182 if (assumptionExpressions != null) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
19289
diff
changeset
|
183 sinks.addAll(assumptionExpressions); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
19289
diff
changeset
|
184 } |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
185 return sinks; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
186 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
187 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
188 public boolean hasRewrite(ProcessorContext context) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
189 if (!getExceptions().isEmpty()) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
190 return true; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
191 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
192 if (!getGuards().isEmpty()) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
193 return true; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
194 } |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
19289
diff
changeset
|
195 if (!getAssumptionExpressions().isEmpty()) { |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
196 return true; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
197 } |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
198 |
16759
23415229349b
Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents:
16755
diff
changeset
|
199 for (Parameter parameter : getSignatureParameters()) { |
18775
a069a87b9a02
Truffle-DSL: Added tests and verification of overridable generic execute methods.
Christian Humer <christian.humer@gmail.com>
parents:
18761
diff
changeset
|
200 NodeChildData child = parameter.getSpecification().getExecution().getChild(); |
20938
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
201 if (child != null) { |
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
202 ExecutableTypeData type = child.findExecutableType(parameter.getType()); |
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
203 if (type == null) { |
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
204 type = child.findAnyGenericExecutableType(context); |
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
205 } |
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
206 if (type.hasUnexpectedValue(context)) { |
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
207 return true; |
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
208 } |
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
209 if (ElementUtils.needsCastTo(type.getReturnType(), parameter.getType())) { |
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
210 return true; |
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
211 } |
18775
a069a87b9a02
Truffle-DSL: Added tests and verification of overridable generic execute methods.
Christian Humer <christian.humer@gmail.com>
parents:
18761
diff
changeset
|
212 } |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
213 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
214 return false; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
215 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
216 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
217 @Override |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
218 public int compareTo(TemplateMethod other) { |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
219 if (this == other) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
220 return 0; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
221 } else if (!(other instanceof SpecializationData)) { |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
222 return super.compareTo(other); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
223 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
224 SpecializationData m2 = (SpecializationData) other; |
13528
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
225 int kindOrder = kind.compareTo(m2.kind); |
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
226 if (kindOrder != 0) { |
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
227 return kindOrder; |
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
228 } |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
229 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
230 int compare = 0; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
231 int order1 = index; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
232 int order2 = m2.index; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
233 if (order1 != NO_NATURAL_ORDER && order2 != NO_NATURAL_ORDER) { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
234 compare = Integer.compare(order1, order2); |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
235 if (compare != 0) { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
236 return compare; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
237 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
238 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
239 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
240 return super.compareTo(other); |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
241 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
242 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
243 public void setIndex(int order) { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
244 this.index = order; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
245 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
246 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
247 public int getIndex() { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
248 return index; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
249 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
250 |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
251 public NodeData getNode() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
252 return node; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
253 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
254 |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
255 public void setGuards(List<GuardExpression> guards) { |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
256 this.guards = guards; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
257 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
258 |
12395
8e8347ecabbc
Truffle-DSL: implemented new polymorphic more compact generation strategy
Christian Humer <christian.humer@gmail.com>
parents:
11438
diff
changeset
|
259 public boolean isSpecialized() { |
13528
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
260 return kind == SpecializationKind.SPECIALIZED; |
12395
8e8347ecabbc
Truffle-DSL: implemented new polymorphic more compact generation strategy
Christian Humer <christian.humer@gmail.com>
parents:
11438
diff
changeset
|
261 } |
8e8347ecabbc
Truffle-DSL: implemented new polymorphic more compact generation strategy
Christian Humer <christian.humer@gmail.com>
parents:
11438
diff
changeset
|
262 |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
17251
diff
changeset
|
263 public boolean isFallback() { |
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
17251
diff
changeset
|
264 return kind == SpecializationKind.FALLBACK; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
265 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
266 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
267 public boolean isUninitialized() { |
13528
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
268 return kind == SpecializationKind.UNINITIALIZED; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
269 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
270 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
271 public List<SpecializationThrowsData> getExceptions() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
272 return exceptions; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
273 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
274 |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
275 public List<GuardExpression> getGuards() { |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
276 return guards; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
277 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
278 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
279 public void setShortCircuits(List<ShortCircuitData> shortCircuits) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
280 this.shortCircuits = shortCircuits; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
281 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
282 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
283 public List<ShortCircuitData> getShortCircuits() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
284 return shortCircuits; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
285 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
286 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
287 public SpecializationData findNextSpecialization() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
288 List<SpecializationData> specializations = node.getSpecializations(); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
289 for (int i = 0; i < specializations.size() - 1; i++) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
290 if (specializations.get(i) == this) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
291 return specializations.get(i + 1); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
292 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
293 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
294 return null; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
295 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
296 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
297 @Override |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
298 public String toString() { |
20984
6361fa2e3321
Truffle-DSL: further fixes for polymorphic execute signatures.
Christian Humer <christian.humer@oracle.com>
parents:
20940
diff
changeset
|
299 return String.format("%s [id = %s, method = %s, guards = %s, signature = %s]", getClass().getSimpleName(), getId(), getMethod(), getGuards(), getDynamicTypes()); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
300 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
301 |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
302 public boolean isFrameUsed() { |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
303 return getFrame() != null; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
304 } |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
305 |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
306 public List<CacheExpression> getCaches() { |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
307 return caches; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
308 } |
17251
6ee7afea175a
Truffle-DSL: Fixed @SlowPath was not applied to certain specialize0 implementations. This will reduce the pressure on the truffle cache.
Christian Humer <christian.humer@gmail.com>
parents:
16765
diff
changeset
|
309 |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
310 public void setCaches(List<CacheExpression> caches) { |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
311 this.caches = caches; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
312 } |
17251
6ee7afea175a
Truffle-DSL: Fixed @SlowPath was not applied to certain specialize0 implementations. This will reduce the pressure on the truffle cache.
Christian Humer <christian.humer@gmail.com>
parents:
16765
diff
changeset
|
313 |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
314 public void setAssumptionExpressions(List<AssumptionExpression> assumptionExpressions) { |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
315 this.assumptionExpressions = assumptionExpressions; |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
316 } |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
317 |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
318 public List<AssumptionExpression> getAssumptionExpressions() { |
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
319 return assumptionExpressions; |
12399
980db6c0bcd3
Truffle-DSL: fixed invalid @SlowPath on generic execute methods. (GRAAL-490 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
12395
diff
changeset
|
320 } |
13527
25ecb47a6d0e
Truffle-DSL: Added support for references to child arrays in @ShortCircuit;
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
321 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
322 public boolean hasMultipleInstances() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
323 if (!getCaches().isEmpty()) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
324 for (GuardExpression guard : getGuards()) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
325 DSLExpression guardExpression = guard.getExpression(); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
326 Set<VariableElement> boundVariables = guardExpression.findBoundVariableElements(); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
327 if (isDynamicParameterBound(guardExpression)) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
328 for (CacheExpression cache : getCaches()) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
329 if (boundVariables.contains(cache.getParameter().getVariableElement())) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
330 return true; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
331 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
332 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
333 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
334 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
335 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
336 return false; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
337 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
338 |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
339 public boolean isReachableAfter(SpecializationData prev) { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
340 if (!prev.isSpecialized()) { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
341 return true; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
342 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
343 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
344 if (!prev.getExceptions().isEmpty()) { |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
345 // may get excluded by exception |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
346 return true; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
347 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
348 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
349 if (hasMultipleInstances()) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
350 // may fallthrough due to limit |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
351 return true; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
352 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
353 |
16759
23415229349b
Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents:
16755
diff
changeset
|
354 Iterator<Parameter> currentSignature = getSignatureParameters().iterator(); |
23415229349b
Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents:
16755
diff
changeset
|
355 Iterator<Parameter> prevSignature = prev.getSignatureParameters().iterator(); |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
356 |
20938
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
357 TypeSystemData typeSystem = prev.getNode().getTypeSystem(); |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
358 while (currentSignature.hasNext() && prevSignature.hasNext()) { |
20938
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
359 TypeMirror currentType = currentSignature.next().getType(); |
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
360 TypeMirror prevType = prevSignature.next().getType(); |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
361 |
20938
18c0f02fa4d2
Truffle-DSL: make type systems optional.
Christian Humer <christian.humer@gmail.com>
parents:
19293
diff
changeset
|
362 if (!typeSystem.isImplicitSubtypeOf(currentType, prevType)) { |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
363 return true; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
364 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
365 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
366 |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
19289
diff
changeset
|
367 if (!prev.getAssumptionExpressions().isEmpty()) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
19289
diff
changeset
|
368 // TODO: chumer: we could at least check reachability after trivial assumptions |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
19289
diff
changeset
|
369 // not sure if this is worth it. |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
19289
diff
changeset
|
370 return true; |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
371 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
372 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
373 Iterator<GuardExpression> prevGuards = prev.getGuards().iterator(); |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
374 Iterator<GuardExpression> currentGuards = getGuards().iterator(); |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
375 while (prevGuards.hasNext()) { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
376 GuardExpression prevGuard = prevGuards.next(); |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
377 GuardExpression currentGuard = currentGuards.hasNext() ? currentGuards.next() : null; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
378 if (currentGuard == null || !currentGuard.implies(prevGuard)) { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
379 return true; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
380 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
381 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
382 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
383 return false; |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
14908
diff
changeset
|
384 } |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
385 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
386 public CacheExpression findCache(Parameter resolvedParameter) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
387 for (CacheExpression cache : getCaches()) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
388 if (cache.getParameter() == resolvedParameter) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
389 return cache; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
390 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
391 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
392 return null; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
393 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
394 |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
395 } |