Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
18359:a3a2359ac88e | 18360:6a5dc0bbebe7 |
---|---|
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.graal.nodes.calc; | 23 package com.oracle.graal.nodes.calc; |
24 | 24 |
25 import com.oracle.graal.api.meta.*; | 25 import com.oracle.graal.api.meta.*; |
26 import com.oracle.graal.compiler.common.calc.*; | 26 import com.oracle.graal.compiler.common.type.*; |
27 import com.oracle.graal.graph.spi.*; | 27 import com.oracle.graal.graph.spi.*; |
28 import com.oracle.graal.nodeinfo.*; | 28 import com.oracle.graal.nodeinfo.*; |
29 import com.oracle.graal.nodes.*; | 29 import com.oracle.graal.nodes.*; |
30 import com.oracle.graal.nodes.spi.*; | 30 import com.oracle.graal.nodes.spi.*; |
31 import com.oracle.graal.nodes.type.*; | 31 import com.oracle.graal.nodes.type.*; |
32 import com.oracle.graal.nodes.util.*; | |
33 | 32 |
34 @NodeInfo(shortName = "==") | 33 @NodeInfo(shortName = "==") |
35 public class ObjectEqualsNode extends CompareNode implements Virtualizable { | 34 public class ObjectEqualsNode extends PointerEqualsNode implements Virtualizable { |
36 | 35 |
37 /** | 36 /** |
38 * Constructs a new object equality comparison node. | 37 * Constructs a new object equality comparison node. |
39 * | 38 * |
40 * @param x the instruction producing the first input to the instruction | 39 * @param x the instruction producing the first input to the instruction |
44 return new ObjectEqualsNode(x, y); | 43 return new ObjectEqualsNode(x, y); |
45 } | 44 } |
46 | 45 |
47 protected ObjectEqualsNode(ValueNode x, ValueNode y) { | 46 protected ObjectEqualsNode(ValueNode x, ValueNode y) { |
48 super(x, y); | 47 super(x, y); |
49 assert x.getKind() == Kind.Object; | 48 assert x.stamp() instanceof AbstractObjectStamp; |
50 assert y.getKind() == Kind.Object; | 49 assert y.stamp() instanceof AbstractObjectStamp; |
51 } | |
52 | |
53 @Override | |
54 public Condition condition() { | |
55 return Condition.EQ; | |
56 } | |
57 | |
58 @Override | |
59 public boolean unorderedIsTrue() { | |
60 return false; | |
61 } | 50 } |
62 | 51 |
63 @Override | 52 @Override |
64 public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) { | 53 public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) { |
65 ValueNode result = super.canonical(tool, forX, forY); | 54 ValueNode result = super.canonical(tool, forX, forY); |
66 if (result != this) { | 55 if (result != this) { |
67 return result; | 56 return result; |
68 } | |
69 if (GraphUtil.unproxify(forX) == GraphUtil.unproxify(forY)) { | |
70 return LogicConstantNode.tautology(); | |
71 } else if (forX.stamp().alwaysDistinct(forY.stamp())) { | |
72 return LogicConstantNode.contradiction(); | |
73 } | 57 } |
74 if (StampTool.isObjectAlwaysNull(forX)) { | 58 if (StampTool.isObjectAlwaysNull(forX)) { |
75 return IsNullNode.create(forY); | 59 return IsNullNode.create(forY); |
76 } else if (StampTool.isObjectAlwaysNull(forY)) { | 60 } else if (StampTool.isObjectAlwaysNull(forY)) { |
77 return IsNullNode.create(forX); | 61 return IsNullNode.create(forX); |