annotate graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/InstanceOfTest.java @ 11590:797b5ea46a90

Merge
author Mick Jordan <mick.jordan@oracle.com>
date Sat, 07 Sep 2013 12:23:40 -0700
parents 963a090eb1d8
children 6f2435671a70
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
8944
e7766460ddb3 Move tests into *.test packages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8416
diff changeset
23 package com.oracle.graal.replacements.test;
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25 import java.util.*;
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
27 import com.oracle.graal.api.code.CompilationResult.Call;
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
28 import com.oracle.graal.api.code.CompilationResult.Mark;
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
29 import com.oracle.graal.api.code.CompilationResult.Site;
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5439
diff changeset
30 import com.oracle.graal.api.meta.*;
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.nodes.*;
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.nodes.java.*;
6647
0b8410de1365 removed targetClassInstruction from InstanceOfNode
Doug Simon <doug.simon@oracle.com>
parents: 6583
diff changeset
33 import com.oracle.graal.phases.common.*;
8954
Doug Simon <doug.simon@oracle.com>
parents: 8951 8944
diff changeset
34 import com.oracle.graal.replacements.test.CheckCastTest.Depth12;
Doug Simon <doug.simon@oracle.com>
parents: 8951 8944
diff changeset
35 import com.oracle.graal.replacements.test.CheckCastTest.Depth13;
Doug Simon <doug.simon@oracle.com>
parents: 8951 8944
diff changeset
36 import com.oracle.graal.replacements.test.CheckCastTest.Depth14;
8951
0dc36e1d813e extra InstanceOf tests
Doug Simon <doug.simon@oracle.com>
parents: 8416
diff changeset
37 import com.oracle.graal.test.*;
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
40 * Tests the implementation of instanceof, allowing profiling information to be manually specified.
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 */
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42 public class InstanceOfTest extends TypeCheckTest {
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43
10935
2da7f2efe6e2 Move inlining phases to HighTier.
Roland Schatz <roland.schatz@oracle.com>
parents: 10513
diff changeset
44 public InstanceOfTest() {
2da7f2efe6e2 Move inlining phases to HighTier.
Roland Schatz <roland.schatz@oracle.com>
parents: 10513
diff changeset
45 suites.getHighTier().findPhase(AbstractInliningPhase.class).remove();
2da7f2efe6e2 Move inlining phases to HighTier.
Roland Schatz <roland.schatz@oracle.com>
parents: 10513
diff changeset
46 }
2da7f2efe6e2 Move inlining phases to HighTier.
Roland Schatz <roland.schatz@oracle.com>
parents: 10513
diff changeset
47
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 @Override
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
49 protected void replaceProfile(StructuredGraph graph, JavaTypeProfile profile) {
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 InstanceOfNode ion = graph.getNodes().filter(InstanceOfNode.class).first();
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51 if (ion != null) {
6647
0b8410de1365 removed targetClassInstruction from InstanceOfNode
Doug Simon <doug.simon@oracle.com>
parents: 6583
diff changeset
52 InstanceOfNode ionNew = graph.add(new InstanceOfNode(ion.type(), ion.object(), profile));
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
53 graph.replaceFloating(ion, ionNew);
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
54 }
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
55 }
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
56
8341
c38d2870439e unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 7814
diff changeset
57 @LongTest
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
58 public void test1() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
59 test("isString", profile(), "object");
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
60 test("isString", profile(String.class), "object");
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
62 test("isString", profile(), Object.class);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
63 test("isString", profile(String.class), Object.class);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
64 }
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65
8341
c38d2870439e unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 7814
diff changeset
66 @LongTest
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
67 public void test2() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
68 test("isStringInt", profile(), "object");
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
69 test("isStringInt", profile(String.class), "object");
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
70
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
71 test("isStringInt", profile(), Object.class);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
72 test("isStringInt", profile(String.class), Object.class);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
73 }
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
74
8341
c38d2870439e unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 7814
diff changeset
75 @LongTest
10513
00b70a864d3b updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents: 8954
diff changeset
76 public void test201() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
77 test("isStringIntComplex", profile(), "object");
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
78 test("isStringIntComplex", profile(String.class), "object");
6302
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
79
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
80 test("isStringIntComplex", profile(), Object.class);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
81 test("isStringIntComplex", profile(String.class), Object.class);
6302
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
82 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
83
8341
c38d2870439e unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 7814
diff changeset
84 @LongTest
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
85 public void test3() {
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
86 Throwable throwable = new Exception();
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
87 test("isThrowable", profile(), throwable);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
88 test("isThrowable", profile(Throwable.class), throwable);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
89 test("isThrowable", profile(Exception.class, Error.class), throwable);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
90
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
91 test("isThrowable", profile(), Object.class);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
92 test("isThrowable", profile(Throwable.class), Object.class);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
93 test("isThrowable", profile(Exception.class, Error.class), Object.class);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
94 }
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
95
8341
c38d2870439e unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 7814
diff changeset
96 @LongTest
10513
00b70a864d3b updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents: 8954
diff changeset
97 public void test301() {
6302
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
98 onlyFirstIsException(new Exception(), new Error());
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
99 test("onlyFirstIsException", profile(), new Exception(), new Error());
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
100 test("onlyFirstIsException", profile(), new Error(), new Exception());
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
101 test("onlyFirstIsException", profile(), new Exception(), new Exception());
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
102 test("onlyFirstIsException", profile(), new Error(), new Error());
6302
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
103 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
104
8341
c38d2870439e unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 7814
diff changeset
105 @LongTest
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
106 public void test4() {
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
107 Throwable throwable = new Exception();
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
108 test("isThrowableInt", profile(), throwable);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
109 test("isThrowableInt", profile(Throwable.class), throwable);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
110 test("isThrowableInt", profile(Exception.class, Error.class), throwable);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
111
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
112 test("isThrowableInt", profile(), Object.class);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
113 test("isThrowableInt", profile(Throwable.class), Object.class);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
114 test("isThrowableInt", profile(Exception.class, Error.class), Object.class);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
115 }
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
116
8341
c38d2870439e unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 7814
diff changeset
117 @LongTest
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
118 public void test5() {
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
119 Map map = new HashMap<>();
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
120 test("isMap", profile(), map);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
121 test("isMap", profile(HashMap.class), map);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
122 test("isMap", profile(TreeMap.class, HashMap.class), map);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
123
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
124 test("isMap", profile(), Object.class);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
125 test("isMap", profile(HashMap.class), Object.class);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
126 test("isMap", profile(TreeMap.class, HashMap.class), Object.class);
8951
0dc36e1d813e extra InstanceOf tests
Doug Simon <doug.simon@oracle.com>
parents: 8416
diff changeset
127 test("isMap", profile(String.class, HashMap.class), Object.class);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
128 }
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
129
8341
c38d2870439e unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 7814
diff changeset
130 @LongTest
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
131 public void test6() {
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
132 Map map = new HashMap<>();
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
133 test("isMapInt", profile(), map);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
134 test("isMapInt", profile(HashMap.class), map);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
135 test("isMapInt", profile(TreeMap.class, HashMap.class), map);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
136
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
137 test("isMapInt", profile(), Object.class);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
138 test("isMapInt", profile(HashMap.class), Object.class);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
139 test("isMapInt", profile(TreeMap.class, HashMap.class), Object.class);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
140 }
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
141
8341
c38d2870439e unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 7814
diff changeset
142 @LongTest
6305
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
143 public void test7() {
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
144 Object o = new Depth13();
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
145 test("isDepth12", profile(), o);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
146 test("isDepth12", profile(Depth13.class), o);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
147 test("isDepth12", profile(Depth13.class, Depth14.class), o);
6305
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
148
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
149 o = "not a depth";
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
150 test("isDepth12", profile(), o);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
151 test("isDepth12", profile(Depth13.class), o);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
152 test("isDepth12", profile(Depth13.class, Depth14.class), o);
8951
0dc36e1d813e extra InstanceOf tests
Doug Simon <doug.simon@oracle.com>
parents: 8416
diff changeset
153 test("isDepth12", profile(String.class, HashMap.class), o);
6305
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
154 }
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
155
8341
c38d2870439e unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 7814
diff changeset
156 @LongTest
6305
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
157 public void test8() {
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
158 Object o = new Depth13();
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
159 test("isDepth12Int", profile(), o);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
160 test("isDepth12Int", profile(Depth13.class), o);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
161 test("isDepth12Int", profile(Depth13.class, Depth14.class), o);
6305
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
162
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
163 o = "not a depth";
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
164 test("isDepth12Int", profile(), o);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
165 test("isDepth12Int", profile(Depth13.class), o);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
166 test("isDepth12Int", profile(Depth13.class, Depth14.class), o);
6305
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
167 }
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
168
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
169 public static boolean isString(Object o) {
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
170 return o instanceof String;
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
171 }
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
172
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
173 public static int isStringInt(Object o) {
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
174 if (o instanceof String) {
6567
3bc7183309e0 improved InstanceOfTest.isStringInt()
Doug Simon <doug.simon@oracle.com>
parents: 6526
diff changeset
175 return id(1);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
176 }
6302
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
177 return id(0);
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
178 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
179
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
180 public static int isStringIntComplex(Object o) {
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
181 if (o instanceof String || o instanceof Integer) {
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
182 return id(o instanceof String ? 1 : 0);
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
183 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
184 return id(0);
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
185 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
186
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
187 public static int id(int value) {
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
188 return value;
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
189 }
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
190
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
191 public static boolean isThrowable(Object o) {
6302
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
192 return ((Throwable) o) instanceof Exception;
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
193 }
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
194
6302
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
195 public static int onlyFirstIsException(Throwable t1, Throwable t2) {
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
196 if (t1 instanceof Exception ^ t2 instanceof Exception) {
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
197 return t1 instanceof Exception ? 1 : -1;
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
198 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
199 return -1;
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
200 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5779
diff changeset
201
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
202 public static int isThrowableInt(Object o) {
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
203 int result = o instanceof Throwable ? 4 : 5;
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
204 if (o instanceof Throwable) {
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
205 return id(4);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
206 }
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
207 return result;
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
208 }
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
209
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
210 public static boolean isMap(Object o) {
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
211 return o instanceof Map;
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
212 }
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
213
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
214 public static int isMapInt(Object o) {
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
215 if (o instanceof Map) {
6579
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
216 return id(1);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
217 }
6579
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
218 return id(0);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
219 }
6305
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
220
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
221 public static boolean isDepth12(Object o) {
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
222 return o instanceof Depth12;
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
223 }
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
224
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
225 public static int isDepth12Int(Object o) {
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
226 if (o instanceof Depth12) {
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
227 return id(0);
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
228 }
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
229 return id(0);
94ed0ba0a1f2 added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents: 6302
diff changeset
230 }
6579
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
231
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
232 abstract static class MySite {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
233
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
234 final int offset;
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
235
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
236 MySite(int offset) {
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
237 this.offset = offset;
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
238 }
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
239 }
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
240
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
241 static class MyMark extends MySite {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
242
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
243 MyMark(int offset) {
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
244 super(offset);
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
245 }
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
246 }
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
247
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
248 abstract static class MySafepoint extends MySite {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
249
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
250 MySafepoint(int offset) {
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
251 super(offset);
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
252 }
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
253 }
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
254
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
255 static class MyCall extends MySafepoint {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
256
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
257 MyCall(int offset) {
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
258 super(offset);
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
259 }
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
260 }
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
261
8341
c38d2870439e unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 7814
diff changeset
262 @LongTest
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
263 public void test9() {
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
264 MyCall callAt63 = new MyCall(63);
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
265 MyMark markAt63 = new MyMark(63);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
266 test("compareMySites", callAt63, callAt63);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
267 test("compareMySites", callAt63, markAt63);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
268 test("compareMySites", markAt63, callAt63);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
269 test("compareMySites", markAt63, markAt63);
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
270 }
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
271
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
272 public static int compareMySites(MySite s1, MySite s2) {
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
273 if (s1.offset == s2.offset && (s1 instanceof MyMark ^ s2 instanceof MyMark)) {
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
274 return s1 instanceof MyMark ? -1 : 1;
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
275 }
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
276 return s1.offset - s2.offset;
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
277 }
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
278
8341
c38d2870439e unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 7814
diff changeset
279 @LongTest
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
280 public void test10() {
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
281 Mark[] noMarks = {};
7814
bab2a51f8dbe Introduce marker interface InvokeTarget. Remove method lookupRuntimeCall from CodeCacheProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
282 Call callAt63 = new Call(null, 63, 5, true, null);
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
283 Mark markAt63 = new Mark(63, "1", noMarks);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
284 test("compareSites", callAt63, callAt63);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
285 test("compareSites", callAt63, markAt63);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
286 test("compareSites", markAt63, callAt63);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
287 test("compareSites", markAt63, markAt63);
6660
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
288 }
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
289
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
290 public static int compareSites(Site s1, Site s2) {
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
291 if (s1.pcOffset == s2.pcOffset && (s1 instanceof Mark ^ s2 instanceof Mark)) {
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
292 return s1 instanceof Mark ? -1 : 1;
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
293 }
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
294 return s1.pcOffset - s2.pcOffset;
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
295 }
3f25ffc69fec added more tests to InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
296
6579
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
297 /**
6583
adb3879ffbe2 improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 6579
diff changeset
298 * This test exists to show the kind of pattern that is be optimizable by
adb3879ffbe2 improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents: 6579
diff changeset
299 * {@code removeIntermediateMaterialization()} in {@link IfNode}.
6579
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
300 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
301 * The test exists in this source file as the transformation was originally motivated by the
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
302 * need to remove use of special JumpNodes in the {@code InstanceOfSnippets}.
6579
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
303 */
8341
c38d2870439e unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 7814
diff changeset
304 @LongTest
10513
00b70a864d3b updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents: 8954
diff changeset
305 public void testRemoveIntermediateMaterialization() {
6579
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
306 List<String> list = Arrays.asList("1", "2", "3", "4");
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
307 test("removeIntermediateMaterialization", profile(), list, "2", "yes", "no");
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
308 test("removeIntermediateMaterialization", profile(), list, null, "yes", "no");
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
309 test("removeIntermediateMaterialization", profile(), null, "2", "yes", "no");
6579
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
310 }
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
311
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
312 public static String removeIntermediateMaterialization(List<Object> list, Object e, String a, String b) {
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
313 boolean test;
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
314 if (list == null || e == null) {
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
315 test = false;
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
316 } else {
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
317 test = false;
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
318 for (Object i : list) {
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
319 if (i.equals(e)) {
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
320 test = true;
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
321 break;
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
322 }
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
323 }
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
324 }
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
325 if (test) {
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
326 return a;
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
327 }
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
328 return b;
77fb2026fcbe added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents: 6567
diff changeset
329 }
7020
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
330
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
331 abstract static class A {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
332 }
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
333
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
334 static class B extends A {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
335 }
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
336
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
337 static class C extends B {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
338 }
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
339
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
340 abstract static class D extends C {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7028
diff changeset
341 }
7020
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
342
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
343 public static boolean isArrayOfA(Object o) {
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
344 return o instanceof A[];
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
345 }
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
346
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
347 public static boolean isArrayOfB(Object o) {
7028
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
348 return o instanceof B[];
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
349 }
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
350
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
351 public static boolean isArrayOfC(Object o) {
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
352 return o instanceof C[];
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
353 }
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
354
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
355 public static boolean isArrayOfD(Object o) {
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
356 return o instanceof D[];
7020
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
357 }
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
358
8341
c38d2870439e unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents: 7814
diff changeset
359 @LongTest
7020
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
360 public void testArray() {
7028
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
361 Object aArray = new A[10];
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
362 test("isArrayOfA", aArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
363
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
364 Object bArray = new B[10];
7020
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
365 test("isArrayOfA", aArray);
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
366 test("isArrayOfA", bArray);
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
367 test("isArrayOfB", aArray);
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
368 test("isArrayOfB", bArray);
7028
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
369
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
370 Object cArray = new C[10];
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
371 test("isArrayOfA", aArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
372 test("isArrayOfA", bArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
373 test("isArrayOfA", cArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
374 test("isArrayOfB", aArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
375 test("isArrayOfB", bArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
376 test("isArrayOfB", cArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
377 test("isArrayOfC", aArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
378 test("isArrayOfC", bArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
379 test("isArrayOfC", cArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
380
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
381 Object dArray = new D[10];
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
382 test("isArrayOfA", aArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
383 test("isArrayOfA", bArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
384 test("isArrayOfA", cArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
385 test("isArrayOfA", dArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
386 test("isArrayOfB", aArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
387 test("isArrayOfB", bArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
388 test("isArrayOfB", cArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
389 test("isArrayOfB", dArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
390 test("isArrayOfC", aArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
391 test("isArrayOfC", bArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
392 test("isArrayOfC", cArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
393 test("isArrayOfC", dArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
394 test("isArrayOfD", aArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
395 test("isArrayOfD", bArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
396 test("isArrayOfD", cArray);
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 7020
diff changeset
397 test("isArrayOfD", dArray);
7020
472609cc3e10 fixed implementation of HotSpotResolvedJavaType.findUniqueConcreteSubtype() for array types
Doug Simon <doug.simon@oracle.com>
parents: 6660
diff changeset
398 }
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
399 }