Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java @ 18845:f57d86eb036f
removed Node factory methods
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 12 Jan 2015 20:39:04 +0100 |
parents | 0f4813e0b4a9 |
children | 7e2c87dae93e |
rev | line source |
---|---|
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
16213
de90d96f562c
make InstanceOfDynamicNode a BinaryOpLogicNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
2 * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. |
7278
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.*; |
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
|
26 import com.oracle.graal.graph.spi.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16811
diff
changeset
|
27 import com.oracle.graal.nodeinfo.*; |
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 */ |
16811
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16213
diff
changeset
|
37 @NodeInfo |
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16213
diff
changeset
|
38 public class InstanceOfDynamicNode extends LogicNode implements Canonicalizable.Binary<ValueNode>, Lowerable { |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 |
16897
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
40 @Input ValueNode object; |
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
41 @Input ValueNode mirror; |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18487
diff
changeset
|
43 public InstanceOfDynamicNode(ValueNode mirror, ValueNode object) { |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 this.mirror = mirror; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 this.object = object; |
14633
da2431cc1506
Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents:
13689
diff
changeset
|
46 assert mirror.getKind() == Kind.Object : mirror.getKind(); |
15260
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
47 assert StampTool.isExactType(mirror); |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
48 assert StampTool.typeOrNull(mirror).getName().equals("Ljava/lang/Class;"); |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 } |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 @Override |
11579
ae619d70bf4b
Rename LoweringType to GuardsPhase and make it an attribute of StructuredGraphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11529
diff
changeset
|
52 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
|
53 tool.getLowerer().lower(this, tool); |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 } |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 |
16213
de90d96f562c
make InstanceOfDynamicNode a BinaryOpLogicNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
56 public ValueNode canonical(CanonicalizerTool tool, ValueNode forObject, ValueNode forMirror) { |
de90d96f562c
make InstanceOfDynamicNode a BinaryOpLogicNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
57 if (forMirror.isConstant()) { |
18487
0f4813e0b4a9
Use asConstant() instead of asJavaConstant() where possible.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
58 ResolvedJavaType t = tool.getConstantReflection().asJavaType(forMirror.asConstant()); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
59 if (t != null) { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
60 if (t.isPrimitive()) { |
16213
de90d96f562c
make InstanceOfDynamicNode a BinaryOpLogicNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
61 return LogicConstantNode.contradiction(); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
62 } else { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18487
diff
changeset
|
63 return new InstanceOfNode(t, forObject, null); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
64 } |
13689
04615309d018
fix Class.isInstance substitution
Lukas Stadler <lukas.stadler@jku.at>
parents:
12045
diff
changeset
|
65 } |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 } |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 return this; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 } |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 public ValueNode object() { |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 return object; |
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 mirror() { |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 return mirror; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 } |
16213
de90d96f562c
make InstanceOfDynamicNode a BinaryOpLogicNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
77 |
de90d96f562c
make InstanceOfDynamicNode a BinaryOpLogicNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
78 public ValueNode getX() { |
de90d96f562c
make InstanceOfDynamicNode a BinaryOpLogicNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
79 return object; |
de90d96f562c
make InstanceOfDynamicNode a BinaryOpLogicNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
80 } |
de90d96f562c
make InstanceOfDynamicNode a BinaryOpLogicNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
81 |
de90d96f562c
make InstanceOfDynamicNode a BinaryOpLogicNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
82 public ValueNode getY() { |
de90d96f562c
make InstanceOfDynamicNode a BinaryOpLogicNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
83 return mirror; |
de90d96f562c
make InstanceOfDynamicNode a BinaryOpLogicNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
84 } |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 } |