Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AssumptionsTest.java @ 19468:6709f8086756
eclipseformat
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Tue, 17 Feb 2015 21:44:55 +0100 |
parents | f4792a544170 |
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 */ |
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
|
23 package com.oracle.truffle.api.dsl.test; |
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 |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
25 import static com.oracle.truffle.api.dsl.test.TestHelper.*; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
26 import static org.junit.Assert.*; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
27 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
28 import java.util.*; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
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 org.junit.*; |
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
|
31 |
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
|
32 import com.oracle.truffle.api.*; |
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 import com.oracle.truffle.api.dsl.*; |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
34 import com.oracle.truffle.api.dsl.test.AssumptionsTestFactory.AssumptionArrayTestFactory; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
35 import com.oracle.truffle.api.dsl.test.AssumptionsTestFactory.CacheAssumptionTestFactory; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
36 import com.oracle.truffle.api.dsl.test.AssumptionsTestFactory.FieldTestFactory; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
37 import com.oracle.truffle.api.dsl.test.AssumptionsTestFactory.MethodTestFactory; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
38 import com.oracle.truffle.api.dsl.test.AssumptionsTestFactory.NodeFieldTest2Factory; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
39 import com.oracle.truffle.api.dsl.test.AssumptionsTestFactory.StaticFieldTestFactory; |
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
|
40 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; |
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
|
41 |
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
|
42 public class AssumptionsTest { |
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
|
43 |
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
|
44 @Test |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
45 public void testField() { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
46 CallTarget root = createCallTarget(FieldTestFactory.getInstance()); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
47 FieldTest node = getNode(root); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
48 assertEquals(42, root.call(42)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
49 assertEquals(42, root.call(42)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
50 node.field.invalidate(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
51 try { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
52 root.call(45); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
53 fail(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
54 } catch (UnsupportedSpecializationException e) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
55 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
56 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
57 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
58 @NodeChild |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
59 static class FieldTest extends ValueNode { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
60 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
61 protected final Assumption field = Truffle.getRuntime().createAssumption(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
62 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
63 @Specialization(assumptions = "field") |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
64 static int do1(int value) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
65 return value; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
66 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
67 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
68 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
69 @Test |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
70 public void testNodeField() { |
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
|
71 Assumption assumption = Truffle.getRuntime().createAssumption(); |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
72 CallTarget root = createCallTarget(NodeFieldTest2Factory.getInstance(), assumption); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
73 assertEquals(42, root.call(42)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
74 assertEquals(42, root.call(42)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
75 assumption.invalidate(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
76 try { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
77 root.call(45); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
78 fail(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
79 } catch (UnsupportedSpecializationException e) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
80 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
81 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
82 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
83 @NodeChild |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
84 @NodeField(name = "field", type = Assumption.class) |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
85 static class NodeFieldTest2 extends ValueNode { |
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
|
86 |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
87 @Specialization(assumptions = "field") |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
88 static int do1(int value) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
89 return value; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
90 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
91 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
92 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
93 @Test |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
94 public void testStaticField() { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
95 CallTarget root = createCallTarget(StaticFieldTestFactory.getInstance()); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
96 assertEquals(42, root.call(42)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
97 assertEquals(42, root.call(42)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
98 StaticFieldTest.FIELD.invalidate(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
99 try { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
100 root.call(45); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
101 fail(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
102 } catch (UnsupportedSpecializationException e) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
103 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
104 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
105 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
106 @NodeChild |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
107 static class StaticFieldTest extends ValueNode { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
108 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
109 static final Assumption FIELD = Truffle.getRuntime().createAssumption(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
110 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
111 @Specialization(assumptions = "FIELD") |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
112 static int do1(int value) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
113 return value; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
114 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
115 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
116 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
117 @Test |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
118 public void testMethod() { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
119 CallTarget root = createCallTarget(MethodTestFactory.getInstance()); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
120 MethodTest node = getNode(root); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
121 assertEquals(42, root.call(42)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
122 assertEquals(42, root.call(42)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
123 node.hiddenAssumption.invalidate(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
124 try { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
125 root.call(45); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
126 fail(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
127 } catch (UnsupportedSpecializationException e) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
128 } |
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
|
129 } |
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
|
130 |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
131 @NodeChild |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
132 static class MethodTest extends ValueNode { |
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
|
133 |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
134 private final Assumption hiddenAssumption = Truffle.getRuntime().createAssumption(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
135 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
136 @Specialization(assumptions = "getAssumption()") |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
137 static int do1(int value) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
138 return value; |
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
|
139 } |
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
|
140 |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
141 Assumption getAssumption() { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
142 return hiddenAssumption; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
143 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
144 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
145 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
146 @Test |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
147 public void testCacheAssumption() { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
148 CallTarget root = createCallTarget(CacheAssumptionTestFactory.getInstance()); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
149 CacheAssumptionTest node = getNode(root); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
150 assertEquals("do1", root.call(42)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
151 assertEquals("do1", root.call(43)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
152 assertEquals("do1", root.call(44)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
153 node.assumptions.get(42).invalidate(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
154 node.assumptions.put(42, null); // clear 42 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
155 node.assumptions.get(43).invalidate(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
156 node.assumptions.get(44).invalidate(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
157 assertEquals("do1", root.call(42)); // recreates 42 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
158 assertEquals("do2", root.call(43)); // invalid 43 -> remove -> insert do2 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
159 assertEquals("do2", root.call(46)); // no more lines can be created. |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
160 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
161 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
162 @Test |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
163 public void testCacheAssumptionLimit() { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
164 CallTarget root = createCallTarget(CacheAssumptionTestFactory.getInstance()); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
165 assertEquals("do1", root.call(42)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
166 assertEquals("do1", root.call(43)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
167 assertEquals("do1", root.call(44)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
168 assertEquals("do2", root.call(45)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
169 assertEquals("do1", root.call(43)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
170 assertEquals("do1", root.call(44)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
171 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
172 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
173 @NodeChild |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
174 @SuppressWarnings("unused") |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
175 static class CacheAssumptionTest extends ValueNode { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
176 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
177 private final Map<Integer, Assumption> assumptions = new HashMap<>(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
178 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
179 @Specialization(guards = "value == cachedValue", assumptions = "getAssumption(cachedValue)") |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
180 static String do1(int value, @Cached("value") int cachedValue) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
181 return "do1"; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
182 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
183 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
184 @Specialization |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
185 static String do2(int value) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
186 return "do2"; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
187 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
188 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
189 Assumption getAssumption(int value) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
190 Assumption assumption = assumptions.get(value); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
191 if (assumption == null) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
192 assumption = Truffle.getRuntime().createAssumption(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
193 assumptions.put(value, assumption); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
194 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
195 return assumption; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
196 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
197 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
198 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
199 @Test |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
200 public void testAssumptionArrays() { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
201 CallTarget root = createCallTarget(AssumptionArrayTestFactory.getInstance()); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
202 AssumptionArrayTest node = getNode(root); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
203 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
204 Assumption a1 = Truffle.getRuntime().createAssumption(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
205 Assumption a2 = Truffle.getRuntime().createAssumption(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
206 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
207 node.assumptions = new Assumption[]{a1, a2}; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
208 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
209 assertEquals("do1", root.call(42)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
210 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
211 a2.invalidate(); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
212 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
213 assertEquals("do2", root.call(42)); |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
214 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
215 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
216 @NodeChild |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
217 @SuppressWarnings("unused") |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
218 static class AssumptionArrayTest extends ValueNode { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
219 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
220 Assumption[] assumptions; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
221 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
222 @Specialization(assumptions = "assumptions") |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
223 static String do1(int value) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
224 return "do1"; |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
225 } |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
226 |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
227 @Specialization |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
228 static String do2(int value) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
229 return "do2"; |
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
|
230 } |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
231 |
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
|
232 } |
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
|
233 |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
234 @NodeChild |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
235 static class ErrorIncompatibleReturnType extends ValueNode { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
236 @ExpectError("Incompatible return type int. Assumptions must be assignable to Assumption or Assumption[].") |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
237 @Specialization(assumptions = "3") |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
238 static int do1(int value) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
239 return value; |
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
|
240 } |
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
|
241 } |
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
|
242 |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
243 @NodeChild |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
244 static class ErrorBoundDynamicValue extends ValueNode { |
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
|
245 |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
246 @ExpectError("Assumption expressions must not bind dynamic parameter values.") |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
247 @Specialization(assumptions = "createAssumption(value)") |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
248 static int do1(int value) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
249 return value; |
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
|
250 } |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
251 |
19291
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
252 Assumption createAssumption(int value) { |
f4792a544170
Truffle-DSL: implement new assumptions semantics.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
253 return Truffle.getRuntime().createAssumption(String.valueOf(value)); |
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
|
254 } |
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
|
255 } |
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 |
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 } |