< prev index next >

src/hotspot/share/opto/type.cpp

Print this page




2357   const TypeInstPtr* tinst;
2358   if (_elem->isa_narrowoop())
2359     tinst = _elem->make_ptr()->isa_instptr();
2360   else
2361     tinst = _elem->isa_instptr();
2362   if (tinst)
2363     return tklass->as_instance_klass()->is_final();
2364   const TypeAryPtr*  tap;
2365   if (_elem->isa_narrowoop())
2366     tap = _elem->make_ptr()->isa_aryptr();
2367   else
2368     tap = _elem->isa_aryptr();
2369   if (tap)
2370     return tap->ary()->ary_must_be_exact();
2371   return false;
2372 }
2373 
2374 //==============================TypeValueType=======================================
2375 
2376 //------------------------------make-------------------------------------------
2377 const TypeValueType* TypeValueType::make(ciValueKlass* vk) {
2378   return (TypeValueType*)(new TypeValueType(vk))->hashcons();
2379 }
2380 
2381 //------------------------------meet-------------------------------------------
2382 // Compute the MEET of two types.  It returns a new Type object.
2383 const Type* TypeValueType::xmeet(const Type* t) const {
2384   // Perform a fast test for common case; meeting the same types together.
2385   if(this == t) return this;  // Meeting same type-rep?
2386 
2387   // Current "this->_base" is ValueType
2388   switch (t->base()) {          // switch on original type
2389 
2390   case Int:
2391   case Long:
2392   case FloatTop:
2393   case FloatCon:
2394   case FloatBot:
2395   case DoubleTop:
2396   case DoubleCon:
2397   case DoubleBot:
2398   case NarrowKlass:


2406     return TypePtr::BOTTOM;
2407 
2408   case Top:
2409     return this;
2410 
2411   case NarrowOop: {
2412     const Type* res = t->make_ptr()->xmeet(this);
2413     if (res->isa_ptr()) {
2414       return res->make_narrowoop();
2415     }
2416     return res;
2417   }
2418 
2419   case AryPtr:
2420   case InstPtr: {
2421     return t->xmeet(this);
2422   }
2423 
2424   case ValueType: {
2425     // All value types inherit from Object









2426     return TypeInstPtr::NOTNULL;
2427   }
2428 
2429   default:                      // All else is a mistake
2430     typerr(t);
2431 
2432   }
2433   return this;
2434 }
2435 
2436 //------------------------------xdual------------------------------------------
2437 const Type* TypeValueType::xdual() const {
2438   return this;
2439 }
2440 
2441 //------------------------------eq---------------------------------------------
2442 // Structural equality check for Type representations
2443 bool TypeValueType::eq(const Type* t) const {
2444   const TypeValueType* vt = t->is_valuetype();
2445   return (_vk == vt->value_klass());
2446 }
2447 
2448 //------------------------------hash-------------------------------------------
2449 // Type-specific hashing function.
2450 int TypeValueType::hash(void) const {
2451   return (intptr_t)_vk;
2452 }
2453 
2454 //------------------------------singleton--------------------------------------
2455 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple constants.
2456 bool TypeValueType::singleton(void) const {
2457   return false;
2458 }
2459 
2460 //------------------------------empty------------------------------------------
2461 // TRUE if Type is a type with no values, FALSE otherwise.
2462 bool TypeValueType::empty(void) const {
2463   return false;
2464 }
2465 
2466 //------------------------------dump2------------------------------------------
2467 #ifndef PRODUCT
2468 void TypeValueType::dump2(Dict &d, uint depth, outputStream* st) const {
2469   int count = _vk->nof_declared_nonstatic_fields();
2470   st->print("valuetype[%d]:{", count);
2471   st->print("%s", count != 0 ? _vk->declared_nonstatic_field_at(0)->type()->name() : "empty");
2472   for (int i = 1; i < count; ++i) {
2473     st->print(", %s", _vk->declared_nonstatic_field_at(i)->type()->name());
2474   }
2475   st->print("}");
2476 }
2477 #endif
2478 
2479 //==============================TypeVect=======================================
2480 // Convenience common pre-built types.
2481 const TypeVect *TypeVect::VECTS = NULL; //  32-bit vectors
2482 const TypeVect *TypeVect::VECTD = NULL; //  64-bit vectors
2483 const TypeVect *TypeVect::VECTX = NULL; // 128-bit vectors
2484 const TypeVect *TypeVect::VECTY = NULL; // 256-bit vectors
2485 const TypeVect *TypeVect::VECTZ = NULL; // 512-bit vectors
2486 
2487 //------------------------------make-------------------------------------------
2488 const TypeVect* TypeVect::make(const Type *elem, uint length) {
2489   BasicType elem_bt = elem->array_element_basic_type();
2490   assert(is_java_primitive(elem_bt), "only primitive types in vector");
2491   assert(length > 1 && is_power_of_2(length), "vector length is power of 2");
2492   assert(Matcher::vector_size_supported(elem_bt, length), "length in range");
2493   int size = length * type2aelembytes(elem_bt);
2494   switch (Matcher::vector_ideal_reg(size)) {
2495   case Op_VecS:




2357   const TypeInstPtr* tinst;
2358   if (_elem->isa_narrowoop())
2359     tinst = _elem->make_ptr()->isa_instptr();
2360   else
2361     tinst = _elem->isa_instptr();
2362   if (tinst)
2363     return tklass->as_instance_klass()->is_final();
2364   const TypeAryPtr*  tap;
2365   if (_elem->isa_narrowoop())
2366     tap = _elem->make_ptr()->isa_aryptr();
2367   else
2368     tap = _elem->isa_aryptr();
2369   if (tap)
2370     return tap->ary()->ary_must_be_exact();
2371   return false;
2372 }
2373 
2374 //==============================TypeValueType=======================================
2375 
2376 //------------------------------make-------------------------------------------
2377 const TypeValueType* TypeValueType::make(ciValueKlass* vk, bool larval) {
2378   return (TypeValueType*)(new TypeValueType(vk, larval))->hashcons();
2379 }
2380 
2381 //------------------------------meet-------------------------------------------
2382 // Compute the MEET of two types.  It returns a new Type object.
2383 const Type* TypeValueType::xmeet(const Type* t) const {
2384   // Perform a fast test for common case; meeting the same types together.
2385   if(this == t) return this;  // Meeting same type-rep?
2386 
2387   // Current "this->_base" is ValueType
2388   switch (t->base()) {          // switch on original type
2389 
2390   case Int:
2391   case Long:
2392   case FloatTop:
2393   case FloatCon:
2394   case FloatBot:
2395   case DoubleTop:
2396   case DoubleCon:
2397   case DoubleBot:
2398   case NarrowKlass:


2406     return TypePtr::BOTTOM;
2407 
2408   case Top:
2409     return this;
2410 
2411   case NarrowOop: {
2412     const Type* res = t->make_ptr()->xmeet(this);
2413     if (res->isa_ptr()) {
2414       return res->make_narrowoop();
2415     }
2416     return res;
2417   }
2418 
2419   case AryPtr:
2420   case InstPtr: {
2421     return t->xmeet(this);
2422   }
2423 
2424   case ValueType: {
2425     // All value types inherit from Object
2426     const TypeValueType* other = t->is_valuetype();
2427     if (_vk == other->_vk) {
2428       if (_larval == other->_larval ||
2429           !_larval) {
2430         return this;
2431       } else {
2432         return t;
2433       }
2434     }
2435     return TypeInstPtr::NOTNULL;
2436   }
2437 
2438   default:                      // All else is a mistake
2439     typerr(t);
2440 
2441   }
2442   return this;
2443 }
2444 
2445 //------------------------------xdual------------------------------------------
2446 const Type* TypeValueType::xdual() const {
2447   return this;
2448 }
2449 
2450 //------------------------------eq---------------------------------------------
2451 // Structural equality check for Type representations
2452 bool TypeValueType::eq(const Type* t) const {
2453   const TypeValueType* vt = t->is_valuetype();
2454   return (_vk == vt->value_klass() && _larval == vt->larval());
2455 }
2456 
2457 //------------------------------hash-------------------------------------------
2458 // Type-specific hashing function.
2459 int TypeValueType::hash(void) const {
2460   return (intptr_t)_vk;
2461 }
2462 
2463 //------------------------------singleton--------------------------------------
2464 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple constants.
2465 bool TypeValueType::singleton(void) const {
2466   return false;
2467 }
2468 
2469 //------------------------------empty------------------------------------------
2470 // TRUE if Type is a type with no values, FALSE otherwise.
2471 bool TypeValueType::empty(void) const {
2472   return false;
2473 }
2474 
2475 //------------------------------dump2------------------------------------------
2476 #ifndef PRODUCT
2477 void TypeValueType::dump2(Dict &d, uint depth, outputStream* st) const {
2478   int count = _vk->nof_declared_nonstatic_fields();
2479   st->print("valuetype[%d]:{", count);
2480   st->print("%s", count != 0 ? _vk->declared_nonstatic_field_at(0)->type()->name() : "empty");
2481   for (int i = 1; i < count; ++i) {
2482     st->print(", %s", _vk->declared_nonstatic_field_at(i)->type()->name());
2483   }
2484   st->print("}%s", _larval?":larval":"");
2485 }
2486 #endif
2487 
2488 //==============================TypeVect=======================================
2489 // Convenience common pre-built types.
2490 const TypeVect *TypeVect::VECTS = NULL; //  32-bit vectors
2491 const TypeVect *TypeVect::VECTD = NULL; //  64-bit vectors
2492 const TypeVect *TypeVect::VECTX = NULL; // 128-bit vectors
2493 const TypeVect *TypeVect::VECTY = NULL; // 256-bit vectors
2494 const TypeVect *TypeVect::VECTZ = NULL; // 512-bit vectors
2495 
2496 //------------------------------make-------------------------------------------
2497 const TypeVect* TypeVect::make(const Type *elem, uint length) {
2498   BasicType elem_bt = elem->array_element_basic_type();
2499   assert(is_java_primitive(elem_bt), "only primitive types in vector");
2500   assert(length > 1 && is_power_of_2(length), "vector length is power of 2");
2501   assert(Matcher::vector_size_supported(elem_bt, length), "length in range");
2502   int size = length * type2aelembytes(elem_bt);
2503   switch (Matcher::vector_ideal_reg(size)) {
2504   case Op_VecS:


< prev index next >