< prev index next >

src/hotspot/share/opto/type.cpp

Print this page




 121   { Bad,             T_ILLEGAL,    "vectory:",      false, 0,                    relocInfo::none          },  // VectorY
 122   { Bad,             T_ILLEGAL,    "vectorz:",      false, 0,                    relocInfo::none          },  // VectorZ
 123 #elif defined(S390)
 124   { Bad,             T_ILLEGAL,    "vectors:",      false, 0,                    relocInfo::none          },  // VectorS
 125   { Bad,             T_ILLEGAL,    "vectord:",      false, Op_RegL,              relocInfo::none          },  // VectorD
 126   { Bad,             T_ILLEGAL,    "vectorx:",      false, 0,                    relocInfo::none          },  // VectorX
 127   { Bad,             T_ILLEGAL,    "vectory:",      false, 0,                    relocInfo::none          },  // VectorY
 128   { Bad,             T_ILLEGAL,    "vectorz:",      false, 0,                    relocInfo::none          },  // VectorZ
 129 #else // all other
 130   { Bad,             T_ILLEGAL,    "vectors:",      false, Op_VecS,              relocInfo::none          },  // VectorS
 131   { Bad,             T_ILLEGAL,    "vectord:",      false, Op_VecD,              relocInfo::none          },  // VectorD
 132   { Bad,             T_ILLEGAL,    "vectorx:",      false, Op_VecX,              relocInfo::none          },  // VectorX
 133   { Bad,             T_ILLEGAL,    "vectory:",      false, Op_VecY,              relocInfo::none          },  // VectorY
 134   { Bad,             T_ILLEGAL,    "vectorz:",      false, Op_VecZ,              relocInfo::none          },  // VectorZ
 135 #endif
 136   { Bad,             T_VALUETYPE,  "value:",        false, Node::NotAMachineReg, relocInfo::none          },  // ValueType
 137   { Bad,             T_ADDRESS,    "anyptr:",       false, Op_RegP,              relocInfo::none          },  // AnyPtr
 138   { Bad,             T_ADDRESS,    "rawptr:",       false, Op_RegP,              relocInfo::none          },  // RawPtr
 139   { Bad,             T_OBJECT,     "oop:",          true,  Op_RegP,              relocInfo::oop_type      },  // OopPtr
 140   { Bad,             T_OBJECT,     "inst:",         true,  Op_RegP,              relocInfo::oop_type      },  // InstPtr
 141   { Bad,             T_VALUETYPEPTR,"valueptr:",     true,  Op_RegP,              relocInfo::oop_type      },  // ValueTypePtr
 142   { Bad,             T_OBJECT,     "ary:",          true,  Op_RegP,              relocInfo::oop_type      },  // AryPtr
 143   { Bad,             T_METADATA,   "metadata:",     false, Op_RegP,              relocInfo::metadata_type },  // MetadataPtr
 144   { Bad,             T_METADATA,   "klass:",        false, Op_RegP,              relocInfo::metadata_type },  // KlassPtr
 145   { Bad,             T_OBJECT,     "func",          false, 0,                    relocInfo::none          },  // Function
 146   { Abio,            T_ILLEGAL,    "abIO",          false, 0,                    relocInfo::none          },  // Abio
 147   { Return_Address,  T_ADDRESS,    "return_address",false, Op_RegP,              relocInfo::none          },  // Return_Address
 148   { Memory,          T_ILLEGAL,    "memory",        false, 0,                    relocInfo::none          },  // Memory
 149   { FloatBot,        T_FLOAT,      "float_top",     false, Op_RegF,              relocInfo::none          },  // FloatTop
 150   { FloatCon,        T_FLOAT,      "ftcon:",        false, Op_RegF,              relocInfo::none          },  // FloatCon
 151   { FloatTop,        T_FLOAT,      "float",         false, Op_RegF,              relocInfo::none          },  // FloatBot
 152   { DoubleBot,       T_DOUBLE,     "double_top",    false, Op_RegD,              relocInfo::none          },  // DoubleTop
 153   { DoubleCon,       T_DOUBLE,     "dblcon:",       false, Op_RegD,              relocInfo::none          },  // DoubleCon
 154   { DoubleTop,       T_DOUBLE,     "double",        false, Op_RegD,              relocInfo::none          },  // DoubleBot
 155   { Top,             T_ILLEGAL,    "bottom",        false, 0,                    relocInfo::none          }   // Bottom
 156 };
 157 
 158 // Map ideal registers (machine types) to ideal types
 159 const Type *Type::mreg2type[_last_machine_leaf];
 160 
 161 // Map basic types to canonical Type* pointers.


 625     TypeAryPtr::OOPS  = TypeAryPtr::NARROWOOPS;
 626   } else
 627 #endif
 628   {
 629     // There is no shared klass for Object[].  See note in TypeAryPtr::klass().
 630     TypeAryPtr::OOPS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInstPtr::BOTTOM,TypeInt::POS), NULL /*ciArrayKlass::make(o)*/,  false,  Offset::bottom);
 631   }
 632   TypeAryPtr::BYTES   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::BYTE      ,TypeInt::POS), ciTypeArrayKlass::make(T_BYTE),   true,  Offset::bottom);
 633   TypeAryPtr::SHORTS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::SHORT     ,TypeInt::POS), ciTypeArrayKlass::make(T_SHORT),  true,  Offset::bottom);
 634   TypeAryPtr::CHARS   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::CHAR      ,TypeInt::POS), ciTypeArrayKlass::make(T_CHAR),   true,  Offset::bottom);
 635   TypeAryPtr::INTS    = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::INT       ,TypeInt::POS), ciTypeArrayKlass::make(T_INT),    true,  Offset::bottom);
 636   TypeAryPtr::LONGS   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeLong::LONG     ,TypeInt::POS), ciTypeArrayKlass::make(T_LONG),   true,  Offset::bottom);
 637   TypeAryPtr::FLOATS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::FLOAT        ,TypeInt::POS), ciTypeArrayKlass::make(T_FLOAT),  true,  Offset::bottom);
 638   TypeAryPtr::DOUBLES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::DOUBLE       ,TypeInt::POS), ciTypeArrayKlass::make(T_DOUBLE), true,  Offset::bottom);
 639 
 640   // Nobody should ask _array_body_type[T_NARROWOOP]. Use NULL as assert.
 641   TypeAryPtr::_array_body_type[T_NARROWOOP] = NULL;
 642   TypeAryPtr::_array_body_type[T_OBJECT]  = TypeAryPtr::OOPS;
 643   TypeAryPtr::_array_body_type[T_VALUETYPE] = TypeAryPtr::OOPS;
 644   TypeAryPtr::_array_body_type[T_ARRAY]   = TypeAryPtr::OOPS; // arrays are stored in oop arrays
 645   TypeAryPtr::_array_body_type[T_VALUETYPEPTR] = NULL;
 646   TypeAryPtr::_array_body_type[T_BYTE]    = TypeAryPtr::BYTES;
 647   TypeAryPtr::_array_body_type[T_BOOLEAN] = TypeAryPtr::BYTES;  // boolean[] is a byte array
 648   TypeAryPtr::_array_body_type[T_SHORT]   = TypeAryPtr::SHORTS;
 649   TypeAryPtr::_array_body_type[T_CHAR]    = TypeAryPtr::CHARS;
 650   TypeAryPtr::_array_body_type[T_INT]     = TypeAryPtr::INTS;
 651   TypeAryPtr::_array_body_type[T_LONG]    = TypeAryPtr::LONGS;
 652   TypeAryPtr::_array_body_type[T_FLOAT]   = TypeAryPtr::FLOATS;
 653   TypeAryPtr::_array_body_type[T_DOUBLE]  = TypeAryPtr::DOUBLES;
 654 
 655   TypeKlassPtr::OBJECT = TypeKlassPtr::make(TypePtr::NotNull, current->env()->Object_klass(), Offset(0) );
 656   TypeKlassPtr::OBJECT_OR_NULL = TypeKlassPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), Offset(0) );
 657   TypeKlassPtr::BOTTOM = EnableValhalla ? TypeKlassPtr::make(TypePtr::BotPTR, NULL, Offset(0)) : TypeKlassPtr::OBJECT_OR_NULL;
 658 
 659   const Type **fi2c = TypeTuple::fields(2);
 660   fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // Method*
 661   fi2c[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // argument pointer
 662   TypeTuple::START_I2C = TypeTuple::make(TypeFunc::Parms+2, fi2c);
 663 
 664   const Type **intpair = TypeTuple::fields(2);
 665   intpair[0] = TypeInt::INT;


 675   intccpair[0] = TypeInt::INT;
 676   intccpair[1] = TypeInt::CC;
 677   TypeTuple::INT_CC_PAIR = TypeTuple::make(2, intccpair);
 678 
 679   const Type **longccpair = TypeTuple::fields(2);
 680   longccpair[0] = TypeLong::LONG;
 681   longccpair[1] = TypeInt::CC;
 682   TypeTuple::LONG_CC_PAIR = TypeTuple::make(2, longccpair);
 683 
 684   _const_basic_type[T_NARROWOOP]   = TypeNarrowOop::BOTTOM;
 685   _const_basic_type[T_NARROWKLASS] = Type::BOTTOM;
 686   _const_basic_type[T_BOOLEAN]     = TypeInt::BOOL;
 687   _const_basic_type[T_CHAR]        = TypeInt::CHAR;
 688   _const_basic_type[T_BYTE]        = TypeInt::BYTE;
 689   _const_basic_type[T_SHORT]       = TypeInt::SHORT;
 690   _const_basic_type[T_INT]         = TypeInt::INT;
 691   _const_basic_type[T_LONG]        = TypeLong::LONG;
 692   _const_basic_type[T_FLOAT]       = Type::FLOAT;
 693   _const_basic_type[T_DOUBLE]      = Type::DOUBLE;
 694   _const_basic_type[T_OBJECT]      = TypeInstPtr::BOTTOM;
 695   _const_basic_type[T_VALUETYPEPTR]= TypeInstPtr::BOTTOM;
 696   _const_basic_type[T_ARRAY]       = TypeInstPtr::BOTTOM; // there is no separate bottom for arrays
 697   _const_basic_type[T_VALUETYPE]   = TypeInstPtr::BOTTOM;
 698   _const_basic_type[T_VOID]        = TypePtr::NULL_PTR;   // reflection represents void this way
 699   _const_basic_type[T_ADDRESS]     = TypeRawPtr::BOTTOM;  // both interpreter return addresses & random raw ptrs
 700   _const_basic_type[T_CONFLICT]    = Type::BOTTOM;        // why not?
 701 
 702   _zero_type[T_NARROWOOP]   = TypeNarrowOop::NULL_PTR;
 703   _zero_type[T_NARROWKLASS] = TypeNarrowKlass::NULL_PTR;
 704   _zero_type[T_BOOLEAN]     = TypeInt::ZERO;     // false == 0
 705   _zero_type[T_CHAR]        = TypeInt::ZERO;     // '\0' == 0
 706   _zero_type[T_BYTE]        = TypeInt::ZERO;     // 0x00 == 0
 707   _zero_type[T_SHORT]       = TypeInt::ZERO;     // 0x0000 == 0
 708   _zero_type[T_INT]         = TypeInt::ZERO;
 709   _zero_type[T_LONG]        = TypeLong::ZERO;
 710   _zero_type[T_FLOAT]       = TypeF::ZERO;
 711   _zero_type[T_DOUBLE]      = TypeD::ZERO;
 712   _zero_type[T_OBJECT]      = TypePtr::NULL_PTR;
 713   _zero_type[T_VALUETYPEPTR]= TypePtr::NULL_PTR;
 714   _zero_type[T_ARRAY]       = TypePtr::NULL_PTR; // null array is null oop
 715   _zero_type[T_VALUETYPE]   = TypePtr::NULL_PTR;
 716   _zero_type[T_ADDRESS]     = TypePtr::NULL_PTR; // raw pointers use the same null
 717   _zero_type[T_VOID]        = Type::TOP;         // the only void value is no value at all
 718 
 719   // get_zero_type() should not happen for T_CONFLICT
 720   _zero_type[T_CONFLICT]= NULL;
 721 
 722   // Vector predefined types, it needs initialized _const_basic_type[].
 723   if (Matcher::vector_size_supported(T_BYTE,4)) {
 724     TypeVect::VECTS = TypeVect::make(T_BYTE,4);
 725   }
 726   if (Matcher::vector_size_supported(T_FLOAT,2)) {
 727     TypeVect::VECTD = TypeVect::make(T_FLOAT,2);
 728   }
 729   if (Matcher::vector_size_supported(T_FLOAT,4)) {
 730     TypeVect::VECTX = TypeVect::make(T_FLOAT,4);
 731   }
 732   if (Matcher::vector_size_supported(T_FLOAT,8)) {
 733     TypeVect::VECTY = TypeVect::make(T_FLOAT,8);


1024   Bottom,       // Top
1025   Bad,          // Int - handled in v-call
1026   Bad,          // Long - handled in v-call
1027   Half,         // Half
1028   Bad,          // NarrowOop - handled in v-call
1029   Bad,          // NarrowKlass - handled in v-call
1030 
1031   Bad,          // Tuple - handled in v-call
1032   Bad,          // Array - handled in v-call
1033   Bad,          // VectorS - handled in v-call
1034   Bad,          // VectorD - handled in v-call
1035   Bad,          // VectorX - handled in v-call
1036   Bad,          // VectorY - handled in v-call
1037   Bad,          // VectorZ - handled in v-call
1038   Bad,          // ValueType - handled in v-call
1039 
1040   Bad,          // AnyPtr - handled in v-call
1041   Bad,          // RawPtr - handled in v-call
1042   Bad,          // OopPtr - handled in v-call
1043   Bad,          // InstPtr - handled in v-call
1044   Bad,          // ValueTypePtr - handled in v-call
1045   Bad,          // AryPtr - handled in v-call
1046 
1047   Bad,          //  MetadataPtr - handled in v-call
1048   Bad,          // KlassPtr - handled in v-call
1049 
1050   Bad,          // Function - handled in v-call
1051   Abio,         // Abio
1052   Return_Address,// Return_Address
1053   Memory,       // Memory
1054   FloatBot,     // FloatTop
1055   FloatCon,     // FloatCon
1056   FloatTop,     // FloatBot
1057   DoubleBot,    // DoubleTop
1058   DoubleCon,    // DoubleCon
1059   DoubleTop,    // DoubleBot
1060   Top           // Bottom
1061 };
1062 
1063 const Type *Type::xdual() const {
1064   // Note: the base() accessor asserts the sanity of _base.


1911 
1912 bool TypeLong::empty(void) const {
1913   return _lo > _hi;
1914 }
1915 
1916 //=============================================================================
1917 // Convenience common pre-built types.
1918 const TypeTuple *TypeTuple::IFBOTH;     // Return both arms of IF as reachable
1919 const TypeTuple *TypeTuple::IFFALSE;
1920 const TypeTuple *TypeTuple::IFTRUE;
1921 const TypeTuple *TypeTuple::IFNEITHER;
1922 const TypeTuple *TypeTuple::LOOPBODY;
1923 const TypeTuple *TypeTuple::MEMBAR;
1924 const TypeTuple *TypeTuple::STORECONDITIONAL;
1925 const TypeTuple *TypeTuple::START_I2C;
1926 const TypeTuple *TypeTuple::INT_PAIR;
1927 const TypeTuple *TypeTuple::LONG_PAIR;
1928 const TypeTuple *TypeTuple::INT_CC_PAIR;
1929 const TypeTuple *TypeTuple::LONG_CC_PAIR;
1930 
1931 static void collect_value_fields(ciValueKlass* vk, const Type** field_array, uint& pos) {
1932   for (int j = 0; j < vk->nof_nonstatic_fields(); j++) {







1933     ciField* field = vk->nonstatic_field_at(j);
1934     BasicType bt = field->type()->basic_type();
1935     const Type* ft = Type::get_const_type(field->type());
1936     field_array[pos++] = ft;
1937     if (bt == T_LONG || bt == T_DOUBLE) {
1938       field_array[pos++] = Type::HALF;
1939     }
1940   }
1941 }
1942 
1943 //------------------------------make-------------------------------------------
1944 // Make a TypeTuple from the range of a method signature
1945 const TypeTuple *TypeTuple::make_range(ciSignature* sig, bool ret_vt_fields) {
1946   ciType* return_type = sig->return_type();
1947   return make_range(return_type, sig->returns_never_null(), ret_vt_fields);
1948 }
1949 
1950 const TypeTuple *TypeTuple::make_range(ciType* return_type, bool never_null, bool ret_vt_fields) {
1951   uint arg_cnt = 0;
1952   if (ret_vt_fields) {


1982   case T_VALUETYPE:
1983     if (ret_vt_fields) {
1984       ciValueKlass* vk = (ciValueKlass*)return_type;
1985       uint pos = TypeFunc::Parms;
1986       field_array[pos] = TypePtr::BOTTOM;
1987       pos++;
1988       collect_value_fields(vk, field_array, pos);
1989     } else {
1990       field_array[TypeFunc::Parms] = get_const_type(return_type)->join_speculative(never_null ? TypePtr::NOTNULL : TypePtr::BOTTOM);
1991     }
1992     break;
1993   case T_VOID:
1994     break;
1995   default:
1996     ShouldNotReachHere();
1997   }
1998   return (TypeTuple*)(new TypeTuple(TypeFunc::Parms + arg_cnt, field_array))->hashcons();
1999 }
2000 
2001 // Make a TypeTuple from the domain of a method signature
2002 const TypeTuple *TypeTuple::make_domain(ciInstanceKlass* recv, ciSignature* sig, bool vt_fields_as_args) {


2003   uint arg_cnt = sig->size();
2004 
2005   int vt_extra = 0;

2006   if (vt_fields_as_args) {
2007     for (int i = 0; i < sig->count(); i++) {
2008       ciType* type = sig->type_at(i);
2009       if (type->basic_type() == T_VALUETYPE) {
2010         assert(type->is_valuetype(), "inconsistent type");
2011         ciValueKlass* vk = (ciValueKlass*)type;
2012         vt_extra += vk->value_arg_slots()-1;
2013       }
2014     }
2015     assert(((int)arg_cnt) + vt_extra >= 0, "negative number of actual arguments?");



2016   }
2017 
2018   uint pos = TypeFunc::Parms;
2019   const Type **field_array;
2020   if (recv != NULL) {
2021     arg_cnt++;
2022     bool vt_fields_for_recv = vt_fields_as_args && recv->is_valuetype();


2023     if (vt_fields_for_recv) {
2024       ciValueKlass* vk = (ciValueKlass*)recv;
2025       vt_extra += vk->value_arg_slots()-1;
2026     }
2027     field_array = fields(arg_cnt + vt_extra);
2028     // Use get_const_type here because it respects UseUniqueSubclasses:
2029     if (vt_fields_for_recv) {
2030       ciValueKlass* vk = (ciValueKlass*)recv;
2031       collect_value_fields(vk, field_array, pos);
2032     } else {
2033       field_array[pos++] = get_const_type(recv)->join_speculative(TypePtr::NOTNULL);
2034     }
2035   } else {
2036     field_array = fields(arg_cnt + vt_extra);
2037   }
2038 
2039   int i = 0;
2040   while (pos < TypeFunc::Parms + arg_cnt + vt_extra) {
2041     ciType* type = sig->type_at(i);
2042 
2043     switch (type->basic_type()) {
2044     case T_LONG:
2045       field_array[pos++] = TypeLong::LONG;
2046       field_array[pos++] = Type::HALF;
2047       break;
2048     case T_DOUBLE:
2049       field_array[pos++] = Type::DOUBLE;
2050       field_array[pos++] = Type::HALF;
2051       break;
2052     case T_OBJECT:
2053     case T_ARRAY:
2054     case T_FLOAT:
2055     case T_INT:
2056       field_array[pos++] = get_const_type(type);
2057       break;
2058     case T_BOOLEAN:
2059     case T_CHAR:
2060     case T_BYTE:
2061     case T_SHORT:
2062       field_array[pos++] = TypeInt::INT;
2063       break;
2064     case T_VALUETYPE: {
2065       assert(type->is_valuetype(), "inconsistent type");
2066       if (vt_fields_as_args) {
2067         ciValueKlass* vk = (ciValueKlass*)type;
2068         collect_value_fields(vk, field_array, pos);
2069       } else {
2070         field_array[pos++] = get_const_type(type)->join_speculative(sig->is_never_null_at(i) ? TypePtr::NOTNULL : TypePtr::BOTTOM);
2071       }
2072       break;
2073     }
2074     default:
2075       ShouldNotReachHere();
2076     }
2077     i++;








2078   }
2079   assert(pos == TypeFunc::Parms + arg_cnt + vt_extra, "wrong number of arguments");
2080 
2081   return (TypeTuple*)(new TypeTuple(TypeFunc::Parms + arg_cnt + vt_extra, field_array))->hashcons();
2082 }
2083 
2084 const TypeTuple *TypeTuple::make( uint cnt, const Type **fields ) {
2085   return (TypeTuple*)(new TypeTuple(cnt,fields))->hashcons();
2086 }
2087 
2088 //------------------------------fields-----------------------------------------
2089 // Subroutine call type with space allocated for argument types
2090 // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
2091 const Type **TypeTuple::fields( uint arg_cnt ) {
2092   const Type **flds = (const Type **)(Compile::current()->type_arena()->Amalloc_4((TypeFunc::Parms+arg_cnt)*sizeof(Type*) ));
2093   flds[TypeFunc::Control  ] = Type::CONTROL;
2094   flds[TypeFunc::I_O      ] = Type::ABIO;
2095   flds[TypeFunc::Memory   ] = Type::MEMORY;
2096   flds[TypeFunc::FramePtr ] = TypeRawPtr::BOTTOM;
2097   flds[TypeFunc::ReturnAdr] = Type::RETURN_ADDRESS;


3194     _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset.get());
3195   }
3196 #ifdef _LP64
3197   if (this->offset() != 0) {
3198     if (this->offset() == oopDesc::klass_offset_in_bytes()) {
3199       _is_ptr_to_narrowklass = UseCompressedClassPointers;
3200     } else if (klass() == NULL) {
3201       // Array with unknown body type
3202       assert(this->isa_aryptr(), "only arrays without klass");
3203       _is_ptr_to_narrowoop = UseCompressedOops;
3204     } else if (UseCompressedOops && this->isa_aryptr() && this->offset() != arrayOopDesc::length_offset_in_bytes()) {
3205       if (klass()->is_obj_array_klass()) {
3206         _is_ptr_to_narrowoop = true;
3207       } else if (klass()->is_value_array_klass() && field_offset != Offset::top && field_offset != Offset::bottom) {
3208         // Check if the field of the value type array element contains oops
3209         ciValueKlass* vk = klass()->as_value_array_klass()->element_klass()->as_value_klass();
3210         int foffset = field_offset.get() + vk->first_field_offset();
3211         ciField* field = vk->get_field_by_offset(foffset, false);
3212         assert(field != NULL, "missing field");
3213         BasicType bt = field->layout_type();
3214         assert(bt != T_VALUETYPEPTR, "unexpected type");
3215         _is_ptr_to_narrowoop = (bt == T_OBJECT || bt == T_ARRAY || T_VALUETYPE);
3216       }
3217     } else if (klass()->is_instance_klass()) {
3218       if (this->isa_klassptr()) {
3219         // Perm objects don't use compressed references
3220       } else if (_offset == Offset::bottom || _offset == Offset::top) {
3221         // unsafe access
3222         _is_ptr_to_narrowoop = UseCompressedOops;
3223       } else { // exclude unsafe ops
3224         assert(this->isa_instptr(), "must be an instance ptr.");
3225         if (klass() == ciEnv::current()->Class_klass() &&
3226             (this->offset() == java_lang_Class::klass_offset_in_bytes() ||
3227              this->offset() == java_lang_Class::array_klass_offset_in_bytes())) {
3228           // Special hidden fields from the Class.
3229           assert(this->isa_instptr(), "must be an instance ptr.");
3230           _is_ptr_to_narrowoop = false;
3231         } else if (klass() == ciEnv::current()->Class_klass() &&
3232                    this->offset() >= InstanceMirrorKlass::offset_of_static_fields()) {
3233           // Static fields
3234           assert(o != NULL, "must be constant");


3237           if (ik->is_valuetype() && this->offset() == ik->as_value_klass()->default_value_offset()) {
3238             // Special hidden field that contains the oop of the default value type
3239             basic_elem_type = T_VALUETYPE;
3240           } else {
3241             ciField* field = ik->get_field_by_offset(this->offset(), true);
3242             assert(field != NULL, "missing field");
3243             basic_elem_type = field->layout_type();
3244           }
3245           _is_ptr_to_narrowoop = UseCompressedOops && (basic_elem_type == T_OBJECT ||
3246                                                        basic_elem_type == T_VALUETYPE ||
3247                                                        basic_elem_type == T_ARRAY);
3248         } else {
3249           // Instance fields which contains a compressed oop references.
3250           ciInstanceKlass* ik = klass()->as_instance_klass();
3251           ciField* field = ik->get_field_by_offset(this->offset(), false);
3252           if (field != NULL) {
3253             BasicType basic_elem_type = field->layout_type();
3254             _is_ptr_to_narrowoop = UseCompressedOops && (basic_elem_type == T_OBJECT ||
3255                                                          basic_elem_type == T_VALUETYPE ||
3256                                                          basic_elem_type == T_ARRAY);
3257             assert(basic_elem_type != T_VALUETYPEPTR, "unexpected type");
3258           } else if (klass()->equals(ciEnv::current()->Object_klass())) {
3259             // Compile::find_alias_type() cast exactness on all types to verify
3260             // that it does not affect alias type.
3261             _is_ptr_to_narrowoop = UseCompressedOops;
3262           } else {
3263             // Type for the copy start in LibraryCallKit::inline_native_clone().
3264             _is_ptr_to_narrowoop = UseCompressedOops;
3265           }
3266         }
3267       }
3268     }
3269   }
3270 #endif
3271 }
3272 
3273 //------------------------------make-------------------------------------------
3274 const TypeOopPtr *TypeOopPtr::make(PTR ptr, Offset offset, int instance_id,
3275                                    const TypePtr* speculative, int inline_depth) {
3276   assert(ptr != Constant, "no constant generic pointers");
3277   ciKlass*  k = Compile::current()->env()->Object_klass();


5590   return (TypeFunc*)(new TypeFunc(domain_sig, domain_cc, range_sig, range_cc))->hashcons();
5591 }
5592 
5593 const TypeFunc *TypeFunc::make(const TypeTuple *domain, const TypeTuple *range) {
5594   return make(domain, domain, range, range);
5595 }
5596 
5597 //------------------------------make-------------------------------------------
5598 const TypeFunc *TypeFunc::make(ciMethod* method) {
5599   Compile* C = Compile::current();
5600   const TypeFunc* tf = C->last_tf(method); // check cache
5601   if (tf != NULL)  return tf;  // The hit rate here is almost 50%.
5602   const TypeTuple *domain_sig, *domain_cc;
5603   // Value type arguments are not passed by reference, instead each
5604   // field of the value type is passed as an argument. We maintain 2
5605   // views of the argument list here: one based on the signature (with
5606   // a value type argument as a single slot), one based on the actual
5607   // calling convention (with a value type argument as a list of its
5608   // fields).
5609   if (method->is_static()) {
5610     domain_sig = TypeTuple::make_domain(NULL, method->signature(), false);
5611     domain_cc = TypeTuple::make_domain(NULL, method->signature(), ValueTypePassFieldsAsArgs);
5612   } else {
5613     domain_sig = TypeTuple::make_domain(method->holder(), method->signature(), false);
5614     domain_cc = TypeTuple::make_domain(method->holder(), method->signature(), ValueTypePassFieldsAsArgs);
5615   }
5616   const TypeTuple *range_sig = TypeTuple::make_range(method->signature(), false);
5617   const TypeTuple *range_cc = TypeTuple::make_range(method->signature(), ValueTypeReturnedAsFields);
5618   tf = TypeFunc::make(domain_sig, domain_cc, range_sig, range_cc);
5619   C->set_last_tf(method, tf);  // fill cache
5620   return tf;
5621 }
5622 
5623 //------------------------------meet-------------------------------------------
5624 // Compute the MEET of two types.  It returns a new Type object.
5625 const Type *TypeFunc::xmeet( const Type *t ) const {
5626   // Perform a fast test for common case; meeting the same types together.
5627   if( this == t ) return this;  // Meeting same type-rep?
5628 
5629   // Current "this->_base" is Func
5630   switch (t->base()) {          // switch on original type
5631 
5632   case Bottom:                  // Ye Olde Default
5633     return t;
5634 




 121   { Bad,             T_ILLEGAL,    "vectory:",      false, 0,                    relocInfo::none          },  // VectorY
 122   { Bad,             T_ILLEGAL,    "vectorz:",      false, 0,                    relocInfo::none          },  // VectorZ
 123 #elif defined(S390)
 124   { Bad,             T_ILLEGAL,    "vectors:",      false, 0,                    relocInfo::none          },  // VectorS
 125   { Bad,             T_ILLEGAL,    "vectord:",      false, Op_RegL,              relocInfo::none          },  // VectorD
 126   { Bad,             T_ILLEGAL,    "vectorx:",      false, 0,                    relocInfo::none          },  // VectorX
 127   { Bad,             T_ILLEGAL,    "vectory:",      false, 0,                    relocInfo::none          },  // VectorY
 128   { Bad,             T_ILLEGAL,    "vectorz:",      false, 0,                    relocInfo::none          },  // VectorZ
 129 #else // all other
 130   { Bad,             T_ILLEGAL,    "vectors:",      false, Op_VecS,              relocInfo::none          },  // VectorS
 131   { Bad,             T_ILLEGAL,    "vectord:",      false, Op_VecD,              relocInfo::none          },  // VectorD
 132   { Bad,             T_ILLEGAL,    "vectorx:",      false, Op_VecX,              relocInfo::none          },  // VectorX
 133   { Bad,             T_ILLEGAL,    "vectory:",      false, Op_VecY,              relocInfo::none          },  // VectorY
 134   { Bad,             T_ILLEGAL,    "vectorz:",      false, Op_VecZ,              relocInfo::none          },  // VectorZ
 135 #endif
 136   { Bad,             T_VALUETYPE,  "value:",        false, Node::NotAMachineReg, relocInfo::none          },  // ValueType
 137   { Bad,             T_ADDRESS,    "anyptr:",       false, Op_RegP,              relocInfo::none          },  // AnyPtr
 138   { Bad,             T_ADDRESS,    "rawptr:",       false, Op_RegP,              relocInfo::none          },  // RawPtr
 139   { Bad,             T_OBJECT,     "oop:",          true,  Op_RegP,              relocInfo::oop_type      },  // OopPtr
 140   { Bad,             T_OBJECT,     "inst:",         true,  Op_RegP,              relocInfo::oop_type      },  // InstPtr

 141   { Bad,             T_OBJECT,     "ary:",          true,  Op_RegP,              relocInfo::oop_type      },  // AryPtr
 142   { Bad,             T_METADATA,   "metadata:",     false, Op_RegP,              relocInfo::metadata_type },  // MetadataPtr
 143   { Bad,             T_METADATA,   "klass:",        false, Op_RegP,              relocInfo::metadata_type },  // KlassPtr
 144   { Bad,             T_OBJECT,     "func",          false, 0,                    relocInfo::none          },  // Function
 145   { Abio,            T_ILLEGAL,    "abIO",          false, 0,                    relocInfo::none          },  // Abio
 146   { Return_Address,  T_ADDRESS,    "return_address",false, Op_RegP,              relocInfo::none          },  // Return_Address
 147   { Memory,          T_ILLEGAL,    "memory",        false, 0,                    relocInfo::none          },  // Memory
 148   { FloatBot,        T_FLOAT,      "float_top",     false, Op_RegF,              relocInfo::none          },  // FloatTop
 149   { FloatCon,        T_FLOAT,      "ftcon:",        false, Op_RegF,              relocInfo::none          },  // FloatCon
 150   { FloatTop,        T_FLOAT,      "float",         false, Op_RegF,              relocInfo::none          },  // FloatBot
 151   { DoubleBot,       T_DOUBLE,     "double_top",    false, Op_RegD,              relocInfo::none          },  // DoubleTop
 152   { DoubleCon,       T_DOUBLE,     "dblcon:",       false, Op_RegD,              relocInfo::none          },  // DoubleCon
 153   { DoubleTop,       T_DOUBLE,     "double",        false, Op_RegD,              relocInfo::none          },  // DoubleBot
 154   { Top,             T_ILLEGAL,    "bottom",        false, 0,                    relocInfo::none          }   // Bottom
 155 };
 156 
 157 // Map ideal registers (machine types) to ideal types
 158 const Type *Type::mreg2type[_last_machine_leaf];
 159 
 160 // Map basic types to canonical Type* pointers.


 624     TypeAryPtr::OOPS  = TypeAryPtr::NARROWOOPS;
 625   } else
 626 #endif
 627   {
 628     // There is no shared klass for Object[].  See note in TypeAryPtr::klass().
 629     TypeAryPtr::OOPS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInstPtr::BOTTOM,TypeInt::POS), NULL /*ciArrayKlass::make(o)*/,  false,  Offset::bottom);
 630   }
 631   TypeAryPtr::BYTES   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::BYTE      ,TypeInt::POS), ciTypeArrayKlass::make(T_BYTE),   true,  Offset::bottom);
 632   TypeAryPtr::SHORTS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::SHORT     ,TypeInt::POS), ciTypeArrayKlass::make(T_SHORT),  true,  Offset::bottom);
 633   TypeAryPtr::CHARS   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::CHAR      ,TypeInt::POS), ciTypeArrayKlass::make(T_CHAR),   true,  Offset::bottom);
 634   TypeAryPtr::INTS    = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::INT       ,TypeInt::POS), ciTypeArrayKlass::make(T_INT),    true,  Offset::bottom);
 635   TypeAryPtr::LONGS   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeLong::LONG     ,TypeInt::POS), ciTypeArrayKlass::make(T_LONG),   true,  Offset::bottom);
 636   TypeAryPtr::FLOATS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::FLOAT        ,TypeInt::POS), ciTypeArrayKlass::make(T_FLOAT),  true,  Offset::bottom);
 637   TypeAryPtr::DOUBLES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::DOUBLE       ,TypeInt::POS), ciTypeArrayKlass::make(T_DOUBLE), true,  Offset::bottom);
 638 
 639   // Nobody should ask _array_body_type[T_NARROWOOP]. Use NULL as assert.
 640   TypeAryPtr::_array_body_type[T_NARROWOOP] = NULL;
 641   TypeAryPtr::_array_body_type[T_OBJECT]  = TypeAryPtr::OOPS;
 642   TypeAryPtr::_array_body_type[T_VALUETYPE] = TypeAryPtr::OOPS;
 643   TypeAryPtr::_array_body_type[T_ARRAY]   = TypeAryPtr::OOPS; // arrays are stored in oop arrays

 644   TypeAryPtr::_array_body_type[T_BYTE]    = TypeAryPtr::BYTES;
 645   TypeAryPtr::_array_body_type[T_BOOLEAN] = TypeAryPtr::BYTES;  // boolean[] is a byte array
 646   TypeAryPtr::_array_body_type[T_SHORT]   = TypeAryPtr::SHORTS;
 647   TypeAryPtr::_array_body_type[T_CHAR]    = TypeAryPtr::CHARS;
 648   TypeAryPtr::_array_body_type[T_INT]     = TypeAryPtr::INTS;
 649   TypeAryPtr::_array_body_type[T_LONG]    = TypeAryPtr::LONGS;
 650   TypeAryPtr::_array_body_type[T_FLOAT]   = TypeAryPtr::FLOATS;
 651   TypeAryPtr::_array_body_type[T_DOUBLE]  = TypeAryPtr::DOUBLES;
 652 
 653   TypeKlassPtr::OBJECT = TypeKlassPtr::make(TypePtr::NotNull, current->env()->Object_klass(), Offset(0) );
 654   TypeKlassPtr::OBJECT_OR_NULL = TypeKlassPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), Offset(0) );
 655   TypeKlassPtr::BOTTOM = EnableValhalla ? TypeKlassPtr::make(TypePtr::BotPTR, NULL, Offset(0)) : TypeKlassPtr::OBJECT_OR_NULL;
 656 
 657   const Type **fi2c = TypeTuple::fields(2);
 658   fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // Method*
 659   fi2c[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // argument pointer
 660   TypeTuple::START_I2C = TypeTuple::make(TypeFunc::Parms+2, fi2c);
 661 
 662   const Type **intpair = TypeTuple::fields(2);
 663   intpair[0] = TypeInt::INT;


 673   intccpair[0] = TypeInt::INT;
 674   intccpair[1] = TypeInt::CC;
 675   TypeTuple::INT_CC_PAIR = TypeTuple::make(2, intccpair);
 676 
 677   const Type **longccpair = TypeTuple::fields(2);
 678   longccpair[0] = TypeLong::LONG;
 679   longccpair[1] = TypeInt::CC;
 680   TypeTuple::LONG_CC_PAIR = TypeTuple::make(2, longccpair);
 681 
 682   _const_basic_type[T_NARROWOOP]   = TypeNarrowOop::BOTTOM;
 683   _const_basic_type[T_NARROWKLASS] = Type::BOTTOM;
 684   _const_basic_type[T_BOOLEAN]     = TypeInt::BOOL;
 685   _const_basic_type[T_CHAR]        = TypeInt::CHAR;
 686   _const_basic_type[T_BYTE]        = TypeInt::BYTE;
 687   _const_basic_type[T_SHORT]       = TypeInt::SHORT;
 688   _const_basic_type[T_INT]         = TypeInt::INT;
 689   _const_basic_type[T_LONG]        = TypeLong::LONG;
 690   _const_basic_type[T_FLOAT]       = Type::FLOAT;
 691   _const_basic_type[T_DOUBLE]      = Type::DOUBLE;
 692   _const_basic_type[T_OBJECT]      = TypeInstPtr::BOTTOM;

 693   _const_basic_type[T_ARRAY]       = TypeInstPtr::BOTTOM; // there is no separate bottom for arrays
 694   _const_basic_type[T_VALUETYPE]   = TypeInstPtr::BOTTOM;
 695   _const_basic_type[T_VOID]        = TypePtr::NULL_PTR;   // reflection represents void this way
 696   _const_basic_type[T_ADDRESS]     = TypeRawPtr::BOTTOM;  // both interpreter return addresses & random raw ptrs
 697   _const_basic_type[T_CONFLICT]    = Type::BOTTOM;        // why not?
 698 
 699   _zero_type[T_NARROWOOP]   = TypeNarrowOop::NULL_PTR;
 700   _zero_type[T_NARROWKLASS] = TypeNarrowKlass::NULL_PTR;
 701   _zero_type[T_BOOLEAN]     = TypeInt::ZERO;     // false == 0
 702   _zero_type[T_CHAR]        = TypeInt::ZERO;     // '\0' == 0
 703   _zero_type[T_BYTE]        = TypeInt::ZERO;     // 0x00 == 0
 704   _zero_type[T_SHORT]       = TypeInt::ZERO;     // 0x0000 == 0
 705   _zero_type[T_INT]         = TypeInt::ZERO;
 706   _zero_type[T_LONG]        = TypeLong::ZERO;
 707   _zero_type[T_FLOAT]       = TypeF::ZERO;
 708   _zero_type[T_DOUBLE]      = TypeD::ZERO;
 709   _zero_type[T_OBJECT]      = TypePtr::NULL_PTR;

 710   _zero_type[T_ARRAY]       = TypePtr::NULL_PTR; // null array is null oop
 711   _zero_type[T_VALUETYPE]   = TypePtr::NULL_PTR;
 712   _zero_type[T_ADDRESS]     = TypePtr::NULL_PTR; // raw pointers use the same null
 713   _zero_type[T_VOID]        = Type::TOP;         // the only void value is no value at all
 714 
 715   // get_zero_type() should not happen for T_CONFLICT
 716   _zero_type[T_CONFLICT]= NULL;
 717 
 718   // Vector predefined types, it needs initialized _const_basic_type[].
 719   if (Matcher::vector_size_supported(T_BYTE,4)) {
 720     TypeVect::VECTS = TypeVect::make(T_BYTE,4);
 721   }
 722   if (Matcher::vector_size_supported(T_FLOAT,2)) {
 723     TypeVect::VECTD = TypeVect::make(T_FLOAT,2);
 724   }
 725   if (Matcher::vector_size_supported(T_FLOAT,4)) {
 726     TypeVect::VECTX = TypeVect::make(T_FLOAT,4);
 727   }
 728   if (Matcher::vector_size_supported(T_FLOAT,8)) {
 729     TypeVect::VECTY = TypeVect::make(T_FLOAT,8);


1020   Bottom,       // Top
1021   Bad,          // Int - handled in v-call
1022   Bad,          // Long - handled in v-call
1023   Half,         // Half
1024   Bad,          // NarrowOop - handled in v-call
1025   Bad,          // NarrowKlass - handled in v-call
1026 
1027   Bad,          // Tuple - handled in v-call
1028   Bad,          // Array - handled in v-call
1029   Bad,          // VectorS - handled in v-call
1030   Bad,          // VectorD - handled in v-call
1031   Bad,          // VectorX - handled in v-call
1032   Bad,          // VectorY - handled in v-call
1033   Bad,          // VectorZ - handled in v-call
1034   Bad,          // ValueType - handled in v-call
1035 
1036   Bad,          // AnyPtr - handled in v-call
1037   Bad,          // RawPtr - handled in v-call
1038   Bad,          // OopPtr - handled in v-call
1039   Bad,          // InstPtr - handled in v-call

1040   Bad,          // AryPtr - handled in v-call
1041 
1042   Bad,          //  MetadataPtr - handled in v-call
1043   Bad,          // KlassPtr - handled in v-call
1044 
1045   Bad,          // Function - handled in v-call
1046   Abio,         // Abio
1047   Return_Address,// Return_Address
1048   Memory,       // Memory
1049   FloatBot,     // FloatTop
1050   FloatCon,     // FloatCon
1051   FloatTop,     // FloatBot
1052   DoubleBot,    // DoubleTop
1053   DoubleCon,    // DoubleCon
1054   DoubleTop,    // DoubleBot
1055   Top           // Bottom
1056 };
1057 
1058 const Type *Type::xdual() const {
1059   // Note: the base() accessor asserts the sanity of _base.


1906 
1907 bool TypeLong::empty(void) const {
1908   return _lo > _hi;
1909 }
1910 
1911 //=============================================================================
1912 // Convenience common pre-built types.
1913 const TypeTuple *TypeTuple::IFBOTH;     // Return both arms of IF as reachable
1914 const TypeTuple *TypeTuple::IFFALSE;
1915 const TypeTuple *TypeTuple::IFTRUE;
1916 const TypeTuple *TypeTuple::IFNEITHER;
1917 const TypeTuple *TypeTuple::LOOPBODY;
1918 const TypeTuple *TypeTuple::MEMBAR;
1919 const TypeTuple *TypeTuple::STORECONDITIONAL;
1920 const TypeTuple *TypeTuple::START_I2C;
1921 const TypeTuple *TypeTuple::INT_PAIR;
1922 const TypeTuple *TypeTuple::LONG_PAIR;
1923 const TypeTuple *TypeTuple::INT_CC_PAIR;
1924 const TypeTuple *TypeTuple::LONG_CC_PAIR;
1925 
1926 static void collect_value_fields(ciValueKlass* vk, const Type** field_array, uint& pos, SigEntry* res_entry = NULL) {
1927   for (int j = 0; j < vk->nof_nonstatic_fields(); j++) {
1928     if (res_entry != NULL && (int)pos == (res_entry->_offset + TypeFunc::Parms)) {
1929       // Add reserved entry
1930       field_array[pos++] = Type::get_const_basic_type(res_entry->_bt);
1931       if (res_entry->_bt == T_LONG || res_entry->_bt == T_DOUBLE) {
1932         field_array[pos++] = Type::HALF;
1933       }
1934     }
1935     ciField* field = vk->nonstatic_field_at(j);
1936     BasicType bt = field->type()->basic_type();
1937     const Type* ft = Type::get_const_type(field->type());
1938     field_array[pos++] = ft;
1939     if (bt == T_LONG || bt == T_DOUBLE) {
1940       field_array[pos++] = Type::HALF;
1941     }
1942   }
1943 }
1944 
1945 //------------------------------make-------------------------------------------
1946 // Make a TypeTuple from the range of a method signature
1947 const TypeTuple *TypeTuple::make_range(ciSignature* sig, bool ret_vt_fields) {
1948   ciType* return_type = sig->return_type();
1949   return make_range(return_type, sig->returns_never_null(), ret_vt_fields);
1950 }
1951 
1952 const TypeTuple *TypeTuple::make_range(ciType* return_type, bool never_null, bool ret_vt_fields) {
1953   uint arg_cnt = 0;
1954   if (ret_vt_fields) {


1984   case T_VALUETYPE:
1985     if (ret_vt_fields) {
1986       ciValueKlass* vk = (ciValueKlass*)return_type;
1987       uint pos = TypeFunc::Parms;
1988       field_array[pos] = TypePtr::BOTTOM;
1989       pos++;
1990       collect_value_fields(vk, field_array, pos);
1991     } else {
1992       field_array[TypeFunc::Parms] = get_const_type(return_type)->join_speculative(never_null ? TypePtr::NOTNULL : TypePtr::BOTTOM);
1993     }
1994     break;
1995   case T_VOID:
1996     break;
1997   default:
1998     ShouldNotReachHere();
1999   }
2000   return (TypeTuple*)(new TypeTuple(TypeFunc::Parms + arg_cnt, field_array))->hashcons();
2001 }
2002 
2003 // Make a TypeTuple from the domain of a method signature
2004 const TypeTuple *TypeTuple::make_domain(ciMethod* method, bool vt_fields_as_args) {
2005   ciInstanceKlass* recv = method->is_static() ? NULL : method->holder();
2006   ciSignature* sig = method->signature();
2007   uint arg_cnt = sig->size();
2008 
2009   int vt_extra = 0;
2010   SigEntry res_entry = method->get_Method()->get_res_entry();
2011   if (vt_fields_as_args) {
2012     for (int i = 0; i < sig->count(); i++) {
2013       ciType* type = sig->type_at(i);
2014       if (type->is_valuetype()) {
2015         vt_extra += type->as_value_klass()->value_arg_slots()-1;


2016       }
2017     }
2018     if (res_entry._offset != -1) {
2019       // Account for the reserved stack slot
2020       vt_extra += type2size[res_entry._bt];
2021     }
2022   }
2023 
2024   uint pos = TypeFunc::Parms;
2025   const Type **field_array;
2026   if (recv != NULL) {
2027     arg_cnt++;
2028     // TODO for now, don't scalarize value type receivers because of interface calls
2029     //bool vt_fields_for_recv = vt_fields_as_args && recv->is_valuetype();
2030     bool vt_fields_for_recv = false;
2031     if (vt_fields_for_recv) {
2032       vt_extra += recv->as_value_klass()->value_arg_slots()-1;

2033     }
2034     field_array = fields(arg_cnt + vt_extra);
2035     // Use get_const_type here because it respects UseUniqueSubclasses:
2036     if (vt_fields_for_recv) {
2037       collect_value_fields(recv->as_value_klass(), field_array, pos, &res_entry);

2038     } else {
2039       field_array[pos++] = get_const_type(recv)->join_speculative(TypePtr::NOTNULL);
2040     }
2041   } else {
2042     field_array = fields(arg_cnt + vt_extra);
2043   }
2044 
2045   int i = 0;
2046   while (pos < TypeFunc::Parms + arg_cnt + vt_extra) {
2047     ciType* type = sig->type_at(i);
2048 
2049     switch (type->basic_type()) {
2050     case T_LONG:
2051       field_array[pos++] = TypeLong::LONG;
2052       field_array[pos++] = Type::HALF;
2053       break;
2054     case T_DOUBLE:
2055       field_array[pos++] = Type::DOUBLE;
2056       field_array[pos++] = Type::HALF;
2057       break;
2058     case T_OBJECT:
2059     case T_ARRAY:
2060     case T_FLOAT:
2061     case T_INT:
2062       field_array[pos++] = get_const_type(type);
2063       break;
2064     case T_BOOLEAN:
2065     case T_CHAR:
2066     case T_BYTE:
2067     case T_SHORT:
2068       field_array[pos++] = TypeInt::INT;
2069       break;
2070     case T_VALUETYPE: {

2071       if (vt_fields_as_args) {
2072         collect_value_fields(type->as_value_klass(), field_array, pos, &res_entry);

2073       } else {
2074         field_array[pos++] = get_const_type(type)->join_speculative(sig->is_never_null_at(i) ? TypePtr::NOTNULL : TypePtr::BOTTOM);
2075       }
2076       break;
2077     }
2078     default:
2079       ShouldNotReachHere();
2080     }
2081     i++;
2082 
2083     if (vt_fields_as_args && (int)pos == (res_entry._offset + TypeFunc::Parms)) {
2084       // Add reserved entry
2085       field_array[pos++] = Type::get_const_basic_type(res_entry._bt);
2086       if (res_entry._bt == T_LONG || res_entry._bt == T_DOUBLE) {
2087         field_array[pos++] = Type::HALF;
2088       }
2089     }
2090   }
2091   assert(pos == TypeFunc::Parms + arg_cnt + vt_extra, "wrong number of arguments");
2092 
2093   return (TypeTuple*)(new TypeTuple(TypeFunc::Parms + arg_cnt + vt_extra, field_array))->hashcons();
2094 }
2095 
2096 const TypeTuple *TypeTuple::make( uint cnt, const Type **fields ) {
2097   return (TypeTuple*)(new TypeTuple(cnt,fields))->hashcons();
2098 }
2099 
2100 //------------------------------fields-----------------------------------------
2101 // Subroutine call type with space allocated for argument types
2102 // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
2103 const Type **TypeTuple::fields( uint arg_cnt ) {
2104   const Type **flds = (const Type **)(Compile::current()->type_arena()->Amalloc_4((TypeFunc::Parms+arg_cnt)*sizeof(Type*) ));
2105   flds[TypeFunc::Control  ] = Type::CONTROL;
2106   flds[TypeFunc::I_O      ] = Type::ABIO;
2107   flds[TypeFunc::Memory   ] = Type::MEMORY;
2108   flds[TypeFunc::FramePtr ] = TypeRawPtr::BOTTOM;
2109   flds[TypeFunc::ReturnAdr] = Type::RETURN_ADDRESS;


3206     _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset.get());
3207   }
3208 #ifdef _LP64
3209   if (this->offset() != 0) {
3210     if (this->offset() == oopDesc::klass_offset_in_bytes()) {
3211       _is_ptr_to_narrowklass = UseCompressedClassPointers;
3212     } else if (klass() == NULL) {
3213       // Array with unknown body type
3214       assert(this->isa_aryptr(), "only arrays without klass");
3215       _is_ptr_to_narrowoop = UseCompressedOops;
3216     } else if (UseCompressedOops && this->isa_aryptr() && this->offset() != arrayOopDesc::length_offset_in_bytes()) {
3217       if (klass()->is_obj_array_klass()) {
3218         _is_ptr_to_narrowoop = true;
3219       } else if (klass()->is_value_array_klass() && field_offset != Offset::top && field_offset != Offset::bottom) {
3220         // Check if the field of the value type array element contains oops
3221         ciValueKlass* vk = klass()->as_value_array_klass()->element_klass()->as_value_klass();
3222         int foffset = field_offset.get() + vk->first_field_offset();
3223         ciField* field = vk->get_field_by_offset(foffset, false);
3224         assert(field != NULL, "missing field");
3225         BasicType bt = field->layout_type();

3226         _is_ptr_to_narrowoop = (bt == T_OBJECT || bt == T_ARRAY || T_VALUETYPE);
3227       }
3228     } else if (klass()->is_instance_klass()) {
3229       if (this->isa_klassptr()) {
3230         // Perm objects don't use compressed references
3231       } else if (_offset == Offset::bottom || _offset == Offset::top) {
3232         // unsafe access
3233         _is_ptr_to_narrowoop = UseCompressedOops;
3234       } else { // exclude unsafe ops
3235         assert(this->isa_instptr(), "must be an instance ptr.");
3236         if (klass() == ciEnv::current()->Class_klass() &&
3237             (this->offset() == java_lang_Class::klass_offset_in_bytes() ||
3238              this->offset() == java_lang_Class::array_klass_offset_in_bytes())) {
3239           // Special hidden fields from the Class.
3240           assert(this->isa_instptr(), "must be an instance ptr.");
3241           _is_ptr_to_narrowoop = false;
3242         } else if (klass() == ciEnv::current()->Class_klass() &&
3243                    this->offset() >= InstanceMirrorKlass::offset_of_static_fields()) {
3244           // Static fields
3245           assert(o != NULL, "must be constant");


3248           if (ik->is_valuetype() && this->offset() == ik->as_value_klass()->default_value_offset()) {
3249             // Special hidden field that contains the oop of the default value type
3250             basic_elem_type = T_VALUETYPE;
3251           } else {
3252             ciField* field = ik->get_field_by_offset(this->offset(), true);
3253             assert(field != NULL, "missing field");
3254             basic_elem_type = field->layout_type();
3255           }
3256           _is_ptr_to_narrowoop = UseCompressedOops && (basic_elem_type == T_OBJECT ||
3257                                                        basic_elem_type == T_VALUETYPE ||
3258                                                        basic_elem_type == T_ARRAY);
3259         } else {
3260           // Instance fields which contains a compressed oop references.
3261           ciInstanceKlass* ik = klass()->as_instance_klass();
3262           ciField* field = ik->get_field_by_offset(this->offset(), false);
3263           if (field != NULL) {
3264             BasicType basic_elem_type = field->layout_type();
3265             _is_ptr_to_narrowoop = UseCompressedOops && (basic_elem_type == T_OBJECT ||
3266                                                          basic_elem_type == T_VALUETYPE ||
3267                                                          basic_elem_type == T_ARRAY);

3268           } else if (klass()->equals(ciEnv::current()->Object_klass())) {
3269             // Compile::find_alias_type() cast exactness on all types to verify
3270             // that it does not affect alias type.
3271             _is_ptr_to_narrowoop = UseCompressedOops;
3272           } else {
3273             // Type for the copy start in LibraryCallKit::inline_native_clone().
3274             _is_ptr_to_narrowoop = UseCompressedOops;
3275           }
3276         }
3277       }
3278     }
3279   }
3280 #endif
3281 }
3282 
3283 //------------------------------make-------------------------------------------
3284 const TypeOopPtr *TypeOopPtr::make(PTR ptr, Offset offset, int instance_id,
3285                                    const TypePtr* speculative, int inline_depth) {
3286   assert(ptr != Constant, "no constant generic pointers");
3287   ciKlass*  k = Compile::current()->env()->Object_klass();


5600   return (TypeFunc*)(new TypeFunc(domain_sig, domain_cc, range_sig, range_cc))->hashcons();
5601 }
5602 
5603 const TypeFunc *TypeFunc::make(const TypeTuple *domain, const TypeTuple *range) {
5604   return make(domain, domain, range, range);
5605 }
5606 
5607 //------------------------------make-------------------------------------------
5608 const TypeFunc *TypeFunc::make(ciMethod* method) {
5609   Compile* C = Compile::current();
5610   const TypeFunc* tf = C->last_tf(method); // check cache
5611   if (tf != NULL)  return tf;  // The hit rate here is almost 50%.
5612   const TypeTuple *domain_sig, *domain_cc;
5613   // Value type arguments are not passed by reference, instead each
5614   // field of the value type is passed as an argument. We maintain 2
5615   // views of the argument list here: one based on the signature (with
5616   // a value type argument as a single slot), one based on the actual
5617   // calling convention (with a value type argument as a list of its
5618   // fields).
5619   if (method->is_static()) {
5620     domain_sig = TypeTuple::make_domain(method, false);
5621     domain_cc = TypeTuple::make_domain(method, method->get_Method()->has_scalarized_args());
5622   } else {
5623     domain_sig = TypeTuple::make_domain(method, false);
5624     domain_cc = TypeTuple::make_domain(method, method->get_Method()->has_scalarized_args());
5625   }
5626   const TypeTuple *range_sig = TypeTuple::make_range(method->signature(), false);
5627   const TypeTuple *range_cc = TypeTuple::make_range(method->signature(), ValueTypeReturnedAsFields);
5628   tf = TypeFunc::make(domain_sig, domain_cc, range_sig, range_cc);
5629   C->set_last_tf(method, tf);  // fill cache
5630   return tf;
5631 }
5632 
5633 //------------------------------meet-------------------------------------------
5634 // Compute the MEET of two types.  It returns a new Type object.
5635 const Type *TypeFunc::xmeet( const Type *t ) const {
5636   // Perform a fast test for common case; meeting the same types together.
5637   if( this == t ) return this;  // Meeting same type-rep?
5638 
5639   // Current "this->_base" is Func
5640   switch (t->base()) {          // switch on original type
5641 
5642   case Bottom:                  // Ye Olde Default
5643     return t;
5644 


< prev index next >