33 #include "memory/oopFactory.hpp" 34 #include "memory/resourceArea.hpp" 35 #include "oops/instanceKlass.hpp" 36 #include "oops/instanceMirrorKlass.hpp" 37 #include "oops/objArrayKlass.hpp" 38 #include "oops/typeArrayKlass.hpp" 39 #include "opto/matcher.hpp" 40 #include "opto/node.hpp" 41 #include "opto/opcodes.hpp" 42 #include "opto/type.hpp" 43 44 // Portions of code courtesy of Clifford Click 45 46 // Optimization - Graph Style 47 48 // Dictionary of types shared among compilations. 49 Dict* Type::_shared_type_dict = NULL; 50 51 // Array which maps compiler types to Basic Types 52 Type::TypeInfo Type::_type_info[Type::lastype] = { 53 { Bad, T_ILLEGAL, "bad", false, Node::NotAMachineReg, relocInfo::none }, // Bad 54 { Control, T_ILLEGAL, "control", false, 0, relocInfo::none }, // Control 55 { Bottom, T_VOID, "top", false, 0, relocInfo::none }, // Top 56 { Bad, T_INT, "int:", false, Op_RegI, relocInfo::none }, // Int 57 { Bad, T_LONG, "long:", false, Op_RegL, relocInfo::none }, // Long 58 { Half, T_VOID, "half", false, 0, relocInfo::none }, // Half 59 { Bad, T_NARROWOOP, "narrowoop:", false, Op_RegN, relocInfo::none }, // NarrowOop 60 { Bad, T_NARROWKLASS,"narrowklass:", false, Op_RegN, relocInfo::none }, // NarrowKlass 61 { Bad, T_ILLEGAL, "tuple:", false, Node::NotAMachineReg, relocInfo::none }, // Tuple 62 { Bad, T_ARRAY, "array:", false, Node::NotAMachineReg, relocInfo::none }, // Array 63 64 #ifdef SPARC 65 { Bad, T_ILLEGAL, "vectors:", false, 0, relocInfo::none }, // VectorS 66 { Bad, T_ILLEGAL, "vectord:", false, Op_RegD, relocInfo::none }, // VectorD 67 { Bad, T_ILLEGAL, "vectorx:", false, 0, relocInfo::none }, // VectorX 68 { Bad, T_ILLEGAL, "vectory:", false, 0, relocInfo::none }, // VectorY 69 { Bad, T_ILLEGAL, "vectorz:", false, 0, relocInfo::none }, // VectorZ 70 #elif defined(PPC64) 71 { Bad, T_ILLEGAL, "vectors:", false, 0, relocInfo::none }, // VectorS 72 { Bad, T_ILLEGAL, "vectord:", false, Op_RegL, relocInfo::none }, // VectorD 73 { Bad, T_ILLEGAL, "vectorx:", false, 0, relocInfo::none }, // VectorX 74 { Bad, T_ILLEGAL, "vectory:", false, 0, relocInfo::none }, // VectorY 75 { Bad, T_ILLEGAL, "vectorz:", false, 0, relocInfo::none }, // VectorZ 76 #else // all other 77 { Bad, T_ILLEGAL, "vectors:", false, Op_VecS, relocInfo::none }, // VectorS 78 { Bad, T_ILLEGAL, "vectord:", false, Op_VecD, relocInfo::none }, // VectorD 79 { Bad, T_ILLEGAL, "vectorx:", false, Op_VecX, relocInfo::none }, // VectorX 80 { Bad, T_ILLEGAL, "vectory:", false, Op_VecY, relocInfo::none }, // VectorY 81 { Bad, T_ILLEGAL, "vectorz:", false, Op_VecZ, relocInfo::none }, // VectorZ 82 #endif 83 { Bad, T_ADDRESS, "anyptr:", false, Op_RegP, relocInfo::none }, // AnyPtr 84 { Bad, T_ADDRESS, "rawptr:", false, Op_RegP, relocInfo::none }, // RawPtr 85 { Bad, T_OBJECT, "oop:", true, Op_RegP, relocInfo::oop_type }, // OopPtr 86 { Bad, T_OBJECT, "inst:", true, Op_RegP, relocInfo::oop_type }, // InstPtr 87 { Bad, T_OBJECT, "ary:", true, Op_RegP, relocInfo::oop_type }, // AryPtr 88 { Bad, T_METADATA, "metadata:", false, Op_RegP, relocInfo::metadata_type }, // MetadataPtr 89 { Bad, T_METADATA, "klass:", false, Op_RegP, relocInfo::metadata_type }, // KlassPtr 90 { Bad, T_OBJECT, "func", false, 0, relocInfo::none }, // Function 91 { Abio, T_ILLEGAL, "abIO", false, 0, relocInfo::none }, // Abio 92 { Return_Address, T_ADDRESS, "return_address",false, Op_RegP, relocInfo::none }, // Return_Address 93 { Memory, T_ILLEGAL, "memory", false, 0, relocInfo::none }, // Memory 94 { FloatBot, T_FLOAT, "float_top", false, Op_RegF, relocInfo::none }, // FloatTop 95 { FloatCon, T_FLOAT, "ftcon:", false, Op_RegF, relocInfo::none }, // FloatCon 96 { FloatTop, T_FLOAT, "float", false, Op_RegF, relocInfo::none }, // FloatBot 97 { DoubleBot, T_DOUBLE, "double_top", false, Op_RegD, relocInfo::none }, // DoubleTop 98 { DoubleCon, T_DOUBLE, "dblcon:", false, Op_RegD, relocInfo::none }, // DoubleCon 99 { DoubleTop, T_DOUBLE, "double", false, Op_RegD, relocInfo::none }, // DoubleBot 100 { Top, T_ILLEGAL, "bottom", false, 0, relocInfo::none } // Bottom 101 }; 102 103 // Map ideal registers (machine types) to ideal types 104 const Type *Type::mreg2type[_last_machine_leaf]; 105 106 // Map basic types to canonical Type* pointers. 107 const Type* Type:: _const_basic_type[T_CONFLICT+1]; 108 109 // Map basic types to constant-zero Types. 110 const Type* Type:: _zero_type[T_CONFLICT+1]; 111 112 // Map basic types to array-body alias types. 113 const TypeAryPtr* TypeAryPtr::_array_body_type[T_CONFLICT+1]; 114 115 //============================================================================= 116 // Convenience common pre-built types. 117 const Type *Type::ABIO; // State-of-machine only 118 const Type *Type::BOTTOM; // All values 119 const Type *Type::CONTROL; // Control only 120 const Type *Type::DOUBLE; // All doubles 121 const Type *Type::FLOAT; // All floats 122 const Type *Type::HALF; // Placeholder half of doublewide type 123 const Type *Type::MEMORY; // Abstract store only 124 const Type *Type::RETURN_ADDRESS; 518 fsc[0] = TypeInt::CC; 519 fsc[1] = Type::MEMORY; 520 TypeTuple::STORECONDITIONAL = TypeTuple::make(2, fsc); 521 522 TypeInstPtr::NOTNULL = TypeInstPtr::make(TypePtr::NotNull, current->env()->Object_klass()); 523 TypeInstPtr::BOTTOM = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass()); 524 TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass()); 525 TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), 526 false, 0, oopDesc::mark_offset_in_bytes()); 527 TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), 528 false, 0, oopDesc::klass_offset_in_bytes()); 529 TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot); 530 531 TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, OffsetBot); 532 533 TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR ); 534 TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM ); 535 536 TypeNarrowKlass::NULL_PTR = TypeNarrowKlass::make( TypePtr::NULL_PTR ); 537 538 mreg2type[Op_Node] = Type::BOTTOM; 539 mreg2type[Op_Set ] = 0; 540 mreg2type[Op_RegN] = TypeNarrowOop::BOTTOM; 541 mreg2type[Op_RegI] = TypeInt::INT; 542 mreg2type[Op_RegP] = TypePtr::BOTTOM; 543 mreg2type[Op_RegF] = Type::FLOAT; 544 mreg2type[Op_RegD] = Type::DOUBLE; 545 mreg2type[Op_RegL] = TypeLong::LONG; 546 mreg2type[Op_RegFlags] = TypeInt::CC; 547 548 TypeAryPtr::RANGE = TypeAryPtr::make( TypePtr::BotPTR, TypeAry::make(Type::BOTTOM,TypeInt::POS), NULL /* current->env()->Object_klass() */, false, arrayOopDesc::length_offset_in_bytes()); 549 550 TypeAryPtr::NARROWOOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeNarrowOop::BOTTOM, TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Type::OffsetBot); 551 552 #ifdef _LP64 553 if (UseCompressedOops) { 554 assert(TypeAryPtr::NARROWOOPS->is_ptr_to_narrowoop(), "array of narrow oops must be ptr to narrow oop"); 555 TypeAryPtr::OOPS = TypeAryPtr::NARROWOOPS; 556 } else 557 #endif 558 { 559 // There is no shared klass for Object[]. See note in TypeAryPtr::klass(). 560 TypeAryPtr::OOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInstPtr::BOTTOM,TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Type::OffsetBot); 561 } 562 TypeAryPtr::BYTES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::BYTE ,TypeInt::POS), ciTypeArrayKlass::make(T_BYTE), true, Type::OffsetBot); 563 TypeAryPtr::SHORTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::SHORT ,TypeInt::POS), ciTypeArrayKlass::make(T_SHORT), true, Type::OffsetBot); 564 TypeAryPtr::CHARS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::CHAR ,TypeInt::POS), ciTypeArrayKlass::make(T_CHAR), true, Type::OffsetBot); 565 TypeAryPtr::INTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::INT ,TypeInt::POS), ciTypeArrayKlass::make(T_INT), true, Type::OffsetBot); 566 TypeAryPtr::LONGS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeLong::LONG ,TypeInt::POS), ciTypeArrayKlass::make(T_LONG), true, Type::OffsetBot); 641 642 // get_zero_type() should not happen for T_CONFLICT 643 _zero_type[T_CONFLICT]= NULL; 644 645 // Vector predefined types, it needs initialized _const_basic_type[]. 646 if (Matcher::vector_size_supported(T_BYTE,4)) { 647 TypeVect::VECTS = TypeVect::make(T_BYTE,4); 648 } 649 if (Matcher::vector_size_supported(T_FLOAT,2)) { 650 TypeVect::VECTD = TypeVect::make(T_FLOAT,2); 651 } 652 if (Matcher::vector_size_supported(T_FLOAT,4)) { 653 TypeVect::VECTX = TypeVect::make(T_FLOAT,4); 654 } 655 if (Matcher::vector_size_supported(T_FLOAT,8)) { 656 TypeVect::VECTY = TypeVect::make(T_FLOAT,8); 657 } 658 if (Matcher::vector_size_supported(T_FLOAT,16)) { 659 TypeVect::VECTZ = TypeVect::make(T_FLOAT,16); 660 } 661 mreg2type[Op_VecS] = TypeVect::VECTS; 662 mreg2type[Op_VecD] = TypeVect::VECTD; 663 mreg2type[Op_VecX] = TypeVect::VECTX; 664 mreg2type[Op_VecY] = TypeVect::VECTY; 665 mreg2type[Op_VecZ] = TypeVect::VECTZ; 666 667 // Restore working type arena. 668 current->set_type_arena(save); 669 current->set_type_dict(NULL); 670 } 671 672 //------------------------------Initialize------------------------------------- 673 void Type::Initialize(Compile* current) { 674 assert(current->type_arena() != NULL, "must have created type arena"); 675 676 if (_shared_type_dict == NULL) { 677 Initialize_shared(current); 678 } 679 680 Arena* type_arena = current->type_arena(); 681 682 // Create the hash-cons'ing dictionary with top-level storage allocation 683 Dict *tdic = new (type_arena) Dict( (CmpKey)Type::cmp,(Hash)Type::uhash, type_arena, 128 ); 684 current->set_type_dict(tdic); 685 2207 return tap->ary()->ary_must_be_exact(); 2208 return false; 2209 } 2210 2211 //==============================TypeVect======================================= 2212 // Convenience common pre-built types. 2213 const TypeVect *TypeVect::VECTS = NULL; // 32-bit vectors 2214 const TypeVect *TypeVect::VECTD = NULL; // 64-bit vectors 2215 const TypeVect *TypeVect::VECTX = NULL; // 128-bit vectors 2216 const TypeVect *TypeVect::VECTY = NULL; // 256-bit vectors 2217 const TypeVect *TypeVect::VECTZ = NULL; // 512-bit vectors 2218 2219 //------------------------------make------------------------------------------- 2220 const TypeVect* TypeVect::make(const Type *elem, uint length) { 2221 BasicType elem_bt = elem->array_element_basic_type(); 2222 assert(is_java_primitive(elem_bt), "only primitive types in vector"); 2223 assert(length > 1 && is_power_of_2(length), "vector length is power of 2"); 2224 assert(Matcher::vector_size_supported(elem_bt, length), "length in range"); 2225 int size = length * type2aelembytes(elem_bt); 2226 switch (Matcher::vector_ideal_reg(size)) { 2227 case Op_VecS: 2228 return (TypeVect*)(new TypeVectS(elem, length))->hashcons(); 2229 case Op_RegL: 2230 case Op_VecD: 2231 case Op_RegD: 2232 return (TypeVect*)(new TypeVectD(elem, length))->hashcons(); 2233 case Op_VecX: 2234 return (TypeVect*)(new TypeVectX(elem, length))->hashcons(); 2235 case Op_VecY: 2236 return (TypeVect*)(new TypeVectY(elem, length))->hashcons(); 2237 case Op_VecZ: 2238 return (TypeVect*)(new TypeVectZ(elem, length))->hashcons(); 2239 } 2240 ShouldNotReachHere(); 2241 return NULL; 2242 } 2243 2244 //------------------------------meet------------------------------------------- 2245 // Compute the MEET of two types. It returns a new Type object. 2246 const Type *TypeVect::xmeet( const Type *t ) const { 2247 // Perform a fast test for common case; meeting the same types together. 2248 if( this == t ) return this; // Meeting same type-rep? 2249 2250 // Current "this->_base" is Vector 2251 switch (t->base()) { // switch on original type 2252 2253 case Bottom: // Ye Olde Default 2254 return t; 2255 2256 default: // All else is a mistake 2257 typerr(t); | 33 #include "memory/oopFactory.hpp" 34 #include "memory/resourceArea.hpp" 35 #include "oops/instanceKlass.hpp" 36 #include "oops/instanceMirrorKlass.hpp" 37 #include "oops/objArrayKlass.hpp" 38 #include "oops/typeArrayKlass.hpp" 39 #include "opto/matcher.hpp" 40 #include "opto/node.hpp" 41 #include "opto/opcodes.hpp" 42 #include "opto/type.hpp" 43 44 // Portions of code courtesy of Clifford Click 45 46 // Optimization - Graph Style 47 48 // Dictionary of types shared among compilations. 49 Dict* Type::_shared_type_dict = NULL; 50 51 // Array which maps compiler types to Basic Types 52 Type::TypeInfo Type::_type_info[Type::lastype] = { 53 { Bad, T_ILLEGAL, "bad", false, Opcodes::NotAMachineReg, relocInfo::none }, // Bad 54 { Control, T_ILLEGAL, "control", false, Opcodes::Op_Node, relocInfo::none }, // Control 55 { Bottom, T_VOID, "top", false, Opcodes::Op_Node, relocInfo::none }, // Top 56 { Bad, T_INT, "int:", false, Opcodes::Op_RegI, relocInfo::none }, // Int 57 { Bad, T_LONG, "long:", false, Opcodes::Op_RegL, relocInfo::none }, // Long 58 { Half, T_VOID, "half", false, Opcodes::Op_Node, relocInfo::none }, // Half 59 { Bad, T_NARROWOOP, "narrowoop:", false, Opcodes::Op_RegN, relocInfo::none }, // NarrowOop 60 { Bad, T_NARROWKLASS,"narrowklass:", false, Opcodes::Op_RegN, relocInfo::none }, // NarrowKlass 61 { Bad, T_ILLEGAL, "tuple:", false, Opcodes::NotAMachineReg, relocInfo::none }, // Tuple 62 { Bad, T_ARRAY, "array:", false, Opcodes::NotAMachineReg, relocInfo::none }, // Array 63 64 #ifdef SPARC 65 { Bad, T_ILLEGAL, "vectors:", false, Opcodes::Op_Node, relocInfo::none }, // VectorS 66 { Bad, T_ILLEGAL, "vectord:", false, Opcodes::Op_RegD, relocInfo::none }, // VectorD 67 { Bad, T_ILLEGAL, "vectorx:", false, Opcodes::Op_Node, relocInfo::none }, // VectorX 68 { Bad, T_ILLEGAL, "vectory:", false, Opcodes::Op_Node, relocInfo::none }, // VectorY 69 { Bad, T_ILLEGAL, "vectorz:", false, Opcodes::Op_Node, relocInfo::none }, // VectorZ 70 #elif defined(PPC64) 71 { Bad, T_ILLEGAL, "vectors:", false, Opcodes::Op_Node, relocInfo::none }, // VectorS 72 { Bad, T_ILLEGAL, "vectord:", false, Opcodes::Op_RegL, relocInfo::none }, // VectorD 73 { Bad, T_ILLEGAL, "vectorx:", false, Opcodes::Op_Node, relocInfo::none }, // VectorX 74 { Bad, T_ILLEGAL, "vectory:", false, Opcodes::Op_Node, relocInfo::none }, // VectorY 75 { Bad, T_ILLEGAL, "vectorz:", false, Opcodes::Op_Node, relocInfo::none }, // VectorZ 76 #else // all other 77 { Bad, T_ILLEGAL, "vectors:", false, Opcodes::Op_VecS, relocInfo::none }, // VectorS 78 { Bad, T_ILLEGAL, "vectord:", false, Opcodes::Op_VecD, relocInfo::none }, // VectorD 79 { Bad, T_ILLEGAL, "vectorx:", false, Opcodes::Op_VecX, relocInfo::none }, // VectorX 80 { Bad, T_ILLEGAL, "vectory:", false, Opcodes::Op_VecY, relocInfo::none }, // VectorY 81 { Bad, T_ILLEGAL, "vectorz:", false, Opcodes::Op_VecZ, relocInfo::none }, // VectorZ 82 #endif 83 { Bad, T_ADDRESS, "anyptr:", false, Opcodes::Op_RegP, relocInfo::none }, // AnyPtr 84 { Bad, T_ADDRESS, "rawptr:", false, Opcodes::Op_RegP, relocInfo::none }, // RawPtr 85 { Bad, T_OBJECT, "oop:", true, Opcodes::Op_RegP, relocInfo::oop_type }, // OopPtr 86 { Bad, T_OBJECT, "inst:", true, Opcodes::Op_RegP, relocInfo::oop_type }, // InstPtr 87 { Bad, T_OBJECT, "ary:", true, Opcodes::Op_RegP, relocInfo::oop_type }, // AryPtr 88 { Bad, T_METADATA, "metadata:", false, Opcodes::Op_RegP, relocInfo::metadata_type }, // MetadataPtr 89 { Bad, T_METADATA, "klass:", false, Opcodes::Op_RegP, relocInfo::metadata_type }, // KlassPtr 90 { Bad, T_OBJECT, "func", false, Opcodes::Op_Node, relocInfo::none }, // Function 91 { Abio, T_ILLEGAL, "abIO", false, Opcodes::Op_Node, relocInfo::none }, // Abio 92 { Return_Address, T_ADDRESS, "return_address",false, Opcodes::Op_RegP, relocInfo::none }, // Return_Address 93 { Memory, T_ILLEGAL, "memory", false, Opcodes::Op_Node, relocInfo::none }, // Memory 94 { FloatBot, T_FLOAT, "float_top", false, Opcodes::Op_RegF, relocInfo::none }, // FloatTop 95 { FloatCon, T_FLOAT, "ftcon:", false, Opcodes::Op_RegF, relocInfo::none }, // FloatCon 96 { FloatTop, T_FLOAT, "float", false, Opcodes::Op_RegF, relocInfo::none }, // FloatBot 97 { DoubleBot, T_DOUBLE, "double_top", false, Opcodes::Op_RegD, relocInfo::none }, // DoubleTop 98 { DoubleCon, T_DOUBLE, "dblcon:", false, Opcodes::Op_RegD, relocInfo::none }, // DoubleCon 99 { DoubleTop, T_DOUBLE, "double", false, Opcodes::Op_RegD, relocInfo::none }, // DoubleBot 100 { Top, T_ILLEGAL, "bottom", false, Opcodes::Op_Node, relocInfo::none } // Bottom 101 }; 102 103 // Map ideal registers (machine types) to ideal types 104 const Type *Type::mreg2type[static_cast<uint>(Opcodes::_last_machine_leaf)]; 105 106 // Map basic types to canonical Type* pointers. 107 const Type* Type:: _const_basic_type[T_CONFLICT+1]; 108 109 // Map basic types to constant-zero Types. 110 const Type* Type:: _zero_type[T_CONFLICT+1]; 111 112 // Map basic types to array-body alias types. 113 const TypeAryPtr* TypeAryPtr::_array_body_type[T_CONFLICT+1]; 114 115 //============================================================================= 116 // Convenience common pre-built types. 117 const Type *Type::ABIO; // State-of-machine only 118 const Type *Type::BOTTOM; // All values 119 const Type *Type::CONTROL; // Control only 120 const Type *Type::DOUBLE; // All doubles 121 const Type *Type::FLOAT; // All floats 122 const Type *Type::HALF; // Placeholder half of doublewide type 123 const Type *Type::MEMORY; // Abstract store only 124 const Type *Type::RETURN_ADDRESS; 518 fsc[0] = TypeInt::CC; 519 fsc[1] = Type::MEMORY; 520 TypeTuple::STORECONDITIONAL = TypeTuple::make(2, fsc); 521 522 TypeInstPtr::NOTNULL = TypeInstPtr::make(TypePtr::NotNull, current->env()->Object_klass()); 523 TypeInstPtr::BOTTOM = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass()); 524 TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass()); 525 TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), 526 false, 0, oopDesc::mark_offset_in_bytes()); 527 TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), 528 false, 0, oopDesc::klass_offset_in_bytes()); 529 TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot); 530 531 TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, OffsetBot); 532 533 TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR ); 534 TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM ); 535 536 TypeNarrowKlass::NULL_PTR = TypeNarrowKlass::make( TypePtr::NULL_PTR ); 537 538 mreg2type[static_cast<uint>(Opcodes::Op_Node)] = Type::BOTTOM; 539 mreg2type[static_cast<uint>(Opcodes::Op_Set) ] = 0; 540 mreg2type[static_cast<uint>(Opcodes::Op_RegN)] = TypeNarrowOop::BOTTOM; 541 mreg2type[static_cast<uint>(Opcodes::Op_RegI)] = TypeInt::INT; 542 mreg2type[static_cast<uint>(Opcodes::Op_RegP)] = TypePtr::BOTTOM; 543 mreg2type[static_cast<uint>(Opcodes::Op_RegF)] = Type::FLOAT; 544 mreg2type[static_cast<uint>(Opcodes::Op_RegD)] = Type::DOUBLE; 545 mreg2type[static_cast<uint>(Opcodes::Op_RegL)] = TypeLong::LONG; 546 mreg2type[static_cast<uint>(Opcodes::Op_RegFlags)] = TypeInt::CC; 547 548 TypeAryPtr::RANGE = TypeAryPtr::make( TypePtr::BotPTR, TypeAry::make(Type::BOTTOM,TypeInt::POS), NULL /* current->env()->Object_klass() */, false, arrayOopDesc::length_offset_in_bytes()); 549 550 TypeAryPtr::NARROWOOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeNarrowOop::BOTTOM, TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Type::OffsetBot); 551 552 #ifdef _LP64 553 if (UseCompressedOops) { 554 assert(TypeAryPtr::NARROWOOPS->is_ptr_to_narrowoop(), "array of narrow oops must be ptr to narrow oop"); 555 TypeAryPtr::OOPS = TypeAryPtr::NARROWOOPS; 556 } else 557 #endif 558 { 559 // There is no shared klass for Object[]. See note in TypeAryPtr::klass(). 560 TypeAryPtr::OOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInstPtr::BOTTOM,TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Type::OffsetBot); 561 } 562 TypeAryPtr::BYTES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::BYTE ,TypeInt::POS), ciTypeArrayKlass::make(T_BYTE), true, Type::OffsetBot); 563 TypeAryPtr::SHORTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::SHORT ,TypeInt::POS), ciTypeArrayKlass::make(T_SHORT), true, Type::OffsetBot); 564 TypeAryPtr::CHARS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::CHAR ,TypeInt::POS), ciTypeArrayKlass::make(T_CHAR), true, Type::OffsetBot); 565 TypeAryPtr::INTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::INT ,TypeInt::POS), ciTypeArrayKlass::make(T_INT), true, Type::OffsetBot); 566 TypeAryPtr::LONGS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeLong::LONG ,TypeInt::POS), ciTypeArrayKlass::make(T_LONG), true, Type::OffsetBot); 641 642 // get_zero_type() should not happen for T_CONFLICT 643 _zero_type[T_CONFLICT]= NULL; 644 645 // Vector predefined types, it needs initialized _const_basic_type[]. 646 if (Matcher::vector_size_supported(T_BYTE,4)) { 647 TypeVect::VECTS = TypeVect::make(T_BYTE,4); 648 } 649 if (Matcher::vector_size_supported(T_FLOAT,2)) { 650 TypeVect::VECTD = TypeVect::make(T_FLOAT,2); 651 } 652 if (Matcher::vector_size_supported(T_FLOAT,4)) { 653 TypeVect::VECTX = TypeVect::make(T_FLOAT,4); 654 } 655 if (Matcher::vector_size_supported(T_FLOAT,8)) { 656 TypeVect::VECTY = TypeVect::make(T_FLOAT,8); 657 } 658 if (Matcher::vector_size_supported(T_FLOAT,16)) { 659 TypeVect::VECTZ = TypeVect::make(T_FLOAT,16); 660 } 661 mreg2type[static_cast<uint>(Opcodes::Op_VecS)] = TypeVect::VECTS; 662 mreg2type[static_cast<uint>(Opcodes::Op_VecD)] = TypeVect::VECTD; 663 mreg2type[static_cast<uint>(Opcodes::Op_VecX)] = TypeVect::VECTX; 664 mreg2type[static_cast<uint>(Opcodes::Op_VecY)] = TypeVect::VECTY; 665 mreg2type[static_cast<uint>(Opcodes::Op_VecZ)] = TypeVect::VECTZ; 666 667 // Restore working type arena. 668 current->set_type_arena(save); 669 current->set_type_dict(NULL); 670 } 671 672 //------------------------------Initialize------------------------------------- 673 void Type::Initialize(Compile* current) { 674 assert(current->type_arena() != NULL, "must have created type arena"); 675 676 if (_shared_type_dict == NULL) { 677 Initialize_shared(current); 678 } 679 680 Arena* type_arena = current->type_arena(); 681 682 // Create the hash-cons'ing dictionary with top-level storage allocation 683 Dict *tdic = new (type_arena) Dict( (CmpKey)Type::cmp,(Hash)Type::uhash, type_arena, 128 ); 684 current->set_type_dict(tdic); 685 2207 return tap->ary()->ary_must_be_exact(); 2208 return false; 2209 } 2210 2211 //==============================TypeVect======================================= 2212 // Convenience common pre-built types. 2213 const TypeVect *TypeVect::VECTS = NULL; // 32-bit vectors 2214 const TypeVect *TypeVect::VECTD = NULL; // 64-bit vectors 2215 const TypeVect *TypeVect::VECTX = NULL; // 128-bit vectors 2216 const TypeVect *TypeVect::VECTY = NULL; // 256-bit vectors 2217 const TypeVect *TypeVect::VECTZ = NULL; // 512-bit vectors 2218 2219 //------------------------------make------------------------------------------- 2220 const TypeVect* TypeVect::make(const Type *elem, uint length) { 2221 BasicType elem_bt = elem->array_element_basic_type(); 2222 assert(is_java_primitive(elem_bt), "only primitive types in vector"); 2223 assert(length > 1 && is_power_of_2(length), "vector length is power of 2"); 2224 assert(Matcher::vector_size_supported(elem_bt, length), "length in range"); 2225 int size = length * type2aelembytes(elem_bt); 2226 switch (Matcher::vector_ideal_reg(size)) { 2227 case Opcodes::Op_VecS: 2228 return (TypeVect*)(new TypeVectS(elem, length))->hashcons(); 2229 case Opcodes::Op_RegL: 2230 case Opcodes::Op_VecD: 2231 case Opcodes::Op_RegD: 2232 return (TypeVect*)(new TypeVectD(elem, length))->hashcons(); 2233 case Opcodes::Op_VecX: 2234 return (TypeVect*)(new TypeVectX(elem, length))->hashcons(); 2235 case Opcodes::Op_VecY: 2236 return (TypeVect*)(new TypeVectY(elem, length))->hashcons(); 2237 case Opcodes::Op_VecZ: 2238 return (TypeVect*)(new TypeVectZ(elem, length))->hashcons(); 2239 } 2240 ShouldNotReachHere(); 2241 return NULL; 2242 } 2243 2244 //------------------------------meet------------------------------------------- 2245 // Compute the MEET of two types. It returns a new Type object. 2246 const Type *TypeVect::xmeet( const Type *t ) const { 2247 // Perform a fast test for common case; meeting the same types together. 2248 if( this == t ) return this; // Meeting same type-rep? 2249 2250 // Current "this->_base" is Vector 2251 switch (t->base()) { // switch on original type 2252 2253 case Bottom: // Ye Olde Default 2254 return t; 2255 2256 default: // All else is a mistake 2257 typerr(t); |