| File: | jdk/src/hotspot/share/opto/type.cpp |
| Warning: | line 4354, column 12 Although the value stored to 'elem_ptr' is used in the enclosing expression, the value is never actually read from 'elem_ptr' |
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 "ci/ciMethodData.hpp" |
| 27 | #include "ci/ciTypeFlow.hpp" |
| 28 | #include "classfile/javaClasses.hpp" |
| 29 | #include "classfile/symbolTable.hpp" |
| 30 | #include "compiler/compileLog.hpp" |
| 31 | #include "libadt/dict.hpp" |
| 32 | #include "memory/oopFactory.hpp" |
| 33 | #include "memory/resourceArea.hpp" |
| 34 | #include "oops/instanceKlass.hpp" |
| 35 | #include "oops/instanceMirrorKlass.hpp" |
| 36 | #include "oops/objArrayKlass.hpp" |
| 37 | #include "oops/typeArrayKlass.hpp" |
| 38 | #include "opto/matcher.hpp" |
| 39 | #include "opto/node.hpp" |
| 40 | #include "opto/opcodes.hpp" |
| 41 | #include "opto/type.hpp" |
| 42 | #include "utilities/powerOfTwo.hpp" |
| 43 | #include "utilities/stringUtils.hpp" |
| 44 | |
| 45 | // Portions of code courtesy of Clifford Click |
| 46 | |
| 47 | // Optimization - Graph Style |
| 48 | |
| 49 | // Dictionary of types shared among compilations. |
| 50 | Dict* Type::_shared_type_dict = NULL__null; |
| 51 | |
| 52 | // Array which maps compiler types to Basic Types |
| 53 | const Type::TypeInfo Type::_type_info[Type::lastype] = { |
| 54 | { Bad, T_ILLEGAL, "bad", false, Node::NotAMachineReg, relocInfo::none }, // Bad |
| 55 | { Control, T_ILLEGAL, "control", false, 0, relocInfo::none }, // Control |
| 56 | { Bottom, T_VOID, "top", false, 0, relocInfo::none }, // Top |
| 57 | { Bad, T_INT, "int:", false, Op_RegI, relocInfo::none }, // Int |
| 58 | { Bad, T_LONG, "long:", false, Op_RegL, relocInfo::none }, // Long |
| 59 | { Half, T_VOID, "half", false, 0, relocInfo::none }, // Half |
| 60 | { Bad, T_NARROWOOP, "narrowoop:", false, Op_RegN, relocInfo::none }, // NarrowOop |
| 61 | { Bad, T_NARROWKLASS,"narrowklass:", false, Op_RegN, relocInfo::none }, // NarrowKlass |
| 62 | { Bad, T_ILLEGAL, "tuple:", false, Node::NotAMachineReg, relocInfo::none }, // Tuple |
| 63 | { Bad, T_ARRAY, "array:", false, Node::NotAMachineReg, relocInfo::none }, // Array |
| 64 | |
| 65 | #if defined(PPC64) |
| 66 | { Bad, T_ILLEGAL, "vectormask:", false, Op_RegVectMask, relocInfo::none }, // VectorMask. |
| 67 | { Bad, T_ILLEGAL, "vectora:", false, Op_VecA, relocInfo::none }, // VectorA. |
| 68 | { Bad, T_ILLEGAL, "vectors:", false, 0, relocInfo::none }, // VectorS |
| 69 | { Bad, T_ILLEGAL, "vectord:", false, Op_RegL, relocInfo::none }, // VectorD |
| 70 | { Bad, T_ILLEGAL, "vectorx:", false, Op_VecX, relocInfo::none }, // VectorX |
| 71 | { Bad, T_ILLEGAL, "vectory:", false, 0, relocInfo::none }, // VectorY |
| 72 | { Bad, T_ILLEGAL, "vectorz:", false, 0, relocInfo::none }, // VectorZ |
| 73 | #elif defined(S390) |
| 74 | { Bad, T_ILLEGAL, "vectormask:", false, Op_RegVectMask, relocInfo::none }, // VectorMask. |
| 75 | { Bad, T_ILLEGAL, "vectora:", false, Op_VecA, relocInfo::none }, // VectorA. |
| 76 | { Bad, T_ILLEGAL, "vectors:", false, 0, relocInfo::none }, // VectorS |
| 77 | { Bad, T_ILLEGAL, "vectord:", false, Op_RegL, relocInfo::none }, // VectorD |
| 78 | { Bad, T_ILLEGAL, "vectorx:", false, 0, relocInfo::none }, // VectorX |
| 79 | { Bad, T_ILLEGAL, "vectory:", false, 0, relocInfo::none }, // VectorY |
| 80 | { Bad, T_ILLEGAL, "vectorz:", false, 0, relocInfo::none }, // VectorZ |
| 81 | #else // all other |
| 82 | { Bad, T_ILLEGAL, "vectormask:", false, Op_RegVectMask, relocInfo::none }, // VectorMask. |
| 83 | { Bad, T_ILLEGAL, "vectora:", false, Op_VecA, relocInfo::none }, // VectorA. |
| 84 | { Bad, T_ILLEGAL, "vectors:", false, Op_VecS, relocInfo::none }, // VectorS |
| 85 | { Bad, T_ILLEGAL, "vectord:", false, Op_VecD, relocInfo::none }, // VectorD |
| 86 | { Bad, T_ILLEGAL, "vectorx:", false, Op_VecX, relocInfo::none }, // VectorX |
| 87 | { Bad, T_ILLEGAL, "vectory:", false, Op_VecY, relocInfo::none }, // VectorY |
| 88 | { Bad, T_ILLEGAL, "vectorz:", false, Op_VecZ, relocInfo::none }, // VectorZ |
| 89 | #endif |
| 90 | { Bad, T_ADDRESS, "anyptr:", false, Op_RegP, relocInfo::none }, // AnyPtr |
| 91 | { Bad, T_ADDRESS, "rawptr:", false, Op_RegP, relocInfo::none }, // RawPtr |
| 92 | { Bad, T_OBJECT, "oop:", true, Op_RegP, relocInfo::oop_type }, // OopPtr |
| 93 | { Bad, T_OBJECT, "inst:", true, Op_RegP, relocInfo::oop_type }, // InstPtr |
| 94 | { Bad, T_OBJECT, "ary:", true, Op_RegP, relocInfo::oop_type }, // AryPtr |
| 95 | { Bad, T_METADATA, "metadata:", false, Op_RegP, relocInfo::metadata_type }, // MetadataPtr |
| 96 | { Bad, T_METADATA, "klass:", false, Op_RegP, relocInfo::metadata_type }, // KlassPtr |
| 97 | { Bad, T_METADATA, "instklass:", false, Op_RegP, relocInfo::metadata_type }, // InstKlassPtr |
| 98 | { Bad, T_METADATA, "aryklass:", false, Op_RegP, relocInfo::metadata_type }, // AryKlassPtr |
| 99 | { Bad, T_OBJECT, "func", false, 0, relocInfo::none }, // Function |
| 100 | { Abio, T_ILLEGAL, "abIO", false, 0, relocInfo::none }, // Abio |
| 101 | { Return_Address, T_ADDRESS, "return_address",false, Op_RegP, relocInfo::none }, // Return_Address |
| 102 | { Memory, T_ILLEGAL, "memory", false, 0, relocInfo::none }, // Memory |
| 103 | { FloatBot, T_FLOAT, "float_top", false, Op_RegF, relocInfo::none }, // FloatTop |
| 104 | { FloatCon, T_FLOAT, "ftcon:", false, Op_RegF, relocInfo::none }, // FloatCon |
| 105 | { FloatTop, T_FLOAT, "float", false, Op_RegF, relocInfo::none }, // FloatBot |
| 106 | { DoubleBot, T_DOUBLE, "double_top", false, Op_RegD, relocInfo::none }, // DoubleTop |
| 107 | { DoubleCon, T_DOUBLE, "dblcon:", false, Op_RegD, relocInfo::none }, // DoubleCon |
| 108 | { DoubleTop, T_DOUBLE, "double", false, Op_RegD, relocInfo::none }, // DoubleBot |
| 109 | { Top, T_ILLEGAL, "bottom", false, 0, relocInfo::none } // Bottom |
| 110 | }; |
| 111 | |
| 112 | // Map ideal registers (machine types) to ideal types |
| 113 | const Type *Type::mreg2type[_last_machine_leaf]; |
| 114 | |
| 115 | // Map basic types to canonical Type* pointers. |
| 116 | const Type* Type:: _const_basic_type[T_CONFLICT+1]; |
| 117 | |
| 118 | // Map basic types to constant-zero Types. |
| 119 | const Type* Type:: _zero_type[T_CONFLICT+1]; |
| 120 | |
| 121 | // Map basic types to array-body alias types. |
| 122 | const TypeAryPtr* TypeAryPtr::_array_body_type[T_CONFLICT+1]; |
| 123 | |
| 124 | //============================================================================= |
| 125 | // Convenience common pre-built types. |
| 126 | const Type *Type::ABIO; // State-of-machine only |
| 127 | const Type *Type::BOTTOM; // All values |
| 128 | const Type *Type::CONTROL; // Control only |
| 129 | const Type *Type::DOUBLE; // All doubles |
| 130 | const Type *Type::FLOAT; // All floats |
| 131 | const Type *Type::HALF; // Placeholder half of doublewide type |
| 132 | const Type *Type::MEMORY; // Abstract store only |
| 133 | const Type *Type::RETURN_ADDRESS; |
| 134 | const Type *Type::TOP; // No values in set |
| 135 | |
| 136 | //------------------------------get_const_type--------------------------- |
| 137 | const Type* Type::get_const_type(ciType* type) { |
| 138 | if (type == NULL__null) { |
| 139 | return NULL__null; |
| 140 | } else if (type->is_primitive_type()) { |
| 141 | return get_const_basic_type(type->basic_type()); |
| 142 | } else { |
| 143 | return TypeOopPtr::make_from_klass(type->as_klass()); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | //---------------------------array_element_basic_type--------------------------------- |
| 148 | // Mapping to the array element's basic type. |
| 149 | BasicType Type::array_element_basic_type() const { |
| 150 | BasicType bt = basic_type(); |
| 151 | if (bt == T_INT) { |
| 152 | if (this == TypeInt::INT) return T_INT; |
| 153 | if (this == TypeInt::CHAR) return T_CHAR; |
| 154 | if (this == TypeInt::BYTE) return T_BYTE; |
| 155 | if (this == TypeInt::BOOL) return T_BOOLEAN; |
| 156 | if (this == TypeInt::SHORT) return T_SHORT; |
| 157 | return T_VOID; |
| 158 | } |
| 159 | return bt; |
| 160 | } |
| 161 | |
| 162 | // For two instance arrays of same dimension, return the base element types. |
| 163 | // Otherwise or if the arrays have different dimensions, return NULL. |
| 164 | void Type::get_arrays_base_elements(const Type *a1, const Type *a2, |
| 165 | const TypeInstPtr **e1, const TypeInstPtr **e2) { |
| 166 | |
| 167 | if (e1) *e1 = NULL__null; |
| 168 | if (e2) *e2 = NULL__null; |
| 169 | const TypeAryPtr* a1tap = (a1 == NULL__null) ? NULL__null : a1->isa_aryptr(); |
| 170 | const TypeAryPtr* a2tap = (a2 == NULL__null) ? NULL__null : a2->isa_aryptr(); |
| 171 | |
| 172 | if (a1tap != NULL__null && a2tap != NULL__null) { |
| 173 | // Handle multidimensional arrays |
| 174 | const TypePtr* a1tp = a1tap->elem()->make_ptr(); |
| 175 | const TypePtr* a2tp = a2tap->elem()->make_ptr(); |
| 176 | while (a1tp && a1tp->isa_aryptr() && a2tp && a2tp->isa_aryptr()) { |
| 177 | a1tap = a1tp->is_aryptr(); |
| 178 | a2tap = a2tp->is_aryptr(); |
| 179 | a1tp = a1tap->elem()->make_ptr(); |
| 180 | a2tp = a2tap->elem()->make_ptr(); |
| 181 | } |
| 182 | if (a1tp && a1tp->isa_instptr() && a2tp && a2tp->isa_instptr()) { |
| 183 | if (e1) *e1 = a1tp->is_instptr(); |
| 184 | if (e2) *e2 = a2tp->is_instptr(); |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | //---------------------------get_typeflow_type--------------------------------- |
| 190 | // Import a type produced by ciTypeFlow. |
| 191 | const Type* Type::get_typeflow_type(ciType* type) { |
| 192 | switch (type->basic_type()) { |
| 193 | |
| 194 | case ciTypeFlow::StateVector::T_BOTTOM: |
| 195 | assert(type == ciTypeFlow::StateVector::bottom_type(), "")do { if (!(type == ciTypeFlow::StateVector::bottom_type())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 195, "assert(" "type == ciTypeFlow::StateVector::bottom_type()" ") failed", ""); ::breakpoint(); } } while (0); |
| 196 | return Type::BOTTOM; |
| 197 | |
| 198 | case ciTypeFlow::StateVector::T_TOP: |
| 199 | assert(type == ciTypeFlow::StateVector::top_type(), "")do { if (!(type == ciTypeFlow::StateVector::top_type())) { (* g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 199, "assert(" "type == ciTypeFlow::StateVector::top_type()" ") failed", ""); ::breakpoint(); } } while (0); |
| 200 | return Type::TOP; |
| 201 | |
| 202 | case ciTypeFlow::StateVector::T_NULL: |
| 203 | assert(type == ciTypeFlow::StateVector::null_type(), "")do { if (!(type == ciTypeFlow::StateVector::null_type())) { ( *g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 203, "assert(" "type == ciTypeFlow::StateVector::null_type()" ") failed", ""); ::breakpoint(); } } while (0); |
| 204 | return TypePtr::NULL_PTR; |
| 205 | |
| 206 | case ciTypeFlow::StateVector::T_LONG2: |
| 207 | // The ciTypeFlow pass pushes a long, then the half. |
| 208 | // We do the same. |
| 209 | assert(type == ciTypeFlow::StateVector::long2_type(), "")do { if (!(type == ciTypeFlow::StateVector::long2_type())) { ( *g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 209, "assert(" "type == ciTypeFlow::StateVector::long2_type()" ") failed", ""); ::breakpoint(); } } while (0); |
| 210 | return TypeInt::TOP; |
| 211 | |
| 212 | case ciTypeFlow::StateVector::T_DOUBLE2: |
| 213 | // The ciTypeFlow pass pushes double, then the half. |
| 214 | // Our convention is the same. |
| 215 | assert(type == ciTypeFlow::StateVector::double2_type(), "")do { if (!(type == ciTypeFlow::StateVector::double2_type())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 215, "assert(" "type == ciTypeFlow::StateVector::double2_type()" ") failed", ""); ::breakpoint(); } } while (0); |
| 216 | return Type::TOP; |
| 217 | |
| 218 | case T_ADDRESS: |
| 219 | assert(type->is_return_address(), "")do { if (!(type->is_return_address())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 219, "assert(" "type->is_return_address()" ") failed", "" ); ::breakpoint(); } } while (0); |
| 220 | return TypeRawPtr::make((address)(intptr_t)type->as_return_address()->bci()); |
| 221 | |
| 222 | default: |
| 223 | // make sure we did not mix up the cases: |
| 224 | assert(type != ciTypeFlow::StateVector::bottom_type(), "")do { if (!(type != ciTypeFlow::StateVector::bottom_type())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 224, "assert(" "type != ciTypeFlow::StateVector::bottom_type()" ") failed", ""); ::breakpoint(); } } while (0); |
| 225 | assert(type != ciTypeFlow::StateVector::top_type(), "")do { if (!(type != ciTypeFlow::StateVector::top_type())) { (* g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 225, "assert(" "type != ciTypeFlow::StateVector::top_type()" ") failed", ""); ::breakpoint(); } } while (0); |
| 226 | assert(type != ciTypeFlow::StateVector::null_type(), "")do { if (!(type != ciTypeFlow::StateVector::null_type())) { ( *g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 226, "assert(" "type != ciTypeFlow::StateVector::null_type()" ") failed", ""); ::breakpoint(); } } while (0); |
| 227 | assert(type != ciTypeFlow::StateVector::long2_type(), "")do { if (!(type != ciTypeFlow::StateVector::long2_type())) { ( *g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 227, "assert(" "type != ciTypeFlow::StateVector::long2_type()" ") failed", ""); ::breakpoint(); } } while (0); |
| 228 | assert(type != ciTypeFlow::StateVector::double2_type(), "")do { if (!(type != ciTypeFlow::StateVector::double2_type())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 228, "assert(" "type != ciTypeFlow::StateVector::double2_type()" ") failed", ""); ::breakpoint(); } } while (0); |
| 229 | assert(!type->is_return_address(), "")do { if (!(!type->is_return_address())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 229, "assert(" "!type->is_return_address()" ") failed", "" ); ::breakpoint(); } } while (0); |
| 230 | |
| 231 | return Type::get_const_type(type); |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | |
| 236 | //-----------------------make_from_constant------------------------------------ |
| 237 | const Type* Type::make_from_constant(ciConstant constant, bool require_constant, |
| 238 | int stable_dimension, bool is_narrow_oop, |
| 239 | bool is_autobox_cache) { |
| 240 | switch (constant.basic_type()) { |
| 241 | case T_BOOLEAN: return TypeInt::make(constant.as_boolean()); |
| 242 | case T_CHAR: return TypeInt::make(constant.as_char()); |
| 243 | case T_BYTE: return TypeInt::make(constant.as_byte()); |
| 244 | case T_SHORT: return TypeInt::make(constant.as_short()); |
| 245 | case T_INT: return TypeInt::make(constant.as_int()); |
| 246 | case T_LONG: return TypeLong::make(constant.as_long()); |
| 247 | case T_FLOAT: return TypeF::make(constant.as_float()); |
| 248 | case T_DOUBLE: return TypeD::make(constant.as_double()); |
| 249 | case T_ARRAY: |
| 250 | case T_OBJECT: { |
| 251 | const Type* con_type = NULL__null; |
| 252 | ciObject* oop_constant = constant.as_object(); |
| 253 | if (oop_constant->is_null_object()) { |
| 254 | con_type = Type::get_zero_type(T_OBJECT); |
| 255 | } else { |
| 256 | guarantee(require_constant || oop_constant->should_be_constant(), "con_type must get computed")do { if (!(require_constant || oop_constant->should_be_constant ())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 256, "guarantee(" "require_constant || oop_constant->should_be_constant()" ") failed", "con_type must get computed"); ::breakpoint(); } } while (0); |
| 257 | con_type = TypeOopPtr::make_from_constant(oop_constant, require_constant); |
| 258 | if (Compile::current()->eliminate_boxing() && is_autobox_cache) { |
| 259 | con_type = con_type->is_aryptr()->cast_to_autobox_cache(); |
| 260 | } |
| 261 | if (stable_dimension > 0) { |
| 262 | assert(FoldStableValues, "sanity")do { if (!(FoldStableValues)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 262, "assert(" "FoldStableValues" ") failed", "sanity"); :: breakpoint(); } } while (0); |
| 263 | assert(!con_type->is_zero_type(), "default value for stable field")do { if (!(!con_type->is_zero_type())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 263, "assert(" "!con_type->is_zero_type()" ") failed", "default value for stable field" ); ::breakpoint(); } } while (0); |
| 264 | con_type = con_type->is_aryptr()->cast_to_stable(true, stable_dimension); |
| 265 | } |
| 266 | } |
| 267 | if (is_narrow_oop) { |
| 268 | con_type = con_type->make_narrowoop(); |
| 269 | } |
| 270 | return con_type; |
| 271 | } |
| 272 | case T_ILLEGAL: |
| 273 | // Invalid ciConstant returned due to OutOfMemoryError in the CI |
| 274 | assert(Compile::current()->env()->failing(), "otherwise should not see this")do { if (!(Compile::current()->env()->failing())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 274, "assert(" "Compile::current()->env()->failing()" ") failed", "otherwise should not see this"); ::breakpoint() ; } } while (0); |
| 275 | return NULL__null; |
| 276 | default: |
| 277 | // Fall through to failure |
| 278 | return NULL__null; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | static ciConstant check_mismatched_access(ciConstant con, BasicType loadbt, bool is_unsigned) { |
| 283 | BasicType conbt = con.basic_type(); |
| 284 | switch (conbt) { |
| 285 | case T_BOOLEAN: conbt = T_BYTE; break; |
| 286 | case T_ARRAY: conbt = T_OBJECT; break; |
| 287 | default: break; |
| 288 | } |
| 289 | switch (loadbt) { |
| 290 | case T_BOOLEAN: loadbt = T_BYTE; break; |
| 291 | case T_NARROWOOP: loadbt = T_OBJECT; break; |
| 292 | case T_ARRAY: loadbt = T_OBJECT; break; |
| 293 | case T_ADDRESS: loadbt = T_OBJECT; break; |
| 294 | default: break; |
| 295 | } |
| 296 | if (conbt == loadbt) { |
| 297 | if (is_unsigned && conbt == T_BYTE) { |
| 298 | // LoadB (T_BYTE) with a small mask (<=8-bit) is converted to LoadUB (T_BYTE). |
| 299 | return ciConstant(T_INT, con.as_int() & 0xFF); |
| 300 | } else { |
| 301 | return con; |
| 302 | } |
| 303 | } |
| 304 | if (conbt == T_SHORT && loadbt == T_CHAR) { |
| 305 | // LoadS (T_SHORT) with a small mask (<=16-bit) is converted to LoadUS (T_CHAR). |
| 306 | return ciConstant(T_INT, con.as_int() & 0xFFFF); |
| 307 | } |
| 308 | return ciConstant(); // T_ILLEGAL |
| 309 | } |
| 310 | |
| 311 | // Try to constant-fold a stable array element. |
| 312 | const Type* Type::make_constant_from_array_element(ciArray* array, int off, int stable_dimension, |
| 313 | BasicType loadbt, bool is_unsigned_load) { |
| 314 | // Decode the results of GraphKit::array_element_address. |
| 315 | ciConstant element_value = array->element_value_by_offset(off); |
| 316 | if (element_value.basic_type() == T_ILLEGAL) { |
| 317 | return NULL__null; // wrong offset |
| 318 | } |
| 319 | ciConstant con = check_mismatched_access(element_value, loadbt, is_unsigned_load); |
| 320 | |
| 321 | assert(con.basic_type() != T_ILLEGAL, "elembt=%s; loadbt=%s; unsigned=%d",do { if (!(con.basic_type() != T_ILLEGAL)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 322, "assert(" "con.basic_type() != T_ILLEGAL" ") failed", "elembt=%s; loadbt=%s; unsigned=%d" , type2name(element_value.basic_type()), type2name(loadbt), is_unsigned_load ); ::breakpoint(); } } while (0) |
| 322 | type2name(element_value.basic_type()), type2name(loadbt), is_unsigned_load)do { if (!(con.basic_type() != T_ILLEGAL)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 322, "assert(" "con.basic_type() != T_ILLEGAL" ") failed", "elembt=%s; loadbt=%s; unsigned=%d" , type2name(element_value.basic_type()), type2name(loadbt), is_unsigned_load ); ::breakpoint(); } } while (0); |
| 323 | |
| 324 | if (con.is_valid() && // not a mismatched access |
| 325 | !con.is_null_or_zero()) { // not a default value |
| 326 | bool is_narrow_oop = (loadbt == T_NARROWOOP); |
| 327 | return Type::make_from_constant(con, /*require_constant=*/true, stable_dimension, is_narrow_oop, /*is_autobox_cache=*/false); |
| 328 | } |
| 329 | return NULL__null; |
| 330 | } |
| 331 | |
| 332 | const Type* Type::make_constant_from_field(ciInstance* holder, int off, bool is_unsigned_load, BasicType loadbt) { |
| 333 | ciField* field; |
| 334 | ciType* type = holder->java_mirror_type(); |
| 335 | if (type != NULL__null && type->is_instance_klass() && off >= InstanceMirrorKlass::offset_of_static_fields()) { |
| 336 | // Static field |
| 337 | field = type->as_instance_klass()->get_field_by_offset(off, /*is_static=*/true); |
| 338 | } else { |
| 339 | // Instance field |
| 340 | field = holder->klass()->as_instance_klass()->get_field_by_offset(off, /*is_static=*/false); |
| 341 | } |
| 342 | if (field == NULL__null) { |
| 343 | return NULL__null; // Wrong offset |
| 344 | } |
| 345 | return Type::make_constant_from_field(field, holder, loadbt, is_unsigned_load); |
| 346 | } |
| 347 | |
| 348 | const Type* Type::make_constant_from_field(ciField* field, ciInstance* holder, |
| 349 | BasicType loadbt, bool is_unsigned_load) { |
| 350 | if (!field->is_constant()) { |
| 351 | return NULL__null; // Non-constant field |
| 352 | } |
| 353 | ciConstant field_value; |
| 354 | if (field->is_static()) { |
| 355 | // final static field |
| 356 | field_value = field->constant_value(); |
| 357 | } else if (holder != NULL__null) { |
| 358 | // final or stable non-static field |
| 359 | // Treat final non-static fields of trusted classes (classes in |
| 360 | // java.lang.invoke and sun.invoke packages and subpackages) as |
| 361 | // compile time constants. |
| 362 | field_value = field->constant_value_of(holder); |
| 363 | } |
| 364 | if (!field_value.is_valid()) { |
| 365 | return NULL__null; // Not a constant |
| 366 | } |
| 367 | |
| 368 | ciConstant con = check_mismatched_access(field_value, loadbt, is_unsigned_load); |
| 369 | |
| 370 | assert(con.is_valid(), "elembt=%s; loadbt=%s; unsigned=%d",do { if (!(con.is_valid())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 371, "assert(" "con.is_valid()" ") failed", "elembt=%s; loadbt=%s; unsigned=%d" , type2name(field_value.basic_type()), type2name(loadbt), is_unsigned_load ); ::breakpoint(); } } while (0) |
| 371 | type2name(field_value.basic_type()), type2name(loadbt), is_unsigned_load)do { if (!(con.is_valid())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 371, "assert(" "con.is_valid()" ") failed", "elembt=%s; loadbt=%s; unsigned=%d" , type2name(field_value.basic_type()), type2name(loadbt), is_unsigned_load ); ::breakpoint(); } } while (0); |
| 372 | |
| 373 | bool is_stable_array = FoldStableValues && field->is_stable() && field->type()->is_array_klass(); |
| 374 | int stable_dimension = (is_stable_array ? field->type()->as_array_klass()->dimension() : 0); |
| 375 | bool is_narrow_oop = (loadbt == T_NARROWOOP); |
| 376 | |
| 377 | const Type* con_type = make_from_constant(con, /*require_constant=*/ true, |
| 378 | stable_dimension, is_narrow_oop, |
| 379 | field->is_autobox_cache()); |
| 380 | if (con_type != NULL__null && field->is_call_site_target()) { |
| 381 | ciCallSite* call_site = holder->as_call_site(); |
| 382 | if (!call_site->is_fully_initialized_constant_call_site()) { |
| 383 | ciMethodHandle* target = con.as_object()->as_method_handle(); |
| 384 | Compile::current()->dependencies()->assert_call_site_target_value(call_site, target); |
| 385 | } |
| 386 | } |
| 387 | return con_type; |
| 388 | } |
| 389 | |
| 390 | //------------------------------make------------------------------------------- |
| 391 | // Create a simple Type, with default empty symbol sets. Then hashcons it |
| 392 | // and look for an existing copy in the type dictionary. |
| 393 | const Type *Type::make( enum TYPES t ) { |
| 394 | return (new Type(t))->hashcons(); |
| 395 | } |
| 396 | |
| 397 | //------------------------------cmp-------------------------------------------- |
| 398 | int Type::cmp( const Type *const t1, const Type *const t2 ) { |
| 399 | if( t1->_base != t2->_base ) |
| 400 | return 1; // Missed badly |
| 401 | assert(t1 != t2 || t1->eq(t2), "eq must be reflexive")do { if (!(t1 != t2 || t1->eq(t2))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 401, "assert(" "t1 != t2 || t1->eq(t2)" ") failed", "eq must be reflexive" ); ::breakpoint(); } } while (0); |
| 402 | return !t1->eq(t2); // Return ZERO if equal |
| 403 | } |
| 404 | |
| 405 | const Type* Type::maybe_remove_speculative(bool include_speculative) const { |
| 406 | if (!include_speculative) { |
| 407 | return remove_speculative(); |
| 408 | } |
| 409 | return this; |
| 410 | } |
| 411 | |
| 412 | //------------------------------hash------------------------------------------- |
| 413 | int Type::uhash( const Type *const t ) { |
| 414 | return t->hash(); |
| 415 | } |
| 416 | |
| 417 | #define SMALLINT((juint)3) ((juint)3) // a value too insignificant to consider widening |
| 418 | #define POSITIVE_INFINITE_F0x7f800000 0x7f800000 // hex representation for IEEE 754 single precision positive infinite |
| 419 | #define POSITIVE_INFINITE_D0x7ff0000000000000 0x7ff0000000000000 // hex representation for IEEE 754 double precision positive infinite |
| 420 | |
| 421 | //--------------------------Initialize_shared---------------------------------- |
| 422 | void Type::Initialize_shared(Compile* current) { |
| 423 | // This method does not need to be locked because the first system |
| 424 | // compilations (stub compilations) occur serially. If they are |
| 425 | // changed to proceed in parallel, then this section will need |
| 426 | // locking. |
| 427 | |
| 428 | Arena* save = current->type_arena(); |
| 429 | Arena* shared_type_arena = new (mtCompiler)Arena(mtCompiler); |
| 430 | |
| 431 | current->set_type_arena(shared_type_arena); |
| 432 | _shared_type_dict = |
| 433 | new (shared_type_arena) Dict( (CmpKey)Type::cmp, (Hash)Type::uhash, |
| 434 | shared_type_arena, 128 ); |
| 435 | current->set_type_dict(_shared_type_dict); |
| 436 | |
| 437 | // Make shared pre-built types. |
| 438 | CONTROL = make(Control); // Control only |
| 439 | TOP = make(Top); // No values in set |
| 440 | MEMORY = make(Memory); // Abstract store only |
| 441 | ABIO = make(Abio); // State-of-machine only |
| 442 | RETURN_ADDRESS=make(Return_Address); |
| 443 | FLOAT = make(FloatBot); // All floats |
| 444 | DOUBLE = make(DoubleBot); // All doubles |
| 445 | BOTTOM = make(Bottom); // Everything |
| 446 | HALF = make(Half); // Placeholder half of doublewide type |
| 447 | |
| 448 | TypeF::MAX = TypeF::make(max_jfloat); // Float MAX |
| 449 | TypeF::MIN = TypeF::make(min_jfloat); // Float MIN |
| 450 | TypeF::ZERO = TypeF::make(0.0); // Float 0 (positive zero) |
| 451 | TypeF::ONE = TypeF::make(1.0); // Float 1 |
| 452 | TypeF::POS_INF = TypeF::make(jfloat_cast(POSITIVE_INFINITE_F0x7f800000)); |
| 453 | TypeF::NEG_INF = TypeF::make(-jfloat_cast(POSITIVE_INFINITE_F0x7f800000)); |
| 454 | |
| 455 | TypeD::MAX = TypeD::make(max_jdouble); // Double MAX |
| 456 | TypeD::MIN = TypeD::make(min_jdouble); // Double MIN |
| 457 | TypeD::ZERO = TypeD::make(0.0); // Double 0 (positive zero) |
| 458 | TypeD::ONE = TypeD::make(1.0); // Double 1 |
| 459 | TypeD::POS_INF = TypeD::make(jdouble_cast(POSITIVE_INFINITE_D0x7ff0000000000000)); |
| 460 | TypeD::NEG_INF = TypeD::make(-jdouble_cast(POSITIVE_INFINITE_D0x7ff0000000000000)); |
| 461 | |
| 462 | TypeInt::MAX = TypeInt::make(max_jint); // Int MAX |
| 463 | TypeInt::MIN = TypeInt::make(min_jint); // Int MIN |
| 464 | TypeInt::MINUS_1 = TypeInt::make(-1); // -1 |
| 465 | TypeInt::ZERO = TypeInt::make( 0); // 0 |
| 466 | TypeInt::ONE = TypeInt::make( 1); // 1 |
| 467 | TypeInt::BOOL = TypeInt::make(0,1, WidenMin); // 0 or 1, FALSE or TRUE. |
| 468 | TypeInt::CC = TypeInt::make(-1, 1, WidenMin); // -1, 0 or 1, condition codes |
| 469 | TypeInt::CC_LT = TypeInt::make(-1,-1, WidenMin); // == TypeInt::MINUS_1 |
| 470 | TypeInt::CC_GT = TypeInt::make( 1, 1, WidenMin); // == TypeInt::ONE |
| 471 | TypeInt::CC_EQ = TypeInt::make( 0, 0, WidenMin); // == TypeInt::ZERO |
| 472 | TypeInt::CC_LE = TypeInt::make(-1, 0, WidenMin); |
| 473 | TypeInt::CC_GE = TypeInt::make( 0, 1, WidenMin); // == TypeInt::BOOL |
| 474 | TypeInt::BYTE = TypeInt::make(-128,127, WidenMin); // Bytes |
| 475 | TypeInt::UBYTE = TypeInt::make(0, 255, WidenMin); // Unsigned Bytes |
| 476 | TypeInt::CHAR = TypeInt::make(0,65535, WidenMin); // Java chars |
| 477 | TypeInt::SHORT = TypeInt::make(-32768,32767, WidenMin); // Java shorts |
| 478 | TypeInt::POS = TypeInt::make(0,max_jint, WidenMin); // Non-neg values |
| 479 | TypeInt::POS1 = TypeInt::make(1,max_jint, WidenMin); // Positive values |
| 480 | TypeInt::INT = TypeInt::make(min_jint,max_jint, WidenMax); // 32-bit integers |
| 481 | TypeInt::SYMINT = TypeInt::make(-max_jint,max_jint,WidenMin); // symmetric range |
| 482 | TypeInt::TYPE_DOMAIN = TypeInt::INT; |
| 483 | // CmpL is overloaded both as the bytecode computation returning |
| 484 | // a trinary (-1,0,+1) integer result AND as an efficient long |
| 485 | // compare returning optimizer ideal-type flags. |
| 486 | assert( TypeInt::CC_LT == TypeInt::MINUS_1, "types must match for CmpL to work" )do { if (!(TypeInt::CC_LT == TypeInt::MINUS_1)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 486, "assert(" "TypeInt::CC_LT == TypeInt::MINUS_1" ") failed" , "types must match for CmpL to work"); ::breakpoint(); } } while (0); |
| 487 | assert( TypeInt::CC_GT == TypeInt::ONE, "types must match for CmpL to work" )do { if (!(TypeInt::CC_GT == TypeInt::ONE)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 487, "assert(" "TypeInt::CC_GT == TypeInt::ONE" ") failed", "types must match for CmpL to work"); ::breakpoint(); } } while (0); |
| 488 | assert( TypeInt::CC_EQ == TypeInt::ZERO, "types must match for CmpL to work" )do { if (!(TypeInt::CC_EQ == TypeInt::ZERO)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 488, "assert(" "TypeInt::CC_EQ == TypeInt::ZERO" ") failed" , "types must match for CmpL to work"); ::breakpoint(); } } while (0); |
| 489 | assert( TypeInt::CC_GE == TypeInt::BOOL, "types must match for CmpL to work" )do { if (!(TypeInt::CC_GE == TypeInt::BOOL)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 489, "assert(" "TypeInt::CC_GE == TypeInt::BOOL" ") failed" , "types must match for CmpL to work"); ::breakpoint(); } } while (0); |
| 490 | assert( (juint)(TypeInt::CC->_hi - TypeInt::CC->_lo) <= SMALLINT, "CC is truly small")do { if (!((juint)(TypeInt::CC->_hi - TypeInt::CC->_lo) <= ((juint)3))) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 490, "assert(" "(juint)(TypeInt::CC->_hi - TypeInt::CC->_lo) <= ((juint)3)" ") failed", "CC is truly small"); ::breakpoint(); } } while ( 0); |
| 491 | |
| 492 | TypeLong::MAX = TypeLong::make(max_jlong); // Long MAX |
| 493 | TypeLong::MIN = TypeLong::make(min_jlong); // Long MIN |
| 494 | TypeLong::MINUS_1 = TypeLong::make(-1); // -1 |
| 495 | TypeLong::ZERO = TypeLong::make( 0); // 0 |
| 496 | TypeLong::ONE = TypeLong::make( 1); // 1 |
| 497 | TypeLong::POS = TypeLong::make(0,max_jlong, WidenMin); // Non-neg values |
| 498 | TypeLong::LONG = TypeLong::make(min_jlong,max_jlong,WidenMax); // 64-bit integers |
| 499 | TypeLong::INT = TypeLong::make((jlong)min_jint,(jlong)max_jint,WidenMin); |
| 500 | TypeLong::UINT = TypeLong::make(0,(jlong)max_juint,WidenMin); |
| 501 | TypeLong::TYPE_DOMAIN = TypeLong::LONG; |
| 502 | |
| 503 | const Type **fboth =(const Type**)shared_type_arena->AmallocWords(2*sizeof(Type*)); |
| 504 | fboth[0] = Type::CONTROL; |
| 505 | fboth[1] = Type::CONTROL; |
| 506 | TypeTuple::IFBOTH = TypeTuple::make( 2, fboth ); |
| 507 | |
| 508 | const Type **ffalse =(const Type**)shared_type_arena->AmallocWords(2*sizeof(Type*)); |
| 509 | ffalse[0] = Type::CONTROL; |
| 510 | ffalse[1] = Type::TOP; |
| 511 | TypeTuple::IFFALSE = TypeTuple::make( 2, ffalse ); |
| 512 | |
| 513 | const Type **fneither =(const Type**)shared_type_arena->AmallocWords(2*sizeof(Type*)); |
| 514 | fneither[0] = Type::TOP; |
| 515 | fneither[1] = Type::TOP; |
| 516 | TypeTuple::IFNEITHER = TypeTuple::make( 2, fneither ); |
| 517 | |
| 518 | const Type **ftrue =(const Type**)shared_type_arena->AmallocWords(2*sizeof(Type*)); |
| 519 | ftrue[0] = Type::TOP; |
| 520 | ftrue[1] = Type::CONTROL; |
| 521 | TypeTuple::IFTRUE = TypeTuple::make( 2, ftrue ); |
| 522 | |
| 523 | const Type **floop =(const Type**)shared_type_arena->AmallocWords(2*sizeof(Type*)); |
| 524 | floop[0] = Type::CONTROL; |
| 525 | floop[1] = TypeInt::INT; |
| 526 | TypeTuple::LOOPBODY = TypeTuple::make( 2, floop ); |
| 527 | |
| 528 | TypePtr::NULL_PTR= TypePtr::make(AnyPtr, TypePtr::Null, 0); |
| 529 | TypePtr::NOTNULL = TypePtr::make(AnyPtr, TypePtr::NotNull, OffsetBot); |
| 530 | TypePtr::BOTTOM = TypePtr::make(AnyPtr, TypePtr::BotPTR, OffsetBot); |
| 531 | |
| 532 | TypeRawPtr::BOTTOM = TypeRawPtr::make( TypePtr::BotPTR ); |
| 533 | TypeRawPtr::NOTNULL= TypeRawPtr::make( TypePtr::NotNull ); |
| 534 | |
| 535 | const Type **fmembar = TypeTuple::fields(0); |
| 536 | TypeTuple::MEMBAR = TypeTuple::make(TypeFunc::Parms+0, fmembar); |
| 537 | |
| 538 | const Type **fsc = (const Type**)shared_type_arena->AmallocWords(2*sizeof(Type*)); |
| 539 | fsc[0] = TypeInt::CC; |
| 540 | fsc[1] = Type::MEMORY; |
| 541 | TypeTuple::STORECONDITIONAL = TypeTuple::make(2, fsc); |
| 542 | |
| 543 | TypeInstPtr::NOTNULL = TypeInstPtr::make(TypePtr::NotNull, current->env()->Object_klass()); |
| 544 | TypeInstPtr::BOTTOM = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass()); |
| 545 | TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass()); |
| 546 | TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), |
| 547 | false, 0, oopDesc::mark_offset_in_bytes()); |
| 548 | TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), |
| 549 | false, 0, oopDesc::klass_offset_in_bytes()); |
| 550 | TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot); |
| 551 | |
| 552 | TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL__null, OffsetBot); |
| 553 | |
| 554 | TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR ); |
| 555 | TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM ); |
| 556 | |
| 557 | TypeNarrowKlass::NULL_PTR = TypeNarrowKlass::make( TypePtr::NULL_PTR ); |
| 558 | |
| 559 | mreg2type[Op_Node] = Type::BOTTOM; |
| 560 | mreg2type[Op_Set ] = 0; |
| 561 | mreg2type[Op_RegN] = TypeNarrowOop::BOTTOM; |
| 562 | mreg2type[Op_RegI] = TypeInt::INT; |
| 563 | mreg2type[Op_RegP] = TypePtr::BOTTOM; |
| 564 | mreg2type[Op_RegF] = Type::FLOAT; |
| 565 | mreg2type[Op_RegD] = Type::DOUBLE; |
| 566 | mreg2type[Op_RegL] = TypeLong::LONG; |
| 567 | mreg2type[Op_RegFlags] = TypeInt::CC; |
| 568 | |
| 569 | TypeAryPtr::RANGE = TypeAryPtr::make( TypePtr::BotPTR, TypeAry::make(Type::BOTTOM,TypeInt::POS), NULL__null /* current->env()->Object_klass() */, false, arrayOopDesc::length_offset_in_bytes()); |
| 570 | |
| 571 | TypeAryPtr::NARROWOOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeNarrowOop::BOTTOM, TypeInt::POS), NULL__null /*ciArrayKlass::make(o)*/, false, Type::OffsetBot); |
| 572 | |
| 573 | #ifdef _LP641 |
| 574 | if (UseCompressedOops) { |
| 575 | assert(TypeAryPtr::NARROWOOPS->is_ptr_to_narrowoop(), "array of narrow oops must be ptr to narrow oop")do { if (!(TypeAryPtr::NARROWOOPS->is_ptr_to_narrowoop())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 575, "assert(" "TypeAryPtr::NARROWOOPS->is_ptr_to_narrowoop()" ") failed", "array of narrow oops must be ptr to narrow oop" ); ::breakpoint(); } } while (0); |
| 576 | TypeAryPtr::OOPS = TypeAryPtr::NARROWOOPS; |
| 577 | } else |
| 578 | #endif |
| 579 | { |
| 580 | // There is no shared klass for Object[]. See note in TypeAryPtr::klass(). |
| 581 | TypeAryPtr::OOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInstPtr::BOTTOM,TypeInt::POS), NULL__null /*ciArrayKlass::make(o)*/, false, Type::OffsetBot); |
| 582 | } |
| 583 | TypeAryPtr::BYTES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::BYTE ,TypeInt::POS), ciTypeArrayKlass::make(T_BYTE), true, Type::OffsetBot); |
| 584 | TypeAryPtr::SHORTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::SHORT ,TypeInt::POS), ciTypeArrayKlass::make(T_SHORT), true, Type::OffsetBot); |
| 585 | TypeAryPtr::CHARS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::CHAR ,TypeInt::POS), ciTypeArrayKlass::make(T_CHAR), true, Type::OffsetBot); |
| 586 | TypeAryPtr::INTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::INT ,TypeInt::POS), ciTypeArrayKlass::make(T_INT), true, Type::OffsetBot); |
| 587 | TypeAryPtr::LONGS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeLong::LONG ,TypeInt::POS), ciTypeArrayKlass::make(T_LONG), true, Type::OffsetBot); |
| 588 | TypeAryPtr::FLOATS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::FLOAT ,TypeInt::POS), ciTypeArrayKlass::make(T_FLOAT), true, Type::OffsetBot); |
| 589 | TypeAryPtr::DOUBLES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::DOUBLE ,TypeInt::POS), ciTypeArrayKlass::make(T_DOUBLE), true, Type::OffsetBot); |
| 590 | |
| 591 | // Nobody should ask _array_body_type[T_NARROWOOP]. Use NULL as assert. |
| 592 | TypeAryPtr::_array_body_type[T_NARROWOOP] = NULL__null; |
| 593 | TypeAryPtr::_array_body_type[T_OBJECT] = TypeAryPtr::OOPS; |
| 594 | TypeAryPtr::_array_body_type[T_ARRAY] = TypeAryPtr::OOPS; // arrays are stored in oop arrays |
| 595 | TypeAryPtr::_array_body_type[T_BYTE] = TypeAryPtr::BYTES; |
| 596 | TypeAryPtr::_array_body_type[T_BOOLEAN] = TypeAryPtr::BYTES; // boolean[] is a byte array |
| 597 | TypeAryPtr::_array_body_type[T_SHORT] = TypeAryPtr::SHORTS; |
| 598 | TypeAryPtr::_array_body_type[T_CHAR] = TypeAryPtr::CHARS; |
| 599 | TypeAryPtr::_array_body_type[T_INT] = TypeAryPtr::INTS; |
| 600 | TypeAryPtr::_array_body_type[T_LONG] = TypeAryPtr::LONGS; |
| 601 | TypeAryPtr::_array_body_type[T_FLOAT] = TypeAryPtr::FLOATS; |
| 602 | TypeAryPtr::_array_body_type[T_DOUBLE] = TypeAryPtr::DOUBLES; |
| 603 | |
| 604 | TypeInstKlassPtr::OBJECT = TypeInstKlassPtr::make(TypePtr::NotNull, current->env()->Object_klass(), 0); |
| 605 | TypeInstKlassPtr::OBJECT_OR_NULL = TypeInstKlassPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), 0); |
| 606 | |
| 607 | const Type **fi2c = TypeTuple::fields(2); |
| 608 | fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // Method* |
| 609 | fi2c[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // argument pointer |
| 610 | TypeTuple::START_I2C = TypeTuple::make(TypeFunc::Parms+2, fi2c); |
| 611 | |
| 612 | const Type **intpair = TypeTuple::fields(2); |
| 613 | intpair[0] = TypeInt::INT; |
| 614 | intpair[1] = TypeInt::INT; |
| 615 | TypeTuple::INT_PAIR = TypeTuple::make(2, intpair); |
| 616 | |
| 617 | const Type **longpair = TypeTuple::fields(2); |
| 618 | longpair[0] = TypeLong::LONG; |
| 619 | longpair[1] = TypeLong::LONG; |
| 620 | TypeTuple::LONG_PAIR = TypeTuple::make(2, longpair); |
| 621 | |
| 622 | const Type **intccpair = TypeTuple::fields(2); |
| 623 | intccpair[0] = TypeInt::INT; |
| 624 | intccpair[1] = TypeInt::CC; |
| 625 | TypeTuple::INT_CC_PAIR = TypeTuple::make(2, intccpair); |
| 626 | |
| 627 | const Type **longccpair = TypeTuple::fields(2); |
| 628 | longccpair[0] = TypeLong::LONG; |
| 629 | longccpair[1] = TypeInt::CC; |
| 630 | TypeTuple::LONG_CC_PAIR = TypeTuple::make(2, longccpair); |
| 631 | |
| 632 | _const_basic_type[T_NARROWOOP] = TypeNarrowOop::BOTTOM; |
| 633 | _const_basic_type[T_NARROWKLASS] = Type::BOTTOM; |
| 634 | _const_basic_type[T_BOOLEAN] = TypeInt::BOOL; |
| 635 | _const_basic_type[T_CHAR] = TypeInt::CHAR; |
| 636 | _const_basic_type[T_BYTE] = TypeInt::BYTE; |
| 637 | _const_basic_type[T_SHORT] = TypeInt::SHORT; |
| 638 | _const_basic_type[T_INT] = TypeInt::INT; |
| 639 | _const_basic_type[T_LONG] = TypeLong::LONG; |
| 640 | _const_basic_type[T_FLOAT] = Type::FLOAT; |
| 641 | _const_basic_type[T_DOUBLE] = Type::DOUBLE; |
| 642 | _const_basic_type[T_OBJECT] = TypeInstPtr::BOTTOM; |
| 643 | _const_basic_type[T_ARRAY] = TypeInstPtr::BOTTOM; // there is no separate bottom for arrays |
| 644 | _const_basic_type[T_VOID] = TypePtr::NULL_PTR; // reflection represents void this way |
| 645 | _const_basic_type[T_ADDRESS] = TypeRawPtr::BOTTOM; // both interpreter return addresses & random raw ptrs |
| 646 | _const_basic_type[T_CONFLICT] = Type::BOTTOM; // why not? |
| 647 | |
| 648 | _zero_type[T_NARROWOOP] = TypeNarrowOop::NULL_PTR; |
| 649 | _zero_type[T_NARROWKLASS] = TypeNarrowKlass::NULL_PTR; |
| 650 | _zero_type[T_BOOLEAN] = TypeInt::ZERO; // false == 0 |
| 651 | _zero_type[T_CHAR] = TypeInt::ZERO; // '\0' == 0 |
| 652 | _zero_type[T_BYTE] = TypeInt::ZERO; // 0x00 == 0 |
| 653 | _zero_type[T_SHORT] = TypeInt::ZERO; // 0x0000 == 0 |
| 654 | _zero_type[T_INT] = TypeInt::ZERO; |
| 655 | _zero_type[T_LONG] = TypeLong::ZERO; |
| 656 | _zero_type[T_FLOAT] = TypeF::ZERO; |
| 657 | _zero_type[T_DOUBLE] = TypeD::ZERO; |
| 658 | _zero_type[T_OBJECT] = TypePtr::NULL_PTR; |
| 659 | _zero_type[T_ARRAY] = TypePtr::NULL_PTR; // null array is null oop |
| 660 | _zero_type[T_ADDRESS] = TypePtr::NULL_PTR; // raw pointers use the same null |
| 661 | _zero_type[T_VOID] = Type::TOP; // the only void value is no value at all |
| 662 | |
| 663 | // get_zero_type() should not happen for T_CONFLICT |
| 664 | _zero_type[T_CONFLICT]= NULL__null; |
| 665 | |
| 666 | TypeVect::VECTMASK = (TypeVect*)(new TypeVectMask(TypeInt::BOOL, MaxVectorSize))->hashcons(); |
| 667 | mreg2type[Op_RegVectMask] = TypeVect::VECTMASK; |
| 668 | |
| 669 | if (Matcher::supports_scalable_vector()) { |
| 670 | TypeVect::VECTA = TypeVect::make(T_BYTE, Matcher::scalable_vector_reg_size(T_BYTE)); |
| 671 | } |
| 672 | |
| 673 | // Vector predefined types, it needs initialized _const_basic_type[]. |
| 674 | if (Matcher::vector_size_supported(T_BYTE,4)) { |
| 675 | TypeVect::VECTS = TypeVect::make(T_BYTE,4); |
| 676 | } |
| 677 | if (Matcher::vector_size_supported(T_FLOAT,2)) { |
| 678 | TypeVect::VECTD = TypeVect::make(T_FLOAT,2); |
| 679 | } |
| 680 | if (Matcher::vector_size_supported(T_FLOAT,4)) { |
| 681 | TypeVect::VECTX = TypeVect::make(T_FLOAT,4); |
| 682 | } |
| 683 | if (Matcher::vector_size_supported(T_FLOAT,8)) { |
| 684 | TypeVect::VECTY = TypeVect::make(T_FLOAT,8); |
| 685 | } |
| 686 | if (Matcher::vector_size_supported(T_FLOAT,16)) { |
| 687 | TypeVect::VECTZ = TypeVect::make(T_FLOAT,16); |
| 688 | } |
| 689 | |
| 690 | mreg2type[Op_VecA] = TypeVect::VECTA; |
| 691 | mreg2type[Op_VecS] = TypeVect::VECTS; |
| 692 | mreg2type[Op_VecD] = TypeVect::VECTD; |
| 693 | mreg2type[Op_VecX] = TypeVect::VECTX; |
| 694 | mreg2type[Op_VecY] = TypeVect::VECTY; |
| 695 | mreg2type[Op_VecZ] = TypeVect::VECTZ; |
| 696 | |
| 697 | // Restore working type arena. |
| 698 | current->set_type_arena(save); |
| 699 | current->set_type_dict(NULL__null); |
| 700 | } |
| 701 | |
| 702 | //------------------------------Initialize------------------------------------- |
| 703 | void Type::Initialize(Compile* current) { |
| 704 | assert(current->type_arena() != NULL, "must have created type arena")do { if (!(current->type_arena() != __null)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 704, "assert(" "current->type_arena() != __null" ") failed" , "must have created type arena"); ::breakpoint(); } } while ( 0); |
| 705 | |
| 706 | if (_shared_type_dict == NULL__null) { |
| 707 | Initialize_shared(current); |
| 708 | } |
| 709 | |
| 710 | Arena* type_arena = current->type_arena(); |
| 711 | |
| 712 | // Create the hash-cons'ing dictionary with top-level storage allocation |
| 713 | Dict *tdic = new (type_arena) Dict(*_shared_type_dict, type_arena); |
| 714 | current->set_type_dict(tdic); |
| 715 | } |
| 716 | |
| 717 | //------------------------------hashcons--------------------------------------- |
| 718 | // Do the hash-cons trick. If the Type already exists in the type table, |
| 719 | // delete the current Type and return the existing Type. Otherwise stick the |
| 720 | // current Type in the Type table. |
| 721 | const Type *Type::hashcons(void) { |
| 722 | debug_only(base())base(); // Check the assertion in Type::base(). |
| 723 | // Look up the Type in the Type dictionary |
| 724 | Dict *tdic = type_dict(); |
| 725 | Type* old = (Type*)(tdic->Insert(this, this, false)); |
| 726 | if( old ) { // Pre-existing Type? |
| 727 | if( old != this ) // Yes, this guy is not the pre-existing? |
| 728 | delete this; // Yes, Nuke this guy |
| 729 | assert( old->_dual, "" )do { if (!(old->_dual)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 729, "assert(" "old->_dual" ") failed", ""); ::breakpoint (); } } while (0); |
| 730 | return old; // Return pre-existing |
| 731 | } |
| 732 | |
| 733 | // Every type has a dual (to make my lattice symmetric). |
| 734 | // Since we just discovered a new Type, compute its dual right now. |
| 735 | assert( !_dual, "" )do { if (!(!_dual)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 735, "assert(" "!_dual" ") failed", ""); ::breakpoint(); } } while (0); // No dual yet |
| 736 | _dual = xdual(); // Compute the dual |
| 737 | if (cmp(this, _dual) == 0) { // Handle self-symmetric |
| 738 | if (_dual != this) { |
| 739 | delete _dual; |
| 740 | _dual = this; |
| 741 | } |
| 742 | return this; |
| 743 | } |
| 744 | assert( !_dual->_dual, "" )do { if (!(!_dual->_dual)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 744, "assert(" "!_dual->_dual" ") failed", ""); ::breakpoint (); } } while (0); // No reverse dual yet |
| 745 | assert( !(*tdic)[_dual], "" )do { if (!(!(*tdic)[_dual])) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 745, "assert(" "!(*tdic)[_dual]" ") failed", ""); ::breakpoint (); } } while (0); // Dual not in type system either |
| 746 | // New Type, insert into Type table |
| 747 | tdic->Insert((void*)_dual,(void*)_dual); |
| 748 | ((Type*)_dual)->_dual = this; // Finish up being symmetric |
| 749 | #ifdef ASSERT1 |
| 750 | Type *dual_dual = (Type*)_dual->xdual(); |
| 751 | assert( eq(dual_dual), "xdual(xdual()) should be identity" )do { if (!(eq(dual_dual))) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 751, "assert(" "eq(dual_dual)" ") failed", "xdual(xdual()) should be identity" ); ::breakpoint(); } } while (0); |
| 752 | delete dual_dual; |
| 753 | #endif |
| 754 | return this; // Return new Type |
| 755 | } |
| 756 | |
| 757 | //------------------------------eq--------------------------------------------- |
| 758 | // Structural equality check for Type representations |
| 759 | bool Type::eq( const Type * ) const { |
| 760 | return true; // Nothing else can go wrong |
| 761 | } |
| 762 | |
| 763 | //------------------------------hash------------------------------------------- |
| 764 | // Type-specific hashing function. |
| 765 | int Type::hash(void) const { |
| 766 | return _base; |
| 767 | } |
| 768 | |
| 769 | //------------------------------is_finite-------------------------------------- |
| 770 | // Has a finite value |
| 771 | bool Type::is_finite() const { |
| 772 | return false; |
| 773 | } |
| 774 | |
| 775 | //------------------------------is_nan----------------------------------------- |
| 776 | // Is not a number (NaN) |
| 777 | bool Type::is_nan() const { |
| 778 | return false; |
| 779 | } |
| 780 | |
| 781 | //----------------------interface_vs_oop--------------------------------------- |
| 782 | #ifdef ASSERT1 |
| 783 | bool Type::interface_vs_oop_helper(const Type *t) const { |
| 784 | bool result = false; |
| 785 | |
| 786 | const TypePtr* this_ptr = this->make_ptr(); // In case it is narrow_oop |
| 787 | const TypePtr* t_ptr = t->make_ptr(); |
| 788 | if( this_ptr == NULL__null || t_ptr == NULL__null ) |
| 789 | return result; |
| 790 | |
| 791 | const TypeInstPtr* this_inst = this_ptr->isa_instptr(); |
| 792 | const TypeInstPtr* t_inst = t_ptr->isa_instptr(); |
| 793 | if( this_inst && this_inst->is_loaded() && t_inst && t_inst->is_loaded() ) { |
| 794 | bool this_interface = this_inst->klass()->is_interface(); |
| 795 | bool t_interface = t_inst->klass()->is_interface(); |
| 796 | result = this_interface ^ t_interface; |
| 797 | } |
| 798 | |
| 799 | return result; |
| 800 | } |
| 801 | |
| 802 | bool Type::interface_vs_oop(const Type *t) const { |
| 803 | if (interface_vs_oop_helper(t)) { |
| 804 | return true; |
| 805 | } |
| 806 | // Now check the speculative parts as well |
| 807 | const TypePtr* this_spec = isa_ptr() != NULL__null ? is_ptr()->speculative() : NULL__null; |
| 808 | const TypePtr* t_spec = t->isa_ptr() != NULL__null ? t->is_ptr()->speculative() : NULL__null; |
| 809 | if (this_spec != NULL__null && t_spec != NULL__null) { |
| 810 | if (this_spec->interface_vs_oop_helper(t_spec)) { |
| 811 | return true; |
| 812 | } |
| 813 | return false; |
| 814 | } |
| 815 | if (this_spec != NULL__null && this_spec->interface_vs_oop_helper(t)) { |
| 816 | return true; |
| 817 | } |
| 818 | if (t_spec != NULL__null && interface_vs_oop_helper(t_spec)) { |
| 819 | return true; |
| 820 | } |
| 821 | return false; |
| 822 | } |
| 823 | |
| 824 | #endif |
| 825 | |
| 826 | void Type::check_symmetrical(const Type* t, const Type* mt) const { |
| 827 | #ifdef ASSERT1 |
| 828 | const Type* mt2 = t->xmeet(this); |
| 829 | if (mt != mt2) { |
| 830 | tty->print_cr("=== Meet Not Commutative ==="); |
| 831 | tty->print("t = "); t->dump(); tty->cr(); |
| 832 | tty->print("this = "); dump(); tty->cr(); |
| 833 | tty->print("t meet this = "); mt2->dump(); tty->cr(); |
| 834 | tty->print("this meet t = "); mt->dump(); tty->cr(); |
| 835 | fatal("meet not commutative")do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 835, "meet not commutative"); ::breakpoint(); } while (0); |
| 836 | } |
| 837 | const Type* dual_join = mt->_dual; |
| 838 | const Type* t2t = dual_join->xmeet(t->_dual); |
| 839 | const Type* t2this = dual_join->xmeet(this->_dual); |
| 840 | |
| 841 | // Interface meet Oop is Not Symmetric: |
| 842 | // Interface:AnyNull meet Oop:AnyNull == Interface:AnyNull |
| 843 | // Interface:NotNull meet Oop:NotNull == java/lang/Object:NotNull |
| 844 | |
| 845 | if (!interface_vs_oop(t) && (t2t != t->_dual || t2this != this->_dual)) { |
| 846 | tty->print_cr("=== Meet Not Symmetric ==="); |
| 847 | tty->print("t = "); t->dump(); tty->cr(); |
| 848 | tty->print("this= "); dump(); tty->cr(); |
| 849 | tty->print("mt=(t meet this)= "); mt->dump(); tty->cr(); |
| 850 | |
| 851 | tty->print("t_dual= "); t->_dual->dump(); tty->cr(); |
| 852 | tty->print("this_dual= "); _dual->dump(); tty->cr(); |
| 853 | tty->print("mt_dual= "); mt->_dual->dump(); tty->cr(); |
| 854 | |
| 855 | tty->print("mt_dual meet t_dual= "); t2t ->dump(); tty->cr(); |
| 856 | tty->print("mt_dual meet this_dual= "); t2this ->dump(); tty->cr(); |
| 857 | |
| 858 | fatal("meet not symmetric")do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 858, "meet not symmetric"); ::breakpoint(); } while (0); |
| 859 | } |
| 860 | #endif |
| 861 | } |
| 862 | |
| 863 | //------------------------------meet------------------------------------------- |
| 864 | // Compute the MEET of two types. NOT virtual. It enforces that meet is |
| 865 | // commutative and the lattice is symmetric. |
| 866 | const Type *Type::meet_helper(const Type *t, bool include_speculative) const { |
| 867 | if (isa_narrowoop() && t->isa_narrowoop()) { |
| 868 | const Type* result = make_ptr()->meet_helper(t->make_ptr(), include_speculative); |
| 869 | return result->make_narrowoop(); |
| 870 | } |
| 871 | if (isa_narrowklass() && t->isa_narrowklass()) { |
| 872 | const Type* result = make_ptr()->meet_helper(t->make_ptr(), include_speculative); |
| 873 | return result->make_narrowklass(); |
| 874 | } |
| 875 | |
| 876 | const Type *this_t = maybe_remove_speculative(include_speculative); |
| 877 | t = t->maybe_remove_speculative(include_speculative); |
| 878 | |
| 879 | const Type *mt = this_t->xmeet(t); |
| 880 | #ifdef ASSERT1 |
| 881 | if (isa_narrowoop() || t->isa_narrowoop()) return mt; |
| 882 | if (isa_narrowklass() || t->isa_narrowklass()) return mt; |
| 883 | Compile* C = Compile::current(); |
| 884 | if (!C->_type_verify_symmetry) { |
| 885 | return mt; |
| 886 | } |
| 887 | this_t->check_symmetrical(t, mt); |
| 888 | // In the case of an array, computing the meet above, caused the |
| 889 | // computation of the meet of the elements which at verification |
| 890 | // time caused the computation of the meet of the dual of the |
| 891 | // elements. Computing the meet of the dual of the arrays here |
| 892 | // causes the meet of the dual of the elements to be computed which |
| 893 | // would cause the meet of the dual of the dual of the elements, |
| 894 | // that is the meet of the elements already computed above to be |
| 895 | // computed. Avoid redundant computations by requesting no |
| 896 | // verification. |
| 897 | C->_type_verify_symmetry = false; |
| 898 | const Type *mt_dual = this_t->_dual->xmeet(t->_dual); |
| 899 | this_t->_dual->check_symmetrical(t->_dual, mt_dual); |
| 900 | assert(!C->_type_verify_symmetry, "shouldn't have changed")do { if (!(!C->_type_verify_symmetry)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 900, "assert(" "!C->_type_verify_symmetry" ") failed", "shouldn't have changed" ); ::breakpoint(); } } while (0); |
| 901 | C->_type_verify_symmetry = true; |
| 902 | #endif |
| 903 | return mt; |
| 904 | } |
| 905 | |
| 906 | //------------------------------xmeet------------------------------------------ |
| 907 | // Compute the MEET of two types. It returns a new Type object. |
| 908 | const Type *Type::xmeet( const Type *t ) const { |
| 909 | // Perform a fast test for common case; meeting the same types together. |
| 910 | if( this == t ) return this; // Meeting same type-rep? |
| 911 | |
| 912 | // Meeting TOP with anything? |
| 913 | if( _base == Top ) return t; |
| 914 | |
| 915 | // Meeting BOTTOM with anything? |
| 916 | if( _base == Bottom ) return BOTTOM; |
| 917 | |
| 918 | // Current "this->_base" is one of: Bad, Multi, Control, Top, |
| 919 | // Abio, Abstore, Floatxxx, Doublexxx, Bottom, lastype. |
| 920 | switch (t->base()) { // Switch on original type |
| 921 | |
| 922 | // Cut in half the number of cases I must handle. Only need cases for when |
| 923 | // the given enum "t->type" is less than or equal to the local enum "type". |
| 924 | case FloatCon: |
| 925 | case DoubleCon: |
| 926 | case Int: |
| 927 | case Long: |
| 928 | return t->xmeet(this); |
| 929 | |
| 930 | case OopPtr: |
| 931 | return t->xmeet(this); |
| 932 | |
| 933 | case InstPtr: |
| 934 | return t->xmeet(this); |
| 935 | |
| 936 | case MetadataPtr: |
| 937 | case KlassPtr: |
| 938 | case InstKlassPtr: |
| 939 | case AryKlassPtr: |
| 940 | return t->xmeet(this); |
| 941 | |
| 942 | case AryPtr: |
| 943 | return t->xmeet(this); |
| 944 | |
| 945 | case NarrowOop: |
| 946 | return t->xmeet(this); |
| 947 | |
| 948 | case NarrowKlass: |
| 949 | return t->xmeet(this); |
| 950 | |
| 951 | case Bad: // Type check |
| 952 | default: // Bogus type not in lattice |
| 953 | typerr(t); |
| 954 | return Type::BOTTOM; |
| 955 | |
| 956 | case Bottom: // Ye Olde Default |
| 957 | return t; |
| 958 | |
| 959 | case FloatTop: |
| 960 | if( _base == FloatTop ) return this; |
| 961 | case FloatBot: // Float |
| 962 | if( _base == FloatBot || _base == FloatTop ) return FLOAT; |
| 963 | if( _base == DoubleTop || _base == DoubleBot ) return Type::BOTTOM; |
| 964 | typerr(t); |
| 965 | return Type::BOTTOM; |
| 966 | |
| 967 | case DoubleTop: |
| 968 | if( _base == DoubleTop ) return this; |
| 969 | case DoubleBot: // Double |
| 970 | if( _base == DoubleBot || _base == DoubleTop ) return DOUBLE; |
| 971 | if( _base == FloatTop || _base == FloatBot ) return Type::BOTTOM; |
| 972 | typerr(t); |
| 973 | return Type::BOTTOM; |
| 974 | |
| 975 | // These next few cases must match exactly or it is a compile-time error. |
| 976 | case Control: // Control of code |
| 977 | case Abio: // State of world outside of program |
| 978 | case Memory: |
| 979 | if( _base == t->_base ) return this; |
| 980 | typerr(t); |
| 981 | return Type::BOTTOM; |
| 982 | |
| 983 | case Top: // Top of the lattice |
| 984 | return this; |
| 985 | } |
| 986 | |
| 987 | // The type is unchanged |
| 988 | return this; |
| 989 | } |
| 990 | |
| 991 | //-----------------------------filter------------------------------------------ |
| 992 | const Type *Type::filter_helper(const Type *kills, bool include_speculative) const { |
| 993 | const Type* ft = join_helper(kills, include_speculative); |
| 994 | if (ft->empty()) |
| 995 | return Type::TOP; // Canonical empty value |
| 996 | return ft; |
| 997 | } |
| 998 | |
| 999 | //------------------------------xdual------------------------------------------ |
| 1000 | const Type *Type::xdual() const { |
| 1001 | // Note: the base() accessor asserts the sanity of _base. |
| 1002 | assert(_type_info[base()].dual_type != Bad, "implement with v-call")do { if (!(_type_info[base()].dual_type != Bad)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 1002, "assert(" "_type_info[base()].dual_type != Bad" ") failed" , "implement with v-call"); ::breakpoint(); } } while (0); |
| 1003 | return new Type(_type_info[_base].dual_type); |
| 1004 | } |
| 1005 | |
| 1006 | //------------------------------has_memory------------------------------------- |
| 1007 | bool Type::has_memory() const { |
| 1008 | Type::TYPES tx = base(); |
| 1009 | if (tx == Memory) return true; |
| 1010 | if (tx == Tuple) { |
| 1011 | const TypeTuple *t = is_tuple(); |
| 1012 | for (uint i=0; i < t->cnt(); i++) { |
| 1013 | tx = t->field_at(i)->base(); |
| 1014 | if (tx == Memory) return true; |
| 1015 | } |
| 1016 | } |
| 1017 | return false; |
| 1018 | } |
| 1019 | |
| 1020 | #ifndef PRODUCT |
| 1021 | //------------------------------dump2------------------------------------------ |
| 1022 | void Type::dump2( Dict &d, uint depth, outputStream *st ) const { |
| 1023 | st->print("%s", _type_info[_base].msg); |
| 1024 | } |
| 1025 | |
| 1026 | //------------------------------dump------------------------------------------- |
| 1027 | void Type::dump_on(outputStream *st) const { |
| 1028 | ResourceMark rm; |
| 1029 | Dict d(cmpkey,hashkey); // Stop recursive type dumping |
| 1030 | dump2(d,1, st); |
| 1031 | if (is_ptr_to_narrowoop()) { |
| 1032 | st->print(" [narrow]"); |
| 1033 | } else if (is_ptr_to_narrowklass()) { |
| 1034 | st->print(" [narrowklass]"); |
| 1035 | } |
| 1036 | } |
| 1037 | |
| 1038 | //----------------------------------------------------------------------------- |
| 1039 | const char* Type::str(const Type* t) { |
| 1040 | stringStream ss; |
| 1041 | t->dump_on(&ss); |
| 1042 | return ss.as_string(); |
| 1043 | } |
| 1044 | #endif |
| 1045 | |
| 1046 | //------------------------------singleton-------------------------------------- |
| 1047 | // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple |
| 1048 | // constants (Ldi nodes). Singletons are integer, float or double constants. |
| 1049 | bool Type::singleton(void) const { |
| 1050 | return _base == Top || _base == Half; |
| 1051 | } |
| 1052 | |
| 1053 | //------------------------------empty------------------------------------------ |
| 1054 | // TRUE if Type is a type with no values, FALSE otherwise. |
| 1055 | bool Type::empty(void) const { |
| 1056 | switch (_base) { |
| 1057 | case DoubleTop: |
| 1058 | case FloatTop: |
| 1059 | case Top: |
| 1060 | return true; |
| 1061 | |
| 1062 | case Half: |
| 1063 | case Abio: |
| 1064 | case Return_Address: |
| 1065 | case Memory: |
| 1066 | case Bottom: |
| 1067 | case FloatBot: |
| 1068 | case DoubleBot: |
| 1069 | return false; // never a singleton, therefore never empty |
| 1070 | |
| 1071 | default: |
| 1072 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 1072); ::breakpoint(); } while (0); |
| 1073 | return false; |
| 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | //------------------------------dump_stats------------------------------------- |
| 1078 | // Dump collected statistics to stderr |
| 1079 | #ifndef PRODUCT |
| 1080 | void Type::dump_stats() { |
| 1081 | tty->print("Types made: %d\n", type_dict()->Size()); |
| 1082 | } |
| 1083 | #endif |
| 1084 | |
| 1085 | //------------------------------category--------------------------------------- |
| 1086 | #ifndef PRODUCT |
| 1087 | Type::Category Type::category() const { |
| 1088 | const TypeTuple* tuple; |
| 1089 | switch (base()) { |
| 1090 | case Type::Int: |
| 1091 | case Type::Long: |
| 1092 | case Type::Half: |
| 1093 | case Type::NarrowOop: |
| 1094 | case Type::NarrowKlass: |
| 1095 | case Type::Array: |
| 1096 | case Type::VectorA: |
| 1097 | case Type::VectorS: |
| 1098 | case Type::VectorD: |
| 1099 | case Type::VectorX: |
| 1100 | case Type::VectorY: |
| 1101 | case Type::VectorZ: |
| 1102 | case Type::VectorMask: |
| 1103 | case Type::AnyPtr: |
| 1104 | case Type::RawPtr: |
| 1105 | case Type::OopPtr: |
| 1106 | case Type::InstPtr: |
| 1107 | case Type::AryPtr: |
| 1108 | case Type::MetadataPtr: |
| 1109 | case Type::KlassPtr: |
| 1110 | case Type::InstKlassPtr: |
| 1111 | case Type::AryKlassPtr: |
| 1112 | case Type::Function: |
| 1113 | case Type::Return_Address: |
| 1114 | case Type::FloatTop: |
| 1115 | case Type::FloatCon: |
| 1116 | case Type::FloatBot: |
| 1117 | case Type::DoubleTop: |
| 1118 | case Type::DoubleCon: |
| 1119 | case Type::DoubleBot: |
| 1120 | return Category::Data; |
| 1121 | case Type::Memory: |
| 1122 | return Category::Memory; |
| 1123 | case Type::Control: |
| 1124 | return Category::Control; |
| 1125 | case Type::Top: |
| 1126 | case Type::Abio: |
| 1127 | case Type::Bottom: |
| 1128 | return Category::Other; |
| 1129 | case Type::Bad: |
| 1130 | case Type::lastype: |
| 1131 | return Category::Undef; |
| 1132 | case Type::Tuple: |
| 1133 | // Recursive case. Return CatMixed if the tuple contains types of |
| 1134 | // different categories (e.g. CallStaticJavaNode's type), or the specific |
| 1135 | // category if all types are of the same category (e.g. IfNode's type). |
| 1136 | tuple = is_tuple(); |
| 1137 | if (tuple->cnt() == 0) { |
| 1138 | return Category::Undef; |
| 1139 | } else { |
| 1140 | Category first = tuple->field_at(0)->category(); |
| 1141 | for (uint i = 1; i < tuple->cnt(); i++) { |
| 1142 | if (tuple->field_at(i)->category() != first) { |
| 1143 | return Category::Mixed; |
| 1144 | } |
| 1145 | } |
| 1146 | return first; |
| 1147 | } |
| 1148 | default: |
| 1149 | assert(false, "unmatched base type: all base types must be categorized")do { if (!(false)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 1149, "assert(" "false" ") failed", "unmatched base type: all base types must be categorized" ); ::breakpoint(); } } while (0); |
| 1150 | } |
| 1151 | return Category::Undef; |
| 1152 | } |
| 1153 | #endif |
| 1154 | |
| 1155 | //------------------------------typerr----------------------------------------- |
| 1156 | void Type::typerr( const Type *t ) const { |
| 1157 | #ifndef PRODUCT |
| 1158 | tty->print("\nError mixing types: "); |
| 1159 | dump(); |
| 1160 | tty->print(" and "); |
| 1161 | t->dump(); |
| 1162 | tty->print("\n"); |
| 1163 | #endif |
| 1164 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 1164); ::breakpoint(); } while (0); |
| 1165 | } |
| 1166 | |
| 1167 | |
| 1168 | //============================================================================= |
| 1169 | // Convenience common pre-built types. |
| 1170 | const TypeF *TypeF::MAX; // Floating point max |
| 1171 | const TypeF *TypeF::MIN; // Floating point min |
| 1172 | const TypeF *TypeF::ZERO; // Floating point zero |
| 1173 | const TypeF *TypeF::ONE; // Floating point one |
| 1174 | const TypeF *TypeF::POS_INF; // Floating point positive infinity |
| 1175 | const TypeF *TypeF::NEG_INF; // Floating point negative infinity |
| 1176 | |
| 1177 | //------------------------------make------------------------------------------- |
| 1178 | // Create a float constant |
| 1179 | const TypeF *TypeF::make(float f) { |
| 1180 | return (TypeF*)(new TypeF(f))->hashcons(); |
| 1181 | } |
| 1182 | |
| 1183 | //------------------------------meet------------------------------------------- |
| 1184 | // Compute the MEET of two types. It returns a new Type object. |
| 1185 | const Type *TypeF::xmeet( const Type *t ) const { |
| 1186 | // Perform a fast test for common case; meeting the same types together. |
| 1187 | if( this == t ) return this; // Meeting same type-rep? |
| 1188 | |
| 1189 | // Current "this->_base" is FloatCon |
| 1190 | switch (t->base()) { // Switch on original type |
| 1191 | case AnyPtr: // Mixing with oops happens when javac |
| 1192 | case RawPtr: // reuses local variables |
| 1193 | case OopPtr: |
| 1194 | case InstPtr: |
| 1195 | case AryPtr: |
| 1196 | case MetadataPtr: |
| 1197 | case KlassPtr: |
| 1198 | case InstKlassPtr: |
| 1199 | case AryKlassPtr: |
| 1200 | case NarrowOop: |
| 1201 | case NarrowKlass: |
| 1202 | case Int: |
| 1203 | case Long: |
| 1204 | case DoubleTop: |
| 1205 | case DoubleCon: |
| 1206 | case DoubleBot: |
| 1207 | case Bottom: // Ye Olde Default |
| 1208 | return Type::BOTTOM; |
| 1209 | |
| 1210 | case FloatBot: |
| 1211 | return t; |
| 1212 | |
| 1213 | default: // All else is a mistake |
| 1214 | typerr(t); |
| 1215 | |
| 1216 | case FloatCon: // Float-constant vs Float-constant? |
| 1217 | if( jint_cast(_f) != jint_cast(t->getf()) ) // unequal constants? |
| 1218 | // must compare bitwise as positive zero, negative zero and NaN have |
| 1219 | // all the same representation in C++ |
| 1220 | return FLOAT; // Return generic float |
| 1221 | // Equal constants |
| 1222 | case Top: |
| 1223 | case FloatTop: |
| 1224 | break; // Return the float constant |
| 1225 | } |
| 1226 | return this; // Return the float constant |
| 1227 | } |
| 1228 | |
| 1229 | //------------------------------xdual------------------------------------------ |
| 1230 | // Dual: symmetric |
| 1231 | const Type *TypeF::xdual() const { |
| 1232 | return this; |
| 1233 | } |
| 1234 | |
| 1235 | //------------------------------eq--------------------------------------------- |
| 1236 | // Structural equality check for Type representations |
| 1237 | bool TypeF::eq(const Type *t) const { |
| 1238 | // Bitwise comparison to distinguish between +/-0. These values must be treated |
| 1239 | // as different to be consistent with C1 and the interpreter. |
| 1240 | return (jint_cast(_f) == jint_cast(t->getf())); |
| 1241 | } |
| 1242 | |
| 1243 | //------------------------------hash------------------------------------------- |
| 1244 | // Type-specific hashing function. |
| 1245 | int TypeF::hash(void) const { |
| 1246 | return *(int*)(&_f); |
| 1247 | } |
| 1248 | |
| 1249 | //------------------------------is_finite-------------------------------------- |
| 1250 | // Has a finite value |
| 1251 | bool TypeF::is_finite() const { |
| 1252 | return g_isfinite(getf()) != 0; |
| 1253 | } |
| 1254 | |
| 1255 | //------------------------------is_nan----------------------------------------- |
| 1256 | // Is not a number (NaN) |
| 1257 | bool TypeF::is_nan() const { |
| 1258 | return g_isnan(getf()) != 0; |
| 1259 | } |
| 1260 | |
| 1261 | //------------------------------dump2------------------------------------------ |
| 1262 | // Dump float constant Type |
| 1263 | #ifndef PRODUCT |
| 1264 | void TypeF::dump2( Dict &d, uint depth, outputStream *st ) const { |
| 1265 | Type::dump2(d,depth, st); |
| 1266 | st->print("%f", _f); |
| 1267 | } |
| 1268 | #endif |
| 1269 | |
| 1270 | //------------------------------singleton-------------------------------------- |
| 1271 | // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple |
| 1272 | // constants (Ldi nodes). Singletons are integer, float or double constants |
| 1273 | // or a single symbol. |
| 1274 | bool TypeF::singleton(void) const { |
| 1275 | return true; // Always a singleton |
| 1276 | } |
| 1277 | |
| 1278 | bool TypeF::empty(void) const { |
| 1279 | return false; // always exactly a singleton |
| 1280 | } |
| 1281 | |
| 1282 | //============================================================================= |
| 1283 | // Convenience common pre-built types. |
| 1284 | const TypeD *TypeD::MAX; // Floating point max |
| 1285 | const TypeD *TypeD::MIN; // Floating point min |
| 1286 | const TypeD *TypeD::ZERO; // Floating point zero |
| 1287 | const TypeD *TypeD::ONE; // Floating point one |
| 1288 | const TypeD *TypeD::POS_INF; // Floating point positive infinity |
| 1289 | const TypeD *TypeD::NEG_INF; // Floating point negative infinity |
| 1290 | |
| 1291 | //------------------------------make------------------------------------------- |
| 1292 | const TypeD *TypeD::make(double d) { |
| 1293 | return (TypeD*)(new TypeD(d))->hashcons(); |
| 1294 | } |
| 1295 | |
| 1296 | //------------------------------meet------------------------------------------- |
| 1297 | // Compute the MEET of two types. It returns a new Type object. |
| 1298 | const Type *TypeD::xmeet( const Type *t ) const { |
| 1299 | // Perform a fast test for common case; meeting the same types together. |
| 1300 | if( this == t ) return this; // Meeting same type-rep? |
| 1301 | |
| 1302 | // Current "this->_base" is DoubleCon |
| 1303 | switch (t->base()) { // Switch on original type |
| 1304 | case AnyPtr: // Mixing with oops happens when javac |
| 1305 | case RawPtr: // reuses local variables |
| 1306 | case OopPtr: |
| 1307 | case InstPtr: |
| 1308 | case AryPtr: |
| 1309 | case MetadataPtr: |
| 1310 | case KlassPtr: |
| 1311 | case InstKlassPtr: |
| 1312 | case AryKlassPtr: |
| 1313 | case NarrowOop: |
| 1314 | case NarrowKlass: |
| 1315 | case Int: |
| 1316 | case Long: |
| 1317 | case FloatTop: |
| 1318 | case FloatCon: |
| 1319 | case FloatBot: |
| 1320 | case Bottom: // Ye Olde Default |
| 1321 | return Type::BOTTOM; |
| 1322 | |
| 1323 | case DoubleBot: |
| 1324 | return t; |
| 1325 | |
| 1326 | default: // All else is a mistake |
| 1327 | typerr(t); |
| 1328 | |
| 1329 | case DoubleCon: // Double-constant vs Double-constant? |
| 1330 | if( jlong_cast(_d) != jlong_cast(t->getd()) ) // unequal constants? (see comment in TypeF::xmeet) |
| 1331 | return DOUBLE; // Return generic double |
| 1332 | case Top: |
| 1333 | case DoubleTop: |
| 1334 | break; |
| 1335 | } |
| 1336 | return this; // Return the double constant |
| 1337 | } |
| 1338 | |
| 1339 | //------------------------------xdual------------------------------------------ |
| 1340 | // Dual: symmetric |
| 1341 | const Type *TypeD::xdual() const { |
| 1342 | return this; |
| 1343 | } |
| 1344 | |
| 1345 | //------------------------------eq--------------------------------------------- |
| 1346 | // Structural equality check for Type representations |
| 1347 | bool TypeD::eq(const Type *t) const { |
| 1348 | // Bitwise comparison to distinguish between +/-0. These values must be treated |
| 1349 | // as different to be consistent with C1 and the interpreter. |
| 1350 | return (jlong_cast(_d) == jlong_cast(t->getd())); |
| 1351 | } |
| 1352 | |
| 1353 | //------------------------------hash------------------------------------------- |
| 1354 | // Type-specific hashing function. |
| 1355 | int TypeD::hash(void) const { |
| 1356 | return *(int*)(&_d); |
| 1357 | } |
| 1358 | |
| 1359 | //------------------------------is_finite-------------------------------------- |
| 1360 | // Has a finite value |
| 1361 | bool TypeD::is_finite() const { |
| 1362 | return g_isfinite(getd()) != 0; |
| 1363 | } |
| 1364 | |
| 1365 | //------------------------------is_nan----------------------------------------- |
| 1366 | // Is not a number (NaN) |
| 1367 | bool TypeD::is_nan() const { |
| 1368 | return g_isnan(getd()) != 0; |
| 1369 | } |
| 1370 | |
| 1371 | //------------------------------dump2------------------------------------------ |
| 1372 | // Dump double constant Type |
| 1373 | #ifndef PRODUCT |
| 1374 | void TypeD::dump2( Dict &d, uint depth, outputStream *st ) const { |
| 1375 | Type::dump2(d,depth,st); |
| 1376 | st->print("%f", _d); |
| 1377 | } |
| 1378 | #endif |
| 1379 | |
| 1380 | //------------------------------singleton-------------------------------------- |
| 1381 | // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple |
| 1382 | // constants (Ldi nodes). Singletons are integer, float or double constants |
| 1383 | // or a single symbol. |
| 1384 | bool TypeD::singleton(void) const { |
| 1385 | return true; // Always a singleton |
| 1386 | } |
| 1387 | |
| 1388 | bool TypeD::empty(void) const { |
| 1389 | return false; // always exactly a singleton |
| 1390 | } |
| 1391 | |
| 1392 | const TypeInteger* TypeInteger::make(jlong lo, jlong hi, int w, BasicType bt) { |
| 1393 | if (bt == T_INT) { |
| 1394 | return TypeInt::make(checked_cast<jint>(lo), checked_cast<jint>(hi), w); |
| 1395 | } |
| 1396 | assert(bt == T_LONG, "basic type not an int or long")do { if (!(bt == T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 1396, "assert(" "bt == T_LONG" ") failed", "basic type not an int or long" ); ::breakpoint(); } } while (0); |
| 1397 | return TypeLong::make(lo, hi, w); |
| 1398 | } |
| 1399 | |
| 1400 | jlong TypeInteger::get_con_as_long(BasicType bt) const { |
| 1401 | if (bt == T_INT) { |
| 1402 | return is_int()->get_con(); |
| 1403 | } |
| 1404 | assert(bt == T_LONG, "basic type not an int or long")do { if (!(bt == T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 1404, "assert(" "bt == T_LONG" ") failed", "basic type not an int or long" ); ::breakpoint(); } } while (0); |
| 1405 | return is_long()->get_con(); |
| 1406 | } |
| 1407 | |
| 1408 | const TypeInteger* TypeInteger::bottom(BasicType bt) { |
| 1409 | if (bt == T_INT) { |
| 1410 | return TypeInt::INT; |
| 1411 | } |
| 1412 | assert(bt == T_LONG, "basic type not an int or long")do { if (!(bt == T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 1412, "assert(" "bt == T_LONG" ") failed", "basic type not an int or long" ); ::breakpoint(); } } while (0); |
| 1413 | return TypeLong::LONG; |
| 1414 | } |
| 1415 | |
| 1416 | const TypeInteger* TypeInteger::zero(BasicType bt) { |
| 1417 | if (bt == T_INT) { |
| 1418 | return TypeInt::ZERO; |
| 1419 | } |
| 1420 | assert(bt == T_LONG, "basic type not an int or long")do { if (!(bt == T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 1420, "assert(" "bt == T_LONG" ") failed", "basic type not an int or long" ); ::breakpoint(); } } while (0); |
| 1421 | return TypeLong::ZERO; |
| 1422 | } |
| 1423 | |
| 1424 | const TypeInteger* TypeInteger::one(BasicType bt) { |
| 1425 | if (bt == T_INT) { |
| 1426 | return TypeInt::ONE; |
| 1427 | } |
| 1428 | assert(bt == T_LONG, "basic type not an int or long")do { if (!(bt == T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 1428, "assert(" "bt == T_LONG" ") failed", "basic type not an int or long" ); ::breakpoint(); } } while (0); |
| 1429 | return TypeLong::ONE; |
| 1430 | } |
| 1431 | |
| 1432 | const TypeInteger* TypeInteger::minus_1(BasicType bt) { |
| 1433 | if (bt == T_INT) { |
| 1434 | return TypeInt::MINUS_1; |
| 1435 | } |
| 1436 | assert(bt == T_LONG, "basic type not an int or long")do { if (!(bt == T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 1436, "assert(" "bt == T_LONG" ") failed", "basic type not an int or long" ); ::breakpoint(); } } while (0); |
| 1437 | return TypeLong::MINUS_1; |
| 1438 | } |
| 1439 | |
| 1440 | //============================================================================= |
| 1441 | // Convience common pre-built types. |
| 1442 | const TypeInt *TypeInt::MAX; // INT_MAX |
| 1443 | const TypeInt *TypeInt::MIN; // INT_MIN |
| 1444 | const TypeInt *TypeInt::MINUS_1;// -1 |
| 1445 | const TypeInt *TypeInt::ZERO; // 0 |
| 1446 | const TypeInt *TypeInt::ONE; // 1 |
| 1447 | const TypeInt *TypeInt::BOOL; // 0 or 1, FALSE or TRUE. |
| 1448 | const TypeInt *TypeInt::CC; // -1,0 or 1, condition codes |
| 1449 | const TypeInt *TypeInt::CC_LT; // [-1] == MINUS_1 |
| 1450 | const TypeInt *TypeInt::CC_GT; // [1] == ONE |
| 1451 | const TypeInt *TypeInt::CC_EQ; // [0] == ZERO |
| 1452 | const TypeInt *TypeInt::CC_LE; // [-1,0] |
| 1453 | const TypeInt *TypeInt::CC_GE; // [0,1] == BOOL (!) |
| 1454 | const TypeInt *TypeInt::BYTE; // Bytes, -128 to 127 |
| 1455 | const TypeInt *TypeInt::UBYTE; // Unsigned Bytes, 0 to 255 |
| 1456 | const TypeInt *TypeInt::CHAR; // Java chars, 0-65535 |
| 1457 | const TypeInt *TypeInt::SHORT; // Java shorts, -32768-32767 |
| 1458 | const TypeInt *TypeInt::POS; // Positive 32-bit integers or zero |
| 1459 | const TypeInt *TypeInt::POS1; // Positive 32-bit integers |
| 1460 | const TypeInt *TypeInt::INT; // 32-bit integers |
| 1461 | const TypeInt *TypeInt::SYMINT; // symmetric range [-max_jint..max_jint] |
| 1462 | const TypeInt *TypeInt::TYPE_DOMAIN; // alias for TypeInt::INT |
| 1463 | |
| 1464 | //------------------------------TypeInt---------------------------------------- |
| 1465 | TypeInt::TypeInt( jint lo, jint hi, int w ) : TypeInteger(Int), _lo(lo), _hi(hi), _widen(w) { |
| 1466 | } |
| 1467 | |
| 1468 | //------------------------------make------------------------------------------- |
| 1469 | const TypeInt *TypeInt::make( jint lo ) { |
| 1470 | return (TypeInt*)(new TypeInt(lo,lo,WidenMin))->hashcons(); |
| 1471 | } |
| 1472 | |
| 1473 | static int normalize_int_widen( jint lo, jint hi, int w ) { |
| 1474 | // Certain normalizations keep us sane when comparing types. |
| 1475 | // The 'SMALLINT' covers constants and also CC and its relatives. |
| 1476 | if (lo <= hi) { |
| 1477 | if (((juint)hi - lo) <= SMALLINT((juint)3)) w = Type::WidenMin; |
| 1478 | if (((juint)hi - lo) >= max_juint) w = Type::WidenMax; // TypeInt::INT |
| 1479 | } else { |
| 1480 | if (((juint)lo - hi) <= SMALLINT((juint)3)) w = Type::WidenMin; |
| 1481 | if (((juint)lo - hi) >= max_juint) w = Type::WidenMin; // dual TypeInt::INT |
| 1482 | } |
| 1483 | return w; |
| 1484 | } |
| 1485 | |
| 1486 | const TypeInt *TypeInt::make( jint lo, jint hi, int w ) { |
| 1487 | w = normalize_int_widen(lo, hi, w); |
| 1488 | return (TypeInt*)(new TypeInt(lo,hi,w))->hashcons(); |
| 1489 | } |
| 1490 | |
| 1491 | //------------------------------meet------------------------------------------- |
| 1492 | // Compute the MEET of two types. It returns a new Type representation object |
| 1493 | // with reference count equal to the number of Types pointing at it. |
| 1494 | // Caller should wrap a Types around it. |
| 1495 | const Type *TypeInt::xmeet( const Type *t ) const { |
| 1496 | // Perform a fast test for common case; meeting the same types together. |
| 1497 | if( this == t ) return this; // Meeting same type? |
| 1498 | |
| 1499 | // Currently "this->_base" is a TypeInt |
| 1500 | switch (t->base()) { // Switch on original type |
| 1501 | case AnyPtr: // Mixing with oops happens when javac |
| 1502 | case RawPtr: // reuses local variables |
| 1503 | case OopPtr: |
| 1504 | case InstPtr: |
| 1505 | case AryPtr: |
| 1506 | case MetadataPtr: |
| 1507 | case KlassPtr: |
| 1508 | case InstKlassPtr: |
| 1509 | case AryKlassPtr: |
| 1510 | case NarrowOop: |
| 1511 | case NarrowKlass: |
| 1512 | case Long: |
| 1513 | case FloatTop: |
| 1514 | case FloatCon: |
| 1515 | case FloatBot: |
| 1516 | case DoubleTop: |
| 1517 | case DoubleCon: |
| 1518 | case DoubleBot: |
| 1519 | case Bottom: // Ye Olde Default |
| 1520 | return Type::BOTTOM; |
| 1521 | default: // All else is a mistake |
| 1522 | typerr(t); |
| 1523 | case Top: // No change |
| 1524 | return this; |
| 1525 | case Int: // Int vs Int? |
| 1526 | break; |
| 1527 | } |
| 1528 | |
| 1529 | // Expand covered set |
| 1530 | const TypeInt *r = t->is_int(); |
| 1531 | return make( MIN2(_lo,r->_lo), MAX2(_hi,r->_hi), MAX2(_widen,r->_widen) ); |
| 1532 | } |
| 1533 | |
| 1534 | //------------------------------xdual------------------------------------------ |
| 1535 | // Dual: reverse hi & lo; flip widen |
| 1536 | const Type *TypeInt::xdual() const { |
| 1537 | int w = normalize_int_widen(_hi,_lo, WidenMax-_widen); |
| 1538 | return new TypeInt(_hi,_lo,w); |
| 1539 | } |
| 1540 | |
| 1541 | //------------------------------widen------------------------------------------ |
| 1542 | // Only happens for optimistic top-down optimizations. |
| 1543 | const Type *TypeInt::widen( const Type *old, const Type* limit ) const { |
| 1544 | // Coming from TOP or such; no widening |
| 1545 | if( old->base() != Int ) return this; |
| 1546 | const TypeInt *ot = old->is_int(); |
| 1547 | |
| 1548 | // If new guy is equal to old guy, no widening |
| 1549 | if( _lo == ot->_lo && _hi == ot->_hi ) |
| 1550 | return old; |
| 1551 | |
| 1552 | // If new guy contains old, then we widened |
| 1553 | if( _lo <= ot->_lo && _hi >= ot->_hi ) { |
| 1554 | // New contains old |
| 1555 | // If new guy is already wider than old, no widening |
| 1556 | if( _widen > ot->_widen ) return this; |
| 1557 | // If old guy was a constant, do not bother |
| 1558 | if (ot->_lo == ot->_hi) return this; |
| 1559 | // Now widen new guy. |
| 1560 | // Check for widening too far |
| 1561 | if (_widen == WidenMax) { |
| 1562 | int max = max_jint; |
| 1563 | int min = min_jint; |
| 1564 | if (limit->isa_int()) { |
| 1565 | max = limit->is_int()->_hi; |
| 1566 | min = limit->is_int()->_lo; |
| 1567 | } |
| 1568 | if (min < _lo && _hi < max) { |
| 1569 | // If neither endpoint is extremal yet, push out the endpoint |
| 1570 | // which is closer to its respective limit. |
| 1571 | if (_lo >= 0 || // easy common case |
| 1572 | (juint)(_lo - min) >= (juint)(max - _hi)) { |
| 1573 | // Try to widen to an unsigned range type of 31 bits: |
| 1574 | return make(_lo, max, WidenMax); |
| 1575 | } else { |
| 1576 | return make(min, _hi, WidenMax); |
| 1577 | } |
| 1578 | } |
| 1579 | return TypeInt::INT; |
| 1580 | } |
| 1581 | // Returned widened new guy |
| 1582 | return make(_lo,_hi,_widen+1); |
| 1583 | } |
| 1584 | |
| 1585 | // If old guy contains new, then we probably widened too far & dropped to |
| 1586 | // bottom. Return the wider fellow. |
| 1587 | if ( ot->_lo <= _lo && ot->_hi >= _hi ) |
| 1588 | return old; |
| 1589 | |
| 1590 | //fatal("Integer value range is not subset"); |
| 1591 | //return this; |
| 1592 | return TypeInt::INT; |
| 1593 | } |
| 1594 | |
| 1595 | //------------------------------narrow--------------------------------------- |
| 1596 | // Only happens for pessimistic optimizations. |
| 1597 | const Type *TypeInt::narrow( const Type *old ) const { |
| 1598 | if (_lo >= _hi) return this; // already narrow enough |
| 1599 | if (old == NULL__null) return this; |
| 1600 | const TypeInt* ot = old->isa_int(); |
| 1601 | if (ot == NULL__null) return this; |
| 1602 | jint olo = ot->_lo; |
| 1603 | jint ohi = ot->_hi; |
| 1604 | |
| 1605 | // If new guy is equal to old guy, no narrowing |
| 1606 | if (_lo == olo && _hi == ohi) return old; |
| 1607 | |
| 1608 | // If old guy was maximum range, allow the narrowing |
| 1609 | if (olo == min_jint && ohi == max_jint) return this; |
| 1610 | |
| 1611 | if (_lo < olo || _hi > ohi) |
| 1612 | return this; // doesn't narrow; pretty wierd |
| 1613 | |
| 1614 | // The new type narrows the old type, so look for a "death march". |
| 1615 | // See comments on PhaseTransform::saturate. |
| 1616 | juint nrange = (juint)_hi - _lo; |
| 1617 | juint orange = (juint)ohi - olo; |
| 1618 | if (nrange < max_juint - 1 && nrange > (orange >> 1) + (SMALLINT((juint)3)*2)) { |
| 1619 | // Use the new type only if the range shrinks a lot. |
| 1620 | // We do not want the optimizer computing 2^31 point by point. |
| 1621 | return old; |
| 1622 | } |
| 1623 | |
| 1624 | return this; |
| 1625 | } |
| 1626 | |
| 1627 | //-----------------------------filter------------------------------------------ |
| 1628 | const Type *TypeInt::filter_helper(const Type *kills, bool include_speculative) const { |
| 1629 | const TypeInt* ft = join_helper(kills, include_speculative)->isa_int(); |
| 1630 | if (ft == NULL__null || ft->empty()) |
| 1631 | return Type::TOP; // Canonical empty value |
| 1632 | if (ft->_widen < this->_widen) { |
| 1633 | // Do not allow the value of kill->_widen to affect the outcome. |
| 1634 | // The widen bits must be allowed to run freely through the graph. |
| 1635 | ft = TypeInt::make(ft->_lo, ft->_hi, this->_widen); |
| 1636 | } |
| 1637 | return ft; |
| 1638 | } |
| 1639 | |
| 1640 | //------------------------------eq--------------------------------------------- |
| 1641 | // Structural equality check for Type representations |
| 1642 | bool TypeInt::eq( const Type *t ) const { |
| 1643 | const TypeInt *r = t->is_int(); // Handy access |
| 1644 | return r->_lo == _lo && r->_hi == _hi && r->_widen == _widen; |
| 1645 | } |
| 1646 | |
| 1647 | //------------------------------hash------------------------------------------- |
| 1648 | // Type-specific hashing function. |
| 1649 | int TypeInt::hash(void) const { |
| 1650 | return java_add(java_add(_lo, _hi), java_add((jint)_widen, (jint)Type::Int)); |
| 1651 | } |
| 1652 | |
| 1653 | //------------------------------is_finite-------------------------------------- |
| 1654 | // Has a finite value |
| 1655 | bool TypeInt::is_finite() const { |
| 1656 | return true; |
| 1657 | } |
| 1658 | |
| 1659 | //------------------------------dump2------------------------------------------ |
| 1660 | // Dump TypeInt |
| 1661 | #ifndef PRODUCT |
| 1662 | static const char* intname(char* buf, jint n) { |
| 1663 | if (n == min_jint) |
| 1664 | return "min"; |
| 1665 | else if (n < min_jint + 10000) |
| 1666 | sprintf(buf, "min+" INT32_FORMAT"%" "d", n - min_jint); |
| 1667 | else if (n == max_jint) |
| 1668 | return "max"; |
| 1669 | else if (n > max_jint - 10000) |
| 1670 | sprintf(buf, "max-" INT32_FORMAT"%" "d", max_jint - n); |
| 1671 | else |
| 1672 | sprintf(buf, INT32_FORMAT"%" "d", n); |
| 1673 | return buf; |
| 1674 | } |
| 1675 | |
| 1676 | void TypeInt::dump2( Dict &d, uint depth, outputStream *st ) const { |
| 1677 | char buf[40], buf2[40]; |
| 1678 | if (_lo == min_jint && _hi == max_jint) |
| 1679 | st->print("int"); |
| 1680 | else if (is_con()) |
| 1681 | st->print("int:%s", intname(buf, get_con())); |
| 1682 | else if (_lo == BOOL->_lo && _hi == BOOL->_hi) |
| 1683 | st->print("bool"); |
| 1684 | else if (_lo == BYTE->_lo && _hi == BYTE->_hi) |
| 1685 | st->print("byte"); |
| 1686 | else if (_lo == CHAR->_lo && _hi == CHAR->_hi) |
| 1687 | st->print("char"); |
| 1688 | else if (_lo == SHORT->_lo && _hi == SHORT->_hi) |
| 1689 | st->print("short"); |
| 1690 | else if (_hi == max_jint) |
| 1691 | st->print("int:>=%s", intname(buf, _lo)); |
| 1692 | else if (_lo == min_jint) |
| 1693 | st->print("int:<=%s", intname(buf, _hi)); |
| 1694 | else |
| 1695 | st->print("int:%s..%s", intname(buf, _lo), intname(buf2, _hi)); |
| 1696 | |
| 1697 | if (_widen != 0 && this != TypeInt::INT) |
| 1698 | st->print(":%.*s", _widen, "wwww"); |
| 1699 | } |
| 1700 | #endif |
| 1701 | |
| 1702 | //------------------------------singleton-------------------------------------- |
| 1703 | // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple |
| 1704 | // constants. |
| 1705 | bool TypeInt::singleton(void) const { |
| 1706 | return _lo >= _hi; |
| 1707 | } |
| 1708 | |
| 1709 | bool TypeInt::empty(void) const { |
| 1710 | return _lo > _hi; |
| 1711 | } |
| 1712 | |
| 1713 | //============================================================================= |
| 1714 | // Convenience common pre-built types. |
| 1715 | const TypeLong *TypeLong::MAX; |
| 1716 | const TypeLong *TypeLong::MIN; |
| 1717 | const TypeLong *TypeLong::MINUS_1;// -1 |
| 1718 | const TypeLong *TypeLong::ZERO; // 0 |
| 1719 | const TypeLong *TypeLong::ONE; // 1 |
| 1720 | const TypeLong *TypeLong::POS; // >=0 |
| 1721 | const TypeLong *TypeLong::LONG; // 64-bit integers |
| 1722 | const TypeLong *TypeLong::INT; // 32-bit subrange |
| 1723 | const TypeLong *TypeLong::UINT; // 32-bit unsigned subrange |
| 1724 | const TypeLong *TypeLong::TYPE_DOMAIN; // alias for TypeLong::LONG |
| 1725 | |
| 1726 | //------------------------------TypeLong--------------------------------------- |
| 1727 | TypeLong::TypeLong(jlong lo, jlong hi, int w) : TypeInteger(Long), _lo(lo), _hi(hi), _widen(w) { |
| 1728 | } |
| 1729 | |
| 1730 | //------------------------------make------------------------------------------- |
| 1731 | const TypeLong *TypeLong::make( jlong lo ) { |
| 1732 | return (TypeLong*)(new TypeLong(lo,lo,WidenMin))->hashcons(); |
| 1733 | } |
| 1734 | |
| 1735 | static int normalize_long_widen( jlong lo, jlong hi, int w ) { |
| 1736 | // Certain normalizations keep us sane when comparing types. |
| 1737 | // The 'SMALLINT' covers constants. |
| 1738 | if (lo <= hi) { |
| 1739 | if (((julong)hi - lo) <= SMALLINT((juint)3)) w = Type::WidenMin; |
| 1740 | if (((julong)hi - lo) >= max_julong) w = Type::WidenMax; // TypeLong::LONG |
| 1741 | } else { |
| 1742 | if (((julong)lo - hi) <= SMALLINT((juint)3)) w = Type::WidenMin; |
| 1743 | if (((julong)lo - hi) >= max_julong) w = Type::WidenMin; // dual TypeLong::LONG |
| 1744 | } |
| 1745 | return w; |
| 1746 | } |
| 1747 | |
| 1748 | const TypeLong *TypeLong::make( jlong lo, jlong hi, int w ) { |
| 1749 | w = normalize_long_widen(lo, hi, w); |
| 1750 | return (TypeLong*)(new TypeLong(lo,hi,w))->hashcons(); |
| 1751 | } |
| 1752 | |
| 1753 | |
| 1754 | //------------------------------meet------------------------------------------- |
| 1755 | // Compute the MEET of two types. It returns a new Type representation object |
| 1756 | // with reference count equal to the number of Types pointing at it. |
| 1757 | // Caller should wrap a Types around it. |
| 1758 | const Type *TypeLong::xmeet( const Type *t ) const { |
| 1759 | // Perform a fast test for common case; meeting the same types together. |
| 1760 | if( this == t ) return this; // Meeting same type? |
| 1761 | |
| 1762 | // Currently "this->_base" is a TypeLong |
| 1763 | switch (t->base()) { // Switch on original type |
| 1764 | case AnyPtr: // Mixing with oops happens when javac |
| 1765 | case RawPtr: // reuses local variables |
| 1766 | case OopPtr: |
| 1767 | case InstPtr: |
| 1768 | case AryPtr: |
| 1769 | case MetadataPtr: |
| 1770 | case KlassPtr: |
| 1771 | case InstKlassPtr: |
| 1772 | case AryKlassPtr: |
| 1773 | case NarrowOop: |
| 1774 | case NarrowKlass: |
| 1775 | case Int: |
| 1776 | case FloatTop: |
| 1777 | case FloatCon: |
| 1778 | case FloatBot: |
| 1779 | case DoubleTop: |
| 1780 | case DoubleCon: |
| 1781 | case DoubleBot: |
| 1782 | case Bottom: // Ye Olde Default |
| 1783 | return Type::BOTTOM; |
| 1784 | default: // All else is a mistake |
| 1785 | typerr(t); |
| 1786 | case Top: // No change |
| 1787 | return this; |
| 1788 | case Long: // Long vs Long? |
| 1789 | break; |
| 1790 | } |
| 1791 | |
| 1792 | // Expand covered set |
| 1793 | const TypeLong *r = t->is_long(); // Turn into a TypeLong |
| 1794 | return make( MIN2(_lo,r->_lo), MAX2(_hi,r->_hi), MAX2(_widen,r->_widen) ); |
| 1795 | } |
| 1796 | |
| 1797 | //------------------------------xdual------------------------------------------ |
| 1798 | // Dual: reverse hi & lo; flip widen |
| 1799 | const Type *TypeLong::xdual() const { |
| 1800 | int w = normalize_long_widen(_hi,_lo, WidenMax-_widen); |
| 1801 | return new TypeLong(_hi,_lo,w); |
| 1802 | } |
| 1803 | |
| 1804 | //------------------------------widen------------------------------------------ |
| 1805 | // Only happens for optimistic top-down optimizations. |
| 1806 | const Type *TypeLong::widen( const Type *old, const Type* limit ) const { |
| 1807 | // Coming from TOP or such; no widening |
| 1808 | if( old->base() != Long ) return this; |
| 1809 | const TypeLong *ot = old->is_long(); |
| 1810 | |
| 1811 | // If new guy is equal to old guy, no widening |
| 1812 | if( _lo == ot->_lo && _hi == ot->_hi ) |
| 1813 | return old; |
| 1814 | |
| 1815 | // If new guy contains old, then we widened |
| 1816 | if( _lo <= ot->_lo && _hi >= ot->_hi ) { |
| 1817 | // New contains old |
| 1818 | // If new guy is already wider than old, no widening |
| 1819 | if( _widen > ot->_widen ) return this; |
| 1820 | // If old guy was a constant, do not bother |
| 1821 | if (ot->_lo == ot->_hi) return this; |
| 1822 | // Now widen new guy. |
| 1823 | // Check for widening too far |
| 1824 | if (_widen == WidenMax) { |
| 1825 | jlong max = max_jlong; |
| 1826 | jlong min = min_jlong; |
| 1827 | if (limit->isa_long()) { |
| 1828 | max = limit->is_long()->_hi; |
| 1829 | min = limit->is_long()->_lo; |
| 1830 | } |
| 1831 | if (min < _lo && _hi < max) { |
| 1832 | // If neither endpoint is extremal yet, push out the endpoint |
| 1833 | // which is closer to its respective limit. |
| 1834 | if (_lo >= 0 || // easy common case |
| 1835 | ((julong)_lo - min) >= ((julong)max - _hi)) { |
| 1836 | // Try to widen to an unsigned range type of 32/63 bits: |
| 1837 | if (max >= max_juint && _hi < max_juint) |
| 1838 | return make(_lo, max_juint, WidenMax); |
| 1839 | else |
| 1840 | return make(_lo, max, WidenMax); |
| 1841 | } else { |
| 1842 | return make(min, _hi, WidenMax); |
| 1843 | } |
| 1844 | } |
| 1845 | return TypeLong::LONG; |
| 1846 | } |
| 1847 | // Returned widened new guy |
| 1848 | return make(_lo,_hi,_widen+1); |
| 1849 | } |
| 1850 | |
| 1851 | // If old guy contains new, then we probably widened too far & dropped to |
| 1852 | // bottom. Return the wider fellow. |
| 1853 | if ( ot->_lo <= _lo && ot->_hi >= _hi ) |
| 1854 | return old; |
| 1855 | |
| 1856 | // fatal("Long value range is not subset"); |
| 1857 | // return this; |
| 1858 | return TypeLong::LONG; |
| 1859 | } |
| 1860 | |
| 1861 | //------------------------------narrow---------------------------------------- |
| 1862 | // Only happens for pessimistic optimizations. |
| 1863 | const Type *TypeLong::narrow( const Type *old ) const { |
| 1864 | if (_lo >= _hi) return this; // already narrow enough |
| 1865 | if (old == NULL__null) return this; |
| 1866 | const TypeLong* ot = old->isa_long(); |
| 1867 | if (ot == NULL__null) return this; |
| 1868 | jlong olo = ot->_lo; |
| 1869 | jlong ohi = ot->_hi; |
| 1870 | |
| 1871 | // If new guy is equal to old guy, no narrowing |
| 1872 | if (_lo == olo && _hi == ohi) return old; |
| 1873 | |
| 1874 | // If old guy was maximum range, allow the narrowing |
| 1875 | if (olo == min_jlong && ohi == max_jlong) return this; |
| 1876 | |
| 1877 | if (_lo < olo || _hi > ohi) |
| 1878 | return this; // doesn't narrow; pretty wierd |
| 1879 | |
| 1880 | // The new type narrows the old type, so look for a "death march". |
| 1881 | // See comments on PhaseTransform::saturate. |
| 1882 | julong nrange = _hi - _lo; |
| 1883 | julong orange = ohi - olo; |
| 1884 | if (nrange < max_julong - 1 && nrange > (orange >> 1) + (SMALLINT((juint)3)*2)) { |
| 1885 | // Use the new type only if the range shrinks a lot. |
| 1886 | // We do not want the optimizer computing 2^31 point by point. |
| 1887 | return old; |
| 1888 | } |
| 1889 | |
| 1890 | return this; |
| 1891 | } |
| 1892 | |
| 1893 | //-----------------------------filter------------------------------------------ |
| 1894 | const Type *TypeLong::filter_helper(const Type *kills, bool include_speculative) const { |
| 1895 | const TypeLong* ft = join_helper(kills, include_speculative)->isa_long(); |
| 1896 | if (ft == NULL__null || ft->empty()) |
| 1897 | return Type::TOP; // Canonical empty value |
| 1898 | if (ft->_widen < this->_widen) { |
| 1899 | // Do not allow the value of kill->_widen to affect the outcome. |
| 1900 | // The widen bits must be allowed to run freely through the graph. |
| 1901 | ft = TypeLong::make(ft->_lo, ft->_hi, this->_widen); |
| 1902 | } |
| 1903 | return ft; |
| 1904 | } |
| 1905 | |
| 1906 | //------------------------------eq--------------------------------------------- |
| 1907 | // Structural equality check for Type representations |
| 1908 | bool TypeLong::eq( const Type *t ) const { |
| 1909 | const TypeLong *r = t->is_long(); // Handy access |
| 1910 | return r->_lo == _lo && r->_hi == _hi && r->_widen == _widen; |
| 1911 | } |
| 1912 | |
| 1913 | //------------------------------hash------------------------------------------- |
| 1914 | // Type-specific hashing function. |
| 1915 | int TypeLong::hash(void) const { |
| 1916 | return (int)(_lo+_hi+_widen+(int)Type::Long); |
| 1917 | } |
| 1918 | |
| 1919 | //------------------------------is_finite-------------------------------------- |
| 1920 | // Has a finite value |
| 1921 | bool TypeLong::is_finite() const { |
| 1922 | return true; |
| 1923 | } |
| 1924 | |
| 1925 | //------------------------------dump2------------------------------------------ |
| 1926 | // Dump TypeLong |
| 1927 | #ifndef PRODUCT |
| 1928 | static const char* longnamenear(jlong x, const char* xname, char* buf, jlong n) { |
| 1929 | if (n > x) { |
| 1930 | if (n >= x + 10000) return NULL__null; |
| 1931 | sprintf(buf, "%s+" JLONG_FORMAT"%" "l" "d", xname, n - x); |
| 1932 | } else if (n < x) { |
| 1933 | if (n <= x - 10000) return NULL__null; |
| 1934 | sprintf(buf, "%s-" JLONG_FORMAT"%" "l" "d", xname, x - n); |
| 1935 | } else { |
| 1936 | return xname; |
| 1937 | } |
| 1938 | return buf; |
| 1939 | } |
| 1940 | |
| 1941 | static const char* longname(char* buf, jlong n) { |
| 1942 | const char* str; |
| 1943 | if (n == min_jlong) |
| 1944 | return "min"; |
| 1945 | else if (n < min_jlong + 10000) |
| 1946 | sprintf(buf, "min+" JLONG_FORMAT"%" "l" "d", n - min_jlong); |
| 1947 | else if (n == max_jlong) |
| 1948 | return "max"; |
| 1949 | else if (n > max_jlong - 10000) |
| 1950 | sprintf(buf, "max-" JLONG_FORMAT"%" "l" "d", max_jlong - n); |
| 1951 | else if ((str = longnamenear(max_juint, "maxuint", buf, n)) != NULL__null) |
| 1952 | return str; |
| 1953 | else if ((str = longnamenear(max_jint, "maxint", buf, n)) != NULL__null) |
| 1954 | return str; |
| 1955 | else if ((str = longnamenear(min_jint, "minint", buf, n)) != NULL__null) |
| 1956 | return str; |
| 1957 | else |
| 1958 | sprintf(buf, JLONG_FORMAT"%" "l" "d", n); |
| 1959 | return buf; |
| 1960 | } |
| 1961 | |
| 1962 | void TypeLong::dump2( Dict &d, uint depth, outputStream *st ) const { |
| 1963 | char buf[80], buf2[80]; |
| 1964 | if (_lo == min_jlong && _hi == max_jlong) |
| 1965 | st->print("long"); |
| 1966 | else if (is_con()) |
| 1967 | st->print("long:%s", longname(buf, get_con())); |
| 1968 | else if (_hi == max_jlong) |
| 1969 | st->print("long:>=%s", longname(buf, _lo)); |
| 1970 | else if (_lo == min_jlong) |
| 1971 | st->print("long:<=%s", longname(buf, _hi)); |
| 1972 | else |
| 1973 | st->print("long:%s..%s", longname(buf, _lo), longname(buf2, _hi)); |
| 1974 | |
| 1975 | if (_widen != 0 && this != TypeLong::LONG) |
| 1976 | st->print(":%.*s", _widen, "wwww"); |
| 1977 | } |
| 1978 | #endif |
| 1979 | |
| 1980 | //------------------------------singleton-------------------------------------- |
| 1981 | // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple |
| 1982 | // constants |
| 1983 | bool TypeLong::singleton(void) const { |
| 1984 | return _lo >= _hi; |
| 1985 | } |
| 1986 | |
| 1987 | bool TypeLong::empty(void) const { |
| 1988 | return _lo > _hi; |
| 1989 | } |
| 1990 | |
| 1991 | //============================================================================= |
| 1992 | // Convenience common pre-built types. |
| 1993 | const TypeTuple *TypeTuple::IFBOTH; // Return both arms of IF as reachable |
| 1994 | const TypeTuple *TypeTuple::IFFALSE; |
| 1995 | const TypeTuple *TypeTuple::IFTRUE; |
| 1996 | const TypeTuple *TypeTuple::IFNEITHER; |
| 1997 | const TypeTuple *TypeTuple::LOOPBODY; |
| 1998 | const TypeTuple *TypeTuple::MEMBAR; |
| 1999 | const TypeTuple *TypeTuple::STORECONDITIONAL; |
| 2000 | const TypeTuple *TypeTuple::START_I2C; |
| 2001 | const TypeTuple *TypeTuple::INT_PAIR; |
| 2002 | const TypeTuple *TypeTuple::LONG_PAIR; |
| 2003 | const TypeTuple *TypeTuple::INT_CC_PAIR; |
| 2004 | const TypeTuple *TypeTuple::LONG_CC_PAIR; |
| 2005 | |
| 2006 | //------------------------------make------------------------------------------- |
| 2007 | // Make a TypeTuple from the range of a method signature |
| 2008 | const TypeTuple *TypeTuple::make_range(ciSignature* sig) { |
| 2009 | ciType* return_type = sig->return_type(); |
| 2010 | uint arg_cnt = return_type->size(); |
| 2011 | const Type **field_array = fields(arg_cnt); |
| 2012 | switch (return_type->basic_type()) { |
| 2013 | case T_LONG: |
| 2014 | field_array[TypeFunc::Parms] = TypeLong::LONG; |
| 2015 | field_array[TypeFunc::Parms+1] = Type::HALF; |
| 2016 | break; |
| 2017 | case T_DOUBLE: |
| 2018 | field_array[TypeFunc::Parms] = Type::DOUBLE; |
| 2019 | field_array[TypeFunc::Parms+1] = Type::HALF; |
| 2020 | break; |
| 2021 | case T_OBJECT: |
| 2022 | case T_ARRAY: |
| 2023 | case T_BOOLEAN: |
| 2024 | case T_CHAR: |
| 2025 | case T_FLOAT: |
| 2026 | case T_BYTE: |
| 2027 | case T_SHORT: |
| 2028 | case T_INT: |
| 2029 | field_array[TypeFunc::Parms] = get_const_type(return_type); |
| 2030 | break; |
| 2031 | case T_VOID: |
| 2032 | break; |
| 2033 | default: |
| 2034 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2034); ::breakpoint(); } while (0); |
| 2035 | } |
| 2036 | return (TypeTuple*)(new TypeTuple(TypeFunc::Parms + arg_cnt, field_array))->hashcons(); |
| 2037 | } |
| 2038 | |
| 2039 | // Make a TypeTuple from the domain of a method signature |
| 2040 | const TypeTuple *TypeTuple::make_domain(ciInstanceKlass* recv, ciSignature* sig) { |
| 2041 | uint arg_cnt = sig->size(); |
| 2042 | |
| 2043 | uint pos = TypeFunc::Parms; |
| 2044 | const Type **field_array; |
| 2045 | if (recv != NULL__null) { |
| 2046 | arg_cnt++; |
| 2047 | field_array = fields(arg_cnt); |
| 2048 | // Use get_const_type here because it respects UseUniqueSubclasses: |
| 2049 | field_array[pos++] = get_const_type(recv)->join_speculative(TypePtr::NOTNULL); |
| 2050 | } else { |
| 2051 | field_array = fields(arg_cnt); |
| 2052 | } |
| 2053 | |
| 2054 | int i = 0; |
| 2055 | while (pos < TypeFunc::Parms + arg_cnt) { |
| 2056 | ciType* type = sig->type_at(i); |
| 2057 | |
| 2058 | switch (type->basic_type()) { |
| 2059 | case T_LONG: |
| 2060 | field_array[pos++] = TypeLong::LONG; |
| 2061 | field_array[pos++] = Type::HALF; |
| 2062 | break; |
| 2063 | case T_DOUBLE: |
| 2064 | field_array[pos++] = Type::DOUBLE; |
| 2065 | field_array[pos++] = Type::HALF; |
| 2066 | break; |
| 2067 | case T_OBJECT: |
| 2068 | case T_ARRAY: |
| 2069 | case T_FLOAT: |
| 2070 | case T_INT: |
| 2071 | field_array[pos++] = get_const_type(type); |
| 2072 | break; |
| 2073 | case T_BOOLEAN: |
| 2074 | case T_CHAR: |
| 2075 | case T_BYTE: |
| 2076 | case T_SHORT: |
| 2077 | field_array[pos++] = TypeInt::INT; |
| 2078 | break; |
| 2079 | default: |
| 2080 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2080); ::breakpoint(); } while (0); |
| 2081 | } |
| 2082 | i++; |
| 2083 | } |
| 2084 | |
| 2085 | return (TypeTuple*)(new TypeTuple(TypeFunc::Parms + arg_cnt, field_array))->hashcons(); |
| 2086 | } |
| 2087 | |
| 2088 | const TypeTuple *TypeTuple::make( uint cnt, const Type **fields ) { |
| 2089 | return (TypeTuple*)(new TypeTuple(cnt,fields))->hashcons(); |
| 2090 | } |
| 2091 | |
| 2092 | //------------------------------fields----------------------------------------- |
| 2093 | // Subroutine call type with space allocated for argument types |
| 2094 | // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly |
| 2095 | const Type **TypeTuple::fields( uint arg_cnt ) { |
| 2096 | const Type **flds = (const Type **)(Compile::current()->type_arena()->AmallocWords((TypeFunc::Parms+arg_cnt)*sizeof(Type*) )); |
| 2097 | flds[TypeFunc::Control ] = Type::CONTROL; |
| 2098 | flds[TypeFunc::I_O ] = Type::ABIO; |
| 2099 | flds[TypeFunc::Memory ] = Type::MEMORY; |
| 2100 | flds[TypeFunc::FramePtr ] = TypeRawPtr::BOTTOM; |
| 2101 | flds[TypeFunc::ReturnAdr] = Type::RETURN_ADDRESS; |
| 2102 | |
| 2103 | return flds; |
| 2104 | } |
| 2105 | |
| 2106 | //------------------------------meet------------------------------------------- |
| 2107 | // Compute the MEET of two types. It returns a new Type object. |
| 2108 | const Type *TypeTuple::xmeet( const Type *t ) const { |
| 2109 | // Perform a fast test for common case; meeting the same types together. |
| 2110 | if( this == t ) return this; // Meeting same type-rep? |
| 2111 | |
| 2112 | // Current "this->_base" is Tuple |
| 2113 | switch (t->base()) { // switch on original type |
| 2114 | |
| 2115 | case Bottom: // Ye Olde Default |
| 2116 | return t; |
| 2117 | |
| 2118 | default: // All else is a mistake |
| 2119 | typerr(t); |
| 2120 | |
| 2121 | case Tuple: { // Meeting 2 signatures? |
| 2122 | const TypeTuple *x = t->is_tuple(); |
| 2123 | assert( _cnt == x->_cnt, "" )do { if (!(_cnt == x->_cnt)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2123, "assert(" "_cnt == x->_cnt" ") failed", ""); ::breakpoint (); } } while (0); |
| 2124 | const Type **fields = (const Type **)(Compile::current()->type_arena()->AmallocWords( _cnt*sizeof(Type*) )); |
| 2125 | for( uint i=0; i<_cnt; i++ ) |
| 2126 | fields[i] = field_at(i)->xmeet( x->field_at(i) ); |
| 2127 | return TypeTuple::make(_cnt,fields); |
| 2128 | } |
| 2129 | case Top: |
| 2130 | break; |
| 2131 | } |
| 2132 | return this; // Return the double constant |
| 2133 | } |
| 2134 | |
| 2135 | //------------------------------xdual------------------------------------------ |
| 2136 | // Dual: compute field-by-field dual |
| 2137 | const Type *TypeTuple::xdual() const { |
| 2138 | const Type **fields = (const Type **)(Compile::current()->type_arena()->AmallocWords( _cnt*sizeof(Type*) )); |
| 2139 | for( uint i=0; i<_cnt; i++ ) |
| 2140 | fields[i] = _fields[i]->dual(); |
| 2141 | return new TypeTuple(_cnt,fields); |
| 2142 | } |
| 2143 | |
| 2144 | //------------------------------eq--------------------------------------------- |
| 2145 | // Structural equality check for Type representations |
| 2146 | bool TypeTuple::eq( const Type *t ) const { |
| 2147 | const TypeTuple *s = (const TypeTuple *)t; |
| 2148 | if (_cnt != s->_cnt) return false; // Unequal field counts |
| 2149 | for (uint i = 0; i < _cnt; i++) |
| 2150 | if (field_at(i) != s->field_at(i)) // POINTER COMPARE! NO RECURSION! |
| 2151 | return false; // Missed |
| 2152 | return true; |
| 2153 | } |
| 2154 | |
| 2155 | //------------------------------hash------------------------------------------- |
| 2156 | // Type-specific hashing function. |
| 2157 | int TypeTuple::hash(void) const { |
| 2158 | intptr_t sum = _cnt; |
| 2159 | for( uint i=0; i<_cnt; i++ ) |
| 2160 | sum += (intptr_t)_fields[i]; // Hash on pointers directly |
| 2161 | return sum; |
| 2162 | } |
| 2163 | |
| 2164 | //------------------------------dump2------------------------------------------ |
| 2165 | // Dump signature Type |
| 2166 | #ifndef PRODUCT |
| 2167 | void TypeTuple::dump2( Dict &d, uint depth, outputStream *st ) const { |
| 2168 | st->print("{"); |
| 2169 | if( !depth || d[this] ) { // Check for recursive print |
| 2170 | st->print("...}"); |
| 2171 | return; |
| 2172 | } |
| 2173 | d.Insert((void*)this, (void*)this); // Stop recursion |
| 2174 | if( _cnt ) { |
| 2175 | uint i; |
| 2176 | for( i=0; i<_cnt-1; i++ ) { |
| 2177 | st->print("%d:", i); |
| 2178 | _fields[i]->dump2(d, depth-1, st); |
| 2179 | st->print(", "); |
| 2180 | } |
| 2181 | st->print("%d:", i); |
| 2182 | _fields[i]->dump2(d, depth-1, st); |
| 2183 | } |
| 2184 | st->print("}"); |
| 2185 | } |
| 2186 | #endif |
| 2187 | |
| 2188 | //------------------------------singleton-------------------------------------- |
| 2189 | // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple |
| 2190 | // constants (Ldi nodes). Singletons are integer, float or double constants |
| 2191 | // or a single symbol. |
| 2192 | bool TypeTuple::singleton(void) const { |
| 2193 | return false; // Never a singleton |
| 2194 | } |
| 2195 | |
| 2196 | bool TypeTuple::empty(void) const { |
| 2197 | for( uint i=0; i<_cnt; i++ ) { |
| 2198 | if (_fields[i]->empty()) return true; |
| 2199 | } |
| 2200 | return false; |
| 2201 | } |
| 2202 | |
| 2203 | //============================================================================= |
| 2204 | // Convenience common pre-built types. |
| 2205 | |
| 2206 | inline const TypeInt* normalize_array_size(const TypeInt* size) { |
| 2207 | // Certain normalizations keep us sane when comparing types. |
| 2208 | // We do not want arrayOop variables to differ only by the wideness |
| 2209 | // of their index types. Pick minimum wideness, since that is the |
| 2210 | // forced wideness of small ranges anyway. |
| 2211 | if (size->_widen != Type::WidenMin) |
| 2212 | return TypeInt::make(size->_lo, size->_hi, Type::WidenMin); |
| 2213 | else |
| 2214 | return size; |
| 2215 | } |
| 2216 | |
| 2217 | //------------------------------make------------------------------------------- |
| 2218 | const TypeAry* TypeAry::make(const Type* elem, const TypeInt* size, bool stable) { |
| 2219 | if (UseCompressedOops && elem->isa_oopptr()) { |
| 2220 | elem = elem->make_narrowoop(); |
| 2221 | } |
| 2222 | size = normalize_array_size(size); |
| 2223 | return (TypeAry*)(new TypeAry(elem,size,stable))->hashcons(); |
| 2224 | } |
| 2225 | |
| 2226 | //------------------------------meet------------------------------------------- |
| 2227 | // Compute the MEET of two types. It returns a new Type object. |
| 2228 | const Type *TypeAry::xmeet( const Type *t ) const { |
| 2229 | // Perform a fast test for common case; meeting the same types together. |
| 2230 | if( this == t ) return this; // Meeting same type-rep? |
| 2231 | |
| 2232 | // Current "this->_base" is Ary |
| 2233 | switch (t->base()) { // switch on original type |
| 2234 | |
| 2235 | case Bottom: // Ye Olde Default |
| 2236 | return t; |
| 2237 | |
| 2238 | default: // All else is a mistake |
| 2239 | typerr(t); |
| 2240 | |
| 2241 | case Array: { // Meeting 2 arrays? |
| 2242 | const TypeAry *a = t->is_ary(); |
| 2243 | return TypeAry::make(_elem->meet_speculative(a->_elem), |
| 2244 | _size->xmeet(a->_size)->is_int(), |
| 2245 | _stable && a->_stable); |
| 2246 | } |
| 2247 | case Top: |
| 2248 | break; |
| 2249 | } |
| 2250 | return this; // Return the double constant |
| 2251 | } |
| 2252 | |
| 2253 | //------------------------------xdual------------------------------------------ |
| 2254 | // Dual: compute field-by-field dual |
| 2255 | const Type *TypeAry::xdual() const { |
| 2256 | const TypeInt* size_dual = _size->dual()->is_int(); |
| 2257 | size_dual = normalize_array_size(size_dual); |
| 2258 | return new TypeAry(_elem->dual(), size_dual, !_stable); |
| 2259 | } |
| 2260 | |
| 2261 | //------------------------------eq--------------------------------------------- |
| 2262 | // Structural equality check for Type representations |
| 2263 | bool TypeAry::eq( const Type *t ) const { |
| 2264 | const TypeAry *a = (const TypeAry*)t; |
| 2265 | return _elem == a->_elem && |
| 2266 | _stable == a->_stable && |
| 2267 | _size == a->_size; |
| 2268 | } |
| 2269 | |
| 2270 | //------------------------------hash------------------------------------------- |
| 2271 | // Type-specific hashing function. |
| 2272 | int TypeAry::hash(void) const { |
| 2273 | return (intptr_t)_elem + (intptr_t)_size + (_stable ? 43 : 0); |
| 2274 | } |
| 2275 | |
| 2276 | /** |
| 2277 | * Return same type without a speculative part in the element |
| 2278 | */ |
| 2279 | const Type* TypeAry::remove_speculative() const { |
| 2280 | return make(_elem->remove_speculative(), _size, _stable); |
| 2281 | } |
| 2282 | |
| 2283 | /** |
| 2284 | * Return same type with cleaned up speculative part of element |
| 2285 | */ |
| 2286 | const Type* TypeAry::cleanup_speculative() const { |
| 2287 | return make(_elem->cleanup_speculative(), _size, _stable); |
| 2288 | } |
| 2289 | |
| 2290 | /** |
| 2291 | * Return same type but with a different inline depth (used for speculation) |
| 2292 | * |
| 2293 | * @param depth depth to meet with |
| 2294 | */ |
| 2295 | const TypePtr* TypePtr::with_inline_depth(int depth) const { |
| 2296 | if (!UseInlineDepthForSpeculativeTypes) { |
| 2297 | return this; |
| 2298 | } |
| 2299 | return make(AnyPtr, _ptr, _offset, _speculative, depth); |
| 2300 | } |
| 2301 | |
| 2302 | //----------------------interface_vs_oop--------------------------------------- |
| 2303 | #ifdef ASSERT1 |
| 2304 | bool TypeAry::interface_vs_oop(const Type *t) const { |
| 2305 | const TypeAry* t_ary = t->is_ary(); |
| 2306 | if (t_ary) { |
| 2307 | const TypePtr* this_ptr = _elem->make_ptr(); // In case we have narrow_oops |
| 2308 | const TypePtr* t_ptr = t_ary->_elem->make_ptr(); |
| 2309 | if(this_ptr != NULL__null && t_ptr != NULL__null) { |
| 2310 | return this_ptr->interface_vs_oop(t_ptr); |
| 2311 | } |
| 2312 | } |
| 2313 | return false; |
| 2314 | } |
| 2315 | #endif |
| 2316 | |
| 2317 | //------------------------------dump2------------------------------------------ |
| 2318 | #ifndef PRODUCT |
| 2319 | void TypeAry::dump2( Dict &d, uint depth, outputStream *st ) const { |
| 2320 | if (_stable) st->print("stable:"); |
| 2321 | _elem->dump2(d, depth, st); |
| 2322 | st->print("["); |
| 2323 | _size->dump2(d, depth, st); |
| 2324 | st->print("]"); |
| 2325 | } |
| 2326 | #endif |
| 2327 | |
| 2328 | //------------------------------singleton-------------------------------------- |
| 2329 | // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple |
| 2330 | // constants (Ldi nodes). Singletons are integer, float or double constants |
| 2331 | // or a single symbol. |
| 2332 | bool TypeAry::singleton(void) const { |
| 2333 | return false; // Never a singleton |
| 2334 | } |
| 2335 | |
| 2336 | bool TypeAry::empty(void) const { |
| 2337 | return _elem->empty() || _size->empty(); |
| 2338 | } |
| 2339 | |
| 2340 | //--------------------------ary_must_be_exact---------------------------------- |
| 2341 | bool TypeAry::ary_must_be_exact() const { |
| 2342 | // This logic looks at the element type of an array, and returns true |
| 2343 | // if the element type is either a primitive or a final instance class. |
| 2344 | // In such cases, an array built on this ary must have no subclasses. |
| 2345 | if (_elem == BOTTOM) return false; // general array not exact |
| 2346 | if (_elem == TOP ) return false; // inverted general array not exact |
| 2347 | const TypeOopPtr* toop = NULL__null; |
| 2348 | if (UseCompressedOops && _elem->isa_narrowoop()) { |
| 2349 | toop = _elem->make_ptr()->isa_oopptr(); |
| 2350 | } else { |
| 2351 | toop = _elem->isa_oopptr(); |
| 2352 | } |
| 2353 | if (!toop) return true; // a primitive type, like int |
| 2354 | ciKlass* tklass = toop->klass(); |
| 2355 | if (tklass == NULL__null) return false; // unloaded class |
| 2356 | if (!tklass->is_loaded()) return false; // unloaded class |
| 2357 | const TypeInstPtr* tinst; |
| 2358 | if (_elem->isa_narrowoop()) |
| 2359 | tinst = _elem->make_ptr()->isa_instptr(); |
| 2360 | else |
| 2361 | tinst = _elem->isa_instptr(); |
| 2362 | if (tinst) |
| 2363 | return tklass->as_instance_klass()->is_final(); |
| 2364 | const TypeAryPtr* tap; |
| 2365 | if (_elem->isa_narrowoop()) |
| 2366 | tap = _elem->make_ptr()->isa_aryptr(); |
| 2367 | else |
| 2368 | tap = _elem->isa_aryptr(); |
| 2369 | if (tap) |
| 2370 | return tap->ary()->ary_must_be_exact(); |
| 2371 | return false; |
| 2372 | } |
| 2373 | |
| 2374 | //==============================TypeVect======================================= |
| 2375 | // Convenience common pre-built types. |
| 2376 | const TypeVect *TypeVect::VECTA = NULL__null; // vector length agnostic |
| 2377 | const TypeVect *TypeVect::VECTS = NULL__null; // 32-bit vectors |
| 2378 | const TypeVect *TypeVect::VECTD = NULL__null; // 64-bit vectors |
| 2379 | const TypeVect *TypeVect::VECTX = NULL__null; // 128-bit vectors |
| 2380 | const TypeVect *TypeVect::VECTY = NULL__null; // 256-bit vectors |
| 2381 | const TypeVect *TypeVect::VECTZ = NULL__null; // 512-bit vectors |
| 2382 | const TypeVect *TypeVect::VECTMASK = NULL__null; // predicate/mask vector |
| 2383 | |
| 2384 | //------------------------------make------------------------------------------- |
| 2385 | const TypeVect* TypeVect::make(const Type *elem, uint length, bool is_mask) { |
| 2386 | if (is_mask) { |
| 2387 | return makemask(elem, length); |
| 2388 | } |
| 2389 | BasicType elem_bt = elem->array_element_basic_type(); |
| 2390 | assert(is_java_primitive(elem_bt), "only primitive types in vector")do { if (!(is_java_primitive(elem_bt))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2390, "assert(" "is_java_primitive(elem_bt)" ") failed", "only primitive types in vector" ); ::breakpoint(); } } while (0); |
| 2391 | assert(Matcher::vector_size_supported(elem_bt, length), "length in range")do { if (!(Matcher::vector_size_supported(elem_bt, length))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2391, "assert(" "Matcher::vector_size_supported(elem_bt, length)" ") failed", "length in range"); ::breakpoint(); } } while (0 ); |
| 2392 | int size = length * type2aelembytes(elem_bt); |
| 2393 | switch (Matcher::vector_ideal_reg(size)) { |
| 2394 | case Op_VecA: |
| 2395 | return (TypeVect*)(new TypeVectA(elem, length))->hashcons(); |
| 2396 | case Op_VecS: |
| 2397 | return (TypeVect*)(new TypeVectS(elem, length))->hashcons(); |
| 2398 | case Op_RegL: |
| 2399 | case Op_VecD: |
| 2400 | case Op_RegD: |
| 2401 | return (TypeVect*)(new TypeVectD(elem, length))->hashcons(); |
| 2402 | case Op_VecX: |
| 2403 | return (TypeVect*)(new TypeVectX(elem, length))->hashcons(); |
| 2404 | case Op_VecY: |
| 2405 | return (TypeVect*)(new TypeVectY(elem, length))->hashcons(); |
| 2406 | case Op_VecZ: |
| 2407 | return (TypeVect*)(new TypeVectZ(elem, length))->hashcons(); |
| 2408 | } |
| 2409 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2409); ::breakpoint(); } while (0); |
| 2410 | return NULL__null; |
| 2411 | } |
| 2412 | |
| 2413 | const TypeVect *TypeVect::makemask(const Type* elem, uint length) { |
| 2414 | BasicType elem_bt = elem->array_element_basic_type(); |
| 2415 | if (Matcher::has_predicated_vectors() && |
| 2416 | Matcher::match_rule_supported_vector_masked(Op_VectorLoadMask, length, elem_bt)) { |
| 2417 | return TypeVectMask::make(elem, length); |
| 2418 | } else { |
| 2419 | return make(elem, length); |
| 2420 | } |
| 2421 | } |
| 2422 | |
| 2423 | //------------------------------meet------------------------------------------- |
| 2424 | // Compute the MEET of two types. It returns a new Type object. |
| 2425 | const Type *TypeVect::xmeet( const Type *t ) const { |
| 2426 | // Perform a fast test for common case; meeting the same types together. |
| 2427 | if( this == t ) return this; // Meeting same type-rep? |
| 2428 | |
| 2429 | // Current "this->_base" is Vector |
| 2430 | switch (t->base()) { // switch on original type |
| 2431 | |
| 2432 | case Bottom: // Ye Olde Default |
| 2433 | return t; |
| 2434 | |
| 2435 | default: // All else is a mistake |
| 2436 | typerr(t); |
| 2437 | case VectorMask: { |
| 2438 | const TypeVectMask* v = t->is_vectmask(); |
| 2439 | assert( base() == v->base(), "")do { if (!(base() == v->base())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2439, "assert(" "base() == v->base()" ") failed", ""); :: breakpoint(); } } while (0); |
| 2440 | assert(length() == v->length(), "")do { if (!(length() == v->length())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2440, "assert(" "length() == v->length()" ") failed", "" ); ::breakpoint(); } } while (0); |
| 2441 | assert(element_basic_type() == v->element_basic_type(), "")do { if (!(element_basic_type() == v->element_basic_type() )) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2441, "assert(" "element_basic_type() == v->element_basic_type()" ") failed", ""); ::breakpoint(); } } while (0); |
| 2442 | return TypeVect::makemask(_elem->xmeet(v->_elem), _length); |
| 2443 | } |
| 2444 | case VectorA: |
| 2445 | case VectorS: |
| 2446 | case VectorD: |
| 2447 | case VectorX: |
| 2448 | case VectorY: |
| 2449 | case VectorZ: { // Meeting 2 vectors? |
| 2450 | const TypeVect* v = t->is_vect(); |
| 2451 | assert( base() == v->base(), "")do { if (!(base() == v->base())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2451, "assert(" "base() == v->base()" ") failed", ""); :: breakpoint(); } } while (0); |
| 2452 | assert(length() == v->length(), "")do { if (!(length() == v->length())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2452, "assert(" "length() == v->length()" ") failed", "" ); ::breakpoint(); } } while (0); |
| 2453 | assert(element_basic_type() == v->element_basic_type(), "")do { if (!(element_basic_type() == v->element_basic_type() )) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2453, "assert(" "element_basic_type() == v->element_basic_type()" ") failed", ""); ::breakpoint(); } } while (0); |
| 2454 | return TypeVect::make(_elem->xmeet(v->_elem), _length); |
| 2455 | } |
| 2456 | case Top: |
| 2457 | break; |
| 2458 | } |
| 2459 | return this; |
| 2460 | } |
| 2461 | |
| 2462 | //------------------------------xdual------------------------------------------ |
| 2463 | // Dual: compute field-by-field dual |
| 2464 | const Type *TypeVect::xdual() const { |
| 2465 | return new TypeVect(base(), _elem->dual(), _length); |
| 2466 | } |
| 2467 | |
| 2468 | //------------------------------eq--------------------------------------------- |
| 2469 | // Structural equality check for Type representations |
| 2470 | bool TypeVect::eq(const Type *t) const { |
| 2471 | const TypeVect *v = t->is_vect(); |
| 2472 | return (_elem == v->_elem) && (_length == v->_length); |
| 2473 | } |
| 2474 | |
| 2475 | //------------------------------hash------------------------------------------- |
| 2476 | // Type-specific hashing function. |
| 2477 | int TypeVect::hash(void) const { |
| 2478 | return (intptr_t)_elem + (intptr_t)_length; |
| 2479 | } |
| 2480 | |
| 2481 | //------------------------------singleton-------------------------------------- |
| 2482 | // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple |
| 2483 | // constants (Ldi nodes). Vector is singleton if all elements are the same |
| 2484 | // constant value (when vector is created with Replicate code). |
| 2485 | bool TypeVect::singleton(void) const { |
| 2486 | // There is no Con node for vectors yet. |
| 2487 | // return _elem->singleton(); |
| 2488 | return false; |
| 2489 | } |
| 2490 | |
| 2491 | bool TypeVect::empty(void) const { |
| 2492 | return _elem->empty(); |
| 2493 | } |
| 2494 | |
| 2495 | //------------------------------dump2------------------------------------------ |
| 2496 | #ifndef PRODUCT |
| 2497 | void TypeVect::dump2(Dict &d, uint depth, outputStream *st) const { |
| 2498 | switch (base()) { |
| 2499 | case VectorA: |
| 2500 | st->print("vectora["); break; |
| 2501 | case VectorS: |
| 2502 | st->print("vectors["); break; |
| 2503 | case VectorD: |
| 2504 | st->print("vectord["); break; |
| 2505 | case VectorX: |
| 2506 | st->print("vectorx["); break; |
| 2507 | case VectorY: |
| 2508 | st->print("vectory["); break; |
| 2509 | case VectorZ: |
| 2510 | st->print("vectorz["); break; |
| 2511 | case VectorMask: |
| 2512 | st->print("vectormask["); break; |
| 2513 | default: |
| 2514 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2514); ::breakpoint(); } while (0); |
| 2515 | } |
| 2516 | st->print("%d]:{", _length); |
| 2517 | _elem->dump2(d, depth, st); |
| 2518 | st->print("}"); |
| 2519 | } |
| 2520 | #endif |
| 2521 | |
| 2522 | bool TypeVectMask::eq(const Type *t) const { |
| 2523 | const TypeVectMask *v = t->is_vectmask(); |
| 2524 | return (element_type() == v->element_type()) && (length() == v->length()); |
| 2525 | } |
| 2526 | |
| 2527 | const Type *TypeVectMask::xdual() const { |
| 2528 | return new TypeVectMask(element_type()->dual(), length()); |
| 2529 | } |
| 2530 | |
| 2531 | const TypeVectMask *TypeVectMask::make(const BasicType elem_bt, uint length) { |
| 2532 | return make(get_const_basic_type(elem_bt), length); |
| 2533 | } |
| 2534 | |
| 2535 | const TypeVectMask *TypeVectMask::make(const Type* elem, uint length) { |
| 2536 | const TypeVectMask* mtype = Matcher::predicate_reg_type(elem, length); |
| 2537 | return (TypeVectMask*) const_cast<TypeVectMask*>(mtype)->hashcons(); |
| 2538 | } |
| 2539 | |
| 2540 | //============================================================================= |
| 2541 | // Convenience common pre-built types. |
| 2542 | const TypePtr *TypePtr::NULL_PTR; |
| 2543 | const TypePtr *TypePtr::NOTNULL; |
| 2544 | const TypePtr *TypePtr::BOTTOM; |
| 2545 | |
| 2546 | //------------------------------meet------------------------------------------- |
| 2547 | // Meet over the PTR enum |
| 2548 | const TypePtr::PTR TypePtr::ptr_meet[TypePtr::lastPTR][TypePtr::lastPTR] = { |
| 2549 | // TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, |
| 2550 | { /* Top */ TopPTR, AnyNull, Constant, Null, NotNull, BotPTR,}, |
| 2551 | { /* AnyNull */ AnyNull, AnyNull, Constant, BotPTR, NotNull, BotPTR,}, |
| 2552 | { /* Constant*/ Constant, Constant, Constant, BotPTR, NotNull, BotPTR,}, |
| 2553 | { /* Null */ Null, BotPTR, BotPTR, Null, BotPTR, BotPTR,}, |
| 2554 | { /* NotNull */ NotNull, NotNull, NotNull, BotPTR, NotNull, BotPTR,}, |
| 2555 | { /* BotPTR */ BotPTR, BotPTR, BotPTR, BotPTR, BotPTR, BotPTR,} |
| 2556 | }; |
| 2557 | |
| 2558 | //------------------------------make------------------------------------------- |
| 2559 | const TypePtr *TypePtr::make(TYPES t, enum PTR ptr, int offset, const TypePtr* speculative, int inline_depth) { |
| 2560 | return (TypePtr*)(new TypePtr(t,ptr,offset, speculative, inline_depth))->hashcons(); |
| 2561 | } |
| 2562 | |
| 2563 | //------------------------------cast_to_ptr_type------------------------------- |
| 2564 | const Type *TypePtr::cast_to_ptr_type(PTR ptr) const { |
| 2565 | assert(_base == AnyPtr, "subclass must override cast_to_ptr_type")do { if (!(_base == AnyPtr)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2565, "assert(" "_base == AnyPtr" ") failed", "subclass must override cast_to_ptr_type" ); ::breakpoint(); } } while (0); |
| 2566 | if( ptr == _ptr ) return this; |
| 2567 | return make(_base, ptr, _offset, _speculative, _inline_depth); |
| 2568 | } |
| 2569 | |
| 2570 | //------------------------------get_con---------------------------------------- |
| 2571 | intptr_t TypePtr::get_con() const { |
| 2572 | assert( _ptr == Null, "" )do { if (!(_ptr == Null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2572, "assert(" "_ptr == Null" ") failed", ""); ::breakpoint (); } } while (0); |
| 2573 | return _offset; |
| 2574 | } |
| 2575 | |
| 2576 | //------------------------------meet------------------------------------------- |
| 2577 | // Compute the MEET of two types. It returns a new Type object. |
| 2578 | const Type *TypePtr::xmeet(const Type *t) const { |
| 2579 | const Type* res = xmeet_helper(t); |
| 2580 | if (res->isa_ptr() == NULL__null) { |
| 2581 | return res; |
| 2582 | } |
| 2583 | |
| 2584 | const TypePtr* res_ptr = res->is_ptr(); |
| 2585 | if (res_ptr->speculative() != NULL__null) { |
| 2586 | // type->speculative() == NULL means that speculation is no better |
| 2587 | // than type, i.e. type->speculative() == type. So there are 2 |
| 2588 | // ways to represent the fact that we have no useful speculative |
| 2589 | // data and we should use a single one to be able to test for |
| 2590 | // equality between types. Check whether type->speculative() == |
| 2591 | // type and set speculative to NULL if it is the case. |
| 2592 | if (res_ptr->remove_speculative() == res_ptr->speculative()) { |
| 2593 | return res_ptr->remove_speculative(); |
| 2594 | } |
| 2595 | } |
| 2596 | |
| 2597 | return res; |
| 2598 | } |
| 2599 | |
| 2600 | const Type *TypePtr::xmeet_helper(const Type *t) const { |
| 2601 | // Perform a fast test for common case; meeting the same types together. |
| 2602 | if( this == t ) return this; // Meeting same type-rep? |
| 2603 | |
| 2604 | // Current "this->_base" is AnyPtr |
| 2605 | switch (t->base()) { // switch on original type |
| 2606 | case Int: // Mixing ints & oops happens when javac |
| 2607 | case Long: // reuses local variables |
| 2608 | case FloatTop: |
| 2609 | case FloatCon: |
| 2610 | case FloatBot: |
| 2611 | case DoubleTop: |
| 2612 | case DoubleCon: |
| 2613 | case DoubleBot: |
| 2614 | case NarrowOop: |
| 2615 | case NarrowKlass: |
| 2616 | case Bottom: // Ye Olde Default |
| 2617 | return Type::BOTTOM; |
| 2618 | case Top: |
| 2619 | return this; |
| 2620 | |
| 2621 | case AnyPtr: { // Meeting to AnyPtrs |
| 2622 | const TypePtr *tp = t->is_ptr(); |
| 2623 | const TypePtr* speculative = xmeet_speculative(tp); |
| 2624 | int depth = meet_inline_depth(tp->inline_depth()); |
| 2625 | return make(AnyPtr, meet_ptr(tp->ptr()), meet_offset(tp->offset()), speculative, depth); |
| 2626 | } |
| 2627 | case RawPtr: // For these, flip the call around to cut down |
| 2628 | case OopPtr: |
| 2629 | case InstPtr: // on the cases I have to handle. |
| 2630 | case AryPtr: |
| 2631 | case MetadataPtr: |
| 2632 | case KlassPtr: |
| 2633 | case InstKlassPtr: |
| 2634 | case AryKlassPtr: |
| 2635 | return t->xmeet(this); // Call in reverse direction |
| 2636 | default: // All else is a mistake |
| 2637 | typerr(t); |
| 2638 | |
| 2639 | } |
| 2640 | return this; |
| 2641 | } |
| 2642 | |
| 2643 | //------------------------------meet_offset------------------------------------ |
| 2644 | int TypePtr::meet_offset( int offset ) const { |
| 2645 | // Either is 'TOP' offset? Return the other offset! |
| 2646 | if( _offset == OffsetTop ) return offset; |
| 2647 | if( offset == OffsetTop ) return _offset; |
| 2648 | // If either is different, return 'BOTTOM' offset |
| 2649 | if( _offset != offset ) return OffsetBot; |
| 2650 | return _offset; |
| 2651 | } |
| 2652 | |
| 2653 | //------------------------------dual_offset------------------------------------ |
| 2654 | int TypePtr::dual_offset( ) const { |
| 2655 | if( _offset == OffsetTop ) return OffsetBot;// Map 'TOP' into 'BOTTOM' |
| 2656 | if( _offset == OffsetBot ) return OffsetTop;// Map 'BOTTOM' into 'TOP' |
| 2657 | return _offset; // Map everything else into self |
| 2658 | } |
| 2659 | |
| 2660 | //------------------------------xdual------------------------------------------ |
| 2661 | // Dual: compute field-by-field dual |
| 2662 | const TypePtr::PTR TypePtr::ptr_dual[TypePtr::lastPTR] = { |
| 2663 | BotPTR, NotNull, Constant, Null, AnyNull, TopPTR |
| 2664 | }; |
| 2665 | const Type *TypePtr::xdual() const { |
| 2666 | return new TypePtr(AnyPtr, dual_ptr(), dual_offset(), dual_speculative(), dual_inline_depth()); |
| 2667 | } |
| 2668 | |
| 2669 | //------------------------------xadd_offset------------------------------------ |
| 2670 | int TypePtr::xadd_offset( intptr_t offset ) const { |
| 2671 | // Adding to 'TOP' offset? Return 'TOP'! |
| 2672 | if( _offset == OffsetTop || offset == OffsetTop ) return OffsetTop; |
| 2673 | // Adding to 'BOTTOM' offset? Return 'BOTTOM'! |
| 2674 | if( _offset == OffsetBot || offset == OffsetBot ) return OffsetBot; |
| 2675 | // Addition overflows or "accidentally" equals to OffsetTop? Return 'BOTTOM'! |
| 2676 | offset += (intptr_t)_offset; |
| 2677 | if (offset != (int)offset || offset == OffsetTop) return OffsetBot; |
| 2678 | |
| 2679 | // assert( _offset >= 0 && _offset+offset >= 0, "" ); |
| 2680 | // It is possible to construct a negative offset during PhaseCCP |
| 2681 | |
| 2682 | return (int)offset; // Sum valid offsets |
| 2683 | } |
| 2684 | |
| 2685 | //------------------------------add_offset------------------------------------- |
| 2686 | const TypePtr *TypePtr::add_offset( intptr_t offset ) const { |
| 2687 | return make(AnyPtr, _ptr, xadd_offset(offset), _speculative, _inline_depth); |
| 2688 | } |
| 2689 | |
| 2690 | //------------------------------eq--------------------------------------------- |
| 2691 | // Structural equality check for Type representations |
| 2692 | bool TypePtr::eq( const Type *t ) const { |
| 2693 | const TypePtr *a = (const TypePtr*)t; |
| 2694 | return _ptr == a->ptr() && _offset == a->offset() && eq_speculative(a) && _inline_depth == a->_inline_depth; |
| 2695 | } |
| 2696 | |
| 2697 | //------------------------------hash------------------------------------------- |
| 2698 | // Type-specific hashing function. |
| 2699 | int TypePtr::hash(void) const { |
| 2700 | return java_add(java_add((jint)_ptr, (jint)_offset), java_add((jint)hash_speculative(), (jint)_inline_depth)); |
| 2701 | ; |
| 2702 | } |
| 2703 | |
| 2704 | /** |
| 2705 | * Return same type without a speculative part |
| 2706 | */ |
| 2707 | const Type* TypePtr::remove_speculative() const { |
| 2708 | if (_speculative == NULL__null) { |
| 2709 | return this; |
| 2710 | } |
| 2711 | assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth")do { if (!(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2711, "assert(" "_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom" ") failed", "non speculative type shouldn't have inline depth" ); ::breakpoint(); } } while (0); |
| 2712 | return make(AnyPtr, _ptr, _offset, NULL__null, _inline_depth); |
| 2713 | } |
| 2714 | |
| 2715 | /** |
| 2716 | * Return same type but drop speculative part if we know we won't use |
| 2717 | * it |
| 2718 | */ |
| 2719 | const Type* TypePtr::cleanup_speculative() const { |
| 2720 | if (speculative() == NULL__null) { |
| 2721 | return this; |
| 2722 | } |
| 2723 | const Type* no_spec = remove_speculative(); |
| 2724 | // If this is NULL_PTR then we don't need the speculative type |
| 2725 | // (with_inline_depth in case the current type inline depth is |
| 2726 | // InlineDepthTop) |
| 2727 | if (no_spec == NULL_PTR->with_inline_depth(inline_depth())) { |
| 2728 | return no_spec; |
| 2729 | } |
| 2730 | if (above_centerline(speculative()->ptr())) { |
| 2731 | return no_spec; |
| 2732 | } |
| 2733 | const TypeOopPtr* spec_oopptr = speculative()->isa_oopptr(); |
| 2734 | // If the speculative may be null and is an inexact klass then it |
| 2735 | // doesn't help |
| 2736 | if (speculative() != TypePtr::NULL_PTR && speculative()->maybe_null() && |
| 2737 | (spec_oopptr == NULL__null || !spec_oopptr->klass_is_exact())) { |
| 2738 | return no_spec; |
| 2739 | } |
| 2740 | return this; |
| 2741 | } |
| 2742 | |
| 2743 | /** |
| 2744 | * dual of the speculative part of the type |
| 2745 | */ |
| 2746 | const TypePtr* TypePtr::dual_speculative() const { |
| 2747 | if (_speculative == NULL__null) { |
| 2748 | return NULL__null; |
| 2749 | } |
| 2750 | return _speculative->dual()->is_ptr(); |
| 2751 | } |
| 2752 | |
| 2753 | /** |
| 2754 | * meet of the speculative parts of 2 types |
| 2755 | * |
| 2756 | * @param other type to meet with |
| 2757 | */ |
| 2758 | const TypePtr* TypePtr::xmeet_speculative(const TypePtr* other) const { |
| 2759 | bool this_has_spec = (_speculative != NULL__null); |
| 2760 | bool other_has_spec = (other->speculative() != NULL__null); |
| 2761 | |
| 2762 | if (!this_has_spec && !other_has_spec) { |
| 2763 | return NULL__null; |
| 2764 | } |
| 2765 | |
| 2766 | // If we are at a point where control flow meets and one branch has |
| 2767 | // a speculative type and the other has not, we meet the speculative |
| 2768 | // type of one branch with the actual type of the other. If the |
| 2769 | // actual type is exact and the speculative is as well, then the |
| 2770 | // result is a speculative type which is exact and we can continue |
| 2771 | // speculation further. |
| 2772 | const TypePtr* this_spec = _speculative; |
| 2773 | const TypePtr* other_spec = other->speculative(); |
| 2774 | |
| 2775 | if (!this_has_spec) { |
| 2776 | this_spec = this; |
| 2777 | } |
| 2778 | |
| 2779 | if (!other_has_spec) { |
| 2780 | other_spec = other; |
| 2781 | } |
| 2782 | |
| 2783 | return this_spec->meet(other_spec)->is_ptr(); |
| 2784 | } |
| 2785 | |
| 2786 | /** |
| 2787 | * dual of the inline depth for this type (used for speculation) |
| 2788 | */ |
| 2789 | int TypePtr::dual_inline_depth() const { |
| 2790 | return -inline_depth(); |
| 2791 | } |
| 2792 | |
| 2793 | /** |
| 2794 | * meet of 2 inline depths (used for speculation) |
| 2795 | * |
| 2796 | * @param depth depth to meet with |
| 2797 | */ |
| 2798 | int TypePtr::meet_inline_depth(int depth) const { |
| 2799 | return MAX2(inline_depth(), depth); |
| 2800 | } |
| 2801 | |
| 2802 | /** |
| 2803 | * Are the speculative parts of 2 types equal? |
| 2804 | * |
| 2805 | * @param other type to compare this one to |
| 2806 | */ |
| 2807 | bool TypePtr::eq_speculative(const TypePtr* other) const { |
| 2808 | if (_speculative == NULL__null || other->speculative() == NULL__null) { |
| 2809 | return _speculative == other->speculative(); |
| 2810 | } |
| 2811 | |
| 2812 | if (_speculative->base() != other->speculative()->base()) { |
| 2813 | return false; |
| 2814 | } |
| 2815 | |
| 2816 | return _speculative->eq(other->speculative()); |
| 2817 | } |
| 2818 | |
| 2819 | /** |
| 2820 | * Hash of the speculative part of the type |
| 2821 | */ |
| 2822 | int TypePtr::hash_speculative() const { |
| 2823 | if (_speculative == NULL__null) { |
| 2824 | return 0; |
| 2825 | } |
| 2826 | |
| 2827 | return _speculative->hash(); |
| 2828 | } |
| 2829 | |
| 2830 | /** |
| 2831 | * add offset to the speculative part of the type |
| 2832 | * |
| 2833 | * @param offset offset to add |
| 2834 | */ |
| 2835 | const TypePtr* TypePtr::add_offset_speculative(intptr_t offset) const { |
| 2836 | if (_speculative == NULL__null) { |
| 2837 | return NULL__null; |
| 2838 | } |
| 2839 | return _speculative->add_offset(offset)->is_ptr(); |
| 2840 | } |
| 2841 | |
| 2842 | /** |
| 2843 | * return exact klass from the speculative type if there's one |
| 2844 | */ |
| 2845 | ciKlass* TypePtr::speculative_type() const { |
| 2846 | if (_speculative != NULL__null && _speculative->isa_oopptr()) { |
| 2847 | const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr(); |
| 2848 | if (speculative->klass_is_exact()) { |
| 2849 | return speculative->klass(); |
| 2850 | } |
| 2851 | } |
| 2852 | return NULL__null; |
| 2853 | } |
| 2854 | |
| 2855 | /** |
| 2856 | * return true if speculative type may be null |
| 2857 | */ |
| 2858 | bool TypePtr::speculative_maybe_null() const { |
| 2859 | if (_speculative != NULL__null) { |
| 2860 | const TypePtr* speculative = _speculative->join(this)->is_ptr(); |
| 2861 | return speculative->maybe_null(); |
| 2862 | } |
| 2863 | return true; |
| 2864 | } |
| 2865 | |
| 2866 | bool TypePtr::speculative_always_null() const { |
| 2867 | if (_speculative != NULL__null) { |
| 2868 | const TypePtr* speculative = _speculative->join(this)->is_ptr(); |
| 2869 | return speculative == TypePtr::NULL_PTR; |
| 2870 | } |
| 2871 | return false; |
| 2872 | } |
| 2873 | |
| 2874 | /** |
| 2875 | * Same as TypePtr::speculative_type() but return the klass only if |
| 2876 | * the speculative tells us is not null |
| 2877 | */ |
| 2878 | ciKlass* TypePtr::speculative_type_not_null() const { |
| 2879 | if (speculative_maybe_null()) { |
| 2880 | return NULL__null; |
| 2881 | } |
| 2882 | return speculative_type(); |
| 2883 | } |
| 2884 | |
| 2885 | /** |
| 2886 | * Check whether new profiling would improve speculative type |
| 2887 | * |
| 2888 | * @param exact_kls class from profiling |
| 2889 | * @param inline_depth inlining depth of profile point |
| 2890 | * |
| 2891 | * @return true if type profile is valuable |
| 2892 | */ |
| 2893 | bool TypePtr::would_improve_type(ciKlass* exact_kls, int inline_depth) const { |
| 2894 | // no profiling? |
| 2895 | if (exact_kls == NULL__null) { |
| 2896 | return false; |
| 2897 | } |
| 2898 | if (speculative() == TypePtr::NULL_PTR) { |
| 2899 | return false; |
| 2900 | } |
| 2901 | // no speculative type or non exact speculative type? |
| 2902 | if (speculative_type() == NULL__null) { |
| 2903 | return true; |
| 2904 | } |
| 2905 | // If the node already has an exact speculative type keep it, |
| 2906 | // unless it was provided by profiling that is at a deeper |
| 2907 | // inlining level. Profiling at a higher inlining depth is |
| 2908 | // expected to be less accurate. |
| 2909 | if (_speculative->inline_depth() == InlineDepthBottom) { |
| 2910 | return false; |
| 2911 | } |
| 2912 | assert(_speculative->inline_depth() != InlineDepthTop, "can't do the comparison")do { if (!(_speculative->inline_depth() != InlineDepthTop) ) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 2912, "assert(" "_speculative->inline_depth() != InlineDepthTop" ") failed", "can't do the comparison"); ::breakpoint(); } } while (0); |
| 2913 | return inline_depth < _speculative->inline_depth(); |
| 2914 | } |
| 2915 | |
| 2916 | /** |
| 2917 | * Check whether new profiling would improve ptr (= tells us it is non |
| 2918 | * null) |
| 2919 | * |
| 2920 | * @param ptr_kind always null or not null? |
| 2921 | * |
| 2922 | * @return true if ptr profile is valuable |
| 2923 | */ |
| 2924 | bool TypePtr::would_improve_ptr(ProfilePtrKind ptr_kind) const { |
| 2925 | // profiling doesn't tell us anything useful |
| 2926 | if (ptr_kind != ProfileAlwaysNull && ptr_kind != ProfileNeverNull) { |
| 2927 | return false; |
| 2928 | } |
| 2929 | // We already know this is not null |
| 2930 | if (!this->maybe_null()) { |
| 2931 | return false; |
| 2932 | } |
| 2933 | // We already know the speculative type cannot be null |
| 2934 | if (!speculative_maybe_null()) { |
| 2935 | return false; |
| 2936 | } |
| 2937 | // We already know this is always null |
| 2938 | if (this == TypePtr::NULL_PTR) { |
| 2939 | return false; |
| 2940 | } |
| 2941 | // We already know the speculative type is always null |
| 2942 | if (speculative_always_null()) { |
| 2943 | return false; |
| 2944 | } |
| 2945 | if (ptr_kind == ProfileAlwaysNull && speculative() != NULL__null && speculative()->isa_oopptr()) { |
| 2946 | return false; |
| 2947 | } |
| 2948 | return true; |
| 2949 | } |
| 2950 | |
| 2951 | //------------------------------dump2------------------------------------------ |
| 2952 | const char *const TypePtr::ptr_msg[TypePtr::lastPTR] = { |
| 2953 | "TopPTR","AnyNull","Constant","NULL","NotNull","BotPTR" |
| 2954 | }; |
| 2955 | |
| 2956 | #ifndef PRODUCT |
| 2957 | void TypePtr::dump2( Dict &d, uint depth, outputStream *st ) const { |
| 2958 | if( _ptr == Null ) st->print("NULL"); |
| 2959 | else st->print("%s *", ptr_msg[_ptr]); |
| 2960 | if( _offset == OffsetTop ) st->print("+top"); |
| 2961 | else if( _offset == OffsetBot ) st->print("+bot"); |
| 2962 | else if( _offset ) st->print("+%d", _offset); |
| 2963 | dump_inline_depth(st); |
| 2964 | dump_speculative(st); |
| 2965 | } |
| 2966 | |
| 2967 | /** |
| 2968 | *dump the speculative part of the type |
| 2969 | */ |
| 2970 | void TypePtr::dump_speculative(outputStream *st) const { |
| 2971 | if (_speculative != NULL__null) { |
| 2972 | st->print(" (speculative="); |
| 2973 | _speculative->dump_on(st); |
| 2974 | st->print(")"); |
| 2975 | } |
| 2976 | } |
| 2977 | |
| 2978 | /** |
| 2979 | *dump the inline depth of the type |
| 2980 | */ |
| 2981 | void TypePtr::dump_inline_depth(outputStream *st) const { |
| 2982 | if (_inline_depth != InlineDepthBottom) { |
| 2983 | if (_inline_depth == InlineDepthTop) { |
| 2984 | st->print(" (inline_depth=InlineDepthTop)"); |
| 2985 | } else { |
| 2986 | st->print(" (inline_depth=%d)", _inline_depth); |
| 2987 | } |
| 2988 | } |
| 2989 | } |
| 2990 | #endif |
| 2991 | |
| 2992 | //------------------------------singleton-------------------------------------- |
| 2993 | // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple |
| 2994 | // constants |
| 2995 | bool TypePtr::singleton(void) const { |
| 2996 | // TopPTR, Null, AnyNull, Constant are all singletons |
| 2997 | return (_offset != OffsetBot) && !below_centerline(_ptr); |
| 2998 | } |
| 2999 | |
| 3000 | bool TypePtr::empty(void) const { |
| 3001 | return (_offset == OffsetTop) || above_centerline(_ptr); |
| 3002 | } |
| 3003 | |
| 3004 | //============================================================================= |
| 3005 | // Convenience common pre-built types. |
| 3006 | const TypeRawPtr *TypeRawPtr::BOTTOM; |
| 3007 | const TypeRawPtr *TypeRawPtr::NOTNULL; |
| 3008 | |
| 3009 | //------------------------------make------------------------------------------- |
| 3010 | const TypeRawPtr *TypeRawPtr::make( enum PTR ptr ) { |
| 3011 | assert( ptr != Constant, "what is the constant?" )do { if (!(ptr != Constant)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3011, "assert(" "ptr != Constant" ") failed", "what is the constant?" ); ::breakpoint(); } } while (0); |
| 3012 | assert( ptr != Null, "Use TypePtr for NULL" )do { if (!(ptr != Null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3012, "assert(" "ptr != Null" ") failed", "Use TypePtr for NULL" ); ::breakpoint(); } } while (0); |
| 3013 | return (TypeRawPtr*)(new TypeRawPtr(ptr,0))->hashcons(); |
| 3014 | } |
| 3015 | |
| 3016 | const TypeRawPtr *TypeRawPtr::make( address bits ) { |
| 3017 | assert( bits, "Use TypePtr for NULL" )do { if (!(bits)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3017, "assert(" "bits" ") failed", "Use TypePtr for NULL"); ::breakpoint(); } } while (0); |
| 3018 | return (TypeRawPtr*)(new TypeRawPtr(Constant,bits))->hashcons(); |
| 3019 | } |
| 3020 | |
| 3021 | //------------------------------cast_to_ptr_type------------------------------- |
| 3022 | const TypeRawPtr* TypeRawPtr::cast_to_ptr_type(PTR ptr) const { |
| 3023 | assert( ptr != Constant, "what is the constant?" )do { if (!(ptr != Constant)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3023, "assert(" "ptr != Constant" ") failed", "what is the constant?" ); ::breakpoint(); } } while (0); |
| 3024 | assert( ptr != Null, "Use TypePtr for NULL" )do { if (!(ptr != Null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3024, "assert(" "ptr != Null" ") failed", "Use TypePtr for NULL" ); ::breakpoint(); } } while (0); |
| 3025 | assert( _bits==0, "Why cast a constant address?")do { if (!(_bits==0)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3025, "assert(" "_bits==0" ") failed", "Why cast a constant address?" ); ::breakpoint(); } } while (0); |
| 3026 | if( ptr == _ptr ) return this; |
| 3027 | return make(ptr); |
| 3028 | } |
| 3029 | |
| 3030 | //------------------------------get_con---------------------------------------- |
| 3031 | intptr_t TypeRawPtr::get_con() const { |
| 3032 | assert( _ptr == Null || _ptr == Constant, "" )do { if (!(_ptr == Null || _ptr == Constant)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3032, "assert(" "_ptr == Null || _ptr == Constant" ") failed" , ""); ::breakpoint(); } } while (0); |
| 3033 | return (intptr_t)_bits; |
| 3034 | } |
| 3035 | |
| 3036 | //------------------------------meet------------------------------------------- |
| 3037 | // Compute the MEET of two types. It returns a new Type object. |
| 3038 | const Type *TypeRawPtr::xmeet( const Type *t ) const { |
| 3039 | // Perform a fast test for common case; meeting the same types together. |
| 3040 | if( this == t ) return this; // Meeting same type-rep? |
| 3041 | |
| 3042 | // Current "this->_base" is RawPtr |
| 3043 | switch( t->base() ) { // switch on original type |
| 3044 | case Bottom: // Ye Olde Default |
| 3045 | return t; |
| 3046 | case Top: |
| 3047 | return this; |
| 3048 | case AnyPtr: // Meeting to AnyPtrs |
| 3049 | break; |
| 3050 | case RawPtr: { // might be top, bot, any/not or constant |
| 3051 | enum PTR tptr = t->is_ptr()->ptr(); |
| 3052 | enum PTR ptr = meet_ptr( tptr ); |
| 3053 | if( ptr == Constant ) { // Cannot be equal constants, so... |
| 3054 | if( tptr == Constant && _ptr != Constant) return t; |
| 3055 | if( _ptr == Constant && tptr != Constant) return this; |
| 3056 | ptr = NotNull; // Fall down in lattice |
| 3057 | } |
| 3058 | return make( ptr ); |
| 3059 | } |
| 3060 | |
| 3061 | case OopPtr: |
| 3062 | case InstPtr: |
| 3063 | case AryPtr: |
| 3064 | case MetadataPtr: |
| 3065 | case KlassPtr: |
| 3066 | case InstKlassPtr: |
| 3067 | case AryKlassPtr: |
| 3068 | return TypePtr::BOTTOM; // Oop meet raw is not well defined |
| 3069 | default: // All else is a mistake |
| 3070 | typerr(t); |
| 3071 | } |
| 3072 | |
| 3073 | // Found an AnyPtr type vs self-RawPtr type |
| 3074 | const TypePtr *tp = t->is_ptr(); |
| 3075 | switch (tp->ptr()) { |
| 3076 | case TypePtr::TopPTR: return this; |
| 3077 | case TypePtr::BotPTR: return t; |
| 3078 | case TypePtr::Null: |
| 3079 | if( _ptr == TypePtr::TopPTR ) return t; |
| 3080 | return TypeRawPtr::BOTTOM; |
| 3081 | case TypePtr::NotNull: return TypePtr::make(AnyPtr, meet_ptr(TypePtr::NotNull), tp->meet_offset(0), tp->speculative(), tp->inline_depth()); |
| 3082 | case TypePtr::AnyNull: |
| 3083 | if( _ptr == TypePtr::Constant) return this; |
| 3084 | return make( meet_ptr(TypePtr::AnyNull) ); |
| 3085 | default: ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3085); ::breakpoint(); } while (0); |
| 3086 | } |
| 3087 | return this; |
| 3088 | } |
| 3089 | |
| 3090 | //------------------------------xdual------------------------------------------ |
| 3091 | // Dual: compute field-by-field dual |
| 3092 | const Type *TypeRawPtr::xdual() const { |
| 3093 | return new TypeRawPtr( dual_ptr(), _bits ); |
| 3094 | } |
| 3095 | |
| 3096 | //------------------------------add_offset------------------------------------- |
| 3097 | const TypePtr *TypeRawPtr::add_offset( intptr_t offset ) const { |
| 3098 | if( offset == OffsetTop ) return BOTTOM; // Undefined offset-> undefined pointer |
| 3099 | if( offset == OffsetBot ) return BOTTOM; // Unknown offset-> unknown pointer |
| 3100 | if( offset == 0 ) return this; // No change |
| 3101 | switch (_ptr) { |
| 3102 | case TypePtr::TopPTR: |
| 3103 | case TypePtr::BotPTR: |
| 3104 | case TypePtr::NotNull: |
| 3105 | return this; |
| 3106 | case TypePtr::Null: |
| 3107 | case TypePtr::Constant: { |
| 3108 | address bits = _bits+offset; |
| 3109 | if ( bits == 0 ) return TypePtr::NULL_PTR; |
| 3110 | return make( bits ); |
| 3111 | } |
| 3112 | default: ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3112); ::breakpoint(); } while (0); |
| 3113 | } |
| 3114 | return NULL__null; // Lint noise |
| 3115 | } |
| 3116 | |
| 3117 | //------------------------------eq--------------------------------------------- |
| 3118 | // Structural equality check for Type representations |
| 3119 | bool TypeRawPtr::eq( const Type *t ) const { |
| 3120 | const TypeRawPtr *a = (const TypeRawPtr*)t; |
| 3121 | return _bits == a->_bits && TypePtr::eq(t); |
| 3122 | } |
| 3123 | |
| 3124 | //------------------------------hash------------------------------------------- |
| 3125 | // Type-specific hashing function. |
| 3126 | int TypeRawPtr::hash(void) const { |
| 3127 | return (intptr_t)_bits + TypePtr::hash(); |
| 3128 | } |
| 3129 | |
| 3130 | //------------------------------dump2------------------------------------------ |
| 3131 | #ifndef PRODUCT |
| 3132 | void TypeRawPtr::dump2( Dict &d, uint depth, outputStream *st ) const { |
| 3133 | if( _ptr == Constant ) |
| 3134 | st->print(INTPTR_FORMAT"0x%016" "l" "x", p2i(_bits)); |
| 3135 | else |
| 3136 | st->print("rawptr:%s", ptr_msg[_ptr]); |
| 3137 | } |
| 3138 | #endif |
| 3139 | |
| 3140 | //============================================================================= |
| 3141 | // Convenience common pre-built type. |
| 3142 | const TypeOopPtr *TypeOopPtr::BOTTOM; |
| 3143 | |
| 3144 | //------------------------------TypeOopPtr------------------------------------- |
| 3145 | TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, |
| 3146 | int instance_id, const TypePtr* speculative, int inline_depth) |
| 3147 | : TypePtr(t, ptr, offset, speculative, inline_depth), |
| 3148 | _const_oop(o), _klass(k), |
| 3149 | _klass_is_exact(xk), |
| 3150 | _is_ptr_to_narrowoop(false), |
| 3151 | _is_ptr_to_narrowklass(false), |
| 3152 | _is_ptr_to_boxed_value(false), |
| 3153 | _instance_id(instance_id) { |
| 3154 | if (Compile::current()->eliminate_boxing() && (t == InstPtr) && |
| 3155 | (offset > 0) && xk && (k != 0) && k->is_instance_klass()) { |
| 3156 | _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset); |
| 3157 | } |
| 3158 | #ifdef _LP641 |
| 3159 | if (_offset > 0 || _offset == Type::OffsetTop || _offset == Type::OffsetBot) { |
| 3160 | if (_offset == oopDesc::klass_offset_in_bytes()) { |
| 3161 | _is_ptr_to_narrowklass = UseCompressedClassPointers; |
| 3162 | } else if (klass() == NULL__null) { |
| 3163 | // Array with unknown body type |
| 3164 | assert(this->isa_aryptr(), "only arrays without klass")do { if (!(this->isa_aryptr())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3164, "assert(" "this->isa_aryptr()" ") failed", "only arrays without klass" ); ::breakpoint(); } } while (0); |
| 3165 | _is_ptr_to_narrowoop = UseCompressedOops; |
| 3166 | } else if (this->isa_aryptr()) { |
| 3167 | _is_ptr_to_narrowoop = (UseCompressedOops && klass()->is_obj_array_klass() && |
| 3168 | _offset != arrayOopDesc::length_offset_in_bytes()); |
| 3169 | } else if (klass()->is_instance_klass()) { |
| 3170 | ciInstanceKlass* ik = klass()->as_instance_klass(); |
| 3171 | ciField* field = NULL__null; |
| 3172 | if (this->isa_klassptr()) { |
| 3173 | // Perm objects don't use compressed references |
| 3174 | } else if (_offset == OffsetBot || _offset == OffsetTop) { |
| 3175 | // unsafe access |
| 3176 | _is_ptr_to_narrowoop = UseCompressedOops; |
| 3177 | } else { |
| 3178 | assert(this->isa_instptr(), "must be an instance ptr.")do { if (!(this->isa_instptr())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3178, "assert(" "this->isa_instptr()" ") failed", "must be an instance ptr." ); ::breakpoint(); } } while (0); |
| 3179 | |
| 3180 | if (klass() == ciEnv::current()->Class_klass() && |
| 3181 | (_offset == java_lang_Class::klass_offset() || |
| 3182 | _offset == java_lang_Class::array_klass_offset())) { |
| 3183 | // Special hidden fields from the Class. |
| 3184 | assert(this->isa_instptr(), "must be an instance ptr.")do { if (!(this->isa_instptr())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3184, "assert(" "this->isa_instptr()" ") failed", "must be an instance ptr." ); ::breakpoint(); } } while (0); |
| 3185 | _is_ptr_to_narrowoop = false; |
| 3186 | } else if (klass() == ciEnv::current()->Class_klass() && |
| 3187 | _offset >= InstanceMirrorKlass::offset_of_static_fields()) { |
| 3188 | // Static fields |
| 3189 | ciField* field = NULL__null; |
| 3190 | if (const_oop() != NULL__null) { |
| 3191 | ciInstanceKlass* k = const_oop()->as_instance()->java_lang_Class_klass()->as_instance_klass(); |
| 3192 | field = k->get_field_by_offset(_offset, true); |
| 3193 | } |
| 3194 | if (field != NULL__null) { |
| 3195 | BasicType basic_elem_type = field->layout_type(); |
| 3196 | _is_ptr_to_narrowoop = UseCompressedOops && is_reference_type(basic_elem_type); |
| 3197 | } else { |
| 3198 | // unsafe access |
| 3199 | _is_ptr_to_narrowoop = UseCompressedOops; |
| 3200 | } |
| 3201 | } else { |
| 3202 | // Instance fields which contains a compressed oop references. |
| 3203 | field = ik->get_field_by_offset(_offset, false); |
| 3204 | if (field != NULL__null) { |
| 3205 | BasicType basic_elem_type = field->layout_type(); |
| 3206 | _is_ptr_to_narrowoop = UseCompressedOops && is_reference_type(basic_elem_type); |
| 3207 | } else if (klass()->equals(ciEnv::current()->Object_klass())) { |
| 3208 | // Compile::find_alias_type() cast exactness on all types to verify |
| 3209 | // that it does not affect alias type. |
| 3210 | _is_ptr_to_narrowoop = UseCompressedOops; |
| 3211 | } else { |
| 3212 | // Type for the copy start in LibraryCallKit::inline_native_clone(). |
| 3213 | _is_ptr_to_narrowoop = UseCompressedOops; |
| 3214 | } |
| 3215 | } |
| 3216 | } |
| 3217 | } |
| 3218 | } |
| 3219 | #endif |
| 3220 | } |
| 3221 | |
| 3222 | //------------------------------make------------------------------------------- |
| 3223 | const TypeOopPtr *TypeOopPtr::make(PTR ptr, int offset, int instance_id, |
| 3224 | const TypePtr* speculative, int inline_depth) { |
| 3225 | assert(ptr != Constant, "no constant generic pointers")do { if (!(ptr != Constant)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3225, "assert(" "ptr != Constant" ") failed", "no constant generic pointers" ); ::breakpoint(); } } while (0); |
| 3226 | ciKlass* k = Compile::current()->env()->Object_klass(); |
| 3227 | bool xk = false; |
| 3228 | ciObject* o = NULL__null; |
| 3229 | return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons(); |
| 3230 | } |
| 3231 | |
| 3232 | |
| 3233 | //------------------------------cast_to_ptr_type------------------------------- |
| 3234 | const TypeOopPtr* TypeOopPtr::cast_to_ptr_type(PTR ptr) const { |
| 3235 | assert(_base == OopPtr, "subclass must override cast_to_ptr_type")do { if (!(_base == OopPtr)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3235, "assert(" "_base == OopPtr" ") failed", "subclass must override cast_to_ptr_type" ); ::breakpoint(); } } while (0); |
| 3236 | if( ptr == _ptr ) return this; |
| 3237 | return make(ptr, _offset, _instance_id, _speculative, _inline_depth); |
| 3238 | } |
| 3239 | |
| 3240 | //-----------------------------cast_to_instance_id---------------------------- |
| 3241 | const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const { |
| 3242 | // There are no instances of a general oop. |
| 3243 | // Return self unchanged. |
| 3244 | return this; |
| 3245 | } |
| 3246 | |
| 3247 | //-----------------------------cast_to_exactness------------------------------- |
| 3248 | const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const { |
| 3249 | // There is no such thing as an exact general oop. |
| 3250 | // Return self unchanged. |
| 3251 | return this; |
| 3252 | } |
| 3253 | |
| 3254 | |
| 3255 | //------------------------------as_klass_type---------------------------------- |
| 3256 | // Return the klass type corresponding to this instance or array type. |
| 3257 | // It is the type that is loaded from an object of this type. |
| 3258 | const TypeKlassPtr* TypeOopPtr::as_klass_type(bool try_for_exact) const { |
| 3259 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3259); ::breakpoint(); } while (0); |
| 3260 | return NULL__null; |
| 3261 | } |
| 3262 | |
| 3263 | //------------------------------meet------------------------------------------- |
| 3264 | // Compute the MEET of two types. It returns a new Type object. |
| 3265 | const Type *TypeOopPtr::xmeet_helper(const Type *t) const { |
| 3266 | // Perform a fast test for common case; meeting the same types together. |
| 3267 | if( this == t ) return this; // Meeting same type-rep? |
| 3268 | |
| 3269 | // Current "this->_base" is OopPtr |
| 3270 | switch (t->base()) { // switch on original type |
| 3271 | |
| 3272 | case Int: // Mixing ints & oops happens when javac |
| 3273 | case Long: // reuses local variables |
| 3274 | case FloatTop: |
| 3275 | case FloatCon: |
| 3276 | case FloatBot: |
| 3277 | case DoubleTop: |
| 3278 | case DoubleCon: |
| 3279 | case DoubleBot: |
| 3280 | case NarrowOop: |
| 3281 | case NarrowKlass: |
| 3282 | case Bottom: // Ye Olde Default |
| 3283 | return Type::BOTTOM; |
| 3284 | case Top: |
| 3285 | return this; |
| 3286 | |
| 3287 | default: // All else is a mistake |
| 3288 | typerr(t); |
| 3289 | |
| 3290 | case RawPtr: |
| 3291 | case MetadataPtr: |
| 3292 | case KlassPtr: |
| 3293 | case InstKlassPtr: |
| 3294 | case AryKlassPtr: |
| 3295 | return TypePtr::BOTTOM; // Oop meet raw is not well defined |
| 3296 | |
| 3297 | case AnyPtr: { |
| 3298 | // Found an AnyPtr type vs self-OopPtr type |
| 3299 | const TypePtr *tp = t->is_ptr(); |
| 3300 | int offset = meet_offset(tp->offset()); |
| 3301 | PTR ptr = meet_ptr(tp->ptr()); |
| 3302 | const TypePtr* speculative = xmeet_speculative(tp); |
| 3303 | int depth = meet_inline_depth(tp->inline_depth()); |
| 3304 | switch (tp->ptr()) { |
| 3305 | case Null: |
| 3306 | if (ptr == Null) return TypePtr::make(AnyPtr, ptr, offset, speculative, depth); |
| 3307 | // else fall through: |
| 3308 | case TopPTR: |
| 3309 | case AnyNull: { |
| 3310 | int instance_id = meet_instance_id(InstanceTop); |
| 3311 | return make(ptr, offset, instance_id, speculative, depth); |
| 3312 | } |
| 3313 | case BotPTR: |
| 3314 | case NotNull: |
| 3315 | return TypePtr::make(AnyPtr, ptr, offset, speculative, depth); |
| 3316 | default: typerr(t); |
| 3317 | } |
| 3318 | } |
| 3319 | |
| 3320 | case OopPtr: { // Meeting to other OopPtrs |
| 3321 | const TypeOopPtr *tp = t->is_oopptr(); |
| 3322 | int instance_id = meet_instance_id(tp->instance_id()); |
| 3323 | const TypePtr* speculative = xmeet_speculative(tp); |
| 3324 | int depth = meet_inline_depth(tp->inline_depth()); |
| 3325 | return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative, depth); |
| 3326 | } |
| 3327 | |
| 3328 | case InstPtr: // For these, flip the call around to cut down |
| 3329 | case AryPtr: |
| 3330 | return t->xmeet(this); // Call in reverse direction |
| 3331 | |
| 3332 | } // End of switch |
| 3333 | return this; // Return the double constant |
| 3334 | } |
| 3335 | |
| 3336 | |
| 3337 | //------------------------------xdual------------------------------------------ |
| 3338 | // Dual of a pure heap pointer. No relevant klass or oop information. |
| 3339 | const Type *TypeOopPtr::xdual() const { |
| 3340 | assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here")do { if (!(klass() == Compile::current()->env()->Object_klass ())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3340, "assert(" "klass() == Compile::current()->env()->Object_klass()" ") failed", "no klasses here"); ::breakpoint(); } } while (0 ); |
| 3341 | assert(const_oop() == NULL, "no constants here")do { if (!(const_oop() == __null)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3341, "assert(" "const_oop() == __null" ") failed", "no constants here" ); ::breakpoint(); } } while (0); |
| 3342 | return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth()); |
| 3343 | } |
| 3344 | |
| 3345 | //--------------------------make_from_klass_common----------------------------- |
| 3346 | // Computes the element-type given a klass. |
| 3347 | const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) { |
| 3348 | if (klass->is_instance_klass()) { |
| 3349 | Compile* C = Compile::current(); |
| 3350 | Dependencies* deps = C->dependencies(); |
| 3351 | assert((deps != NULL) == (C->method() != NULL && C->method()->code_size() > 0), "sanity")do { if (!((deps != __null) == (C->method() != __null && C->method()->code_size() > 0))) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3351, "assert(" "(deps != __null) == (C->method() != __null && C->method()->code_size() > 0)" ") failed", "sanity"); ::breakpoint(); } } while (0); |
| 3352 | // Element is an instance |
| 3353 | bool klass_is_exact = false; |
| 3354 | if (klass->is_loaded()) { |
| 3355 | // Try to set klass_is_exact. |
| 3356 | ciInstanceKlass* ik = klass->as_instance_klass(); |
| 3357 | klass_is_exact = ik->is_final(); |
| 3358 | if (!klass_is_exact && klass_change |
| 3359 | && deps != NULL__null && UseUniqueSubclasses) { |
| 3360 | ciInstanceKlass* sub = ik->unique_concrete_subklass(); |
| 3361 | if (sub != NULL__null) { |
| 3362 | deps->assert_abstract_with_unique_concrete_subtype(ik, sub); |
| 3363 | klass = ik = sub; |
| 3364 | klass_is_exact = sub->is_final(); |
| 3365 | } |
| 3366 | } |
| 3367 | if (!klass_is_exact && try_for_exact && deps != NULL__null && |
| 3368 | !ik->is_interface() && !ik->has_subklass()) { |
| 3369 | // Add a dependence; if concrete subclass added we need to recompile |
| 3370 | deps->assert_leaf_type(ik); |
| 3371 | klass_is_exact = true; |
| 3372 | } |
| 3373 | } |
| 3374 | return TypeInstPtr::make(TypePtr::BotPTR, klass, klass_is_exact, NULL__null, 0); |
| 3375 | } else if (klass->is_obj_array_klass()) { |
| 3376 | // Element is an object array. Recursively call ourself. |
| 3377 | const TypeOopPtr *etype = TypeOopPtr::make_from_klass_common(klass->as_obj_array_klass()->element_klass(), false, try_for_exact); |
| 3378 | bool xk = etype->klass_is_exact(); |
| 3379 | const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); |
| 3380 | // We used to pass NotNull in here, asserting that the sub-arrays |
| 3381 | // are all not-null. This is not true in generally, as code can |
| 3382 | // slam NULLs down in the subarrays. |
| 3383 | const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, xk, 0); |
| 3384 | return arr; |
| 3385 | } else if (klass->is_type_array_klass()) { |
| 3386 | // Element is an typeArray |
| 3387 | const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type()); |
| 3388 | const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); |
| 3389 | // We used to pass NotNull in here, asserting that the array pointer |
| 3390 | // is not-null. That was not true in general. |
| 3391 | const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, 0); |
| 3392 | return arr; |
| 3393 | } else { |
| 3394 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3394); ::breakpoint(); } while (0); |
| 3395 | return NULL__null; |
| 3396 | } |
| 3397 | } |
| 3398 | |
| 3399 | //------------------------------make_from_constant----------------------------- |
| 3400 | // Make a java pointer from an oop constant |
| 3401 | const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o, bool require_constant) { |
| 3402 | assert(!o->is_null_object(), "null object not yet handled here.")do { if (!(!o->is_null_object())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3402, "assert(" "!o->is_null_object()" ") failed", "null object not yet handled here." ); ::breakpoint(); } } while (0); |
| 3403 | |
| 3404 | const bool make_constant = require_constant || o->should_be_constant(); |
| 3405 | |
| 3406 | ciKlass* klass = o->klass(); |
| 3407 | if (klass->is_instance_klass()) { |
| 3408 | // Element is an instance |
| 3409 | if (make_constant) { |
| 3410 | return TypeInstPtr::make(o); |
| 3411 | } else { |
| 3412 | return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL__null, 0); |
| 3413 | } |
| 3414 | } else if (klass->is_obj_array_klass()) { |
| 3415 | // Element is an object array. Recursively call ourself. |
| 3416 | const TypeOopPtr *etype = |
| 3417 | TypeOopPtr::make_from_klass_raw(klass->as_obj_array_klass()->element_klass()); |
| 3418 | const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); |
| 3419 | // We used to pass NotNull in here, asserting that the sub-arrays |
| 3420 | // are all not-null. This is not true in generally, as code can |
| 3421 | // slam NULLs down in the subarrays. |
| 3422 | if (make_constant) { |
| 3423 | return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); |
| 3424 | } else { |
| 3425 | return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); |
| 3426 | } |
| 3427 | } else if (klass->is_type_array_klass()) { |
| 3428 | // Element is an typeArray |
| 3429 | const Type* etype = |
| 3430 | (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type()); |
| 3431 | const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); |
| 3432 | // We used to pass NotNull in here, asserting that the array pointer |
| 3433 | // is not-null. That was not true in general. |
| 3434 | if (make_constant) { |
| 3435 | return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); |
| 3436 | } else { |
| 3437 | return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); |
| 3438 | } |
| 3439 | } |
| 3440 | |
| 3441 | fatal("unhandled object type")do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3441, "unhandled object type"); ::breakpoint(); } while (0); |
| 3442 | return NULL__null; |
| 3443 | } |
| 3444 | |
| 3445 | //------------------------------get_con---------------------------------------- |
| 3446 | intptr_t TypeOopPtr::get_con() const { |
| 3447 | assert( _ptr == Null || _ptr == Constant, "" )do { if (!(_ptr == Null || _ptr == Constant)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3447, "assert(" "_ptr == Null || _ptr == Constant" ") failed" , ""); ::breakpoint(); } } while (0); |
| 3448 | assert( _offset >= 0, "" )do { if (!(_offset >= 0)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3448, "assert(" "_offset >= 0" ") failed", ""); ::breakpoint (); } } while (0); |
| 3449 | |
| 3450 | if (_offset != 0) { |
| 3451 | // After being ported to the compiler interface, the compiler no longer |
| 3452 | // directly manipulates the addresses of oops. Rather, it only has a pointer |
| 3453 | // to a handle at compile time. This handle is embedded in the generated |
| 3454 | // code and dereferenced at the time the nmethod is made. Until that time, |
| 3455 | // it is not reasonable to do arithmetic with the addresses of oops (we don't |
| 3456 | // have access to the addresses!). This does not seem to currently happen, |
| 3457 | // but this assertion here is to help prevent its occurence. |
| 3458 | tty->print_cr("Found oop constant with non-zero offset"); |
| 3459 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3459); ::breakpoint(); } while (0); |
| 3460 | } |
| 3461 | |
| 3462 | return (intptr_t)const_oop()->constant_encoding(); |
| 3463 | } |
| 3464 | |
| 3465 | |
| 3466 | //-----------------------------filter------------------------------------------ |
| 3467 | // Do not allow interface-vs.-noninterface joins to collapse to top. |
| 3468 | const Type *TypeOopPtr::filter_helper(const Type *kills, bool include_speculative) const { |
| 3469 | |
| 3470 | const Type* ft = join_helper(kills, include_speculative); |
| 3471 | const TypeInstPtr* ftip = ft->isa_instptr(); |
| 3472 | const TypeInstPtr* ktip = kills->isa_instptr(); |
| 3473 | |
| 3474 | if (ft->empty()) { |
| 3475 | // Check for evil case of 'this' being a class and 'kills' expecting an |
| 3476 | // interface. This can happen because the bytecodes do not contain |
| 3477 | // enough type info to distinguish a Java-level interface variable |
| 3478 | // from a Java-level object variable. If we meet 2 classes which |
| 3479 | // both implement interface I, but their meet is at 'j/l/O' which |
| 3480 | // doesn't implement I, we have no way to tell if the result should |
| 3481 | // be 'I' or 'j/l/O'. Thus we'll pick 'j/l/O'. If this then flows |
| 3482 | // into a Phi which "knows" it's an Interface type we'll have to |
| 3483 | // uplift the type. |
| 3484 | if (!empty()) { |
| 3485 | if (ktip != NULL__null && ktip->is_loaded() && ktip->klass()->is_interface()) { |
| 3486 | return kills; // Uplift to interface |
| 3487 | } |
| 3488 | // Also check for evil cases of 'this' being a class array |
| 3489 | // and 'kills' expecting an array of interfaces. |
| 3490 | Type::get_arrays_base_elements(ft, kills, NULL__null, &ktip); |
| 3491 | if (ktip != NULL__null && ktip->is_loaded() && ktip->klass()->is_interface()) { |
| 3492 | return kills; // Uplift to array of interface |
| 3493 | } |
| 3494 | } |
| 3495 | |
| 3496 | return Type::TOP; // Canonical empty value |
| 3497 | } |
| 3498 | |
| 3499 | // If we have an interface-typed Phi or cast and we narrow to a class type, |
| 3500 | // the join should report back the class. However, if we have a J/L/Object |
| 3501 | // class-typed Phi and an interface flows in, it's possible that the meet & |
| 3502 | // join report an interface back out. This isn't possible but happens |
| 3503 | // because the type system doesn't interact well with interfaces. |
| 3504 | if (ftip != NULL__null && ktip != NULL__null && |
| 3505 | ftip->is_loaded() && ftip->klass()->is_interface() && |
| 3506 | ktip->is_loaded() && !ktip->klass()->is_interface()) { |
| 3507 | assert(!ftip->klass_is_exact(), "interface could not be exact")do { if (!(!ftip->klass_is_exact())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3507, "assert(" "!ftip->klass_is_exact()" ") failed", "interface could not be exact" ); ::breakpoint(); } } while (0); |
| 3508 | return ktip->cast_to_ptr_type(ftip->ptr()); |
| 3509 | } |
| 3510 | |
| 3511 | return ft; |
| 3512 | } |
| 3513 | |
| 3514 | //------------------------------eq--------------------------------------------- |
| 3515 | // Structural equality check for Type representations |
| 3516 | bool TypeOopPtr::eq( const Type *t ) const { |
| 3517 | const TypeOopPtr *a = (const TypeOopPtr*)t; |
| 3518 | if (_klass_is_exact != a->_klass_is_exact || |
| 3519 | _instance_id != a->_instance_id) return false; |
| 3520 | ciObject* one = const_oop(); |
| 3521 | ciObject* two = a->const_oop(); |
| 3522 | if (one == NULL__null || two == NULL__null) { |
| 3523 | return (one == two) && TypePtr::eq(t); |
| 3524 | } else { |
| 3525 | return one->equals(two) && TypePtr::eq(t); |
| 3526 | } |
| 3527 | } |
| 3528 | |
| 3529 | //------------------------------hash------------------------------------------- |
| 3530 | // Type-specific hashing function. |
| 3531 | int TypeOopPtr::hash(void) const { |
| 3532 | return |
| 3533 | java_add(java_add((jint)(const_oop() ? const_oop()->hash() : 0), (jint)_klass_is_exact), |
| 3534 | java_add((jint)_instance_id, (jint)TypePtr::hash())); |
| 3535 | } |
| 3536 | |
| 3537 | //------------------------------dump2------------------------------------------ |
| 3538 | #ifndef PRODUCT |
| 3539 | void TypeOopPtr::dump2( Dict &d, uint depth, outputStream *st ) const { |
| 3540 | st->print("oopptr:%s", ptr_msg[_ptr]); |
| 3541 | if( _klass_is_exact ) st->print(":exact"); |
| 3542 | if( const_oop() ) st->print(INTPTR_FORMAT"0x%016" "l" "x", p2i(const_oop())); |
| 3543 | switch( _offset ) { |
| 3544 | case OffsetTop: st->print("+top"); break; |
| 3545 | case OffsetBot: st->print("+any"); break; |
| 3546 | case 0: break; |
| 3547 | default: st->print("+%d",_offset); break; |
| 3548 | } |
| 3549 | if (_instance_id == InstanceTop) |
| 3550 | st->print(",iid=top"); |
| 3551 | else if (_instance_id != InstanceBot) |
| 3552 | st->print(",iid=%d",_instance_id); |
| 3553 | |
| 3554 | dump_inline_depth(st); |
| 3555 | dump_speculative(st); |
| 3556 | } |
| 3557 | #endif |
| 3558 | |
| 3559 | //------------------------------singleton-------------------------------------- |
| 3560 | // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple |
| 3561 | // constants |
| 3562 | bool TypeOopPtr::singleton(void) const { |
| 3563 | // detune optimizer to not generate constant oop + constant offset as a constant! |
| 3564 | // TopPTR, Null, AnyNull, Constant are all singletons |
| 3565 | return (_offset == 0) && !below_centerline(_ptr); |
| 3566 | } |
| 3567 | |
| 3568 | //------------------------------add_offset------------------------------------- |
| 3569 | const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const { |
| 3570 | return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth); |
| 3571 | } |
| 3572 | |
| 3573 | /** |
| 3574 | * Return same type without a speculative part |
| 3575 | */ |
| 3576 | const Type* TypeOopPtr::remove_speculative() const { |
| 3577 | if (_speculative == NULL__null) { |
| 3578 | return this; |
| 3579 | } |
| 3580 | assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth")do { if (!(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3580, "assert(" "_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom" ") failed", "non speculative type shouldn't have inline depth" ); ::breakpoint(); } } while (0); |
| 3581 | return make(_ptr, _offset, _instance_id, NULL__null, _inline_depth); |
| 3582 | } |
| 3583 | |
| 3584 | /** |
| 3585 | * Return same type but drop speculative part if we know we won't use |
| 3586 | * it |
| 3587 | */ |
| 3588 | const Type* TypeOopPtr::cleanup_speculative() const { |
| 3589 | // If the klass is exact and the ptr is not null then there's |
| 3590 | // nothing that the speculative type can help us with |
| 3591 | if (klass_is_exact() && !maybe_null()) { |
| 3592 | return remove_speculative(); |
| 3593 | } |
| 3594 | return TypePtr::cleanup_speculative(); |
| 3595 | } |
| 3596 | |
| 3597 | /** |
| 3598 | * Return same type but with a different inline depth (used for speculation) |
| 3599 | * |
| 3600 | * @param depth depth to meet with |
| 3601 | */ |
| 3602 | const TypePtr* TypeOopPtr::with_inline_depth(int depth) const { |
| 3603 | if (!UseInlineDepthForSpeculativeTypes) { |
| 3604 | return this; |
| 3605 | } |
| 3606 | return make(_ptr, _offset, _instance_id, _speculative, depth); |
| 3607 | } |
| 3608 | |
| 3609 | //------------------------------with_instance_id-------------------------------- |
| 3610 | const TypePtr* TypeOopPtr::with_instance_id(int instance_id) const { |
| 3611 | assert(_instance_id != -1, "should be known")do { if (!(_instance_id != -1)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3611, "assert(" "_instance_id != -1" ") failed", "should be known" ); ::breakpoint(); } } while (0); |
| 3612 | return make(_ptr, _offset, instance_id, _speculative, _inline_depth); |
| 3613 | } |
| 3614 | |
| 3615 | //------------------------------meet_instance_id-------------------------------- |
| 3616 | int TypeOopPtr::meet_instance_id( int instance_id ) const { |
| 3617 | // Either is 'TOP' instance? Return the other instance! |
| 3618 | if( _instance_id == InstanceTop ) return instance_id; |
| 3619 | if( instance_id == InstanceTop ) return _instance_id; |
| 3620 | // If either is different, return 'BOTTOM' instance |
| 3621 | if( _instance_id != instance_id ) return InstanceBot; |
| 3622 | return _instance_id; |
| 3623 | } |
| 3624 | |
| 3625 | //------------------------------dual_instance_id-------------------------------- |
| 3626 | int TypeOopPtr::dual_instance_id( ) const { |
| 3627 | if( _instance_id == InstanceTop ) return InstanceBot; // Map TOP into BOTTOM |
| 3628 | if( _instance_id == InstanceBot ) return InstanceTop; // Map BOTTOM into TOP |
| 3629 | return _instance_id; // Map everything else into self |
| 3630 | } |
| 3631 | |
| 3632 | /** |
| 3633 | * Check whether new profiling would improve speculative type |
| 3634 | * |
| 3635 | * @param exact_kls class from profiling |
| 3636 | * @param inline_depth inlining depth of profile point |
| 3637 | * |
| 3638 | * @return true if type profile is valuable |
| 3639 | */ |
| 3640 | bool TypeOopPtr::would_improve_type(ciKlass* exact_kls, int inline_depth) const { |
| 3641 | // no way to improve an already exact type |
| 3642 | if (klass_is_exact()) { |
| 3643 | return false; |
| 3644 | } |
| 3645 | return TypePtr::would_improve_type(exact_kls, inline_depth); |
| 3646 | } |
| 3647 | |
| 3648 | //============================================================================= |
| 3649 | // Convenience common pre-built types. |
| 3650 | const TypeInstPtr *TypeInstPtr::NOTNULL; |
| 3651 | const TypeInstPtr *TypeInstPtr::BOTTOM; |
| 3652 | const TypeInstPtr *TypeInstPtr::MIRROR; |
| 3653 | const TypeInstPtr *TypeInstPtr::MARK; |
| 3654 | const TypeInstPtr *TypeInstPtr::KLASS; |
| 3655 | |
| 3656 | //------------------------------TypeInstPtr------------------------------------- |
| 3657 | TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, |
| 3658 | int instance_id, const TypePtr* speculative, int inline_depth) |
| 3659 | : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative, inline_depth), |
| 3660 | _name(k->name()) { |
| 3661 | assert(k != NULL &&do { if (!(k != __null && (k->is_loaded() || o == __null ))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3663, "assert(" "k != __null && (k->is_loaded() || o == __null)" ") failed", "cannot have constants with non-loaded klass"); :: breakpoint(); } } while (0) |
| 3662 | (k->is_loaded() || o == NULL),do { if (!(k != __null && (k->is_loaded() || o == __null ))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3663, "assert(" "k != __null && (k->is_loaded() || o == __null)" ") failed", "cannot have constants with non-loaded klass"); :: breakpoint(); } } while (0) |
| 3663 | "cannot have constants with non-loaded klass")do { if (!(k != __null && (k->is_loaded() || o == __null ))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3663, "assert(" "k != __null && (k->is_loaded() || o == __null)" ") failed", "cannot have constants with non-loaded klass"); :: breakpoint(); } } while (0); |
| 3664 | }; |
| 3665 | |
| 3666 | //------------------------------make------------------------------------------- |
| 3667 | const TypeInstPtr *TypeInstPtr::make(PTR ptr, |
| 3668 | ciKlass* k, |
| 3669 | bool xk, |
| 3670 | ciObject* o, |
| 3671 | int offset, |
| 3672 | int instance_id, |
| 3673 | const TypePtr* speculative, |
| 3674 | int inline_depth) { |
| 3675 | assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance")do { if (!(!k->is_loaded() || k->is_instance_klass())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3675, "assert(" "!k->is_loaded() || k->is_instance_klass()" ") failed", "Must be for instance"); ::breakpoint(); } } while (0); |
| 3676 | // Either const_oop() is NULL or else ptr is Constant |
| 3677 | assert( (!o && ptr != Constant) || (o && ptr == Constant),do { if (!((!o && ptr != Constant) || (o && ptr == Constant))) { (*g_assert_poison) = 'X';; report_vm_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3678, "assert(" "(!o && ptr != Constant) || (o && ptr == Constant)" ") failed", "constant pointers must have a value supplied"); ::breakpoint(); } } while (0) |
| 3678 | "constant pointers must have a value supplied" )do { if (!((!o && ptr != Constant) || (o && ptr == Constant))) { (*g_assert_poison) = 'X';; report_vm_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3678, "assert(" "(!o && ptr != Constant) || (o && ptr == Constant)" ") failed", "constant pointers must have a value supplied"); ::breakpoint(); } } while (0); |
| 3679 | // Ptr is never Null |
| 3680 | assert( ptr != Null, "NULL pointers are not typed" )do { if (!(ptr != Null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3680, "assert(" "ptr != Null" ") failed", "NULL pointers are not typed" ); ::breakpoint(); } } while (0); |
| 3681 | |
| 3682 | assert(instance_id <= 0 || xk, "instances are always exactly typed")do { if (!(instance_id <= 0 || xk)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3682, "assert(" "instance_id <= 0 || xk" ") failed", "instances are always exactly typed" ); ::breakpoint(); } } while (0); |
| 3683 | if (ptr == Constant) { |
| 3684 | // Note: This case includes meta-object constants, such as methods. |
| 3685 | xk = true; |
| 3686 | } else if (k->is_loaded()) { |
| 3687 | ciInstanceKlass* ik = k->as_instance_klass(); |
| 3688 | if (!xk && ik->is_final()) xk = true; // no inexact final klass |
| 3689 | if (xk && ik->is_interface()) xk = false; // no exact interface |
| 3690 | } |
| 3691 | |
| 3692 | // Now hash this baby |
| 3693 | TypeInstPtr *result = |
| 3694 | (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative, inline_depth))->hashcons(); |
| 3695 | |
| 3696 | return result; |
| 3697 | } |
| 3698 | |
| 3699 | /** |
| 3700 | * Create constant type for a constant boxed value |
| 3701 | */ |
| 3702 | const Type* TypeInstPtr::get_const_boxed_value() const { |
| 3703 | assert(is_ptr_to_boxed_value(), "should be called only for boxed value")do { if (!(is_ptr_to_boxed_value())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3703, "assert(" "is_ptr_to_boxed_value()" ") failed", "should be called only for boxed value" ); ::breakpoint(); } } while (0); |
| 3704 | assert((const_oop() != NULL), "should be called only for constant object")do { if (!((const_oop() != __null))) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3704, "assert(" "(const_oop() != __null)" ") failed", "should be called only for constant object" ); ::breakpoint(); } } while (0); |
| 3705 | ciConstant constant = const_oop()->as_instance()->field_value_by_offset(offset()); |
| 3706 | BasicType bt = constant.basic_type(); |
| 3707 | switch (bt) { |
| 3708 | case T_BOOLEAN: return TypeInt::make(constant.as_boolean()); |
| 3709 | case T_INT: return TypeInt::make(constant.as_int()); |
| 3710 | case T_CHAR: return TypeInt::make(constant.as_char()); |
| 3711 | case T_BYTE: return TypeInt::make(constant.as_byte()); |
| 3712 | case T_SHORT: return TypeInt::make(constant.as_short()); |
| 3713 | case T_FLOAT: return TypeF::make(constant.as_float()); |
| 3714 | case T_DOUBLE: return TypeD::make(constant.as_double()); |
| 3715 | case T_LONG: return TypeLong::make(constant.as_long()); |
| 3716 | default: break; |
| 3717 | } |
| 3718 | fatal("Invalid boxed value type '%s'", type2name(bt))do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3718, "Invalid boxed value type '%s'", type2name(bt)); ::breakpoint (); } while (0); |
| 3719 | return NULL__null; |
| 3720 | } |
| 3721 | |
| 3722 | //------------------------------cast_to_ptr_type------------------------------- |
| 3723 | const TypeInstPtr *TypeInstPtr::cast_to_ptr_type(PTR ptr) const { |
| 3724 | if( ptr == _ptr ) return this; |
| 3725 | // Reconstruct _sig info here since not a problem with later lazy |
| 3726 | // construction, _sig will show up on demand. |
| 3727 | return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, _inline_depth); |
| 3728 | } |
| 3729 | |
| 3730 | |
| 3731 | //-----------------------------cast_to_exactness------------------------------- |
| 3732 | const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const { |
| 3733 | if( klass_is_exact == _klass_is_exact ) return this; |
| 3734 | if (!_klass->is_loaded()) return this; |
| 3735 | ciInstanceKlass* ik = _klass->as_instance_klass(); |
| 3736 | if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk |
| 3737 | if( ik->is_interface() ) return this; // cannot set xk |
| 3738 | return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative, _inline_depth); |
| 3739 | } |
| 3740 | |
| 3741 | //-----------------------------cast_to_instance_id---------------------------- |
| 3742 | const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { |
| 3743 | if( instance_id == _instance_id ) return this; |
| 3744 | return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative, _inline_depth); |
| 3745 | } |
| 3746 | |
| 3747 | //------------------------------xmeet_unloaded--------------------------------- |
| 3748 | // Compute the MEET of two InstPtrs when at least one is unloaded. |
| 3749 | // Assume classes are different since called after check for same name/class-loader |
| 3750 | const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { |
| 3751 | int off = meet_offset(tinst->offset()); |
| 3752 | PTR ptr = meet_ptr(tinst->ptr()); |
| 3753 | int instance_id = meet_instance_id(tinst->instance_id()); |
| 3754 | const TypePtr* speculative = xmeet_speculative(tinst); |
| 3755 | int depth = meet_inline_depth(tinst->inline_depth()); |
| 3756 | |
| 3757 | const TypeInstPtr *loaded = is_loaded() ? this : tinst; |
| 3758 | const TypeInstPtr *unloaded = is_loaded() ? tinst : this; |
| 3759 | if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) { |
| 3760 | // |
| 3761 | // Meet unloaded class with java/lang/Object |
| 3762 | // |
| 3763 | // Meet |
| 3764 | // | Unloaded Class |
| 3765 | // Object | TOP | AnyNull | Constant | NotNull | BOTTOM | |
| 3766 | // =================================================================== |
| 3767 | // TOP | ..........................Unloaded......................| |
| 3768 | // AnyNull | U-AN |................Unloaded......................| |
| 3769 | // Constant | ... O-NN .................................. | O-BOT | |
| 3770 | // NotNull | ... O-NN .................................. | O-BOT | |
| 3771 | // BOTTOM | ........................Object-BOTTOM ..................| |
| 3772 | // |
| 3773 | assert(loaded->ptr() != TypePtr::Null, "insanity check")do { if (!(loaded->ptr() != TypePtr::Null)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3773, "assert(" "loaded->ptr() != TypePtr::Null" ") failed" , "insanity check"); ::breakpoint(); } } while (0); |
| 3774 | // |
| 3775 | if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; } |
| 3776 | else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL__null, off, instance_id, speculative, depth); } |
| 3777 | else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } |
| 3778 | else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) { |
| 3779 | if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } |
| 3780 | else { return TypeInstPtr::NOTNULL; } |
| 3781 | } |
| 3782 | else if( unloaded->ptr() == TypePtr::TopPTR ) { return unloaded; } |
| 3783 | |
| 3784 | return unloaded->cast_to_ptr_type(TypePtr::AnyNull)->is_instptr(); |
| 3785 | } |
| 3786 | |
| 3787 | // Both are unloaded, not the same class, not Object |
| 3788 | // Or meet unloaded with a different loaded class, not java/lang/Object |
| 3789 | if( ptr != TypePtr::BotPTR ) { |
| 3790 | return TypeInstPtr::NOTNULL; |
| 3791 | } |
| 3792 | return TypeInstPtr::BOTTOM; |
| 3793 | } |
| 3794 | |
| 3795 | |
| 3796 | //------------------------------meet------------------------------------------- |
| 3797 | // Compute the MEET of two types. It returns a new Type object. |
| 3798 | const Type *TypeInstPtr::xmeet_helper(const Type *t) const { |
| 3799 | // Perform a fast test for common case; meeting the same types together. |
| 3800 | if( this == t ) return this; // Meeting same type-rep? |
| 3801 | |
| 3802 | // Current "this->_base" is Pointer |
| 3803 | switch (t->base()) { // switch on original type |
| 3804 | |
| 3805 | case Int: // Mixing ints & oops happens when javac |
| 3806 | case Long: // reuses local variables |
| 3807 | case FloatTop: |
| 3808 | case FloatCon: |
| 3809 | case FloatBot: |
| 3810 | case DoubleTop: |
| 3811 | case DoubleCon: |
| 3812 | case DoubleBot: |
| 3813 | case NarrowOop: |
| 3814 | case NarrowKlass: |
| 3815 | case Bottom: // Ye Olde Default |
| 3816 | return Type::BOTTOM; |
| 3817 | case Top: |
| 3818 | return this; |
| 3819 | |
| 3820 | default: // All else is a mistake |
| 3821 | typerr(t); |
| 3822 | |
| 3823 | case MetadataPtr: |
| 3824 | case KlassPtr: |
| 3825 | case InstKlassPtr: |
| 3826 | case AryKlassPtr: |
| 3827 | case RawPtr: return TypePtr::BOTTOM; |
| 3828 | |
| 3829 | case AryPtr: { // All arrays inherit from Object class |
| 3830 | // Call in reverse direction to avoid duplication |
| 3831 | return t->is_aryptr()->xmeet_helper(this); |
| 3832 | } |
| 3833 | |
| 3834 | case OopPtr: { // Meeting to OopPtrs |
| 3835 | // Found a OopPtr type vs self-InstPtr type |
| 3836 | const TypeOopPtr *tp = t->is_oopptr(); |
| 3837 | int offset = meet_offset(tp->offset()); |
| 3838 | PTR ptr = meet_ptr(tp->ptr()); |
| 3839 | switch (tp->ptr()) { |
| 3840 | case TopPTR: |
| 3841 | case AnyNull: { |
| 3842 | int instance_id = meet_instance_id(InstanceTop); |
| 3843 | const TypePtr* speculative = xmeet_speculative(tp); |
| 3844 | int depth = meet_inline_depth(tp->inline_depth()); |
| 3845 | return make(ptr, klass(), klass_is_exact(), |
| 3846 | (ptr == Constant ? const_oop() : NULL__null), offset, instance_id, speculative, depth); |
| 3847 | } |
| 3848 | case NotNull: |
| 3849 | case BotPTR: { |
| 3850 | int instance_id = meet_instance_id(tp->instance_id()); |
| 3851 | const TypePtr* speculative = xmeet_speculative(tp); |
| 3852 | int depth = meet_inline_depth(tp->inline_depth()); |
| 3853 | return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth); |
| 3854 | } |
| 3855 | default: typerr(t); |
| 3856 | } |
| 3857 | } |
| 3858 | |
| 3859 | case AnyPtr: { // Meeting to AnyPtrs |
| 3860 | // Found an AnyPtr type vs self-InstPtr type |
| 3861 | const TypePtr *tp = t->is_ptr(); |
| 3862 | int offset = meet_offset(tp->offset()); |
| 3863 | PTR ptr = meet_ptr(tp->ptr()); |
| 3864 | int instance_id = meet_instance_id(InstanceTop); |
| 3865 | const TypePtr* speculative = xmeet_speculative(tp); |
| 3866 | int depth = meet_inline_depth(tp->inline_depth()); |
| 3867 | switch (tp->ptr()) { |
| 3868 | case Null: |
| 3869 | if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset, speculative, depth); |
| 3870 | // else fall through to AnyNull |
| 3871 | case TopPTR: |
| 3872 | case AnyNull: { |
| 3873 | return make(ptr, klass(), klass_is_exact(), |
| 3874 | (ptr == Constant ? const_oop() : NULL__null), offset, instance_id, speculative, depth); |
| 3875 | } |
| 3876 | case NotNull: |
| 3877 | case BotPTR: |
| 3878 | return TypePtr::make(AnyPtr, ptr, offset, speculative,depth); |
| 3879 | default: typerr(t); |
| 3880 | } |
| 3881 | } |
| 3882 | |
| 3883 | /* |
| 3884 | A-top } |
| 3885 | / | \ } Tops |
| 3886 | B-top A-any C-top } |
| 3887 | | / | \ | } Any-nulls |
| 3888 | B-any | C-any } |
| 3889 | | | | |
| 3890 | B-con A-con C-con } constants; not comparable across classes |
| 3891 | | | | |
| 3892 | B-not | C-not } |
| 3893 | | \ | / | } not-nulls |
| 3894 | B-bot A-not C-bot } |
| 3895 | \ | / } Bottoms |
| 3896 | A-bot } |
| 3897 | */ |
| 3898 | |
| 3899 | case InstPtr: { // Meeting 2 Oops? |
| 3900 | // Found an InstPtr sub-type vs self-InstPtr type |
| 3901 | const TypeInstPtr *tinst = t->is_instptr(); |
| 3902 | int off = meet_offset(tinst->offset()); |
| 3903 | PTR ptr = meet_ptr(tinst->ptr()); |
| 3904 | int instance_id = meet_instance_id(tinst->instance_id()); |
| 3905 | const TypePtr* speculative = xmeet_speculative(tinst); |
| 3906 | int depth = meet_inline_depth(tinst->inline_depth()); |
| 3907 | ciKlass* tinst_klass = tinst->klass(); |
| 3908 | ciKlass* this_klass = klass(); |
| 3909 | bool tinst_xk = tinst->klass_is_exact(); |
| 3910 | bool this_xk = klass_is_exact(); |
| 3911 | |
| 3912 | ciKlass* res_klass = NULL__null; |
| 3913 | bool res_xk = false; |
| 3914 | const Type* res; |
| 3915 | MeetResult kind = meet_instptr(ptr, this_klass, tinst_klass, this_xk, tinst_xk, this->_ptr, tinst->_ptr, res_klass, res_xk); |
| 3916 | if (kind == UNLOADED) { |
| 3917 | // One of these classes has not been loaded |
| 3918 | const TypeInstPtr* unloaded_meet = xmeet_unloaded(tinst); |
| 3919 | #ifndef PRODUCT |
| 3920 | if (PrintOpto && Verbose) { |
| 3921 | tty->print("meet of unloaded classes resulted in: "); |
| 3922 | unloaded_meet->dump(); |
| 3923 | tty->cr(); |
| 3924 | tty->print(" this == "); |
| 3925 | dump(); |
| 3926 | tty->cr(); |
| 3927 | tty->print(" tinst == "); |
| 3928 | tinst->dump(); |
| 3929 | tty->cr(); |
| 3930 | } |
| 3931 | #endif |
| 3932 | res = unloaded_meet; |
| 3933 | } else { |
| 3934 | if (kind == NOT_SUBTYPE && instance_id > 0) { |
| 3935 | instance_id = InstanceBot; |
| 3936 | } else if (kind == LCA) { |
| 3937 | instance_id = InstanceBot; |
| 3938 | } |
| 3939 | ciObject* o = NULL__null; // Assume not constant when done |
| 3940 | ciObject* this_oop = const_oop(); |
| 3941 | ciObject* tinst_oop = tinst->const_oop(); |
| 3942 | if (ptr == Constant) { |
| 3943 | if (this_oop != NULL__null && tinst_oop != NULL__null && |
| 3944 | this_oop->equals(tinst_oop)) |
| 3945 | o = this_oop; |
| 3946 | else if (above_centerline(_ptr)) { |
| 3947 | assert(!tinst_klass->is_interface(), "")do { if (!(!tinst_klass->is_interface())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3947, "assert(" "!tinst_klass->is_interface()" ") failed" , ""); ::breakpoint(); } } while (0); |
| 3948 | o = tinst_oop; |
| 3949 | } else if (above_centerline(tinst->_ptr)) { |
| 3950 | assert(!this_klass->is_interface(), "")do { if (!(!this_klass->is_interface())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 3950, "assert(" "!this_klass->is_interface()" ") failed" , ""); ::breakpoint(); } } while (0); |
| 3951 | o = this_oop; |
| 3952 | } else |
| 3953 | ptr = NotNull; |
| 3954 | } |
| 3955 | res = make(ptr, res_klass, res_xk, o, off, instance_id, speculative, depth); |
| 3956 | } |
| 3957 | |
| 3958 | return res; |
| 3959 | |
| 3960 | } // End of case InstPtr |
| 3961 | |
| 3962 | } // End of switch |
| 3963 | return this; // Return the double constant |
| 3964 | } |
| 3965 | |
| 3966 | TypePtr::MeetResult TypePtr::meet_instptr(PTR &ptr, ciKlass* this_klass, ciKlass* tinst_klass, bool this_xk, bool tinst_xk, |
| 3967 | PTR this_ptr, |
| 3968 | PTR tinst_ptr, ciKlass*&res_klass, bool &res_xk) { |
| 3969 | |
| 3970 | // Check for easy case; klasses are equal (and perhaps not loaded!) |
| 3971 | // If we have constants, then we created oops so classes are loaded |
| 3972 | // and we can handle the constants further down. This case handles |
| 3973 | // both-not-loaded or both-loaded classes |
| 3974 | if (ptr != Constant && this_klass->equals(tinst_klass) && this_xk == tinst_xk) { |
| 3975 | res_klass = this_klass; |
| 3976 | res_xk = this_xk; |
| 3977 | return QUICK; |
| 3978 | } |
| 3979 | |
| 3980 | // Classes require inspection in the Java klass hierarchy. Must be loaded. |
| 3981 | if (!tinst_klass->is_loaded() || !this_klass->is_loaded()) { |
| 3982 | return UNLOADED; |
| 3983 | } |
| 3984 | |
| 3985 | // Handle mixing oops and interfaces first. |
| 3986 | if (this_klass->is_interface() && !(tinst_klass->is_interface() || |
| 3987 | tinst_klass == ciEnv::current()->Object_klass())) { |
| 3988 | ciKlass *tmp = tinst_klass; // Swap interface around |
| 3989 | tinst_klass = this_klass; |
| 3990 | this_klass = tmp; |
| 3991 | bool tmp2 = tinst_xk; |
| 3992 | tinst_xk = this_xk; |
| 3993 | this_xk = tmp2; |
| 3994 | } |
| 3995 | if (tinst_klass->is_interface() && |
| 3996 | !(this_klass->is_interface() || |
| 3997 | // Treat java/lang/Object as an honorary interface, |
| 3998 | // because we need a bottom for the interface hierarchy. |
| 3999 | this_klass == ciEnv::current()->Object_klass())) { |
| 4000 | // Oop meets interface! |
| 4001 | |
| 4002 | // See if the oop subtypes (implements) interface. |
| 4003 | if (this_klass->is_subtype_of(tinst_klass)) { |
| 4004 | // Oop indeed subtypes. Now keep oop or interface depending |
| 4005 | // on whether we are both above the centerline or either is |
| 4006 | // below the centerline. If we are on the centerline |
| 4007 | // (e.g., Constant vs. AnyNull interface), use the constant. |
| 4008 | res_klass = below_centerline(ptr) ? tinst_klass : this_klass; |
| 4009 | // If we are keeping this_klass, keep its exactness too. |
| 4010 | res_xk = below_centerline(ptr) ? tinst_xk : this_xk; |
| 4011 | return SUBTYPE; |
| 4012 | } else { // Does not implement, fall to Object |
| 4013 | // Oop does not implement interface, so mixing falls to Object |
| 4014 | // just like the verifier does (if both are above the |
| 4015 | // centerline fall to interface) |
| 4016 | res_klass = above_centerline(ptr) ? tinst_klass : ciEnv::current()->Object_klass(); |
| 4017 | res_xk = above_centerline(ptr) ? tinst_xk : false; |
| 4018 | // Watch out for Constant vs. AnyNull interface. |
| 4019 | if (ptr == Constant) ptr = NotNull; // forget it was a constant |
| 4020 | return NOT_SUBTYPE; |
| 4021 | } |
| 4022 | } |
| 4023 | |
| 4024 | // Either oop vs oop or interface vs interface or interface vs Object |
| 4025 | |
| 4026 | // !!! Here's how the symmetry requirement breaks down into invariants: |
| 4027 | // If we split one up & one down AND they subtype, take the down man. |
| 4028 | // If we split one up & one down AND they do NOT subtype, "fall hard". |
| 4029 | // If both are up and they subtype, take the subtype class. |
| 4030 | // If both are up and they do NOT subtype, "fall hard". |
| 4031 | // If both are down and they subtype, take the supertype class. |
| 4032 | // If both are down and they do NOT subtype, "fall hard". |
| 4033 | // Constants treated as down. |
| 4034 | |
| 4035 | // Now, reorder the above list; observe that both-down+subtype is also |
| 4036 | // "fall hard"; "fall hard" becomes the default case: |
| 4037 | // If we split one up & one down AND they subtype, take the down man. |
| 4038 | // If both are up and they subtype, take the subtype class. |
| 4039 | |
| 4040 | // If both are down and they subtype, "fall hard". |
| 4041 | // If both are down and they do NOT subtype, "fall hard". |
| 4042 | // If both are up and they do NOT subtype, "fall hard". |
| 4043 | // If we split one up & one down AND they do NOT subtype, "fall hard". |
| 4044 | |
| 4045 | // If a proper subtype is exact, and we return it, we return it exactly. |
| 4046 | // If a proper supertype is exact, there can be no subtyping relationship! |
| 4047 | // If both types are equal to the subtype, exactness is and-ed below the |
| 4048 | // centerline and or-ed above it. (N.B. Constants are always exact.) |
| 4049 | |
| 4050 | // Check for subtyping: |
| 4051 | ciKlass *subtype = NULL__null; |
| 4052 | bool subtype_exact = false; |
| 4053 | if (tinst_klass->equals(this_klass)) { |
| 4054 | subtype = this_klass; |
| 4055 | subtype_exact = below_centerline(ptr) ? (this_xk && tinst_xk) : (this_xk || tinst_xk); |
| 4056 | } else if (!tinst_xk && this_klass->is_subtype_of(tinst_klass)) { |
| 4057 | subtype = this_klass; // Pick subtyping class |
| 4058 | subtype_exact = this_xk; |
| 4059 | } else if (!this_xk && tinst_klass->is_subtype_of(this_klass)) { |
| 4060 | subtype = tinst_klass; // Pick subtyping class |
| 4061 | subtype_exact = tinst_xk; |
| 4062 | } |
| 4063 | |
| 4064 | if (subtype) { |
| 4065 | if (above_centerline(ptr)) { // both are up? |
| 4066 | this_klass = tinst_klass = subtype; |
| 4067 | this_xk = tinst_xk = subtype_exact; |
| 4068 | } else if (above_centerline(this_ptr) && !above_centerline(tinst_ptr)) { |
| 4069 | this_klass = tinst_klass; // tinst is down; keep down man |
| 4070 | this_xk = tinst_xk; |
| 4071 | } else if (above_centerline(tinst_ptr) && !above_centerline(this_ptr)) { |
| 4072 | tinst_klass = this_klass; // this is down; keep down man |
| 4073 | tinst_xk = this_xk; |
| 4074 | } else { |
| 4075 | this_xk = subtype_exact; // either they are equal, or we'll do an LCA |
| 4076 | } |
| 4077 | } |
| 4078 | |
| 4079 | // Check for classes now being equal |
| 4080 | if (tinst_klass->equals(this_klass)) { |
| 4081 | // If the klasses are equal, the constants may still differ. Fall to |
| 4082 | // NotNull if they do (neither constant is NULL; that is a special case |
| 4083 | // handled elsewhere). |
| 4084 | res_klass = this_klass; |
| 4085 | res_xk = this_xk; |
| 4086 | return SUBTYPE; |
| 4087 | } // Else classes are not equal |
| 4088 | |
| 4089 | // Since klasses are different, we require a LCA in the Java |
| 4090 | // class hierarchy - which means we have to fall to at least NotNull. |
| 4091 | if (ptr == TopPTR || ptr == AnyNull || ptr == Constant) { |
| 4092 | ptr = NotNull; |
| 4093 | } |
| 4094 | |
| 4095 | // Now we find the LCA of Java classes |
| 4096 | ciKlass* k = this_klass->least_common_ancestor(tinst_klass); |
| 4097 | |
| 4098 | res_klass = k; |
| 4099 | res_xk = false; |
| 4100 | |
| 4101 | return LCA; |
| 4102 | } |
| 4103 | |
| 4104 | |
| 4105 | //------------------------java_mirror_type-------------------------------------- |
| 4106 | ciType* TypeInstPtr::java_mirror_type() const { |
| 4107 | // must be a singleton type |
| 4108 | if( const_oop() == NULL__null ) return NULL__null; |
| 4109 | |
| 4110 | // must be of type java.lang.Class |
| 4111 | if( klass() != ciEnv::current()->Class_klass() ) return NULL__null; |
| 4112 | |
| 4113 | return const_oop()->as_instance()->java_mirror_type(); |
| 4114 | } |
| 4115 | |
| 4116 | |
| 4117 | //------------------------------xdual------------------------------------------ |
| 4118 | // Dual: do NOT dual on klasses. This means I do NOT understand the Java |
| 4119 | // inheritance mechanism. |
| 4120 | const Type *TypeInstPtr::xdual() const { |
| 4121 | return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth()); |
| 4122 | } |
| 4123 | |
| 4124 | //------------------------------eq--------------------------------------------- |
| 4125 | // Structural equality check for Type representations |
| 4126 | bool TypeInstPtr::eq( const Type *t ) const { |
| 4127 | const TypeInstPtr *p = t->is_instptr(); |
| 4128 | return |
| 4129 | klass()->equals(p->klass()) && |
| 4130 | TypeOopPtr::eq(p); // Check sub-type stuff |
| 4131 | } |
| 4132 | |
| 4133 | //------------------------------hash------------------------------------------- |
| 4134 | // Type-specific hashing function. |
| 4135 | int TypeInstPtr::hash(void) const { |
| 4136 | int hash = java_add((jint)klass()->hash(), (jint)TypeOopPtr::hash()); |
| 4137 | return hash; |
| 4138 | } |
| 4139 | |
| 4140 | //------------------------------dump2------------------------------------------ |
| 4141 | // Dump oop Type |
| 4142 | #ifndef PRODUCT |
| 4143 | void TypeInstPtr::dump2(Dict &d, uint depth, outputStream* st) const { |
| 4144 | // Print the name of the klass. |
| 4145 | klass()->print_name_on(st); |
| 4146 | |
| 4147 | switch( _ptr ) { |
| 4148 | case Constant: |
| 4149 | if (WizardMode || Verbose) { |
| 4150 | ResourceMark rm; |
| 4151 | stringStream ss; |
| 4152 | |
| 4153 | st->print(" "); |
| 4154 | const_oop()->print_oop(&ss); |
| 4155 | // 'const_oop->print_oop()' may emit newlines('\n') into ss. |
| 4156 | // suppress newlines from it so -XX:+Verbose -XX:+PrintIdeal dumps one-liner for each node. |
| 4157 | char* buf = ss.as_string(/* c_heap= */false); |
| 4158 | StringUtils::replace_no_expand(buf, "\n", ""); |
| 4159 | st->print_raw(buf); |
| 4160 | } |
| 4161 | case BotPTR: |
| 4162 | if (!WizardMode && !Verbose) { |
| 4163 | if( _klass_is_exact ) st->print(":exact"); |
| 4164 | break; |
| 4165 | } |
| 4166 | case TopPTR: |
| 4167 | case AnyNull: |
| 4168 | case NotNull: |
| 4169 | st->print(":%s", ptr_msg[_ptr]); |
| 4170 | if( _klass_is_exact ) st->print(":exact"); |
| 4171 | break; |
| 4172 | default: |
| 4173 | break; |
| 4174 | } |
| 4175 | |
| 4176 | if( _offset ) { // Dump offset, if any |
| 4177 | if( _offset == OffsetBot ) st->print("+any"); |
| 4178 | else if( _offset == OffsetTop ) st->print("+unknown"); |
| 4179 | else st->print("+%d", _offset); |
| 4180 | } |
| 4181 | |
| 4182 | st->print(" *"); |
| 4183 | if (_instance_id == InstanceTop) |
| 4184 | st->print(",iid=top"); |
| 4185 | else if (_instance_id != InstanceBot) |
| 4186 | st->print(",iid=%d",_instance_id); |
| 4187 | |
| 4188 | dump_inline_depth(st); |
| 4189 | dump_speculative(st); |
| 4190 | } |
| 4191 | #endif |
| 4192 | |
| 4193 | //------------------------------add_offset------------------------------------- |
| 4194 | const TypePtr *TypeInstPtr::add_offset(intptr_t offset) const { |
| 4195 | return make(_ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset), |
| 4196 | _instance_id, add_offset_speculative(offset), _inline_depth); |
| 4197 | } |
| 4198 | |
| 4199 | const Type *TypeInstPtr::remove_speculative() const { |
| 4200 | if (_speculative == NULL__null) { |
| 4201 | return this; |
| 4202 | } |
| 4203 | assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth")do { if (!(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4203, "assert(" "_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom" ") failed", "non speculative type shouldn't have inline depth" ); ::breakpoint(); } } while (0); |
| 4204 | return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, |
| 4205 | _instance_id, NULL__null, _inline_depth); |
| 4206 | } |
| 4207 | |
| 4208 | const TypePtr *TypeInstPtr::with_inline_depth(int depth) const { |
| 4209 | if (!UseInlineDepthForSpeculativeTypes) { |
| 4210 | return this; |
| 4211 | } |
| 4212 | return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, depth); |
| 4213 | } |
| 4214 | |
| 4215 | const TypePtr *TypeInstPtr::with_instance_id(int instance_id) const { |
| 4216 | assert(is_known_instance(), "should be known")do { if (!(is_known_instance())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4216, "assert(" "is_known_instance()" ") failed", "should be known" ); ::breakpoint(); } } while (0); |
| 4217 | return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, instance_id, _speculative, _inline_depth); |
| 4218 | } |
| 4219 | |
| 4220 | const TypeKlassPtr* TypeInstPtr::as_klass_type(bool try_for_exact) const { |
| 4221 | bool xk = klass_is_exact(); |
| 4222 | ciInstanceKlass* ik = klass()->as_instance_klass(); |
| 4223 | if (try_for_exact && !xk && !ik->has_subklass() && !ik->is_final() && !ik->is_interface()) { |
| 4224 | Compile* C = Compile::current(); |
| 4225 | Dependencies* deps = C->dependencies(); |
| 4226 | deps->assert_leaf_type(ik); |
| 4227 | xk = true; |
| 4228 | } |
| 4229 | return TypeInstKlassPtr::make(xk ? TypePtr::Constant : TypePtr::NotNull, klass(), 0); |
| 4230 | } |
| 4231 | |
| 4232 | //============================================================================= |
| 4233 | // Convenience common pre-built types. |
| 4234 | const TypeAryPtr *TypeAryPtr::RANGE; |
| 4235 | const TypeAryPtr *TypeAryPtr::OOPS; |
| 4236 | const TypeAryPtr *TypeAryPtr::NARROWOOPS; |
| 4237 | const TypeAryPtr *TypeAryPtr::BYTES; |
| 4238 | const TypeAryPtr *TypeAryPtr::SHORTS; |
| 4239 | const TypeAryPtr *TypeAryPtr::CHARS; |
| 4240 | const TypeAryPtr *TypeAryPtr::INTS; |
| 4241 | const TypeAryPtr *TypeAryPtr::LONGS; |
| 4242 | const TypeAryPtr *TypeAryPtr::FLOATS; |
| 4243 | const TypeAryPtr *TypeAryPtr::DOUBLES; |
| 4244 | |
| 4245 | //------------------------------make------------------------------------------- |
| 4246 | const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, |
| 4247 | int instance_id, const TypePtr* speculative, int inline_depth) { |
| 4248 | assert(!(k == NULL && ary->_elem->isa_int()),do { if (!(!(k == __null && ary->_elem->isa_int ()))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4249, "assert(" "!(k == __null && ary->_elem->isa_int())" ") failed", "integral arrays must be pre-equipped with a class" ); ::breakpoint(); } } while (0) |
| 4249 | "integral arrays must be pre-equipped with a class")do { if (!(!(k == __null && ary->_elem->isa_int ()))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4249, "assert(" "!(k == __null && ary->_elem->isa_int())" ") failed", "integral arrays must be pre-equipped with a class" ); ::breakpoint(); } } while (0); |
| 4250 | if (!xk) xk = ary->ary_must_be_exact(); |
| 4251 | assert(instance_id <= 0 || xk, "instances are always exactly typed")do { if (!(instance_id <= 0 || xk)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4251, "assert(" "instance_id <= 0 || xk" ") failed", "instances are always exactly typed" ); ::breakpoint(); } } while (0); |
| 4252 | return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL__null, ary, k, xk, offset, instance_id, false, speculative, inline_depth))->hashcons(); |
| 4253 | } |
| 4254 | |
| 4255 | //------------------------------make------------------------------------------- |
| 4256 | const TypeAryPtr *TypeAryPtr::make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, |
| 4257 | int instance_id, const TypePtr* speculative, int inline_depth, |
| 4258 | bool is_autobox_cache) { |
| 4259 | assert(!(k == NULL && ary->_elem->isa_int()),do { if (!(!(k == __null && ary->_elem->isa_int ()))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4260, "assert(" "!(k == __null && ary->_elem->isa_int())" ") failed", "integral arrays must be pre-equipped with a class" ); ::breakpoint(); } } while (0) |
| 4260 | "integral arrays must be pre-equipped with a class")do { if (!(!(k == __null && ary->_elem->isa_int ()))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4260, "assert(" "!(k == __null && ary->_elem->isa_int())" ") failed", "integral arrays must be pre-equipped with a class" ); ::breakpoint(); } } while (0); |
| 4261 | assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" )do { if (!((ptr==Constant && o) || (ptr!=Constant && !o))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4261, "assert(" "(ptr==Constant && o) || (ptr!=Constant && !o)" ") failed", ""); ::breakpoint(); } } while (0); |
| 4262 | if (!xk) xk = (o != NULL__null) || ary->ary_must_be_exact(); |
| 4263 | assert(instance_id <= 0 || xk, "instances are always exactly typed")do { if (!(instance_id <= 0 || xk)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4263, "assert(" "instance_id <= 0 || xk" ") failed", "instances are always exactly typed" ); ::breakpoint(); } } while (0); |
| 4264 | return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative, inline_depth))->hashcons(); |
| 4265 | } |
| 4266 | |
| 4267 | //------------------------------cast_to_ptr_type------------------------------- |
| 4268 | const TypeAryPtr* TypeAryPtr::cast_to_ptr_type(PTR ptr) const { |
| 4269 | if( ptr == _ptr ) return this; |
| 4270 | return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth); |
| 4271 | } |
| 4272 | |
| 4273 | |
| 4274 | //-----------------------------cast_to_exactness------------------------------- |
| 4275 | const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const { |
| 4276 | if( klass_is_exact == _klass_is_exact ) return this; |
| 4277 | if (_ary->ary_must_be_exact()) return this; // cannot clear xk |
| 4278 | return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth); |
| 4279 | } |
| 4280 | |
| 4281 | //-----------------------------cast_to_instance_id---------------------------- |
| 4282 | const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { |
| 4283 | if( instance_id == _instance_id ) return this; |
| 4284 | return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth); |
| 4285 | } |
| 4286 | |
| 4287 | |
| 4288 | //-----------------------------max_array_length------------------------------- |
| 4289 | // A wrapper around arrayOopDesc::max_array_length(etype) with some input normalization. |
| 4290 | jint TypeAryPtr::max_array_length(BasicType etype) { |
| 4291 | if (!is_java_primitive(etype) && !is_reference_type(etype)) { |
| 4292 | if (etype == T_NARROWOOP) { |
| 4293 | etype = T_OBJECT; |
| 4294 | } else if (etype == T_ILLEGAL) { // bottom[] |
| 4295 | etype = T_BYTE; // will produce conservatively high value |
| 4296 | } else { |
| 4297 | fatal("not an element type: %s", type2name(etype))do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4297, "not an element type: %s", type2name(etype)); ::breakpoint (); } while (0); |
| 4298 | } |
| 4299 | } |
| 4300 | return arrayOopDesc::max_array_length(etype); |
| 4301 | } |
| 4302 | |
| 4303 | //-----------------------------narrow_size_type------------------------------- |
| 4304 | // Narrow the given size type to the index range for the given array base type. |
| 4305 | // Return NULL if the resulting int type becomes empty. |
| 4306 | const TypeInt* TypeAryPtr::narrow_size_type(const TypeInt* size) const { |
| 4307 | jint hi = size->_hi; |
| 4308 | jint lo = size->_lo; |
| 4309 | jint min_lo = 0; |
| 4310 | jint max_hi = max_array_length(elem()->basic_type()); |
| 4311 | //if (index_not_size) --max_hi; // type of a valid array index, FTR |
| 4312 | bool chg = false; |
| 4313 | if (lo < min_lo) { |
| 4314 | lo = min_lo; |
| 4315 | if (size->is_con()) { |
| 4316 | hi = lo; |
| 4317 | } |
| 4318 | chg = true; |
| 4319 | } |
| 4320 | if (hi > max_hi) { |
| 4321 | hi = max_hi; |
| 4322 | if (size->is_con()) { |
| 4323 | lo = hi; |
| 4324 | } |
| 4325 | chg = true; |
| 4326 | } |
| 4327 | // Negative length arrays will produce weird intermediate dead fast-path code |
| 4328 | if (lo > hi) |
| 4329 | return TypeInt::ZERO; |
| 4330 | if (!chg) |
| 4331 | return size; |
| 4332 | return TypeInt::make(lo, hi, Type::WidenMin); |
| 4333 | } |
| 4334 | |
| 4335 | //-------------------------------cast_to_size---------------------------------- |
| 4336 | const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const { |
| 4337 | assert(new_size != NULL, "")do { if (!(new_size != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4337, "assert(" "new_size != __null" ") failed", ""); ::breakpoint (); } } while (0); |
| 4338 | new_size = narrow_size_type(new_size); |
| 4339 | if (new_size == size()) return this; |
| 4340 | const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable()); |
| 4341 | return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth); |
| 4342 | } |
| 4343 | |
| 4344 | //------------------------------cast_to_stable--------------------------------- |
| 4345 | const TypeAryPtr* TypeAryPtr::cast_to_stable(bool stable, int stable_dimension) const { |
| 4346 | if (stable_dimension <= 0 || (stable_dimension == 1 && stable == this->is_stable())) |
| 4347 | return this; |
| 4348 | |
| 4349 | const Type* elem = this->elem(); |
| 4350 | const TypePtr* elem_ptr = elem->make_ptr(); |
| 4351 | |
| 4352 | if (stable_dimension > 1 && elem_ptr != NULL__null && elem_ptr->isa_aryptr()) { |
| 4353 | // If this is widened from a narrow oop, TypeAry::make will re-narrow it. |
| 4354 | elem = elem_ptr = elem_ptr->is_aryptr()->cast_to_stable(stable, stable_dimension - 1); |
Although the value stored to 'elem_ptr' is used in the enclosing expression, the value is never actually read from 'elem_ptr' | |
| 4355 | } |
| 4356 | |
| 4357 | const TypeAry* new_ary = TypeAry::make(elem, size(), stable); |
| 4358 | |
| 4359 | return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth); |
| 4360 | } |
| 4361 | |
| 4362 | //-----------------------------stable_dimension-------------------------------- |
| 4363 | int TypeAryPtr::stable_dimension() const { |
| 4364 | if (!is_stable()) return 0; |
| 4365 | int dim = 1; |
| 4366 | const TypePtr* elem_ptr = elem()->make_ptr(); |
| 4367 | if (elem_ptr != NULL__null && elem_ptr->isa_aryptr()) |
| 4368 | dim += elem_ptr->is_aryptr()->stable_dimension(); |
| 4369 | return dim; |
| 4370 | } |
| 4371 | |
| 4372 | //----------------------cast_to_autobox_cache----------------------------------- |
| 4373 | const TypeAryPtr* TypeAryPtr::cast_to_autobox_cache() const { |
| 4374 | if (is_autobox_cache()) return this; |
| 4375 | const TypeOopPtr* etype = elem()->make_oopptr(); |
| 4376 | if (etype == NULL__null) return this; |
| 4377 | // The pointers in the autobox arrays are always non-null. |
| 4378 | etype = etype->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr(); |
| 4379 | const TypeAry* new_ary = TypeAry::make(etype, size(), is_stable()); |
| 4380 | return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth, /*is_autobox_cache=*/true); |
| 4381 | } |
| 4382 | |
| 4383 | //------------------------------eq--------------------------------------------- |
| 4384 | // Structural equality check for Type representations |
| 4385 | bool TypeAryPtr::eq( const Type *t ) const { |
| 4386 | const TypeAryPtr *p = t->is_aryptr(); |
| 4387 | return |
| 4388 | _ary == p->_ary && // Check array |
| 4389 | TypeOopPtr::eq(p); // Check sub-parts |
| 4390 | } |
| 4391 | |
| 4392 | //------------------------------hash------------------------------------------- |
| 4393 | // Type-specific hashing function. |
| 4394 | int TypeAryPtr::hash(void) const { |
| 4395 | return (intptr_t)_ary + TypeOopPtr::hash(); |
| 4396 | } |
| 4397 | |
| 4398 | //------------------------------meet------------------------------------------- |
| 4399 | // Compute the MEET of two types. It returns a new Type object. |
| 4400 | const Type *TypeAryPtr::xmeet_helper(const Type *t) const { |
| 4401 | // Perform a fast test for common case; meeting the same types together. |
| 4402 | if( this == t ) return this; // Meeting same type-rep? |
| 4403 | // Current "this->_base" is Pointer |
| 4404 | switch (t->base()) { // switch on original type |
| 4405 | |
| 4406 | // Mixing ints & oops happens when javac reuses local variables |
| 4407 | case Int: |
| 4408 | case Long: |
| 4409 | case FloatTop: |
| 4410 | case FloatCon: |
| 4411 | case FloatBot: |
| 4412 | case DoubleTop: |
| 4413 | case DoubleCon: |
| 4414 | case DoubleBot: |
| 4415 | case NarrowOop: |
| 4416 | case NarrowKlass: |
| 4417 | case Bottom: // Ye Olde Default |
| 4418 | return Type::BOTTOM; |
| 4419 | case Top: |
| 4420 | return this; |
| 4421 | |
| 4422 | default: // All else is a mistake |
| 4423 | typerr(t); |
| 4424 | |
| 4425 | case OopPtr: { // Meeting to OopPtrs |
| 4426 | // Found a OopPtr type vs self-AryPtr type |
| 4427 | const TypeOopPtr *tp = t->is_oopptr(); |
| 4428 | int offset = meet_offset(tp->offset()); |
| 4429 | PTR ptr = meet_ptr(tp->ptr()); |
| 4430 | int depth = meet_inline_depth(tp->inline_depth()); |
| 4431 | const TypePtr* speculative = xmeet_speculative(tp); |
| 4432 | switch (tp->ptr()) { |
| 4433 | case TopPTR: |
| 4434 | case AnyNull: { |
| 4435 | int instance_id = meet_instance_id(InstanceTop); |
| 4436 | return make(ptr, (ptr == Constant ? const_oop() : NULL__null), |
| 4437 | _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); |
| 4438 | } |
| 4439 | case BotPTR: |
| 4440 | case NotNull: { |
| 4441 | int instance_id = meet_instance_id(tp->instance_id()); |
| 4442 | return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth); |
| 4443 | } |
| 4444 | default: ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4444); ::breakpoint(); } while (0); |
| 4445 | } |
| 4446 | } |
| 4447 | |
| 4448 | case AnyPtr: { // Meeting two AnyPtrs |
| 4449 | // Found an AnyPtr type vs self-AryPtr type |
| 4450 | const TypePtr *tp = t->is_ptr(); |
| 4451 | int offset = meet_offset(tp->offset()); |
| 4452 | PTR ptr = meet_ptr(tp->ptr()); |
| 4453 | const TypePtr* speculative = xmeet_speculative(tp); |
| 4454 | int depth = meet_inline_depth(tp->inline_depth()); |
| 4455 | switch (tp->ptr()) { |
| 4456 | case TopPTR: |
| 4457 | return this; |
| 4458 | case BotPTR: |
| 4459 | case NotNull: |
| 4460 | return TypePtr::make(AnyPtr, ptr, offset, speculative, depth); |
| 4461 | case Null: |
| 4462 | if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset, speculative, depth); |
| 4463 | // else fall through to AnyNull |
| 4464 | case AnyNull: { |
| 4465 | int instance_id = meet_instance_id(InstanceTop); |
| 4466 | return make(ptr, (ptr == Constant ? const_oop() : NULL__null), |
| 4467 | _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); |
| 4468 | } |
| 4469 | default: ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4469); ::breakpoint(); } while (0); |
| 4470 | } |
| 4471 | } |
| 4472 | |
| 4473 | case MetadataPtr: |
| 4474 | case KlassPtr: |
| 4475 | case InstKlassPtr: |
| 4476 | case AryKlassPtr: |
| 4477 | case RawPtr: return TypePtr::BOTTOM; |
| 4478 | |
| 4479 | case AryPtr: { // Meeting 2 references? |
| 4480 | const TypeAryPtr *tap = t->is_aryptr(); |
| 4481 | int off = meet_offset(tap->offset()); |
| 4482 | const TypeAry *tary = _ary->meet_speculative(tap->_ary)->is_ary(); |
| 4483 | PTR ptr = meet_ptr(tap->ptr()); |
| 4484 | int instance_id = meet_instance_id(tap->instance_id()); |
| 4485 | const TypePtr* speculative = xmeet_speculative(tap); |
| 4486 | int depth = meet_inline_depth(tap->inline_depth()); |
| 4487 | |
| 4488 | ciKlass* res_klass = NULL__null; |
| 4489 | bool res_xk = false; |
| 4490 | const Type* elem = tary->_elem; |
| 4491 | if (meet_aryptr(ptr, elem, this->klass(), tap->klass(), this->klass_is_exact(), tap->klass_is_exact(), this->ptr(), tap->ptr(), res_klass, res_xk) == NOT_SUBTYPE) { |
| 4492 | instance_id = InstanceBot; |
| 4493 | } |
| 4494 | |
| 4495 | ciObject* o = NULL__null; // Assume not constant when done |
| 4496 | ciObject* this_oop = const_oop(); |
| 4497 | ciObject* tap_oop = tap->const_oop(); |
| 4498 | if (ptr == Constant) { |
| 4499 | if (this_oop != NULL__null && tap_oop != NULL__null && |
| 4500 | this_oop->equals(tap_oop)) { |
| 4501 | o = tap_oop; |
| 4502 | } else if (above_centerline(_ptr)) { |
| 4503 | o = tap_oop; |
| 4504 | } else if (above_centerline(tap->_ptr)) { |
| 4505 | o = this_oop; |
| 4506 | } else { |
| 4507 | ptr = NotNull; |
| 4508 | } |
| 4509 | } |
| 4510 | return make(ptr, o, TypeAry::make(elem, tary->_size, tary->_stable), res_klass, res_xk, off, instance_id, speculative, depth); |
| 4511 | } |
| 4512 | |
| 4513 | // All arrays inherit from Object class |
| 4514 | case InstPtr: { |
| 4515 | const TypeInstPtr *tp = t->is_instptr(); |
| 4516 | int offset = meet_offset(tp->offset()); |
| 4517 | PTR ptr = meet_ptr(tp->ptr()); |
| 4518 | int instance_id = meet_instance_id(tp->instance_id()); |
| 4519 | const TypePtr* speculative = xmeet_speculative(tp); |
| 4520 | int depth = meet_inline_depth(tp->inline_depth()); |
| 4521 | switch (ptr) { |
| 4522 | case TopPTR: |
| 4523 | case AnyNull: // Fall 'down' to dual of object klass |
| 4524 | // For instances when a subclass meets a superclass we fall |
| 4525 | // below the centerline when the superclass is exact. We need to |
| 4526 | // do the same here. |
| 4527 | if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { |
| 4528 | return make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); |
| 4529 | } else { |
| 4530 | // cannot subclass, so the meet has to fall badly below the centerline |
| 4531 | ptr = NotNull; |
| 4532 | instance_id = InstanceBot; |
| 4533 | return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL__null,offset, instance_id, speculative, depth); |
| 4534 | } |
| 4535 | case Constant: |
| 4536 | case NotNull: |
| 4537 | case BotPTR: // Fall down to object klass |
| 4538 | // LCA is object_klass, but if we subclass from the top we can do better |
| 4539 | if (above_centerline(tp->ptr())) { |
| 4540 | // If 'tp' is above the centerline and it is Object class |
| 4541 | // then we can subclass in the Java class hierarchy. |
| 4542 | // For instances when a subclass meets a superclass we fall |
| 4543 | // below the centerline when the superclass is exact. We need |
| 4544 | // to do the same here. |
| 4545 | if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { |
| 4546 | // that is, my array type is a subtype of 'tp' klass |
| 4547 | return make(ptr, (ptr == Constant ? const_oop() : NULL__null), |
| 4548 | _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); |
| 4549 | } |
| 4550 | } |
| 4551 | // The other case cannot happen, since t cannot be a subtype of an array. |
| 4552 | // The meet falls down to Object class below centerline. |
| 4553 | if (ptr == Constant) { |
| 4554 | ptr = NotNull; |
| 4555 | } |
| 4556 | if (instance_id > 0) { |
| 4557 | instance_id = InstanceBot; |
| 4558 | } |
| 4559 | return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL__null, offset, instance_id, speculative, depth); |
| 4560 | default: typerr(t); |
| 4561 | } |
| 4562 | } |
| 4563 | } |
| 4564 | return this; // Lint noise |
| 4565 | } |
| 4566 | |
| 4567 | |
| 4568 | TypePtr::MeetResult TypePtr::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) { |
| 4569 | res_klass = NULL__null; |
| 4570 | MeetResult result = SUBTYPE; |
| 4571 | if (elem->isa_int()) { |
| 4572 | // Integral array element types have irrelevant lattice relations. |
| 4573 | // It is the klass that determines array layout, not the element type. |
| 4574 | if (this_klass == NULL__null) |
| 4575 | res_klass = tap_klass; |
| 4576 | else if (tap_klass == NULL__null || tap_klass == this_klass) { |
| 4577 | res_klass = this_klass; |
| 4578 | } else { |
| 4579 | // Something like byte[int+] meets char[int+]. |
| 4580 | // This must fall to bottom, not (int[-128..65535])[int+]. |
| 4581 | // instance_id = InstanceBot; |
| 4582 | elem = Type::BOTTOM; |
| 4583 | result = NOT_SUBTYPE; |
| 4584 | } |
| 4585 | } else // Non integral arrays. |
| 4586 | // Must fall to bottom if exact klasses in upper lattice |
| 4587 | // are not equal or super klass is exact. |
| 4588 | if ((above_centerline(ptr) || ptr == Constant) && this_klass != tap_klass && |
| 4589 | // meet with top[] and bottom[] are processed further down: |
| 4590 | tap_klass != NULL__null && this_klass != NULL__null && |
| 4591 | // both are exact and not equal: |
| 4592 | ((tap_xk && this_xk) || |
| 4593 | // 'tap' is exact and super or unrelated: |
| 4594 | (tap_xk && !tap_klass->is_subtype_of(this_klass)) || |
| 4595 | // 'this' is exact and super or unrelated: |
| 4596 | (this_xk && !this_klass->is_subtype_of(tap_klass)))) { |
| 4597 | if (above_centerline(ptr) || (elem->make_ptr() && above_centerline(elem->make_ptr()->_ptr))) { |
| 4598 | elem = Type::BOTTOM; |
| 4599 | } |
| 4600 | ptr = NotNull; |
| 4601 | res_xk = false; |
| 4602 | return NOT_SUBTYPE; |
| 4603 | } |
| 4604 | |
| 4605 | res_xk = false; |
| 4606 | switch (tap_ptr) { |
| 4607 | case AnyNull: |
| 4608 | case TopPTR: |
| 4609 | // Compute new klass on demand, do not use tap->_klass |
| 4610 | if (below_centerline(this_ptr)) { |
| 4611 | res_xk = this_xk; |
| 4612 | } else { |
| 4613 | res_xk = (tap_xk || this_xk); |
| 4614 | } |
| 4615 | return result; |
| 4616 | case Constant: { |
| 4617 | if (this_ptr == Constant) { |
| 4618 | res_xk = true; |
| 4619 | } else if(above_centerline(this_ptr)) { |
| 4620 | res_xk = true; |
| 4621 | } else { |
| 4622 | // Only precise for identical arrays |
| 4623 | res_xk = this_xk && (this_klass == tap_klass); |
| 4624 | } |
| 4625 | return result; |
| 4626 | } |
| 4627 | case NotNull: |
| 4628 | case BotPTR: |
| 4629 | // Compute new klass on demand, do not use tap->_klass |
| 4630 | if (above_centerline(this_ptr)) { |
| 4631 | res_xk = tap_xk; |
| 4632 | } else { |
| 4633 | res_xk = (tap_xk && this_xk) && |
| 4634 | (this_klass == tap_klass); // Only precise for identical arrays |
| 4635 | } |
| 4636 | return result; |
| 4637 | default: { |
| 4638 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4638); ::breakpoint(); } while (0); |
| 4639 | return result; |
| 4640 | } |
| 4641 | } |
| 4642 | return result; |
| 4643 | } |
| 4644 | |
| 4645 | |
| 4646 | //------------------------------xdual------------------------------------------ |
| 4647 | // Dual: compute field-by-field dual |
| 4648 | const Type *TypeAryPtr::xdual() const { |
| 4649 | return new TypeAryPtr(dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache(), dual_speculative(), dual_inline_depth()); |
| 4650 | } |
| 4651 | |
| 4652 | //----------------------interface_vs_oop--------------------------------------- |
| 4653 | #ifdef ASSERT1 |
| 4654 | bool TypeAryPtr::interface_vs_oop(const Type *t) const { |
| 4655 | const TypeAryPtr* t_aryptr = t->isa_aryptr(); |
| 4656 | if (t_aryptr) { |
| 4657 | return _ary->interface_vs_oop(t_aryptr->_ary); |
| 4658 | } |
| 4659 | return false; |
| 4660 | } |
| 4661 | #endif |
| 4662 | |
| 4663 | //------------------------------dump2------------------------------------------ |
| 4664 | #ifndef PRODUCT |
| 4665 | void TypeAryPtr::dump2( Dict &d, uint depth, outputStream *st ) const { |
| 4666 | _ary->dump2(d,depth,st); |
| 4667 | switch( _ptr ) { |
| 4668 | case Constant: |
| 4669 | const_oop()->print(st); |
| 4670 | break; |
| 4671 | case BotPTR: |
| 4672 | if (!WizardMode && !Verbose) { |
| 4673 | if( _klass_is_exact ) st->print(":exact"); |
| 4674 | break; |
| 4675 | } |
| 4676 | case TopPTR: |
| 4677 | case AnyNull: |
| 4678 | case NotNull: |
| 4679 | st->print(":%s", ptr_msg[_ptr]); |
| 4680 | if( _klass_is_exact ) st->print(":exact"); |
| 4681 | break; |
| 4682 | default: |
| 4683 | break; |
| 4684 | } |
| 4685 | |
| 4686 | if( _offset != 0 ) { |
| 4687 | int header_size = objArrayOopDesc::header_size() * wordSize; |
| 4688 | if( _offset == OffsetTop ) st->print("+undefined"); |
| 4689 | else if( _offset == OffsetBot ) st->print("+any"); |
| 4690 | else if( _offset < header_size ) st->print("+%d", _offset); |
| 4691 | else { |
| 4692 | BasicType basic_elem_type = elem()->basic_type(); |
| 4693 | int array_base = arrayOopDesc::base_offset_in_bytes(basic_elem_type); |
| 4694 | int elem_size = type2aelembytes(basic_elem_type); |
| 4695 | st->print("[%d]", (_offset - array_base)/elem_size); |
| 4696 | } |
| 4697 | } |
| 4698 | st->print(" *"); |
| 4699 | if (_instance_id == InstanceTop) |
| 4700 | st->print(",iid=top"); |
| 4701 | else if (_instance_id != InstanceBot) |
| 4702 | st->print(",iid=%d",_instance_id); |
| 4703 | |
| 4704 | dump_inline_depth(st); |
| 4705 | dump_speculative(st); |
| 4706 | } |
| 4707 | #endif |
| 4708 | |
| 4709 | bool TypeAryPtr::empty(void) const { |
| 4710 | if (_ary->empty()) return true; |
| 4711 | return TypeOopPtr::empty(); |
| 4712 | } |
| 4713 | |
| 4714 | //------------------------------add_offset------------------------------------- |
| 4715 | const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const { |
| 4716 | return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth); |
| 4717 | } |
| 4718 | |
| 4719 | const Type *TypeAryPtr::remove_speculative() const { |
| 4720 | if (_speculative == NULL__null) { |
| 4721 | return this; |
| 4722 | } |
| 4723 | assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth")do { if (!(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4723, "assert(" "_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom" ") failed", "non speculative type shouldn't have inline depth" ); ::breakpoint(); } } while (0); |
| 4724 | return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, NULL__null, _inline_depth); |
| 4725 | } |
| 4726 | |
| 4727 | const TypePtr *TypeAryPtr::with_inline_depth(int depth) const { |
| 4728 | if (!UseInlineDepthForSpeculativeTypes) { |
| 4729 | return this; |
| 4730 | } |
| 4731 | return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, _speculative, depth); |
| 4732 | } |
| 4733 | |
| 4734 | const TypePtr *TypeAryPtr::with_instance_id(int instance_id) const { |
| 4735 | assert(is_known_instance(), "should be known")do { if (!(is_known_instance())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4735, "assert(" "is_known_instance()" ") failed", "should be known" ); ::breakpoint(); } } while (0); |
| 4736 | return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, instance_id, _speculative, _inline_depth); |
| 4737 | } |
| 4738 | |
| 4739 | //============================================================================= |
| 4740 | |
| 4741 | //------------------------------hash------------------------------------------- |
| 4742 | // Type-specific hashing function. |
| 4743 | int TypeNarrowPtr::hash(void) const { |
| 4744 | return _ptrtype->hash() + 7; |
| 4745 | } |
| 4746 | |
| 4747 | bool TypeNarrowPtr::singleton(void) const { // TRUE if type is a singleton |
| 4748 | return _ptrtype->singleton(); |
| 4749 | } |
| 4750 | |
| 4751 | bool TypeNarrowPtr::empty(void) const { |
| 4752 | return _ptrtype->empty(); |
| 4753 | } |
| 4754 | |
| 4755 | intptr_t TypeNarrowPtr::get_con() const { |
| 4756 | return _ptrtype->get_con(); |
| 4757 | } |
| 4758 | |
| 4759 | bool TypeNarrowPtr::eq( const Type *t ) const { |
| 4760 | const TypeNarrowPtr* tc = isa_same_narrowptr(t); |
| 4761 | if (tc != NULL__null) { |
| 4762 | if (_ptrtype->base() != tc->_ptrtype->base()) { |
| 4763 | return false; |
| 4764 | } |
| 4765 | return tc->_ptrtype->eq(_ptrtype); |
| 4766 | } |
| 4767 | return false; |
| 4768 | } |
| 4769 | |
| 4770 | const Type *TypeNarrowPtr::xdual() const { // Compute dual right now. |
| 4771 | const TypePtr* odual = _ptrtype->dual()->is_ptr(); |
| 4772 | return make_same_narrowptr(odual); |
| 4773 | } |
| 4774 | |
| 4775 | |
| 4776 | const Type *TypeNarrowPtr::filter_helper(const Type *kills, bool include_speculative) const { |
| 4777 | if (isa_same_narrowptr(kills)) { |
| 4778 | const Type* ft =_ptrtype->filter_helper(is_same_narrowptr(kills)->_ptrtype, include_speculative); |
| 4779 | if (ft->empty()) |
| 4780 | return Type::TOP; // Canonical empty value |
| 4781 | if (ft->isa_ptr()) { |
| 4782 | return make_hash_same_narrowptr(ft->isa_ptr()); |
| 4783 | } |
| 4784 | return ft; |
| 4785 | } else if (kills->isa_ptr()) { |
| 4786 | const Type* ft = _ptrtype->join_helper(kills, include_speculative); |
| 4787 | if (ft->empty()) |
| 4788 | return Type::TOP; // Canonical empty value |
| 4789 | return ft; |
| 4790 | } else { |
| 4791 | return Type::TOP; |
| 4792 | } |
| 4793 | } |
| 4794 | |
| 4795 | //------------------------------xmeet------------------------------------------ |
| 4796 | // Compute the MEET of two types. It returns a new Type object. |
| 4797 | const Type *TypeNarrowPtr::xmeet( const Type *t ) const { |
| 4798 | // Perform a fast test for common case; meeting the same types together. |
| 4799 | if( this == t ) return this; // Meeting same type-rep? |
| 4800 | |
| 4801 | if (t->base() == base()) { |
| 4802 | const Type* result = _ptrtype->xmeet(t->make_ptr()); |
| 4803 | if (result->isa_ptr()) { |
| 4804 | return make_hash_same_narrowptr(result->is_ptr()); |
| 4805 | } |
| 4806 | return result; |
| 4807 | } |
| 4808 | |
| 4809 | // Current "this->_base" is NarrowKlass or NarrowOop |
| 4810 | switch (t->base()) { // switch on original type |
| 4811 | |
| 4812 | case Int: // Mixing ints & oops happens when javac |
| 4813 | case Long: // reuses local variables |
| 4814 | case FloatTop: |
| 4815 | case FloatCon: |
| 4816 | case FloatBot: |
| 4817 | case DoubleTop: |
| 4818 | case DoubleCon: |
| 4819 | case DoubleBot: |
| 4820 | case AnyPtr: |
| 4821 | case RawPtr: |
| 4822 | case OopPtr: |
| 4823 | case InstPtr: |
| 4824 | case AryPtr: |
| 4825 | case MetadataPtr: |
| 4826 | case KlassPtr: |
| 4827 | case InstKlassPtr: |
| 4828 | case AryKlassPtr: |
| 4829 | case NarrowOop: |
| 4830 | case NarrowKlass: |
| 4831 | |
| 4832 | case Bottom: // Ye Olde Default |
| 4833 | return Type::BOTTOM; |
| 4834 | case Top: |
| 4835 | return this; |
| 4836 | |
| 4837 | default: // All else is a mistake |
| 4838 | typerr(t); |
| 4839 | |
| 4840 | } // End of switch |
| 4841 | |
| 4842 | return this; |
| 4843 | } |
| 4844 | |
| 4845 | #ifndef PRODUCT |
| 4846 | void TypeNarrowPtr::dump2( Dict & d, uint depth, outputStream *st ) const { |
| 4847 | _ptrtype->dump2(d, depth, st); |
| 4848 | } |
| 4849 | #endif |
| 4850 | |
| 4851 | const TypeNarrowOop *TypeNarrowOop::BOTTOM; |
| 4852 | const TypeNarrowOop *TypeNarrowOop::NULL_PTR; |
| 4853 | |
| 4854 | |
| 4855 | const TypeNarrowOop* TypeNarrowOop::make(const TypePtr* type) { |
| 4856 | return (const TypeNarrowOop*)(new TypeNarrowOop(type))->hashcons(); |
| 4857 | } |
| 4858 | |
| 4859 | const Type* TypeNarrowOop::remove_speculative() const { |
| 4860 | return make(_ptrtype->remove_speculative()->is_ptr()); |
| 4861 | } |
| 4862 | |
| 4863 | const Type* TypeNarrowOop::cleanup_speculative() const { |
| 4864 | return make(_ptrtype->cleanup_speculative()->is_ptr()); |
| 4865 | } |
| 4866 | |
| 4867 | #ifndef PRODUCT |
| 4868 | void TypeNarrowOop::dump2( Dict & d, uint depth, outputStream *st ) const { |
| 4869 | st->print("narrowoop: "); |
| 4870 | TypeNarrowPtr::dump2(d, depth, st); |
| 4871 | } |
| 4872 | #endif |
| 4873 | |
| 4874 | const TypeNarrowKlass *TypeNarrowKlass::NULL_PTR; |
| 4875 | |
| 4876 | const TypeNarrowKlass* TypeNarrowKlass::make(const TypePtr* type) { |
| 4877 | return (const TypeNarrowKlass*)(new TypeNarrowKlass(type))->hashcons(); |
| 4878 | } |
| 4879 | |
| 4880 | #ifndef PRODUCT |
| 4881 | void TypeNarrowKlass::dump2( Dict & d, uint depth, outputStream *st ) const { |
| 4882 | st->print("narrowklass: "); |
| 4883 | TypeNarrowPtr::dump2(d, depth, st); |
| 4884 | } |
| 4885 | #endif |
| 4886 | |
| 4887 | |
| 4888 | //------------------------------eq--------------------------------------------- |
| 4889 | // Structural equality check for Type representations |
| 4890 | bool TypeMetadataPtr::eq( const Type *t ) const { |
| 4891 | const TypeMetadataPtr *a = (const TypeMetadataPtr*)t; |
| 4892 | ciMetadata* one = metadata(); |
| 4893 | ciMetadata* two = a->metadata(); |
| 4894 | if (one == NULL__null || two == NULL__null) { |
| 4895 | return (one == two) && TypePtr::eq(t); |
| 4896 | } else { |
| 4897 | return one->equals(two) && TypePtr::eq(t); |
| 4898 | } |
| 4899 | } |
| 4900 | |
| 4901 | //------------------------------hash------------------------------------------- |
| 4902 | // Type-specific hashing function. |
| 4903 | int TypeMetadataPtr::hash(void) const { |
| 4904 | return |
| 4905 | (metadata() ? metadata()->hash() : 0) + |
| 4906 | TypePtr::hash(); |
| 4907 | } |
| 4908 | |
| 4909 | //------------------------------singleton-------------------------------------- |
| 4910 | // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple |
| 4911 | // constants |
| 4912 | bool TypeMetadataPtr::singleton(void) const { |
| 4913 | // detune optimizer to not generate constant metadata + constant offset as a constant! |
| 4914 | // TopPTR, Null, AnyNull, Constant are all singletons |
| 4915 | return (_offset == 0) && !below_centerline(_ptr); |
| 4916 | } |
| 4917 | |
| 4918 | //------------------------------add_offset------------------------------------- |
| 4919 | const TypePtr *TypeMetadataPtr::add_offset( intptr_t offset ) const { |
| 4920 | return make( _ptr, _metadata, xadd_offset(offset)); |
| 4921 | } |
| 4922 | |
| 4923 | //-----------------------------filter------------------------------------------ |
| 4924 | // Do not allow interface-vs.-noninterface joins to collapse to top. |
| 4925 | const Type *TypeMetadataPtr::filter_helper(const Type *kills, bool include_speculative) const { |
| 4926 | const TypeMetadataPtr* ft = join_helper(kills, include_speculative)->isa_metadataptr(); |
| 4927 | if (ft == NULL__null || ft->empty()) |
| 4928 | return Type::TOP; // Canonical empty value |
| 4929 | return ft; |
| 4930 | } |
| 4931 | |
| 4932 | //------------------------------get_con---------------------------------------- |
| 4933 | intptr_t TypeMetadataPtr::get_con() const { |
| 4934 | assert( _ptr == Null || _ptr == Constant, "" )do { if (!(_ptr == Null || _ptr == Constant)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4934, "assert(" "_ptr == Null || _ptr == Constant" ") failed" , ""); ::breakpoint(); } } while (0); |
| 4935 | assert( _offset >= 0, "" )do { if (!(_offset >= 0)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4935, "assert(" "_offset >= 0" ") failed", ""); ::breakpoint (); } } while (0); |
| 4936 | |
| 4937 | if (_offset != 0) { |
| 4938 | // After being ported to the compiler interface, the compiler no longer |
| 4939 | // directly manipulates the addresses of oops. Rather, it only has a pointer |
| 4940 | // to a handle at compile time. This handle is embedded in the generated |
| 4941 | // code and dereferenced at the time the nmethod is made. Until that time, |
| 4942 | // it is not reasonable to do arithmetic with the addresses of oops (we don't |
| 4943 | // have access to the addresses!). This does not seem to currently happen, |
| 4944 | // but this assertion here is to help prevent its occurence. |
| 4945 | tty->print_cr("Found oop constant with non-zero offset"); |
| 4946 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 4946); ::breakpoint(); } while (0); |
| 4947 | } |
| 4948 | |
| 4949 | return (intptr_t)metadata()->constant_encoding(); |
| 4950 | } |
| 4951 | |
| 4952 | //------------------------------cast_to_ptr_type------------------------------- |
| 4953 | const TypeMetadataPtr* TypeMetadataPtr::cast_to_ptr_type(PTR ptr) const { |
| 4954 | if( ptr == _ptr ) return this; |
| 4955 | return make(ptr, metadata(), _offset); |
| 4956 | } |
| 4957 | |
| 4958 | //------------------------------meet------------------------------------------- |
| 4959 | // Compute the MEET of two types. It returns a new Type object. |
| 4960 | const Type *TypeMetadataPtr::xmeet( const Type *t ) const { |
| 4961 | // Perform a fast test for common case; meeting the same types together. |
| 4962 | if( this == t ) return this; // Meeting same type-rep? |
| 4963 | |
| 4964 | // Current "this->_base" is OopPtr |
| 4965 | switch (t->base()) { // switch on original type |
| 4966 | |
| 4967 | case Int: // Mixing ints & oops happens when javac |
| 4968 | case Long: // reuses local variables |
| 4969 | case FloatTop: |
| 4970 | case FloatCon: |
| 4971 | case FloatBot: |
| 4972 | case DoubleTop: |
| 4973 | case DoubleCon: |
| 4974 | case DoubleBot: |
| 4975 | case NarrowOop: |
| 4976 | case NarrowKlass: |
| 4977 | case Bottom: // Ye Olde Default |
| 4978 | return Type::BOTTOM; |
| 4979 | case Top: |
| 4980 | return this; |
| 4981 | |
| 4982 | default: // All else is a mistake |
| 4983 | typerr(t); |
| 4984 | |
| 4985 | case AnyPtr: { |
| 4986 | // Found an AnyPtr type vs self-OopPtr type |
| 4987 | const TypePtr *tp = t->is_ptr(); |
| 4988 | int offset = meet_offset(tp->offset()); |
| 4989 | PTR ptr = meet_ptr(tp->ptr()); |
| 4990 | switch (tp->ptr()) { |
| 4991 | case Null: |
| 4992 | if (ptr == Null) return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth()); |
| 4993 | // else fall through: |
| 4994 | case TopPTR: |
| 4995 | case AnyNull: { |
| 4996 | return make(ptr, _metadata, offset); |
| 4997 | } |
| 4998 | case BotPTR: |
| 4999 | case NotNull: |
| 5000 | return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth()); |
| 5001 | default: typerr(t); |
| 5002 | } |
| 5003 | } |
| 5004 | |
| 5005 | case RawPtr: |
| 5006 | case KlassPtr: |
| 5007 | case InstKlassPtr: |
| 5008 | case AryKlassPtr: |
| 5009 | case OopPtr: |
| 5010 | case InstPtr: |
| 5011 | case AryPtr: |
| 5012 | return TypePtr::BOTTOM; // Oop meet raw is not well defined |
| 5013 | |
| 5014 | case MetadataPtr: { |
| 5015 | const TypeMetadataPtr *tp = t->is_metadataptr(); |
| 5016 | int offset = meet_offset(tp->offset()); |
| 5017 | PTR tptr = tp->ptr(); |
| 5018 | PTR ptr = meet_ptr(tptr); |
| 5019 | ciMetadata* md = (tptr == TopPTR) ? metadata() : tp->metadata(); |
| 5020 | if (tptr == TopPTR || _ptr == TopPTR || |
| 5021 | metadata()->equals(tp->metadata())) { |
| 5022 | return make(ptr, md, offset); |
| 5023 | } |
| 5024 | // metadata is different |
| 5025 | if( ptr == Constant ) { // Cannot be equal constants, so... |
| 5026 | if( tptr == Constant && _ptr != Constant) return t; |
| 5027 | if( _ptr == Constant && tptr != Constant) return this; |
| 5028 | ptr = NotNull; // Fall down in lattice |
| 5029 | } |
| 5030 | return make(ptr, NULL__null, offset); |
| 5031 | break; |
| 5032 | } |
| 5033 | } // End of switch |
| 5034 | return this; // Return the double constant |
| 5035 | } |
| 5036 | |
| 5037 | |
| 5038 | //------------------------------xdual------------------------------------------ |
| 5039 | // Dual of a pure metadata pointer. |
| 5040 | const Type *TypeMetadataPtr::xdual() const { |
| 5041 | return new TypeMetadataPtr(dual_ptr(), metadata(), dual_offset()); |
| 5042 | } |
| 5043 | |
| 5044 | //------------------------------dump2------------------------------------------ |
| 5045 | #ifndef PRODUCT |
| 5046 | void TypeMetadataPtr::dump2( Dict &d, uint depth, outputStream *st ) const { |
| 5047 | st->print("metadataptr:%s", ptr_msg[_ptr]); |
| 5048 | if( metadata() ) st->print(INTPTR_FORMAT"0x%016" "l" "x", p2i(metadata())); |
| 5049 | switch( _offset ) { |
| 5050 | case OffsetTop: st->print("+top"); break; |
| 5051 | case OffsetBot: st->print("+any"); break; |
| 5052 | case 0: break; |
| 5053 | default: st->print("+%d",_offset); break; |
| 5054 | } |
| 5055 | } |
| 5056 | #endif |
| 5057 | |
| 5058 | |
| 5059 | //============================================================================= |
| 5060 | // Convenience common pre-built type. |
| 5061 | const TypeMetadataPtr *TypeMetadataPtr::BOTTOM; |
| 5062 | |
| 5063 | TypeMetadataPtr::TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset): |
| 5064 | TypePtr(MetadataPtr, ptr, offset), _metadata(metadata) { |
| 5065 | } |
| 5066 | |
| 5067 | const TypeMetadataPtr* TypeMetadataPtr::make(ciMethod* m) { |
| 5068 | return make(Constant, m, 0); |
| 5069 | } |
| 5070 | const TypeMetadataPtr* TypeMetadataPtr::make(ciMethodData* m) { |
| 5071 | return make(Constant, m, 0); |
| 5072 | } |
| 5073 | |
| 5074 | //------------------------------make------------------------------------------- |
| 5075 | // Create a meta data constant |
| 5076 | const TypeMetadataPtr *TypeMetadataPtr::make(PTR ptr, ciMetadata* m, int offset) { |
| 5077 | assert(m == NULL || !m->is_klass(), "wrong type")do { if (!(m == __null || !m->is_klass())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 5077, "assert(" "m == __null || !m->is_klass()" ") failed" , "wrong type"); ::breakpoint(); } } while (0); |
| 5078 | return (TypeMetadataPtr*)(new TypeMetadataPtr(ptr, m, offset))->hashcons(); |
| 5079 | } |
| 5080 | |
| 5081 | |
| 5082 | const TypeKlassPtr* TypeAryPtr::as_klass_type(bool try_for_exact) const { |
| 5083 | const Type* elem = _ary->_elem; |
| 5084 | bool xk = klass_is_exact(); |
| 5085 | if (elem->make_oopptr() != NULL__null) { |
| 5086 | elem = elem->make_oopptr()->as_klass_type(try_for_exact); |
| 5087 | if (elem->is_klassptr()->klass_is_exact()) { |
| 5088 | xk = true; |
| 5089 | } |
| 5090 | } |
| 5091 | return TypeAryKlassPtr::make(xk ? TypePtr::Constant : TypePtr::NotNull, elem, klass(), 0); |
| 5092 | } |
| 5093 | |
| 5094 | const TypeKlassPtr* TypeKlassPtr::make(ciKlass *klass) { |
| 5095 | if (klass->is_instance_klass()) { |
| 5096 | return TypeInstKlassPtr::make(klass); |
| 5097 | } |
| 5098 | return TypeAryKlassPtr::make(klass); |
| 5099 | } |
| 5100 | |
| 5101 | const TypeKlassPtr* TypeKlassPtr::make(PTR ptr, ciKlass* klass, int offset) { |
| 5102 | if (klass->is_instance_klass()) { |
| 5103 | return TypeInstKlassPtr::make(ptr, klass, offset); |
| 5104 | } |
| 5105 | return TypeAryKlassPtr::make(ptr, klass, offset); |
| 5106 | } |
| 5107 | |
| 5108 | |
| 5109 | //------------------------------TypeKlassPtr----------------------------------- |
| 5110 | TypeKlassPtr::TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, int offset) |
| 5111 | : TypePtr(t, ptr, offset), _klass(klass) { |
| 5112 | } |
| 5113 | |
| 5114 | //------------------------------eq--------------------------------------------- |
| 5115 | // Structural equality check for Type representations |
| 5116 | bool TypeKlassPtr::eq(const Type *t) const { |
| 5117 | const TypeKlassPtr *p = t->is_klassptr(); |
| 5118 | return |
| 5119 | TypePtr::eq(p); |
| 5120 | } |
| 5121 | |
| 5122 | //------------------------------hash------------------------------------------- |
| 5123 | // Type-specific hashing function. |
| 5124 | int TypeKlassPtr::hash(void) const { |
| 5125 | return TypePtr::hash(); |
| 5126 | } |
| 5127 | |
| 5128 | //------------------------------singleton-------------------------------------- |
| 5129 | // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple |
| 5130 | // constants |
| 5131 | bool TypeKlassPtr::singleton(void) const { |
| 5132 | // detune optimizer to not generate constant klass + constant offset as a constant! |
| 5133 | // TopPTR, Null, AnyNull, Constant are all singletons |
| 5134 | return (_offset == 0) && !below_centerline(_ptr); |
| 5135 | } |
| 5136 | |
| 5137 | // Do not allow interface-vs.-noninterface joins to collapse to top. |
| 5138 | const Type *TypeKlassPtr::filter_helper(const Type *kills, bool include_speculative) const { |
| 5139 | // logic here mirrors the one from TypeOopPtr::filter. See comments |
| 5140 | // there. |
| 5141 | const Type* ft = join_helper(kills, include_speculative); |
| 5142 | const TypeKlassPtr* ftkp = ft->isa_instklassptr(); |
| 5143 | const TypeKlassPtr* ktkp = kills->isa_instklassptr(); |
| 5144 | |
| 5145 | if (ft->empty()) { |
| 5146 | if (!empty() && ktkp != NULL__null && ktkp->klass()->is_loaded() && ktkp->klass()->is_interface()) |
| 5147 | return kills; // Uplift to interface |
| 5148 | |
| 5149 | return Type::TOP; // Canonical empty value |
| 5150 | } |
| 5151 | |
| 5152 | // Interface klass type could be exact in opposite to interface type, |
| 5153 | // return it here instead of incorrect Constant ptr J/L/Object (6894807). |
| 5154 | if (ftkp != NULL__null && ktkp != NULL__null && |
| 5155 | ftkp->is_loaded() && ftkp->klass()->is_interface() && |
| 5156 | !ftkp->klass_is_exact() && // Keep exact interface klass |
| 5157 | ktkp->is_loaded() && !ktkp->klass()->is_interface()) { |
| 5158 | return ktkp->cast_to_ptr_type(ftkp->ptr()); |
| 5159 | } |
| 5160 | |
| 5161 | return ft; |
| 5162 | } |
| 5163 | |
| 5164 | //------------------------------get_con---------------------------------------- |
| 5165 | intptr_t TypeKlassPtr::get_con() const { |
| 5166 | assert( _ptr == Null || _ptr == Constant, "" )do { if (!(_ptr == Null || _ptr == Constant)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 5166, "assert(" "_ptr == Null || _ptr == Constant" ") failed" , ""); ::breakpoint(); } } while (0); |
| 5167 | assert( _offset >= 0, "" )do { if (!(_offset >= 0)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 5167, "assert(" "_offset >= 0" ") failed", ""); ::breakpoint (); } } while (0); |
| 5168 | |
| 5169 | if (_offset != 0) { |
| 5170 | // After being ported to the compiler interface, the compiler no longer |
| 5171 | // directly manipulates the addresses of oops. Rather, it only has a pointer |
| 5172 | // to a handle at compile time. This handle is embedded in the generated |
| 5173 | // code and dereferenced at the time the nmethod is made. Until that time, |
| 5174 | // it is not reasonable to do arithmetic with the addresses of oops (we don't |
| 5175 | // have access to the addresses!). This does not seem to currently happen, |
| 5176 | // but this assertion here is to help prevent its occurence. |
| 5177 | tty->print_cr("Found oop constant with non-zero offset"); |
| 5178 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 5178); ::breakpoint(); } while (0); |
| 5179 | } |
| 5180 | |
| 5181 | return (intptr_t)klass()->constant_encoding(); |
| 5182 | } |
| 5183 | |
| 5184 | //------------------------------dump2------------------------------------------ |
| 5185 | // Dump Klass Type |
| 5186 | #ifndef PRODUCT |
| 5187 | void TypeKlassPtr::dump2(Dict & d, uint depth, outputStream *st) const { |
| 5188 | switch(_ptr) { |
| 5189 | case Constant: |
| 5190 | st->print("precise "); |
| 5191 | case NotNull: |
| 5192 | { |
| 5193 | const char *name = klass()->name()->as_utf8(); |
| 5194 | if (name) { |
| 5195 | st->print("%s: " INTPTR_FORMAT"0x%016" "l" "x", name, p2i(klass())); |
| 5196 | } else { |
| 5197 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 5197); ::breakpoint(); } while (0); |
| 5198 | } |
| 5199 | } |
| 5200 | case BotPTR: |
| 5201 | if (!WizardMode && !Verbose && _ptr != Constant) break; |
| 5202 | case TopPTR: |
| 5203 | case AnyNull: |
| 5204 | st->print(":%s", ptr_msg[_ptr]); |
| 5205 | if (_ptr == Constant) st->print(":exact"); |
| 5206 | break; |
| 5207 | default: |
| 5208 | break; |
| 5209 | } |
| 5210 | |
| 5211 | if (_offset) { // Dump offset, if any |
| 5212 | if (_offset == OffsetBot) { st->print("+any"); } |
| 5213 | else if (_offset == OffsetTop) { st->print("+unknown"); } |
| 5214 | else { st->print("+%d", _offset); } |
| 5215 | } |
| 5216 | |
| 5217 | st->print(" *"); |
| 5218 | } |
| 5219 | #endif |
| 5220 | |
| 5221 | //============================================================================= |
| 5222 | // Convenience common pre-built types. |
| 5223 | |
| 5224 | // Not-null object klass or below |
| 5225 | const TypeInstKlassPtr *TypeInstKlassPtr::OBJECT; |
| 5226 | const TypeInstKlassPtr *TypeInstKlassPtr::OBJECT_OR_NULL; |
| 5227 | |
| 5228 | bool TypeInstKlassPtr::eq(const Type *t) const { |
| 5229 | const TypeKlassPtr *p = t->is_klassptr(); |
| 5230 | return |
| 5231 | klass()->equals(p->klass()) && |
| 5232 | TypeKlassPtr::eq(p); |
| 5233 | } |
| 5234 | |
| 5235 | int TypeInstKlassPtr::hash(void) const { |
| 5236 | return java_add((jint)klass()->hash(), TypeKlassPtr::hash()); |
| 5237 | } |
| 5238 | |
| 5239 | const TypeInstKlassPtr *TypeInstKlassPtr::make(PTR ptr, ciKlass* k, int offset) { |
| 5240 | TypeInstKlassPtr *r = |
| 5241 | (TypeInstKlassPtr*)(new TypeInstKlassPtr(ptr, k, offset))->hashcons(); |
| 5242 | |
| 5243 | return r; |
| 5244 | } |
| 5245 | |
| 5246 | //------------------------------add_offset------------------------------------- |
| 5247 | // Access internals of klass object |
| 5248 | const TypePtr *TypeInstKlassPtr::add_offset( intptr_t offset ) const { |
| 5249 | return make( _ptr, klass(), xadd_offset(offset) ); |
| 5250 | } |
| 5251 | |
| 5252 | const TypeKlassPtr *TypeInstKlassPtr::with_offset(intptr_t offset) const { |
| 5253 | return make(_ptr, klass(), offset); |
| 5254 | } |
| 5255 | |
| 5256 | //------------------------------cast_to_ptr_type------------------------------- |
| 5257 | const TypePtr* TypeInstKlassPtr::cast_to_ptr_type(PTR ptr) const { |
| 5258 | assert(_base == InstKlassPtr, "subclass must override cast_to_ptr_type")do { if (!(_base == InstKlassPtr)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 5258, "assert(" "_base == InstKlassPtr" ") failed", "subclass must override cast_to_ptr_type" ); ::breakpoint(); } } while (0); |
| 5259 | if( ptr == _ptr ) return this; |
| 5260 | return make(ptr, _klass, _offset); |
| 5261 | } |
| 5262 | |
| 5263 | |
| 5264 | bool TypeInstKlassPtr::must_be_exact() const { |
| 5265 | if (!_klass->is_loaded()) return false; |
| 5266 | ciInstanceKlass* ik = _klass->as_instance_klass(); |
| 5267 | if (ik->is_final()) return true; // cannot clear xk |
| 5268 | return false; |
| 5269 | } |
| 5270 | |
| 5271 | //-----------------------------cast_to_exactness------------------------------- |
| 5272 | const TypeKlassPtr* TypeInstKlassPtr::cast_to_exactness(bool klass_is_exact) const { |
| 5273 | if (klass_is_exact == (_ptr == Constant)) return this; |
| 5274 | if (must_be_exact()) return this; |
| 5275 | ciKlass* k = klass(); |
| 5276 | return make(klass_is_exact ? Constant : NotNull, k, _offset); |
| 5277 | } |
| 5278 | |
| 5279 | |
| 5280 | //-----------------------------as_instance_type-------------------------------- |
| 5281 | // Corresponding type for an instance of the given class. |
| 5282 | // It will be NotNull, and exact if and only if the klass type is exact. |
| 5283 | const TypeOopPtr* TypeInstKlassPtr::as_instance_type() const { |
| 5284 | ciKlass* k = klass(); |
| 5285 | bool xk = klass_is_exact(); |
| 5286 | return TypeInstPtr::make(TypePtr::BotPTR, k, xk, NULL__null, 0); |
| 5287 | } |
| 5288 | |
| 5289 | //------------------------------xmeet------------------------------------------ |
| 5290 | // Compute the MEET of two types, return a new Type object. |
| 5291 | const Type *TypeInstKlassPtr::xmeet( const Type *t ) const { |
| 5292 | // Perform a fast test for common case; meeting the same types together. |
| 5293 | if( this == t ) return this; // Meeting same type-rep? |
| 5294 | |
| 5295 | // Current "this->_base" is Pointer |
| 5296 | switch (t->base()) { // switch on original type |
| 5297 | |
| 5298 | case Int: // Mixing ints & oops happens when javac |
| 5299 | case Long: // reuses local variables |
| 5300 | case FloatTop: |
| 5301 | case FloatCon: |
| 5302 | case FloatBot: |
| 5303 | case DoubleTop: |
| 5304 | case DoubleCon: |
| 5305 | case DoubleBot: |
| 5306 | case NarrowOop: |
| 5307 | case NarrowKlass: |
| 5308 | case Bottom: // Ye Olde Default |
| 5309 | return Type::BOTTOM; |
| 5310 | case Top: |
| 5311 | return this; |
| 5312 | |
| 5313 | default: // All else is a mistake |
| 5314 | typerr(t); |
| 5315 | |
| 5316 | case AnyPtr: { // Meeting to AnyPtrs |
| 5317 | // Found an AnyPtr type vs self-KlassPtr type |
| 5318 | const TypePtr *tp = t->is_ptr(); |
| 5319 | int offset = meet_offset(tp->offset()); |
| 5320 | PTR ptr = meet_ptr(tp->ptr()); |
| 5321 | switch (tp->ptr()) { |
| 5322 | case TopPTR: |
| 5323 | return this; |
| 5324 | case Null: |
| 5325 | if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth()); |
| 5326 | case AnyNull: |
| 5327 | return make( ptr, klass(), offset ); |
| 5328 | case BotPTR: |
| 5329 | case NotNull: |
| 5330 | return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth()); |
| 5331 | default: typerr(t); |
| 5332 | } |
| 5333 | } |
| 5334 | |
| 5335 | case RawPtr: |
| 5336 | case MetadataPtr: |
| 5337 | case OopPtr: |
| 5338 | case AryPtr: // Meet with AryPtr |
| 5339 | case InstPtr: // Meet with InstPtr |
| 5340 | return TypePtr::BOTTOM; |
| 5341 | |
| 5342 | // |
| 5343 | // A-top } |
| 5344 | // / | \ } Tops |
| 5345 | // B-top A-any C-top } |
| 5346 | // | / | \ | } Any-nulls |
| 5347 | // B-any | C-any } |
| 5348 | // | | | |
| 5349 | // B-con A-con C-con } constants; not comparable across classes |
| 5350 | // | | | |
| 5351 | // B-not | C-not } |
| 5352 | // | \ | / | } not-nulls |
| 5353 | // B-bot A-not C-bot } |
| 5354 | // \ | / } Bottoms |
| 5355 | // A-bot } |
| 5356 | // |
| 5357 | |
| 5358 | case InstKlassPtr: { // Meet two KlassPtr types |
| 5359 | const TypeInstKlassPtr *tkls = t->is_instklassptr(); |
| 5360 | int off = meet_offset(tkls->offset()); |
| 5361 | PTR ptr = meet_ptr(tkls->ptr()); |
| 5362 | ciKlass* tkls_klass = tkls->klass(); |
| 5363 | ciKlass* this_klass = klass(); |
| 5364 | bool tkls_xk = tkls->klass_is_exact(); |
| 5365 | bool this_xk = klass_is_exact(); |
| 5366 | |
| 5367 | ciKlass* res_klass = NULL__null; |
| 5368 | bool res_xk = false; |
| 5369 | switch(meet_instptr(ptr, this_klass, tkls_klass, this_xk, tkls_xk, this->_ptr, tkls->_ptr, res_klass, res_xk)) { |
| 5370 | case UNLOADED: |
| 5371 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 5371); ::breakpoint(); } while (0); |
| 5372 | case SUBTYPE: |
| 5373 | case NOT_SUBTYPE: |
| 5374 | case LCA: |
| 5375 | case QUICK: { |
| 5376 | assert(res_xk == (ptr == Constant), "")do { if (!(res_xk == (ptr == Constant))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 5376, "assert(" "res_xk == (ptr == Constant)" ") failed", "" ); ::breakpoint(); } } while (0); |
| 5377 | const Type* res1 = make(ptr, res_klass, off); |
| 5378 | return res1; |
| 5379 | } |
| 5380 | default: |
| 5381 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 5381); ::breakpoint(); } while (0); |
| 5382 | } |
| 5383 | } // End of case KlassPtr |
| 5384 | case AryKlassPtr: { // All arrays inherit from Object class |
| 5385 | const TypeAryKlassPtr *tp = t->is_aryklassptr(); |
| 5386 | int offset = meet_offset(tp->offset()); |
| 5387 | PTR ptr = meet_ptr(tp->ptr()); |
| 5388 | |
| 5389 | switch (ptr) { |
| 5390 | case TopPTR: |
| 5391 | case AnyNull: // Fall 'down' to dual of object klass |
| 5392 | // For instances when a subclass meets a superclass we fall |
| 5393 | // below the centerline when the superclass is exact. We need to |
| 5394 | // do the same here. |
| 5395 | if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { |
| 5396 | return TypeAryKlassPtr::make(ptr, tp->elem(), tp->klass(), offset); |
| 5397 | } else { |
| 5398 | // cannot subclass, so the meet has to fall badly below the centerline |
| 5399 | ptr = NotNull; |
| 5400 | return make(ptr, ciEnv::current()->Object_klass(), offset); |
| 5401 | } |
| 5402 | case Constant: |
| 5403 | case NotNull: |
| 5404 | case BotPTR: // Fall down to object klass |
| 5405 | // LCA is object_klass, but if we subclass from the top we can do better |
| 5406 | if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull ) |
| 5407 | // If 'this' (InstPtr) is above the centerline and it is Object class |
| 5408 | // then we can subclass in the Java class hierarchy. |
| 5409 | // For instances when a subclass meets a superclass we fall |
| 5410 | // below the centerline when the superclass is exact. We need |
| 5411 | // to do the same here. |
| 5412 | if (klass()->equals(ciEnv::current()->Object_klass())) { |
| 5413 | // that is, tp's array type is a subtype of my klass |
| 5414 | return TypeAryKlassPtr::make(ptr, |
| 5415 | tp->elem(), tp->klass(), offset); |
| 5416 | } |
| 5417 | } |
| 5418 | // The other case cannot happen, since I cannot be a subtype of an array. |
| 5419 | // The meet falls down to Object class below centerline. |
| 5420 | if( ptr == Constant ) |
| 5421 | ptr = NotNull; |
| 5422 | return make(ptr, ciEnv::current()->Object_klass(), offset); |
| 5423 | default: typerr(t); |
| 5424 | } |
| 5425 | } |
| 5426 | |
| 5427 | } // End of switch |
| 5428 | return this; // Return the double constant |
| 5429 | } |
| 5430 | |
| 5431 | //------------------------------xdual------------------------------------------ |
| 5432 | // Dual: compute field-by-field dual |
| 5433 | const Type *TypeInstKlassPtr::xdual() const { |
| 5434 | return new TypeInstKlassPtr(dual_ptr(), klass(), dual_offset()); |
| 5435 | } |
| 5436 | |
| 5437 | const TypeAryKlassPtr *TypeAryKlassPtr::make(PTR ptr, const Type* elem, ciKlass* k, int offset) { |
| 5438 | return (TypeAryKlassPtr*)(new TypeAryKlassPtr(ptr, elem, k, offset))->hashcons(); |
| 5439 | } |
| 5440 | |
| 5441 | const TypeAryKlassPtr *TypeAryKlassPtr::make(PTR ptr, ciKlass* klass, int offset) { |
| 5442 | if (klass->is_obj_array_klass()) { |
| 5443 | // Element is an object array. Recursively call ourself. |
| 5444 | ciKlass* eklass = klass->as_obj_array_klass()->element_klass(); |
| 5445 | const TypeKlassPtr *etype = TypeKlassPtr::make(eklass)->cast_to_exactness(false); |
| 5446 | return TypeAryKlassPtr::make(ptr, etype, NULL__null, offset); |
| 5447 | } else if (klass->is_type_array_klass()) { |
| 5448 | // Element is an typeArray |
| 5449 | const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type()); |
| 5450 | return TypeAryKlassPtr::make(ptr, etype, klass, offset); |
| 5451 | } else { |
| 5452 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 5452); ::breakpoint(); } while (0); |
| 5453 | return NULL__null; |
| 5454 | } |
| 5455 | } |
| 5456 | |
| 5457 | const TypeAryKlassPtr* TypeAryKlassPtr::make(ciKlass* klass) { |
| 5458 | return TypeAryKlassPtr::make(Constant, klass, 0); |
| 5459 | } |
| 5460 | |
| 5461 | //------------------------------eq--------------------------------------------- |
| 5462 | // Structural equality check for Type representations |
| 5463 | bool TypeAryKlassPtr::eq(const Type *t) const { |
| 5464 | const TypeAryKlassPtr *p = t->is_aryklassptr(); |
| 5465 | return |
| 5466 | _elem == p->_elem && // Check array |
| 5467 | TypeKlassPtr::eq(p); // Check sub-parts |
| 5468 | } |
| 5469 | |
| 5470 | //------------------------------hash------------------------------------------- |
| 5471 | // Type-specific hashing function. |
| 5472 | int TypeAryKlassPtr::hash(void) const { |
| 5473 | return (intptr_t)_elem + TypeKlassPtr::hash(); |
| 5474 | } |
| 5475 | |
| 5476 | //----------------------compute_klass------------------------------------------ |
| 5477 | // Compute the defining klass for this class |
| 5478 | ciKlass* TypeAryPtr::compute_klass(DEBUG_ONLY(bool verify)bool verify) const { |
| 5479 | // Compute _klass based on element type. |
| 5480 | ciKlass* k_ary = NULL__null; |
| 5481 | const TypeInstPtr *tinst; |
| 5482 | const TypeAryPtr *tary; |
| 5483 | const Type* el = elem(); |
| 5484 | if (el->isa_narrowoop()) { |
| 5485 | el = el->make_ptr(); |
| 5486 | } |
| 5487 | |
| 5488 | // Get element klass |
| 5489 | if ((tinst = el->isa_instptr()) != NULL__null) { |
| 5490 | // Compute array klass from element klass |
| 5491 | k_ary = ciObjArrayKlass::make(tinst->klass()); |
| 5492 | } else if ((tary = el->isa_aryptr()) != NULL__null) { |
| 5493 | // Compute array klass from element klass |
| 5494 | ciKlass* k_elem = tary->klass(); |
| 5495 | // If element type is something like bottom[], k_elem will be null. |
| 5496 | if (k_elem != NULL__null) |
| 5497 | k_ary = ciObjArrayKlass::make(k_elem); |
| 5498 | } else if ((el->base() == Type::Top) || |
| 5499 | (el->base() == Type::Bottom)) { |
| 5500 | // element type of Bottom occurs from meet of basic type |
| 5501 | // and object; Top occurs when doing join on Bottom. |
| 5502 | // Leave k_ary at NULL. |
| 5503 | } else { |
| 5504 | // Cannot compute array klass directly from basic type, |
| 5505 | // since subtypes of TypeInt all have basic type T_INT. |
| 5506 | #ifdef ASSERT1 |
| 5507 | if (verify && el->isa_int()) { |
| 5508 | // Check simple cases when verifying klass. |
| 5509 | BasicType bt = T_ILLEGAL; |
| 5510 | if (el == TypeInt::BYTE) { |
| 5511 | bt = T_BYTE; |
| 5512 | } else if (el == TypeInt::SHORT) { |
| 5513 | bt = T_SHORT; |
| 5514 | } else if (el == TypeInt::CHAR) { |
| 5515 | bt = T_CHAR; |
| 5516 | } else if (el == TypeInt::INT) { |
| 5517 | bt = T_INT; |
| 5518 | } else { |
| 5519 | return _klass; // just return specified klass |
| 5520 | } |
| 5521 | return ciTypeArrayKlass::make(bt); |
| 5522 | } |
| 5523 | #endif |
| 5524 | assert(!el->isa_int(),do { if (!(!el->isa_int())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 5525, "assert(" "!el->isa_int()" ") failed", "integral arrays must be pre-equipped with a class" ); ::breakpoint(); } } while (0) |
| 5525 | "integral arrays must be pre-equipped with a class")do { if (!(!el->isa_int())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 5525, "assert(" "!el->isa_int()" ") failed", "integral arrays must be pre-equipped with a class" ); ::breakpoint(); } } while (0); |
| 5526 | // Compute array klass directly from basic type |
| 5527 | k_ary = ciTypeArrayKlass::make(el->basic_type()); |
| 5528 | } |
| 5529 | return k_ary; |
| 5530 | } |
| 5531 | |
| 5532 | //------------------------------klass------------------------------------------ |
| 5533 | // Return the defining klass for this class |
| 5534 | ciKlass* TypeAryPtr::klass() const { |
| 5535 | if( _klass ) return _klass; // Return cached value, if possible |
| 5536 | |
| 5537 | // Oops, need to compute _klass and cache it |
| 5538 | ciKlass* k_ary = compute_klass(); |
| 5539 | |
| 5540 | if( this != TypeAryPtr::OOPS && this->dual() != TypeAryPtr::OOPS ) { |
| 5541 | // The _klass field acts as a cache of the underlying |
| 5542 | // ciKlass for this array type. In order to set the field, |
| 5543 | // we need to cast away const-ness. |
| 5544 | // |
| 5545 | // IMPORTANT NOTE: we *never* set the _klass field for the |
| 5546 | // type TypeAryPtr::OOPS. This Type is shared between all |
| 5547 | // active compilations. However, the ciKlass which represents |
| 5548 | // this Type is *not* shared between compilations, so caching |
| 5549 | // this value would result in fetching a dangling pointer. |
| 5550 | // |
| 5551 | // Recomputing the underlying ciKlass for each request is |
| 5552 | // a bit less efficient than caching, but calls to |
| 5553 | // TypeAryPtr::OOPS->klass() are not common enough to matter. |
| 5554 | ((TypeAryPtr*)this)->_klass = k_ary; |
| 5555 | if (UseCompressedOops && k_ary != NULL__null && k_ary->is_obj_array_klass() && |
| 5556 | _offset != 0 && _offset != arrayOopDesc::length_offset_in_bytes()) { |
| 5557 | ((TypeAryPtr*)this)->_is_ptr_to_narrowoop = true; |
| 5558 | } |
| 5559 | } |
| 5560 | return k_ary; |
| 5561 | } |
| 5562 | |
| 5563 | |
| 5564 | //------------------------------add_offset------------------------------------- |
| 5565 | // Access internals of klass object |
| 5566 | const TypePtr *TypeAryKlassPtr::add_offset(intptr_t offset) const { |
| 5567 | return make(_ptr, elem(), klass(), xadd_offset(offset)); |
| 5568 | } |
| 5569 | |
| 5570 | const TypeKlassPtr *TypeAryKlassPtr::with_offset(intptr_t offset) const { |
| 5571 | return make(_ptr, elem(), klass(), offset); |
| 5572 | } |
| 5573 | |
| 5574 | //------------------------------cast_to_ptr_type------------------------------- |
| 5575 | const TypePtr* TypeAryKlassPtr::cast_to_ptr_type(PTR ptr) const { |
| 5576 | assert(_base == AryKlassPtr, "subclass must override cast_to_ptr_type")do { if (!(_base == AryKlassPtr)) { (*g_assert_poison) = 'X'; ; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 5576, "assert(" "_base == AryKlassPtr" ") failed", "subclass must override cast_to_ptr_type" ); ::breakpoint(); } } while (0); |
| 5577 | if (ptr == _ptr) return this; |
| 5578 | return make(ptr, elem(), _klass, _offset); |
| 5579 | } |
| 5580 | |
| 5581 | bool TypeAryKlassPtr::must_be_exact() const { |
| 5582 | if (_elem == Type::BOTTOM) return false; |
| 5583 | if (_elem == Type::TOP ) return false; |
| 5584 | const TypeKlassPtr* tk = _elem->isa_klassptr(); |
| 5585 | if (!tk) return true; // a primitive type, like int |
| 5586 | return tk->must_be_exact(); |
| 5587 | } |
| 5588 | |
| 5589 | |
| 5590 | //-----------------------------cast_to_exactness------------------------------- |
| 5591 | const TypeKlassPtr *TypeAryKlassPtr::cast_to_exactness(bool klass_is_exact) const { |
| 5592 | if (must_be_exact()) return this; // cannot clear xk |
| 5593 | ciKlass* k = _klass; |
| 5594 | const Type* elem = this->elem(); |
| 5595 | if (elem->isa_klassptr() && !klass_is_exact) { |
| 5596 | elem = elem->is_klassptr()->cast_to_exactness(klass_is_exact); |
| 5597 | } |
| 5598 | return make(klass_is_exact ? Constant : NotNull, elem, k, _offset); |
| 5599 | } |
| 5600 | |
| 5601 | |
| 5602 | //-----------------------------as_instance_type-------------------------------- |
| 5603 | // Corresponding type for an instance of the given class. |
| 5604 | // It will be exact if and only if the klass type is exact. |
| 5605 | const TypeOopPtr* TypeAryKlassPtr::as_instance_type() const { |
| 5606 | ciKlass* k = klass(); |
| 5607 | bool xk = klass_is_exact(); |
| 5608 | const Type* el = elem()->isa_klassptr() ? elem()->is_klassptr()->as_instance_type()->is_oopptr()->cast_to_exactness(false) : elem(); |
| 5609 | return TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(el, TypeInt::POS), k, xk, 0); |
| 5610 | } |
| 5611 | |
| 5612 | |
| 5613 | //------------------------------xmeet------------------------------------------ |
| 5614 | // Compute the MEET of two types, return a new Type object. |
| 5615 | const Type *TypeAryKlassPtr::xmeet( const Type *t ) const { |
| 5616 | // Perform a fast test for common case; meeting the same types together. |
| 5617 | if( this == t ) return this; // Meeting same type-rep? |
| 5618 | |
| 5619 | // Current "this->_base" is Pointer |
| 5620 | switch (t->base()) { // switch on original type |
| 5621 | |
| 5622 | case Int: // Mixing ints & oops happens when javac |
| 5623 | case Long: // reuses local variables |
| 5624 | case FloatTop: |
| 5625 | case FloatCon: |
| 5626 | case FloatBot: |
| 5627 | case DoubleTop: |
| 5628 | case DoubleCon: |
| 5629 | case DoubleBot: |
| 5630 | case NarrowOop: |
| 5631 | case NarrowKlass: |
| 5632 | case Bottom: // Ye Olde Default |
| 5633 | return Type::BOTTOM; |
| 5634 | case Top: |
| 5635 | return this; |
| 5636 | |
| 5637 | default: // All else is a mistake |
| 5638 | typerr(t); |
| 5639 | |
| 5640 | case AnyPtr: { // Meeting to AnyPtrs |
| 5641 | // Found an AnyPtr type vs self-KlassPtr type |
| 5642 | const TypePtr *tp = t->is_ptr(); |
| 5643 | int offset = meet_offset(tp->offset()); |
| 5644 | PTR ptr = meet_ptr(tp->ptr()); |
| 5645 | switch (tp->ptr()) { |
| 5646 | case TopPTR: |
| 5647 | return this; |
| 5648 | case Null: |
| 5649 | if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth()); |
| 5650 | case AnyNull: |
| 5651 | return make( ptr, _elem, klass(), offset ); |
| 5652 | case BotPTR: |
| 5653 | case NotNull: |
| 5654 | return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth()); |
| 5655 | default: typerr(t); |
| 5656 | } |
| 5657 | } |
| 5658 | |
| 5659 | case RawPtr: |
| 5660 | case MetadataPtr: |
| 5661 | case OopPtr: |
| 5662 | case AryPtr: // Meet with AryPtr |
| 5663 | case InstPtr: // Meet with InstPtr |
| 5664 | return TypePtr::BOTTOM; |
| 5665 | |
| 5666 | // |
| 5667 | // A-top } |
| 5668 | // / | \ } Tops |
| 5669 | // B-top A-any C-top } |
| 5670 | // | / | \ | } Any-nulls |
| 5671 | // B-any | C-any } |
| 5672 | // | | | |
| 5673 | // B-con A-con C-con } constants; not comparable across classes |
| 5674 | // | | | |
| 5675 | // B-not | C-not } |
| 5676 | // | \ | / | } not-nulls |
| 5677 | // B-bot A-not C-bot } |
| 5678 | // \ | / } Bottoms |
| 5679 | // A-bot } |
| 5680 | // |
| 5681 | |
| 5682 | case AryKlassPtr: { // Meet two KlassPtr types |
| 5683 | const TypeAryKlassPtr *tap = t->is_aryklassptr(); |
| 5684 | int off = meet_offset(tap->offset()); |
| 5685 | const Type* elem = _elem->meet(tap->_elem); |
| 5686 | |
| 5687 | PTR ptr = meet_ptr(tap->ptr()); |
| 5688 | ciKlass* res_klass = NULL__null; |
| 5689 | bool res_xk = false; |
| 5690 | meet_aryptr(ptr, elem, this->klass(), tap->klass(), this->klass_is_exact(), tap->klass_is_exact(), this->ptr(), tap->ptr(), res_klass, res_xk); |
| 5691 | assert(res_xk == (ptr == Constant), "")do { if (!(res_xk == (ptr == Constant))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/type.cpp" , 5691, "assert(" "res_xk == (ptr == Constant)" ") failed", "" ); ::breakpoint(); } } while (0); |
| 5692 | return make(ptr, elem, res_klass, off); |
| 5693 | } // End of case KlassPtr |
| 5694 | case InstKlassPtr: { |
| 5695 | const TypeInstKlassPtr *tp = t->is_instklassptr(); |
| 5696 | int offset = meet_offset(tp->offset()); |
| 5697 | PTR ptr = meet_ptr(tp->ptr()); |
| 5698 | |
| 5699 | switch (ptr) { |
| 5700 | case TopPTR: |
| 5701 | case AnyNull: // Fall 'down' to dual of object klass |
| 5702 | // For instances when a subclass meets a superclass we fall |
| 5703 | // below the centerline when the superclass is exact. We need to |
| 5704 | // do the same here. |
| 5705 | if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { |
| 5706 | return TypeAryKlassPtr::make(ptr, _elem, _klass, offset); |
| 5707 | } else { |
| 5708 | // cannot subclass, so the meet has to fall badly below the centerline |
| 5709 | ptr = NotNull; |
| 5710 | return TypeInstKlassPtr::make(ptr, ciEnv::current()->Object_klass(), offset); |
| 5711 | } |
| 5712 | case Constant: |
| 5713 | case NotNull: |
| 5714 | case BotPTR: // Fall down to object klass |
| 5715 | // LCA is object_klass, but if we subclass from the top we can do better |
| 5716 | if (above_centerline(tp->ptr())) { |
| 5717 | // If 'tp' is above the centerline and it is Object class |
| 5718 | // then we can subclass in the Java class hierarchy. |
| 5719 | // For instances when a subclass meets a superclass we fall |
| 5720 | // below the centerline when the superclass is exact. We need |
| 5721 | // to do the same here. |
| 5722 | if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { |
| 5723 | // that is, my array type is a subtype of 'tp' klass |
| 5724 | return make(ptr, _elem, _klass, offset); |
| 5725 | } |
| 5726 | } |
| 5727 | // The other case cannot happen, since t cannot be a subtype of an array. |
| 5728 | // The meet falls down to Object class below centerline. |
| 5729 | if (ptr == Constant) |
| 5730 | ptr = NotNull; |
| 5731 | return TypeInstKlassPtr::make(ptr, ciEnv::current()->Object_klass(), offset); |
| 5732 | default: typerr(t); |
| 5733 | } |
| 5734 | } |
| 5735 | |
| 5736 | } // End of switch |
| 5737 | return this; // Return the double constant |
| 5738 | } |
| 5739 | |
| 5740 | //------------------------------xdual------------------------------------------ |
| 5741 | // Dual: compute field-by-field dual |
| 5742 | const Type *TypeAryKlassPtr::xdual() const { |
| 5743 | return new TypeAryKlassPtr(dual_ptr(), elem()->dual(), klass(), dual_offset()); |
| 5744 | } |
| 5745 | |
| 5746 | //------------------------------get_con---------------------------------------- |
| 5747 | ciKlass* TypeAryKlassPtr::klass() const { |
| 5748 | if (_klass != NULL__null) { |
| 5749 | return _klass; |
| 5750 | } |
| 5751 | ciKlass* k = NULL__null; |
| 5752 | if (elem()->isa_klassptr()) { |
| 5753 | k = elem()->is_klassptr()->klass(); |
| 5754 | if (k != NULL__null) { |
| 5755 | k = ciObjArrayKlass::make(k); |
| 5756 | ((TypeAryKlassPtr*)this)->_klass = k; |
| 5757 | } |
| 5758 | } else if ((elem()->base() == Type::Top) || |
| 5759 | (elem()->base() == Type::Bottom)) { |
| 5760 | } else { |
| 5761 | k = ciTypeArrayKlass::make(elem()->basic_type()); |
| 5762 | } |
| 5763 | return k; |
| 5764 | } |
| 5765 | |
| 5766 | //------------------------------dump2------------------------------------------ |
| 5767 | // Dump Klass Type |
| 5768 | #ifndef PRODUCT |
| 5769 | void TypeAryKlassPtr::dump2( Dict & d, uint depth, outputStream *st ) const { |
| 5770 | switch( _ptr ) { |
| 5771 | case Constant: |
| 5772 | st->print("precise "); |
| 5773 | case NotNull: |
| 5774 | { |
| 5775 | st->print("["); |
| 5776 | _elem->dump2(d, depth, st); |
| 5777 | st->print(": "); |
| 5778 | } |
| 5779 | case BotPTR: |
| 5780 | if( !WizardMode && !Verbose && _ptr != Constant ) break; |
| 5781 | case TopPTR: |
| 5782 | case AnyNull: |
| 5783 | st->print(":%s", ptr_msg[_ptr]); |
| 5784 | if( _ptr == Constant ) st->print(":exact"); |
| 5785 | break; |
| 5786 | default: |
| 5787 | break; |
| 5788 | } |
| 5789 | |
| 5790 | if( _offset ) { // Dump offset, if any |
| 5791 | if( _offset == OffsetBot ) { st->print("+any"); } |
| 5792 | else if( _offset == OffsetTop ) { st->print("+unknown"); } |
| 5793 | else { st->print("+%d", _offset); } |
| 5794 | } |
| 5795 | |
| 5796 | st->print(" *"); |
| 5797 | } |
| 5798 | #endif |
| 5799 | |
| 5800 | const Type* TypeAryKlassPtr::base_element_type(int& dims) const { |
| 5801 | const Type* elem = this->elem(); |
| 5802 | dims = 1; |
| 5803 | while (elem->isa_aryklassptr()) { |
| 5804 | elem = elem->is_aryklassptr()->elem(); |
| 5805 | dims++; |
| 5806 | } |
| 5807 | return elem; |
| 5808 | } |
| 5809 | |
| 5810 | //============================================================================= |
| 5811 | // Convenience common pre-built types. |
| 5812 | |
| 5813 | //------------------------------make------------------------------------------- |
| 5814 | const TypeFunc *TypeFunc::make( const TypeTuple *domain, const TypeTuple *range ) { |
| 5815 | return (TypeFunc*)(new TypeFunc(domain,range))->hashcons(); |
| 5816 | } |
| 5817 | |
| 5818 | //------------------------------make------------------------------------------- |
| 5819 | const TypeFunc *TypeFunc::make(ciMethod* method) { |
| 5820 | Compile* C = Compile::current(); |
| 5821 | const TypeFunc* tf = C->last_tf(method); // check cache |
| 5822 | if (tf != NULL__null) return tf; // The hit rate here is almost 50%. |
| 5823 | const TypeTuple *domain; |
| 5824 | if (method->is_static()) { |
| 5825 | domain = TypeTuple::make_domain(NULL__null, method->signature()); |
| 5826 | } else { |
| 5827 | domain = TypeTuple::make_domain(method->holder(), method->signature()); |
| 5828 | } |
| 5829 | const TypeTuple *range = TypeTuple::make_range(method->signature()); |
| 5830 | tf = TypeFunc::make(domain, range); |
| 5831 | C->set_last_tf(method, tf); // fill cache |
| 5832 | return tf; |
| 5833 | } |
| 5834 | |
| 5835 | //------------------------------meet------------------------------------------- |
| 5836 | // Compute the MEET of two types. It returns a new Type object. |
| 5837 | const Type *TypeFunc::xmeet( const Type *t ) const { |
| 5838 | // Perform a fast test for common case; meeting the same types together. |
| 5839 | if( this == t ) return this; // Meeting same type-rep? |
| 5840 | |
| 5841 | // Current "this->_base" is Func |
| 5842 | switch (t->base()) { // switch on original type |
| 5843 | |
| 5844 | case Bottom: // Ye Olde Default |
| 5845 | return t; |
| 5846 | |
| 5847 | default: // All else is a mistake |
| 5848 | typerr(t); |
| 5849 | |
| 5850 | case Top: |
| 5851 | break; |
| 5852 | } |
| 5853 | return this; // Return the double constant |
| 5854 | } |
| 5855 | |
| 5856 | //------------------------------xdual------------------------------------------ |
| 5857 | // Dual: compute field-by-field dual |
| 5858 | const Type *TypeFunc::xdual() const { |
| 5859 | return this; |
| 5860 | } |
| 5861 | |
| 5862 | //------------------------------eq--------------------------------------------- |
| 5863 | // Structural equality check for Type representations |
| 5864 | bool TypeFunc::eq( const Type *t ) const { |
| 5865 | const TypeFunc *a = (const TypeFunc*)t; |
| 5866 | return _domain == a->_domain && |
| 5867 | _range == a->_range; |
| 5868 | } |
| 5869 | |
| 5870 | //------------------------------hash------------------------------------------- |
| 5871 | // Type-specific hashing function. |
| 5872 | int TypeFunc::hash(void) const { |
| 5873 | return (intptr_t)_domain + (intptr_t)_range; |
| 5874 | } |
| 5875 | |
| 5876 | //------------------------------dump2------------------------------------------ |
| 5877 | // Dump Function Type |
| 5878 | #ifndef PRODUCT |
| 5879 | void TypeFunc::dump2( Dict &d, uint depth, outputStream *st ) const { |
| 5880 | if( _range->cnt() <= Parms ) |
| 5881 | st->print("void"); |
| 5882 | else { |
| 5883 | uint i; |
| 5884 | for (i = Parms; i < _range->cnt()-1; i++) { |
| 5885 | _range->field_at(i)->dump2(d,depth,st); |
| 5886 | st->print("/"); |
| 5887 | } |
| 5888 | _range->field_at(i)->dump2(d,depth,st); |
| 5889 | } |
| 5890 | st->print(" "); |
| 5891 | st->print("( "); |
| 5892 | if( !depth || d[this] ) { // Check for recursive dump |
| 5893 | st->print("...)"); |
| 5894 | return; |
| 5895 | } |
| 5896 | d.Insert((void*)this,(void*)this); // Stop recursion |
| 5897 | if (Parms < _domain->cnt()) |
| 5898 | _domain->field_at(Parms)->dump2(d,depth-1,st); |
| 5899 | for (uint i = Parms+1; i < _domain->cnt(); i++) { |
| 5900 | st->print(", "); |
| 5901 | _domain->field_at(i)->dump2(d,depth-1,st); |
| 5902 | } |
| 5903 | st->print(" )"); |
| 5904 | } |
| 5905 | #endif |
| 5906 | |
| 5907 | //------------------------------singleton-------------------------------------- |
| 5908 | // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple |
| 5909 | // constants (Ldi nodes). Singletons are integer, float or double constants |
| 5910 | // or a single symbol. |
| 5911 | bool TypeFunc::singleton(void) const { |
| 5912 | return false; // Never a singleton |
| 5913 | } |
| 5914 | |
| 5915 | bool TypeFunc::empty(void) const { |
| 5916 | return false; // Never empty |
| 5917 | } |
| 5918 | |
| 5919 | |
| 5920 | BasicType TypeFunc::return_type() const{ |
| 5921 | if (range()->cnt() == TypeFunc::Parms) { |
| 5922 | return T_VOID; |
| 5923 | } |
| 5924 | return range()->field_at(TypeFunc::Parms)->basic_type(); |
| 5925 | } |