Mercurial > hg > truffle
annotate graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java @ 6567:3bc7183309e0
improved InstanceOfTest.isStringInt()
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 22 Oct 2012 10:23:50 +0200 |
parents | ee651c726397 |
children | 77fb2026fcbe |
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 */ |
5779
1458f656b060
moved snippet related tests to com.oracle.graal.snippets.test project
Doug Simon <doug.simon@oracle.com>
parents:
5541
diff
changeset
|
23 package com.oracle.graal.snippets; |
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 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import org.junit.*; |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5439
diff
changeset
|
29 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
|
30 import com.oracle.graal.nodes.*; |
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.java.*; |
6526
ee651c726397
split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
32 import com.oracle.graal.phases.*; |
ee651c726397
split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
33 import com.oracle.graal.phases.common.*; |
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
|
34 import com.oracle.graal.snippets.CheckCastTest.*; |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 /** |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 * Tests the implementation of instanceof, allowing profiling information to |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 * be manually specified. |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 */ |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 public class InstanceOfTest extends TypeCheckTest { |
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 @Override |
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
|
43 protected void editPhasePlan(ResolvedJavaMethod method, StructuredGraph graph, PhasePlan phasePlan) { |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
44 phasePlan.disablePhase(InliningPhase.class); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
45 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
46 |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
47 @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
|
48 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
|
49 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
|
50 if (ion != null) { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 InstanceOfNode ionNew = graph.add(new InstanceOfNode(ion.targetClassInstruction(), ion.targetClass(), ion.object(), profile)); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 graph.replaceFloating(ion, ionNew); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 } |
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 @Test |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 public void test1() { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 test("isString", profile(), "object"); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 test("isString", profile(String.class), "object"); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 test("isString", profile(), Object.class); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 test("isString", profile(String.class), Object.class); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 } |
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 @Test |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 public void test2() { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 test("isStringInt", profile(), "object"); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 test("isStringInt", profile(String.class), "object"); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 test("isStringInt", profile(), Object.class); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 test("isStringInt", profile(String.class), Object.class); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 } |
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 @Test |
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
|
75 public void test2_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
|
76 test("isStringIntComplex", profile(), "object"); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
77 test("isStringIntComplex", profile(String.class), "object"); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
78 |
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 test("isStringIntComplex", profile(), Object.class); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
80 test("isStringIntComplex", profile(String.class), Object.class); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
81 } |
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 @Test |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 public void test3() { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 Throwable throwable = new Exception(); |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
86 test("isThrowable", profile(), throwable); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
87 test("isThrowable", profile(Throwable.class), throwable); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
88 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
|
89 |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
90 test("isThrowable", profile(), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
91 test("isThrowable", profile(Throwable.class), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
92 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
|
93 } |
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 @Test |
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
|
96 public void test3_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
|
97 onlyFirstIsException(new Exception(), new Error()); |
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 test("onlyFirstIsException", profile(), new Exception(), new Error()); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
99 test("onlyFirstIsException", profile(), new Error(), new 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
|
100 test("onlyFirstIsException", profile(), new Exception(), new 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
|
101 test("onlyFirstIsException", profile(), new Error(), new Error()); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
102 } |
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 @Test |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
105 public void test4() { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
106 Throwable throwable = new Exception(); |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
107 test("isThrowableInt", profile(), throwable); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
108 test("isThrowableInt", profile(Throwable.class), throwable); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
109 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
|
110 |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
111 test("isThrowableInt", profile(), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
112 test("isThrowableInt", profile(Throwable.class), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
113 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
|
114 } |
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 @Test |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 public void test5() { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
118 Map map = new HashMap<>(); |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
119 test("isMap", profile(), map); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
120 test("isMap", profile(HashMap.class), map); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
121 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
|
122 |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
123 test("isMap", profile(), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
124 test("isMap", profile(HashMap.class), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
125 test("isMap", 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
|
126 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
128 @Test |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
129 public void test6() { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 Map map = new HashMap<>(); |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
131 test("isMapInt", profile(), map); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
132 test("isMapInt", profile(HashMap.class), map); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
133 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
|
134 |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
135 test("isMapInt", profile(), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
136 test("isMapInt", profile(HashMap.class), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
137 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
|
138 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
139 |
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
|
140 @Test |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
141 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
|
142 Object o = new Depth13(); |
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 test("isDepth12", profile(), 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
|
144 test("isDepth12", profile(Depth13.class), 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
|
145 test("isDepth12", profile(Depth13.class, Depth14.class), 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
|
146 |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
147 o = "not a depth"; |
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 test("isDepth12", profile(), 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
|
149 test("isDepth12", profile(Depth13.class), 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
|
150 test("isDepth12", profile(Depth13.class, Depth14.class), 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
|
151 } |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
152 |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
153 @Test |
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 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
|
155 Object o = new Depth13(); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
156 test("isDepth12Int", profile(), 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
|
157 test("isDepth12Int", profile(Depth13.class), 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
|
158 test("isDepth12Int", profile(Depth13.class, Depth14.class), 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
|
159 |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
160 o = "not a depth"; |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
161 test("isDepth12Int", profile(), 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
|
162 test("isDepth12Int", profile(Depth13.class), 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
|
163 test("isDepth12Int", profile(Depth13.class, Depth14.class), 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
|
164 } |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
165 |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
166 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
|
167 return o instanceof String; |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
170 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
|
171 if (o instanceof String) { |
6567
3bc7183309e0
improved InstanceOfTest.isStringInt()
Doug Simon <doug.simon@oracle.com>
parents:
6526
diff
changeset
|
172 return id(1); |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
173 } |
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
|
174 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
|
175 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
176 |
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 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
|
178 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
|
179 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
|
180 } |
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 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
|
182 } |
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 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
|
185 return value; |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
186 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
187 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
188 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
|
189 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
|
190 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
191 |
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 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
|
193 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
|
194 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
|
195 } |
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 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
|
197 } |
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 |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
200 public static int isThrowableInt(Object o) { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
201 if (o instanceof Throwable) { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
202 return 1; |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
203 } |
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
|
204 if (o instanceof Throwable) { |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
205 return 2; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
206 } |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
207 return 0; |
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) { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
216 return 1; |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
217 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
218 return 0; |
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 } |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
231 } |