< prev index next >

src/share/vm/opto/type.cpp

Print this page




 629   TypeAryPtr::FLOATS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::FLOAT        ,TypeInt::POS), ciTypeArrayKlass::make(T_FLOAT),  true,  Offset::bottom);
 630   TypeAryPtr::DOUBLES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::DOUBLE       ,TypeInt::POS), ciTypeArrayKlass::make(T_DOUBLE), true,  Offset::bottom);
 631 
 632   // Nobody should ask _array_body_type[T_NARROWOOP]. Use NULL as assert.
 633   TypeAryPtr::_array_body_type[T_NARROWOOP] = NULL;
 634   TypeAryPtr::_array_body_type[T_OBJECT]  = TypeAryPtr::OOPS;
 635   TypeAryPtr::_array_body_type[T_ARRAY]   = TypeAryPtr::OOPS; // arrays are stored in oop arrays
 636   TypeAryPtr::_array_body_type[T_VALUETYPE] = TypeAryPtr::OOPS;
 637   TypeAryPtr::_array_body_type[T_BYTE]    = TypeAryPtr::BYTES;
 638   TypeAryPtr::_array_body_type[T_BOOLEAN] = TypeAryPtr::BYTES;  // boolean[] is a byte array
 639   TypeAryPtr::_array_body_type[T_SHORT]   = TypeAryPtr::SHORTS;
 640   TypeAryPtr::_array_body_type[T_CHAR]    = TypeAryPtr::CHARS;
 641   TypeAryPtr::_array_body_type[T_INT]     = TypeAryPtr::INTS;
 642   TypeAryPtr::_array_body_type[T_LONG]    = TypeAryPtr::LONGS;
 643   TypeAryPtr::_array_body_type[T_FLOAT]   = TypeAryPtr::FLOATS;
 644   TypeAryPtr::_array_body_type[T_DOUBLE]  = TypeAryPtr::DOUBLES;
 645 
 646   TypeKlassPtr::OBJECT = TypeKlassPtr::make(TypePtr::NotNull, current->env()->Object_klass(), Offset(0) );
 647   TypeKlassPtr::OBJECT_OR_NULL = TypeKlassPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), Offset(0) );
 648   TypeKlassPtr::BOTTOM = (EnableValhalla | EnableMVT) ? TypeKlassPtr::make(TypePtr::BotPTR, NULL, Offset(0)) : TypeKlassPtr::OBJECT_OR_NULL;

 649 
 650   const Type **fi2c = TypeTuple::fields(2);
 651   fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // Method*
 652   fi2c[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // argument pointer
 653   TypeTuple::START_I2C = TypeTuple::make(TypeFunc::Parms+2, fi2c);
 654 
 655   const Type **intpair = TypeTuple::fields(2);
 656   intpair[0] = TypeInt::INT;
 657   intpair[1] = TypeInt::INT;
 658   TypeTuple::INT_PAIR = TypeTuple::make(2, intpair);
 659 
 660   const Type **longpair = TypeTuple::fields(2);
 661   longpair[0] = TypeLong::LONG;
 662   longpair[1] = TypeLong::LONG;
 663   TypeTuple::LONG_PAIR = TypeTuple::make(2, longpair);
 664 
 665   const Type **intccpair = TypeTuple::fields(2);
 666   intccpair[0] = TypeInt::INT;
 667   intccpair[1] = TypeInt::CC;
 668   TypeTuple::INT_CC_PAIR = TypeTuple::make(2, intccpair);


4752   return make(_vt, _ptr, _const_oop, _offset, instance_id, _speculative, _inline_depth);
4753 }
4754 
4755 //------------------------------meet-------------------------------------------
4756 // Compute the MEET of two types.  It returns a new Type object.
4757 const Type* TypeValueTypePtr::xmeet_helper(const Type* t) const {
4758   // Perform a fast test for common case; meeting the same types together.
4759   if (this == t) return this;  // Meeting same type-rep?
4760 
4761   switch (t->base()) {          // switch on original type
4762     case Int:                     // Mixing ints & oops happens when javac
4763     case Long:                    // reuses local variables
4764     case FloatTop:
4765     case FloatCon:
4766     case FloatBot:
4767     case DoubleTop:
4768     case DoubleCon:
4769     case DoubleBot:
4770     case NarrowOop:
4771     case NarrowKlass:



4772     case MetadataPtr:
4773     case KlassPtr:
4774     case RawPtr:
4775     case AryPtr:
4776     case InstPtr:
4777     case Bottom:                  // Ye Olde Default
4778       return Type::BOTTOM;
4779     case Top:
4780       return this;
4781 
4782     default:                      // All else is a mistake
4783       typerr(t);
4784 
4785     case OopPtr: {
4786       // Found a OopPtr type vs self-ValueTypePtr type
4787       const TypeOopPtr* tp = t->is_oopptr();
4788       Offset offset = meet_offset(tp->offset());
4789       PTR ptr = meet_ptr(tp->ptr());
4790       int instance_id = meet_instance_id(tp->instance_id());
4791       const TypePtr* speculative = xmeet_speculative(tp);
4792       int depth = meet_inline_depth(tp->inline_depth());
4793       switch (tp->ptr()) {
4794       case TopPTR:
4795       case AnyNull: {
4796         return make(_vt, ptr, NULL, offset, instance_id, speculative, depth);
4797       }
4798       case NotNull:


5237 }
5238 const TypeMetadataPtr* TypeMetadataPtr::make(ciMethodData* m) {
5239   return make(Constant, m, Offset(0));
5240 }
5241 
5242 //------------------------------make-------------------------------------------
5243 // Create a meta data constant
5244 const TypeMetadataPtr* TypeMetadataPtr::make(PTR ptr, ciMetadata* m, Offset offset) {
5245   assert(m == NULL || !m->is_klass(), "wrong type");
5246   return (TypeMetadataPtr*)(new TypeMetadataPtr(ptr, m, offset))->hashcons();
5247 }
5248 
5249 
5250 //=============================================================================
5251 // Convenience common pre-built types.
5252 
5253 // Not-null object klass or below
5254 const TypeKlassPtr *TypeKlassPtr::OBJECT;
5255 const TypeKlassPtr *TypeKlassPtr::OBJECT_OR_NULL;
5256 const TypeKlassPtr* TypeKlassPtr::BOTTOM;

5257 
5258 //------------------------------TypeKlassPtr-----------------------------------
5259 TypeKlassPtr::TypeKlassPtr( PTR ptr, ciKlass* klass, Offset offset )
5260   : TypePtr(KlassPtr, ptr, offset), _klass(klass), _klass_is_exact(ptr == Constant) {
5261 }
5262 
5263 //------------------------------make-------------------------------------------
5264 // ptr to klass 'k', if Constant, or possibly to a sub-klass if not a Constant
5265 const TypeKlassPtr* TypeKlassPtr::make(PTR ptr, ciKlass* k, Offset offset) {
5266   assert(k == NULL || k->is_instance_klass() || k->is_array_klass(), "Incorrect type of klass oop");
5267   return (TypeKlassPtr*)(new TypeKlassPtr(ptr, k, offset))->hashcons();
5268 }
5269 
5270 //------------------------------eq---------------------------------------------
5271 // Structural equality check for Type representations
5272 bool TypeKlassPtr::eq( const Type *t ) const {
5273   const TypeKlassPtr *p = t->is_klassptr();
5274   return klass() == p->klass() && TypePtr::eq(p);
5275 }
5276 


5655 //------------------------------make-------------------------------------------
5656 const TypeFunc *TypeFunc::make(ciMethod* method) {
5657   Compile* C = Compile::current();
5658   const TypeFunc* tf = C->last_tf(method); // check cache
5659   if (tf != NULL)  return tf;  // The hit rate here is almost 50%.
5660   const TypeTuple *domain_sig, *domain_cc;
5661   // Value type arguments are not passed by reference, instead each
5662   // field of the value type is passed as an argument. We maintain 2
5663   // views of the argument list here: one based on the signature (with
5664   // a value type argument as a single slot), one based on the actual
5665   // calling convention (with a value type argument as a list of its
5666   // fields).
5667   if (method->is_static()) {
5668     domain_sig = TypeTuple::make_domain(NULL, method->signature(), false);
5669     domain_cc = TypeTuple::make_domain(NULL, method->signature(), ValueTypePassFieldsAsArgs);
5670   } else {
5671     domain_sig = TypeTuple::make_domain(method->holder(), method->signature(), false);
5672     domain_cc = TypeTuple::make_domain(method->holder(), method->signature(), ValueTypePassFieldsAsArgs);
5673   }
5674   const TypeTuple *range_sig = TypeTuple::make_range(method->signature(), false);
5675   const TypeTuple *range_cc = TypeTuple::make_range(method->signature(), ValueTypeReturnedAsFields);

5676   tf = TypeFunc::make(domain_sig, domain_cc, range_sig, range_cc);
5677   C->set_last_tf(method, tf);  // fill cache
5678   return tf;
5679 }
5680 
5681 //------------------------------meet-------------------------------------------
5682 // Compute the MEET of two types.  It returns a new Type object.
5683 const Type *TypeFunc::xmeet( const Type *t ) const {
5684   // Perform a fast test for common case; meeting the same types together.
5685   if( this == t ) return this;  // Meeting same type-rep?
5686 
5687   // Current "this->_base" is Func
5688   switch (t->base()) {          // switch on original type
5689 
5690   case Bottom:                  // Ye Olde Default
5691     return t;
5692 
5693   default:                      // All else is a mistake
5694     typerr(t);
5695 




 629   TypeAryPtr::FLOATS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::FLOAT        ,TypeInt::POS), ciTypeArrayKlass::make(T_FLOAT),  true,  Offset::bottom);
 630   TypeAryPtr::DOUBLES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::DOUBLE       ,TypeInt::POS), ciTypeArrayKlass::make(T_DOUBLE), true,  Offset::bottom);
 631 
 632   // Nobody should ask _array_body_type[T_NARROWOOP]. Use NULL as assert.
 633   TypeAryPtr::_array_body_type[T_NARROWOOP] = NULL;
 634   TypeAryPtr::_array_body_type[T_OBJECT]  = TypeAryPtr::OOPS;
 635   TypeAryPtr::_array_body_type[T_ARRAY]   = TypeAryPtr::OOPS; // arrays are stored in oop arrays
 636   TypeAryPtr::_array_body_type[T_VALUETYPE] = TypeAryPtr::OOPS;
 637   TypeAryPtr::_array_body_type[T_BYTE]    = TypeAryPtr::BYTES;
 638   TypeAryPtr::_array_body_type[T_BOOLEAN] = TypeAryPtr::BYTES;  // boolean[] is a byte array
 639   TypeAryPtr::_array_body_type[T_SHORT]   = TypeAryPtr::SHORTS;
 640   TypeAryPtr::_array_body_type[T_CHAR]    = TypeAryPtr::CHARS;
 641   TypeAryPtr::_array_body_type[T_INT]     = TypeAryPtr::INTS;
 642   TypeAryPtr::_array_body_type[T_LONG]    = TypeAryPtr::LONGS;
 643   TypeAryPtr::_array_body_type[T_FLOAT]   = TypeAryPtr::FLOATS;
 644   TypeAryPtr::_array_body_type[T_DOUBLE]  = TypeAryPtr::DOUBLES;
 645 
 646   TypeKlassPtr::OBJECT = TypeKlassPtr::make(TypePtr::NotNull, current->env()->Object_klass(), Offset(0) );
 647   TypeKlassPtr::OBJECT_OR_NULL = TypeKlassPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), Offset(0) );
 648   TypeKlassPtr::BOTTOM = (EnableValhalla | EnableMVT) ? TypeKlassPtr::make(TypePtr::BotPTR, NULL, Offset(0)) : TypeKlassPtr::OBJECT_OR_NULL;
 649   TypeKlassPtr::VALUE = TypeKlassPtr::make(TypePtr::NotNull, current->env()->___Value_klass(), Offset(0));
 650 
 651   const Type **fi2c = TypeTuple::fields(2);
 652   fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // Method*
 653   fi2c[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // argument pointer
 654   TypeTuple::START_I2C = TypeTuple::make(TypeFunc::Parms+2, fi2c);
 655 
 656   const Type **intpair = TypeTuple::fields(2);
 657   intpair[0] = TypeInt::INT;
 658   intpair[1] = TypeInt::INT;
 659   TypeTuple::INT_PAIR = TypeTuple::make(2, intpair);
 660 
 661   const Type **longpair = TypeTuple::fields(2);
 662   longpair[0] = TypeLong::LONG;
 663   longpair[1] = TypeLong::LONG;
 664   TypeTuple::LONG_PAIR = TypeTuple::make(2, longpair);
 665 
 666   const Type **intccpair = TypeTuple::fields(2);
 667   intccpair[0] = TypeInt::INT;
 668   intccpair[1] = TypeInt::CC;
 669   TypeTuple::INT_CC_PAIR = TypeTuple::make(2, intccpair);


4753   return make(_vt, _ptr, _const_oop, _offset, instance_id, _speculative, _inline_depth);
4754 }
4755 
4756 //------------------------------meet-------------------------------------------
4757 // Compute the MEET of two types.  It returns a new Type object.
4758 const Type* TypeValueTypePtr::xmeet_helper(const Type* t) const {
4759   // Perform a fast test for common case; meeting the same types together.
4760   if (this == t) return this;  // Meeting same type-rep?
4761 
4762   switch (t->base()) {          // switch on original type
4763     case Int:                     // Mixing ints & oops happens when javac
4764     case Long:                    // reuses local variables
4765     case FloatTop:
4766     case FloatCon:
4767     case FloatBot:
4768     case DoubleTop:
4769     case DoubleCon:
4770     case DoubleBot:
4771     case NarrowOop:
4772     case NarrowKlass:
4773     case Bottom:                  // Ye Olde Default
4774       return Type::BOTTOM;
4775 
4776     case MetadataPtr:
4777     case KlassPtr:
4778     case RawPtr:
4779     case AryPtr:
4780     case InstPtr:
4781       return TypePtr::BOTTOM;
4782 
4783     case Top:
4784       return this;
4785 
4786     default:                      // All else is a mistake
4787       typerr(t);
4788 
4789     case OopPtr: {
4790       // Found a OopPtr type vs self-ValueTypePtr type
4791       const TypeOopPtr* tp = t->is_oopptr();
4792       Offset offset = meet_offset(tp->offset());
4793       PTR ptr = meet_ptr(tp->ptr());
4794       int instance_id = meet_instance_id(tp->instance_id());
4795       const TypePtr* speculative = xmeet_speculative(tp);
4796       int depth = meet_inline_depth(tp->inline_depth());
4797       switch (tp->ptr()) {
4798       case TopPTR:
4799       case AnyNull: {
4800         return make(_vt, ptr, NULL, offset, instance_id, speculative, depth);
4801       }
4802       case NotNull:


5241 }
5242 const TypeMetadataPtr* TypeMetadataPtr::make(ciMethodData* m) {
5243   return make(Constant, m, Offset(0));
5244 }
5245 
5246 //------------------------------make-------------------------------------------
5247 // Create a meta data constant
5248 const TypeMetadataPtr* TypeMetadataPtr::make(PTR ptr, ciMetadata* m, Offset offset) {
5249   assert(m == NULL || !m->is_klass(), "wrong type");
5250   return (TypeMetadataPtr*)(new TypeMetadataPtr(ptr, m, offset))->hashcons();
5251 }
5252 
5253 
5254 //=============================================================================
5255 // Convenience common pre-built types.
5256 
5257 // Not-null object klass or below
5258 const TypeKlassPtr *TypeKlassPtr::OBJECT;
5259 const TypeKlassPtr *TypeKlassPtr::OBJECT_OR_NULL;
5260 const TypeKlassPtr* TypeKlassPtr::BOTTOM;
5261 const TypeKlassPtr *TypeKlassPtr::VALUE;
5262 
5263 //------------------------------TypeKlassPtr-----------------------------------
5264 TypeKlassPtr::TypeKlassPtr( PTR ptr, ciKlass* klass, Offset offset )
5265   : TypePtr(KlassPtr, ptr, offset), _klass(klass), _klass_is_exact(ptr == Constant) {
5266 }
5267 
5268 //------------------------------make-------------------------------------------
5269 // ptr to klass 'k', if Constant, or possibly to a sub-klass if not a Constant
5270 const TypeKlassPtr* TypeKlassPtr::make(PTR ptr, ciKlass* k, Offset offset) {
5271   assert(k == NULL || k->is_instance_klass() || k->is_array_klass(), "Incorrect type of klass oop");
5272   return (TypeKlassPtr*)(new TypeKlassPtr(ptr, k, offset))->hashcons();
5273 }
5274 
5275 //------------------------------eq---------------------------------------------
5276 // Structural equality check for Type representations
5277 bool TypeKlassPtr::eq( const Type *t ) const {
5278   const TypeKlassPtr *p = t->is_klassptr();
5279   return klass() == p->klass() && TypePtr::eq(p);
5280 }
5281 


5660 //------------------------------make-------------------------------------------
5661 const TypeFunc *TypeFunc::make(ciMethod* method) {
5662   Compile* C = Compile::current();
5663   const TypeFunc* tf = C->last_tf(method); // check cache
5664   if (tf != NULL)  return tf;  // The hit rate here is almost 50%.
5665   const TypeTuple *domain_sig, *domain_cc;
5666   // Value type arguments are not passed by reference, instead each
5667   // field of the value type is passed as an argument. We maintain 2
5668   // views of the argument list here: one based on the signature (with
5669   // a value type argument as a single slot), one based on the actual
5670   // calling convention (with a value type argument as a list of its
5671   // fields).
5672   if (method->is_static()) {
5673     domain_sig = TypeTuple::make_domain(NULL, method->signature(), false);
5674     domain_cc = TypeTuple::make_domain(NULL, method->signature(), ValueTypePassFieldsAsArgs);
5675   } else {
5676     domain_sig = TypeTuple::make_domain(method->holder(), method->signature(), false);
5677     domain_cc = TypeTuple::make_domain(method->holder(), method->signature(), ValueTypePassFieldsAsArgs);
5678   }
5679   const TypeTuple *range_sig = TypeTuple::make_range(method->signature(), false);
5680   bool as_fields = ValueTypeReturnedAsFields;
5681   const TypeTuple *range_cc = TypeTuple::make_range(method->signature(), as_fields);
5682   tf = TypeFunc::make(domain_sig, domain_cc, range_sig, range_cc);
5683   C->set_last_tf(method, tf);  // fill cache
5684   return tf;
5685 }
5686 
5687 //------------------------------meet-------------------------------------------
5688 // Compute the MEET of two types.  It returns a new Type object.
5689 const Type *TypeFunc::xmeet( const Type *t ) const {
5690   // Perform a fast test for common case; meeting the same types together.
5691   if( this == t ) return this;  // Meeting same type-rep?
5692 
5693   // Current "this->_base" is Func
5694   switch (t->base()) {          // switch on original type
5695 
5696   case Bottom:                  // Ye Olde Default
5697     return t;
5698 
5699   default:                      // All else is a mistake
5700     typerr(t);
5701 


< prev index next >