Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java @ 14633:da2431cc1506
Rename ValueNode kind() to getKind().
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Thu, 20 Mar 2014 11:48:39 +0100 |
parents | 04615309d018 |
children | db4254246f9a |
rev | line source |
---|---|
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.nodes.java; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import com.oracle.graal.api.meta.*; |
11880
9a747d8e0d0f
broadened types in Canonicalizable interface so that it can be moved to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11579
diff
changeset
|
26 import com.oracle.graal.graph.*; |
11881
da9db8331658
moved Canonicalizable and Simplifiable to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11880
diff
changeset
|
27 import com.oracle.graal.graph.spi.*; |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.graal.nodes.*; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.nodes.spi.*; |
11265 | 30 import com.oracle.graal.nodes.type.*; |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7278
diff
changeset
|
33 * The {@code InstanceOfDynamicNode} represents a type check where the type being checked is not |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7278
diff
changeset
|
34 * known at compile time. This is used, for instance, to intrinsify {@link Class#isInstance(Object)} |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7278
diff
changeset
|
35 * . |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 */ |
7767
4a6646d8eb87
separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
37 public final class InstanceOfDynamicNode extends LogicNode implements Canonicalizable, Lowerable { |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 @Input private ValueNode object; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 @Input private ValueNode mirror; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 /** |
11226
422b0e9b9aed
removed obsolete checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
9360
diff
changeset
|
43 * @param mirror the {@link Class} value representing the target target type of the test |
422b0e9b9aed
removed obsolete checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
9360
diff
changeset
|
44 * @param object the object being tested |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 */ |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 public InstanceOfDynamicNode(ValueNode mirror, ValueNode object) { |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 this.mirror = mirror; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 this.object = object; |
14633
da2431cc1506
Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents:
13689
diff
changeset
|
49 assert mirror.getKind() == Kind.Object : mirror.getKind(); |
11384
5e99a0628192
Add javadoc for ObjectStamp.castTo. Fix javadoc typo.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11265
diff
changeset
|
50 assert ObjectStamp.isExactType(mirror); |
5e99a0628192
Add javadoc for ObjectStamp.castTo. Fix javadoc typo.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11265
diff
changeset
|
51 assert ObjectStamp.typeOrNull(mirror).getName().equals("Ljava/lang/Class;"); |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 } |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 @Override |
11579
ae619d70bf4b
Rename LoweringType to GuardsPhase and make it an attribute of StructuredGraphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11529
diff
changeset
|
55 public void lower(LoweringTool tool) { |
12045
0fc653a9e019
made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
56 tool.getLowerer().lower(this, tool); |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 } |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 @Override |
11880
9a747d8e0d0f
broadened types in Canonicalizable interface so that it can be moved to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11579
diff
changeset
|
60 public Node canonical(CanonicalizerTool tool) { |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 assert object() != null : this; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 if (mirror().isConstant()) { |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 Class clazz = (Class) mirror().asConstant().asObject(); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11881
diff
changeset
|
64 ResolvedJavaType t = tool.getMetaAccess().lookupJavaType(clazz); |
13689
04615309d018
fix Class.isInstance substitution
Lukas Stadler <lukas.stadler@jku.at>
parents:
12045
diff
changeset
|
65 if (t.isPrimitive()) { |
04615309d018
fix Class.isInstance substitution
Lukas Stadler <lukas.stadler@jku.at>
parents:
12045
diff
changeset
|
66 return LogicConstantNode.contradiction(graph()); |
04615309d018
fix Class.isInstance substitution
Lukas Stadler <lukas.stadler@jku.at>
parents:
12045
diff
changeset
|
67 } else { |
04615309d018
fix Class.isInstance substitution
Lukas Stadler <lukas.stadler@jku.at>
parents:
12045
diff
changeset
|
68 return graph().unique(new InstanceOfNode(t, object(), null)); |
04615309d018
fix Class.isInstance substitution
Lukas Stadler <lukas.stadler@jku.at>
parents:
12045
diff
changeset
|
69 } |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 } |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 return this; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 } |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 public ValueNode object() { |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 return object; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 } |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 public ValueNode mirror() { |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 return mirror; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 } |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 } |