comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/PointerEqualsNode.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 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java@9619ba4daf4c
children ca81508f2a19
comparison
equal deleted inserted replaced
18359:a3a2359ac88e 18360:6a5dc0bbebe7
1 /*
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package com.oracle.graal.nodes.calc;
24
25 import com.oracle.graal.compiler.common.calc.*;
26 import com.oracle.graal.compiler.common.type.*;
27 import com.oracle.graal.graph.spi.*;
28 import com.oracle.graal.nodeinfo.*;
29 import com.oracle.graal.nodes.*;
30 import com.oracle.graal.nodes.util.*;
31
32 @NodeInfo(shortName = "==")
33 public class PointerEqualsNode extends CompareNode {
34
35 /**
36 * Constructs a new pointer equality comparison node.
37 *
38 * @param x the instruction producing the first input to the instruction
39 * @param y the instruction that produces the second input to this instruction
40 */
41 public static PointerEqualsNode create(ValueNode x, ValueNode y) {
42 return new PointerEqualsNode(x, y);
43 }
44
45 protected PointerEqualsNode(ValueNode x, ValueNode y) {
46 super(x, y);
47 assert x.stamp() instanceof AbstractPointerStamp;
48 assert y.stamp() instanceof AbstractPointerStamp;
49 }
50
51 @Override
52 public Condition condition() {
53 return Condition.EQ;
54 }
55
56 @Override
57 public boolean unorderedIsTrue() {
58 return false;
59 }
60
61 @Override
62 public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
63 if (GraphUtil.unproxify(forX) == GraphUtil.unproxify(forY)) {
64 return LogicConstantNode.tautology();
65 } else if (forX.stamp().alwaysDistinct(forY.stamp())) {
66 return LogicConstantNode.contradiction();
67 }
68 return super.canonical(tool, forX, forY);
69 }
70
71 @Override
72 protected CompareNode duplicateModified(ValueNode newX, ValueNode newY) {
73 return PointerEqualsNode.create(newX, newY);
74 }
75 }