annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java @ 19403:61d3cb8e1280

Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 16 Feb 2015 17:47:43 +0100
parents 7e2c87dae93e
children 8fc336a04d77
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
19396
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
2 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.nodes.java;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19239
diff changeset
25 import com.oracle.graal.api.code.*;
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5504
diff changeset
26 import com.oracle.graal.api.meta.*;
15198
2c0cfbf454b5 Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 12045
diff changeset
27 import com.oracle.graal.compiler.common.type.*;
19396
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
28 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
29 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: 16822
diff changeset
30 import com.oracle.graal.nodeinfo.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
31 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
32 import com.oracle.graal.nodes.calc.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
33 import com.oracle.graal.nodes.spi.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 * The {@code InstanceOfNode} represents an instanceof test.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 */
16822
5d468add216f added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents: 16421
diff changeset
38 @NodeInfo
19396
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
39 public final class InstanceOfNode extends UnaryOpLogicNode implements Lowerable, Virtualizable {
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19396
diff changeset
40 public static final NodeClass<InstanceOfNode> TYPE = NodeClass.get(InstanceOfNode.class);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41
17328
c9bb0da795d4 Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents: 17327
diff changeset
42 protected final ResolvedJavaType type;
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17135
diff changeset
43 protected JavaTypeProfile profile;
4338
04ebcabcba4f misc cleanup
Lukas Stadler <lukas.stadler@jku.at>
parents: 4309
diff changeset
44
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
45 public InstanceOfNode(ResolvedJavaType type, ValueNode object, JavaTypeProfile profile) {
19396
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
46 super(TYPE, object);
6647
0b8410de1365 removed targetClassInstruction from InstanceOfNode
Doug Simon <doug.simon@oracle.com>
parents: 6548
diff changeset
47 this.type = type;
5370
5229911d3970 removed TypeCheckNode
Doug Simon <doug.simon@oracle.com>
parents: 5369
diff changeset
48 this.profile = profile;
6647
0b8410de1365 removed targetClassInstruction from InstanceOfNode
Doug Simon <doug.simon@oracle.com>
parents: 6548
diff changeset
49 assert type != null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
52 public static LogicNode create(ResolvedJavaType type, ValueNode object, JavaTypeProfile profile) {
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
53 ObjectStamp objectStamp = (ObjectStamp) object.stamp();
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
54 LogicNode constantValue = findSynonym(type, objectStamp.type(), objectStamp.nonNull(), objectStamp.isExactType());
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
55 if (constantValue != null) {
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
56 return constantValue;
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
57 } else {
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
58 return new InstanceOfNode(type, object, profile);
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
59 }
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
60 }
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
61
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 @Override
11579
ae619d70bf4b Rename LoweringType to GuardsPhase and make it an attribute of StructuredGraphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
63 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
64 tool.getLowerer().lower(this, tool);
6302
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5891
diff changeset
65 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5891
diff changeset
66
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5891
diff changeset
67 @Override
16211
a15b25626672 implement Canonicalizable.Unary in the UnaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16207
diff changeset
68 public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) {
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17135
diff changeset
69 if (!(forValue.stamp() instanceof ObjectStamp)) {
16211
a15b25626672 implement Canonicalizable.Unary in the UnaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16207
diff changeset
70 return this;
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10789
diff changeset
71 }
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17135
diff changeset
72 ObjectStamp objectStamp = (ObjectStamp) forValue.stamp();
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10789
diff changeset
73 if (objectStamp.alwaysNull()) {
16211
a15b25626672 implement Canonicalizable.Unary in the UnaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16207
diff changeset
74 return LogicConstantNode.contradiction();
10708
41e9c8845826 Improve instanceof canonicalization
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10693
diff changeset
75 }
41e9c8845826 Improve instanceof canonicalization
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10693
diff changeset
76
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10789
diff changeset
77 ResolvedJavaType stampType = objectStamp.type();
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10789
diff changeset
78 if (stampType != null) {
16420
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
79 ValueNode result = checkInstanceOf(forValue, stampType, objectStamp.nonNull(), objectStamp.isExactType());
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
80 if (result != null) {
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
81 return result;
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
82 }
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19239
diff changeset
83 Assumptions assumptions = graph().getAssumptions();
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
84 if (assumptions != null) {
16421
c158f653275e don't forget to record assumptions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16420
diff changeset
85 ResolvedJavaType exact = stampType.findUniqueConcreteSubtype();
c158f653275e don't forget to record assumptions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16420
diff changeset
86 if (exact != null) {
c158f653275e don't forget to record assumptions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16420
diff changeset
87 result = checkInstanceOf(forValue, exact, objectStamp.nonNull(), true);
c158f653275e don't forget to record assumptions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16420
diff changeset
88 if (result != null) {
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19239
diff changeset
89 assumptions.recordConcreteSubtype(stampType, exact);
16421
c158f653275e don't forget to record assumptions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16420
diff changeset
90 return result;
c158f653275e don't forget to record assumptions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16420
diff changeset
91 }
5338
17a84768b1cd fix canonicalization of InstanceOfNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 5320
diff changeset
92 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94 }
16420
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
95 return this;
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
96 }
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
97
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
98 private ValueNode checkInstanceOf(ValueNode forValue, ResolvedJavaType inputType, boolean nonNull, boolean exactType) {
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
99 ValueNode result = findSynonym(type(), inputType, nonNull, exactType);
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
100 if (result != null) {
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
101 return result;
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
102 }
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
103 if (type().isAssignableFrom(inputType)) {
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
104 if (!nonNull) {
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
105 // the instanceof matches if the object is non-null, so return true
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
106 // depending on the null-ness.
19373
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19306
diff changeset
107 return LogicNegationNode.create(new IsNullNode(forValue));
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
108 }
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
109 }
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
110 return null;
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
111 }
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
112
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
113 public static LogicNode findSynonym(ResolvedJavaType type, ResolvedJavaType inputType, boolean nonNull, boolean exactType) {
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
114 if (inputType == null) {
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
115 return null;
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
116 }
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
117 boolean subType = type.isAssignableFrom(inputType);
16420
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
118 if (subType) {
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
119 if (nonNull) {
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
120 // the instanceOf matches, so return true
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
121 return LogicConstantNode.tautology();
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
122 }
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
123 } else {
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
124 if (exactType) {
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
125 // since this type check failed for an exact type we know that it can never
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
126 // succeed at run time. we also don't care about null values, since they will
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
127 // also make the check fail.
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
128 return LogicConstantNode.contradiction();
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
129 } else {
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
130 boolean superType = inputType.isAssignableFrom(type);
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
131 if (!superType && !inputType.isInterface() && !type.isInterface()) {
16420
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
132 return LogicConstantNode.contradiction();
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
133 }
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
134 // since the subtype comparison was only performed on a declared type we don't
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
135 // really know if it might be true at run time...
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
136 }
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
137 }
e4ac25d4e13d use findUniqueConcreteSubtype in InstanceOfNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16211
diff changeset
138 return null;
5370
5229911d3970 removed TypeCheckNode
Doug Simon <doug.simon@oracle.com>
parents: 5369
diff changeset
139 }
5229911d3970 removed TypeCheckNode
Doug Simon <doug.simon@oracle.com>
parents: 5369
diff changeset
140
5229911d3970 removed TypeCheckNode
Doug Simon <doug.simon@oracle.com>
parents: 5369
diff changeset
141 /**
6647
0b8410de1365 removed targetClassInstruction from InstanceOfNode
Doug Simon <doug.simon@oracle.com>
parents: 6548
diff changeset
142 * Gets the type being tested.
5370
5229911d3970 removed TypeCheckNode
Doug Simon <doug.simon@oracle.com>
parents: 5369
diff changeset
143 */
6647
0b8410de1365 removed targetClassInstruction from InstanceOfNode
Doug Simon <doug.simon@oracle.com>
parents: 6548
diff changeset
144 public ResolvedJavaType type() {
0b8410de1365 removed targetClassInstruction from InstanceOfNode
Doug Simon <doug.simon@oracle.com>
parents: 6548
diff changeset
145 return type;
5370
5229911d3970 removed TypeCheckNode
Doug Simon <doug.simon@oracle.com>
parents: 5369
diff changeset
146 }
5229911d3970 removed TypeCheckNode
Doug Simon <doug.simon@oracle.com>
parents: 5369
diff changeset
147
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: 5540
diff changeset
148 public JavaTypeProfile profile() {
5370
5229911d3970 removed TypeCheckNode
Doug Simon <doug.simon@oracle.com>
parents: 5369
diff changeset
149 return profile;
5229911d3970 removed TypeCheckNode
Doug Simon <doug.simon@oracle.com>
parents: 5369
diff changeset
150 }
6548
4dc9e468c8b0 The lowering currently does not support a FixedGuard as the usage of an InstanceOfNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6302
diff changeset
151
9366
f1170c277b7b Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9360
diff changeset
152 public void setProfile(JavaTypeProfile profile) {
f1170c277b7b Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9360
diff changeset
153 this.profile = profile;
f1170c277b7b Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9360
diff changeset
154 }
f1170c277b7b Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9360
diff changeset
155
6548
4dc9e468c8b0 The lowering currently does not support a FixedGuard as the usage of an InstanceOfNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6302
diff changeset
156 @Override
7011
09df32b1dff9 make InstanceOfNode Virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents: 6647
diff changeset
157 public void virtualize(VirtualizerTool tool) {
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15831
diff changeset
158 State state = tool.getObjectState(getValue());
7394
94f032472c28 changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents: 7277
diff changeset
159 if (state != null) {
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
160 tool.replaceWithValue(LogicConstantNode.forBoolean(type().isAssignableFrom(state.getVirtualObject().type()), graph()));
7011
09df32b1dff9 make InstanceOfNode Virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents: 6647
diff changeset
161 }
09df32b1dff9 make InstanceOfNode Virtualizable
Lukas Stadler <lukas.stadler@jku.at>
parents: 6647
diff changeset
162 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
163 }