| File: | jdk/src/hotspot/share/opto/mulnode.cpp |
| Warning: | line 673, column 43 The result of the right shift is undefined due to shifting by '64', which is greater or equal to the width of type 'julong' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 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/connode.hpp" | ||||
| 29 | #include "opto/convertnode.hpp" | ||||
| 30 | #include "opto/memnode.hpp" | ||||
| 31 | #include "opto/mulnode.hpp" | ||||
| 32 | #include "opto/phaseX.hpp" | ||||
| 33 | #include "opto/subnode.hpp" | ||||
| 34 | #include "utilities/powerOfTwo.hpp" | ||||
| 35 | |||||
| 36 | // Portions of code courtesy of Clifford Click | ||||
| 37 | |||||
| 38 | |||||
| 39 | //============================================================================= | ||||
| 40 | //------------------------------hash------------------------------------------- | ||||
| 41 | // Hash function over MulNodes. Needs to be commutative; i.e., I swap | ||||
| 42 | // (commute) inputs to MulNodes willy-nilly so the hash function must return | ||||
| 43 | // the same value in the presence of edge swapping. | ||||
| 44 | uint MulNode::hash() const { | ||||
| 45 | return (uintptr_t)in(1) + (uintptr_t)in(2) + Opcode(); | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | //------------------------------Identity--------------------------------------- | ||||
| 49 | // Multiplying a one preserves the other argument | ||||
| 50 | Node* MulNode::Identity(PhaseGVN* phase) { | ||||
| 51 | const Type *one = mul_id(); // The multiplicative identity | ||||
| 52 | if( phase->type( in(1) )->higher_equal( one ) ) return in(2); | ||||
| 53 | if( phase->type( in(2) )->higher_equal( one ) ) return in(1); | ||||
| 54 | |||||
| 55 | return this; | ||||
| 56 | } | ||||
| 57 | |||||
| 58 | //------------------------------Ideal------------------------------------------ | ||||
| 59 | // We also canonicalize the Node, moving constants to the right input, | ||||
| 60 | // and flatten expressions (so that 1+x+2 becomes x+3). | ||||
| 61 | Node *MulNode::Ideal(PhaseGVN *phase, bool can_reshape) { | ||||
| 62 | Node* in1 = in(1); | ||||
| 63 | Node* in2 = in(2); | ||||
| 64 | Node* progress = NULL__null; // Progress flag | ||||
| 65 | |||||
| 66 | // This code is used by And nodes too, but some conversions are | ||||
| 67 | // only valid for the actual Mul nodes. | ||||
| 68 | uint op = Opcode(); | ||||
| 69 | bool real_mul = (op == Op_MulI) || (op == Op_MulL) || | ||||
| 70 | (op == Op_MulF) || (op == Op_MulD); | ||||
| 71 | |||||
| 72 | // Convert "(-a)*(-b)" into "a*b". | ||||
| 73 | if (real_mul && in1->is_Sub() && in2->is_Sub()) { | ||||
| 74 | if (phase->type(in1->in(1))->is_zero_type() && | ||||
| 75 | phase->type(in2->in(1))->is_zero_type()) { | ||||
| 76 | set_req(1, in1->in(2)); | ||||
| 77 | set_req(2, in2->in(2)); | ||||
| 78 | PhaseIterGVN* igvn = phase->is_IterGVN(); | ||||
| 79 | if (igvn) { | ||||
| 80 | igvn->_worklist.push(in1); | ||||
| 81 | igvn->_worklist.push(in2); | ||||
| 82 | } | ||||
| 83 | in1 = in(1); | ||||
| 84 | in2 = in(2); | ||||
| 85 | progress = this; | ||||
| 86 | } | ||||
| 87 | } | ||||
| 88 | |||||
| 89 | // convert "max(a,b) * min(a,b)" into "a*b". | ||||
| 90 | if ((in(1)->Opcode() == max_opcode() && in(2)->Opcode() == min_opcode()) | ||||
| 91 | || (in(1)->Opcode() == min_opcode() && in(2)->Opcode() == max_opcode())) { | ||||
| 92 | Node *in11 = in(1)->in(1); | ||||
| 93 | Node *in12 = in(1)->in(2); | ||||
| 94 | |||||
| 95 | Node *in21 = in(2)->in(1); | ||||
| 96 | Node *in22 = in(2)->in(2); | ||||
| 97 | |||||
| 98 | if ((in11 == in21 && in12 == in22) || | ||||
| 99 | (in11 == in22 && in12 == in21)) { | ||||
| 100 | set_req(1, in11); | ||||
| 101 | set_req(2, in12); | ||||
| 102 | PhaseIterGVN* igvn = phase->is_IterGVN(); | ||||
| 103 | if (igvn) { | ||||
| 104 | igvn->_worklist.push(in1); | ||||
| 105 | igvn->_worklist.push(in2); | ||||
| 106 | } | ||||
| 107 | in1 = in(1); | ||||
| 108 | in2 = in(2); | ||||
| 109 | progress = this; | ||||
| 110 | } | ||||
| 111 | } | ||||
| 112 | |||||
| 113 | const Type* t1 = phase->type(in1); | ||||
| 114 | const Type* t2 = phase->type(in2); | ||||
| 115 | |||||
| 116 | // We are OK if right is a constant, or right is a load and | ||||
| 117 | // left is a non-constant. | ||||
| 118 | if( !(t2->singleton() || | ||||
| 119 | (in(2)->is_Load() && !(t1->singleton() || in(1)->is_Load())) ) ) { | ||||
| 120 | if( t1->singleton() || // Left input is a constant? | ||||
| 121 | // Otherwise, sort inputs (commutativity) to help value numbering. | ||||
| 122 | (in(1)->_idx > in(2)->_idx) ) { | ||||
| 123 | swap_edges(1, 2); | ||||
| 124 | const Type *t = t1; | ||||
| 125 | t1 = t2; | ||||
| 126 | t2 = t; | ||||
| 127 | progress = this; // Made progress | ||||
| 128 | } | ||||
| 129 | } | ||||
| 130 | |||||
| 131 | // If the right input is a constant, and the left input is a product of a | ||||
| 132 | // constant, flatten the expression tree. | ||||
| 133 | if( t2->singleton() && // Right input is a constant? | ||||
| 134 | op != Op_MulF && // Float & double cannot reassociate | ||||
| 135 | op != Op_MulD ) { | ||||
| 136 | if( t2 == Type::TOP ) return NULL__null; | ||||
| 137 | Node *mul1 = in(1); | ||||
| 138 | #ifdef ASSERT1 | ||||
| 139 | // Check for dead loop | ||||
| 140 | int op1 = mul1->Opcode(); | ||||
| 141 | if ((mul1 == this) || (in(2) == this) || | ||||
| 142 | ((op1 == mul_opcode() || op1 == add_opcode()) && | ||||
| 143 | ((mul1->in(1) == this) || (mul1->in(2) == this) || | ||||
| 144 | (mul1->in(1) == mul1) || (mul1->in(2) == mul1)))) { | ||||
| 145 | assert(false, "dead loop in MulNode::Ideal")do { if (!(false)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 145, "assert(" "false" ") failed", "dead loop in MulNode::Ideal" ); ::breakpoint(); } } while (0); | ||||
| 146 | } | ||||
| 147 | #endif | ||||
| 148 | |||||
| 149 | if( mul1->Opcode() == mul_opcode() ) { // Left input is a multiply? | ||||
| 150 | // Mul of a constant? | ||||
| 151 | const Type *t12 = phase->type( mul1->in(2) ); | ||||
| 152 | if( t12->singleton() && t12 != Type::TOP) { // Left input is an add of a constant? | ||||
| 153 | // Compute new constant; check for overflow | ||||
| 154 | const Type *tcon01 = ((MulNode*)mul1)->mul_ring(t2,t12); | ||||
| 155 | if( tcon01->singleton() ) { | ||||
| 156 | // The Mul of the flattened expression | ||||
| 157 | set_req_X(1, mul1->in(1), phase); | ||||
| 158 | set_req_X(2, phase->makecon(tcon01), phase); | ||||
| 159 | t2 = tcon01; | ||||
| 160 | progress = this; // Made progress | ||||
| 161 | } | ||||
| 162 | } | ||||
| 163 | } | ||||
| 164 | // If the right input is a constant, and the left input is an add of a | ||||
| 165 | // constant, flatten the tree: (X+con1)*con0 ==> X*con0 + con1*con0 | ||||
| 166 | const Node *add1 = in(1); | ||||
| 167 | if( add1->Opcode() == add_opcode() ) { // Left input is an add? | ||||
| 168 | // Add of a constant? | ||||
| 169 | const Type *t12 = phase->type( add1->in(2) ); | ||||
| 170 | if( t12->singleton() && t12 != Type::TOP ) { // Left input is an add of a constant? | ||||
| 171 | assert( add1->in(1) != add1, "dead loop in MulNode::Ideal" )do { if (!(add1->in(1) != add1)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 171, "assert(" "add1->in(1) != add1" ") failed", "dead loop in MulNode::Ideal" ); ::breakpoint(); } } while (0); | ||||
| 172 | // Compute new constant; check for overflow | ||||
| 173 | const Type *tcon01 = mul_ring(t2,t12); | ||||
| 174 | if( tcon01->singleton() ) { | ||||
| 175 | |||||
| 176 | // Convert (X+con1)*con0 into X*con0 | ||||
| 177 | Node *mul = clone(); // mul = ()*con0 | ||||
| 178 | mul->set_req(1,add1->in(1)); // mul = X*con0 | ||||
| 179 | mul = phase->transform(mul); | ||||
| 180 | |||||
| 181 | Node *add2 = add1->clone(); | ||||
| 182 | add2->set_req(1, mul); // X*con0 + con0*con1 | ||||
| 183 | add2->set_req(2, phase->makecon(tcon01) ); | ||||
| 184 | progress = add2; | ||||
| 185 | } | ||||
| 186 | } | ||||
| 187 | } // End of is left input an add | ||||
| 188 | } // End of is right input a Mul | ||||
| 189 | |||||
| 190 | return progress; | ||||
| 191 | } | ||||
| 192 | |||||
| 193 | //------------------------------Value----------------------------------------- | ||||
| 194 | const Type* MulNode::Value(PhaseGVN* phase) const { | ||||
| 195 | const Type *t1 = phase->type( in(1) ); | ||||
| 196 | const Type *t2 = phase->type( in(2) ); | ||||
| 197 | // Either input is TOP ==> the result is TOP | ||||
| 198 | if( t1 == Type::TOP ) return Type::TOP; | ||||
| 199 | if( t2 == Type::TOP ) return Type::TOP; | ||||
| 200 | |||||
| 201 | // Either input is ZERO ==> the result is ZERO. | ||||
| 202 | // Not valid for floats or doubles since +0.0 * -0.0 --> +0.0 | ||||
| 203 | int op = Opcode(); | ||||
| 204 | if( op == Op_MulI || op == Op_AndI || op == Op_MulL || op == Op_AndL ) { | ||||
| 205 | const Type *zero = add_id(); // The multiplicative zero | ||||
| 206 | if( t1->higher_equal( zero ) ) return zero; | ||||
| 207 | if( t2->higher_equal( zero ) ) return zero; | ||||
| 208 | } | ||||
| 209 | |||||
| 210 | // Either input is BOTTOM ==> the result is the local BOTTOM | ||||
| 211 | if( t1 == Type::BOTTOM || t2 == Type::BOTTOM ) | ||||
| 212 | return bottom_type(); | ||||
| 213 | |||||
| 214 | #if defined(IA32) | ||||
| 215 | // Can't trust native compilers to properly fold strict double | ||||
| 216 | // multiplication with round-to-zero on this platform. | ||||
| 217 | if (op == Op_MulD) { | ||||
| 218 | return TypeD::DOUBLE; | ||||
| 219 | } | ||||
| 220 | #endif | ||||
| 221 | |||||
| 222 | return mul_ring(t1,t2); // Local flavor of type multiplication | ||||
| 223 | } | ||||
| 224 | |||||
| 225 | MulNode* MulNode::make(Node* in1, Node* in2, BasicType bt) { | ||||
| 226 | switch (bt) { | ||||
| 227 | case T_INT: | ||||
| 228 | return new MulINode(in1, in2); | ||||
| 229 | case T_LONG: | ||||
| 230 | return new MulLNode(in1, in2); | ||||
| 231 | default: | ||||
| 232 | 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/mulnode.cpp" , 232, "Not implemented for %s", type2name(bt)); ::breakpoint (); } while (0); | ||||
| 233 | } | ||||
| 234 | return NULL__null; | ||||
| 235 | } | ||||
| 236 | |||||
| 237 | |||||
| 238 | //============================================================================= | ||||
| 239 | //------------------------------Ideal------------------------------------------ | ||||
| 240 | // Check for power-of-2 multiply, then try the regular MulNode::Ideal | ||||
| 241 | Node *MulINode::Ideal(PhaseGVN *phase, bool can_reshape) { | ||||
| 242 | // Swap constant to right | ||||
| 243 | jint con; | ||||
| 244 | if ((con = in(1)->find_int_con(0)) != 0) { | ||||
| 245 | swap_edges(1, 2); | ||||
| 246 | // Finish rest of method to use info in 'con' | ||||
| 247 | } else if ((con = in(2)->find_int_con(0)) == 0) { | ||||
| 248 | return MulNode::Ideal(phase, can_reshape); | ||||
| 249 | } | ||||
| 250 | |||||
| 251 | // Now we have a constant Node on the right and the constant in con | ||||
| 252 | if (con == 0) return NULL__null; // By zero is handled by Value call | ||||
| 253 | if (con == 1) return NULL__null; // By one is handled by Identity call | ||||
| 254 | |||||
| 255 | // Check for negative constant; if so negate the final result | ||||
| 256 | bool sign_flip = false; | ||||
| 257 | |||||
| 258 | unsigned int abs_con = uabs(con); | ||||
| 259 | if (abs_con != (unsigned int)con) { | ||||
| 260 | sign_flip = true; | ||||
| 261 | } | ||||
| 262 | |||||
| 263 | // Get low bit; check for being the only bit | ||||
| 264 | Node *res = NULL__null; | ||||
| 265 | unsigned int bit1 = abs_con & (0-abs_con); // Extract low bit | ||||
| 266 | if (bit1 == abs_con) { // Found a power of 2? | ||||
| 267 | res = new LShiftINode(in(1), phase->intcon(log2i_exact(bit1))); | ||||
| 268 | } else { | ||||
| 269 | // Check for constant with 2 bits set | ||||
| 270 | unsigned int bit2 = abs_con - bit1; | ||||
| 271 | bit2 = bit2 & (0 - bit2); // Extract 2nd bit | ||||
| 272 | if (bit2 + bit1 == abs_con) { // Found all bits in con? | ||||
| 273 | Node *n1 = phase->transform(new LShiftINode(in(1), phase->intcon(log2i_exact(bit1)))); | ||||
| 274 | Node *n2 = phase->transform(new LShiftINode(in(1), phase->intcon(log2i_exact(bit2)))); | ||||
| 275 | res = new AddINode(n2, n1); | ||||
| 276 | } else if (is_power_of_2(abs_con + 1)) { | ||||
| 277 | // Sleezy: power-of-2 - 1. Next time be generic. | ||||
| 278 | unsigned int temp = abs_con + 1; | ||||
| 279 | Node *n1 = phase->transform(new LShiftINode(in(1), phase->intcon(log2i_exact(temp)))); | ||||
| 280 | res = new SubINode(n1, in(1)); | ||||
| 281 | } else { | ||||
| 282 | return MulNode::Ideal(phase, can_reshape); | ||||
| 283 | } | ||||
| 284 | } | ||||
| 285 | |||||
| 286 | if (sign_flip) { // Need to negate result? | ||||
| 287 | res = phase->transform(res);// Transform, before making the zero con | ||||
| 288 | res = new SubINode(phase->intcon(0),res); | ||||
| 289 | } | ||||
| 290 | |||||
| 291 | return res; // Return final result | ||||
| 292 | } | ||||
| 293 | |||||
| 294 | //------------------------------mul_ring--------------------------------------- | ||||
| 295 | // Compute the product type of two integer ranges into this node. | ||||
| 296 | const Type *MulINode::mul_ring(const Type *t0, const Type *t1) const { | ||||
| 297 | const TypeInt *r0 = t0->is_int(); // Handy access | ||||
| 298 | const TypeInt *r1 = t1->is_int(); | ||||
| 299 | |||||
| 300 | // Fetch endpoints of all ranges | ||||
| 301 | jint lo0 = r0->_lo; | ||||
| 302 | double a = (double)lo0; | ||||
| 303 | jint hi0 = r0->_hi; | ||||
| 304 | double b = (double)hi0; | ||||
| 305 | jint lo1 = r1->_lo; | ||||
| 306 | double c = (double)lo1; | ||||
| 307 | jint hi1 = r1->_hi; | ||||
| 308 | double d = (double)hi1; | ||||
| 309 | |||||
| 310 | // Compute all endpoints & check for overflow | ||||
| 311 | int32_t A = java_multiply(lo0, lo1); | ||||
| 312 | if( (double)A != a*c ) return TypeInt::INT; // Overflow? | ||||
| 313 | int32_t B = java_multiply(lo0, hi1); | ||||
| 314 | if( (double)B != a*d ) return TypeInt::INT; // Overflow? | ||||
| 315 | int32_t C = java_multiply(hi0, lo1); | ||||
| 316 | if( (double)C != b*c ) return TypeInt::INT; // Overflow? | ||||
| 317 | int32_t D = java_multiply(hi0, hi1); | ||||
| 318 | if( (double)D != b*d ) return TypeInt::INT; // Overflow? | ||||
| 319 | |||||
| 320 | if( A < B ) { lo0 = A; hi0 = B; } // Sort range endpoints | ||||
| 321 | else { lo0 = B; hi0 = A; } | ||||
| 322 | if( C < D ) { | ||||
| 323 | if( C < lo0 ) lo0 = C; | ||||
| 324 | if( D > hi0 ) hi0 = D; | ||||
| 325 | } else { | ||||
| 326 | if( D < lo0 ) lo0 = D; | ||||
| 327 | if( C > hi0 ) hi0 = C; | ||||
| 328 | } | ||||
| 329 | return TypeInt::make(lo0, hi0, MAX2(r0->_widen,r1->_widen)); | ||||
| 330 | } | ||||
| 331 | |||||
| 332 | |||||
| 333 | //============================================================================= | ||||
| 334 | //------------------------------Ideal------------------------------------------ | ||||
| 335 | // Check for power-of-2 multiply, then try the regular MulNode::Ideal | ||||
| 336 | Node *MulLNode::Ideal(PhaseGVN *phase, bool can_reshape) { | ||||
| 337 | // Swap constant to right | ||||
| 338 | jlong con; | ||||
| 339 | if ((con = in(1)->find_long_con(0)) != 0) { | ||||
| 340 | swap_edges(1, 2); | ||||
| 341 | // Finish rest of method to use info in 'con' | ||||
| 342 | } else if ((con = in(2)->find_long_con(0)) == 0) { | ||||
| 343 | return MulNode::Ideal(phase, can_reshape); | ||||
| 344 | } | ||||
| 345 | |||||
| 346 | // Now we have a constant Node on the right and the constant in con | ||||
| 347 | if (con == CONST64(0)(0LL)) return NULL__null; // By zero is handled by Value call | ||||
| 348 | if (con == CONST64(1)(1LL)) return NULL__null; // By one is handled by Identity call | ||||
| 349 | |||||
| 350 | // Check for negative constant; if so negate the final result | ||||
| 351 | bool sign_flip = false; | ||||
| 352 | julong abs_con = uabs(con); | ||||
| 353 | if (abs_con != (julong)con) { | ||||
| 354 | sign_flip = true; | ||||
| 355 | } | ||||
| 356 | |||||
| 357 | // Get low bit; check for being the only bit | ||||
| 358 | Node *res = NULL__null; | ||||
| 359 | julong bit1 = abs_con & (0-abs_con); // Extract low bit | ||||
| 360 | if (bit1 == abs_con) { // Found a power of 2? | ||||
| 361 | res = new LShiftLNode(in(1), phase->intcon(log2i_exact(bit1))); | ||||
| 362 | } else { | ||||
| 363 | |||||
| 364 | // Check for constant with 2 bits set | ||||
| 365 | julong bit2 = abs_con-bit1; | ||||
| 366 | bit2 = bit2 & (0-bit2); // Extract 2nd bit | ||||
| 367 | if (bit2 + bit1 == abs_con) { // Found all bits in con? | ||||
| 368 | Node *n1 = phase->transform(new LShiftLNode(in(1), phase->intcon(log2i_exact(bit1)))); | ||||
| 369 | Node *n2 = phase->transform(new LShiftLNode(in(1), phase->intcon(log2i_exact(bit2)))); | ||||
| 370 | res = new AddLNode(n2, n1); | ||||
| 371 | |||||
| 372 | } else if (is_power_of_2(abs_con+1)) { | ||||
| 373 | // Sleezy: power-of-2 -1. Next time be generic. | ||||
| 374 | julong temp = abs_con + 1; | ||||
| 375 | Node *n1 = phase->transform( new LShiftLNode(in(1), phase->intcon(log2i_exact(temp)))); | ||||
| 376 | res = new SubLNode(n1, in(1)); | ||||
| 377 | } else { | ||||
| 378 | return MulNode::Ideal(phase, can_reshape); | ||||
| 379 | } | ||||
| 380 | } | ||||
| 381 | |||||
| 382 | if (sign_flip) { // Need to negate result? | ||||
| 383 | res = phase->transform(res);// Transform, before making the zero con | ||||
| 384 | res = new SubLNode(phase->longcon(0),res); | ||||
| 385 | } | ||||
| 386 | |||||
| 387 | return res; // Return final result | ||||
| 388 | } | ||||
| 389 | |||||
| 390 | //------------------------------mul_ring--------------------------------------- | ||||
| 391 | // Compute the product type of two integer ranges into this node. | ||||
| 392 | const Type *MulLNode::mul_ring(const Type *t0, const Type *t1) const { | ||||
| 393 | const TypeLong *r0 = t0->is_long(); // Handy access | ||||
| 394 | const TypeLong *r1 = t1->is_long(); | ||||
| 395 | |||||
| 396 | // Fetch endpoints of all ranges | ||||
| 397 | jlong lo0 = r0->_lo; | ||||
| 398 | double a = (double)lo0; | ||||
| 399 | jlong hi0 = r0->_hi; | ||||
| 400 | double b = (double)hi0; | ||||
| 401 | jlong lo1 = r1->_lo; | ||||
| 402 | double c = (double)lo1; | ||||
| 403 | jlong hi1 = r1->_hi; | ||||
| 404 | double d = (double)hi1; | ||||
| 405 | |||||
| 406 | // Compute all endpoints & check for overflow | ||||
| 407 | jlong A = java_multiply(lo0, lo1); | ||||
| 408 | if( (double)A != a*c ) return TypeLong::LONG; // Overflow? | ||||
| 409 | jlong B = java_multiply(lo0, hi1); | ||||
| 410 | if( (double)B != a*d ) return TypeLong::LONG; // Overflow? | ||||
| 411 | jlong C = java_multiply(hi0, lo1); | ||||
| 412 | if( (double)C != b*c ) return TypeLong::LONG; // Overflow? | ||||
| 413 | jlong D = java_multiply(hi0, hi1); | ||||
| 414 | if( (double)D != b*d ) return TypeLong::LONG; // Overflow? | ||||
| 415 | |||||
| 416 | if( A < B ) { lo0 = A; hi0 = B; } // Sort range endpoints | ||||
| 417 | else { lo0 = B; hi0 = A; } | ||||
| 418 | if( C < D ) { | ||||
| 419 | if( C < lo0 ) lo0 = C; | ||||
| 420 | if( D > hi0 ) hi0 = D; | ||||
| 421 | } else { | ||||
| 422 | if( D < lo0 ) lo0 = D; | ||||
| 423 | if( C > hi0 ) hi0 = C; | ||||
| 424 | } | ||||
| 425 | return TypeLong::make(lo0, hi0, MAX2(r0->_widen,r1->_widen)); | ||||
| 426 | } | ||||
| 427 | |||||
| 428 | //============================================================================= | ||||
| 429 | //------------------------------mul_ring--------------------------------------- | ||||
| 430 | // Compute the product type of two double ranges into this node. | ||||
| 431 | const Type *MulFNode::mul_ring(const Type *t0, const Type *t1) const { | ||||
| 432 | if( t0 == Type::FLOAT || t1 == Type::FLOAT ) return Type::FLOAT; | ||||
| 433 | return TypeF::make( t0->getf() * t1->getf() ); | ||||
| 434 | } | ||||
| 435 | |||||
| 436 | //============================================================================= | ||||
| 437 | //------------------------------mul_ring--------------------------------------- | ||||
| 438 | // Compute the product type of two double ranges into this node. | ||||
| 439 | const Type *MulDNode::mul_ring(const Type *t0, const Type *t1) const { | ||||
| 440 | if( t0 == Type::DOUBLE || t1 == Type::DOUBLE ) return Type::DOUBLE; | ||||
| 441 | // We must be multiplying 2 double constants. | ||||
| 442 | return TypeD::make( t0->getd() * t1->getd() ); | ||||
| 443 | } | ||||
| 444 | |||||
| 445 | //============================================================================= | ||||
| 446 | //------------------------------Value------------------------------------------ | ||||
| 447 | const Type* MulHiLNode::Value(PhaseGVN* phase) const { | ||||
| 448 | const Type *t1 = phase->type( in(1) ); | ||||
| 449 | const Type *t2 = phase->type( in(2) ); | ||||
| 450 | const Type *bot = bottom_type(); | ||||
| 451 | return MulHiValue(t1, t2, bot); | ||||
| 452 | } | ||||
| 453 | |||||
| 454 | const Type* UMulHiLNode::Value(PhaseGVN* phase) const { | ||||
| 455 | const Type *t1 = phase->type( in(1) ); | ||||
| 456 | const Type *t2 = phase->type( in(2) ); | ||||
| 457 | const Type *bot = bottom_type(); | ||||
| 458 | return MulHiValue(t1, t2, bot); | ||||
| 459 | } | ||||
| 460 | |||||
| 461 | // A common routine used by UMulHiLNode and MulHiLNode | ||||
| 462 | const Type* MulHiValue(const Type *t1, const Type *t2, const Type *bot) { | ||||
| 463 | // Either input is TOP ==> the result is TOP | ||||
| 464 | if( t1 == Type::TOP ) return Type::TOP; | ||||
| 465 | if( t2 == Type::TOP ) return Type::TOP; | ||||
| 466 | |||||
| 467 | // Either input is BOTTOM ==> the result is the local BOTTOM | ||||
| 468 | if( (t1 == bot) || (t2 == bot) || | ||||
| 469 | (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) ) | ||||
| 470 | return bot; | ||||
| 471 | |||||
| 472 | // It is not worth trying to constant fold this stuff! | ||||
| 473 | return TypeLong::LONG; | ||||
| 474 | } | ||||
| 475 | |||||
| 476 | //============================================================================= | ||||
| 477 | //------------------------------mul_ring--------------------------------------- | ||||
| 478 | // Supplied function returns the product of the inputs IN THE CURRENT RING. | ||||
| 479 | // For the logical operations the ring's MUL is really a logical AND function. | ||||
| 480 | // This also type-checks the inputs for sanity. Guaranteed never to | ||||
| 481 | // be passed a TOP or BOTTOM type, these are filtered out by pre-check. | ||||
| 482 | const Type *AndINode::mul_ring( const Type *t0, const Type *t1 ) const { | ||||
| 483 | const TypeInt *r0 = t0->is_int(); // Handy access | ||||
| 484 | const TypeInt *r1 = t1->is_int(); | ||||
| 485 | int widen = MAX2(r0->_widen,r1->_widen); | ||||
| 486 | |||||
| 487 | // If either input is a constant, might be able to trim cases | ||||
| 488 | if( !r0->is_con() && !r1->is_con() ) | ||||
| 489 | return TypeInt::INT; // No constants to be had | ||||
| 490 | |||||
| 491 | // Both constants? Return bits | ||||
| 492 | if( r0->is_con() && r1->is_con() ) | ||||
| 493 | return TypeInt::make( r0->get_con() & r1->get_con() ); | ||||
| 494 | |||||
| 495 | if( r0->is_con() && r0->get_con() > 0 ) | ||||
| 496 | return TypeInt::make(0, r0->get_con(), widen); | ||||
| 497 | |||||
| 498 | if( r1->is_con() && r1->get_con() > 0 ) | ||||
| 499 | return TypeInt::make(0, r1->get_con(), widen); | ||||
| 500 | |||||
| 501 | if( r0 == TypeInt::BOOL || r1 == TypeInt::BOOL ) { | ||||
| 502 | return TypeInt::BOOL; | ||||
| 503 | } | ||||
| 504 | |||||
| 505 | return TypeInt::INT; // No constants to be had | ||||
| 506 | } | ||||
| 507 | |||||
| 508 | const Type* AndINode::Value(PhaseGVN* phase) const { | ||||
| 509 | // patterns similar to (v << 2) & 3 | ||||
| 510 | if (AndIL_shift_and_mask(phase, in(2), in(1), T_INT)) { | ||||
| 511 | return TypeInt::ZERO; | ||||
| 512 | } | ||||
| 513 | |||||
| 514 | return MulNode::Value(phase); | ||||
| 515 | } | ||||
| 516 | |||||
| 517 | //------------------------------Identity--------------------------------------- | ||||
| 518 | // Masking off the high bits of an unsigned load is not required | ||||
| 519 | Node* AndINode::Identity(PhaseGVN* phase) { | ||||
| 520 | |||||
| 521 | // x & x => x | ||||
| 522 | if (in(1) == in(2)) { | ||||
| 523 | return in(1); | ||||
| 524 | } | ||||
| 525 | |||||
| 526 | Node* in1 = in(1); | ||||
| 527 | uint op = in1->Opcode(); | ||||
| 528 | const TypeInt* t2 = phase->type(in(2))->isa_int(); | ||||
| 529 | if (t2 && t2->is_con()) { | ||||
| 530 | int con = t2->get_con(); | ||||
| 531 | // Masking off high bits which are always zero is useless. | ||||
| 532 | const TypeInt* t1 = phase->type(in(1))->isa_int(); | ||||
| 533 | if (t1 != NULL__null && t1->_lo >= 0) { | ||||
| 534 | jint t1_support = right_n_bits(1 + log2i_graceful(t1->_hi))((((1 + log2i_graceful(t1->_hi)) >= BitsPerWord) ? 0 : ( OneBit << (1 + log2i_graceful(t1->_hi)))) - 1); | ||||
| 535 | if ((t1_support & con) == t1_support) | ||||
| 536 | return in1; | ||||
| 537 | } | ||||
| 538 | // Masking off the high bits of a unsigned-shift-right is not | ||||
| 539 | // needed either. | ||||
| 540 | if (op == Op_URShiftI) { | ||||
| 541 | const TypeInt* t12 = phase->type(in1->in(2))->isa_int(); | ||||
| 542 | if (t12 && t12->is_con()) { // Shift is by a constant | ||||
| 543 | int shift = t12->get_con(); | ||||
| 544 | shift &= BitsPerJavaInteger - 1; // semantics of Java shifts | ||||
| 545 | int mask = max_juint >> shift; | ||||
| 546 | if ((mask & con) == mask) // If AND is useless, skip it | ||||
| 547 | return in1; | ||||
| 548 | } | ||||
| 549 | } | ||||
| 550 | } | ||||
| 551 | return MulNode::Identity(phase); | ||||
| 552 | } | ||||
| 553 | |||||
| 554 | //------------------------------Ideal------------------------------------------ | ||||
| 555 | Node *AndINode::Ideal(PhaseGVN *phase, bool can_reshape) { | ||||
| 556 | // Special case constant AND mask | ||||
| 557 | const TypeInt *t2 = phase->type( in(2) )->isa_int(); | ||||
| 558 | if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape); | ||||
| 559 | const int mask = t2->get_con(); | ||||
| 560 | Node *load = in(1); | ||||
| 561 | uint lop = load->Opcode(); | ||||
| 562 | |||||
| 563 | // Masking bits off of a Character? Hi bits are already zero. | ||||
| 564 | if( lop == Op_LoadUS && | ||||
| 565 | (mask & 0xFFFF0000) ) // Can we make a smaller mask? | ||||
| 566 | return new AndINode(load,phase->intcon(mask&0xFFFF)); | ||||
| 567 | |||||
| 568 | // Masking bits off of a Short? Loading a Character does some masking | ||||
| 569 | if (can_reshape && | ||||
| 570 | load->outcnt() == 1 && load->unique_out() == this) { | ||||
| 571 | if (lop == Op_LoadS && (mask & 0xFFFF0000) == 0 ) { | ||||
| 572 | Node* ldus = load->as_Load()->convert_to_unsigned_load(*phase); | ||||
| 573 | ldus = phase->transform(ldus); | ||||
| 574 | return new AndINode(ldus, phase->intcon(mask & 0xFFFF)); | ||||
| 575 | } | ||||
| 576 | |||||
| 577 | // Masking sign bits off of a Byte? Do an unsigned byte load plus | ||||
| 578 | // an and. | ||||
| 579 | if (lop == Op_LoadB && (mask & 0xFFFFFF00) == 0) { | ||||
| 580 | Node* ldub = load->as_Load()->convert_to_unsigned_load(*phase); | ||||
| 581 | ldub = phase->transform(ldub); | ||||
| 582 | return new AndINode(ldub, phase->intcon(mask)); | ||||
| 583 | } | ||||
| 584 | } | ||||
| 585 | |||||
| 586 | // Masking off sign bits? Dont make them! | ||||
| 587 | if( lop == Op_RShiftI ) { | ||||
| 588 | const TypeInt *t12 = phase->type(load->in(2))->isa_int(); | ||||
| 589 | if( t12 && t12->is_con() ) { // Shift is by a constant | ||||
| 590 | int shift = t12->get_con(); | ||||
| 591 | shift &= BitsPerJavaInteger-1; // semantics of Java shifts | ||||
| 592 | const int sign_bits_mask = ~right_n_bits(BitsPerJavaInteger - shift)((((BitsPerJavaInteger - shift) >= BitsPerWord) ? 0 : (OneBit << (BitsPerJavaInteger - shift))) - 1); | ||||
| 593 | // If the AND'ing of the 2 masks has no bits, then only original shifted | ||||
| 594 | // bits survive. NO sign-extension bits survive the maskings. | ||||
| 595 | if( (sign_bits_mask & mask) == 0 ) { | ||||
| 596 | // Use zero-fill shift instead | ||||
| 597 | Node *zshift = phase->transform(new URShiftINode(load->in(1),load->in(2))); | ||||
| 598 | return new AndINode( zshift, in(2) ); | ||||
| 599 | } | ||||
| 600 | } | ||||
| 601 | } | ||||
| 602 | |||||
| 603 | // Check for 'negate/and-1', a pattern emitted when someone asks for | ||||
| 604 | // 'mod 2'. Negate leaves the low order bit unchanged (think: complement | ||||
| 605 | // plus 1) and the mask is of the low order bit. Skip the negate. | ||||
| 606 | if( lop == Op_SubI && mask == 1 && load->in(1) && | ||||
| 607 | phase->type(load->in(1)) == TypeInt::ZERO ) | ||||
| 608 | return new AndINode( load->in(2), in(2) ); | ||||
| 609 | |||||
| 610 | // pattern similar to (v1 + (v2 << 2)) & 3 transformed to v1 & 3 | ||||
| 611 | Node* progress = AndIL_add_shift_and_mask(phase, T_INT); | ||||
| 612 | if (progress != NULL__null) { | ||||
| 613 | return progress; | ||||
| 614 | } | ||||
| 615 | |||||
| 616 | return MulNode::Ideal(phase, can_reshape); | ||||
| 617 | } | ||||
| 618 | |||||
| 619 | //============================================================================= | ||||
| 620 | //------------------------------mul_ring--------------------------------------- | ||||
| 621 | // Supplied function returns the product of the inputs IN THE CURRENT RING. | ||||
| 622 | // For the logical operations the ring's MUL is really a logical AND function. | ||||
| 623 | // This also type-checks the inputs for sanity. Guaranteed never to | ||||
| 624 | // be passed a TOP or BOTTOM type, these are filtered out by pre-check. | ||||
| 625 | const Type *AndLNode::mul_ring( const Type *t0, const Type *t1 ) const { | ||||
| 626 | const TypeLong *r0 = t0->is_long(); // Handy access | ||||
| 627 | const TypeLong *r1 = t1->is_long(); | ||||
| 628 | int widen = MAX2(r0->_widen,r1->_widen); | ||||
| 629 | |||||
| 630 | // If either input is a constant, might be able to trim cases | ||||
| 631 | if( !r0->is_con() && !r1->is_con() ) | ||||
| 632 | return TypeLong::LONG; // No constants to be had | ||||
| 633 | |||||
| 634 | // Both constants? Return bits | ||||
| 635 | if( r0->is_con() && r1->is_con() ) | ||||
| 636 | return TypeLong::make( r0->get_con() & r1->get_con() ); | ||||
| 637 | |||||
| 638 | if( r0->is_con() && r0->get_con() > 0 ) | ||||
| 639 | return TypeLong::make(CONST64(0)(0LL), r0->get_con(), widen); | ||||
| 640 | |||||
| 641 | if( r1->is_con() && r1->get_con() > 0 ) | ||||
| 642 | return TypeLong::make(CONST64(0)(0LL), r1->get_con(), widen); | ||||
| 643 | |||||
| 644 | return TypeLong::LONG; // No constants to be had | ||||
| 645 | } | ||||
| 646 | |||||
| 647 | const Type* AndLNode::Value(PhaseGVN* phase) const { | ||||
| 648 | // patterns similar to (v << 2) & 3 | ||||
| 649 | if (AndIL_shift_and_mask(phase, in(2), in(1), T_LONG)) { | ||||
| 650 | return TypeLong::ZERO; | ||||
| 651 | } | ||||
| 652 | |||||
| 653 | return MulNode::Value(phase); | ||||
| 654 | } | ||||
| 655 | |||||
| 656 | //------------------------------Identity--------------------------------------- | ||||
| 657 | // Masking off the high bits of an unsigned load is not required | ||||
| 658 | Node* AndLNode::Identity(PhaseGVN* phase) { | ||||
| 659 | |||||
| 660 | // x & x => x | ||||
| 661 | if (in(1) == in(2)) { | ||||
| |||||
| 662 | return in(1); | ||||
| 663 | } | ||||
| 664 | |||||
| 665 | Node *usr = in(1); | ||||
| 666 | const TypeLong *t2 = phase->type( in(2) )->isa_long(); | ||||
| 667 | if( t2
| ||||
| 668 | jlong con = t2->get_con(); | ||||
| 669 | // Masking off high bits which are always zero is useless. | ||||
| 670 | const TypeLong* t1 = phase->type( in(1) )->isa_long(); | ||||
| 671 | if (t1
| ||||
| 672 | int bit_count = log2i_graceful(t1->_hi) + 1; | ||||
| 673 | jlong t1_support = jlong(max_julong >> (BitsPerJavaLong - bit_count)); | ||||
| |||||
| 674 | if ((t1_support & con) == t1_support) | ||||
| 675 | return usr; | ||||
| 676 | } | ||||
| 677 | uint lop = usr->Opcode(); | ||||
| 678 | // Masking off the high bits of a unsigned-shift-right is not | ||||
| 679 | // needed either. | ||||
| 680 | if( lop == Op_URShiftL ) { | ||||
| 681 | const TypeInt *t12 = phase->type( usr->in(2) )->isa_int(); | ||||
| 682 | if( t12 && t12->is_con() ) { // Shift is by a constant | ||||
| 683 | int shift = t12->get_con(); | ||||
| 684 | shift &= BitsPerJavaLong - 1; // semantics of Java shifts | ||||
| 685 | jlong mask = max_julong >> shift; | ||||
| 686 | if( (mask&con) == mask ) // If AND is useless, skip it | ||||
| 687 | return usr; | ||||
| 688 | } | ||||
| 689 | } | ||||
| 690 | } | ||||
| 691 | return MulNode::Identity(phase); | ||||
| 692 | } | ||||
| 693 | |||||
| 694 | //------------------------------Ideal------------------------------------------ | ||||
| 695 | Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) { | ||||
| 696 | // Special case constant AND mask | ||||
| 697 | const TypeLong *t2 = phase->type( in(2) )->isa_long(); | ||||
| 698 | if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape); | ||||
| 699 | const jlong mask = t2->get_con(); | ||||
| 700 | |||||
| 701 | Node* in1 = in(1); | ||||
| 702 | int op = in1->Opcode(); | ||||
| 703 | |||||
| 704 | // Are we masking a long that was converted from an int with a mask | ||||
| 705 | // that fits in 32-bits? Commute them and use an AndINode. Don't | ||||
| 706 | // convert masks which would cause a sign extension of the integer | ||||
| 707 | // value. This check includes UI2L masks (0x00000000FFFFFFFF) which | ||||
| 708 | // would be optimized away later in Identity. | ||||
| 709 | if (op == Op_ConvI2L && (mask & UCONST64(0xFFFFFFFF80000000)(0xFFFFFFFF80000000ULL)) == 0) { | ||||
| 710 | Node* andi = new AndINode(in1->in(1), phase->intcon(mask)); | ||||
| 711 | andi = phase->transform(andi); | ||||
| 712 | return new ConvI2LNode(andi); | ||||
| 713 | } | ||||
| 714 | |||||
| 715 | // Masking off sign bits? Dont make them! | ||||
| 716 | if (op == Op_RShiftL) { | ||||
| 717 | const TypeInt* t12 = phase->type(in1->in(2))->isa_int(); | ||||
| 718 | if( t12 && t12->is_con() ) { // Shift is by a constant | ||||
| 719 | int shift = t12->get_con(); | ||||
| 720 | shift &= BitsPerJavaLong - 1; // semantics of Java shifts | ||||
| 721 | const jlong sign_bits_mask = ~(((jlong)CONST64(1)(1LL) << (jlong)(BitsPerJavaLong - shift)) -1); | ||||
| 722 | // If the AND'ing of the 2 masks has no bits, then only original shifted | ||||
| 723 | // bits survive. NO sign-extension bits survive the maskings. | ||||
| 724 | if( (sign_bits_mask & mask) == 0 ) { | ||||
| 725 | // Use zero-fill shift instead | ||||
| 726 | Node *zshift = phase->transform(new URShiftLNode(in1->in(1), in1->in(2))); | ||||
| 727 | return new AndLNode(zshift, in(2)); | ||||
| 728 | } | ||||
| 729 | } | ||||
| 730 | } | ||||
| 731 | |||||
| 732 | // pattern similar to (v1 + (v2 << 2)) & 3 transformed to v1 & 3 | ||||
| 733 | Node* progress = AndIL_add_shift_and_mask(phase, T_LONG); | ||||
| 734 | if (progress != NULL__null) { | ||||
| 735 | return progress; | ||||
| 736 | } | ||||
| 737 | |||||
| 738 | return MulNode::Ideal(phase, can_reshape); | ||||
| 739 | } | ||||
| 740 | |||||
| 741 | //============================================================================= | ||||
| 742 | |||||
| 743 | static bool const_shift_count(PhaseGVN* phase, Node* shiftNode, int* count) { | ||||
| 744 | const TypeInt* tcount = phase->type(shiftNode->in(2))->isa_int(); | ||||
| 745 | if (tcount != NULL__null && tcount->is_con()) { | ||||
| 746 | *count = tcount->get_con(); | ||||
| 747 | return true; | ||||
| 748 | } | ||||
| 749 | return false; | ||||
| 750 | } | ||||
| 751 | |||||
| 752 | static int maskShiftAmount(PhaseGVN* phase, Node* shiftNode, int nBits) { | ||||
| 753 | int count = 0; | ||||
| 754 | if (const_shift_count(phase, shiftNode, &count)) { | ||||
| 755 | int maskedShift = count & (nBits - 1); | ||||
| 756 | if (maskedShift == 0) { | ||||
| 757 | // Let Identity() handle 0 shift count. | ||||
| 758 | return 0; | ||||
| 759 | } | ||||
| 760 | |||||
| 761 | if (count != maskedShift) { | ||||
| 762 | shiftNode->set_req(2, phase->intcon(maskedShift)); // Replace shift count with masked value. | ||||
| 763 | PhaseIterGVN* igvn = phase->is_IterGVN(); | ||||
| 764 | if (igvn) { | ||||
| 765 | igvn->rehash_node_delayed(shiftNode); | ||||
| 766 | } | ||||
| 767 | } | ||||
| 768 | return maskedShift; | ||||
| 769 | } | ||||
| 770 | return 0; | ||||
| 771 | } | ||||
| 772 | |||||
| 773 | //------------------------------Identity--------------------------------------- | ||||
| 774 | Node* LShiftINode::Identity(PhaseGVN* phase) { | ||||
| 775 | int count = 0; | ||||
| 776 | if (const_shift_count(phase, this, &count) && (count & (BitsPerJavaInteger - 1)) == 0) { | ||||
| 777 | // Shift by a multiple of 32 does nothing | ||||
| 778 | return in(1); | ||||
| 779 | } | ||||
| 780 | return this; | ||||
| 781 | } | ||||
| 782 | |||||
| 783 | //------------------------------Ideal------------------------------------------ | ||||
| 784 | // If the right input is a constant, and the left input is an add of a | ||||
| 785 | // constant, flatten the tree: (X+con1)<<con0 ==> X<<con0 + con1<<con0 | ||||
| 786 | Node *LShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { | ||||
| 787 | int con = maskShiftAmount(phase, this, BitsPerJavaInteger); | ||||
| 788 | if (con == 0) { | ||||
| 789 | return NULL__null; | ||||
| 790 | } | ||||
| 791 | |||||
| 792 | // Left input is an add of a constant? | ||||
| 793 | Node *add1 = in(1); | ||||
| 794 | int add1_op = add1->Opcode(); | ||||
| 795 | if( add1_op == Op_AddI ) { // Left input is an add? | ||||
| 796 | assert( add1 != add1->in(1), "dead loop in LShiftINode::Ideal" )do { if (!(add1 != add1->in(1))) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 796, "assert(" "add1 != add1->in(1)" ") failed", "dead loop in LShiftINode::Ideal" ); ::breakpoint(); } } while (0); | ||||
| 797 | const TypeInt *t12 = phase->type(add1->in(2))->isa_int(); | ||||
| 798 | if( t12 && t12->is_con() ){ // Left input is an add of a con? | ||||
| 799 | // Transform is legal, but check for profit. Avoid breaking 'i2s' | ||||
| 800 | // and 'i2b' patterns which typically fold into 'StoreC/StoreB'. | ||||
| 801 | if( con < 16 ) { | ||||
| 802 | // Compute X << con0 | ||||
| 803 | Node *lsh = phase->transform( new LShiftINode( add1->in(1), in(2) ) ); | ||||
| 804 | // Compute X<<con0 + (con1<<con0) | ||||
| 805 | return new AddINode( lsh, phase->intcon(t12->get_con() << con)); | ||||
| 806 | } | ||||
| 807 | } | ||||
| 808 | } | ||||
| 809 | |||||
| 810 | // Check for "(x>>c0)<<c0" which just masks off low bits | ||||
| 811 | if( (add1_op == Op_RShiftI || add1_op == Op_URShiftI ) && | ||||
| 812 | add1->in(2) == in(2) ) | ||||
| 813 | // Convert to "(x & -(1<<c0))" | ||||
| 814 | return new AndINode(add1->in(1),phase->intcon( -(1<<con))); | ||||
| 815 | |||||
| 816 | // Check for "((x>>c0) & Y)<<c0" which just masks off more low bits | ||||
| 817 | if( add1_op == Op_AndI ) { | ||||
| 818 | Node *add2 = add1->in(1); | ||||
| 819 | int add2_op = add2->Opcode(); | ||||
| 820 | if( (add2_op == Op_RShiftI || add2_op == Op_URShiftI ) && | ||||
| 821 | add2->in(2) == in(2) ) { | ||||
| 822 | // Convert to "(x & (Y<<c0))" | ||||
| 823 | Node *y_sh = phase->transform( new LShiftINode( add1->in(2), in(2) ) ); | ||||
| 824 | return new AndINode( add2->in(1), y_sh ); | ||||
| 825 | } | ||||
| 826 | } | ||||
| 827 | |||||
| 828 | // Check for ((x & ((1<<(32-c0))-1)) << c0) which ANDs off high bits | ||||
| 829 | // before shifting them away. | ||||
| 830 | const jint bits_mask = right_n_bits(BitsPerJavaInteger-con)((((BitsPerJavaInteger-con) >= BitsPerWord) ? 0 : (OneBit << (BitsPerJavaInteger-con))) - 1); | ||||
| 831 | if( add1_op == Op_AndI && | ||||
| 832 | phase->type(add1->in(2)) == TypeInt::make( bits_mask ) ) | ||||
| 833 | return new LShiftINode( add1->in(1), in(2) ); | ||||
| 834 | |||||
| 835 | return NULL__null; | ||||
| 836 | } | ||||
| 837 | |||||
| 838 | //------------------------------Value------------------------------------------ | ||||
| 839 | // A LShiftINode shifts its input2 left by input1 amount. | ||||
| 840 | const Type* LShiftINode::Value(PhaseGVN* phase) const { | ||||
| 841 | const Type *t1 = phase->type( in(1) ); | ||||
| 842 | const Type *t2 = phase->type( in(2) ); | ||||
| 843 | // Either input is TOP ==> the result is TOP | ||||
| 844 | if( t1 == Type::TOP ) return Type::TOP; | ||||
| 845 | if( t2 == Type::TOP ) return Type::TOP; | ||||
| 846 | |||||
| 847 | // Left input is ZERO ==> the result is ZERO. | ||||
| 848 | if( t1 == TypeInt::ZERO ) return TypeInt::ZERO; | ||||
| 849 | // Shift by zero does nothing | ||||
| 850 | if( t2 == TypeInt::ZERO ) return t1; | ||||
| 851 | |||||
| 852 | // Either input is BOTTOM ==> the result is BOTTOM | ||||
| 853 | if( (t1 == TypeInt::INT) || (t2 == TypeInt::INT) || | ||||
| 854 | (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) ) | ||||
| 855 | return TypeInt::INT; | ||||
| 856 | |||||
| 857 | const TypeInt *r1 = t1->is_int(); // Handy access | ||||
| 858 | const TypeInt *r2 = t2->is_int(); // Handy access | ||||
| 859 | |||||
| 860 | if (!r2->is_con()) | ||||
| 861 | return TypeInt::INT; | ||||
| 862 | |||||
| 863 | uint shift = r2->get_con(); | ||||
| 864 | shift &= BitsPerJavaInteger-1; // semantics of Java shifts | ||||
| 865 | // Shift by a multiple of 32 does nothing: | ||||
| 866 | if (shift == 0) return t1; | ||||
| 867 | |||||
| 868 | // If the shift is a constant, shift the bounds of the type, | ||||
| 869 | // unless this could lead to an overflow. | ||||
| 870 | if (!r1->is_con()) { | ||||
| 871 | jint lo = r1->_lo, hi = r1->_hi; | ||||
| 872 | if (((lo << shift) >> shift) == lo && | ||||
| 873 | ((hi << shift) >> shift) == hi) { | ||||
| 874 | // No overflow. The range shifts up cleanly. | ||||
| 875 | return TypeInt::make((jint)lo << (jint)shift, | ||||
| 876 | (jint)hi << (jint)shift, | ||||
| 877 | MAX2(r1->_widen,r2->_widen)); | ||||
| 878 | } | ||||
| 879 | return TypeInt::INT; | ||||
| 880 | } | ||||
| 881 | |||||
| 882 | return TypeInt::make( (jint)r1->get_con() << (jint)shift ); | ||||
| 883 | } | ||||
| 884 | |||||
| 885 | //============================================================================= | ||||
| 886 | //------------------------------Identity--------------------------------------- | ||||
| 887 | Node* LShiftLNode::Identity(PhaseGVN* phase) { | ||||
| 888 | int count = 0; | ||||
| 889 | if (const_shift_count(phase, this, &count) && (count & (BitsPerJavaLong - 1)) == 0) { | ||||
| 890 | // Shift by a multiple of 64 does nothing | ||||
| 891 | return in(1); | ||||
| 892 | } | ||||
| 893 | return this; | ||||
| 894 | } | ||||
| 895 | |||||
| 896 | //------------------------------Ideal------------------------------------------ | ||||
| 897 | // If the right input is a constant, and the left input is an add of a | ||||
| 898 | // constant, flatten the tree: (X+con1)<<con0 ==> X<<con0 + con1<<con0 | ||||
| 899 | Node *LShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) { | ||||
| 900 | int con = maskShiftAmount(phase, this, BitsPerJavaLong); | ||||
| 901 | if (con == 0) { | ||||
| 902 | return NULL__null; | ||||
| 903 | } | ||||
| 904 | |||||
| 905 | // Left input is an add of a constant? | ||||
| 906 | Node *add1 = in(1); | ||||
| 907 | int add1_op = add1->Opcode(); | ||||
| 908 | if( add1_op == Op_AddL ) { // Left input is an add? | ||||
| 909 | // Avoid dead data cycles from dead loops | ||||
| 910 | assert( add1 != add1->in(1), "dead loop in LShiftLNode::Ideal" )do { if (!(add1 != add1->in(1))) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 910, "assert(" "add1 != add1->in(1)" ") failed", "dead loop in LShiftLNode::Ideal" ); ::breakpoint(); } } while (0); | ||||
| 911 | const TypeLong *t12 = phase->type(add1->in(2))->isa_long(); | ||||
| 912 | if( t12 && t12->is_con() ){ // Left input is an add of a con? | ||||
| 913 | // Compute X << con0 | ||||
| 914 | Node *lsh = phase->transform( new LShiftLNode( add1->in(1), in(2) ) ); | ||||
| 915 | // Compute X<<con0 + (con1<<con0) | ||||
| 916 | return new AddLNode( lsh, phase->longcon(t12->get_con() << con)); | ||||
| 917 | } | ||||
| 918 | } | ||||
| 919 | |||||
| 920 | // Check for "(x>>c0)<<c0" which just masks off low bits | ||||
| 921 | if( (add1_op == Op_RShiftL || add1_op == Op_URShiftL ) && | ||||
| 922 | add1->in(2) == in(2) ) | ||||
| 923 | // Convert to "(x & -(1<<c0))" | ||||
| 924 | return new AndLNode(add1->in(1),phase->longcon( -(CONST64(1)(1LL)<<con))); | ||||
| 925 | |||||
| 926 | // Check for "((x>>c0) & Y)<<c0" which just masks off more low bits | ||||
| 927 | if( add1_op == Op_AndL ) { | ||||
| 928 | Node *add2 = add1->in(1); | ||||
| 929 | int add2_op = add2->Opcode(); | ||||
| 930 | if( (add2_op == Op_RShiftL || add2_op == Op_URShiftL ) && | ||||
| 931 | add2->in(2) == in(2) ) { | ||||
| 932 | // Convert to "(x & (Y<<c0))" | ||||
| 933 | Node *y_sh = phase->transform( new LShiftLNode( add1->in(2), in(2) ) ); | ||||
| 934 | return new AndLNode( add2->in(1), y_sh ); | ||||
| 935 | } | ||||
| 936 | } | ||||
| 937 | |||||
| 938 | // Check for ((x & ((CONST64(1)<<(64-c0))-1)) << c0) which ANDs off high bits | ||||
| 939 | // before shifting them away. | ||||
| 940 | const jlong bits_mask = jlong(max_julong >> con); | ||||
| 941 | if( add1_op == Op_AndL && | ||||
| 942 | phase->type(add1->in(2)) == TypeLong::make( bits_mask ) ) | ||||
| 943 | return new LShiftLNode( add1->in(1), in(2) ); | ||||
| 944 | |||||
| 945 | return NULL__null; | ||||
| 946 | } | ||||
| 947 | |||||
| 948 | //------------------------------Value------------------------------------------ | ||||
| 949 | // A LShiftLNode shifts its input2 left by input1 amount. | ||||
| 950 | const Type* LShiftLNode::Value(PhaseGVN* phase) const { | ||||
| 951 | const Type *t1 = phase->type( in(1) ); | ||||
| 952 | const Type *t2 = phase->type( in(2) ); | ||||
| 953 | // Either input is TOP ==> the result is TOP | ||||
| 954 | if( t1 == Type::TOP ) return Type::TOP; | ||||
| 955 | if( t2 == Type::TOP ) return Type::TOP; | ||||
| 956 | |||||
| 957 | // Left input is ZERO ==> the result is ZERO. | ||||
| 958 | if( t1 == TypeLong::ZERO ) return TypeLong::ZERO; | ||||
| 959 | // Shift by zero does nothing | ||||
| 960 | if( t2 == TypeInt::ZERO ) return t1; | ||||
| 961 | |||||
| 962 | // Either input is BOTTOM ==> the result is BOTTOM | ||||
| 963 | if( (t1 == TypeLong::LONG) || (t2 == TypeInt::INT) || | ||||
| 964 | (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) ) | ||||
| 965 | return TypeLong::LONG; | ||||
| 966 | |||||
| 967 | const TypeLong *r1 = t1->is_long(); // Handy access | ||||
| 968 | const TypeInt *r2 = t2->is_int(); // Handy access | ||||
| 969 | |||||
| 970 | if (!r2->is_con()) | ||||
| 971 | return TypeLong::LONG; | ||||
| 972 | |||||
| 973 | uint shift = r2->get_con(); | ||||
| 974 | shift &= BitsPerJavaLong - 1; // semantics of Java shifts | ||||
| 975 | // Shift by a multiple of 64 does nothing: | ||||
| 976 | if (shift == 0) return t1; | ||||
| 977 | |||||
| 978 | // If the shift is a constant, shift the bounds of the type, | ||||
| 979 | // unless this could lead to an overflow. | ||||
| 980 | if (!r1->is_con()) { | ||||
| 981 | jlong lo = r1->_lo, hi = r1->_hi; | ||||
| 982 | if (((lo << shift) >> shift) == lo && | ||||
| 983 | ((hi << shift) >> shift) == hi) { | ||||
| 984 | // No overflow. The range shifts up cleanly. | ||||
| 985 | return TypeLong::make((jlong)lo << (jint)shift, | ||||
| 986 | (jlong)hi << (jint)shift, | ||||
| 987 | MAX2(r1->_widen,r2->_widen)); | ||||
| 988 | } | ||||
| 989 | return TypeLong::LONG; | ||||
| 990 | } | ||||
| 991 | |||||
| 992 | return TypeLong::make( (jlong)r1->get_con() << (jint)shift ); | ||||
| 993 | } | ||||
| 994 | |||||
| 995 | //============================================================================= | ||||
| 996 | //------------------------------Identity--------------------------------------- | ||||
| 997 | Node* RShiftINode::Identity(PhaseGVN* phase) { | ||||
| 998 | int count = 0; | ||||
| 999 | if (const_shift_count(phase, this, &count)) { | ||||
| 1000 | if ((count & (BitsPerJavaInteger - 1)) == 0) { | ||||
| 1001 | // Shift by a multiple of 32 does nothing | ||||
| 1002 | return in(1); | ||||
| 1003 | } | ||||
| 1004 | // Check for useless sign-masking | ||||
| 1005 | if (in(1)->Opcode() == Op_LShiftI && | ||||
| 1006 | in(1)->req() == 3 && | ||||
| 1007 | in(1)->in(2) == in(2)) { | ||||
| 1008 | count &= BitsPerJavaInteger-1; // semantics of Java shifts | ||||
| 1009 | // Compute masks for which this shifting doesn't change | ||||
| 1010 | int lo = (-1 << (BitsPerJavaInteger - ((uint)count)-1)); // FFFF8000 | ||||
| 1011 | int hi = ~lo; // 00007FFF | ||||
| 1012 | const TypeInt* t11 = phase->type(in(1)->in(1))->isa_int(); | ||||
| 1013 | if (t11 == NULL__null) { | ||||
| 1014 | return this; | ||||
| 1015 | } | ||||
| 1016 | // Does actual value fit inside of mask? | ||||
| 1017 | if (lo <= t11->_lo && t11->_hi <= hi) { | ||||
| 1018 | return in(1)->in(1); // Then shifting is a nop | ||||
| 1019 | } | ||||
| 1020 | } | ||||
| 1021 | } | ||||
| 1022 | return this; | ||||
| 1023 | } | ||||
| 1024 | |||||
| 1025 | //------------------------------Ideal------------------------------------------ | ||||
| 1026 | Node *RShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { | ||||
| 1027 | // Inputs may be TOP if they are dead. | ||||
| 1028 | const TypeInt *t1 = phase->type(in(1))->isa_int(); | ||||
| 1029 | if (!t1) return NULL__null; // Left input is an integer | ||||
| 1030 | const TypeInt *t3; // type of in(1).in(2) | ||||
| 1031 | int shift = maskShiftAmount(phase, this, BitsPerJavaInteger); | ||||
| 1032 | if (shift == 0) { | ||||
| 1033 | return NULL__null; | ||||
| 1034 | } | ||||
| 1035 | |||||
| 1036 | // Check for (x & 0xFF000000) >> 24, whose mask can be made smaller. | ||||
| 1037 | // Such expressions arise normally from shift chains like (byte)(x >> 24). | ||||
| 1038 | const Node *mask = in(1); | ||||
| 1039 | if( mask->Opcode() == Op_AndI && | ||||
| 1040 | (t3 = phase->type(mask->in(2))->isa_int()) && | ||||
| 1041 | t3->is_con() ) { | ||||
| 1042 | Node *x = mask->in(1); | ||||
| 1043 | jint maskbits = t3->get_con(); | ||||
| 1044 | // Convert to "(x >> shift) & (mask >> shift)" | ||||
| 1045 | Node *shr_nomask = phase->transform( new RShiftINode(mask->in(1), in(2)) ); | ||||
| 1046 | return new AndINode(shr_nomask, phase->intcon( maskbits >> shift)); | ||||
| 1047 | } | ||||
| 1048 | |||||
| 1049 | // Check for "(short[i] <<16)>>16" which simply sign-extends | ||||
| 1050 | const Node *shl = in(1); | ||||
| 1051 | if( shl->Opcode() != Op_LShiftI ) return NULL__null; | ||||
| 1052 | |||||
| 1053 | if( shift == 16 && | ||||
| 1054 | (t3 = phase->type(shl->in(2))->isa_int()) && | ||||
| 1055 | t3->is_con(16) ) { | ||||
| 1056 | Node *ld = shl->in(1); | ||||
| 1057 | if( ld->Opcode() == Op_LoadS ) { | ||||
| 1058 | // Sign extension is just useless here. Return a RShiftI of zero instead | ||||
| 1059 | // returning 'ld' directly. We cannot return an old Node directly as | ||||
| 1060 | // that is the job of 'Identity' calls and Identity calls only work on | ||||
| 1061 | // direct inputs ('ld' is an extra Node removed from 'this'). The | ||||
| 1062 | // combined optimization requires Identity only return direct inputs. | ||||
| 1063 | set_req_X(1, ld, phase); | ||||
| 1064 | set_req_X(2, phase->intcon(0), phase); | ||||
| 1065 | return this; | ||||
| 1066 | } | ||||
| 1067 | else if (can_reshape && | ||||
| 1068 | ld->Opcode() == Op_LoadUS && | ||||
| 1069 | ld->outcnt() == 1 && ld->unique_out() == shl) | ||||
| 1070 | // Replace zero-extension-load with sign-extension-load | ||||
| 1071 | return ld->as_Load()->convert_to_signed_load(*phase); | ||||
| 1072 | } | ||||
| 1073 | |||||
| 1074 | // Check for "(byte[i] <<24)>>24" which simply sign-extends | ||||
| 1075 | if( shift == 24 && | ||||
| 1076 | (t3 = phase->type(shl->in(2))->isa_int()) && | ||||
| 1077 | t3->is_con(24) ) { | ||||
| 1078 | Node *ld = shl->in(1); | ||||
| 1079 | if (ld->Opcode() == Op_LoadB) { | ||||
| 1080 | // Sign extension is just useless here | ||||
| 1081 | set_req_X(1, ld, phase); | ||||
| 1082 | set_req_X(2, phase->intcon(0), phase); | ||||
| 1083 | return this; | ||||
| 1084 | } | ||||
| 1085 | } | ||||
| 1086 | |||||
| 1087 | return NULL__null; | ||||
| 1088 | } | ||||
| 1089 | |||||
| 1090 | //------------------------------Value------------------------------------------ | ||||
| 1091 | // A RShiftINode shifts its input2 right by input1 amount. | ||||
| 1092 | const Type* RShiftINode::Value(PhaseGVN* phase) const { | ||||
| 1093 | const Type *t1 = phase->type( in(1) ); | ||||
| 1094 | const Type *t2 = phase->type( in(2) ); | ||||
| 1095 | // Either input is TOP ==> the result is TOP | ||||
| 1096 | if( t1 == Type::TOP ) return Type::TOP; | ||||
| 1097 | if( t2 == Type::TOP ) return Type::TOP; | ||||
| 1098 | |||||
| 1099 | // Left input is ZERO ==> the result is ZERO. | ||||
| 1100 | if( t1 == TypeInt::ZERO ) return TypeInt::ZERO; | ||||
| 1101 | // Shift by zero does nothing | ||||
| 1102 | if( t2 == TypeInt::ZERO ) return t1; | ||||
| 1103 | |||||
| 1104 | // Either input is BOTTOM ==> the result is BOTTOM | ||||
| 1105 | if (t1 == Type::BOTTOM || t2 == Type::BOTTOM) | ||||
| 1106 | return TypeInt::INT; | ||||
| 1107 | |||||
| 1108 | if (t2 == TypeInt::INT) | ||||
| 1109 | return TypeInt::INT; | ||||
| 1110 | |||||
| 1111 | const TypeInt *r1 = t1->is_int(); // Handy access | ||||
| 1112 | const TypeInt *r2 = t2->is_int(); // Handy access | ||||
| 1113 | |||||
| 1114 | // If the shift is a constant, just shift the bounds of the type. | ||||
| 1115 | // For example, if the shift is 31, we just propagate sign bits. | ||||
| 1116 | if (r2->is_con()) { | ||||
| 1117 | uint shift = r2->get_con(); | ||||
| 1118 | shift &= BitsPerJavaInteger-1; // semantics of Java shifts | ||||
| 1119 | // Shift by a multiple of 32 does nothing: | ||||
| 1120 | if (shift == 0) return t1; | ||||
| 1121 | // Calculate reasonably aggressive bounds for the result. | ||||
| 1122 | // This is necessary if we are to correctly type things | ||||
| 1123 | // like (x<<24>>24) == ((byte)x). | ||||
| 1124 | jint lo = (jint)r1->_lo >> (jint)shift; | ||||
| 1125 | jint hi = (jint)r1->_hi >> (jint)shift; | ||||
| 1126 | assert(lo <= hi, "must have valid bounds")do { if (!(lo <= hi)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1126, "assert(" "lo <= hi" ") failed", "must have valid bounds" ); ::breakpoint(); } } while (0); | ||||
| 1127 | const TypeInt* ti = TypeInt::make(lo, hi, MAX2(r1->_widen,r2->_widen)); | ||||
| 1128 | #ifdef ASSERT1 | ||||
| 1129 | // Make sure we get the sign-capture idiom correct. | ||||
| 1130 | if (shift == BitsPerJavaInteger-1) { | ||||
| 1131 | if (r1->_lo >= 0) assert(ti == TypeInt::ZERO, ">>31 of + is 0")do { if (!(ti == TypeInt::ZERO)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1131, "assert(" "ti == TypeInt::ZERO" ") failed", ">>31 of + is 0" ); ::breakpoint(); } } while (0); | ||||
| 1132 | if (r1->_hi < 0) assert(ti == TypeInt::MINUS_1, ">>31 of - is -1")do { if (!(ti == TypeInt::MINUS_1)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1132, "assert(" "ti == TypeInt::MINUS_1" ") failed", ">>31 of - is -1" ); ::breakpoint(); } } while (0); | ||||
| 1133 | } | ||||
| 1134 | #endif | ||||
| 1135 | return ti; | ||||
| 1136 | } | ||||
| 1137 | |||||
| 1138 | if( !r1->is_con() || !r2->is_con() ) | ||||
| 1139 | return TypeInt::INT; | ||||
| 1140 | |||||
| 1141 | // Signed shift right | ||||
| 1142 | return TypeInt::make( r1->get_con() >> (r2->get_con()&31) ); | ||||
| 1143 | } | ||||
| 1144 | |||||
| 1145 | //============================================================================= | ||||
| 1146 | //------------------------------Identity--------------------------------------- | ||||
| 1147 | Node* RShiftLNode::Identity(PhaseGVN* phase) { | ||||
| 1148 | const TypeInt *ti = phase->type(in(2))->isa_int(); // Shift count is an int. | ||||
| 1149 | return (ti && ti->is_con() && (ti->get_con() & (BitsPerJavaLong - 1)) == 0) ? in(1) : this; | ||||
| 1150 | } | ||||
| 1151 | |||||
| 1152 | //------------------------------Value------------------------------------------ | ||||
| 1153 | // A RShiftLNode shifts its input2 right by input1 amount. | ||||
| 1154 | const Type* RShiftLNode::Value(PhaseGVN* phase) const { | ||||
| 1155 | const Type *t1 = phase->type( in(1) ); | ||||
| 1156 | const Type *t2 = phase->type( in(2) ); | ||||
| 1157 | // Either input is TOP ==> the result is TOP | ||||
| 1158 | if( t1 == Type::TOP ) return Type::TOP; | ||||
| 1159 | if( t2 == Type::TOP ) return Type::TOP; | ||||
| 1160 | |||||
| 1161 | // Left input is ZERO ==> the result is ZERO. | ||||
| 1162 | if( t1 == TypeLong::ZERO ) return TypeLong::ZERO; | ||||
| 1163 | // Shift by zero does nothing | ||||
| 1164 | if( t2 == TypeInt::ZERO ) return t1; | ||||
| 1165 | |||||
| 1166 | // Either input is BOTTOM ==> the result is BOTTOM | ||||
| 1167 | if (t1 == Type::BOTTOM || t2 == Type::BOTTOM) | ||||
| 1168 | return TypeLong::LONG; | ||||
| 1169 | |||||
| 1170 | if (t2 == TypeInt::INT) | ||||
| 1171 | return TypeLong::LONG; | ||||
| 1172 | |||||
| 1173 | const TypeLong *r1 = t1->is_long(); // Handy access | ||||
| 1174 | const TypeInt *r2 = t2->is_int (); // Handy access | ||||
| 1175 | |||||
| 1176 | // If the shift is a constant, just shift the bounds of the type. | ||||
| 1177 | // For example, if the shift is 63, we just propagate sign bits. | ||||
| 1178 | if (r2->is_con()) { | ||||
| 1179 | uint shift = r2->get_con(); | ||||
| 1180 | shift &= (2*BitsPerJavaInteger)-1; // semantics of Java shifts | ||||
| 1181 | // Shift by a multiple of 64 does nothing: | ||||
| 1182 | if (shift == 0) return t1; | ||||
| 1183 | // Calculate reasonably aggressive bounds for the result. | ||||
| 1184 | // This is necessary if we are to correctly type things | ||||
| 1185 | // like (x<<24>>24) == ((byte)x). | ||||
| 1186 | jlong lo = (jlong)r1->_lo >> (jlong)shift; | ||||
| 1187 | jlong hi = (jlong)r1->_hi >> (jlong)shift; | ||||
| 1188 | assert(lo <= hi, "must have valid bounds")do { if (!(lo <= hi)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1188, "assert(" "lo <= hi" ") failed", "must have valid bounds" ); ::breakpoint(); } } while (0); | ||||
| 1189 | const TypeLong* tl = TypeLong::make(lo, hi, MAX2(r1->_widen,r2->_widen)); | ||||
| 1190 | #ifdef ASSERT1 | ||||
| 1191 | // Make sure we get the sign-capture idiom correct. | ||||
| 1192 | if (shift == (2*BitsPerJavaInteger)-1) { | ||||
| 1193 | if (r1->_lo >= 0) assert(tl == TypeLong::ZERO, ">>63 of + is 0")do { if (!(tl == TypeLong::ZERO)) { (*g_assert_poison) = 'X'; ; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1193, "assert(" "tl == TypeLong::ZERO" ") failed", ">>63 of + is 0" ); ::breakpoint(); } } while (0); | ||||
| 1194 | if (r1->_hi < 0) assert(tl == TypeLong::MINUS_1, ">>63 of - is -1")do { if (!(tl == TypeLong::MINUS_1)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1194, "assert(" "tl == TypeLong::MINUS_1" ") failed", ">>63 of - is -1" ); ::breakpoint(); } } while (0); | ||||
| 1195 | } | ||||
| 1196 | #endif | ||||
| 1197 | return tl; | ||||
| 1198 | } | ||||
| 1199 | |||||
| 1200 | return TypeLong::LONG; // Give up | ||||
| 1201 | } | ||||
| 1202 | |||||
| 1203 | //============================================================================= | ||||
| 1204 | //------------------------------Identity--------------------------------------- | ||||
| 1205 | Node* URShiftINode::Identity(PhaseGVN* phase) { | ||||
| 1206 | int count = 0; | ||||
| 1207 | if (const_shift_count(phase, this, &count) && (count & (BitsPerJavaInteger - 1)) == 0) { | ||||
| 1208 | // Shift by a multiple of 32 does nothing | ||||
| 1209 | return in(1); | ||||
| 1210 | } | ||||
| 1211 | |||||
| 1212 | // Check for "((x << LogBytesPerWord) + (wordSize-1)) >> LogBytesPerWord" which is just "x". | ||||
| 1213 | // Happens during new-array length computation. | ||||
| 1214 | // Safe if 'x' is in the range [0..(max_int>>LogBytesPerWord)] | ||||
| 1215 | Node *add = in(1); | ||||
| 1216 | if (add->Opcode() == Op_AddI) { | ||||
| 1217 | const TypeInt *t2 = phase->type(add->in(2))->isa_int(); | ||||
| 1218 | if (t2 && t2->is_con(wordSize - 1) && | ||||
| 1219 | add->in(1)->Opcode() == Op_LShiftI) { | ||||
| 1220 | // Check that shift_counts are LogBytesPerWord. | ||||
| 1221 | Node *lshift_count = add->in(1)->in(2); | ||||
| 1222 | const TypeInt *t_lshift_count = phase->type(lshift_count)->isa_int(); | ||||
| 1223 | if (t_lshift_count && t_lshift_count->is_con(LogBytesPerWord) && | ||||
| 1224 | t_lshift_count == phase->type(in(2))) { | ||||
| 1225 | Node *x = add->in(1)->in(1); | ||||
| 1226 | const TypeInt *t_x = phase->type(x)->isa_int(); | ||||
| 1227 | if (t_x != NULL__null && 0 <= t_x->_lo && t_x->_hi <= (max_jint>>LogBytesPerWord)) { | ||||
| 1228 | return x; | ||||
| 1229 | } | ||||
| 1230 | } | ||||
| 1231 | } | ||||
| 1232 | } | ||||
| 1233 | |||||
| 1234 | return (phase->type(in(2))->higher_equal(TypeInt::ZERO)) ? in(1) : this; | ||||
| 1235 | } | ||||
| 1236 | |||||
| 1237 | //------------------------------Ideal------------------------------------------ | ||||
| 1238 | Node *URShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { | ||||
| 1239 | int con = maskShiftAmount(phase, this, BitsPerJavaInteger); | ||||
| 1240 | if (con == 0) { | ||||
| 1241 | return NULL__null; | ||||
| 1242 | } | ||||
| 1243 | |||||
| 1244 | // We'll be wanting the right-shift amount as a mask of that many bits | ||||
| 1245 | const int mask = right_n_bits(BitsPerJavaInteger - con)((((BitsPerJavaInteger - con) >= BitsPerWord) ? 0 : (OneBit << (BitsPerJavaInteger - con))) - 1); | ||||
| 1246 | |||||
| 1247 | int in1_op = in(1)->Opcode(); | ||||
| 1248 | |||||
| 1249 | // Check for ((x>>>a)>>>b) and replace with (x>>>(a+b)) when a+b < 32 | ||||
| 1250 | if( in1_op == Op_URShiftI ) { | ||||
| 1251 | const TypeInt *t12 = phase->type( in(1)->in(2) )->isa_int(); | ||||
| 1252 | if( t12 && t12->is_con() ) { // Right input is a constant | ||||
| 1253 | assert( in(1) != in(1)->in(1), "dead loop in URShiftINode::Ideal" )do { if (!(in(1) != in(1)->in(1))) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1253, "assert(" "in(1) != in(1)->in(1)" ") failed", "dead loop in URShiftINode::Ideal" ); ::breakpoint(); } } while (0); | ||||
| 1254 | const int con2 = t12->get_con() & 31; // Shift count is always masked | ||||
| 1255 | const int con3 = con+con2; | ||||
| 1256 | if( con3 < 32 ) // Only merge shifts if total is < 32 | ||||
| 1257 | return new URShiftINode( in(1)->in(1), phase->intcon(con3) ); | ||||
| 1258 | } | ||||
| 1259 | } | ||||
| 1260 | |||||
| 1261 | // Check for ((x << z) + Y) >>> z. Replace with x + con>>>z | ||||
| 1262 | // The idiom for rounding to a power of 2 is "(Q+(2^z-1)) >>> z". | ||||
| 1263 | // If Q is "X << z" the rounding is useless. Look for patterns like | ||||
| 1264 | // ((X<<Z) + Y) >>> Z and replace with (X + Y>>>Z) & Z-mask. | ||||
| 1265 | Node *add = in(1); | ||||
| 1266 | const TypeInt *t2 = phase->type(in(2))->isa_int(); | ||||
| 1267 | if (in1_op == Op_AddI) { | ||||
| 1268 | Node *lshl = add->in(1); | ||||
| 1269 | if( lshl->Opcode() == Op_LShiftI && | ||||
| 1270 | phase->type(lshl->in(2)) == t2 ) { | ||||
| 1271 | Node *y_z = phase->transform( new URShiftINode(add->in(2),in(2)) ); | ||||
| 1272 | Node *sum = phase->transform( new AddINode( lshl->in(1), y_z ) ); | ||||
| 1273 | return new AndINode( sum, phase->intcon(mask) ); | ||||
| 1274 | } | ||||
| 1275 | } | ||||
| 1276 | |||||
| 1277 | // Check for (x & mask) >>> z. Replace with (x >>> z) & (mask >>> z) | ||||
| 1278 | // This shortens the mask. Also, if we are extracting a high byte and | ||||
| 1279 | // storing it to a buffer, the mask will be removed completely. | ||||
| 1280 | Node *andi = in(1); | ||||
| 1281 | if( in1_op == Op_AndI ) { | ||||
| 1282 | const TypeInt *t3 = phase->type( andi->in(2) )->isa_int(); | ||||
| 1283 | if( t3 && t3->is_con() ) { // Right input is a constant | ||||
| 1284 | jint mask2 = t3->get_con(); | ||||
| 1285 | mask2 >>= con; // *signed* shift downward (high-order zeroes do not help) | ||||
| 1286 | Node *newshr = phase->transform( new URShiftINode(andi->in(1), in(2)) ); | ||||
| 1287 | return new AndINode(newshr, phase->intcon(mask2)); | ||||
| 1288 | // The negative values are easier to materialize than positive ones. | ||||
| 1289 | // A typical case from address arithmetic is ((x & ~15) >> 4). | ||||
| 1290 | // It's better to change that to ((x >> 4) & ~0) versus | ||||
| 1291 | // ((x >> 4) & 0x0FFFFFFF). The difference is greatest in LP64. | ||||
| 1292 | } | ||||
| 1293 | } | ||||
| 1294 | |||||
| 1295 | // Check for "(X << z ) >>> z" which simply zero-extends | ||||
| 1296 | Node *shl = in(1); | ||||
| 1297 | if( in1_op == Op_LShiftI && | ||||
| 1298 | phase->type(shl->in(2)) == t2 ) | ||||
| 1299 | return new AndINode( shl->in(1), phase->intcon(mask) ); | ||||
| 1300 | |||||
| 1301 | // Check for (x >> n) >>> 31. Replace with (x >>> 31) | ||||
| 1302 | Node *shr = in(1); | ||||
| 1303 | if ( in1_op == Op_RShiftI ) { | ||||
| 1304 | Node *in11 = shr->in(1); | ||||
| 1305 | Node *in12 = shr->in(2); | ||||
| 1306 | const TypeInt *t11 = phase->type(in11)->isa_int(); | ||||
| 1307 | const TypeInt *t12 = phase->type(in12)->isa_int(); | ||||
| 1308 | if ( t11 && t2 && t2->is_con(31) && t12 && t12->is_con() ) { | ||||
| 1309 | return new URShiftINode(in11, phase->intcon(31)); | ||||
| 1310 | } | ||||
| 1311 | } | ||||
| 1312 | |||||
| 1313 | return NULL__null; | ||||
| 1314 | } | ||||
| 1315 | |||||
| 1316 | //------------------------------Value------------------------------------------ | ||||
| 1317 | // A URShiftINode shifts its input2 right by input1 amount. | ||||
| 1318 | const Type* URShiftINode::Value(PhaseGVN* phase) const { | ||||
| 1319 | // (This is a near clone of RShiftINode::Value.) | ||||
| 1320 | const Type *t1 = phase->type( in(1) ); | ||||
| 1321 | const Type *t2 = phase->type( in(2) ); | ||||
| 1322 | // Either input is TOP ==> the result is TOP | ||||
| 1323 | if( t1 == Type::TOP ) return Type::TOP; | ||||
| 1324 | if( t2 == Type::TOP ) return Type::TOP; | ||||
| 1325 | |||||
| 1326 | // Left input is ZERO ==> the result is ZERO. | ||||
| 1327 | if( t1 == TypeInt::ZERO ) return TypeInt::ZERO; | ||||
| 1328 | // Shift by zero does nothing | ||||
| 1329 | if( t2 == TypeInt::ZERO ) return t1; | ||||
| 1330 | |||||
| 1331 | // Either input is BOTTOM ==> the result is BOTTOM | ||||
| 1332 | if (t1 == Type::BOTTOM || t2 == Type::BOTTOM) | ||||
| 1333 | return TypeInt::INT; | ||||
| 1334 | |||||
| 1335 | if (t2 == TypeInt::INT) | ||||
| 1336 | return TypeInt::INT; | ||||
| 1337 | |||||
| 1338 | const TypeInt *r1 = t1->is_int(); // Handy access | ||||
| 1339 | const TypeInt *r2 = t2->is_int(); // Handy access | ||||
| 1340 | |||||
| 1341 | if (r2->is_con()) { | ||||
| 1342 | uint shift = r2->get_con(); | ||||
| 1343 | shift &= BitsPerJavaInteger-1; // semantics of Java shifts | ||||
| 1344 | // Shift by a multiple of 32 does nothing: | ||||
| 1345 | if (shift == 0) return t1; | ||||
| 1346 | // Calculate reasonably aggressive bounds for the result. | ||||
| 1347 | jint lo = (juint)r1->_lo >> (juint)shift; | ||||
| 1348 | jint hi = (juint)r1->_hi >> (juint)shift; | ||||
| 1349 | if (r1->_hi >= 0 && r1->_lo < 0) { | ||||
| 1350 | // If the type has both negative and positive values, | ||||
| 1351 | // there are two separate sub-domains to worry about: | ||||
| 1352 | // The positive half and the negative half. | ||||
| 1353 | jint neg_lo = lo; | ||||
| 1354 | jint neg_hi = (juint)-1 >> (juint)shift; | ||||
| 1355 | jint pos_lo = (juint) 0 >> (juint)shift; | ||||
| 1356 | jint pos_hi = hi; | ||||
| 1357 | lo = MIN2(neg_lo, pos_lo); // == 0 | ||||
| 1358 | hi = MAX2(neg_hi, pos_hi); // == -1 >>> shift; | ||||
| 1359 | } | ||||
| 1360 | assert(lo <= hi, "must have valid bounds")do { if (!(lo <= hi)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1360, "assert(" "lo <= hi" ") failed", "must have valid bounds" ); ::breakpoint(); } } while (0); | ||||
| 1361 | const TypeInt* ti = TypeInt::make(lo, hi, MAX2(r1->_widen,r2->_widen)); | ||||
| 1362 | #ifdef ASSERT1 | ||||
| 1363 | // Make sure we get the sign-capture idiom correct. | ||||
| 1364 | if (shift == BitsPerJavaInteger-1) { | ||||
| 1365 | if (r1->_lo >= 0) assert(ti == TypeInt::ZERO, ">>>31 of + is 0")do { if (!(ti == TypeInt::ZERO)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1365, "assert(" "ti == TypeInt::ZERO" ") failed", ">>>31 of + is 0" ); ::breakpoint(); } } while (0); | ||||
| 1366 | if (r1->_hi < 0) assert(ti == TypeInt::ONE, ">>>31 of - is +1")do { if (!(ti == TypeInt::ONE)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1366, "assert(" "ti == TypeInt::ONE" ") failed", ">>>31 of - is +1" ); ::breakpoint(); } } while (0); | ||||
| 1367 | } | ||||
| 1368 | #endif | ||||
| 1369 | return ti; | ||||
| 1370 | } | ||||
| 1371 | |||||
| 1372 | // | ||||
| 1373 | // Do not support shifted oops in info for GC | ||||
| 1374 | // | ||||
| 1375 | // else if( t1->base() == Type::InstPtr ) { | ||||
| 1376 | // | ||||
| 1377 | // const TypeInstPtr *o = t1->is_instptr(); | ||||
| 1378 | // if( t1->singleton() ) | ||||
| 1379 | // return TypeInt::make( ((uint32_t)o->const_oop() + o->_offset) >> shift ); | ||||
| 1380 | // } | ||||
| 1381 | // else if( t1->base() == Type::KlassPtr ) { | ||||
| 1382 | // const TypeKlassPtr *o = t1->is_klassptr(); | ||||
| 1383 | // if( t1->singleton() ) | ||||
| 1384 | // return TypeInt::make( ((uint32_t)o->const_oop() + o->_offset) >> shift ); | ||||
| 1385 | // } | ||||
| 1386 | |||||
| 1387 | return TypeInt::INT; | ||||
| 1388 | } | ||||
| 1389 | |||||
| 1390 | //============================================================================= | ||||
| 1391 | //------------------------------Identity--------------------------------------- | ||||
| 1392 | Node* URShiftLNode::Identity(PhaseGVN* phase) { | ||||
| 1393 | int count = 0; | ||||
| 1394 | if (const_shift_count(phase, this, &count) && (count & (BitsPerJavaLong - 1)) == 0) { | ||||
| 1395 | // Shift by a multiple of 64 does nothing | ||||
| 1396 | return in(1); | ||||
| 1397 | } | ||||
| 1398 | return this; | ||||
| 1399 | } | ||||
| 1400 | |||||
| 1401 | //------------------------------Ideal------------------------------------------ | ||||
| 1402 | Node *URShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) { | ||||
| 1403 | int con = maskShiftAmount(phase, this, BitsPerJavaLong); | ||||
| 1404 | if (con == 0) { | ||||
| 1405 | return NULL__null; | ||||
| 1406 | } | ||||
| 1407 | |||||
| 1408 | // We'll be wanting the right-shift amount as a mask of that many bits | ||||
| 1409 | const jlong mask = jlong(max_julong >> con); | ||||
| 1410 | |||||
| 1411 | // Check for ((x << z) + Y) >>> z. Replace with x + con>>>z | ||||
| 1412 | // The idiom for rounding to a power of 2 is "(Q+(2^z-1)) >>> z". | ||||
| 1413 | // If Q is "X << z" the rounding is useless. Look for patterns like | ||||
| 1414 | // ((X<<Z) + Y) >>> Z and replace with (X + Y>>>Z) & Z-mask. | ||||
| 1415 | Node *add = in(1); | ||||
| 1416 | const TypeInt *t2 = phase->type(in(2))->isa_int(); | ||||
| 1417 | if (add->Opcode() == Op_AddL) { | ||||
| 1418 | Node *lshl = add->in(1); | ||||
| 1419 | if( lshl->Opcode() == Op_LShiftL && | ||||
| 1420 | phase->type(lshl->in(2)) == t2 ) { | ||||
| 1421 | Node *y_z = phase->transform( new URShiftLNode(add->in(2),in(2)) ); | ||||
| 1422 | Node *sum = phase->transform( new AddLNode( lshl->in(1), y_z ) ); | ||||
| 1423 | return new AndLNode( sum, phase->longcon(mask) ); | ||||
| 1424 | } | ||||
| 1425 | } | ||||
| 1426 | |||||
| 1427 | // Check for (x & mask) >>> z. Replace with (x >>> z) & (mask >>> z) | ||||
| 1428 | // This shortens the mask. Also, if we are extracting a high byte and | ||||
| 1429 | // storing it to a buffer, the mask will be removed completely. | ||||
| 1430 | Node *andi = in(1); | ||||
| 1431 | if( andi->Opcode() == Op_AndL ) { | ||||
| 1432 | const TypeLong *t3 = phase->type( andi->in(2) )->isa_long(); | ||||
| 1433 | if( t3 && t3->is_con() ) { // Right input is a constant | ||||
| 1434 | jlong mask2 = t3->get_con(); | ||||
| 1435 | mask2 >>= con; // *signed* shift downward (high-order zeroes do not help) | ||||
| 1436 | Node *newshr = phase->transform( new URShiftLNode(andi->in(1), in(2)) ); | ||||
| 1437 | return new AndLNode(newshr, phase->longcon(mask2)); | ||||
| 1438 | } | ||||
| 1439 | } | ||||
| 1440 | |||||
| 1441 | // Check for "(X << z ) >>> z" which simply zero-extends | ||||
| 1442 | Node *shl = in(1); | ||||
| 1443 | if( shl->Opcode() == Op_LShiftL && | ||||
| 1444 | phase->type(shl->in(2)) == t2 ) | ||||
| 1445 | return new AndLNode( shl->in(1), phase->longcon(mask) ); | ||||
| 1446 | |||||
| 1447 | // Check for (x >> n) >>> 63. Replace with (x >>> 63) | ||||
| 1448 | Node *shr = in(1); | ||||
| 1449 | if ( shr->Opcode() == Op_RShiftL ) { | ||||
| 1450 | Node *in11 = shr->in(1); | ||||
| 1451 | Node *in12 = shr->in(2); | ||||
| 1452 | const TypeLong *t11 = phase->type(in11)->isa_long(); | ||||
| 1453 | const TypeInt *t12 = phase->type(in12)->isa_int(); | ||||
| 1454 | if ( t11 && t2 && t2->is_con(63) && t12 && t12->is_con() ) { | ||||
| 1455 | return new URShiftLNode(in11, phase->intcon(63)); | ||||
| 1456 | } | ||||
| 1457 | } | ||||
| 1458 | return NULL__null; | ||||
| 1459 | } | ||||
| 1460 | |||||
| 1461 | //------------------------------Value------------------------------------------ | ||||
| 1462 | // A URShiftINode shifts its input2 right by input1 amount. | ||||
| 1463 | const Type* URShiftLNode::Value(PhaseGVN* phase) const { | ||||
| 1464 | // (This is a near clone of RShiftLNode::Value.) | ||||
| 1465 | const Type *t1 = phase->type( in(1) ); | ||||
| 1466 | const Type *t2 = phase->type( in(2) ); | ||||
| 1467 | // Either input is TOP ==> the result is TOP | ||||
| 1468 | if( t1 == Type::TOP ) return Type::TOP; | ||||
| 1469 | if( t2 == Type::TOP ) return Type::TOP; | ||||
| 1470 | |||||
| 1471 | // Left input is ZERO ==> the result is ZERO. | ||||
| 1472 | if( t1 == TypeLong::ZERO ) return TypeLong::ZERO; | ||||
| 1473 | // Shift by zero does nothing | ||||
| 1474 | if( t2 == TypeInt::ZERO ) return t1; | ||||
| 1475 | |||||
| 1476 | // Either input is BOTTOM ==> the result is BOTTOM | ||||
| 1477 | if (t1 == Type::BOTTOM || t2 == Type::BOTTOM) | ||||
| 1478 | return TypeLong::LONG; | ||||
| 1479 | |||||
| 1480 | if (t2 == TypeInt::INT) | ||||
| 1481 | return TypeLong::LONG; | ||||
| 1482 | |||||
| 1483 | const TypeLong *r1 = t1->is_long(); // Handy access | ||||
| 1484 | const TypeInt *r2 = t2->is_int (); // Handy access | ||||
| 1485 | |||||
| 1486 | if (r2->is_con()) { | ||||
| 1487 | uint shift = r2->get_con(); | ||||
| 1488 | shift &= BitsPerJavaLong - 1; // semantics of Java shifts | ||||
| 1489 | // Shift by a multiple of 64 does nothing: | ||||
| 1490 | if (shift == 0) return t1; | ||||
| 1491 | // Calculate reasonably aggressive bounds for the result. | ||||
| 1492 | jlong lo = (julong)r1->_lo >> (juint)shift; | ||||
| 1493 | jlong hi = (julong)r1->_hi >> (juint)shift; | ||||
| 1494 | if (r1->_hi >= 0 && r1->_lo < 0) { | ||||
| 1495 | // If the type has both negative and positive values, | ||||
| 1496 | // there are two separate sub-domains to worry about: | ||||
| 1497 | // The positive half and the negative half. | ||||
| 1498 | jlong neg_lo = lo; | ||||
| 1499 | jlong neg_hi = (julong)-1 >> (juint)shift; | ||||
| 1500 | jlong pos_lo = (julong) 0 >> (juint)shift; | ||||
| 1501 | jlong pos_hi = hi; | ||||
| 1502 | //lo = MIN2(neg_lo, pos_lo); // == 0 | ||||
| 1503 | lo = neg_lo < pos_lo ? neg_lo : pos_lo; | ||||
| 1504 | //hi = MAX2(neg_hi, pos_hi); // == -1 >>> shift; | ||||
| 1505 | hi = neg_hi > pos_hi ? neg_hi : pos_hi; | ||||
| 1506 | } | ||||
| 1507 | assert(lo <= hi, "must have valid bounds")do { if (!(lo <= hi)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1507, "assert(" "lo <= hi" ") failed", "must have valid bounds" ); ::breakpoint(); } } while (0); | ||||
| 1508 | const TypeLong* tl = TypeLong::make(lo, hi, MAX2(r1->_widen,r2->_widen)); | ||||
| 1509 | #ifdef ASSERT1 | ||||
| 1510 | // Make sure we get the sign-capture idiom correct. | ||||
| 1511 | if (shift == BitsPerJavaLong - 1) { | ||||
| 1512 | if (r1->_lo >= 0) assert(tl == TypeLong::ZERO, ">>>63 of + is 0")do { if (!(tl == TypeLong::ZERO)) { (*g_assert_poison) = 'X'; ; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1512, "assert(" "tl == TypeLong::ZERO" ") failed", ">>>63 of + is 0" ); ::breakpoint(); } } while (0); | ||||
| 1513 | if (r1->_hi < 0) assert(tl == TypeLong::ONE, ">>>63 of - is +1")do { if (!(tl == TypeLong::ONE)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1513, "assert(" "tl == TypeLong::ONE" ") failed", ">>>63 of - is +1" ); ::breakpoint(); } } while (0); | ||||
| 1514 | } | ||||
| 1515 | #endif | ||||
| 1516 | return tl; | ||||
| 1517 | } | ||||
| 1518 | |||||
| 1519 | return TypeLong::LONG; // Give up | ||||
| 1520 | } | ||||
| 1521 | |||||
| 1522 | //============================================================================= | ||||
| 1523 | //------------------------------Value------------------------------------------ | ||||
| 1524 | const Type* FmaDNode::Value(PhaseGVN* phase) const { | ||||
| 1525 | const Type *t1 = phase->type(in(1)); | ||||
| 1526 | if (t1 == Type::TOP) return Type::TOP; | ||||
| 1527 | if (t1->base() != Type::DoubleCon) return Type::DOUBLE; | ||||
| 1528 | const Type *t2 = phase->type(in(2)); | ||||
| 1529 | if (t2 == Type::TOP) return Type::TOP; | ||||
| 1530 | if (t2->base() != Type::DoubleCon) return Type::DOUBLE; | ||||
| 1531 | const Type *t3 = phase->type(in(3)); | ||||
| 1532 | if (t3 == Type::TOP) return Type::TOP; | ||||
| 1533 | if (t3->base() != Type::DoubleCon) return Type::DOUBLE; | ||||
| 1534 | #ifndef __STDC_IEC_559__1 | ||||
| 1535 | return Type::DOUBLE; | ||||
| 1536 | #else | ||||
| 1537 | double d1 = t1->getd(); | ||||
| 1538 | double d2 = t2->getd(); | ||||
| 1539 | double d3 = t3->getd(); | ||||
| 1540 | return TypeD::make(fma(d1, d2, d3)); | ||||
| 1541 | #endif | ||||
| 1542 | } | ||||
| 1543 | |||||
| 1544 | //============================================================================= | ||||
| 1545 | //------------------------------Value------------------------------------------ | ||||
| 1546 | const Type* FmaFNode::Value(PhaseGVN* phase) const { | ||||
| 1547 | const Type *t1 = phase->type(in(1)); | ||||
| 1548 | if (t1 == Type::TOP) return Type::TOP; | ||||
| 1549 | if (t1->base() != Type::FloatCon) return Type::FLOAT; | ||||
| 1550 | const Type *t2 = phase->type(in(2)); | ||||
| 1551 | if (t2 == Type::TOP) return Type::TOP; | ||||
| 1552 | if (t2->base() != Type::FloatCon) return Type::FLOAT; | ||||
| 1553 | const Type *t3 = phase->type(in(3)); | ||||
| 1554 | if (t3 == Type::TOP) return Type::TOP; | ||||
| 1555 | if (t3->base() != Type::FloatCon) return Type::FLOAT; | ||||
| 1556 | #ifndef __STDC_IEC_559__1 | ||||
| 1557 | return Type::FLOAT; | ||||
| 1558 | #else | ||||
| 1559 | float f1 = t1->getf(); | ||||
| 1560 | float f2 = t2->getf(); | ||||
| 1561 | float f3 = t3->getf(); | ||||
| 1562 | return TypeF::make(fma(f1, f2, f3)); | ||||
| 1563 | #endif | ||||
| 1564 | } | ||||
| 1565 | |||||
| 1566 | //============================================================================= | ||||
| 1567 | //------------------------------hash------------------------------------------- | ||||
| 1568 | // Hash function for MulAddS2INode. Operation is commutative with commutative pairs. | ||||
| 1569 | // The hash function must return the same value when edge swapping is performed. | ||||
| 1570 | uint MulAddS2INode::hash() const { | ||||
| 1571 | return (uintptr_t)in(1) + (uintptr_t)in(2) + (uintptr_t)in(3) + (uintptr_t)in(4) + Opcode(); | ||||
| 1572 | } | ||||
| 1573 | |||||
| 1574 | //------------------------------Rotate Operations ------------------------------ | ||||
| 1575 | |||||
| 1576 | Node* RotateLeftNode::Identity(PhaseGVN* phase) { | ||||
| 1577 | const Type* t1 = phase->type(in(1)); | ||||
| 1578 | if (t1 == Type::TOP) { | ||||
| 1579 | return this; | ||||
| 1580 | } | ||||
| 1581 | int count = 0; | ||||
| 1582 | assert(t1->isa_int() || t1->isa_long(), "Unexpected type")do { if (!(t1->isa_int() || t1->isa_long())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1582, "assert(" "t1->isa_int() || t1->isa_long()" ") failed" , "Unexpected type"); ::breakpoint(); } } while (0); | ||||
| 1583 | int mask = (t1->isa_int() ? BitsPerJavaInteger : BitsPerJavaLong) - 1; | ||||
| 1584 | if (const_shift_count(phase, this, &count) && (count & mask) == 0) { | ||||
| 1585 | // Rotate by a multiple of 32/64 does nothing | ||||
| 1586 | return in(1); | ||||
| 1587 | } | ||||
| 1588 | return this; | ||||
| 1589 | } | ||||
| 1590 | |||||
| 1591 | const Type* RotateLeftNode::Value(PhaseGVN* phase) const { | ||||
| 1592 | const Type* t1 = phase->type(in(1)); | ||||
| 1593 | const Type* t2 = phase->type(in(2)); | ||||
| 1594 | // Either input is TOP ==> the result is TOP | ||||
| 1595 | if (t1 == Type::TOP || t2 == Type::TOP) { | ||||
| 1596 | return Type::TOP; | ||||
| 1597 | } | ||||
| 1598 | |||||
| 1599 | if (t1->isa_int()) { | ||||
| 1600 | const TypeInt* r1 = t1->is_int(); | ||||
| 1601 | const TypeInt* r2 = t2->is_int(); | ||||
| 1602 | |||||
| 1603 | // Left input is ZERO ==> the result is ZERO. | ||||
| 1604 | if (r1 == TypeInt::ZERO) { | ||||
| 1605 | return TypeInt::ZERO; | ||||
| 1606 | } | ||||
| 1607 | // Rotate by zero does nothing | ||||
| 1608 | if (r2 == TypeInt::ZERO) { | ||||
| 1609 | return r1; | ||||
| 1610 | } | ||||
| 1611 | if (r1->is_con() && r2->is_con()) { | ||||
| 1612 | juint r1_con = (juint)r1->get_con(); | ||||
| 1613 | juint shift = (juint)(r2->get_con()) & (juint)(BitsPerJavaInteger - 1); // semantics of Java shifts | ||||
| 1614 | return TypeInt::make((r1_con << shift) | (r1_con >> (32 - shift))); | ||||
| 1615 | } | ||||
| 1616 | return TypeInt::INT; | ||||
| 1617 | } else { | ||||
| 1618 | assert(t1->isa_long(), "Type must be a long")do { if (!(t1->isa_long())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1618, "assert(" "t1->isa_long()" ") failed", "Type must be a long" ); ::breakpoint(); } } while (0); | ||||
| 1619 | const TypeLong* r1 = t1->is_long(); | ||||
| 1620 | const TypeInt* r2 = t2->is_int(); | ||||
| 1621 | |||||
| 1622 | // Left input is ZERO ==> the result is ZERO. | ||||
| 1623 | if (r1 == TypeLong::ZERO) { | ||||
| 1624 | return TypeLong::ZERO; | ||||
| 1625 | } | ||||
| 1626 | // Rotate by zero does nothing | ||||
| 1627 | if (r2 == TypeInt::ZERO) { | ||||
| 1628 | return r1; | ||||
| 1629 | } | ||||
| 1630 | if (r1->is_con() && r2->is_con()) { | ||||
| 1631 | julong r1_con = (julong)r1->get_con(); | ||||
| 1632 | julong shift = (julong)(r2->get_con()) & (julong)(BitsPerJavaLong - 1); // semantics of Java shifts | ||||
| 1633 | return TypeLong::make((r1_con << shift) | (r1_con >> (64 - shift))); | ||||
| 1634 | } | ||||
| 1635 | return TypeLong::LONG; | ||||
| 1636 | } | ||||
| 1637 | } | ||||
| 1638 | |||||
| 1639 | Node* RotateLeftNode::Ideal(PhaseGVN *phase, bool can_reshape) { | ||||
| 1640 | const Type* t1 = phase->type(in(1)); | ||||
| 1641 | const Type* t2 = phase->type(in(2)); | ||||
| 1642 | if (t2->isa_int() && t2->is_int()->is_con()) { | ||||
| 1643 | if (t1->isa_int()) { | ||||
| 1644 | int lshift = t2->is_int()->get_con() & 31; | ||||
| 1645 | return new RotateRightNode(in(1), phase->intcon(32 - (lshift & 31)), TypeInt::INT); | ||||
| 1646 | } else if (t1 != Type::TOP) { | ||||
| 1647 | assert(t1->isa_long(), "Type must be a long")do { if (!(t1->isa_long())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1647, "assert(" "t1->isa_long()" ") failed", "Type must be a long" ); ::breakpoint(); } } while (0); | ||||
| 1648 | int lshift = t2->is_int()->get_con() & 63; | ||||
| 1649 | return new RotateRightNode(in(1), phase->intcon(64 - (lshift & 63)), TypeLong::LONG); | ||||
| 1650 | } | ||||
| 1651 | } | ||||
| 1652 | return NULL__null; | ||||
| 1653 | } | ||||
| 1654 | |||||
| 1655 | Node* RotateRightNode::Identity(PhaseGVN* phase) { | ||||
| 1656 | const Type* t1 = phase->type(in(1)); | ||||
| 1657 | if (t1 == Type::TOP) { | ||||
| 1658 | return this; | ||||
| 1659 | } | ||||
| 1660 | int count = 0; | ||||
| 1661 | assert(t1->isa_int() || t1->isa_long(), "Unexpected type")do { if (!(t1->isa_int() || t1->isa_long())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1661, "assert(" "t1->isa_int() || t1->isa_long()" ") failed" , "Unexpected type"); ::breakpoint(); } } while (0); | ||||
| 1662 | int mask = (t1->isa_int() ? BitsPerJavaInteger : BitsPerJavaLong) - 1; | ||||
| 1663 | if (const_shift_count(phase, this, &count) && (count & mask) == 0) { | ||||
| 1664 | // Rotate by a multiple of 32/64 does nothing | ||||
| 1665 | return in(1); | ||||
| 1666 | } | ||||
| 1667 | return this; | ||||
| 1668 | } | ||||
| 1669 | |||||
| 1670 | const Type* RotateRightNode::Value(PhaseGVN* phase) const { | ||||
| 1671 | const Type* t1 = phase->type(in(1)); | ||||
| 1672 | const Type* t2 = phase->type(in(2)); | ||||
| 1673 | // Either input is TOP ==> the result is TOP | ||||
| 1674 | if (t1 == Type::TOP || t2 == Type::TOP) { | ||||
| 1675 | return Type::TOP; | ||||
| 1676 | } | ||||
| 1677 | |||||
| 1678 | if (t1->isa_int()) { | ||||
| 1679 | const TypeInt* r1 = t1->is_int(); | ||||
| 1680 | const TypeInt* r2 = t2->is_int(); | ||||
| 1681 | |||||
| 1682 | // Left input is ZERO ==> the result is ZERO. | ||||
| 1683 | if (r1 == TypeInt::ZERO) { | ||||
| 1684 | return TypeInt::ZERO; | ||||
| 1685 | } | ||||
| 1686 | // Rotate by zero does nothing | ||||
| 1687 | if (r2 == TypeInt::ZERO) { | ||||
| 1688 | return r1; | ||||
| 1689 | } | ||||
| 1690 | if (r1->is_con() && r2->is_con()) { | ||||
| 1691 | juint r1_con = (juint)r1->get_con(); | ||||
| 1692 | juint shift = (juint)(r2->get_con()) & (juint)(BitsPerJavaInteger - 1); // semantics of Java shifts | ||||
| 1693 | return TypeInt::make((r1_con >> shift) | (r1_con << (32 - shift))); | ||||
| 1694 | } | ||||
| 1695 | return TypeInt::INT; | ||||
| 1696 | } else { | ||||
| 1697 | assert(t1->isa_long(), "Type must be a long")do { if (!(t1->isa_long())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/mulnode.cpp" , 1697, "assert(" "t1->isa_long()" ") failed", "Type must be a long" ); ::breakpoint(); } } while (0); | ||||
| 1698 | const TypeLong* r1 = t1->is_long(); | ||||
| 1699 | const TypeInt* r2 = t2->is_int(); | ||||
| 1700 | // Left input is ZERO ==> the result is ZERO. | ||||
| 1701 | if (r1 == TypeLong::ZERO) { | ||||
| 1702 | return TypeLong::ZERO; | ||||
| 1703 | } | ||||
| 1704 | // Rotate by zero does nothing | ||||
| 1705 | if (r2 == TypeInt::ZERO) { | ||||
| 1706 | return r1; | ||||
| 1707 | } | ||||
| 1708 | if (r1->is_con() && r2->is_con()) { | ||||
| 1709 | julong r1_con = (julong)r1->get_con(); | ||||
| 1710 | julong shift = (julong)(r2->get_con()) & (julong)(BitsPerJavaLong - 1); // semantics of Java shifts | ||||
| 1711 | return TypeLong::make((r1_con >> shift) | (r1_con << (64 - shift))); | ||||
| 1712 | } | ||||
| 1713 | return TypeLong::LONG; | ||||
| 1714 | } | ||||
| 1715 | } | ||||
| 1716 | |||||
| 1717 | // Helper method to transform: | ||||
| 1718 | // patterns similar to (v << 2) & 3 to 0 | ||||
| 1719 | // and | ||||
| 1720 | // patterns similar to (v1 + (v2 << 2)) & 3 transformed to v1 & 3 | ||||
| 1721 | bool MulNode::AndIL_shift_and_mask(PhaseGVN* phase, Node* mask, Node* shift, BasicType bt) { | ||||
| 1722 | if (mask == NULL__null || shift == NULL__null) { | ||||
| 1723 | return false; | ||||
| 1724 | } | ||||
| 1725 | const TypeInteger* mask_t = phase->type(mask)->isa_integer(bt); | ||||
| 1726 | const TypeInteger* shift_t = phase->type(shift)->isa_integer(bt); | ||||
| 1727 | if (mask_t == NULL__null || shift_t == NULL__null) { | ||||
| 1728 | return false; | ||||
| 1729 | } | ||||
| 1730 | if (bt == T_LONG && shift != NULL__null && shift->Opcode() == Op_ConvI2L) { | ||||
| 1731 | bt = T_INT; | ||||
| 1732 | shift = shift->in(1); | ||||
| 1733 | if (shift == NULL__null) { | ||||
| 1734 | return false; | ||||
| 1735 | } | ||||
| 1736 | } | ||||
| 1737 | if (shift->Opcode() != Op_LShift(bt)) { | ||||
| 1738 | return false; | ||||
| 1739 | } | ||||
| 1740 | Node* shift2 = shift->in(2); | ||||
| 1741 | if (shift2 == NULL__null) { | ||||
| 1742 | return false; | ||||
| 1743 | } | ||||
| 1744 | const Type* shift2_t = phase->type(shift2); | ||||
| 1745 | if (!shift2_t->isa_int() || !shift2_t->is_int()->is_con()) { | ||||
| 1746 | return false; | ||||
| 1747 | } | ||||
| 1748 | |||||
| 1749 | jint shift_con = shift2_t->is_int()->get_con() & ((bt == T_INT ? BitsPerJavaInteger : BitsPerJavaLong) - 1); | ||||
| 1750 | if ((((jlong)1) << shift_con) > mask_t->hi_as_long() && mask_t->lo_as_long() >= 0) { | ||||
| 1751 | return true; | ||||
| 1752 | } | ||||
| 1753 | |||||
| 1754 | return false; | ||||
| 1755 | } | ||||
| 1756 | |||||
| 1757 | // Helper method to transform: | ||||
| 1758 | // patterns similar to (v1 + (v2 << 2)) & 3 to v1 & 3 | ||||
| 1759 | Node* MulNode::AndIL_add_shift_and_mask(PhaseGVN* phase, BasicType bt) { | ||||
| 1760 | Node* in1 = in(1); | ||||
| 1761 | Node* in2 = in(2); | ||||
| 1762 | if (in1 != NULL__null && in2 != NULL__null && in1->Opcode() == Op_Add(bt)) { | ||||
| 1763 | Node* add1 = in1->in(1); | ||||
| 1764 | Node* add2 = in1->in(2); | ||||
| 1765 | if (add1 != NULL__null && add2 != NULL__null) { | ||||
| 1766 | if (AndIL_shift_and_mask(phase, in2, add1, bt)) { | ||||
| 1767 | set_req_X(1, add2, phase); | ||||
| 1768 | return this; | ||||
| 1769 | } else if (AndIL_shift_and_mask(phase, in2, add2, bt)) { | ||||
| 1770 | set_req_X(1, add1, phase); | ||||
| 1771 | return this; | ||||
| 1772 | } | ||||
| 1773 | } | ||||
| 1774 | } | ||||
| 1775 | return NULL__null; | ||||
| 1776 | } |
| 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 | |
| 44 | class Dict; |
| 45 | class Type; |
| 46 | class TypeD; |
| 47 | class TypeF; |
| 48 | class TypeInteger; |
| 49 | class TypeInt; |
| 50 | class TypeLong; |
| 51 | class TypeNarrowPtr; |
| 52 | class TypeNarrowOop; |
| 53 | class TypeNarrowKlass; |
| 54 | class TypeAry; |
| 55 | class TypeTuple; |
| 56 | class TypeVect; |
| 57 | class TypeVectA; |
| 58 | class TypeVectS; |
| 59 | class TypeVectD; |
| 60 | class TypeVectX; |
| 61 | class TypeVectY; |
| 62 | class TypeVectZ; |
| 63 | class TypeVectMask; |
| 64 | class TypePtr; |
| 65 | class TypeRawPtr; |
| 66 | class TypeOopPtr; |
| 67 | class TypeInstPtr; |
| 68 | class TypeAryPtr; |
| 69 | class TypeKlassPtr; |
| 70 | class TypeInstKlassPtr; |
| 71 | class TypeAryKlassPtr; |
| 72 | class 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. |
| 79 | class Type { |
| 80 | friend class VMStructs; |
| 81 | |
| 82 | public: |
| 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 | |
| 142 | private: |
| 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 | |
| 179 | protected: |
| 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 | |
| 191 | public: |
| 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()); |
| 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 | |
| 485 | private: |
| 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. |
| 493 | class TypeF : public Type { |
| 494 | TypeF( float f ) : Type(FloatCon), _f(f) {}; |
| 495 | public: |
| 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 |
| 500 | public: |
| 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. |
| 524 | class TypeD : public Type { |
| 525 | TypeD( double d ) : Type(DoubleCon), _d(d) {}; |
| 526 | public: |
| 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 |
| 531 | public: |
| 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 | |
| 553 | class TypeInteger : public Type { |
| 554 | protected: |
| 555 | TypeInteger(TYPES t) : Type(t) {} |
| 556 | |
| 557 | public: |
| 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. |
| 576 | class TypeInt : public TypeInteger { |
| 577 | TypeInt( jint lo, jint hi, int w ); |
| 578 | protected: |
| 579 | virtual const Type *filter_helper(const Type *kills, bool include_speculative) const; |
| 580 | |
| 581 | public: |
| 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. |
| 643 | class TypeLong : public TypeInteger { |
| 644 | TypeLong( jlong lo, jlong hi, int w ); |
| 645 | protected: |
| 646 | // Do not kill _widen bits. |
| 647 | virtual const Type *filter_helper(const Type *kills, bool include_speculative) const; |
| 648 | public: |
| 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 |
| 654 | public: |
| 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. |
| 703 | class 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 | |
| 709 | public: |
| 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 |
| 756 | class TypeAry : public Type { |
| 757 | TypeAry(const Type* elem, const TypeInt* size, bool stable) : Type(Array), |
| 758 | _elem(elem), _size(size), _stable(stable) {} |
| 759 | public: |
| 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 | |
| 765 | private: |
| 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 | |
| 771 | public: |
| 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 |
| 790 | class TypeVect : public Type { |
| 791 | const Type* _elem; // Vector's element type |
| 792 | const uint _length; // Elements in vector (power of 2) |
| 793 | |
| 794 | protected: |
| 795 | TypeVect(TYPES t, const Type* elem, uint length) : Type(t), |
| 796 | _elem(elem), _length(length) {} |
| 797 | |
| 798 | public: |
| 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 | |
| 841 | class TypeVectA : public TypeVect { |
| 842 | friend class TypeVect; |
| 843 | TypeVectA(const Type* elem, uint length) : TypeVect(VectorA, elem, length) {} |
| 844 | }; |
| 845 | |
| 846 | class TypeVectS : public TypeVect { |
| 847 | friend class TypeVect; |
| 848 | TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {} |
| 849 | }; |
| 850 | |
| 851 | class TypeVectD : public TypeVect { |
| 852 | friend class TypeVect; |
| 853 | TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {} |
| 854 | }; |
| 855 | |
| 856 | class TypeVectX : public TypeVect { |
| 857 | friend class TypeVect; |
| 858 | TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {} |
| 859 | }; |
| 860 | |
| 861 | class TypeVectY : public TypeVect { |
| 862 | friend class TypeVect; |
| 863 | TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {} |
| 864 | }; |
| 865 | |
| 866 | class TypeVectZ : public TypeVect { |
| 867 | friend class TypeVect; |
| 868 | TypeVectZ(const Type* elem, uint length) : TypeVect(VectorZ, elem, length) {} |
| 869 | }; |
| 870 | |
| 871 | class TypeVectMask : public TypeVect { |
| 872 | public: |
| 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. |
| 886 | class TypePtr : public Type { |
| 887 | friend class TypeNarrowPtr; |
| 888 | public: |
| 889 | enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR }; |
| 890 | protected: |
| 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 | |
| 951 | public: |
| 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. |
| 1020 | class TypeRawPtr : public TypePtr { |
| 1021 | protected: |
| 1022 | TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){} |
| 1023 | public: |
| 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. |
| 1051 | class TypeOopPtr : public TypePtr { |
| 1052 | protected: |
| 1053 | TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, |
| 1054 | const TypePtr* speculative, int inline_depth); |
| 1055 | public: |
| 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 | }; |
| 1063 | protected: |
| 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 | |
| 1088 | public: |
| 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). |
| 1165 | class 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 |
| 1249 | class 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 | |
| 1281 | public: |
| 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 |
| 1360 | class TypeMetadataPtr : public TypePtr { |
| 1361 | protected: |
| 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; |
| 1365 | public: |
| 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 | |
| 1370 | private: |
| 1371 | ciMetadata* _metadata; |
| 1372 | |
| 1373 | public: |
| 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 |
| 1400 | class TypeKlassPtr : public TypePtr { |
| 1401 | protected: |
| 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 | |
| 1406 | public: |
| 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 | |
| 1412 | protected: |
| 1413 | |
| 1414 | ciKlass* _klass; |
| 1415 | |
| 1416 | public: |
| 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 |
| 1447 | class 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 | |
| 1455 | public: |
| 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 |
| 1484 | class 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 | |
| 1493 | public: |
| 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 | |
| 1530 | class TypeNarrowPtr : public Type { |
| 1531 | protected: |
| 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; |
| 1547 | public: |
| 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. |
| 1579 | class TypeNarrowOop : public TypeNarrowPtr { |
| 1580 | protected: |
| 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 | |
| 1600 | public: |
| 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. |
| 1623 | class TypeNarrowKlass : public TypeNarrowPtr { |
| 1624 | protected: |
| 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 | |
| 1644 | public: |
| 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 |
| 1657 | class 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 | |
| 1667 | public: |
| 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-------------------------------------- |
| 1698 | inline 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 | |
| 1706 | inline 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 | |
| 1714 | inline 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 | |
| 1719 | inline 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 | |
| 1724 | inline 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 | |
| 1729 | inline 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 | |
| 1733 | inline 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 | |
| 1738 | inline const TypeInt *Type::isa_int() const { |
| 1739 | return ( _base == Int ? (TypeInt*)this : NULL__null); |
| 1740 | } |
| 1741 | |
| 1742 | inline 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 | |
| 1747 | inline const TypeLong *Type::isa_long() const { |
| 1748 | return ( _base == Long ? (TypeLong*)this : NULL__null); |
| 1749 | } |
| 1750 | |
| 1751 | inline const TypeF *Type::isa_float() const { |
| 1752 | return ((_base == FloatTop || |
| 1753 | _base == FloatCon || |
| 1754 | _base == FloatBot) ? (TypeF*)this : NULL__null); |
| 1755 | } |
| 1756 | |
| 1757 | inline 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 | |
| 1762 | inline const TypeF *Type::isa_float_constant() const { |
| 1763 | return ( _base == FloatCon ? (TypeF*)this : NULL__null); |
| 1764 | } |
| 1765 | |
| 1766 | inline const TypeD *Type::isa_double() const { |
| 1767 | return ((_base == DoubleTop || |
| 1768 | _base == DoubleCon || |
| 1769 | _base == DoubleBot) ? (TypeD*)this : NULL__null); |
| 1770 | } |
| 1771 | |
| 1772 | inline 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 | |
| 1777 | inline const TypeD *Type::isa_double_constant() const { |
| 1778 | return ( _base == DoubleCon ? (TypeD*)this : NULL__null); |
| 1779 | } |
| 1780 | |
| 1781 | inline 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 | |
| 1786 | inline 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 | |
| 1791 | inline const TypeAry *Type::isa_ary() const { |
| 1792 | return ((_base == Array) ? (TypeAry*)this : NULL__null); |
| 1793 | } |
| 1794 | |
| 1795 | inline 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 | |
| 1800 | inline const TypeVectMask *Type::isa_vectmask() const { |
| 1801 | return (_base == VectorMask) ? (TypeVectMask*)this : NULL__null; |
| 1802 | } |
| 1803 | |
| 1804 | inline 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 | |
| 1809 | inline const TypeVect *Type::isa_vect() const { |
| 1810 | return (_base >= VectorMask && _base <= VectorZ) ? (TypeVect*)this : NULL__null; |
| 1811 | } |
| 1812 | |
| 1813 | inline 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 | |
| 1819 | inline 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 | |
| 1824 | inline 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 | |
| 1830 | inline 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 | |
| 1835 | inline const TypeRawPtr *Type::isa_rawptr() const { |
| 1836 | return (_base == RawPtr) ? (TypeRawPtr*)this : NULL__null; |
| 1837 | } |
| 1838 | |
| 1839 | inline 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 | |
| 1844 | inline const TypeInstPtr *Type::isa_instptr() const { |
| 1845 | return (_base == InstPtr) ? (TypeInstPtr*)this : NULL__null; |
| 1846 | } |
| 1847 | |
| 1848 | inline 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 | |
| 1853 | inline const TypeAryPtr *Type::isa_aryptr() const { |
| 1854 | return (_base == AryPtr) ? (TypeAryPtr*)this : NULL__null; |
| 1855 | } |
| 1856 | |
| 1857 | inline 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 | |
| 1862 | inline 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 | |
| 1868 | inline 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 | |
| 1873 | inline 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 | |
| 1878 | inline const TypeNarrowKlass *Type::isa_narrowklass() const { |
| 1879 | return (_base == NarrowKlass) ? (TypeNarrowKlass*)this : NULL__null; |
| 1880 | } |
| 1881 | |
| 1882 | inline 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 | |
| 1888 | inline const TypeMetadataPtr *Type::isa_metadataptr() const { |
| 1889 | return (_base == MetadataPtr) ? (TypeMetadataPtr*)this : NULL__null; |
| 1890 | } |
| 1891 | |
| 1892 | inline const TypeKlassPtr *Type::isa_klassptr() const { |
| 1893 | return (_base >= KlassPtr && _base <= AryKlassPtr ) ? (TypeKlassPtr*)this : NULL__null; |
| 1894 | } |
| 1895 | |
| 1896 | inline 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 | |
| 1901 | inline const TypeInstKlassPtr *Type::isa_instklassptr() const { |
| 1902 | return (_base == InstKlassPtr) ? (TypeInstKlassPtr*)this : NULL__null; |
| 1903 | } |
| 1904 | |
| 1905 | inline 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 | |
| 1910 | inline const TypeAryKlassPtr *Type::isa_aryklassptr() const { |
| 1911 | return (_base == AryKlassPtr) ? (TypeAryKlassPtr*)this : NULL__null; |
| 1912 | } |
| 1913 | |
| 1914 | inline 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 | |
| 1919 | inline 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 | |
| 1925 | inline const TypeOopPtr* Type::make_oopptr() const { |
| 1926 | return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->isa_oopptr() : isa_oopptr(); |
| 1927 | } |
| 1928 | |
| 1929 | inline const TypeNarrowOop* Type::make_narrowoop() const { |
| 1930 | return (_base == NarrowOop) ? is_narrowoop() : |
| 1931 | (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL__null); |
| 1932 | } |
| 1933 | |
| 1934 | inline const TypeNarrowKlass* Type::make_narrowklass() const { |
| 1935 | return (_base == NarrowKlass) ? is_narrowklass() : |
| 1936 | (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : NULL__null); |
| 1937 | } |
| 1938 | |
| 1939 | inline bool Type::is_floatingpoint() const { |
| 1940 | if( (_base == FloatCon) || (_base == FloatBot) || |
| 1941 | (_base == DoubleCon) || (_base == DoubleBot) ) |
| 1942 | return true; |
| 1943 | return false; |
| 1944 | } |
| 1945 | |
| 1946 | inline 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 |