annotate graal/com.oracle.truffle.api.codegen.test/src/com/oracle/truffle/api/codegen/test/TypeSystemTest.java @ 9785:ecd5cd2806e8

Relax assertion for virtual array component kind.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 22 May 2013 14:07:57 +0200
parents e162d9e32830
children 72e6b178de16
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8249
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
1 /*
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
8249
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
4 *
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
8 *
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
13 * accompanied this code).
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
14 *
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
18 *
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
21 * questions.
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
22 */
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
23 package com.oracle.truffle.api.codegen.test;
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
24
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
25 import com.oracle.truffle.api.*;
8249
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
26 import com.oracle.truffle.api.codegen.*;
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
27 import com.oracle.truffle.api.codegen.test.BuiltinTest.Str;
8249
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
28 import com.oracle.truffle.api.frame.*;
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
29 import com.oracle.truffle.api.nodes.*;
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
30
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
31 public class TypeSystemTest {
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
32
9223
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
33 @TypeSystem({int.class, Str.class, CallTarget.class, Object[].class})
8249
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
34 static class SimpleTypes {
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
35 }
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
36
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
37 @TypeSystemReference(SimpleTypes.class)
9223
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
38 public abstract static class ValueNode extends Node {
8249
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
39
9223
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
40 public int executeInt(VirtualFrame frame) throws UnexpectedResultException {
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
41 return SimpleTypesGen.SIMPLETYPES.expectInteger(execute(frame));
8249
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
42 }
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
43
9223
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
44 public Str executeStr(VirtualFrame frame) throws UnexpectedResultException {
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
45 return SimpleTypesGen.SIMPLETYPES.expectStr(execute(frame));
8249
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
46 }
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
47
9223
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
48 public Object[] executeIntArray(VirtualFrame frame) throws UnexpectedResultException {
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
49 return SimpleTypesGen.SIMPLETYPES.expectObjectArray(execute(frame));
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
50 }
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
51
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
52 public abstract Object execute(VirtualFrame frame);
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
53
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
54 @Override
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
55 public ValueNode copy() {
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
56 return (ValueNode) super.copy();
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
57 }
8249
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
58 }
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
59
9223
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
60 @NodeChild(value = "children", type = ValueNode[].class)
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
61 public abstract static class ChildrenNode extends ValueNode {
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
62
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
63 }
8249
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
64
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
65 @TypeSystemReference(SimpleTypes.class)
9223
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
66 public static class TestRootNode<E extends ValueNode> extends RootNode {
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
67
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
68 @Child private E node;
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
69
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
70 public TestRootNode(E node) {
8249
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
71 this.node = adoptChild(node);
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
72 }
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
73
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
74 @Override
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
75 public Object execute(VirtualFrame frame) {
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
76 return node.execute(frame);
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
77 }
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
78
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
79 public E getNode() {
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
80 return node;
8249
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
81 }
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
82 }
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
83
9223
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
84 public static class TestArguments extends Arguments {
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
85
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
86 private final Object[] values;
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
87
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
88 public TestArguments(Object... values) {
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
89 this.values = values;
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
90 }
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
91
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
92 public Object[] getValues() {
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
93 return values;
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
94 }
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
95
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
96 public Object get(int index) {
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
97 return values[index];
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
98 }
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
99
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
100 }
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
101
9223
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
102 public static class ArgumentNode extends ValueNode {
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
103
9287
8e3a1635cc9e Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents: 9223
diff changeset
104 private int invocationCount;
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
105 final int index;
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
106
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
107 public ArgumentNode(int index) {
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
108 this.index = index;
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
109 }
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
110
9287
8e3a1635cc9e Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents: 9223
diff changeset
111 public int getInvocationCount() {
8e3a1635cc9e Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents: 9223
diff changeset
112 return invocationCount;
8e3a1635cc9e Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents: 9223
diff changeset
113 }
8e3a1635cc9e Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents: 9223
diff changeset
114
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
115 @Override
9223
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents: 8596
diff changeset
116 public Object execute(VirtualFrame frame) {
9287
8e3a1635cc9e Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents: 9223
diff changeset
117 invocationCount++;
9330
e162d9e32830 Added a clazz parameter to Frame.getArguments in order to allow unsafe access to the arguments object (i.e., avoiding the null check and the type cast).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9287
diff changeset
118 return frame.getArguments(TestArguments.class).get(index);
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
119 }
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
120
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
121 }
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
122
8249
aad7e9f4f71c A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
123 }