< prev index next >

src/hotspot/share/opto/type.cpp

Print this page




2386   const TypeInstPtr* tinst;
2387   if (_elem->isa_narrowoop())
2388     tinst = _elem->make_ptr()->isa_instptr();
2389   else
2390     tinst = _elem->isa_instptr();
2391   if (tinst)
2392     return tklass->as_instance_klass()->is_final();
2393   const TypeAryPtr*  tap;
2394   if (_elem->isa_narrowoop())
2395     tap = _elem->make_ptr()->isa_aryptr();
2396   else
2397     tap = _elem->isa_aryptr();
2398   if (tap)
2399     return tap->ary()->ary_must_be_exact();
2400   return false;
2401 }
2402 
2403 //==============================TypeValueType=======================================
2404 
2405 //------------------------------make-------------------------------------------
2406 const TypeValueType* TypeValueType::make(ciValueKlass* vk) {
2407   return (TypeValueType*)(new TypeValueType(vk))->hashcons();
2408 }
2409 
2410 //------------------------------meet-------------------------------------------
2411 // Compute the MEET of two types.  It returns a new Type object.
2412 const Type* TypeValueType::xmeet(const Type* t) const {
2413   // Perform a fast test for common case; meeting the same types together.
2414   if(this == t) return this;  // Meeting same type-rep?
2415 
2416   // Current "this->_base" is ValueType
2417   switch (t->base()) {          // switch on original type
2418 
2419   case Int:
2420   case Long:
2421   case FloatTop:
2422   case FloatCon:
2423   case FloatBot:
2424   case DoubleTop:
2425   case DoubleCon:
2426   case DoubleBot:
2427   case NarrowKlass:


2435     return TypePtr::BOTTOM;
2436 
2437   case Top:
2438     return this;
2439 
2440   case NarrowOop: {
2441     const Type* res = t->make_ptr()->xmeet(this);
2442     if (res->isa_ptr()) {
2443       return res->make_narrowoop();
2444     }
2445     return res;
2446   }
2447 
2448   case AryPtr:
2449   case InstPtr: {
2450     return t->xmeet(this);
2451   }
2452 
2453   case ValueType: {
2454     // All value types inherit from Object









2455     return TypeInstPtr::NOTNULL;
2456   }
2457 
2458   default:                      // All else is a mistake
2459     typerr(t);
2460 
2461   }
2462   return this;
2463 }
2464 
2465 //------------------------------xdual------------------------------------------
2466 const Type* TypeValueType::xdual() const {
2467   return this;
2468 }
2469 
2470 //------------------------------eq---------------------------------------------
2471 // Structural equality check for Type representations
2472 bool TypeValueType::eq(const Type* t) const {
2473   const TypeValueType* vt = t->is_valuetype();
2474   return (_vk == vt->value_klass());
2475 }
2476 
2477 //------------------------------hash-------------------------------------------
2478 // Type-specific hashing function.
2479 int TypeValueType::hash(void) const {
2480   return (intptr_t)_vk;
2481 }
2482 
2483 //------------------------------singleton--------------------------------------
2484 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple constants.
2485 bool TypeValueType::singleton(void) const {
2486   return false;
2487 }
2488 
2489 //------------------------------empty------------------------------------------
2490 // TRUE if Type is a type with no values, FALSE otherwise.
2491 bool TypeValueType::empty(void) const {
2492   return false;
2493 }
2494 
2495 //------------------------------dump2------------------------------------------
2496 #ifndef PRODUCT
2497 void TypeValueType::dump2(Dict &d, uint depth, outputStream* st) const {
2498   int count = _vk->nof_declared_nonstatic_fields();
2499   st->print("valuetype[%d]:{", count);
2500   st->print("%s", count != 0 ? _vk->declared_nonstatic_field_at(0)->type()->name() : "empty");
2501   for (int i = 1; i < count; ++i) {
2502     st->print(", %s", _vk->declared_nonstatic_field_at(i)->type()->name());
2503   }
2504   st->print("}");
2505 }
2506 #endif
2507 
2508 //==============================TypeVect=======================================
2509 // Convenience common pre-built types.
2510 const TypeVect *TypeVect::VECTS = NULL; //  32-bit vectors
2511 const TypeVect *TypeVect::VECTD = NULL; //  64-bit vectors
2512 const TypeVect *TypeVect::VECTX = NULL; // 128-bit vectors
2513 const TypeVect *TypeVect::VECTY = NULL; // 256-bit vectors
2514 const TypeVect *TypeVect::VECTZ = NULL; // 512-bit vectors
2515 
2516 //------------------------------make-------------------------------------------
2517 const TypeVect* TypeVect::make(const Type *elem, uint length) {
2518   BasicType elem_bt = elem->array_element_basic_type();
2519   assert(is_java_primitive(elem_bt), "only primitive types in vector");
2520   assert(length > 1 && is_power_of_2(length), "vector length is power of 2");
2521   assert(Matcher::vector_size_supported(elem_bt, length), "length in range");
2522   int size = length * type2aelembytes(elem_bt);
2523   switch (Matcher::vector_ideal_reg(size)) {
2524   case Op_VecS:




2386   const TypeInstPtr* tinst;
2387   if (_elem->isa_narrowoop())
2388     tinst = _elem->make_ptr()->isa_instptr();
2389   else
2390     tinst = _elem->isa_instptr();
2391   if (tinst)
2392     return tklass->as_instance_klass()->is_final();
2393   const TypeAryPtr*  tap;
2394   if (_elem->isa_narrowoop())
2395     tap = _elem->make_ptr()->isa_aryptr();
2396   else
2397     tap = _elem->isa_aryptr();
2398   if (tap)
2399     return tap->ary()->ary_must_be_exact();
2400   return false;
2401 }
2402 
2403 //==============================TypeValueType=======================================
2404 
2405 //------------------------------make-------------------------------------------
2406 const TypeValueType* TypeValueType::make(ciValueKlass* vk, bool larval) {
2407   return (TypeValueType*)(new TypeValueType(vk, larval))->hashcons();
2408 }
2409 
2410 //------------------------------meet-------------------------------------------
2411 // Compute the MEET of two types.  It returns a new Type object.
2412 const Type* TypeValueType::xmeet(const Type* t) const {
2413   // Perform a fast test for common case; meeting the same types together.
2414   if(this == t) return this;  // Meeting same type-rep?
2415 
2416   // Current "this->_base" is ValueType
2417   switch (t->base()) {          // switch on original type
2418 
2419   case Int:
2420   case Long:
2421   case FloatTop:
2422   case FloatCon:
2423   case FloatBot:
2424   case DoubleTop:
2425   case DoubleCon:
2426   case DoubleBot:
2427   case NarrowKlass:


2435     return TypePtr::BOTTOM;
2436 
2437   case Top:
2438     return this;
2439 
2440   case NarrowOop: {
2441     const Type* res = t->make_ptr()->xmeet(this);
2442     if (res->isa_ptr()) {
2443       return res->make_narrowoop();
2444     }
2445     return res;
2446   }
2447 
2448   case AryPtr:
2449   case InstPtr: {
2450     return t->xmeet(this);
2451   }
2452 
2453   case ValueType: {
2454     // All value types inherit from Object
2455     const TypeValueType* other = t->is_valuetype();
2456     if (_vk == other->_vk) {
2457       if (_larval == other->_larval ||
2458           !_larval) {
2459         return this;
2460       } else {
2461         return t;
2462       }
2463     }
2464     return TypeInstPtr::NOTNULL;
2465   }
2466 
2467   default:                      // All else is a mistake
2468     typerr(t);
2469 
2470   }
2471   return this;
2472 }
2473 
2474 //------------------------------xdual------------------------------------------
2475 const Type* TypeValueType::xdual() const {
2476   return this;
2477 }
2478 
2479 //------------------------------eq---------------------------------------------
2480 // Structural equality check for Type representations
2481 bool TypeValueType::eq(const Type* t) const {
2482   const TypeValueType* vt = t->is_valuetype();
2483   return (_vk == vt->value_klass() && _larval == vt->larval());
2484 }
2485 
2486 //------------------------------hash-------------------------------------------
2487 // Type-specific hashing function.
2488 int TypeValueType::hash(void) const {
2489   return (intptr_t)_vk;
2490 }
2491 
2492 //------------------------------singleton--------------------------------------
2493 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple constants.
2494 bool TypeValueType::singleton(void) const {
2495   return false;
2496 }
2497 
2498 //------------------------------empty------------------------------------------
2499 // TRUE if Type is a type with no values, FALSE otherwise.
2500 bool TypeValueType::empty(void) const {
2501   return false;
2502 }
2503 
2504 //------------------------------dump2------------------------------------------
2505 #ifndef PRODUCT
2506 void TypeValueType::dump2(Dict &d, uint depth, outputStream* st) const {
2507   int count = _vk->nof_declared_nonstatic_fields();
2508   st->print("valuetype[%d]:{", count);
2509   st->print("%s", count != 0 ? _vk->declared_nonstatic_field_at(0)->type()->name() : "empty");
2510   for (int i = 1; i < count; ++i) {
2511     st->print(", %s", _vk->declared_nonstatic_field_at(i)->type()->name());
2512   }
2513   st->print("}%s", _larval?":larval":"");
2514 }
2515 #endif
2516 
2517 //==============================TypeVect=======================================
2518 // Convenience common pre-built types.
2519 const TypeVect *TypeVect::VECTS = NULL; //  32-bit vectors
2520 const TypeVect *TypeVect::VECTD = NULL; //  64-bit vectors
2521 const TypeVect *TypeVect::VECTX = NULL; // 128-bit vectors
2522 const TypeVect *TypeVect::VECTY = NULL; // 256-bit vectors
2523 const TypeVect *TypeVect::VECTZ = NULL; // 512-bit vectors
2524 
2525 //------------------------------make-------------------------------------------
2526 const TypeVect* TypeVect::make(const Type *elem, uint length) {
2527   BasicType elem_bt = elem->array_element_basic_type();
2528   assert(is_java_primitive(elem_bt), "only primitive types in vector");
2529   assert(length > 1 && is_power_of_2(length), "vector length is power of 2");
2530   assert(Matcher::vector_size_supported(elem_bt, length), "length in range");
2531   int size = length * type2aelembytes(elem_bt);
2532   switch (Matcher::vector_ideal_reg(size)) {
2533   case Op_VecS:


< prev index next >