annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java @ 20074:a7ee2e1f0d4e

remove UnboxNodes without usages (if object is non-null)
author Lukas Stadler <lukas.stadler@oracle.com>
date Mon, 30 Mar 2015 13:59:59 +0200
parents 1b7dbb81df4f
children 35e1b66f2810
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
1 /*
18839
1b7dbb81df4f Use ArithmeticOpTable for shift operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 18490
diff changeset
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
4 *
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
8 *
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
13 * accompanied this code).
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
14 *
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
18 *
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
21 * questions.
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
22 */
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
23 package com.oracle.graal.nodes.type;
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
24
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
25 import java.util.*;
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
26
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
27 import com.oracle.graal.api.meta.*;
15198
2c0cfbf454b5 Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15132
diff changeset
28 import com.oracle.graal.compiler.common.type.*;
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
29 import com.oracle.graal.nodes.*;
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
30
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
31 /**
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
32 * Helper class that is used to keep all stamp-related operations in one place.
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
33 */
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
34 public class StampTool {
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
35
18364
ad3c2cacdd1a Remove StampProvider interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 17344
diff changeset
36 public static Stamp meet(Collection<? extends ValueNode> values) {
ad3c2cacdd1a Remove StampProvider interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 17344
diff changeset
37 Iterator<? extends ValueNode> iterator = values.iterator();
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
38 if (iterator.hasNext()) {
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
39 Stamp stamp = iterator.next().stamp();
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
40 while (iterator.hasNext()) {
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
41 stamp = stamp.meet(iterator.next().stamp());
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
42 }
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
43 return stamp;
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
44 } else {
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
45 return StampFactory.forVoid();
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
46 }
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
47 }
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
48
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
49 /**
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
50 * Compute the stamp resulting from the unsigned comparison being true.
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14863
diff changeset
51 *
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
52 * @return null if it's can't be true or it nothing useful can be encoded.
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
53 */
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
54 public static Stamp unsignedCompare(Stamp stamp, Stamp stamp2) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
55 IntegerStamp x = (IntegerStamp) stamp;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
56 IntegerStamp y = (IntegerStamp) stamp2;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
57 if (x == x.unrestricted() && y == y.unrestricted()) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
58 // Don't know anything.
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
59 return null;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
60 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
61 // c <| n, where c is a constant and n is known to be positive.
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
62 if (x.lowerBound() == x.upperBound()) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
63 if (y.isPositive()) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
64 if (x.lowerBound() == (1 << x.getBits()) - 1) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
65 // Constant is MAX_VALUE which must fail.
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
66 return null;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
67 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
68 if (x.lowerBound() <= y.lowerBound()) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
69 // Test will fail. Return illegalStamp instead?
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
70 return null;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
71 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
72 // If the test succeeds then this proves that n is at greater than c so the bounds
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
73 // are [c+1..-n.upperBound)].
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14863
diff changeset
74 return StampFactory.forInteger(x.getBits(), x.lowerBound() + 1, y.upperBound());
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
75 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
76 return null;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
77 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
78 // n <| c, where c is a strictly positive constant
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
79 if (y.lowerBound() == y.upperBound() && y.isStrictlyPositive()) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
80 // The test proves that n is positive and less than c, [0..c-1]
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14863
diff changeset
81 return StampFactory.forInteger(y.getBits(), 0, y.lowerBound() - 1);
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
82 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
83 return null;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
84 }
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
85
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
86 /**
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18364
diff changeset
87 * Checks whether this {@link ValueNode} represents a {@linkplain Stamp#isLegal() legal} pointer
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
88 * value which is known to be always null.
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
89 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
90 * @param node the node to check
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
91 * @return true if this node represents a legal object value which is known to be always null
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
92 */
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18364
diff changeset
93 public static boolean isPointerAlwaysNull(ValueNode node) {
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18364
diff changeset
94 return isPointerAlwaysNull(node.stamp());
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
95 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
96
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
97 /**
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18364
diff changeset
98 * Checks whether this {@link Stamp} represents a {@linkplain Stamp#isLegal() legal} pointer
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
99 * stamp whose values are known to be always null.
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
100 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
101 * @param stamp the stamp to check
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
102 * @return true if this stamp represents a legal object stamp whose values are known to be
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
103 * always null
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
104 */
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18364
diff changeset
105 public static boolean isPointerAlwaysNull(Stamp stamp) {
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18364
diff changeset
106 if (stamp instanceof AbstractPointerStamp && stamp.isLegal()) {
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18364
diff changeset
107 return ((AbstractPointerStamp) stamp).alwaysNull();
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
108 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
109 return false;
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
110 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
111
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
112 /**
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18364
diff changeset
113 * Checks whether this {@link ValueNode} represents a {@linkplain Stamp#isLegal() legal} pointer
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
114 * value which is known to never be null.
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
115 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
116 * @param node the node to check
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
117 * @return true if this node represents a legal object value which is known to never be null
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
118 */
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18364
diff changeset
119 public static boolean isPointerNonNull(ValueNode node) {
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18364
diff changeset
120 return isPointerNonNull(node.stamp());
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
121 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
122
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
123 /**
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18364
diff changeset
124 * Checks whether this {@link Stamp} represents a {@linkplain Stamp#isLegal() legal} pointer
20074
a7ee2e1f0d4e remove UnboxNodes without usages (if object is non-null)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 18839
diff changeset
125 * stamp whose values are known to never be null.
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
126 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
127 * @param stamp the stamp to check
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
128 * @return true if this stamp represents a legal object stamp whose values are known to be
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
129 * always null
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
130 */
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18364
diff changeset
131 public static boolean isPointerNonNull(Stamp stamp) {
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18364
diff changeset
132 if (stamp instanceof AbstractPointerStamp && stamp.isLegal()) {
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18364
diff changeset
133 return ((AbstractPointerStamp) stamp).nonNull();
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
134 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
135 return false;
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
136 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
137
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
138 /**
15380
10c6705dbe9a StampTool: fix typo and change "java" to "Java"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15260
diff changeset
139 * Returns the {@linkplain ResolvedJavaType Java type} this {@linkplain ValueNode} has if it is
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
140 * a {@linkplain Stamp#isLegal() legal} Object value.
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
141 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
142 * @param node the node to check
15380
10c6705dbe9a StampTool: fix typo and change "java" to "Java"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15260
diff changeset
143 * @return the Java type this value has if it is a legal Object type, null otherwise
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
144 */
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
145 public static ResolvedJavaType typeOrNull(ValueNode node) {
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
146 return typeOrNull(node.stamp());
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
147 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
148
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
149 /**
15380
10c6705dbe9a StampTool: fix typo and change "java" to "Java"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15260
diff changeset
150 * Returns the {@linkplain ResolvedJavaType Java type} this {@linkplain Stamp} has if it is a
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
151 * {@linkplain Stamp#isLegal() legal} Object stamp.
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
152 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
153 * @param stamp the stamp to check
15380
10c6705dbe9a StampTool: fix typo and change "java" to "Java"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15260
diff changeset
154 * @return the Java type this stamp has if it is a legal Object stamp, null otherwise
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
155 */
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
156 public static ResolvedJavaType typeOrNull(Stamp stamp) {
16003
83433cf49019 Fix incorrect null check in oop compression.
Roland Schatz <roland.schatz@oracle.com>
parents: 15791
diff changeset
157 if (stamp instanceof AbstractObjectStamp && stamp.isLegal()) {
83433cf49019 Fix incorrect null check in oop compression.
Roland Schatz <roland.schatz@oracle.com>
parents: 15791
diff changeset
158 return ((AbstractObjectStamp) stamp).type();
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
159 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
160 return null;
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
161 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
162
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
163 /**
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
164 * Checks whether this {@link ValueNode} represents a {@linkplain Stamp#isLegal() legal} Object
15380
10c6705dbe9a StampTool: fix typo and change "java" to "Java"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15260
diff changeset
165 * value whose Java type is known exactly. If this method returns true then the
10c6705dbe9a StampTool: fix typo and change "java" to "Java"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15260
diff changeset
166 * {@linkplain ResolvedJavaType Java type} returned by {@link #typeOrNull(ValueNode)} is the
10c6705dbe9a StampTool: fix typo and change "java" to "Java"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15260
diff changeset
167 * concrete dynamic/runtime Java type of this value.
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
168 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
169 * @param node the node to check
15380
10c6705dbe9a StampTool: fix typo and change "java" to "Java"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15260
diff changeset
170 * @return true if this node represents a legal object value whose Java type is known exactly
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
171 */
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
172 public static boolean isExactType(ValueNode node) {
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
173 return isExactType(node.stamp());
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
174 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
175
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
176 /**
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
177 * Checks whether this {@link Stamp} represents a {@linkplain Stamp#isLegal() legal} Object
15380
10c6705dbe9a StampTool: fix typo and change "java" to "Java"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15260
diff changeset
178 * stamp whose {@linkplain ResolvedJavaType Java type} is known exactly. If this method returns
10c6705dbe9a StampTool: fix typo and change "java" to "Java"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15260
diff changeset
179 * true then the Java type returned by {@link #typeOrNull(Stamp)} is the only concrete
10c6705dbe9a StampTool: fix typo and change "java" to "Java"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15260
diff changeset
180 * dynamic/runtime Java type possible for values of this stamp.
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
181 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
182 * @param stamp the stamp to check
15380
10c6705dbe9a StampTool: fix typo and change "java" to "Java"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15260
diff changeset
183 * @return true if this node represents a legal object stamp whose Java type is known exactly
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
184 */
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
185 public static boolean isExactType(Stamp stamp) {
16003
83433cf49019 Fix incorrect null check in oop compression.
Roland Schatz <roland.schatz@oracle.com>
parents: 15791
diff changeset
186 if (stamp instanceof AbstractObjectStamp && stamp.isLegal()) {
83433cf49019 Fix incorrect null check in oop compression.
Roland Schatz <roland.schatz@oracle.com>
parents: 15791
diff changeset
187 return ((AbstractObjectStamp) stamp).isExactType();
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
188 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
189 return false;
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
190 }
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
191 }