Bug Summary

File:jdk/src/hotspot/share/opto/addnode.cpp
Warning:line 924, column 23
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name addnode.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mthread-model posix -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/libjvm/objs/precompiled -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D __STDC_CONSTANT_MACROS -D _GNU_SOURCE -D _REENTRANT -D LIBC=gnu -D LINUX -D VM_LITTLE_ENDIAN -D _LP64=1 -D ASSERT -D CHECK_UNHANDLED_OOPS -D TARGET_ARCH_x86 -D INCLUDE_SUFFIX_OS=_linux -D INCLUDE_SUFFIX_CPU=_x86 -D INCLUDE_SUFFIX_COMPILER=_gcc -D TARGET_COMPILER_gcc -D AMD64 -D HOTSPOT_LIB_ARCH="amd64" -D COMPILER1 -D COMPILER2 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc/adfiles -I /home/daniel/Projects/java/jdk/src/hotspot/share -I /home/daniel/Projects/java/jdk/src/hotspot/os/linux -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix -I /home/daniel/Projects/java/jdk/src/hotspot/cpu/x86 -I /home/daniel/Projects/java/jdk/src/hotspot/os_cpu/linux_x86 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc -I /home/daniel/Projects/java/jdk/src/hotspot/share/precompiled -I /home/daniel/Projects/java/jdk/src/hotspot/share/include -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix/include -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base/linux -I /home/daniel/Projects/java/jdk/src/java.base/share/native/libjimage -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc/adfiles -I /home/daniel/Projects/java/jdk/src/hotspot/share -I /home/daniel/Projects/java/jdk/src/hotspot/os/linux -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix -I /home/daniel/Projects/java/jdk/src/hotspot/cpu/x86 -I /home/daniel/Projects/java/jdk/src/hotspot/os_cpu/linux_x86 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc -D _FORTIFY_SOURCE=2 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-format-zero-length -Wno-unused-parameter -Wno-unused -Wno-parentheses -Wno-comment -Wno-unknown-pragmas -Wno-address -Wno-delete-non-virtual-dtor -Wno-char-subscripts -Wno-array-bounds -Wno-int-in-bool-context -Wno-ignored-qualifiers -Wno-missing-field-initializers -Wno-implicit-fallthrough -Wno-empty-body -Wno-strict-overflow -Wno-sequence-point -Wno-maybe-uninitialized -Wno-misleading-indentation -Wno-cast-function-type -Wno-shift-negative-value -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /home/daniel/Projects/java/jdk/make/hotspot -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -stack-protector 1 -fno-rtti -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /home/daniel/Projects/java/scan/2021-12-21-193737-8510-1 -x c++ /home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp

/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp

1/*
2 * Copyright (c) 1997, 2021, 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 */
24
25#include "precompiled.hpp"
26#include "memory/allocation.inline.hpp"
27#include "opto/addnode.hpp"
28#include "opto/castnode.hpp"
29#include "opto/cfgnode.hpp"
30#include "opto/connode.hpp"
31#include "opto/machnode.hpp"
32#include "opto/movenode.hpp"
33#include "opto/mulnode.hpp"
34#include "opto/phaseX.hpp"
35#include "opto/subnode.hpp"
36
37// Portions of code courtesy of Clifford Click
38
39// Classic Add functionality. This covers all the usual 'add' behaviors for
40// an algebraic ring. Add-integer, add-float, add-double, and binary-or are
41// all inherited from this class. The various identity values are supplied
42// by virtual functions.
43
44
45//=============================================================================
46//------------------------------hash-------------------------------------------
47// Hash function over AddNodes. Needs to be commutative; i.e., I swap
48// (commute) inputs to AddNodes willy-nilly so the hash function must return
49// the same value in the presence of edge swapping.
50uint AddNode::hash() const {
51 return (uintptr_t)in(1) + (uintptr_t)in(2) + Opcode();
52}
53
54//------------------------------Identity---------------------------------------
55// If either input is a constant 0, return the other input.
56Node* AddNode::Identity(PhaseGVN* phase) {
57 const Type *zero = add_id(); // The additive identity
58 if( phase->type( in(1) )->higher_equal( zero ) ) return in(2);
59 if( phase->type( in(2) )->higher_equal( zero ) ) return in(1);
60 return this;
61}
62
63//------------------------------commute----------------------------------------
64// Commute operands to move loads and constants to the right.
65static bool commute(PhaseGVN* phase, Node* add) {
66 Node *in1 = add->in(1);
67 Node *in2 = add->in(2);
68
69 // convert "max(a,b) + min(a,b)" into "a+b".
70 if ((in1->Opcode() == add->as_Add()->max_opcode() && in2->Opcode() == add->as_Add()->min_opcode())
71 || (in1->Opcode() == add->as_Add()->min_opcode() && in2->Opcode() == add->as_Add()->max_opcode())) {
72 Node *in11 = in1->in(1);
73 Node *in12 = in1->in(2);
74
75 Node *in21 = in2->in(1);
76 Node *in22 = in2->in(2);
77
78 if ((in11 == in21 && in12 == in22) ||
79 (in11 == in22 && in12 == in21)) {
80 add->set_req(1, in11);
81 add->set_req(2, in12);
82 PhaseIterGVN* igvn = phase->is_IterGVN();
83 if (igvn) {
84 igvn->_worklist.push(in1);
85 igvn->_worklist.push(in2);
86 }
87 return true;
88 }
89 }
90
91 bool con_left = phase->type(in1)->singleton();
92 bool con_right = phase->type(in2)->singleton();
93
94 // Convert "1+x" into "x+1".
95 // Right is a constant; leave it
96 if( con_right ) return false;
97 // Left is a constant; move it right.
98 if( con_left ) {
99 add->swap_edges(1, 2);
100 return true;
101 }
102
103 // Convert "Load+x" into "x+Load".
104 // Now check for loads
105 if (in2->is_Load()) {
106 if (!in1->is_Load()) {
107 // already x+Load to return
108 return false;
109 }
110 // both are loads, so fall through to sort inputs by idx
111 } else if( in1->is_Load() ) {
112 // Left is a Load and Right is not; move it right.
113 add->swap_edges(1, 2);
114 return true;
115 }
116
117 PhiNode *phi;
118 // Check for tight loop increments: Loop-phi of Add of loop-phi
119 if (in1->is_Phi() && (phi = in1->as_Phi()) && phi->region()->is_Loop() && phi->in(2) == add)
120 return false;
121 if (in2->is_Phi() && (phi = in2->as_Phi()) && phi->region()->is_Loop() && phi->in(2) == add) {
122 add->swap_edges(1, 2);
123 return true;
124 }
125
126 // Otherwise, sort inputs (commutativity) to help value numbering.
127 if( in1->_idx > in2->_idx ) {
128 add->swap_edges(1, 2);
129 return true;
130 }
131 return false;
132}
133
134//------------------------------Idealize---------------------------------------
135// If we get here, we assume we are associative!
136Node *AddNode::Ideal(PhaseGVN *phase, bool can_reshape) {
137 const Type *t1 = phase->type(in(1));
138 const Type *t2 = phase->type(in(2));
139 bool con_left = t1->singleton();
140 bool con_right = t2->singleton();
141
142 // Check for commutative operation desired
143 if (commute(phase, this)) return this;
144
145 AddNode *progress = NULL__null; // Progress flag
146
147 // Convert "(x+1)+2" into "x+(1+2)". If the right input is a
148 // constant, and the left input is an add of a constant, flatten the
149 // expression tree.
150 Node *add1 = in(1);
151 Node *add2 = in(2);
152 int add1_op = add1->Opcode();
153 int this_op = Opcode();
154 if (con_right && t2 != Type::TOP && // Right input is a constant?
155 add1_op == this_op) { // Left input is an Add?
156
157 // Type of left _in right input
158 const Type *t12 = phase->type(add1->in(2));
159 if (t12->singleton() && t12 != Type::TOP) { // Left input is an add of a constant?
160 // Check for rare case of closed data cycle which can happen inside
161 // unreachable loops. In these cases the computation is undefined.
162#ifdef ASSERT1
163 Node *add11 = add1->in(1);
164 int add11_op = add11->Opcode();
165 if ((add1 == add1->in(1))
166 || (add11_op == this_op && add11->in(1) == add1)) {
167 assert(false, "dead loop in AddNode::Ideal")do { if (!(false)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 167, "assert(" "false" ") failed", "dead loop in AddNode::Ideal"
); ::breakpoint(); } } while (0)
;
168 }
169#endif
170 // The Add of the flattened expression
171 Node *x1 = add1->in(1);
172 Node *x2 = phase->makecon(add1->as_Add()->add_ring(t2, t12));
173 set_req_X(2, x2, phase);
174 set_req_X(1, x1, phase);
175 progress = this; // Made progress
176 add1 = in(1);
177 add1_op = add1->Opcode();
178 }
179 }
180
181 // Convert "(x+1)+y" into "(x+y)+1". Push constants down the expression tree.
182 if (add1_op == this_op && !con_right) {
183 Node *a12 = add1->in(2);
184 const Type *t12 = phase->type( a12 );
185 if (t12->singleton() && t12 != Type::TOP && (add1 != add1->in(1)) &&
186 !(add1->in(1)->is_Phi() && (add1->in(1)->as_Phi()->is_tripcount(T_INT) || add1->in(1)->as_Phi()->is_tripcount(T_LONG)))) {
187 assert(add1->in(1) != this, "dead loop in AddNode::Ideal")do { if (!(add1->in(1) != this)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 187, "assert(" "add1->in(1) != this" ") failed", "dead loop in AddNode::Ideal"
); ::breakpoint(); } } while (0)
;
188 add2 = add1->clone();
189 add2->set_req(2, in(2));
190 add2 = phase->transform(add2);
191 set_req_X(1, add2, phase);
192 set_req_X(2, a12, phase);
193 progress = this;
194 add2 = a12;
195 }
196 }
197
198 // Convert "x+(y+1)" into "(x+y)+1". Push constants down the expression tree.
199 int add2_op = add2->Opcode();
200 if (add2_op == this_op && !con_left) {
201 Node *a22 = add2->in(2);
202 const Type *t22 = phase->type( a22 );
203 if (t22->singleton() && t22 != Type::TOP && (add2 != add2->in(1)) &&
204 !(add2->in(1)->is_Phi() && (add2->in(1)->as_Phi()->is_tripcount(T_INT) || add2->in(1)->as_Phi()->is_tripcount(T_LONG)))) {
205 assert(add2->in(1) != this, "dead loop in AddNode::Ideal")do { if (!(add2->in(1) != this)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 205, "assert(" "add2->in(1) != this" ") failed", "dead loop in AddNode::Ideal"
); ::breakpoint(); } } while (0)
;
206 Node *addx = add2->clone();
207 addx->set_req(1, in(1));
208 addx->set_req(2, add2->in(1));
209 addx = phase->transform(addx);
210 set_req_X(1, addx, phase);
211 set_req_X(2, a22, phase);
212 progress = this;
213 }
214 }
215
216 return progress;
217}
218
219//------------------------------Value-----------------------------------------
220// An add node sums it's two _in. If one input is an RSD, we must mixin
221// the other input's symbols.
222const Type* AddNode::Value(PhaseGVN* phase) const {
223 // Either input is TOP ==> the result is TOP
224 const Type *t1 = phase->type( in(1) );
225 const Type *t2 = phase->type( in(2) );
7
't2' initialized here
226 if( t1 == Type::TOP ) return Type::TOP;
8
Assuming 't1' is not equal to 'TOP'
9
Taking false branch
227 if( t2 == Type::TOP ) return Type::TOP;
10
Assuming 't2' is not equal to 'TOP'
11
Taking false branch
228
229 // Either input is BOTTOM ==> the result is the local BOTTOM
230 const Type *bot = bottom_type();
231 if( (t1 == bot) || (t2 == bot) ||
12
Assuming 't1' is not equal to 'bot'
13
Assuming 't2' is not equal to 'bot'
16
Taking false branch
232 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
14
Assuming 't1' is not equal to 'BOTTOM'
15
Assuming 't2' is not equal to 'BOTTOM'
233 return bot;
234
235 // Check for an addition involving the additive identity
236 const Type *tadd = add_of_identity( t1, t2 );
17
Calling 'AddNode::add_of_identity'
24
Returning from 'AddNode::add_of_identity'
237 if( tadd ) return tadd;
25
Assuming 'tadd' is null
26
Taking false branch
238
239 return add_ring(t1,t2); // Local flavor of type addition
27
Passing null pointer value via 2nd parameter 't1'
28
Calling 'XorINode::add_ring'
240}
241
242//------------------------------add_identity-----------------------------------
243// Check for addition of the identity
244const Type *AddNode::add_of_identity( const Type *t1, const Type *t2 ) const {
245 const Type *zero = add_id(); // The additive identity
246 if( t1->higher_equal( zero ) ) return t2;
18
Calling 'Type::higher_equal'
21
Returning from 'Type::higher_equal'
22
Taking true branch
23
Returning pointer (loaded from 't2'), which participates in a condition later
247 if( t2->higher_equal( zero ) ) return t1;
248
249 return NULL__null;
250}
251
252AddNode* AddNode::make(Node* in1, Node* in2, BasicType bt) {
253 switch (bt) {
254 case T_INT:
255 return new AddINode(in1, in2);
256 case T_LONG:
257 return new AddLNode(in1, in2);
258 default:
259 fatal("Not implemented for %s", type2name(bt))do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 259, "Not implemented for %s", type2name(bt)); ::breakpoint
(); } while (0)
;
260 }
261 return NULL__null;
262}
263
264//=============================================================================
265//------------------------------Idealize---------------------------------------
266Node* AddNode::IdealIL(PhaseGVN* phase, bool can_reshape, BasicType bt) {
267 Node* in1 = in(1);
268 Node* in2 = in(2);
269 int op1 = in1->Opcode();
270 int op2 = in2->Opcode();
271 // Fold (con1-x)+con2 into (con1+con2)-x
272 if (op1 == Op_Add(bt) && op2 == Op_Sub(bt)) {
273 // Swap edges to try optimizations below
274 in1 = in2;
275 in2 = in(1);
276 op1 = op2;
277 op2 = in2->Opcode();
278 }
279 if (op1 == Op_Sub(bt)) {
280 const Type* t_sub1 = phase->type(in1->in(1));
281 const Type* t_2 = phase->type(in2 );
282 if (t_sub1->singleton() && t_2->singleton() && t_sub1 != Type::TOP && t_2 != Type::TOP) {
283 return SubNode::make(phase->makecon(add_ring(t_sub1, t_2)), in1->in(2), bt);
284 }
285 // Convert "(a-b)+(c-d)" into "(a+c)-(b+d)"
286 if (op2 == Op_Sub(bt)) {
287 // Check for dead cycle: d = (a-b)+(c-d)
288 assert( in1->in(2) != this && in2->in(2) != this,do { if (!(in1->in(2) != this && in2->in(2) != this
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 289, "assert(" "in1->in(2) != this && in2->in(2) != this"
") failed", "dead loop in AddINode::Ideal"); ::breakpoint();
} } while (0)
289 "dead loop in AddINode::Ideal" )do { if (!(in1->in(2) != this && in2->in(2) != this
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 289, "assert(" "in1->in(2) != this && in2->in(2) != this"
") failed", "dead loop in AddINode::Ideal"); ::breakpoint();
} } while (0)
;
290 Node* sub = SubNode::make(NULL__null, NULL__null, bt);
291 sub->init_req(1, phase->transform(AddNode::make(in1->in(1), in2->in(1), bt)));
292 sub->init_req(2, phase->transform(AddNode::make(in1->in(2), in2->in(2), bt)));
293 return sub;
294 }
295 // Convert "(a-b)+(b+c)" into "(a+c)"
296 if (op2 == Op_Add(bt) && in1->in(2) == in2->in(1)) {
297 assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddINode::Ideal/AddLNode::Ideal")do { if (!(in1->in(1) != this && in2->in(2) != this
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 297, "assert(" "in1->in(1) != this && in2->in(2) != this"
") failed", "dead loop in AddINode::Ideal/AddLNode::Ideal");
::breakpoint(); } } while (0)
;
298 return AddNode::make(in1->in(1), in2->in(2), bt);
299 }
300 // Convert "(a-b)+(c+b)" into "(a+c)"
301 if (op2 == Op_Add(bt) && in1->in(2) == in2->in(2)) {
302 assert(in1->in(1) != this && in2->in(1) != this,"dead loop in AddINode::Ideal/AddLNode::Ideal")do { if (!(in1->in(1) != this && in2->in(1) != this
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 302, "assert(" "in1->in(1) != this && in2->in(1) != this"
") failed", "dead loop in AddINode::Ideal/AddLNode::Ideal");
::breakpoint(); } } while (0)
;
303 return AddNode::make(in1->in(1), in2->in(1), bt);
304 }
305 }
306
307 // Convert "x+(0-y)" into "(x-y)"
308 if (op2 == Op_Sub(bt) && phase->type(in2->in(1)) == TypeInteger::zero(bt)) {
309 return SubNode::make(in1, in2->in(2), bt);
310 }
311
312 // Convert "(0-y)+x" into "(x-y)"
313 if (op1 == Op_Sub(bt) && phase->type(in1->in(1)) == TypeInteger::zero(bt)) {
314 return SubNode::make(in2, in1->in(2), bt);
315 }
316
317 // Associative
318 if (op1 == Op_Mul(bt) && op2 == Op_Mul(bt)) {
319 Node* add_in1 = NULL__null;
320 Node* add_in2 = NULL__null;
321 Node* mul_in = NULL__null;
322
323 if (in1->in(1) == in2->in(1)) {
324 // Convert "a*b+a*c into a*(b+c)
325 add_in1 = in1->in(2);
326 add_in2 = in2->in(2);
327 mul_in = in1->in(1);
328 } else if (in1->in(2) == in2->in(1)) {
329 // Convert a*b+b*c into b*(a+c)
330 add_in1 = in1->in(1);
331 add_in2 = in2->in(2);
332 mul_in = in1->in(2);
333 } else if (in1->in(2) == in2->in(2)) {
334 // Convert a*c+b*c into (a+b)*c
335 add_in1 = in1->in(1);
336 add_in2 = in2->in(1);
337 mul_in = in1->in(2);
338 } else if (in1->in(1) == in2->in(2)) {
339 // Convert a*b+c*a into a*(b+c)
340 add_in1 = in1->in(2);
341 add_in2 = in2->in(1);
342 mul_in = in1->in(1);
343 }
344
345 if (mul_in != NULL__null) {
346 Node* add = phase->transform(AddNode::make(add_in1, add_in2, bt));
347 return MulNode::make(mul_in, add, bt);
348 }
349 }
350
351 // Convert (x >>> rshift) + (x << lshift) into RotateRight(x, rshift)
352 if (Matcher::match_rule_supported(Op_RotateRight) &&
353 ((op1 == Op_URShift(bt) && op2 == Op_LShift(bt)) || (op1 == Op_LShift(bt) && op2 == Op_URShift(bt))) &&
354 in1->in(1) != NULL__null && in1->in(1) == in2->in(1)) {
355 Node* rshift = op1 == Op_URShift(bt) ? in1->in(2) : in2->in(2);
356 Node* lshift = op1 == Op_URShift(bt) ? in2->in(2) : in1->in(2);
357 if (rshift != NULL__null && lshift != NULL__null) {
358 const TypeInt* rshift_t = phase->type(rshift)->isa_int();
359 const TypeInt* lshift_t = phase->type(lshift)->isa_int();
360 int bits = bt == T_INT ? 32 : 64;
361 int mask = bt == T_INT ? 0x1F : 0x3F;
362 if (lshift_t != NULL__null && lshift_t->is_con() &&
363 rshift_t != NULL__null && rshift_t->is_con() &&
364 ((lshift_t->get_con() & mask) == (bits - (rshift_t->get_con() & mask)))) {
365 return new RotateRightNode(in1->in(1), phase->intcon(rshift_t->get_con() & mask), TypeInteger::bottom(bt));
366 }
367 }
368 }
369
370 // Convert (~x+1) into -x. Note there isn't a bitwise not bytecode,
371 // "~x" would typically represented as "x^(-1)", so (~x+1) will
372 // be (x^(-1))+1.
373 if (op1 == Op_Xor(bt) && phase->type(in2) == TypeInteger::one(bt) &&
374 phase->type(in1->in(2)) == TypeInteger::minus_1(bt)) {
375 return SubNode::make(phase->makecon(TypeInteger::zero(bt)), in1->in(1), bt);
376 }
377 return AddNode::Ideal(phase, can_reshape);
378}
379
380
381Node* AddINode::Ideal(PhaseGVN* phase, bool can_reshape) {
382 Node* in1 = in(1);
383 Node* in2 = in(2);
384 int op1 = in1->Opcode();
385 int op2 = in2->Opcode();
386
387 // Convert (x>>>z)+y into (x+(y<<z))>>>z for small constant z and y.
388 // Helps with array allocation math constant folding
389 // See 4790063:
390 // Unrestricted transformation is unsafe for some runtime values of 'x'
391 // ( x == 0, z == 1, y == -1 ) fails
392 // ( x == -5, z == 1, y == 1 ) fails
393 // Transform works for small z and small negative y when the addition
394 // (x + (y << z)) does not cross zero.
395 // Implement support for negative y and (x >= -(y << z))
396 // Have not observed cases where type information exists to support
397 // positive y and (x <= -(y << z))
398 if (op1 == Op_URShiftI && op2 == Op_ConI &&
399 in1->in(2)->Opcode() == Op_ConI) {
400 jint z = phase->type(in1->in(2))->is_int()->get_con() & 0x1f; // only least significant 5 bits matter
401 jint y = phase->type(in2)->is_int()->get_con();
402
403 if (z < 5 && -5 < y && y < 0) {
404 const Type* t_in11 = phase->type(in1->in(1));
405 if( t_in11 != Type::TOP && (t_in11->is_int()->_lo >= -(y << z))) {
406 Node* a = phase->transform(new AddINode( in1->in(1), phase->intcon(y<<z)));
407 return new URShiftINode(a, in1->in(2));
408 }
409 }
410 }
411
412 return AddNode::IdealIL(phase, can_reshape, T_INT);
413}
414
415
416//------------------------------Identity---------------------------------------
417// Fold (x-y)+y OR y+(x-y) into x
418Node* AddINode::Identity(PhaseGVN* phase) {
419 if (in(1)->Opcode() == Op_SubI && in(1)->in(2) == in(2)) {
420 return in(1)->in(1);
421 } else if (in(2)->Opcode() == Op_SubI && in(2)->in(2) == in(1)) {
422 return in(2)->in(1);
423 }
424 return AddNode::Identity(phase);
425}
426
427
428//------------------------------add_ring---------------------------------------
429// Supplied function returns the sum of the inputs. Guaranteed never
430// to be passed a TOP or BOTTOM type, these are filtered out by
431// pre-check.
432const Type *AddINode::add_ring( const Type *t0, const Type *t1 ) const {
433 const TypeInt *r0 = t0->is_int(); // Handy access
434 const TypeInt *r1 = t1->is_int();
435 int lo = java_add(r0->_lo, r1->_lo);
436 int hi = java_add(r0->_hi, r1->_hi);
437 if( !(r0->is_con() && r1->is_con()) ) {
438 // Not both constants, compute approximate result
439 if( (r0->_lo & r1->_lo) < 0 && lo >= 0 ) {
440 lo = min_jint; hi = max_jint; // Underflow on the low side
441 }
442 if( (~(r0->_hi | r1->_hi)) < 0 && hi < 0 ) {
443 lo = min_jint; hi = max_jint; // Overflow on the high side
444 }
445 if( lo > hi ) { // Handle overflow
446 lo = min_jint; hi = max_jint;
447 }
448 } else {
449 // both constants, compute precise result using 'lo' and 'hi'
450 // Semantics define overflow and underflow for integer addition
451 // as expected. In particular: 0x80000000 + 0x80000000 --> 0x0
452 }
453 return TypeInt::make( lo, hi, MAX2(r0->_widen,r1->_widen) );
454}
455
456
457//=============================================================================
458//------------------------------Idealize---------------------------------------
459Node* AddLNode::Ideal(PhaseGVN* phase, bool can_reshape) {
460 return AddNode::IdealIL(phase, can_reshape, T_LONG);
461}
462
463
464//------------------------------Identity---------------------------------------
465// Fold (x-y)+y OR y+(x-y) into x
466Node* AddLNode::Identity(PhaseGVN* phase) {
467 if (in(1)->Opcode() == Op_SubL && in(1)->in(2) == in(2)) {
468 return in(1)->in(1);
469 } else if (in(2)->Opcode() == Op_SubL && in(2)->in(2) == in(1)) {
470 return in(2)->in(1);
471 }
472 return AddNode::Identity(phase);
473}
474
475
476//------------------------------add_ring---------------------------------------
477// Supplied function returns the sum of the inputs. Guaranteed never
478// to be passed a TOP or BOTTOM type, these are filtered out by
479// pre-check.
480const Type *AddLNode::add_ring( const Type *t0, const Type *t1 ) const {
481 const TypeLong *r0 = t0->is_long(); // Handy access
482 const TypeLong *r1 = t1->is_long();
483 jlong lo = java_add(r0->_lo, r1->_lo);
484 jlong hi = java_add(r0->_hi, r1->_hi);
485 if( !(r0->is_con() && r1->is_con()) ) {
486 // Not both constants, compute approximate result
487 if( (r0->_lo & r1->_lo) < 0 && lo >= 0 ) {
488 lo =min_jlong; hi = max_jlong; // Underflow on the low side
489 }
490 if( (~(r0->_hi | r1->_hi)) < 0 && hi < 0 ) {
491 lo = min_jlong; hi = max_jlong; // Overflow on the high side
492 }
493 if( lo > hi ) { // Handle overflow
494 lo = min_jlong; hi = max_jlong;
495 }
496 } else {
497 // both constants, compute precise result using 'lo' and 'hi'
498 // Semantics define overflow and underflow for integer addition
499 // as expected. In particular: 0x80000000 + 0x80000000 --> 0x0
500 }
501 return TypeLong::make( lo, hi, MAX2(r0->_widen,r1->_widen) );
502}
503
504
505//=============================================================================
506//------------------------------add_of_identity--------------------------------
507// Check for addition of the identity
508const Type *AddFNode::add_of_identity( const Type *t1, const Type *t2 ) const {
509 // x ADD 0 should return x unless 'x' is a -zero
510 //
511 // const Type *zero = add_id(); // The additive identity
512 // jfloat f1 = t1->getf();
513 // jfloat f2 = t2->getf();
514 //
515 // if( t1->higher_equal( zero ) ) return t2;
516 // if( t2->higher_equal( zero ) ) return t1;
517
518 return NULL__null;
519}
520
521//------------------------------add_ring---------------------------------------
522// Supplied function returns the sum of the inputs.
523// This also type-checks the inputs for sanity. Guaranteed never to
524// be passed a TOP or BOTTOM type, these are filtered out by pre-check.
525const Type *AddFNode::add_ring( const Type *t0, const Type *t1 ) const {
526 // We must be adding 2 float constants.
527 return TypeF::make( t0->getf() + t1->getf() );
528}
529
530//------------------------------Ideal------------------------------------------
531Node *AddFNode::Ideal(PhaseGVN *phase, bool can_reshape) {
532 // Floating point additions are not associative because of boundary conditions (infinity)
533 return commute(phase, this) ? this : NULL__null;
534}
535
536
537//=============================================================================
538//------------------------------add_of_identity--------------------------------
539// Check for addition of the identity
540const Type *AddDNode::add_of_identity( const Type *t1, const Type *t2 ) const {
541 // x ADD 0 should return x unless 'x' is a -zero
542 //
543 // const Type *zero = add_id(); // The additive identity
544 // jfloat f1 = t1->getf();
545 // jfloat f2 = t2->getf();
546 //
547 // if( t1->higher_equal( zero ) ) return t2;
548 // if( t2->higher_equal( zero ) ) return t1;
549
550 return NULL__null;
551}
552//------------------------------add_ring---------------------------------------
553// Supplied function returns the sum of the inputs.
554// This also type-checks the inputs for sanity. Guaranteed never to
555// be passed a TOP or BOTTOM type, these are filtered out by pre-check.
556const Type *AddDNode::add_ring( const Type *t0, const Type *t1 ) const {
557 // We must be adding 2 double constants.
558 return TypeD::make( t0->getd() + t1->getd() );
559}
560
561//------------------------------Ideal------------------------------------------
562Node *AddDNode::Ideal(PhaseGVN *phase, bool can_reshape) {
563 // Floating point additions are not associative because of boundary conditions (infinity)
564 return commute(phase, this) ? this : NULL__null;
565}
566
567
568//=============================================================================
569//------------------------------Identity---------------------------------------
570// If one input is a constant 0, return the other input.
571Node* AddPNode::Identity(PhaseGVN* phase) {
572 return ( phase->type( in(Offset) )->higher_equal( TypeX_ZEROTypeLong::ZERO ) ) ? in(Address) : this;
573}
574
575//------------------------------Idealize---------------------------------------
576Node *AddPNode::Ideal(PhaseGVN *phase, bool can_reshape) {
577 // Bail out if dead inputs
578 if( phase->type( in(Address) ) == Type::TOP ) return NULL__null;
579
580 // If the left input is an add of a constant, flatten the expression tree.
581 const Node *n = in(Address);
582 if (n->is_AddP() && n->in(Base) == in(Base)) {
583 const AddPNode *addp = n->as_AddP(); // Left input is an AddP
584 assert( !addp->in(Address)->is_AddP() ||do { if (!(!addp->in(Address)->is_AddP() || addp->in
(Address)->as_AddP() != addp)) { (*g_assert_poison) = 'X';
; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 586, "assert(" "!addp->in(Address)->is_AddP() || addp->in(Address)->as_AddP() != addp"
") failed", "dead loop in AddPNode::Ideal"); ::breakpoint();
} } while (0)
585 addp->in(Address)->as_AddP() != addp,do { if (!(!addp->in(Address)->is_AddP() || addp->in
(Address)->as_AddP() != addp)) { (*g_assert_poison) = 'X';
; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 586, "assert(" "!addp->in(Address)->is_AddP() || addp->in(Address)->as_AddP() != addp"
") failed", "dead loop in AddPNode::Ideal"); ::breakpoint();
} } while (0)
586 "dead loop in AddPNode::Ideal" )do { if (!(!addp->in(Address)->is_AddP() || addp->in
(Address)->as_AddP() != addp)) { (*g_assert_poison) = 'X';
; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 586, "assert(" "!addp->in(Address)->is_AddP() || addp->in(Address)->as_AddP() != addp"
") failed", "dead loop in AddPNode::Ideal"); ::breakpoint();
} } while (0)
;
587 // Type of left input's right input
588 const Type *t = phase->type( addp->in(Offset) );
589 if( t == Type::TOP ) return NULL__null;
590 const TypeXTypeLong *t12 = t->is_intptr_tis_long();
591 if( t12->is_con() ) { // Left input is an add of a constant?
592 // If the right input is a constant, combine constants
593 const Type *temp_t2 = phase->type( in(Offset) );
594 if( temp_t2 == Type::TOP ) return NULL__null;
595 const TypeXTypeLong *t2 = temp_t2->is_intptr_tis_long();
596 Node* address;
597 Node* offset;
598 if( t2->is_con() ) {
599 // The Add of the flattened expression
600 address = addp->in(Address);
601 offset = phase->MakeConXlongcon(t2->get_con() + t12->get_con());
602 } else {
603 // Else move the constant to the right. ((A+con)+B) into ((A+B)+con)
604 address = phase->transform(new AddPNode(in(Base),addp->in(Address),in(Offset)));
605 offset = addp->in(Offset);
606 }
607 set_req_X(Address, address, phase);
608 set_req_X(Offset, offset, phase);
609 return this;
610 }
611 }
612
613 // Raw pointers?
614 if( in(Base)->bottom_type() == Type::TOP ) {
615 // If this is a NULL+long form (from unsafe accesses), switch to a rawptr.
616 if (phase->type(in(Address)) == TypePtr::NULL_PTR) {
617 Node* offset = in(Offset);
618 return new CastX2PNode(offset);
619 }
620 }
621
622 // If the right is an add of a constant, push the offset down.
623 // Convert: (ptr + (offset+con)) into (ptr+offset)+con.
624 // The idea is to merge array_base+scaled_index groups together,
625 // and only have different constant offsets from the same base.
626 const Node *add = in(Offset);
627 if( add->Opcode() == Op_AddXOp_AddL && add->in(1) != add ) {
628 const Type *t22 = phase->type( add->in(2) );
629 if( t22->singleton() && (t22 != Type::TOP) ) { // Right input is an add of a constant?
630 set_req(Address, phase->transform(new AddPNode(in(Base),in(Address),add->in(1))));
631 set_req(Offset, add->in(2));
632 PhaseIterGVN* igvn = phase->is_IterGVN();
633 if (add->outcnt() == 0 && igvn) {
634 // add disconnected.
635 igvn->_worklist.push((Node*)add);
636 }
637 return this; // Made progress
638 }
639 }
640
641 return NULL__null; // No progress
642}
643
644//------------------------------bottom_type------------------------------------
645// Bottom-type is the pointer-type with unknown offset.
646const Type *AddPNode::bottom_type() const {
647 if (in(Address) == NULL__null) return TypePtr::BOTTOM;
648 const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
649 if( !tp ) return Type::TOP; // TOP input means TOP output
650 assert( in(Offset)->Opcode() != Op_ConP, "" )do { if (!(in(Offset)->Opcode() != Op_ConP)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 650, "assert(" "in(Offset)->Opcode() != Op_ConP" ") failed"
, ""); ::breakpoint(); } } while (0)
;
651 const Type *t = in(Offset)->bottom_type();
652 if( t == Type::TOP )
653 return tp->add_offset(Type::OffsetTop);
654 const TypeXTypeLong *tx = t->is_intptr_tis_long();
655 intptr_t txoffset = Type::OffsetBot;
656 if (tx->is_con()) { // Left input is an add of a constant?
657 txoffset = tx->get_con();
658 }
659 return tp->add_offset(txoffset);
660}
661
662//------------------------------Value------------------------------------------
663const Type* AddPNode::Value(PhaseGVN* phase) const {
664 // Either input is TOP ==> the result is TOP
665 const Type *t1 = phase->type( in(Address) );
666 const Type *t2 = phase->type( in(Offset) );
667 if( t1 == Type::TOP ) return Type::TOP;
668 if( t2 == Type::TOP ) return Type::TOP;
669
670 // Left input is a pointer
671 const TypePtr *p1 = t1->isa_ptr();
672 // Right input is an int
673 const TypeXTypeLong *p2 = t2->is_intptr_tis_long();
674 // Add 'em
675 intptr_t p2offset = Type::OffsetBot;
676 if (p2->is_con()) { // Left input is an add of a constant?
677 p2offset = p2->get_con();
678 }
679 return p1->add_offset(p2offset);
680}
681
682//------------------------Ideal_base_and_offset--------------------------------
683// Split an oop pointer into a base and offset.
684// (The offset might be Type::OffsetBot in the case of an array.)
685// Return the base, or NULL if failure.
686Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseTransform* phase,
687 // second return value:
688 intptr_t& offset) {
689 if (ptr->is_AddP()) {
690 Node* base = ptr->in(AddPNode::Base);
691 Node* addr = ptr->in(AddPNode::Address);
692 Node* offs = ptr->in(AddPNode::Offset);
693 if (base == addr || base->is_top()) {
694 offset = phase->find_intptr_t_confind_long_con(offs, Type::OffsetBot);
695 if (offset != Type::OffsetBot) {
696 return addr;
697 }
698 }
699 }
700 offset = Type::OffsetBot;
701 return NULL__null;
702}
703
704//------------------------------unpack_offsets----------------------------------
705// Collect the AddP offset values into the elements array, giving up
706// if there are more than length.
707int AddPNode::unpack_offsets(Node* elements[], int length) {
708 int count = 0;
709 Node* addr = this;
710 Node* base = addr->in(AddPNode::Base);
711 while (addr->is_AddP()) {
712 if (addr->in(AddPNode::Base) != base) {
713 // give up
714 return -1;
715 }
716 elements[count++] = addr->in(AddPNode::Offset);
717 if (count == length) {
718 // give up
719 return -1;
720 }
721 addr = addr->in(AddPNode::Address);
722 }
723 if (addr != base) {
724 return -1;
725 }
726 return count;
727}
728
729//------------------------------match_edge-------------------------------------
730// Do we Match on this edge index or not? Do not match base pointer edge
731uint AddPNode::match_edge(uint idx) const {
732 return idx > Base;
733}
734
735//=============================================================================
736//------------------------------Identity---------------------------------------
737Node* OrINode::Identity(PhaseGVN* phase) {
738 // x | x => x
739 if (in(1) == in(2)) {
740 return in(1);
741 }
742
743 return AddNode::Identity(phase);
744}
745
746// Find shift value for Integer or Long OR.
747Node* rotate_shift(PhaseGVN* phase, Node* lshift, Node* rshift, int mask) {
748 // val << norm_con_shift | val >> ({32|64} - norm_con_shift) => rotate_left val, norm_con_shift
749 const TypeInt* lshift_t = phase->type(lshift)->isa_int();
750 const TypeInt* rshift_t = phase->type(rshift)->isa_int();
751 if (lshift_t != NULL__null && lshift_t->is_con() &&
752 rshift_t != NULL__null && rshift_t->is_con() &&
753 ((lshift_t->get_con() & mask) == ((mask + 1) - (rshift_t->get_con() & mask)))) {
754 return phase->intcon(lshift_t->get_con() & mask);
755 }
756 // val << var_shift | val >> ({0|32|64} - var_shift) => rotate_left val, var_shift
757 if (rshift->Opcode() == Op_SubI && rshift->in(2) == lshift && rshift->in(1)->is_Con()){
758 const TypeInt* shift_t = phase->type(rshift->in(1))->isa_int();
759 if (shift_t != NULL__null && shift_t->is_con() &&
760 (shift_t->get_con() == 0 || shift_t->get_con() == (mask + 1))) {
761 return lshift;
762 }
763 }
764 return NULL__null;
765}
766
767Node* OrINode::Ideal(PhaseGVN* phase, bool can_reshape) {
768 int lopcode = in(1)->Opcode();
769 int ropcode = in(2)->Opcode();
770 if (Matcher::match_rule_supported(Op_RotateLeft) &&
771 lopcode == Op_LShiftI && ropcode == Op_URShiftI && in(1)->in(1) == in(2)->in(1)) {
772 Node* lshift = in(1)->in(2);
773 Node* rshift = in(2)->in(2);
774 Node* shift = rotate_shift(phase, lshift, rshift, 0x1F);
775 if (shift != NULL__null) {
776 return new RotateLeftNode(in(1)->in(1), shift, TypeInt::INT);
777 }
778 return NULL__null;
779 }
780 if (Matcher::match_rule_supported(Op_RotateRight) &&
781 lopcode == Op_URShiftI && ropcode == Op_LShiftI && in(1)->in(1) == in(2)->in(1)) {
782 Node* rshift = in(1)->in(2);
783 Node* lshift = in(2)->in(2);
784 Node* shift = rotate_shift(phase, rshift, lshift, 0x1F);
785 if (shift != NULL__null) {
786 return new RotateRightNode(in(1)->in(1), shift, TypeInt::INT);
787 }
788 }
789 return NULL__null;
790}
791
792//------------------------------add_ring---------------------------------------
793// Supplied function returns the sum of the inputs IN THE CURRENT RING. For
794// the logical operations the ring's ADD is really a logical OR function.
795// This also type-checks the inputs for sanity. Guaranteed never to
796// be passed a TOP or BOTTOM type, these are filtered out by pre-check.
797const Type *OrINode::add_ring( const Type *t0, const Type *t1 ) const {
798 const TypeInt *r0 = t0->is_int(); // Handy access
799 const TypeInt *r1 = t1->is_int();
800
801 // If both args are bool, can figure out better types
802 if ( r0 == TypeInt::BOOL ) {
803 if ( r1 == TypeInt::ONE) {
804 return TypeInt::ONE;
805 } else if ( r1 == TypeInt::BOOL ) {
806 return TypeInt::BOOL;
807 }
808 } else if ( r0 == TypeInt::ONE ) {
809 if ( r1 == TypeInt::BOOL ) {
810 return TypeInt::ONE;
811 }
812 }
813
814 // If either input is not a constant, just return all integers.
815 if( !r0->is_con() || !r1->is_con() )
816 return TypeInt::INT; // Any integer, but still no symbols.
817
818 // Otherwise just OR them bits.
819 return TypeInt::make( r0->get_con() | r1->get_con() );
820}
821
822//=============================================================================
823//------------------------------Identity---------------------------------------
824Node* OrLNode::Identity(PhaseGVN* phase) {
825 // x | x => x
826 if (in(1) == in(2)) {
827 return in(1);
828 }
829
830 return AddNode::Identity(phase);
831}
832
833Node* OrLNode::Ideal(PhaseGVN* phase, bool can_reshape) {
834 int lopcode = in(1)->Opcode();
835 int ropcode = in(2)->Opcode();
836 if (Matcher::match_rule_supported(Op_RotateLeft) &&
837 lopcode == Op_LShiftL && ropcode == Op_URShiftL && in(1)->in(1) == in(2)->in(1)) {
838 Node* lshift = in(1)->in(2);
839 Node* rshift = in(2)->in(2);
840 Node* shift = rotate_shift(phase, lshift, rshift, 0x3F);
841 if (shift != NULL__null) {
842 return new RotateLeftNode(in(1)->in(1), shift, TypeLong::LONG);
843 }
844 return NULL__null;
845 }
846 if (Matcher::match_rule_supported(Op_RotateRight) &&
847 lopcode == Op_URShiftL && ropcode == Op_LShiftL && in(1)->in(1) == in(2)->in(1)) {
848 Node* rshift = in(1)->in(2);
849 Node* lshift = in(2)->in(2);
850 Node* shift = rotate_shift(phase, rshift, lshift, 0x3F);
851 if (shift != NULL__null) {
852 return new RotateRightNode(in(1)->in(1), shift, TypeLong::LONG);
853 }
854 }
855 return NULL__null;
856}
857
858//------------------------------add_ring---------------------------------------
859const Type *OrLNode::add_ring( const Type *t0, const Type *t1 ) const {
860 const TypeLong *r0 = t0->is_long(); // Handy access
861 const TypeLong *r1 = t1->is_long();
862
863 // If either input is not a constant, just return all integers.
864 if( !r0->is_con() || !r1->is_con() )
865 return TypeLong::LONG; // Any integer, but still no symbols.
866
867 // Otherwise just OR them bits.
868 return TypeLong::make( r0->get_con() | r1->get_con() );
869}
870
871//=============================================================================
872//------------------------------Idealize---------------------------------------
873Node* XorINode::Ideal(PhaseGVN* phase, bool can_reshape) {
874 Node* in1 = in(1);
875 Node* in2 = in(2);
876 int op1 = in1->Opcode();
877 // Convert ~(x-1) into -x. Note there isn't a bitwise not bytecode,
878 // "~x" would typically represented as "x^(-1)", and "x-c0" would
879 // convert into "x+ -c0" in SubXNode::Ideal. So ~(x-1) will eventually
880 // be (x+(-1))^-1.
881 if (op1 == Op_AddI && phase->type(in2) == TypeInt::MINUS_1 &&
882 phase->type(in1->in(2)) == TypeInt::MINUS_1) {
883 return new SubINode(phase->makecon(TypeInt::ZERO), in1->in(1));
884 }
885 return AddNode::Ideal(phase, can_reshape);
886}
887
888const Type* XorINode::Value(PhaseGVN* phase) const {
889 Node* in1 = in(1);
890 Node* in2 = in(2);
891 const Type* t1 = phase->type(in1);
892 const Type* t2 = phase->type(in2);
893 if (t1 == Type::TOP || t2 == Type::TOP) {
1
Assuming 't1' is not equal to 'TOP'
2
Assuming 't2' is not equal to 'TOP'
3
Taking false branch
894 return Type::TOP;
895 }
896 // x ^ x ==> 0
897 if (in1->eqv_uncast(in2)) {
4
Taking false branch
898 return add_id();
899 }
900 // result of xor can only have bits sets where any of the
901 // inputs have bits set. lo can always become 0.
902 const TypeInt* t1i = t1->is_int();
903 const TypeInt* t2i = t2->is_int();
904 if ((t1i->_lo >= 0) &&
5
Assuming field '_lo' is < 0
905 (t1i->_hi > 0) &&
906 (t2i->_lo >= 0) &&
907 (t2i->_hi > 0)) {
908 // hi - set all bits below the highest bit. Using round_down to avoid overflow.
909 const TypeInt* t1x = TypeInt::make(0, round_down_power_of_2(t1i->_hi) + (round_down_power_of_2(t1i->_hi) - 1), t1i->_widen);
910 const TypeInt* t2x = TypeInt::make(0, round_down_power_of_2(t2i->_hi) + (round_down_power_of_2(t2i->_hi) - 1), t2i->_widen);
911 return t1x->meet(t2x);
912 }
913 return AddNode::Value(phase);
6
Calling 'AddNode::Value'
914}
915
916
917//------------------------------add_ring---------------------------------------
918// Supplied function returns the sum of the inputs IN THE CURRENT RING. For
919// the logical operations the ring's ADD is really a logical OR function.
920// This also type-checks the inputs for sanity. Guaranteed never to
921// be passed a TOP or BOTTOM type, these are filtered out by pre-check.
922const Type *XorINode::add_ring( const Type *t0, const Type *t1 ) const {
923 const TypeInt *r0 = t0->is_int(); // Handy access
924 const TypeInt *r1 = t1->is_int();
29
Called C++ object pointer is null
925
926 // Complementing a boolean?
927 if( r0 == TypeInt::BOOL && ( r1 == TypeInt::ONE
928 || r1 == TypeInt::BOOL))
929 return TypeInt::BOOL;
930
931 if( !r0->is_con() || !r1->is_con() ) // Not constants
932 return TypeInt::INT; // Any integer, but still no symbols.
933
934 // Otherwise just XOR them bits.
935 return TypeInt::make( r0->get_con() ^ r1->get_con() );
936}
937
938//=============================================================================
939//------------------------------add_ring---------------------------------------
940const Type *XorLNode::add_ring( const Type *t0, const Type *t1 ) const {
941 const TypeLong *r0 = t0->is_long(); // Handy access
942 const TypeLong *r1 = t1->is_long();
943
944 // If either input is not a constant, just return all integers.
945 if( !r0->is_con() || !r1->is_con() )
946 return TypeLong::LONG; // Any integer, but still no symbols.
947
948 // Otherwise just OR them bits.
949 return TypeLong::make( r0->get_con() ^ r1->get_con() );
950}
951
952Node* XorLNode::Ideal(PhaseGVN* phase, bool can_reshape) {
953 Node* in1 = in(1);
954 Node* in2 = in(2);
955 int op1 = in1->Opcode();
956 // Convert ~(x-1) into -x. Note there isn't a bitwise not bytecode,
957 // "~x" would typically represented as "x^(-1)", and "x-c0" would
958 // convert into "x+ -c0" in SubXNode::Ideal. So ~(x-1) will eventually
959 // be (x+(-1))^-1.
960 if (op1 == Op_AddL && phase->type(in2) == TypeLong::MINUS_1 &&
961 phase->type(in1->in(2)) == TypeLong::MINUS_1) {
962 return new SubLNode(phase->makecon(TypeLong::ZERO), in1->in(1));
963 }
964 return AddNode::Ideal(phase, can_reshape);
965}
966
967const Type* XorLNode::Value(PhaseGVN* phase) const {
968 Node* in1 = in(1);
969 Node* in2 = in(2);
970 const Type* t1 = phase->type(in1);
971 const Type* t2 = phase->type(in2);
972 if (t1 == Type::TOP || t2 == Type::TOP) {
973 return Type::TOP;
974 }
975 // x ^ x ==> 0
976 if (in1->eqv_uncast(in2)) {
977 return add_id();
978 }
979 // result of xor can only have bits sets where any of the
980 // inputs have bits set. lo can always become 0.
981 const TypeLong* t1l = t1->is_long();
982 const TypeLong* t2l = t2->is_long();
983 if ((t1l->_lo >= 0) &&
984 (t1l->_hi > 0) &&
985 (t2l->_lo >= 0) &&
986 (t2l->_hi > 0)) {
987 // hi - set all bits below the highest bit. Using round_down to avoid overflow.
988 const TypeLong* t1x = TypeLong::make(0, round_down_power_of_2(t1l->_hi) + (round_down_power_of_2(t1l->_hi) - 1), t1l->_widen);
989 const TypeLong* t2x = TypeLong::make(0, round_down_power_of_2(t2l->_hi) + (round_down_power_of_2(t2l->_hi) - 1), t2l->_widen);
990 return t1x->meet(t2x);
991 }
992 return AddNode::Value(phase);
993}
994
995Node* MaxNode::build_min_max(Node* a, Node* b, bool is_max, bool is_unsigned, const Type* t, PhaseGVN& gvn) {
996 bool is_int = gvn.type(a)->isa_int();
997 assert(is_int || gvn.type(a)->isa_long(), "int or long inputs")do { if (!(is_int || gvn.type(a)->isa_long())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 997, "assert(" "is_int || gvn.type(a)->isa_long()" ") failed"
, "int or long inputs"); ::breakpoint(); } } while (0)
;
998 assert(is_int == (gvn.type(b)->isa_int() != NULL), "inconsistent inputs")do { if (!(is_int == (gvn.type(b)->isa_int() != __null))) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 998, "assert(" "is_int == (gvn.type(b)->isa_int() != __null)"
") failed", "inconsistent inputs"); ::breakpoint(); } } while
(0)
;
999 BasicType bt = is_int ? T_INT: T_LONG;
1000 Node* hook = NULL__null;
1001 if (gvn.is_IterGVN()) {
1002 // Make sure a and b are not destroyed
1003 hook = new Node(2);
1004 hook->init_req(0, a);
1005 hook->init_req(1, b);
1006 }
1007 Node* res = NULL__null;
1008 if (is_int && !is_unsigned) {
1009 if (is_max) {
1010 res = gvn.transform(new MaxINode(a, b));
1011 assert(gvn.type(res)->is_int()->_lo >= t->is_int()->_lo && gvn.type(res)->is_int()->_hi <= t->is_int()->_hi, "type doesn't match")do { if (!(gvn.type(res)->is_int()->_lo >= t->is_int
()->_lo && gvn.type(res)->is_int()->_hi <=
t->is_int()->_hi)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 1011, "assert(" "gvn.type(res)->is_int()->_lo >= t->is_int()->_lo && gvn.type(res)->is_int()->_hi <= t->is_int()->_hi"
") failed", "type doesn't match"); ::breakpoint(); } } while
(0)
;
1012 } else {
1013 Node* res = gvn.transform(new MinINode(a, b));
1014 assert(gvn.type(res)->is_int()->_lo >= t->is_int()->_lo && gvn.type(res)->is_int()->_hi <= t->is_int()->_hi, "type doesn't match")do { if (!(gvn.type(res)->is_int()->_lo >= t->is_int
()->_lo && gvn.type(res)->is_int()->_hi <=
t->is_int()->_hi)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 1014, "assert(" "gvn.type(res)->is_int()->_lo >= t->is_int()->_lo && gvn.type(res)->is_int()->_hi <= t->is_int()->_hi"
") failed", "type doesn't match"); ::breakpoint(); } } while
(0)
;
1015 }
1016 } else {
1017 Node* cmp = NULL__null;
1018 if (is_max) {
1019 cmp = gvn.transform(CmpNode::make(a, b, bt, is_unsigned));
1020 } else {
1021 cmp = gvn.transform(CmpNode::make(b, a, bt, is_unsigned));
1022 }
1023 Node* bol = gvn.transform(new BoolNode(cmp, BoolTest::lt));
1024 res = gvn.transform(CMoveNode::make(NULL__null, bol, a, b, t));
1025 }
1026 if (hook != NULL__null) {
1027 hook->destruct(&gvn);
1028 }
1029 return res;
1030}
1031
1032Node* MaxNode::build_min_max_diff_with_zero(Node* a, Node* b, bool is_max, const Type* t, PhaseGVN& gvn) {
1033 bool is_int = gvn.type(a)->isa_int();
1034 assert(is_int || gvn.type(a)->isa_long(), "int or long inputs")do { if (!(is_int || gvn.type(a)->isa_long())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 1034, "assert(" "is_int || gvn.type(a)->isa_long()" ") failed"
, "int or long inputs"); ::breakpoint(); } } while (0)
;
1035 assert(is_int == (gvn.type(b)->isa_int() != NULL), "inconsistent inputs")do { if (!(is_int == (gvn.type(b)->isa_int() != __null))) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 1035, "assert(" "is_int == (gvn.type(b)->isa_int() != __null)"
") failed", "inconsistent inputs"); ::breakpoint(); } } while
(0)
;
1036 BasicType bt = is_int ? T_INT: T_LONG;
1037 Node* zero = gvn.integercon(0, bt);
1038 Node* hook = NULL__null;
1039 if (gvn.is_IterGVN()) {
1040 // Make sure a and b are not destroyed
1041 hook = new Node(2);
1042 hook->init_req(0, a);
1043 hook->init_req(1, b);
1044 }
1045 Node* cmp = NULL__null;
1046 if (is_max) {
1047 cmp = gvn.transform(CmpNode::make(a, b, bt, false));
1048 } else {
1049 cmp = gvn.transform(CmpNode::make(b, a, bt, false));
1050 }
1051 Node* sub = gvn.transform(SubNode::make(a, b, bt));
1052 Node* bol = gvn.transform(new BoolNode(cmp, BoolTest::lt));
1053 Node* res = gvn.transform(CMoveNode::make(NULL__null, bol, sub, zero, t));
1054 if (hook != NULL__null) {
1055 hook->destruct(&gvn);
1056 }
1057 return res;
1058}
1059
1060//=============================================================================
1061//------------------------------add_ring---------------------------------------
1062// Supplied function returns the sum of the inputs.
1063const Type *MaxINode::add_ring( const Type *t0, const Type *t1 ) const {
1064 const TypeInt *r0 = t0->is_int(); // Handy access
1065 const TypeInt *r1 = t1->is_int();
1066
1067 // Otherwise just MAX them bits.
1068 return TypeInt::make( MAX2(r0->_lo,r1->_lo), MAX2(r0->_hi,r1->_hi), MAX2(r0->_widen,r1->_widen) );
1069}
1070
1071// Check if addition of an integer with type 't' and a constant 'c' can overflow
1072static bool can_overflow(const TypeInt* t, jint c) {
1073 jint t_lo = t->_lo;
1074 jint t_hi = t->_hi;
1075 return ((c < 0 && (java_add(t_lo, c) > t_lo)) ||
1076 (c > 0 && (java_add(t_hi, c) < t_hi)));
1077}
1078
1079//=============================================================================
1080//------------------------------Idealize---------------------------------------
1081// MINs show up in range-check loop limit calculations. Look for
1082// "MIN2(x+c0,MIN2(y,x+c1))". Pick the smaller constant: "MIN2(x+c0,y)"
1083Node *MinINode::Ideal(PhaseGVN *phase, bool can_reshape) {
1084 Node *progress = NULL__null;
1085 // Force a right-spline graph
1086 Node *l = in(1);
1087 Node *r = in(2);
1088 // Transform MinI1( MinI2(a,b), c) into MinI1( a, MinI2(b,c) )
1089 // to force a right-spline graph for the rest of MinINode::Ideal().
1090 if( l->Opcode() == Op_MinI ) {
1091 assert( l != l->in(1), "dead loop in MinINode::Ideal" )do { if (!(l != l->in(1))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 1091, "assert(" "l != l->in(1)" ") failed", "dead loop in MinINode::Ideal"
); ::breakpoint(); } } while (0)
;
1092 r = phase->transform(new MinINode(l->in(2),r));
1093 l = l->in(1);
1094 set_req_X(1, l, phase);
1095 set_req_X(2, r, phase);
1096 return this;
1097 }
1098
1099 // Get left input & constant
1100 Node *x = l;
1101 jint x_off = 0;
1102 if( x->Opcode() == Op_AddI && // Check for "x+c0" and collect constant
1103 x->in(2)->is_Con() ) {
1104 const Type *t = x->in(2)->bottom_type();
1105 if( t == Type::TOP ) return NULL__null; // No progress
1106 x_off = t->is_int()->get_con();
1107 x = x->in(1);
1108 }
1109
1110 // Scan a right-spline-tree for MINs
1111 Node *y = r;
1112 jint y_off = 0;
1113 // Check final part of MIN tree
1114 if( y->Opcode() == Op_AddI && // Check for "y+c1" and collect constant
1115 y->in(2)->is_Con() ) {
1116 const Type *t = y->in(2)->bottom_type();
1117 if( t == Type::TOP ) return NULL__null; // No progress
1118 y_off = t->is_int()->get_con();
1119 y = y->in(1);
1120 }
1121 if( x->_idx > y->_idx && r->Opcode() != Op_MinI ) {
1122 swap_edges(1, 2);
1123 return this;
1124 }
1125
1126 const TypeInt* tx = phase->type(x)->isa_int();
1127
1128 if( r->Opcode() == Op_MinI ) {
1129 assert( r != r->in(2), "dead loop in MinINode::Ideal" )do { if (!(r != r->in(2))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/addnode.cpp"
, 1129, "assert(" "r != r->in(2)" ") failed", "dead loop in MinINode::Ideal"
); ::breakpoint(); } } while (0)
;
1130 y = r->in(1);
1131 // Check final part of MIN tree
1132 if( y->Opcode() == Op_AddI &&// Check for "y+c1" and collect constant
1133 y->in(2)->is_Con() ) {
1134 const Type *t = y->in(2)->bottom_type();
1135 if( t == Type::TOP ) return NULL__null; // No progress
1136 y_off = t->is_int()->get_con();
1137 y = y->in(1);
1138 }
1139
1140 if( x->_idx > y->_idx )
1141 return new MinINode(r->in(1),phase->transform(new MinINode(l,r->in(2))));
1142
1143 // Transform MIN2(x + c0, MIN2(x + c1, z)) into MIN2(x + MIN2(c0, c1), z)
1144 // if x == y and the additions can't overflow.
1145 if (x == y && tx != NULL__null &&
1146 !can_overflow(tx, x_off) &&
1147 !can_overflow(tx, y_off)) {
1148 return new MinINode(phase->transform(new AddINode(x, phase->intcon(MIN2(x_off, y_off)))), r->in(2));
1149 }
1150 } else {
1151 // Transform MIN2(x + c0, y + c1) into x + MIN2(c0, c1)
1152 // if x == y and the additions can't overflow.
1153 if (x == y && tx != NULL__null &&
1154 !can_overflow(tx, x_off) &&
1155 !can_overflow(tx, y_off)) {
1156 return new AddINode(x,phase->intcon(MIN2(x_off,y_off)));
1157 }
1158 }
1159 return NULL__null;
1160}
1161
1162//------------------------------add_ring---------------------------------------
1163// Supplied function returns the sum of the inputs.
1164const Type *MinINode::add_ring( const Type *t0, const Type *t1 ) const {
1165 const TypeInt *r0 = t0->is_int(); // Handy access
1166 const TypeInt *r1 = t1->is_int();
1167
1168 // Otherwise just MIN them bits.
1169 return TypeInt::make( MIN2(r0->_lo,r1->_lo), MIN2(r0->_hi,r1->_hi), MAX2(r0->_widen,r1->_widen) );
1170}
1171
1172//------------------------------add_ring---------------------------------------
1173const Type *MinFNode::add_ring( const Type *t0, const Type *t1 ) const {
1174 const TypeF *r0 = t0->is_float_constant();
1175 const TypeF *r1 = t1->is_float_constant();
1176
1177 if (r0->is_nan()) {
1178 return r0;
1179 }
1180 if (r1->is_nan()) {
1181 return r1;
1182 }
1183
1184 float f0 = r0->getf();
1185 float f1 = r1->getf();
1186 if (f0 != 0.0f || f1 != 0.0f) {
1187 return f0 < f1 ? r0 : r1;
1188 }
1189
1190 // handle min of 0.0, -0.0 case.
1191 return (jint_cast(f0) < jint_cast(f1)) ? r0 : r1;
1192}
1193
1194//------------------------------add_ring---------------------------------------
1195const Type *MinDNode::add_ring( const Type *t0, const Type *t1 ) const {
1196 const TypeD *r0 = t0->is_double_constant();
1197 const TypeD *r1 = t1->is_double_constant();
1198
1199 if (r0->is_nan()) {
1200 return r0;
1201 }
1202 if (r1->is_nan()) {
1203 return r1;
1204 }
1205
1206 double d0 = r0->getd();
1207 double d1 = r1->getd();
1208 if (d0 != 0.0 || d1 != 0.0) {
1209 return d0 < d1 ? r0 : r1;
1210 }
1211
1212 // handle min of 0.0, -0.0 case.
1213 return (jlong_cast(d0) < jlong_cast(d1)) ? r0 : r1;
1214}
1215
1216//------------------------------add_ring---------------------------------------
1217const Type *MaxFNode::add_ring( const Type *t0, const Type *t1 ) const {
1218 const TypeF *r0 = t0->is_float_constant();
1219 const TypeF *r1 = t1->is_float_constant();
1220
1221 if (r0->is_nan()) {
1222 return r0;
1223 }
1224 if (r1->is_nan()) {
1225 return r1;
1226 }
1227
1228 float f0 = r0->getf();
1229 float f1 = r1->getf();
1230 if (f0 != 0.0f || f1 != 0.0f) {
1231 return f0 > f1 ? r0 : r1;
1232 }
1233
1234 // handle max of 0.0,-0.0 case.
1235 return (jint_cast(f0) > jint_cast(f1)) ? r0 : r1;
1236}
1237
1238//------------------------------add_ring---------------------------------------
1239const Type *MaxDNode::add_ring( const Type *t0, const Type *t1 ) const {
1240 const TypeD *r0 = t0->is_double_constant();
1241 const TypeD *r1 = t1->is_double_constant();
1242
1243 if (r0->is_nan()) {
1244 return r0;
1245 }
1246 if (r1->is_nan()) {
1247 return r1;
1248 }
1249
1250 double d0 = r0->getd();
1251 double d1 = r1->getd();
1252 if (d0 != 0.0 || d1 != 0.0) {
1253 return d0 > d1 ? r0 : r1;
1254 }
1255
1256 // handle max of 0.0, -0.0 case.
1257 return (jlong_cast(d0) > jlong_cast(d1)) ? r0 : r1;
1258}

/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp

1/*
2 * Copyright (c) 1997, 2021, 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 */
24
25#ifndef SHARE_OPTO_TYPE_HPP
26#define SHARE_OPTO_TYPE_HPP
27
28#include "opto/adlcVMDeps.hpp"
29#include "runtime/handles.hpp"
30
31// Portions of code courtesy of Clifford Click
32
33// Optimization - Graph Style
34
35
36// This class defines a Type lattice. The lattice is used in the constant
37// propagation algorithms, and for some type-checking of the iloc code.
38// Basic types include RSD's (lower bound, upper bound, stride for integers),
39// float & double precision constants, sets of data-labels and code-labels.
40// The complete lattice is described below. Subtypes have no relationship to
41// up or down in the lattice; that is entirely determined by the behavior of
42// the MEET/JOIN functions.
43
44class Dict;
45class Type;
46class TypeD;
47class TypeF;
48class TypeInteger;
49class TypeInt;
50class TypeLong;
51class TypeNarrowPtr;
52class TypeNarrowOop;
53class TypeNarrowKlass;
54class TypeAry;
55class TypeTuple;
56class TypeVect;
57class TypeVectA;
58class TypeVectS;
59class TypeVectD;
60class TypeVectX;
61class TypeVectY;
62class TypeVectZ;
63class TypeVectMask;
64class TypePtr;
65class TypeRawPtr;
66class TypeOopPtr;
67class TypeInstPtr;
68class TypeAryPtr;
69class TypeKlassPtr;
70class TypeInstKlassPtr;
71class TypeAryKlassPtr;
72class TypeMetadataPtr;
73
74//------------------------------Type-------------------------------------------
75// Basic Type object, represents a set of primitive Values.
76// Types are hash-cons'd into a private class dictionary, so only one of each
77// different kind of Type exists. Types are never modified after creation, so
78// all their interesting fields are constant.
79class Type {
80 friend class VMStructs;
81
82public:
83 enum TYPES {
84 Bad=0, // Type check
85 Control, // Control of code (not in lattice)
86 Top, // Top of the lattice
87 Int, // Integer range (lo-hi)
88 Long, // Long integer range (lo-hi)
89 Half, // Placeholder half of doubleword
90 NarrowOop, // Compressed oop pointer
91 NarrowKlass, // Compressed klass pointer
92
93 Tuple, // Method signature or object layout
94 Array, // Array types
95
96 VectorMask, // Vector predicate/mask type
97 VectorA, // (Scalable) Vector types for vector length agnostic
98 VectorS, // 32bit Vector types
99 VectorD, // 64bit Vector types
100 VectorX, // 128bit Vector types
101 VectorY, // 256bit Vector types
102 VectorZ, // 512bit Vector types
103
104 AnyPtr, // Any old raw, klass, inst, or array pointer
105 RawPtr, // Raw (non-oop) pointers
106 OopPtr, // Any and all Java heap entities
107 InstPtr, // Instance pointers (non-array objects)
108 AryPtr, // Array pointers
109 // (Ptr order matters: See is_ptr, isa_ptr, is_oopptr, isa_oopptr.)
110
111 MetadataPtr, // Generic metadata
112 KlassPtr, // Klass pointers
113 InstKlassPtr,
114 AryKlassPtr,
115
116 Function, // Function signature
117 Abio, // Abstract I/O
118 Return_Address, // Subroutine return address
119 Memory, // Abstract store
120 FloatTop, // No float value
121 FloatCon, // Floating point constant
122 FloatBot, // Any float value
123 DoubleTop, // No double value
124 DoubleCon, // Double precision constant
125 DoubleBot, // Any double value
126 Bottom, // Bottom of lattice
127 lastype // Bogus ending type (not in lattice)
128 };
129
130 // Signal values for offsets from a base pointer
131 enum OFFSET_SIGNALS {
132 OffsetTop = -2000000000, // undefined offset
133 OffsetBot = -2000000001 // any possible offset
134 };
135
136 // Min and max WIDEN values.
137 enum WIDEN {
138 WidenMin = 0,
139 WidenMax = 3
140 };
141
142private:
143 typedef struct {
144 TYPES dual_type;
145 BasicType basic_type;
146 const char* msg;
147 bool isa_oop;
148 uint ideal_reg;
149 relocInfo::relocType reloc;
150 } TypeInfo;
151
152 // Dictionary of types shared among compilations.
153 static Dict* _shared_type_dict;
154 static const TypeInfo _type_info[];
155
156 static int uhash( const Type *const t );
157 // Structural equality check. Assumes that cmp() has already compared
158 // the _base types and thus knows it can cast 't' appropriately.
159 virtual bool eq( const Type *t ) const;
160
161 // Top-level hash-table of types
162 static Dict *type_dict() {
163 return Compile::current()->type_dict();
164 }
165
166 // DUAL operation: reflect around lattice centerline. Used instead of
167 // join to ensure my lattice is symmetric up and down. Dual is computed
168 // lazily, on demand, and cached in _dual.
169 const Type *_dual; // Cached dual value
170
171#ifdef ASSERT1
172 // One type is interface, the other is oop
173 virtual bool interface_vs_oop_helper(const Type *t) const;
174#endif
175
176 const Type *meet_helper(const Type *t, bool include_speculative) const;
177 void check_symmetrical(const Type *t, const Type *mt) const;
178
179protected:
180 // Each class of type is also identified by its base.
181 const TYPES _base; // Enum of Types type
182
183 Type( TYPES t ) : _dual(NULL__null), _base(t) {} // Simple types
184 // ~Type(); // Use fast deallocation
185 const Type *hashcons(); // Hash-cons the type
186 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
187 const Type *join_helper(const Type *t, bool include_speculative) const {
188 return dual()->meet_helper(t->dual(), include_speculative)->dual();
189 }
190
191public:
192
193 inline void* operator new( size_t x ) throw() {
194 Compile* compile = Compile::current();
195 compile->set_type_last_size(x);
196 return compile->type_arena()->AmallocWords(x);
197 }
198 inline void operator delete( void* ptr ) {
199 Compile* compile = Compile::current();
200 compile->type_arena()->Afree(ptr,compile->type_last_size());
201 }
202
203 // Initialize the type system for a particular compilation.
204 static void Initialize(Compile* compile);
205
206 // Initialize the types shared by all compilations.
207 static void Initialize_shared(Compile* compile);
208
209 TYPES base() const {
210 assert(_base > Bad && _base < lastype, "sanity")do { if (!(_base > Bad && _base < lastype)) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 210, "assert(" "_base > Bad && _base < lastype"
") failed", "sanity"); ::breakpoint(); } } while (0)
;
211 return _base;
212 }
213
214 // Create a new hash-consd type
215 static const Type *make(enum TYPES);
216 // Test for equivalence of types
217 static int cmp( const Type *const t1, const Type *const t2 );
218 // Test for higher or equal in lattice
219 // Variant that drops the speculative part of the types
220 bool higher_equal(const Type *t) const {
221 return !cmp(meet(t),t->remove_speculative());
19
Assuming the condition is true
20
Returning the value 1, which participates in a condition later
222 }
223 // Variant that keeps the speculative part of the types
224 bool higher_equal_speculative(const Type *t) const {
225 return !cmp(meet_speculative(t),t);
226 }
227
228 // MEET operation; lower in lattice.
229 // Variant that drops the speculative part of the types
230 const Type *meet(const Type *t) const {
231 return meet_helper(t, false);
232 }
233 // Variant that keeps the speculative part of the types
234 const Type *meet_speculative(const Type *t) const {
235 return meet_helper(t, true)->cleanup_speculative();
236 }
237 // WIDEN: 'widens' for Ints and other range types
238 virtual const Type *widen( const Type *old, const Type* limit ) const { return this; }
239 // NARROW: complement for widen, used by pessimistic phases
240 virtual const Type *narrow( const Type *old ) const { return this; }
241
242 // DUAL operation: reflect around lattice centerline. Used instead of
243 // join to ensure my lattice is symmetric up and down.
244 const Type *dual() const { return _dual; }
245
246 // Compute meet dependent on base type
247 virtual const Type *xmeet( const Type *t ) const;
248 virtual const Type *xdual() const; // Compute dual right now.
249
250 // JOIN operation; higher in lattice. Done by finding the dual of the
251 // meet of the dual of the 2 inputs.
252 // Variant that drops the speculative part of the types
253 const Type *join(const Type *t) const {
254 return join_helper(t, false);
255 }
256 // Variant that keeps the speculative part of the types
257 const Type *join_speculative(const Type *t) const {
258 return join_helper(t, true)->cleanup_speculative();
259 }
260
261 // Modified version of JOIN adapted to the needs Node::Value.
262 // Normalizes all empty values to TOP. Does not kill _widen bits.
263 // Currently, it also works around limitations involving interface types.
264 // Variant that drops the speculative part of the types
265 const Type *filter(const Type *kills) const {
266 return filter_helper(kills, false);
267 }
268 // Variant that keeps the speculative part of the types
269 const Type *filter_speculative(const Type *kills) const {
270 return filter_helper(kills, true)->cleanup_speculative();
271 }
272
273#ifdef ASSERT1
274 // One type is interface, the other is oop
275 virtual bool interface_vs_oop(const Type *t) const;
276#endif
277
278 // Returns true if this pointer points at memory which contains a
279 // compressed oop references.
280 bool is_ptr_to_narrowoop() const;
281 bool is_ptr_to_narrowklass() const;
282
283 bool is_ptr_to_boxing_obj() const;
284
285
286 // Convenience access
287 float getf() const;
288 double getd() const;
289
290 const TypeInt *is_int() const;
291 const TypeInt *isa_int() const; // Returns NULL if not an Int
292 const TypeInteger* is_integer(BasicType bt) const;
293 const TypeInteger* isa_integer(BasicType bt) const;
294 const TypeLong *is_long() const;
295 const TypeLong *isa_long() const; // Returns NULL if not a Long
296 const TypeD *isa_double() const; // Returns NULL if not a Double{Top,Con,Bot}
297 const TypeD *is_double_constant() const; // Asserts it is a DoubleCon
298 const TypeD *isa_double_constant() const; // Returns NULL if not a DoubleCon
299 const TypeF *isa_float() const; // Returns NULL if not a Float{Top,Con,Bot}
300 const TypeF *is_float_constant() const; // Asserts it is a FloatCon
301 const TypeF *isa_float_constant() const; // Returns NULL if not a FloatCon
302 const TypeTuple *is_tuple() const; // Collection of fields, NOT a pointer
303 const TypeAry *is_ary() const; // Array, NOT array pointer
304 const TypeAry *isa_ary() const; // Returns NULL of not ary
305 const TypeVect *is_vect() const; // Vector
306 const TypeVect *isa_vect() const; // Returns NULL if not a Vector
307 const TypeVectMask *is_vectmask() const; // Predicate/Mask Vector
308 const TypeVectMask *isa_vectmask() const; // Returns NULL if not a Vector Predicate/Mask
309 const TypePtr *is_ptr() const; // Asserts it is a ptr type
310 const TypePtr *isa_ptr() const; // Returns NULL if not ptr type
311 const TypeRawPtr *isa_rawptr() const; // NOT Java oop
312 const TypeRawPtr *is_rawptr() const; // Asserts is rawptr
313 const TypeNarrowOop *is_narrowoop() const; // Java-style GC'd pointer
314 const TypeNarrowOop *isa_narrowoop() const; // Returns NULL if not oop ptr type
315 const TypeNarrowKlass *is_narrowklass() const; // compressed klass pointer
316 const TypeNarrowKlass *isa_narrowklass() const;// Returns NULL if not oop ptr type
317 const TypeOopPtr *isa_oopptr() const; // Returns NULL if not oop ptr type
318 const TypeOopPtr *is_oopptr() const; // Java-style GC'd pointer
319 const TypeInstPtr *isa_instptr() const; // Returns NULL if not InstPtr
320 const TypeInstPtr *is_instptr() const; // Instance
321 const TypeAryPtr *isa_aryptr() const; // Returns NULL if not AryPtr
322 const TypeAryPtr *is_aryptr() const; // Array oop
323
324 const TypeMetadataPtr *isa_metadataptr() const; // Returns NULL if not oop ptr type
325 const TypeMetadataPtr *is_metadataptr() const; // Java-style GC'd pointer
326 const TypeKlassPtr *isa_klassptr() const; // Returns NULL if not KlassPtr
327 const TypeKlassPtr *is_klassptr() const; // assert if not KlassPtr
328 const TypeInstKlassPtr *isa_instklassptr() const; // Returns NULL if not IntKlassPtr
329 const TypeInstKlassPtr *is_instklassptr() const; // assert if not IntKlassPtr
330 const TypeAryKlassPtr *isa_aryklassptr() const; // Returns NULL if not AryKlassPtr
331 const TypeAryKlassPtr *is_aryklassptr() const; // assert if not AryKlassPtr
332
333 virtual bool is_finite() const; // Has a finite value
334 virtual bool is_nan() const; // Is not a number (NaN)
335
336 // Returns this ptr type or the equivalent ptr type for this compressed pointer.
337 const TypePtr* make_ptr() const;
338
339 // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
340 // Asserts if the underlying type is not an oopptr or narrowoop.
341 const TypeOopPtr* make_oopptr() const;
342
343 // Returns this compressed pointer or the equivalent compressed version
344 // of this pointer type.
345 const TypeNarrowOop* make_narrowoop() const;
346
347 // Returns this compressed klass pointer or the equivalent
348 // compressed version of this pointer type.
349 const TypeNarrowKlass* make_narrowklass() const;
350
351 // Special test for register pressure heuristic
352 bool is_floatingpoint() const; // True if Float or Double base type
353
354 // Do you have memory, directly or through a tuple?
355 bool has_memory( ) const;
356
357 // TRUE if type is a singleton
358 virtual bool singleton(void) const;
359
360 // TRUE if type is above the lattice centerline, and is therefore vacuous
361 virtual bool empty(void) const;
362
363 // Return a hash for this type. The hash function is public so ConNode
364 // (constants) can hash on their constant, which is represented by a Type.
365 virtual int hash() const;
366
367 // Map ideal registers (machine types) to ideal types
368 static const Type *mreg2type[];
369
370 // Printing, statistics
371#ifndef PRODUCT
372 void dump_on(outputStream *st) const;
373 void dump() const {
374 dump_on(tty);
375 }
376 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
377 static void dump_stats();
378 // Groups of types, for debugging and visualization only.
379 enum class Category {
380 Data,
381 Memory,
382 Mixed, // Tuples with types of different categories.
383 Control,
384 Other, // {Type::Top, Type::Abio, Type::Bottom}.
385 Undef // {Type::Bad, Type::lastype}, for completeness.
386 };
387 // Return the category of this type.
388 Category category() const;
389
390 static const char* str(const Type* t);
391#endif // !PRODUCT
392 void typerr(const Type *t) const; // Mixing types error
393
394 // Create basic type
395 static const Type* get_const_basic_type(BasicType type) {
396 assert((uint)type <= T_CONFLICT && _const_basic_type[type] != NULL, "bad type")do { if (!((uint)type <= T_CONFLICT && _const_basic_type
[type] != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 396, "assert(" "(uint)type <= T_CONFLICT && _const_basic_type[type] != __null"
") failed", "bad type"); ::breakpoint(); } } while (0)
;
397 return _const_basic_type[type];
398 }
399
400 // For two instance arrays of same dimension, return the base element types.
401 // Otherwise or if the arrays have different dimensions, return NULL.
402 static void get_arrays_base_elements(const Type *a1, const Type *a2,
403 const TypeInstPtr **e1, const TypeInstPtr **e2);
404
405 // Mapping to the array element's basic type.
406 BasicType array_element_basic_type() const;
407
408 // Create standard type for a ciType:
409 static const Type* get_const_type(ciType* type);
410
411 // Create standard zero value:
412 static const Type* get_zero_type(BasicType type) {
413 assert((uint)type <= T_CONFLICT && _zero_type[type] != NULL, "bad type")do { if (!((uint)type <= T_CONFLICT && _zero_type[
type] != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 413, "assert(" "(uint)type <= T_CONFLICT && _zero_type[type] != __null"
") failed", "bad type"); ::breakpoint(); } } while (0)
;
414 return _zero_type[type];
415 }
416
417 // Report if this is a zero value (not top).
418 bool is_zero_type() const {
419 BasicType type = basic_type();
420 if (type == T_VOID || type >= T_CONFLICT)
421 return false;
422 else
423 return (this == _zero_type[type]);
424 }
425
426 // Convenience common pre-built types.
427 static const Type *ABIO;
428 static const Type *BOTTOM;
429 static const Type *CONTROL;
430 static const Type *DOUBLE;
431 static const Type *FLOAT;
432 static const Type *HALF;
433 static const Type *MEMORY;
434 static const Type *MULTI;
435 static const Type *RETURN_ADDRESS;
436 static const Type *TOP;
437
438 // Mapping from compiler type to VM BasicType
439 BasicType basic_type() const { return _type_info[_base].basic_type; }
440 uint ideal_reg() const { return _type_info[_base].ideal_reg; }
441 const char* msg() const { return _type_info[_base].msg; }
442 bool isa_oop_ptr() const { return _type_info[_base].isa_oop; }
443 relocInfo::relocType reloc() const { return _type_info[_base].reloc; }
444
445 // Mapping from CI type system to compiler type:
446 static const Type* get_typeflow_type(ciType* type);
447
448 static const Type* make_from_constant(ciConstant constant,
449 bool require_constant = false,
450 int stable_dimension = 0,
451 bool is_narrow = false,
452 bool is_autobox_cache = false);
453
454 static const Type* make_constant_from_field(ciInstance* holder,
455 int off,
456 bool is_unsigned_load,
457 BasicType loadbt);
458
459 static const Type* make_constant_from_field(ciField* field,
460 ciInstance* holder,
461 BasicType loadbt,
462 bool is_unsigned_load);
463
464 static const Type* make_constant_from_array_element(ciArray* array,
465 int off,
466 int stable_dimension,
467 BasicType loadbt,
468 bool is_unsigned_load);
469
470 // Speculative type helper methods. See TypePtr.
471 virtual const TypePtr* speculative() const { return NULL__null; }
472 virtual ciKlass* speculative_type() const { return NULL__null; }
473 virtual ciKlass* speculative_type_not_null() const { return NULL__null; }
474 virtual bool speculative_maybe_null() const { return true; }
475 virtual bool speculative_always_null() const { return true; }
476 virtual const Type* remove_speculative() const { return this; }
477 virtual const Type* cleanup_speculative() const { return this; }
478 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const { return exact_kls != NULL__null; }
479 virtual bool would_improve_ptr(ProfilePtrKind ptr_kind) const { return ptr_kind == ProfileAlwaysNull || ptr_kind == ProfileNeverNull; }
480 const Type* maybe_remove_speculative(bool include_speculative) const;
481
482 virtual bool maybe_null() const { return true; }
483 virtual bool is_known_instance() const { return false; }
484
485private:
486 // support arrays
487 static const Type* _zero_type[T_CONFLICT+1];
488 static const Type* _const_basic_type[T_CONFLICT+1];
489};
490
491//------------------------------TypeF------------------------------------------
492// Class of Float-Constant Types.
493class TypeF : public Type {
494 TypeF( float f ) : Type(FloatCon), _f(f) {};
495public:
496 virtual bool eq( const Type *t ) const;
497 virtual int hash() const; // Type specific hashing
498 virtual bool singleton(void) const; // TRUE if type is a singleton
499 virtual bool empty(void) const; // TRUE if type is vacuous
500public:
501 const float _f; // Float constant
502
503 static const TypeF *make(float f);
504
505 virtual bool is_finite() const; // Has a finite value
506 virtual bool is_nan() const; // Is not a number (NaN)
507
508 virtual const Type *xmeet( const Type *t ) const;
509 virtual const Type *xdual() const; // Compute dual right now.
510 // Convenience common pre-built types.
511 static const TypeF *MAX;
512 static const TypeF *MIN;
513 static const TypeF *ZERO; // positive zero only
514 static const TypeF *ONE;
515 static const TypeF *POS_INF;
516 static const TypeF *NEG_INF;
517#ifndef PRODUCT
518 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
519#endif
520};
521
522//------------------------------TypeD------------------------------------------
523// Class of Double-Constant Types.
524class TypeD : public Type {
525 TypeD( double d ) : Type(DoubleCon), _d(d) {};
526public:
527 virtual bool eq( const Type *t ) const;
528 virtual int hash() const; // Type specific hashing
529 virtual bool singleton(void) const; // TRUE if type is a singleton
530 virtual bool empty(void) const; // TRUE if type is vacuous
531public:
532 const double _d; // Double constant
533
534 static const TypeD *make(double d);
535
536 virtual bool is_finite() const; // Has a finite value
537 virtual bool is_nan() const; // Is not a number (NaN)
538
539 virtual const Type *xmeet( const Type *t ) const;
540 virtual const Type *xdual() const; // Compute dual right now.
541 // Convenience common pre-built types.
542 static const TypeD *MAX;
543 static const TypeD *MIN;
544 static const TypeD *ZERO; // positive zero only
545 static const TypeD *ONE;
546 static const TypeD *POS_INF;
547 static const TypeD *NEG_INF;
548#ifndef PRODUCT
549 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
550#endif
551};
552
553class TypeInteger : public Type {
554protected:
555 TypeInteger(TYPES t) : Type(t) {}
556
557public:
558 virtual jlong hi_as_long() const = 0;
559 virtual jlong lo_as_long() const = 0;
560 jlong get_con_as_long(BasicType bt) const;
561 bool is_con() const { return lo_as_long() == hi_as_long(); }
562
563 static const TypeInteger* make(jlong lo, jlong hi, int w, BasicType bt);
564
565 static const TypeInteger* bottom(BasicType type);
566 static const TypeInteger* zero(BasicType type);
567 static const TypeInteger* one(BasicType type);
568 static const TypeInteger* minus_1(BasicType type);
569};
570
571
572
573//------------------------------TypeInt----------------------------------------
574// Class of integer ranges, the set of integers between a lower bound and an
575// upper bound, inclusive.
576class TypeInt : public TypeInteger {
577 TypeInt( jint lo, jint hi, int w );
578protected:
579 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
580
581public:
582 typedef jint NativeType;
583 virtual bool eq( const Type *t ) const;
584 virtual int hash() const; // Type specific hashing
585 virtual bool singleton(void) const; // TRUE if type is a singleton
586 virtual bool empty(void) const; // TRUE if type is vacuous
587 const jint _lo, _hi; // Lower bound, upper bound
588 const short _widen; // Limit on times we widen this sucker
589
590 static const TypeInt *make(jint lo);
591 // must always specify w
592 static const TypeInt *make(jint lo, jint hi, int w);
593
594 // Check for single integer
595 bool is_con() const { return _lo==_hi; }
596 bool is_con(int i) const { return is_con() && _lo == i; }
597 jint get_con() const { assert(is_con(), "" )do { if (!(is_con())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 597, "assert(" "is_con()" ") failed", ""); ::breakpoint(); }
} while (0)
; return _lo; }
598
599 virtual bool is_finite() const; // Has a finite value
600
601 virtual const Type *xmeet( const Type *t ) const;
602 virtual const Type *xdual() const; // Compute dual right now.
603 virtual const Type *widen( const Type *t, const Type* limit_type ) const;
604 virtual const Type *narrow( const Type *t ) const;
605
606 virtual jlong hi_as_long() const { return _hi; }
607 virtual jlong lo_as_long() const { return _lo; }
608
609 // Do not kill _widen bits.
610 // Convenience common pre-built types.
611 static const TypeInt *MAX;
612 static const TypeInt *MIN;
613 static const TypeInt *MINUS_1;
614 static const TypeInt *ZERO;
615 static const TypeInt *ONE;
616 static const TypeInt *BOOL;
617 static const TypeInt *CC;
618 static const TypeInt *CC_LT; // [-1] == MINUS_1
619 static const TypeInt *CC_GT; // [1] == ONE
620 static const TypeInt *CC_EQ; // [0] == ZERO
621 static const TypeInt *CC_LE; // [-1,0]
622 static const TypeInt *CC_GE; // [0,1] == BOOL (!)
623 static const TypeInt *BYTE;
624 static const TypeInt *UBYTE;
625 static const TypeInt *CHAR;
626 static const TypeInt *SHORT;
627 static const TypeInt *POS;
628 static const TypeInt *POS1;
629 static const TypeInt *INT;
630 static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint]
631 static const TypeInt *TYPE_DOMAIN; // alias for TypeInt::INT
632
633 static const TypeInt *as_self(const Type *t) { return t->is_int(); }
634#ifndef PRODUCT
635 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
636#endif
637};
638
639
640//------------------------------TypeLong---------------------------------------
641// Class of long integer ranges, the set of integers between a lower bound and
642// an upper bound, inclusive.
643class TypeLong : public TypeInteger {
644 TypeLong( jlong lo, jlong hi, int w );
645protected:
646 // Do not kill _widen bits.
647 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
648public:
649 typedef jlong NativeType;
650 virtual bool eq( const Type *t ) const;
651 virtual int hash() const; // Type specific hashing
652 virtual bool singleton(void) const; // TRUE if type is a singleton
653 virtual bool empty(void) const; // TRUE if type is vacuous
654public:
655 const jlong _lo, _hi; // Lower bound, upper bound
656 const short _widen; // Limit on times we widen this sucker
657
658 static const TypeLong *make(jlong lo);
659 // must always specify w
660 static const TypeLong *make(jlong lo, jlong hi, int w);
661
662 // Check for single integer
663 bool is_con() const { return _lo==_hi; }
664 bool is_con(int i) const { return is_con() && _lo == i; }
665 jlong get_con() const { assert(is_con(), "" )do { if (!(is_con())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 665, "assert(" "is_con()" ") failed", ""); ::breakpoint(); }
} while (0)
; return _lo; }
666
667 // Check for positive 32-bit value.
668 int is_positive_int() const { return _lo >= 0 && _hi <= (jlong)max_jint; }
669
670 virtual bool is_finite() const; // Has a finite value
671
672 virtual jlong hi_as_long() const { return _hi; }
673 virtual jlong lo_as_long() const { return _lo; }
674
675 virtual const Type *xmeet( const Type *t ) const;
676 virtual const Type *xdual() const; // Compute dual right now.
677 virtual const Type *widen( const Type *t, const Type* limit_type ) const;
678 virtual const Type *narrow( const Type *t ) const;
679 // Convenience common pre-built types.
680 static const TypeLong *MAX;
681 static const TypeLong *MIN;
682 static const TypeLong *MINUS_1;
683 static const TypeLong *ZERO;
684 static const TypeLong *ONE;
685 static const TypeLong *POS;
686 static const TypeLong *LONG;
687 static const TypeLong *INT; // 32-bit subrange [min_jint..max_jint]
688 static const TypeLong *UINT; // 32-bit unsigned [0..max_juint]
689 static const TypeLong *TYPE_DOMAIN; // alias for TypeLong::LONG
690
691 // static convenience methods.
692 static const TypeLong *as_self(const Type *t) { return t->is_long(); }
693
694#ifndef PRODUCT
695 virtual void dump2( Dict &d, uint, outputStream *st ) const;// Specialized per-Type dumping
696#endif
697};
698
699//------------------------------TypeTuple--------------------------------------
700// Class of Tuple Types, essentially type collections for function signatures
701// and class layouts. It happens to also be a fast cache for the HotSpot
702// signature types.
703class TypeTuple : public Type {
704 TypeTuple( uint cnt, const Type **fields ) : Type(Tuple), _cnt(cnt), _fields(fields) { }
705
706 const uint _cnt; // Count of fields
707 const Type ** const _fields; // Array of field types
708
709public:
710 virtual bool eq( const Type *t ) const;
711 virtual int hash() const; // Type specific hashing
712 virtual bool singleton(void) const; // TRUE if type is a singleton
713 virtual bool empty(void) const; // TRUE if type is vacuous
714
715 // Accessors:
716 uint cnt() const { return _cnt; }
717 const Type* field_at(uint i) const {
718 assert(i < _cnt, "oob")do { if (!(i < _cnt)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 718, "assert(" "i < _cnt" ") failed", "oob"); ::breakpoint
(); } } while (0)
;
719 return _fields[i];
720 }
721 void set_field_at(uint i, const Type* t) {
722 assert(i < _cnt, "oob")do { if (!(i < _cnt)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 722, "assert(" "i < _cnt" ") failed", "oob"); ::breakpoint
(); } } while (0)
;
723 _fields[i] = t;
724 }
725
726 static const TypeTuple *make( uint cnt, const Type **fields );
727 static const TypeTuple *make_range(ciSignature *sig);
728 static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig);
729
730 // Subroutine call type with space allocated for argument types
731 // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
732 static const Type **fields( uint arg_cnt );
733
734 virtual const Type *xmeet( const Type *t ) const;
735 virtual const Type *xdual() const; // Compute dual right now.
736 // Convenience common pre-built types.
737 static const TypeTuple *IFBOTH;
738 static const TypeTuple *IFFALSE;
739 static const TypeTuple *IFTRUE;
740 static const TypeTuple *IFNEITHER;
741 static const TypeTuple *LOOPBODY;
742 static const TypeTuple *MEMBAR;
743 static const TypeTuple *STORECONDITIONAL;
744 static const TypeTuple *START_I2C;
745 static const TypeTuple *INT_PAIR;
746 static const TypeTuple *LONG_PAIR;
747 static const TypeTuple *INT_CC_PAIR;
748 static const TypeTuple *LONG_CC_PAIR;
749#ifndef PRODUCT
750 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
751#endif
752};
753
754//------------------------------TypeAry----------------------------------------
755// Class of Array Types
756class TypeAry : public Type {
757 TypeAry(const Type* elem, const TypeInt* size, bool stable) : Type(Array),
758 _elem(elem), _size(size), _stable(stable) {}
759public:
760 virtual bool eq( const Type *t ) const;
761 virtual int hash() const; // Type specific hashing
762 virtual bool singleton(void) const; // TRUE if type is a singleton
763 virtual bool empty(void) const; // TRUE if type is vacuous
764
765private:
766 const Type *_elem; // Element type of array
767 const TypeInt *_size; // Elements in array
768 const bool _stable; // Are elements @Stable?
769 friend class TypeAryPtr;
770
771public:
772 static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false);
773
774 virtual const Type *xmeet( const Type *t ) const;
775 virtual const Type *xdual() const; // Compute dual right now.
776 bool ary_must_be_exact() const; // true if arrays of such are never generic
777 virtual const Type* remove_speculative() const;
778 virtual const Type* cleanup_speculative() const;
779#ifdef ASSERT1
780 // One type is interface, the other is oop
781 virtual bool interface_vs_oop(const Type *t) const;
782#endif
783#ifndef PRODUCT
784 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
785#endif
786};
787
788//------------------------------TypeVect---------------------------------------
789// Class of Vector Types
790class TypeVect : public Type {
791 const Type* _elem; // Vector's element type
792 const uint _length; // Elements in vector (power of 2)
793
794protected:
795 TypeVect(TYPES t, const Type* elem, uint length) : Type(t),
796 _elem(elem), _length(length) {}
797
798public:
799 const Type* element_type() const { return _elem; }
800 BasicType element_basic_type() const { return _elem->array_element_basic_type(); }
801 uint length() const { return _length; }
802 uint length_in_bytes() const {
803 return _length * type2aelembytes(element_basic_type());
804 }
805
806 virtual bool eq(const Type *t) const;
807 virtual int hash() const; // Type specific hashing
808 virtual bool singleton(void) const; // TRUE if type is a singleton
809 virtual bool empty(void) const; // TRUE if type is vacuous
810
811 static const TypeVect *make(const BasicType elem_bt, uint length, bool is_mask = false) {
812 // Use bottom primitive type.
813 return make(get_const_basic_type(elem_bt), length, is_mask);
814 }
815 // Used directly by Replicate nodes to construct singleton vector.
816 static const TypeVect *make(const Type* elem, uint length, bool is_mask = false);
817
818 static const TypeVect *makemask(const BasicType elem_bt, uint length) {
819 // Use bottom primitive type.
820 return makemask(get_const_basic_type(elem_bt), length);
821 }
822 static const TypeVect *makemask(const Type* elem, uint length);
823
824
825 virtual const Type *xmeet( const Type *t) const;
826 virtual const Type *xdual() const; // Compute dual right now.
827
828 static const TypeVect *VECTA;
829 static const TypeVect *VECTS;
830 static const TypeVect *VECTD;
831 static const TypeVect *VECTX;
832 static const TypeVect *VECTY;
833 static const TypeVect *VECTZ;
834 static const TypeVect *VECTMASK;
835
836#ifndef PRODUCT
837 virtual void dump2(Dict &d, uint, outputStream *st) const; // Specialized per-Type dumping
838#endif
839};
840
841class TypeVectA : public TypeVect {
842 friend class TypeVect;
843 TypeVectA(const Type* elem, uint length) : TypeVect(VectorA, elem, length) {}
844};
845
846class TypeVectS : public TypeVect {
847 friend class TypeVect;
848 TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {}
849};
850
851class TypeVectD : public TypeVect {
852 friend class TypeVect;
853 TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {}
854};
855
856class TypeVectX : public TypeVect {
857 friend class TypeVect;
858 TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {}
859};
860
861class TypeVectY : public TypeVect {
862 friend class TypeVect;
863 TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {}
864};
865
866class TypeVectZ : public TypeVect {
867 friend class TypeVect;
868 TypeVectZ(const Type* elem, uint length) : TypeVect(VectorZ, elem, length) {}
869};
870
871class TypeVectMask : public TypeVect {
872public:
873 friend class TypeVect;
874 TypeVectMask(const Type* elem, uint length) : TypeVect(VectorMask, elem, length) {}
875 virtual bool eq(const Type *t) const;
876 virtual const Type *xdual() const;
877 static const TypeVectMask* make(const BasicType elem_bt, uint length);
878 static const TypeVectMask* make(const Type* elem, uint length);
879};
880
881//------------------------------TypePtr----------------------------------------
882// Class of machine Pointer Types: raw data, instances or arrays.
883// If the _base enum is AnyPtr, then this refers to all of the above.
884// Otherwise the _base will indicate which subset of pointers is affected,
885// and the class will be inherited from.
886class TypePtr : public Type {
887 friend class TypeNarrowPtr;
888public:
889 enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
890protected:
891 TypePtr(TYPES t, PTR ptr, int offset,
892 const TypePtr* speculative = NULL__null,
893 int inline_depth = InlineDepthBottom) :
894 Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
895 _ptr(ptr) {}
896 static const PTR ptr_meet[lastPTR][lastPTR];
897 static const PTR ptr_dual[lastPTR];
898 static const char * const ptr_msg[lastPTR];
899
900 enum {
901 InlineDepthBottom = INT_MAX2147483647,
902 InlineDepthTop = -InlineDepthBottom
903 };
904
905 // Extra type information profiling gave us. We propagate it the
906 // same way the rest of the type info is propagated. If we want to
907 // use it, then we have to emit a guard: this part of the type is
908 // not something we know but something we speculate about the type.
909 const TypePtr* _speculative;
910 // For speculative types, we record at what inlining depth the
911 // profiling point that provided the data is. We want to favor
912 // profile data coming from outer scopes which are likely better for
913 // the current compilation.
914 int _inline_depth;
915
916 // utility methods to work on the speculative part of the type
917 const TypePtr* dual_speculative() const;
918 const TypePtr* xmeet_speculative(const TypePtr* other) const;
919 bool eq_speculative(const TypePtr* other) const;
920 int hash_speculative() const;
921 const TypePtr* add_offset_speculative(intptr_t offset) const;
922#ifndef PRODUCT
923 void dump_speculative(outputStream *st) const;
924#endif
925
926 // utility methods to work on the inline depth of the type
927 int dual_inline_depth() const;
928 int meet_inline_depth(int depth) const;
929#ifndef PRODUCT
930 void dump_inline_depth(outputStream *st) const;
931#endif
932
933 // TypeInstPtr (TypeAryPtr resp.) and TypeInstKlassPtr (TypeAryKlassPtr resp.) implement very similar meet logic.
934 // The logic for meeting 2 instances (2 arrays resp.) is shared in the 2 utility methods below. However the logic for
935 // the oop and klass versions can be slightly different and extra logic may have to be executed depending on what
936 // exact case the meet falls into. The MeetResult struct is used by the utility methods to communicate what case was
937 // encountered so the right logic specific to klasses or oops can be executed.,
938 enum MeetResult {
939 QUICK,
940 UNLOADED,
941 SUBTYPE,
942 NOT_SUBTYPE,
943 LCA
944 };
945 static MeetResult
946 meet_instptr(PTR &ptr, ciKlass* this_klass, ciKlass* tinst_klass, bool this_xk, bool tinst_xk, PTR this_ptr,
947 PTR tinst_ptr, ciKlass*&res_klass, bool &res_xk);
948 static MeetResult
949 meet_aryptr(PTR& ptr, const Type*& elem, ciKlass* this_klass, ciKlass* tap_klass, bool this_xk, bool tap_xk, PTR this_ptr, PTR tap_ptr, ciKlass*& res_klass, bool& res_xk);
950
951public:
952 const int _offset; // Offset into oop, with TOP & BOT
953 const PTR _ptr; // Pointer equivalence class
954
955 const int offset() const { return _offset; }
956 const PTR ptr() const { return _ptr; }
957
958 static const TypePtr *make(TYPES t, PTR ptr, int offset,
959 const TypePtr* speculative = NULL__null,
960 int inline_depth = InlineDepthBottom);
961
962 // Return a 'ptr' version of this type
963 virtual const Type *cast_to_ptr_type(PTR ptr) const;
964
965 virtual intptr_t get_con() const;
966
967 int xadd_offset( intptr_t offset ) const;
968 virtual const TypePtr *add_offset( intptr_t offset ) const;
969 virtual bool eq(const Type *t) const;
970 virtual int hash() const; // Type specific hashing
971
972 virtual bool singleton(void) const; // TRUE if type is a singleton
973 virtual bool empty(void) const; // TRUE if type is vacuous
974 virtual const Type *xmeet( const Type *t ) const;
975 virtual const Type *xmeet_helper( const Type *t ) const;
976 int meet_offset( int offset ) const;
977 int dual_offset( ) const;
978 virtual const Type *xdual() const; // Compute dual right now.
979
980 // meet, dual and join over pointer equivalence sets
981 PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
982 PTR dual_ptr() const { return ptr_dual[ptr()]; }
983
984 // This is textually confusing unless one recalls that
985 // join(t) == dual()->meet(t->dual())->dual().
986 PTR join_ptr( const PTR in_ptr ) const {
987 return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
988 }
989
990 // Speculative type helper methods.
991 virtual const TypePtr* speculative() const { return _speculative; }
992 int inline_depth() const { return _inline_depth; }
993 virtual ciKlass* speculative_type() const;
994 virtual ciKlass* speculative_type_not_null() const;
995 virtual bool speculative_maybe_null() const;
996 virtual bool speculative_always_null() const;
997 virtual const Type* remove_speculative() const;
998 virtual const Type* cleanup_speculative() const;
999 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1000 virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
1001 virtual const TypePtr* with_inline_depth(int depth) const;
1002
1003 virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
1004
1005 // Tests for relation to centerline of type lattice:
1006 static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
1007 static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
1008 // Convenience common pre-built types.
1009 static const TypePtr *NULL_PTR;
1010 static const TypePtr *NOTNULL;
1011 static const TypePtr *BOTTOM;
1012#ifndef PRODUCT
1013 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1014#endif
1015};
1016
1017//------------------------------TypeRawPtr-------------------------------------
1018// Class of raw pointers, pointers to things other than Oops. Examples
1019// include the stack pointer, top of heap, card-marking area, handles, etc.
1020class TypeRawPtr : public TypePtr {
1021protected:
1022 TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
1023public:
1024 virtual bool eq( const Type *t ) const;
1025 virtual int hash() const; // Type specific hashing
1026
1027 const address _bits; // Constant value, if applicable
1028
1029 static const TypeRawPtr *make( PTR ptr );
1030 static const TypeRawPtr *make( address bits );
1031
1032 // Return a 'ptr' version of this type
1033 virtual const TypeRawPtr* cast_to_ptr_type(PTR ptr) const;
1034
1035 virtual intptr_t get_con() const;
1036
1037 virtual const TypePtr *add_offset( intptr_t offset ) const;
1038
1039 virtual const Type *xmeet( const Type *t ) const;
1040 virtual const Type *xdual() const; // Compute dual right now.
1041 // Convenience common pre-built types.
1042 static const TypeRawPtr *BOTTOM;
1043 static const TypeRawPtr *NOTNULL;
1044#ifndef PRODUCT
1045 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1046#endif
1047};
1048
1049//------------------------------TypeOopPtr-------------------------------------
1050// Some kind of oop (Java pointer), either instance or array.
1051class TypeOopPtr : public TypePtr {
1052protected:
1053 TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id,
1054 const TypePtr* speculative, int inline_depth);
1055public:
1056 virtual bool eq( const Type *t ) const;
1057 virtual int hash() const; // Type specific hashing
1058 virtual bool singleton(void) const; // TRUE if type is a singleton
1059 enum {
1060 InstanceTop = -1, // undefined instance
1061 InstanceBot = 0 // any possible instance
1062 };
1063protected:
1064
1065 // Oop is NULL, unless this is a constant oop.
1066 ciObject* _const_oop; // Constant oop
1067 // If _klass is NULL, then so is _sig. This is an unloaded klass.
1068 ciKlass* _klass; // Klass object
1069 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
1070 bool _klass_is_exact;
1071 bool _is_ptr_to_narrowoop;
1072 bool _is_ptr_to_narrowklass;
1073 bool _is_ptr_to_boxed_value;
1074
1075 // If not InstanceTop or InstanceBot, indicates that this is
1076 // a particular instance of this type which is distinct.
1077 // This is the node index of the allocation node creating this instance.
1078 int _instance_id;
1079
1080 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
1081
1082 int dual_instance_id() const;
1083 int meet_instance_id(int uid) const;
1084
1085 // Do not allow interface-vs.-noninterface joins to collapse to top.
1086 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1087
1088public:
1089 // Creates a type given a klass. Correctly handles multi-dimensional arrays
1090 // Respects UseUniqueSubclasses.
1091 // If the klass is final, the resulting type will be exact.
1092 static const TypeOopPtr* make_from_klass(ciKlass* klass) {
1093 return make_from_klass_common(klass, true, false);
1094 }
1095 // Same as before, but will produce an exact type, even if
1096 // the klass is not final, as long as it has exactly one implementation.
1097 static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
1098 return make_from_klass_common(klass, true, true);
1099 }
1100 // Same as before, but does not respects UseUniqueSubclasses.
1101 // Use this only for creating array element types.
1102 static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
1103 return make_from_klass_common(klass, false, false);
1104 }
1105 // Creates a singleton type given an object.
1106 // If the object cannot be rendered as a constant,
1107 // may return a non-singleton type.
1108 // If require_constant, produce a NULL if a singleton is not possible.
1109 static const TypeOopPtr* make_from_constant(ciObject* o,
1110 bool require_constant = false);
1111
1112 // Make a generic (unclassed) pointer to an oop.
1113 static const TypeOopPtr* make(PTR ptr, int offset, int instance_id,
1114 const TypePtr* speculative = NULL__null,
1115 int inline_depth = InlineDepthBottom);
1116
1117 ciObject* const_oop() const { return _const_oop; }
1118 virtual ciKlass* klass() const { return _klass; }
1119 bool klass_is_exact() const { return _klass_is_exact; }
1120
1121 // Returns true if this pointer points at memory which contains a
1122 // compressed oop references.
1123 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1124 bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1125 bool is_ptr_to_boxed_value() const { return _is_ptr_to_boxed_value; }
1126 bool is_known_instance() const { return _instance_id > 0; }
1127 int instance_id() const { return _instance_id; }
1128 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
1129
1130 virtual intptr_t get_con() const;
1131
1132 virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1133
1134 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1135
1136 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1137
1138 // corresponding pointer to klass, for a given instance
1139 virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1140
1141 virtual const TypePtr *add_offset( intptr_t offset ) const;
1142
1143 // Speculative type helper methods.
1144 virtual const Type* remove_speculative() const;
1145 virtual const Type* cleanup_speculative() const;
1146 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1147 virtual const TypePtr* with_inline_depth(int depth) const;
1148
1149 virtual const TypePtr* with_instance_id(int instance_id) const;
1150
1151 virtual const Type *xdual() const; // Compute dual right now.
1152 // the core of the computation of the meet for TypeOopPtr and for its subclasses
1153 virtual const Type *xmeet_helper(const Type *t) const;
1154
1155 // Convenience common pre-built type.
1156 static const TypeOopPtr *BOTTOM;
1157#ifndef PRODUCT
1158 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1159#endif
1160};
1161
1162//------------------------------TypeInstPtr------------------------------------
1163// Class of Java object pointers, pointing either to non-array Java instances
1164// or to a Klass* (including array klasses).
1165class TypeInstPtr : public TypeOopPtr {
1166 TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id,
1167 const TypePtr* speculative, int inline_depth);
1168 virtual bool eq( const Type *t ) const;
1169 virtual int hash() const; // Type specific hashing
1170
1171 ciSymbol* _name; // class name
1172
1173 public:
1174 ciSymbol* name() const { return _name; }
1175
1176 bool is_loaded() const { return _klass->is_loaded(); }
1177
1178 // Make a pointer to a constant oop.
1179 static const TypeInstPtr *make(ciObject* o) {
1180 return make(TypePtr::Constant, o->klass(), true, o, 0, InstanceBot);
1181 }
1182 // Make a pointer to a constant oop with offset.
1183 static const TypeInstPtr *make(ciObject* o, int offset) {
1184 return make(TypePtr::Constant, o->klass(), true, o, offset, InstanceBot);
1185 }
1186
1187 // Make a pointer to some value of type klass.
1188 static const TypeInstPtr *make(PTR ptr, ciKlass* klass) {
1189 return make(ptr, klass, false, NULL__null, 0, InstanceBot);
1190 }
1191
1192 // Make a pointer to some non-polymorphic value of exactly type klass.
1193 static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1194 return make(ptr, klass, true, NULL__null, 0, InstanceBot);
1195 }
1196
1197 // Make a pointer to some value of type klass with offset.
1198 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
1199 return make(ptr, klass, false, NULL__null, offset, InstanceBot);
1200 }
1201
1202 // Make a pointer to an oop.
1203 static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset,
1204 int instance_id = InstanceBot,
1205 const TypePtr* speculative = NULL__null,
1206 int inline_depth = InlineDepthBottom);
1207
1208 /** Create constant type for a constant boxed value */
1209 const Type* get_const_boxed_value() const;
1210
1211 // If this is a java.lang.Class constant, return the type for it or NULL.
1212 // Pass to Type::get_const_type to turn it to a type, which will usually
1213 // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1214 ciType* java_mirror_type() const;
1215
1216 virtual const TypeInstPtr* cast_to_ptr_type(PTR ptr) const;
1217
1218 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1219
1220 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1221
1222 virtual const TypePtr *add_offset( intptr_t offset ) const;
1223
1224 // Speculative type helper methods.
1225 virtual const Type* remove_speculative() const;
1226 virtual const TypePtr* with_inline_depth(int depth) const;
1227 virtual const TypePtr* with_instance_id(int instance_id) const;
1228
1229 // the core of the computation of the meet of 2 types
1230 virtual const Type *xmeet_helper(const Type *t) const;
1231 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
1232 virtual const Type *xdual() const; // Compute dual right now.
1233
1234 const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1235
1236 // Convenience common pre-built types.
1237 static const TypeInstPtr *NOTNULL;
1238 static const TypeInstPtr *BOTTOM;
1239 static const TypeInstPtr *MIRROR;
1240 static const TypeInstPtr *MARK;
1241 static const TypeInstPtr *KLASS;
1242#ifndef PRODUCT
1243 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1244#endif
1245};
1246
1247//------------------------------TypeAryPtr-------------------------------------
1248// Class of Java array pointers
1249class TypeAryPtr : public TypeOopPtr {
1250 TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1251 int offset, int instance_id, bool is_autobox_cache,
1252 const TypePtr* speculative, int inline_depth)
1253 : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative, inline_depth),
1254 _ary(ary),
1255 _is_autobox_cache(is_autobox_cache)
1256 {
1257#ifdef ASSERT1
1258 if (k != NULL__null) {
1259 // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
1260 ciKlass* ck = compute_klass(true);
1261 if (k != ck) {
1262 this->dump(); tty->cr();
1263 tty->print(" k: ");
1264 k->print(); tty->cr();
1265 tty->print("ck: ");
1266 if (ck != NULL__null) ck->print();
1267 else tty->print("<NULL>");
1268 tty->cr();
1269 assert(false, "unexpected TypeAryPtr::_klass")do { if (!(false)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1269, "assert(" "false" ") failed", "unexpected TypeAryPtr::_klass"
); ::breakpoint(); } } while (0)
;
1270 }
1271 }
1272#endif
1273 }
1274 virtual bool eq( const Type *t ) const;
1275 virtual int hash() const; // Type specific hashing
1276 const TypeAry *_ary; // Array we point into
1277 const bool _is_autobox_cache;
1278
1279 ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)bool verify = false) const;
1280
1281public:
1282 // Accessors
1283 ciKlass* klass() const;
1284 const TypeAry* ary() const { return _ary; }
1285 const Type* elem() const { return _ary->_elem; }
1286 const TypeInt* size() const { return _ary->_size; }
1287 bool is_stable() const { return _ary->_stable; }
1288
1289 bool is_autobox_cache() const { return _is_autobox_cache; }
1290
1291 static const TypeAryPtr *make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset,
1292 int instance_id = InstanceBot,
1293 const TypePtr* speculative = NULL__null,
1294 int inline_depth = InlineDepthBottom);
1295 // Constant pointer to array
1296 static const TypeAryPtr *make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset,
1297 int instance_id = InstanceBot,
1298 const TypePtr* speculative = NULL__null,
1299 int inline_depth = InlineDepthBottom, bool is_autobox_cache = false);
1300
1301 // Return a 'ptr' version of this type
1302 virtual const TypeAryPtr* cast_to_ptr_type(PTR ptr) const;
1303
1304 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1305
1306 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1307
1308 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1309 virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1310
1311 virtual bool empty(void) const; // TRUE if type is vacuous
1312 virtual const TypePtr *add_offset( intptr_t offset ) const;
1313
1314 // Speculative type helper methods.
1315 virtual const Type* remove_speculative() const;
1316 virtual const TypePtr* with_inline_depth(int depth) const;
1317 virtual const TypePtr* with_instance_id(int instance_id) const;
1318
1319 // the core of the computation of the meet of 2 types
1320 virtual const Type *xmeet_helper(const Type *t) const;
1321 virtual const Type *xdual() const; // Compute dual right now.
1322
1323 const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1324 int stable_dimension() const;
1325
1326 const TypeAryPtr* cast_to_autobox_cache() const;
1327
1328 static jint max_array_length(BasicType etype) ;
1329 virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1330
1331 // Convenience common pre-built types.
1332 static const TypeAryPtr *RANGE;
1333 static const TypeAryPtr *OOPS;
1334 static const TypeAryPtr *NARROWOOPS;
1335 static const TypeAryPtr *BYTES;
1336 static const TypeAryPtr *SHORTS;
1337 static const TypeAryPtr *CHARS;
1338 static const TypeAryPtr *INTS;
1339 static const TypeAryPtr *LONGS;
1340 static const TypeAryPtr *FLOATS;
1341 static const TypeAryPtr *DOUBLES;
1342 // selects one of the above:
1343 static const TypeAryPtr *get_array_body_type(BasicType elem) {
1344 assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type")do { if (!((uint)elem <= T_CONFLICT && _array_body_type
[elem] != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1344, "assert(" "(uint)elem <= T_CONFLICT && _array_body_type[elem] != __null"
") failed", "bad elem type"); ::breakpoint(); } } while (0)
;
1345 return _array_body_type[elem];
1346 }
1347 static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1348 // sharpen the type of an int which is used as an array size
1349#ifdef ASSERT1
1350 // One type is interface, the other is oop
1351 virtual bool interface_vs_oop(const Type *t) const;
1352#endif
1353#ifndef PRODUCT
1354 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1355#endif
1356};
1357
1358//------------------------------TypeMetadataPtr-------------------------------------
1359// Some kind of metadata, either Method*, MethodData* or CPCacheOop
1360class TypeMetadataPtr : public TypePtr {
1361protected:
1362 TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
1363 // Do not allow interface-vs.-noninterface joins to collapse to top.
1364 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1365public:
1366 virtual bool eq( const Type *t ) const;
1367 virtual int hash() const; // Type specific hashing
1368 virtual bool singleton(void) const; // TRUE if type is a singleton
1369
1370private:
1371 ciMetadata* _metadata;
1372
1373public:
1374 static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset);
1375
1376 static const TypeMetadataPtr* make(ciMethod* m);
1377 static const TypeMetadataPtr* make(ciMethodData* m);
1378
1379 ciMetadata* metadata() const { return _metadata; }
1380
1381 virtual const TypeMetadataPtr* cast_to_ptr_type(PTR ptr) const;
1382
1383 virtual const TypePtr *add_offset( intptr_t offset ) const;
1384
1385 virtual const Type *xmeet( const Type *t ) const;
1386 virtual const Type *xdual() const; // Compute dual right now.
1387
1388 virtual intptr_t get_con() const;
1389
1390 // Convenience common pre-built types.
1391 static const TypeMetadataPtr *BOTTOM;
1392
1393#ifndef PRODUCT
1394 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1395#endif
1396};
1397
1398//------------------------------TypeKlassPtr-----------------------------------
1399// Class of Java Klass pointers
1400class TypeKlassPtr : public TypePtr {
1401protected:
1402 TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, int offset);
1403
1404 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1405
1406public:
1407 virtual bool eq( const Type *t ) const;
1408 virtual int hash() const;
1409 virtual bool singleton(void) const; // TRUE if type is a singleton
1410 virtual bool must_be_exact() const { ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1410); ::breakpoint(); } while (0)
; return false; }
1411
1412protected:
1413
1414 ciKlass* _klass;
1415
1416public:
1417
1418 virtual ciKlass* klass() const { return _klass; }
1419 bool klass_is_exact() const { return _ptr == Constant; }
1420 bool is_loaded() const { return klass()->is_loaded(); }
1421
1422 static const TypeKlassPtr* make(ciKlass* klass);
1423 static const TypeKlassPtr *make(PTR ptr, ciKlass* klass, int offset);
1424
1425
1426 virtual const TypePtr* cast_to_ptr_type(PTR ptr) const { ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1426); ::breakpoint(); } while (0)
; return NULL__null; }
1427
1428 virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const { ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1428); ::breakpoint(); } while (0)
; return NULL__null; }
1429
1430 // corresponding pointer to instance, for a given class
1431 virtual const TypeOopPtr* as_instance_type() const { ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1431); ::breakpoint(); } while (0)
; return NULL__null; }
1432
1433 virtual const TypePtr *add_offset( intptr_t offset ) const { ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1433); ::breakpoint(); } while (0)
; return NULL__null; }
1434 virtual const Type *xmeet( const Type *t ) const { ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1434); ::breakpoint(); } while (0)
; return NULL__null; }
1435 virtual const Type *xdual() const { ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1435); ::breakpoint(); } while (0)
; return NULL__null; }
1436
1437 virtual intptr_t get_con() const;
1438
1439 virtual const TypeKlassPtr* with_offset(intptr_t offset) const { ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1439); ::breakpoint(); } while (0)
; return NULL__null; }
1440
1441#ifndef PRODUCT
1442 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1443#endif
1444};
1445
1446// Instance klass pointer, mirrors TypeInstPtr
1447class TypeInstKlassPtr : public TypeKlassPtr {
1448
1449 TypeInstKlassPtr(PTR ptr, ciKlass* klass, int offset)
1450 : TypeKlassPtr(InstKlassPtr, ptr, klass, offset) {
1451 }
1452
1453 virtual bool must_be_exact() const;
1454
1455public:
1456 // Instance klass ignoring any interface
1457 ciInstanceKlass* instance_klass() const { return klass()->as_instance_klass(); }
1458
1459 static const TypeInstKlassPtr *make(ciKlass* k) {
1460 return make(TypePtr::Constant, k, 0);
1461 }
1462 static const TypeInstKlassPtr *make(PTR ptr, ciKlass* k, int offset);
1463
1464 virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1465
1466 virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1467
1468 // corresponding pointer to instance, for a given class
1469 virtual const TypeOopPtr* as_instance_type() const;
1470 virtual int hash() const;
1471 virtual bool eq(const Type *t) const;
1472
1473 virtual const TypePtr *add_offset( intptr_t offset ) const;
1474 virtual const Type *xmeet( const Type *t ) const;
1475 virtual const Type *xdual() const;
1476 virtual const TypeKlassPtr* with_offset(intptr_t offset) const;
1477
1478 // Convenience common pre-built types.
1479 static const TypeInstKlassPtr* OBJECT; // Not-null object klass or below
1480 static const TypeInstKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
1481};
1482
1483// Array klass pointer, mirrors TypeAryPtr
1484class TypeAryKlassPtr : public TypeKlassPtr {
1485 const Type *_elem;
1486
1487 TypeAryKlassPtr(PTR ptr, const Type *elem, ciKlass* klass, int offset)
1488 : TypeKlassPtr(AryKlassPtr, ptr, klass, offset), _elem(elem) {
1489 }
1490
1491 virtual bool must_be_exact() const;
1492
1493public:
1494 virtual ciKlass* klass() const;
1495
1496 // returns base element type, an instance klass (and not interface) for object arrays
1497 const Type* base_element_type(int& dims) const;
1498
1499 static const TypeAryKlassPtr *make(PTR ptr, ciKlass* k, int offset);
1500 static const TypeAryKlassPtr *make(PTR ptr, const Type *elem, ciKlass* k, int offset);
1501 static const TypeAryKlassPtr* make(ciKlass* klass);
1502
1503 const Type *elem() const { return _elem; }
1504
1505 virtual bool eq(const Type *t) const;
1506 virtual int hash() const; // Type specific hashing
1507
1508 virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1509
1510 virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1511
1512 // corresponding pointer to instance, for a given class
1513 virtual const TypeOopPtr* as_instance_type() const;
1514
1515 virtual const TypePtr *add_offset( intptr_t offset ) const;
1516 virtual const Type *xmeet( const Type *t ) const;
1517 virtual const Type *xdual() const; // Compute dual right now.
1518
1519 virtual const TypeKlassPtr* with_offset(intptr_t offset) const;
1520
1521 virtual bool empty(void) const {
1522 return TypeKlassPtr::empty() || _elem->empty();
1523 }
1524
1525#ifndef PRODUCT
1526 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1527#endif
1528};
1529
1530class TypeNarrowPtr : public Type {
1531protected:
1532 const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
1533
1534 TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
1535 _ptrtype(ptrtype) {
1536 assert(ptrtype->offset() == 0 ||do { if (!(ptrtype->offset() == 0 || ptrtype->offset() ==
OffsetBot || ptrtype->offset() == OffsetTop)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1538, "assert(" "ptrtype->offset() == 0 || ptrtype->offset() == OffsetBot || ptrtype->offset() == OffsetTop"
") failed", "no real offsets"); ::breakpoint(); } } while (0
)
1537 ptrtype->offset() == OffsetBot ||do { if (!(ptrtype->offset() == 0 || ptrtype->offset() ==
OffsetBot || ptrtype->offset() == OffsetTop)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1538, "assert(" "ptrtype->offset() == 0 || ptrtype->offset() == OffsetBot || ptrtype->offset() == OffsetTop"
") failed", "no real offsets"); ::breakpoint(); } } while (0
)
1538 ptrtype->offset() == OffsetTop, "no real offsets")do { if (!(ptrtype->offset() == 0 || ptrtype->offset() ==
OffsetBot || ptrtype->offset() == OffsetTop)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1538, "assert(" "ptrtype->offset() == 0 || ptrtype->offset() == OffsetBot || ptrtype->offset() == OffsetTop"
") failed", "no real offsets"); ::breakpoint(); } } while (0
)
;
1539 }
1540
1541 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1542 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
1543 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0;
1544 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0;
1545 // Do not allow interface-vs.-noninterface joins to collapse to top.
1546 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1547public:
1548 virtual bool eq( const Type *t ) const;
1549 virtual int hash() const; // Type specific hashing
1550 virtual bool singleton(void) const; // TRUE if type is a singleton
1551
1552 virtual const Type *xmeet( const Type *t ) const;
1553 virtual const Type *xdual() const; // Compute dual right now.
1554
1555 virtual intptr_t get_con() const;
1556
1557 virtual bool empty(void) const; // TRUE if type is vacuous
1558
1559 // returns the equivalent ptr type for this compressed pointer
1560 const TypePtr *get_ptrtype() const {
1561 return _ptrtype;
1562 }
1563
1564 bool is_known_instance() const {
1565 return _ptrtype->is_known_instance();
1566 }
1567
1568#ifndef PRODUCT
1569 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1570#endif
1571};
1572
1573//------------------------------TypeNarrowOop----------------------------------
1574// A compressed reference to some kind of Oop. This type wraps around
1575// a preexisting TypeOopPtr and forwards most of it's operations to
1576// the underlying type. It's only real purpose is to track the
1577// oopness of the compressed oop value when we expose the conversion
1578// between the normal and the compressed form.
1579class TypeNarrowOop : public TypeNarrowPtr {
1580protected:
1581 TypeNarrowOop( const TypePtr* ptrtype): TypeNarrowPtr(NarrowOop, ptrtype) {
1582 }
1583
1584 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
1585 return t->isa_narrowoop();
1586 }
1587
1588 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
1589 return t->is_narrowoop();
1590 }
1591
1592 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
1593 return new TypeNarrowOop(t);
1594 }
1595
1596 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1597 return (const TypeNarrowPtr*)((new TypeNarrowOop(t))->hashcons());
1598 }
1599
1600public:
1601
1602 static const TypeNarrowOop *make( const TypePtr* type);
1603
1604 static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) {
1605 return make(TypeOopPtr::make_from_constant(con, require_constant));
1606 }
1607
1608 static const TypeNarrowOop *BOTTOM;
1609 static const TypeNarrowOop *NULL_PTR;
1610
1611 virtual const Type* remove_speculative() const;
1612 virtual const Type* cleanup_speculative() const;
1613
1614#ifndef PRODUCT
1615 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1616#endif
1617};
1618
1619//------------------------------TypeNarrowKlass----------------------------------
1620// A compressed reference to klass pointer. This type wraps around a
1621// preexisting TypeKlassPtr and forwards most of it's operations to
1622// the underlying type.
1623class TypeNarrowKlass : public TypeNarrowPtr {
1624protected:
1625 TypeNarrowKlass( const TypePtr* ptrtype): TypeNarrowPtr(NarrowKlass, ptrtype) {
1626 }
1627
1628 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
1629 return t->isa_narrowklass();
1630 }
1631
1632 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
1633 return t->is_narrowklass();
1634 }
1635
1636 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
1637 return new TypeNarrowKlass(t);
1638 }
1639
1640 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1641 return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
1642 }
1643
1644public:
1645 static const TypeNarrowKlass *make( const TypePtr* type);
1646
1647 // static const TypeNarrowKlass *BOTTOM;
1648 static const TypeNarrowKlass *NULL_PTR;
1649
1650#ifndef PRODUCT
1651 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1652#endif
1653};
1654
1655//------------------------------TypeFunc---------------------------------------
1656// Class of Array Types
1657class TypeFunc : public Type {
1658 TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function), _domain(domain), _range(range) {}
1659 virtual bool eq( const Type *t ) const;
1660 virtual int hash() const; // Type specific hashing
1661 virtual bool singleton(void) const; // TRUE if type is a singleton
1662 virtual bool empty(void) const; // TRUE if type is vacuous
1663
1664 const TypeTuple* const _domain; // Domain of inputs
1665 const TypeTuple* const _range; // Range of results
1666
1667public:
1668 // Constants are shared among ADLC and VM
1669 enum { Control = AdlcVMDeps::Control,
1670 I_O = AdlcVMDeps::I_O,
1671 Memory = AdlcVMDeps::Memory,
1672 FramePtr = AdlcVMDeps::FramePtr,
1673 ReturnAdr = AdlcVMDeps::ReturnAdr,
1674 Parms = AdlcVMDeps::Parms
1675 };
1676
1677
1678 // Accessors:
1679 const TypeTuple* domain() const { return _domain; }
1680 const TypeTuple* range() const { return _range; }
1681
1682 static const TypeFunc *make(ciMethod* method);
1683 static const TypeFunc *make(ciSignature signature, const Type* extra);
1684 static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
1685
1686 virtual const Type *xmeet( const Type *t ) const;
1687 virtual const Type *xdual() const; // Compute dual right now.
1688
1689 BasicType return_type() const;
1690
1691#ifndef PRODUCT
1692 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1693#endif
1694 // Convenience common pre-built types.
1695};
1696
1697//------------------------------accessors--------------------------------------
1698inline bool Type::is_ptr_to_narrowoop() const {
1699#ifdef _LP641
1700 return (isa_oopptr() != NULL__null && is_oopptr()->is_ptr_to_narrowoop_nv());
1701#else
1702 return false;
1703#endif
1704}
1705
1706inline bool Type::is_ptr_to_narrowklass() const {
1707#ifdef _LP641
1708 return (isa_oopptr() != NULL__null && is_oopptr()->is_ptr_to_narrowklass_nv());
1709#else
1710 return false;
1711#endif
1712}
1713
1714inline float Type::getf() const {
1715 assert( _base == FloatCon, "Not a FloatCon" )do { if (!(_base == FloatCon)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1715, "assert(" "_base == FloatCon" ") failed", "Not a FloatCon"
); ::breakpoint(); } } while (0)
;
1716 return ((TypeF*)this)->_f;
1717}
1718
1719inline double Type::getd() const {
1720 assert( _base == DoubleCon, "Not a DoubleCon" )do { if (!(_base == DoubleCon)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1720, "assert(" "_base == DoubleCon" ") failed", "Not a DoubleCon"
); ::breakpoint(); } } while (0)
;
1721 return ((TypeD*)this)->_d;
1722}
1723
1724inline const TypeInteger *Type::is_integer(BasicType bt) const {
1725 assert((bt == T_INT && _base == Int) || (bt == T_LONG && _base == Long), "Not an Int")do { if (!((bt == T_INT && _base == Int) || (bt == T_LONG
&& _base == Long))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1725, "assert(" "(bt == T_INT && _base == Int) || (bt == T_LONG && _base == Long)"
") failed", "Not an Int"); ::breakpoint(); } } while (0)
;
1726 return (TypeInteger*)this;
1727}
1728
1729inline const TypeInteger *Type::isa_integer(BasicType bt) const {
1730 return (((bt == T_INT && _base == Int) || (bt == T_LONG && _base == Long)) ? (TypeInteger*)this : NULL__null);
1731}
1732
1733inline const TypeInt *Type::is_int() const {
1734 assert( _base == Int, "Not an Int" )do { if (!(_base == Int)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1734, "assert(" "_base == Int" ") failed", "Not an Int"); ::
breakpoint(); } } while (0)
;
1735 return (TypeInt*)this;
1736}
1737
1738inline const TypeInt *Type::isa_int() const {
1739 return ( _base == Int ? (TypeInt*)this : NULL__null);
1740}
1741
1742inline const TypeLong *Type::is_long() const {
1743 assert( _base == Long, "Not a Long" )do { if (!(_base == Long)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1743, "assert(" "_base == Long" ") failed", "Not a Long"); ::
breakpoint(); } } while (0)
;
1744 return (TypeLong*)this;
1745}
1746
1747inline const TypeLong *Type::isa_long() const {
1748 return ( _base == Long ? (TypeLong*)this : NULL__null);
1749}
1750
1751inline const TypeF *Type::isa_float() const {
1752 return ((_base == FloatTop ||
1753 _base == FloatCon ||
1754 _base == FloatBot) ? (TypeF*)this : NULL__null);
1755}
1756
1757inline const TypeF *Type::is_float_constant() const {
1758 assert( _base == FloatCon, "Not a Float" )do { if (!(_base == FloatCon)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1758, "assert(" "_base == FloatCon" ") failed", "Not a Float"
); ::breakpoint(); } } while (0)
;
1759 return (TypeF*)this;
1760}
1761
1762inline const TypeF *Type::isa_float_constant() const {
1763 return ( _base == FloatCon ? (TypeF*)this : NULL__null);
1764}
1765
1766inline const TypeD *Type::isa_double() const {
1767 return ((_base == DoubleTop ||
1768 _base == DoubleCon ||
1769 _base == DoubleBot) ? (TypeD*)this : NULL__null);
1770}
1771
1772inline const TypeD *Type::is_double_constant() const {
1773 assert( _base == DoubleCon, "Not a Double" )do { if (!(_base == DoubleCon)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1773, "assert(" "_base == DoubleCon" ") failed", "Not a Double"
); ::breakpoint(); } } while (0)
;
1774 return (TypeD*)this;
1775}
1776
1777inline const TypeD *Type::isa_double_constant() const {
1778 return ( _base == DoubleCon ? (TypeD*)this : NULL__null);
1779}
1780
1781inline const TypeTuple *Type::is_tuple() const {
1782 assert( _base == Tuple, "Not a Tuple" )do { if (!(_base == Tuple)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1782, "assert(" "_base == Tuple" ") failed", "Not a Tuple")
; ::breakpoint(); } } while (0)
;
1783 return (TypeTuple*)this;
1784}
1785
1786inline const TypeAry *Type::is_ary() const {
1787 assert( _base == Array , "Not an Array" )do { if (!(_base == Array)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1787, "assert(" "_base == Array" ") failed", "Not an Array"
); ::breakpoint(); } } while (0)
;
1788 return (TypeAry*)this;
1789}
1790
1791inline const TypeAry *Type::isa_ary() const {
1792 return ((_base == Array) ? (TypeAry*)this : NULL__null);
1793}
1794
1795inline const TypeVectMask *Type::is_vectmask() const {
1796 assert( _base == VectorMask, "Not a Vector Mask" )do { if (!(_base == VectorMask)) { (*g_assert_poison) = 'X';;
report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1796, "assert(" "_base == VectorMask" ") failed", "Not a Vector Mask"
); ::breakpoint(); } } while (0)
;
1797 return (TypeVectMask*)this;
1798}
1799
1800inline const TypeVectMask *Type::isa_vectmask() const {
1801 return (_base == VectorMask) ? (TypeVectMask*)this : NULL__null;
1802}
1803
1804inline const TypeVect *Type::is_vect() const {
1805 assert( _base >= VectorMask && _base <= VectorZ, "Not a Vector" )do { if (!(_base >= VectorMask && _base <= VectorZ
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1805, "assert(" "_base >= VectorMask && _base <= VectorZ"
") failed", "Not a Vector"); ::breakpoint(); } } while (0)
;
1806 return (TypeVect*)this;
1807}
1808
1809inline const TypeVect *Type::isa_vect() const {
1810 return (_base >= VectorMask && _base <= VectorZ) ? (TypeVect*)this : NULL__null;
1811}
1812
1813inline const TypePtr *Type::is_ptr() const {
1814 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
1815 assert(_base >= AnyPtr && _base <= AryKlassPtr, "Not a pointer")do { if (!(_base >= AnyPtr && _base <= AryKlassPtr
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1815, "assert(" "_base >= AnyPtr && _base <= AryKlassPtr"
") failed", "Not a pointer"); ::breakpoint(); } } while (0)
;
1816 return (TypePtr*)this;
1817}
1818
1819inline const TypePtr *Type::isa_ptr() const {
1820 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
1821 return (_base >= AnyPtr && _base <= AryKlassPtr) ? (TypePtr*)this : NULL__null;
1822}
1823
1824inline const TypeOopPtr *Type::is_oopptr() const {
1825 // OopPtr is the first and KlassPtr the last, with no non-oops between.
1826 assert(_base >= OopPtr && _base <= AryPtr, "Not a Java pointer" )do { if (!(_base >= OopPtr && _base <= AryPtr))
{ (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1826, "assert(" "_base >= OopPtr && _base <= AryPtr"
") failed", "Not a Java pointer"); ::breakpoint(); } } while
(0)
;
1827 return (TypeOopPtr*)this;
1828}
1829
1830inline const TypeOopPtr *Type::isa_oopptr() const {
1831 // OopPtr is the first and KlassPtr the last, with no non-oops between.
1832 return (_base >= OopPtr && _base <= AryPtr) ? (TypeOopPtr*)this : NULL__null;
1833}
1834
1835inline const TypeRawPtr *Type::isa_rawptr() const {
1836 return (_base == RawPtr) ? (TypeRawPtr*)this : NULL__null;
1837}
1838
1839inline const TypeRawPtr *Type::is_rawptr() const {
1840 assert( _base == RawPtr, "Not a raw pointer" )do { if (!(_base == RawPtr)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1840, "assert(" "_base == RawPtr" ") failed", "Not a raw pointer"
); ::breakpoint(); } } while (0)
;
1841 return (TypeRawPtr*)this;
1842}
1843
1844inline const TypeInstPtr *Type::isa_instptr() const {
1845 return (_base == InstPtr) ? (TypeInstPtr*)this : NULL__null;
1846}
1847
1848inline const TypeInstPtr *Type::is_instptr() const {
1849 assert( _base == InstPtr, "Not an object pointer" )do { if (!(_base == InstPtr)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1849, "assert(" "_base == InstPtr" ") failed", "Not an object pointer"
); ::breakpoint(); } } while (0)
;
1850 return (TypeInstPtr*)this;
1851}
1852
1853inline const TypeAryPtr *Type::isa_aryptr() const {
1854 return (_base == AryPtr) ? (TypeAryPtr*)this : NULL__null;
1855}
1856
1857inline const TypeAryPtr *Type::is_aryptr() const {
1858 assert( _base == AryPtr, "Not an array pointer" )do { if (!(_base == AryPtr)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1858, "assert(" "_base == AryPtr" ") failed", "Not an array pointer"
); ::breakpoint(); } } while (0)
;
1859 return (TypeAryPtr*)this;
1860}
1861
1862inline const TypeNarrowOop *Type::is_narrowoop() const {
1863 // OopPtr is the first and KlassPtr the last, with no non-oops between.
1864 assert(_base == NarrowOop, "Not a narrow oop" )do { if (!(_base == NarrowOop)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1864, "assert(" "_base == NarrowOop" ") failed", "Not a narrow oop"
); ::breakpoint(); } } while (0)
;
1865 return (TypeNarrowOop*)this;
1866}
1867
1868inline const TypeNarrowOop *Type::isa_narrowoop() const {
1869 // OopPtr is the first and KlassPtr the last, with no non-oops between.
1870 return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL__null;
1871}
1872
1873inline const TypeNarrowKlass *Type::is_narrowklass() const {
1874 assert(_base == NarrowKlass, "Not a narrow oop" )do { if (!(_base == NarrowKlass)) { (*g_assert_poison) = 'X';
; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1874, "assert(" "_base == NarrowKlass" ") failed", "Not a narrow oop"
); ::breakpoint(); } } while (0)
;
1875 return (TypeNarrowKlass*)this;
1876}
1877
1878inline const TypeNarrowKlass *Type::isa_narrowklass() const {
1879 return (_base == NarrowKlass) ? (TypeNarrowKlass*)this : NULL__null;
1880}
1881
1882inline const TypeMetadataPtr *Type::is_metadataptr() const {
1883 // MetadataPtr is the first and CPCachePtr the last
1884 assert(_base == MetadataPtr, "Not a metadata pointer" )do { if (!(_base == MetadataPtr)) { (*g_assert_poison) = 'X';
; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1884, "assert(" "_base == MetadataPtr" ") failed", "Not a metadata pointer"
); ::breakpoint(); } } while (0)
;
1885 return (TypeMetadataPtr*)this;
1886}
1887
1888inline const TypeMetadataPtr *Type::isa_metadataptr() const {
1889 return (_base == MetadataPtr) ? (TypeMetadataPtr*)this : NULL__null;
1890}
1891
1892inline const TypeKlassPtr *Type::isa_klassptr() const {
1893 return (_base >= KlassPtr && _base <= AryKlassPtr ) ? (TypeKlassPtr*)this : NULL__null;
1894}
1895
1896inline const TypeKlassPtr *Type::is_klassptr() const {
1897 assert(_base >= KlassPtr && _base <= AryKlassPtr, "Not a klass pointer")do { if (!(_base >= KlassPtr && _base <= AryKlassPtr
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1897, "assert(" "_base >= KlassPtr && _base <= AryKlassPtr"
") failed", "Not a klass pointer"); ::breakpoint(); } } while
(0)
;
1898 return (TypeKlassPtr*)this;
1899}
1900
1901inline const TypeInstKlassPtr *Type::isa_instklassptr() const {
1902 return (_base == InstKlassPtr) ? (TypeInstKlassPtr*)this : NULL__null;
1903}
1904
1905inline const TypeInstKlassPtr *Type::is_instklassptr() const {
1906 assert(_base == InstKlassPtr, "Not a klass pointer")do { if (!(_base == InstKlassPtr)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1906, "assert(" "_base == InstKlassPtr" ") failed", "Not a klass pointer"
); ::breakpoint(); } } while (0)
;
1907 return (TypeInstKlassPtr*)this;
1908}
1909
1910inline const TypeAryKlassPtr *Type::isa_aryklassptr() const {
1911 return (_base == AryKlassPtr) ? (TypeAryKlassPtr*)this : NULL__null;
1912}
1913
1914inline const TypeAryKlassPtr *Type::is_aryklassptr() const {
1915 assert(_base == AryKlassPtr, "Not a klass pointer")do { if (!(_base == AryKlassPtr)) { (*g_assert_poison) = 'X';
; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.hpp"
, 1915, "assert(" "_base == AryKlassPtr" ") failed", "Not a klass pointer"
); ::breakpoint(); } } while (0)
;
1916 return (TypeAryKlassPtr*)this;
1917}
1918
1919inline const TypePtr* Type::make_ptr() const {
1920 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
1921 ((_base == NarrowKlass) ? is_narrowklass()->get_ptrtype() :
1922 isa_ptr());
1923}
1924
1925inline const TypeOopPtr* Type::make_oopptr() const {
1926 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->isa_oopptr() : isa_oopptr();
1927}
1928
1929inline const TypeNarrowOop* Type::make_narrowoop() const {
1930 return (_base == NarrowOop) ? is_narrowoop() :
1931 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL__null);
1932}
1933
1934inline const TypeNarrowKlass* Type::make_narrowklass() const {
1935 return (_base == NarrowKlass) ? is_narrowklass() :
1936 (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : NULL__null);
1937}
1938
1939inline bool Type::is_floatingpoint() const {
1940 if( (_base == FloatCon) || (_base == FloatBot) ||
1941 (_base == DoubleCon) || (_base == DoubleBot) )
1942 return true;
1943 return false;
1944}
1945
1946inline bool Type::is_ptr_to_boxing_obj() const {
1947 const TypeInstPtr* tp = isa_instptr();
1948 return (tp != NULL__null) && (tp->offset() == 0) &&
1949 tp->klass()->is_instance_klass() &&
1950 tp->klass()->as_instance_klass()->is_box_klass();
1951}
1952
1953
1954// ===============================================================
1955// Things that need to be 64-bits in the 64-bit build but
1956// 32-bits in the 32-bit build. Done this way to get full
1957// optimization AND strong typing.
1958#ifdef _LP641
1959
1960// For type queries and asserts
1961#define is_intptr_tis_long is_long
1962#define isa_intptr_tisa_long isa_long
1963#define find_intptr_t_typefind_long_type find_long_type
1964#define find_intptr_t_confind_long_con find_long_con
1965#define TypeXTypeLong TypeLong
1966#define Type_XType::Long Type::Long
1967#define TypeX_XTypeLong::LONG TypeLong::LONG
1968#define TypeX_ZEROTypeLong::ZERO TypeLong::ZERO
1969// For 'ideal_reg' machine registers
1970#define Op_RegXOp_RegL Op_RegL
1971// For phase->intcon variants
1972#define MakeConXlongcon longcon
1973#define ConXNodeConLNode ConLNode
1974// For array index arithmetic
1975#define MulXNodeMulLNode MulLNode
1976#define AndXNodeAndLNode AndLNode
1977#define OrXNodeOrLNode OrLNode
1978#define CmpXNodeCmpLNode CmpLNode
1979#define SubXNodeSubLNode SubLNode
1980#define LShiftXNodeLShiftLNode LShiftLNode
1981// For object size computation:
1982#define AddXNodeAddLNode AddLNode
1983#define RShiftXNodeRShiftLNode RShiftLNode
1984// For card marks and hashcodes
1985#define URShiftXNodeURShiftLNode URShiftLNode
1986// For shenandoahSupport
1987#define LoadXNodeLoadLNode LoadLNode
1988#define StoreXNodeStoreLNode StoreLNode
1989// Opcodes
1990#define Op_LShiftXOp_LShiftL Op_LShiftL
1991#define Op_AndXOp_AndL Op_AndL
1992#define Op_AddXOp_AddL Op_AddL
1993#define Op_SubXOp_SubL Op_SubL
1994#define Op_XorXOp_XorL Op_XorL
1995#define Op_URShiftXOp_URShiftL Op_URShiftL
1996#define Op_LoadXOp_LoadL Op_LoadL
1997// conversions
1998#define ConvI2X(x)ConvI2L(x) ConvI2L(x)
1999#define ConvL2X(x)(x) (x)
2000#define ConvX2I(x)ConvL2I(x) ConvL2I(x)
2001#define ConvX2L(x)(x) (x)
2002#define ConvX2UL(x)(x) (x)
2003
2004#else
2005
2006// For type queries and asserts
2007#define is_intptr_tis_long is_int
2008#define isa_intptr_tisa_long isa_int
2009#define find_intptr_t_typefind_long_type find_int_type
2010#define find_intptr_t_confind_long_con find_int_con
2011#define TypeXTypeLong TypeInt
2012#define Type_XType::Long Type::Int
2013#define TypeX_XTypeLong::LONG TypeInt::INT
2014#define TypeX_ZEROTypeLong::ZERO TypeInt::ZERO
2015// For 'ideal_reg' machine registers
2016#define Op_RegXOp_RegL Op_RegI
2017// For phase->intcon variants
2018#define MakeConXlongcon intcon
2019#define ConXNodeConLNode ConINode
2020// For array index arithmetic
2021#define MulXNodeMulLNode MulINode
2022#define AndXNodeAndLNode AndINode
2023#define OrXNodeOrLNode OrINode
2024#define CmpXNodeCmpLNode CmpINode
2025#define SubXNodeSubLNode SubINode
2026#define LShiftXNodeLShiftLNode LShiftINode
2027// For object size computation:
2028#define AddXNodeAddLNode AddINode
2029#define RShiftXNodeRShiftLNode RShiftINode
2030// For card marks and hashcodes
2031#define URShiftXNodeURShiftLNode URShiftINode
2032// For shenandoahSupport
2033#define LoadXNodeLoadLNode LoadINode
2034#define StoreXNodeStoreLNode StoreINode
2035// Opcodes
2036#define Op_LShiftXOp_LShiftL Op_LShiftI
2037#define Op_AndXOp_AndL Op_AndI
2038#define Op_AddXOp_AddL Op_AddI
2039#define Op_SubXOp_SubL Op_SubI
2040#define Op_XorXOp_XorL Op_XorI
2041#define Op_URShiftXOp_URShiftL Op_URShiftI
2042#define Op_LoadXOp_LoadL Op_LoadI
2043// conversions
2044#define ConvI2X(x)ConvI2L(x) (x)
2045#define ConvL2X(x)(x) ConvL2I(x)
2046#define ConvX2I(x)ConvL2I(x) (x)
2047#define ConvX2L(x)(x) ConvI2L(x)
2048#define ConvX2UL(x)(x) ConvI2UL(x)
2049
2050#endif
2051
2052#endif // SHARE_OPTO_TYPE_HPP