Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java @ 18360:6a5dc0bbebe7
Introduce PointerEqualsNode for metaspace pointer comparison.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Wed, 12 Nov 2014 11:48:54 +0100 |
parents | 9619ba4daf4c |
children | 0f4813e0b4a9 |
rev | line source |
---|---|
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
1 /* |
16212
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
4 * |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
8 * |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
14 * |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
18 * |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
21 * questions. |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
22 */ |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
23 package com.oracle.graal.nodes.calc; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
24 |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5504
diff
changeset
|
25 import com.oracle.graal.api.meta.*; |
18360
6a5dc0bbebe7
Introduce PointerEqualsNode for metaspace pointer comparison.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
26 import com.oracle.graal.compiler.common.type.*; |
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.*; |
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
|
28 import com.oracle.graal.nodeinfo.*; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
29 import com.oracle.graal.nodes.*; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
30 import com.oracle.graal.nodes.spi.*; |
11265 | 31 import com.oracle.graal.nodes.type.*; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
32 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
33 @NodeInfo(shortName = "==") |
18360
6a5dc0bbebe7
Introduce PointerEqualsNode for metaspace pointer comparison.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
34 public class ObjectEqualsNode extends PointerEqualsNode implements Virtualizable { |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
35 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
36 /** |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
37 * Constructs a new object equality comparison node. |
15349
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
38 * |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
39 * @param x the instruction producing the first input to the instruction |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
40 * @param y the instruction that produces the second input to this instruction |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
41 */ |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
42 public static ObjectEqualsNode create(ValueNode x, ValueNode y) { |
17450
45b45f902bed
removed Node generation (GRAAL-857)
Doug Simon <doug.simon@oracle.com>
parents:
17390
diff
changeset
|
43 return new ObjectEqualsNode(x, y); |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
44 } |
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
45 |
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
46 protected ObjectEqualsNode(ValueNode x, ValueNode y) { |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
47 super(x, y); |
18360
6a5dc0bbebe7
Introduce PointerEqualsNode for metaspace pointer comparison.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
48 assert x.stamp() instanceof AbstractObjectStamp; |
6a5dc0bbebe7
Introduce PointerEqualsNode for metaspace pointer comparison.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
49 assert y.stamp() instanceof AbstractObjectStamp; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
50 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
51 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
52 @Override |
16212
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
53 public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) { |
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
54 ValueNode result = super.canonical(tool, forX, forY); |
15349
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
55 if (result != this) { |
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
56 return result; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
57 } |
16212
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
58 if (StampTool.isObjectAlwaysNull(forX)) { |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
59 return IsNullNode.create(forY); |
16212
51c7c676d41a
implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
60 } else if (StampTool.isObjectAlwaysNull(forY)) { |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
61 return IsNullNode.create(forX); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
62 } |
15349
7766f486f5d6
evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15260
diff
changeset
|
63 return this; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
64 } |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
5831
diff
changeset
|
65 |
9606
0f7bd899a1a8
make ObjectEqualsNode virtualization less conservative
Lukas Stadler <lukas.stadler@jku.at>
parents:
9586
diff
changeset
|
66 private void virtualizeNonVirtualComparison(State state, ValueNode other, VirtualizerTool tool) { |
0f7bd899a1a8
make ObjectEqualsNode virtualization less conservative
Lukas Stadler <lukas.stadler@jku.at>
parents:
9586
diff
changeset
|
67 if (!state.getVirtualObject().hasIdentity() && state.getVirtualObject().entryKind(0) == Kind.Boolean) { |
0f7bd899a1a8
make ObjectEqualsNode virtualization less conservative
Lukas Stadler <lukas.stadler@jku.at>
parents:
9586
diff
changeset
|
68 if (other.isConstant()) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17450
diff
changeset
|
69 JavaConstant otherUnboxed = tool.getConstantReflectionProvider().unboxPrimitive(other.asJavaConstant()); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
70 if (otherUnboxed != null && otherUnboxed.getKind() == Kind.Boolean) { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
71 int expectedValue = otherUnboxed.asBoolean() ? 1 : 0; |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
72 IntegerEqualsNode equals = IntegerEqualsNode.create(state.getEntry(0), ConstantNode.forInt(expectedValue, graph())); |
10604
953a0d51a11f
ObjectEqualsNode: fix comparison of virtual boolean against constant object
Andreas Woess <andreas.woess@jku.at>
parents:
9634
diff
changeset
|
73 tool.addNode(equals); |
953a0d51a11f
ObjectEqualsNode: fix comparison of virtual boolean against constant object
Andreas Woess <andreas.woess@jku.at>
parents:
9634
diff
changeset
|
74 tool.replaceWithValue(equals); |
953a0d51a11f
ObjectEqualsNode: fix comparison of virtual boolean against constant object
Andreas Woess <andreas.woess@jku.at>
parents:
9634
diff
changeset
|
75 } else { |
953a0d51a11f
ObjectEqualsNode: fix comparison of virtual boolean against constant object
Andreas Woess <andreas.woess@jku.at>
parents:
9634
diff
changeset
|
76 tool.replaceWithValue(LogicConstantNode.contradiction(graph())); |
953a0d51a11f
ObjectEqualsNode: fix comparison of virtual boolean against constant object
Andreas Woess <andreas.woess@jku.at>
parents:
9634
diff
changeset
|
77 } |
9606
0f7bd899a1a8
make ObjectEqualsNode virtualization less conservative
Lukas Stadler <lukas.stadler@jku.at>
parents:
9586
diff
changeset
|
78 } |
0f7bd899a1a8
make ObjectEqualsNode virtualization less conservative
Lukas Stadler <lukas.stadler@jku.at>
parents:
9586
diff
changeset
|
79 } else { |
0f7bd899a1a8
make ObjectEqualsNode virtualization less conservative
Lukas Stadler <lukas.stadler@jku.at>
parents:
9586
diff
changeset
|
80 // one of them is virtual: they can never be the same objects |
0f7bd899a1a8
make ObjectEqualsNode virtualization less conservative
Lukas Stadler <lukas.stadler@jku.at>
parents:
9586
diff
changeset
|
81 tool.replaceWithValue(LogicConstantNode.contradiction(graph())); |
0f7bd899a1a8
make ObjectEqualsNode virtualization less conservative
Lukas Stadler <lukas.stadler@jku.at>
parents:
9586
diff
changeset
|
82 } |
0f7bd899a1a8
make ObjectEqualsNode virtualization less conservative
Lukas Stadler <lukas.stadler@jku.at>
parents:
9586
diff
changeset
|
83 } |
0f7bd899a1a8
make ObjectEqualsNode virtualization less conservative
Lukas Stadler <lukas.stadler@jku.at>
parents:
9586
diff
changeset
|
84 |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
5831
diff
changeset
|
85 @Override |
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
5831
diff
changeset
|
86 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:
15961
diff
changeset
|
87 State stateX = tool.getObjectState(getX()); |
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15961
diff
changeset
|
88 State stateY = tool.getObjectState(getY()); |
7394
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
6710
diff
changeset
|
89 boolean xVirtual = stateX != null && stateX.getState() == EscapeState.Virtual; |
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
6710
diff
changeset
|
90 boolean yVirtual = stateY != null && stateY.getState() == EscapeState.Virtual; |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
5831
diff
changeset
|
91 |
9586
c064c48b9387
fix virtualization of ObjectEqualsNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
8981
diff
changeset
|
92 if (xVirtual && !yVirtual) { |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15961
diff
changeset
|
93 virtualizeNonVirtualComparison(stateX, stateY != null ? stateY.getMaterializedValue() : getY(), tool); |
9586
c064c48b9387
fix virtualization of ObjectEqualsNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
8981
diff
changeset
|
94 } else if (!xVirtual && yVirtual) { |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15961
diff
changeset
|
95 virtualizeNonVirtualComparison(stateY, stateX != null ? stateX.getMaterializedValue() : getX(), tool); |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
5831
diff
changeset
|
96 } else if (xVirtual && yVirtual) { |
8925
1b2635aa6a1d
PEA: handle identity-less objects in IntegerEqualsNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
97 boolean xIdentity = stateX.getVirtualObject().hasIdentity(); |
1b2635aa6a1d
PEA: handle identity-less objects in IntegerEqualsNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
98 boolean yIdentity = stateY.getVirtualObject().hasIdentity(); |
1b2635aa6a1d
PEA: handle identity-less objects in IntegerEqualsNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
99 if (xIdentity ^ yIdentity) { |
8981
09cdf7224794
PEA: cleanup and documentation for recent changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8925
diff
changeset
|
100 /* |
09cdf7224794
PEA: cleanup and documentation for recent changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8925
diff
changeset
|
101 * One of the two objects has identity, the other doesn't. In code, this looks like |
09cdf7224794
PEA: cleanup and documentation for recent changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8925
diff
changeset
|
102 * "Integer.valueOf(a) == new Integer(b)", which is always false. |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
103 * |
8981
09cdf7224794
PEA: cleanup and documentation for recent changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8925
diff
changeset
|
104 * In other words: an object created via valueOf can never be equal to one created |
09cdf7224794
PEA: cleanup and documentation for recent changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8925
diff
changeset
|
105 * by new in the same compilation unit. |
09cdf7224794
PEA: cleanup and documentation for recent changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8925
diff
changeset
|
106 */ |
8925
1b2635aa6a1d
PEA: handle identity-less objects in IntegerEqualsNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
107 tool.replaceWithValue(LogicConstantNode.contradiction(graph())); |
1b2635aa6a1d
PEA: handle identity-less objects in IntegerEqualsNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
108 } else if (!xIdentity && !yIdentity) { |
17390
5949340cc50e
only optimize identity-less comparisons for Integer and Long
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16919
diff
changeset
|
109 ResolvedJavaType type = stateX.getVirtualObject().type(); |
5949340cc50e
only optimize identity-less comparisons for Integer and Long
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16919
diff
changeset
|
110 if (type.equals(stateY.getVirtualObject().type())) { |
5949340cc50e
only optimize identity-less comparisons for Integer and Long
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16919
diff
changeset
|
111 MetaAccessProvider metaAccess = tool.getMetaAccessProvider(); |
5949340cc50e
only optimize identity-less comparisons for Integer and Long
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16919
diff
changeset
|
112 if (type.equals(metaAccess.lookupJavaType(Integer.class)) || type.equals(metaAccess.lookupJavaType(Long.class))) { |
5949340cc50e
only optimize identity-less comparisons for Integer and Long
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16919
diff
changeset
|
113 // both are virtual without identity: check contents |
5949340cc50e
only optimize identity-less comparisons for Integer and Long
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16919
diff
changeset
|
114 assert stateX.getVirtualObject().entryCount() == 1 && stateY.getVirtualObject().entryCount() == 1; |
5949340cc50e
only optimize identity-less comparisons for Integer and Long
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16919
diff
changeset
|
115 assert stateX.getVirtualObject().entryKind(0).getStackKind() == Kind.Int || stateX.getVirtualObject().entryKind(0) == Kind.Long; |
5949340cc50e
only optimize identity-less comparisons for Integer and Long
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16919
diff
changeset
|
116 IntegerEqualsNode equals = IntegerEqualsNode.create(stateX.getEntry(0), stateY.getEntry(0)); |
5949340cc50e
only optimize identity-less comparisons for Integer and Long
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16919
diff
changeset
|
117 tool.addNode(equals); |
5949340cc50e
only optimize identity-less comparisons for Integer and Long
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16919
diff
changeset
|
118 tool.replaceWithValue(equals); |
5949340cc50e
only optimize identity-less comparisons for Integer and Long
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16919
diff
changeset
|
119 } |
5949340cc50e
only optimize identity-less comparisons for Integer and Long
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16919
diff
changeset
|
120 } |
8925
1b2635aa6a1d
PEA: handle identity-less objects in IntegerEqualsNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
121 } else { |
1b2635aa6a1d
PEA: handle identity-less objects in IntegerEqualsNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
122 // both are virtual with identity: check if they refer to the same object |
1b2635aa6a1d
PEA: handle identity-less objects in IntegerEqualsNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
123 tool.replaceWithValue(LogicConstantNode.forBoolean(stateX == stateY, graph())); |
1b2635aa6a1d
PEA: handle identity-less objects in IntegerEqualsNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
124 } |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
5831
diff
changeset
|
125 } |
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
5831
diff
changeset
|
126 } |
15961
d5b824a41530
CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15349
diff
changeset
|
127 |
d5b824a41530
CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15349
diff
changeset
|
128 @Override |
d5b824a41530
CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15349
diff
changeset
|
129 protected CompareNode duplicateModified(ValueNode newX, ValueNode newY) { |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
130 return ObjectEqualsNode.create(newX, newY); |
15961
d5b824a41530
CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15349
diff
changeset
|
131 } |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
132 } |