Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemTest.java @ 20934:033dd4494705
Fix compare in LoweringPhase.processBlock
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Tue, 14 Apr 2015 17:23:37 +0200 |
parents | 9ca538e3e46e |
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, 2013, 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 |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
25 import java.math.*; |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
26 |
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
|
27 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
|
28 import com.oracle.truffle.api.dsl.*; |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
29 import com.oracle.truffle.api.dsl.internal.*; |
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.api.frame.*; |
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 import com.oracle.truffle.api.nodes.*; |
16967
c5db657d93c1
Truffle-DSL: added test for source sections in @CreateCast methods.
Christian Humer <christian.humer@gmail.com>
parents:
16830
diff
changeset
|
32 import com.oracle.truffle.api.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
|
33 |
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
|
34 public class TypeSystemTest { |
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 |
20171
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
18785
diff
changeset
|
36 @TypeSystem({byte.class, short.class, int.class, long.class, double.class, boolean.class, BigInteger.class, String.class, CallTarget.class, BExtendsAbstract.class, CExtendsAbstract.class, |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
18785
diff
changeset
|
37 Abstract.class, Interface.class, Object[].class}) |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
38 @DSLOptions(useNewLayout = true) |
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
|
39 static class SimpleTypes { |
11195
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
40 |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
41 static int intCheck; |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
42 static int intCast; |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
43 |
18782
3ea386a1036f
Truffle-DSL: breaking: @TypeCheck and @TypeCast now require casted/checked type as explicit parameter. Previously the type was parsed from the method name. (GRAAL-446 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18758
diff
changeset
|
44 @TypeCheck(int.class) |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
45 public static boolean isInteger(Object value) { |
11195
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
46 intCheck++; |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
47 return value instanceof Integer; |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
48 } |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
49 |
18782
3ea386a1036f
Truffle-DSL: breaking: @TypeCheck and @TypeCast now require casted/checked type as explicit parameter. Previously the type was parsed from the method name. (GRAAL-446 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18758
diff
changeset
|
50 @TypeCast(int.class) |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
51 public static int asInteger(Object value) { |
11195
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
52 intCast++; |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
53 return (int) value; |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
54 } |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
55 |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
56 @ImplicitCast |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
57 public static double castDouble(int value) { |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
58 return value; |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
59 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
60 |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
61 @ImplicitCast |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
62 public static long castLong(int value) { |
18221
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
16967
diff
changeset
|
63 return value; |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
16967
diff
changeset
|
64 } |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
16967
diff
changeset
|
65 |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
16967
diff
changeset
|
66 @ImplicitCast |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
67 public static BigInteger castBigInteger(int value) { |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
68 return BigInteger.valueOf(value); |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
69 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
70 |
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 } |
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
|
72 |
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
|
73 @TypeSystemReference(SimpleTypes.class) |
18755
59953a46c56f
Truffle-DSL: migrate DSL tests to use @GenerateNodeFactory.
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
74 @GenerateNodeFactory |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
75 public static class ValueNode extends Node { |
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
|
76 |
11903
df1d665ca846
Truffle; remove uses of Node() constructor in test code
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11545
diff
changeset
|
77 public ValueNode() { |
df1d665ca846
Truffle; remove uses of Node() constructor in test code
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11545
diff
changeset
|
78 super(null); |
df1d665ca846
Truffle; remove uses of Node() constructor in test code
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11545
diff
changeset
|
79 } |
df1d665ca846
Truffle; remove uses of Node() constructor in test code
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11545
diff
changeset
|
80 |
16967
c5db657d93c1
Truffle-DSL: added test for source sections in @CreateCast methods.
Christian Humer <christian.humer@gmail.com>
parents:
16830
diff
changeset
|
81 public ValueNode(SourceSection sourceSection) { |
c5db657d93c1
Truffle-DSL: added test for source sections in @CreateCast methods.
Christian Humer <christian.humer@gmail.com>
parents:
16830
diff
changeset
|
82 super(sourceSection); |
c5db657d93c1
Truffle-DSL: added test for source sections in @CreateCast methods.
Christian Humer <christian.humer@gmail.com>
parents:
16830
diff
changeset
|
83 } |
c5db657d93c1
Truffle-DSL: added test for source sections in @CreateCast methods.
Christian Humer <christian.humer@gmail.com>
parents:
16830
diff
changeset
|
84 |
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
|
85 public int executeInt(VirtualFrame frame) throws UnexpectedResultException { |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
86 return SimpleTypesGen.expectInteger(execute(frame)); |
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
|
87 } |
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
|
88 |
18221
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
16967
diff
changeset
|
89 public long executeLong(VirtualFrame frame) throws UnexpectedResultException { |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
90 return SimpleTypesGen.expectLong(execute(frame)); |
18221
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
16967
diff
changeset
|
91 } |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
16967
diff
changeset
|
92 |
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
|
93 public String executeString(VirtualFrame frame) throws UnexpectedResultException { |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
94 return SimpleTypesGen.expectString(execute(frame)); |
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
|
95 } |
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
|
96 |
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
|
97 public boolean executeBoolean(VirtualFrame frame) throws UnexpectedResultException { |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
98 return SimpleTypesGen.expectBoolean(execute(frame)); |
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
|
99 } |
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
|
100 |
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
|
101 public Object[] executeIntArray(VirtualFrame frame) throws UnexpectedResultException { |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
102 return SimpleTypesGen.expectObjectArray(execute(frame)); |
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
|
103 } |
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
|
104 |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
105 public BigInteger executeBigInteger(VirtualFrame frame) throws UnexpectedResultException { |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
106 return SimpleTypesGen.expectBigInteger(execute(frame)); |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
107 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
108 |
11507
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
109 public BExtendsAbstract executeBExtendsAbstract(VirtualFrame frame) throws UnexpectedResultException { |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
110 return SimpleTypesGen.expectBExtendsAbstract(execute(frame)); |
11507
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
111 } |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
112 |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
113 public CExtendsAbstract executeCExtendsAbstract(VirtualFrame frame) throws UnexpectedResultException { |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
114 return SimpleTypesGen.expectCExtendsAbstract(execute(frame)); |
11507
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
115 } |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
116 |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
117 public Abstract executeAbstract(VirtualFrame frame) throws UnexpectedResultException { |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
118 return SimpleTypesGen.expectAbstract(execute(frame)); |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
119 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
120 |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
121 public double executeDouble(VirtualFrame frame) throws UnexpectedResultException { |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
122 return SimpleTypesGen.expectDouble(execute(frame)); |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
123 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
124 |
16830
c3c07046a74b
Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents:
16756
diff
changeset
|
125 public Interface executeInterface(VirtualFrame frame) throws UnexpectedResultException { |
18758
3912400fc33a
Truffle-DSL: remove type system singleton
Christian Humer <christian.humer@gmail.com>
parents:
18755
diff
changeset
|
126 return SimpleTypesGen.expectInterface(execute(frame)); |
16830
c3c07046a74b
Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents:
16756
diff
changeset
|
127 } |
c3c07046a74b
Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents:
16756
diff
changeset
|
128 |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
129 public Object execute(@SuppressWarnings("unused") VirtualFrame frame) { |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
130 throw new UnsupportedOperationException(); |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
131 } |
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
|
132 |
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 @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
|
134 public ValueNode copy() { |
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
|
135 return (ValueNode) super.copy(); |
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
|
136 } |
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
|
137 } |
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
|
138 |
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 @NodeChild(value = "children", type = ValueNode[].class) |
18755
59953a46c56f
Truffle-DSL: migrate DSL tests to use @GenerateNodeFactory.
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
140 @GenerateNodeFactory |
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
|
141 public abstract static class ChildrenNode extends 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
|
142 |
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
|
143 } |
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
|
144 |
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
|
145 @TypeSystemReference(SimpleTypes.class) |
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
|
146 public static class TestRootNode<E extends ValueNode> extends RootNode { |
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
|
147 |
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
|
148 @Child private E 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
|
149 |
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
|
150 public TestRootNode(E node) { |
11905
b563d9cb084f
Truffle: clean out one more use of the RootNode() constructor in test code
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
11903
diff
changeset
|
151 super(null); |
14628
a08b8694f556
Truffle: Node API changes
Andreas Woess <andreas.woess@jku.at>
parents:
13528
diff
changeset
|
152 this.node = node; |
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
|
153 } |
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
|
154 |
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
|
155 @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
|
156 public Object execute(VirtualFrame frame) { |
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 return node.execute(frame); |
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 } |
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 |
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 public E 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
|
161 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
|
162 } |
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 } |
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 public static class ArgumentNode extends 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
|
166 |
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
|
167 private int invocationCount; |
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 final int index; |
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 public ArgumentNode(int index) { |
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 this.index = index; |
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 } |
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 |
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 public int getInvocationCount() { |
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 return invocationCount; |
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 } |
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
|
177 |
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 @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
|
179 public Object execute(VirtualFrame frame) { |
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
|
180 invocationCount++; |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14628
diff
changeset
|
181 return frame.getArguments()[index]; |
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
|
182 } |
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
|
183 |
11195
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
184 @Override |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
185 public int executeInt(VirtualFrame frame) throws UnexpectedResultException { |
18785
93016f2f3f16
Truffle-DSL: optimize generated code for nodes with a single specialization. (GRAAL-602 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18782
diff
changeset
|
186 invocationCount++; |
11195
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
187 // avoid casts for some tests |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14628
diff
changeset
|
188 Object o = frame.getArguments()[index]; |
11195
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
189 if (o instanceof Integer) { |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
190 return (int) o; |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
191 } |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
192 throw new UnexpectedResultException(o); |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
193 } |
4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
194 |
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
|
195 } |
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 |
11507
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
197 abstract static class Abstract { |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
198 } |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
199 |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
200 static final class BExtendsAbstract extends Abstract { |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
201 |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
202 static final BExtendsAbstract INSTANCE = new BExtendsAbstract(); |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
203 |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
204 } |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
205 |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
206 static final class CExtendsAbstract extends Abstract { |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
207 |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
208 static final CExtendsAbstract INSTANCE = new CExtendsAbstract(); |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
209 } |
d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
Christian Humer <christian.humer@gmail.com>
parents:
11195
diff
changeset
|
210 |
16830
c3c07046a74b
Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents:
16756
diff
changeset
|
211 interface Interface { |
c3c07046a74b
Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents:
16756
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 } |