annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java @ 18364:ad3c2cacdd1a

Remove StampProvider interface.
author Roland Schatz <roland.schatz@oracle.com>
date Thu, 13 Nov 2014 15:07:10 +0100
parents 98e60bdf6d05
children ca81508f2a19
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 /*
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
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
17196
189479d72dc8 Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents: 16585
diff changeset
27 import com.oracle.graal.api.code.*;
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
28 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
29 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
30 import com.oracle.graal.nodes.*;
5657
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 /**
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
33 * 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
34 */
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
35 public class StampTool {
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
36
18364
ad3c2cacdd1a Remove StampProvider interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 17344
diff changeset
37 public static Stamp meet(Collection<? extends ValueNode> values) {
ad3c2cacdd1a Remove StampProvider interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 17344
diff changeset
38 Iterator<? extends ValueNode> iterator = values.iterator();
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
39 if (iterator.hasNext()) {
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
40 Stamp stamp = iterator.next().stamp();
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
41 while (iterator.hasNext()) {
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
42 stamp = stamp.meet(iterator.next().stamp());
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
43 }
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
44 return stamp;
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
45 } else {
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
46 return StampFactory.forVoid();
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 }
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
49
16585
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
50 public static Stamp rightShift(Stamp value, Stamp shift) {
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
51 if (value instanceof IntegerStamp && shift instanceof IntegerStamp) {
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
52 return rightShift((IntegerStamp) value, (IntegerStamp) shift);
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
53 }
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
54 return value.illegal();
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
55 }
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
56
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
57 public static Stamp rightShift(IntegerStamp value, IntegerStamp shift) {
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
58 int bits = value.getBits();
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
59 if (shift.lowerBound() == shift.upperBound()) {
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
60 int extraBits = 64 - bits;
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
61 long shiftMask = bits > 32 ? 0x3FL : 0x1FL;
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
62 long shiftCount = shift.lowerBound() & shiftMask;
17196
189479d72dc8 Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents: 16585
diff changeset
63 long defaultMask = CodeUtil.mask(bits);
16585
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
64 // shifting back and forth performs sign extension
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
65 long downMask = (value.downMask() << extraBits) >> (shiftCount + extraBits) & defaultMask;
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
66 long upMask = (value.upMask() << extraBits) >> (shiftCount + extraBits) & defaultMask;
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
67 return new IntegerStamp(bits, value.lowerBound() >> shiftCount, value.upperBound() >> shiftCount, downMask, upMask);
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
68 }
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
69 long mask = IntegerStamp.upMaskFor(bits, value.lowerBound(), value.upperBound());
17199
88012c1750a0 Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents: 17198
diff changeset
70 return IntegerStamp.stampForMask(bits, 0, mask);
16585
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
71 }
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
72
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10815
diff changeset
73 public static Stamp unsignedRightShift(Stamp value, Stamp shift) {
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10815
diff changeset
74 if (value instanceof IntegerStamp && shift instanceof IntegerStamp) {
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10815
diff changeset
75 return unsignedRightShift((IntegerStamp) value, (IntegerStamp) shift);
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10815
diff changeset
76 }
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
77 return value.illegal();
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10815
diff changeset
78 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10815
diff changeset
79
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
80 public static Stamp unsignedRightShift(IntegerStamp value, IntegerStamp shift) {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
81 int bits = value.getBits();
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
82 if (shift.lowerBound() == shift.upperBound()) {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
83 long shiftMask = bits > 32 ? 0x3FL : 0x1FL;
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
84 long shiftCount = shift.lowerBound() & shiftMask;
16585
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
85 long downMask = value.downMask() >>> shiftCount;
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
86 long upMask = value.upMask() >>> shiftCount;
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
87 if (value.lowerBound() < 0) {
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
88 return new IntegerStamp(bits, downMask, upMask, downMask, upMask);
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
89 } else {
0d3a4532a28c better stamps for RightShiftNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16452
diff changeset
90 return new IntegerStamp(bits, value.lowerBound() >>> shiftCount, value.upperBound() >>> shiftCount, downMask, upMask);
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
91 }
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
92 }
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
93 long mask = IntegerStamp.upMaskFor(bits, value.lowerBound(), value.upperBound());
17199
88012c1750a0 Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents: 17198
diff changeset
94 return IntegerStamp.stampForMask(bits, 0, mask);
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
95 }
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
96
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10815
diff changeset
97 public static Stamp leftShift(Stamp value, Stamp shift) {
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10815
diff changeset
98 if (value instanceof IntegerStamp && shift instanceof IntegerStamp) {
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10815
diff changeset
99 return leftShift((IntegerStamp) value, (IntegerStamp) shift);
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10815
diff changeset
100 }
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
101 return value.illegal();
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10815
diff changeset
102 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10815
diff changeset
103
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
104 public static Stamp leftShift(IntegerStamp value, IntegerStamp shift) {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
105 int bits = value.getBits();
17196
189479d72dc8 Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents: 16585
diff changeset
106 long defaultMask = CodeUtil.mask(bits);
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
107 if (value.upMask() == 0) {
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
108 return value;
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
109 }
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
110 int shiftBits = bits > 32 ? 6 : 5;
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
111 long shiftMask = bits > 32 ? 0x3FL : 0x1FL;
16452
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16158
diff changeset
112 if (shift.lowerBound() == shift.upperBound()) {
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16158
diff changeset
113 int shiftAmount = (int) (shift.lowerBound() & shiftMask);
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16158
diff changeset
114 if (shiftAmount == 0) {
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16158
diff changeset
115 return value;
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16158
diff changeset
116 }
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16158
diff changeset
117 // the mask of bits that will be lost or shifted into the sign bit
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16158
diff changeset
118 long removedBits = -1L << (bits - shiftAmount - 1);
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16158
diff changeset
119 if ((value.lowerBound() & removedBits) == 0 && (value.upperBound() & removedBits) == 0) {
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16158
diff changeset
120 // use a better stamp if neither lower nor upper bound can lose bits
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16158
diff changeset
121 return new IntegerStamp(bits, value.lowerBound() << shiftAmount, value.upperBound() << shiftAmount, value.downMask() << shiftAmount, value.upMask() << shiftAmount);
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16158
diff changeset
122 }
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16158
diff changeset
123 }
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
124 if ((shift.lowerBound() >>> shiftBits) == (shift.upperBound() >>> shiftBits)) {
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
125 long downMask = defaultMask;
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
126 long upMask = 0;
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
127 for (long i = shift.lowerBound(); i <= shift.upperBound(); i++) {
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
128 if (shift.contains(i)) {
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
129 downMask &= value.downMask() << (i & shiftMask);
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
130 upMask |= value.upMask() << (i & shiftMask);
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
131 }
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
132 }
17199
88012c1750a0 Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents: 17198
diff changeset
133 Stamp result = IntegerStamp.stampForMask(bits, downMask, upMask & defaultMask);
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
134 return result;
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
135 }
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
136 return value.unrestricted();
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
137 }
6313
7ac010ae8c97 Add inferStamp for a number of ConvertNode's operations
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6299
diff changeset
138
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
139 /**
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
140 * 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
141 *
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
142 * @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
143 */
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
144 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
145 IntegerStamp x = (IntegerStamp) stamp;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
146 IntegerStamp y = (IntegerStamp) stamp2;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
147 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
148 // Don't know anything.
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
149 return null;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
150 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
151 // 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
152 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
153 if (y.isPositive()) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
154 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
155 // 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
156 return null;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
157 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
158 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
159 // 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
160 return null;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
161 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
162 // 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
163 // are [c+1..-n.upperBound)].
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14863
diff changeset
164 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
165 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
166 return null;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
167 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
168 // 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
169 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
170 // 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
171 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
172 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
173 return null;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14021
diff changeset
174 }
15260
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 ValueNode} represents a {@linkplain Stamp#isLegal() legal} Object
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
178 * 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
179 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
180 * @param node the node to check
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
181 * @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
182 */
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
183 public static boolean isObjectAlwaysNull(ValueNode node) {
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
184 return isObjectAlwaysNull(node.stamp());
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
185 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
186
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
187 /**
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
188 * Checks whether this {@link Stamp} represents a {@linkplain Stamp#isLegal() legal} Object
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
189 * 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
190 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
191 * @param stamp the stamp to check
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
192 * @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
193 * always null
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
194 */
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
195 public static boolean isObjectAlwaysNull(Stamp stamp) {
16003
83433cf49019 Fix incorrect null check in oop compression.
Roland Schatz <roland.schatz@oracle.com>
parents: 15791
diff changeset
196 if (stamp instanceof AbstractObjectStamp && stamp.isLegal()) {
83433cf49019 Fix incorrect null check in oop compression.
Roland Schatz <roland.schatz@oracle.com>
parents: 15791
diff changeset
197 return ((AbstractObjectStamp) stamp).alwaysNull();
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
198 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
199 return false;
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
200 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
201
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
202 /**
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
203 * Checks whether this {@link ValueNode} represents a {@linkplain Stamp#isLegal() legal} Object
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
204 * 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
205 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
206 * @param node the node to check
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
207 * @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
208 */
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
209 public static boolean isObjectNonNull(ValueNode node) {
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
210 return isObjectNonNull(node.stamp());
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
211 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
212
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
213 /**
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
214 * Checks whether this {@link Stamp} represents a {@linkplain Stamp#isLegal() legal} Object
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
215 * stamp whose values known to be always null.
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
216 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
217 * @param stamp the stamp to check
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
218 * @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
219 * always null
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
220 */
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
221 public static boolean isObjectNonNull(Stamp stamp) {
16003
83433cf49019 Fix incorrect null check in oop compression.
Roland Schatz <roland.schatz@oracle.com>
parents: 15791
diff changeset
222 if (stamp instanceof AbstractObjectStamp && stamp.isLegal()) {
83433cf49019 Fix incorrect null check in oop compression.
Roland Schatz <roland.schatz@oracle.com>
parents: 15791
diff changeset
223 return ((AbstractObjectStamp) stamp).nonNull();
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
224 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
225 return false;
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
226 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
227
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
228 /**
15380
10c6705dbe9a StampTool: fix typo and change "java" to "Java"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15260
diff changeset
229 * 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
230 * 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
231 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
232 * @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
233 * @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
234 */
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
235 public static ResolvedJavaType typeOrNull(ValueNode node) {
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
236 return typeOrNull(node.stamp());
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
237 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
238
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
239 /**
15380
10c6705dbe9a StampTool: fix typo and change "java" to "Java"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15260
diff changeset
240 * 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
241 * {@linkplain Stamp#isLegal() legal} Object stamp.
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
242 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
243 * @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
244 * @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
245 */
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
246 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
247 if (stamp instanceof AbstractObjectStamp && stamp.isLegal()) {
83433cf49019 Fix incorrect null check in oop compression.
Roland Schatz <roland.schatz@oracle.com>
parents: 15791
diff changeset
248 return ((AbstractObjectStamp) stamp).type();
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
249 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
250 return null;
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
251 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
252
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
253 /**
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
254 * 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
255 * 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
256 * {@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
257 * 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
258 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
259 * @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
260 * @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
261 */
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
262 public static boolean isExactType(ValueNode node) {
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
263 return isExactType(node.stamp());
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
264 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
265
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
266 /**
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
267 * 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
268 * 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
269 * 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
270 * 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
271 *
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
272 * @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
273 * @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
274 */
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
275 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
276 if (stamp instanceof AbstractObjectStamp && stamp.isLegal()) {
83433cf49019 Fix incorrect null check in oop compression.
Roland Schatz <roland.schatz@oracle.com>
parents: 15791
diff changeset
277 return ((AbstractObjectStamp) stamp).isExactType();
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
278 }
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
279 return false;
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
280 }
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
281 }