594
595 const Type **fmembar = TypeTuple::fields(0);
596 TypeTuple::MEMBAR = TypeTuple::make(TypeFunc::Parms+0, fmembar);
597
598 const Type **fsc = (const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
599 fsc[0] = TypeInt::CC;
600 fsc[1] = Type::MEMORY;
601 TypeTuple::STORECONDITIONAL = TypeTuple::make(2, fsc);
602
603 TypeInstPtr::NOTNULL = TypeInstPtr::make(TypePtr::NotNull, current->env()->Object_klass());
604 TypeInstPtr::BOTTOM = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass());
605 TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass());
606 TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(),
607 false, 0, Offset(oopDesc::mark_offset_in_bytes()));
608 TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(),
609 false, 0, Offset(oopDesc::klass_offset_in_bytes()));
610 TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, Offset::bottom, TypeOopPtr::InstanceBot);
611
612 TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, Offset::bottom);
613
614 TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR );
615 TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM );
616
617 TypeNarrowKlass::NULL_PTR = TypeNarrowKlass::make( TypePtr::NULL_PTR );
618
619 mreg2type[Op_Node] = Type::BOTTOM;
620 mreg2type[Op_Set ] = 0;
621 mreg2type[Op_RegN] = TypeNarrowOop::BOTTOM;
622 mreg2type[Op_RegI] = TypeInt::INT;
623 mreg2type[Op_RegP] = TypePtr::BOTTOM;
624 mreg2type[Op_RegF] = Type::FLOAT;
625 mreg2type[Op_RegD] = Type::DOUBLE;
626 mreg2type[Op_RegL] = TypeLong::LONG;
627 mreg2type[Op_RegFlags] = TypeInt::CC;
628
629 TypeAryPtr::RANGE = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::BOTTOM,TypeInt::POS), NULL /* current->env()->Object_klass() */, false, Offset(arrayOopDesc::length_offset_in_bytes()));
630
631 TypeAryPtr::NARROWOOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeNarrowOop::BOTTOM, TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Offset::bottom);
632
633 #ifdef _LP64
634 if (UseCompressedOops) {
635 assert(TypeAryPtr::NARROWOOPS->is_ptr_to_narrowoop(), "array of narrow oops must be ptr to narrow oop");
636 TypeAryPtr::OOPS = TypeAryPtr::NARROWOOPS;
637 } else
638 #endif
639 {
640 // There is no shared klass for Object[]. See note in TypeAryPtr::klass().
641 TypeAryPtr::OOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInstPtr::BOTTOM,TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Offset::bottom);
642 }
643 TypeAryPtr::BYTES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::BYTE ,TypeInt::POS), ciTypeArrayKlass::make(T_BYTE), true, Offset::bottom);
644 TypeAryPtr::SHORTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::SHORT ,TypeInt::POS), ciTypeArrayKlass::make(T_SHORT), true, Offset::bottom);
645 TypeAryPtr::CHARS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::CHAR ,TypeInt::POS), ciTypeArrayKlass::make(T_CHAR), true, Offset::bottom);
646 TypeAryPtr::INTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::INT ,TypeInt::POS), ciTypeArrayKlass::make(T_INT), true, Offset::bottom);
647 TypeAryPtr::LONGS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeLong::LONG ,TypeInt::POS), ciTypeArrayKlass::make(T_LONG), true, Offset::bottom);
648 TypeAryPtr::FLOATS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::FLOAT ,TypeInt::POS), ciTypeArrayKlass::make(T_FLOAT), true, Offset::bottom);
649 TypeAryPtr::DOUBLES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::DOUBLE ,TypeInt::POS), ciTypeArrayKlass::make(T_DOUBLE), true, Offset::bottom);
650
651 // Nobody should ask _array_body_type[T_NARROWOOP]. Use NULL as assert.
652 TypeAryPtr::_array_body_type[T_NARROWOOP] = NULL;
653 TypeAryPtr::_array_body_type[T_OBJECT] = TypeAryPtr::OOPS;
654 TypeAryPtr::_array_body_type[T_VALUETYPE] = TypeAryPtr::OOPS;
655 TypeAryPtr::_array_body_type[T_ARRAY] = TypeAryPtr::OOPS; // arrays are stored in oop arrays
656 TypeAryPtr::_array_body_type[T_BYTE] = TypeAryPtr::BYTES;
657 TypeAryPtr::_array_body_type[T_BOOLEAN] = TypeAryPtr::BYTES; // boolean[] is a byte array
658 TypeAryPtr::_array_body_type[T_SHORT] = TypeAryPtr::SHORTS;
659 TypeAryPtr::_array_body_type[T_CHAR] = TypeAryPtr::CHARS;
660 TypeAryPtr::_array_body_type[T_INT] = TypeAryPtr::INTS;
661 TypeAryPtr::_array_body_type[T_LONG] = TypeAryPtr::LONGS;
662 TypeAryPtr::_array_body_type[T_FLOAT] = TypeAryPtr::FLOATS;
663 TypeAryPtr::_array_body_type[T_DOUBLE] = TypeAryPtr::DOUBLES;
664
665 TypeKlassPtr::OBJECT = TypeKlassPtr::make(TypePtr::NotNull, current->env()->Object_klass(), Offset(0) );
666 TypeKlassPtr::OBJECT_OR_NULL = TypeKlassPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), Offset(0) );
667
668 const Type **fi2c = TypeTuple::fields(2);
669 fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // Method*
2369 if (tklass->as_instance_klass()->is_final()) {
2370 if (tinst->is_valuetypeptr() && (tinst->ptr() == TypePtr::BotPTR || tinst->ptr() == TypePtr::TopPTR)) {
2371 return false;
2372 }
2373 return true;
2374 }
2375 return false;
2376 }
2377 const TypeAryPtr* tap;
2378 if (_elem->isa_narrowoop())
2379 tap = _elem->make_ptr()->isa_aryptr();
2380 else
2381 tap = _elem->isa_aryptr();
2382 if (tap)
2383 return tap->ary()->ary_must_be_exact();
2384 return false;
2385 }
2386
2387 //==============================TypeValueType=======================================
2388
2389 //------------------------------make-------------------------------------------
2390 const TypeValueType* TypeValueType::make(ciValueKlass* vk, bool larval) {
2391 return (TypeValueType*)(new TypeValueType(vk, larval))->hashcons();
2392 }
2393
2394 //------------------------------meet-------------------------------------------
2395 // Compute the MEET of two types. It returns a new Type object.
2396 const Type* TypeValueType::xmeet(const Type* t) const {
2397 // Perform a fast test for common case; meeting the same types together.
2398 if(this == t) return this; // Meeting same type-rep?
2399
2400 // Current "this->_base" is ValueType
2401 switch (t->base()) { // switch on original type
2402
2403 case Int:
2404 case Long:
2405 case FloatTop:
2406 case FloatCon:
2407 case FloatBot:
2408 case DoubleTop:
2420
2421 case Top:
2422 return this;
2423
2424 case NarrowOop: {
2425 const Type* res = t->make_ptr()->xmeet(this);
2426 if (res->isa_ptr()) {
2427 return res->make_narrowoop();
2428 }
2429 return res;
2430 }
2431
2432 case AryPtr:
2433 case InstPtr: {
2434 return t->xmeet(this);
2435 }
2436
2437 case ValueType: {
2438 // All value types inherit from Object
2439 const TypeValueType* other = t->is_valuetype();
2440 if (_vk == other->_vk) {
2441 if (_larval == other->_larval ||
2442 !_larval) {
2443 return this;
2444 } else {
2445 return t;
2446 }
2447 }
2448 return TypeInstPtr::NOTNULL;
2449 }
2450
2451 default: // All else is a mistake
2452 typerr(t);
2453
2454 }
2455 return this;
2456 }
2457
2458 //------------------------------xdual------------------------------------------
2459 const Type* TypeValueType::xdual() const {
2460 return this;
2471 // Type-specific hashing function.
2472 int TypeValueType::hash(void) const {
2473 return (intptr_t)_vk;
2474 }
2475
2476 //------------------------------singleton--------------------------------------
2477 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple constants.
2478 bool TypeValueType::singleton(void) const {
2479 return false;
2480 }
2481
2482 //------------------------------empty------------------------------------------
2483 // TRUE if Type is a type with no values, FALSE otherwise.
2484 bool TypeValueType::empty(void) const {
2485 return false;
2486 }
2487
2488 //------------------------------dump2------------------------------------------
2489 #ifndef PRODUCT
2490 void TypeValueType::dump2(Dict &d, uint depth, outputStream* st) const {
2491 int count = _vk->nof_declared_nonstatic_fields();
2492 st->print("valuetype[%d]:{", count);
2493 st->print("%s", count != 0 ? _vk->declared_nonstatic_field_at(0)->type()->name() : "empty");
2494 for (int i = 1; i < count; ++i) {
2495 st->print(", %s", _vk->declared_nonstatic_field_at(i)->type()->name());
2496 }
2497 st->print("}%s", _larval?" : larval":"");
2498 }
2499 #endif
2500
2501 //==============================TypeVect=======================================
2502 // Convenience common pre-built types.
2503 const TypeVect *TypeVect::VECTS = NULL; // 32-bit vectors
2504 const TypeVect *TypeVect::VECTD = NULL; // 64-bit vectors
2505 const TypeVect *TypeVect::VECTX = NULL; // 128-bit vectors
2506 const TypeVect *TypeVect::VECTY = NULL; // 256-bit vectors
2507 const TypeVect *TypeVect::VECTZ = NULL; // 512-bit vectors
2508
2509 //------------------------------make-------------------------------------------
2510 const TypeVect* TypeVect::make(const Type *elem, uint length) {
4334 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, depth);
4335 }
4336
4337 const TypePtr *TypeInstPtr::with_instance_id(int instance_id) const {
4338 assert(is_known_instance(), "should be known");
4339 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, instance_id, _speculative, _inline_depth);
4340 }
4341
4342 //=============================================================================
4343 // Convenience common pre-built types.
4344 const TypeAryPtr *TypeAryPtr::RANGE;
4345 const TypeAryPtr *TypeAryPtr::OOPS;
4346 const TypeAryPtr *TypeAryPtr::NARROWOOPS;
4347 const TypeAryPtr *TypeAryPtr::BYTES;
4348 const TypeAryPtr *TypeAryPtr::SHORTS;
4349 const TypeAryPtr *TypeAryPtr::CHARS;
4350 const TypeAryPtr *TypeAryPtr::INTS;
4351 const TypeAryPtr *TypeAryPtr::LONGS;
4352 const TypeAryPtr *TypeAryPtr::FLOATS;
4353 const TypeAryPtr *TypeAryPtr::DOUBLES;
4354
4355 //------------------------------make-------------------------------------------
4356 const TypeAryPtr* TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, Offset offset, Offset field_offset,
4357 int instance_id, const TypePtr* speculative, int inline_depth) {
4358 assert(!(k == NULL && ary->_elem->isa_int()),
4359 "integral arrays must be pre-equipped with a class");
4360 if (!xk) xk = ary->ary_must_be_exact();
4361 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
4362 if (!UseExactTypes) xk = (ptr == Constant);
4363 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, field_offset, instance_id, false, speculative, inline_depth))->hashcons();
4364 }
4365
4366 //------------------------------make-------------------------------------------
4367 const TypeAryPtr* TypeAryPtr::make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, Offset offset, Offset field_offset,
4368 int instance_id, const TypePtr* speculative, int inline_depth,
4369 bool is_autobox_cache) {
4370 assert(!(k == NULL && ary->_elem->isa_int()),
4371 "integral arrays must be pre-equipped with a class");
4372 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" );
4373 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact();
5329 return ft;
5330 }
5331
5332 //----------------------compute_klass------------------------------------------
5333 // Compute the defining klass for this class
5334 ciKlass* TypeAryPtr::compute_klass(DEBUG_ONLY(bool verify)) const {
5335 // Compute _klass based on element type.
5336 ciKlass* k_ary = NULL;
5337 const TypeAryPtr *tary;
5338 const Type* el = elem();
5339 if (el->isa_narrowoop()) {
5340 el = el->make_ptr();
5341 }
5342
5343 // Get element klass
5344 if (el->isa_instptr()) {
5345 // Compute object array klass from element klass
5346 bool null_free = el->is_valuetypeptr() && el->isa_instptr()->ptr() != TypePtr::TopPTR && !el->isa_instptr()->maybe_null();
5347 k_ary = ciArrayKlass::make(el->is_oopptr()->klass(), null_free);
5348 } else if (el->isa_valuetype()) {
5349 k_ary = ciArrayKlass::make(el->value_klass(), /* null_free */ true);
5350 } else if ((tary = el->isa_aryptr()) != NULL) {
5351 // Compute array klass from element klass
5352 ciKlass* k_elem = tary->klass();
5353 // If element type is something like bottom[], k_elem will be null.
5354 if (k_elem != NULL)
5355 k_ary = ciObjArrayKlass::make(k_elem);
5356 } else if ((el->base() == Type::Top) ||
5357 (el->base() == Type::Bottom)) {
5358 // element type of Bottom occurs from meet of basic type
5359 // and object; Top occurs when doing join on Bottom.
5360 // Leave k_ary at NULL.
5361 } else {
5362 // Cannot compute array klass directly from basic type,
5363 // since subtypes of TypeInt all have basic type T_INT.
5364 #ifdef ASSERT
5365 if (verify && el->isa_int()) {
5366 // Check simple cases when verifying klass.
5367 BasicType bt = T_ILLEGAL;
5368 if (el == TypeInt::BYTE) {
5369 bt = T_BYTE;
|
594
595 const Type **fmembar = TypeTuple::fields(0);
596 TypeTuple::MEMBAR = TypeTuple::make(TypeFunc::Parms+0, fmembar);
597
598 const Type **fsc = (const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
599 fsc[0] = TypeInt::CC;
600 fsc[1] = Type::MEMORY;
601 TypeTuple::STORECONDITIONAL = TypeTuple::make(2, fsc);
602
603 TypeInstPtr::NOTNULL = TypeInstPtr::make(TypePtr::NotNull, current->env()->Object_klass());
604 TypeInstPtr::BOTTOM = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass());
605 TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass());
606 TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(),
607 false, 0, Offset(oopDesc::mark_offset_in_bytes()));
608 TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(),
609 false, 0, Offset(oopDesc::klass_offset_in_bytes()));
610 TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, Offset::bottom, TypeOopPtr::InstanceBot);
611
612 TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, Offset::bottom);
613
614 TypeValueType::BOTTOM = TypeValueType::make(NULL);
615
616 TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR );
617 TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM );
618
619 TypeNarrowKlass::NULL_PTR = TypeNarrowKlass::make( TypePtr::NULL_PTR );
620
621 mreg2type[Op_Node] = Type::BOTTOM;
622 mreg2type[Op_Set ] = 0;
623 mreg2type[Op_RegN] = TypeNarrowOop::BOTTOM;
624 mreg2type[Op_RegI] = TypeInt::INT;
625 mreg2type[Op_RegP] = TypePtr::BOTTOM;
626 mreg2type[Op_RegF] = Type::FLOAT;
627 mreg2type[Op_RegD] = Type::DOUBLE;
628 mreg2type[Op_RegL] = TypeLong::LONG;
629 mreg2type[Op_RegFlags] = TypeInt::CC;
630
631 TypeAryPtr::RANGE = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::BOTTOM,TypeInt::POS), NULL /* current->env()->Object_klass() */, false, Offset(arrayOopDesc::length_offset_in_bytes()));
632
633 TypeAryPtr::NARROWOOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeNarrowOop::BOTTOM, TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Offset::bottom);
634
635 #ifdef _LP64
636 if (UseCompressedOops) {
637 assert(TypeAryPtr::NARROWOOPS->is_ptr_to_narrowoop(), "array of narrow oops must be ptr to narrow oop");
638 TypeAryPtr::OOPS = TypeAryPtr::NARROWOOPS;
639 } else
640 #endif
641 {
642 // There is no shared klass for Object[]. See note in TypeAryPtr::klass().
643 TypeAryPtr::OOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInstPtr::BOTTOM,TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Offset::bottom);
644 }
645 TypeAryPtr::BYTES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::BYTE ,TypeInt::POS), ciTypeArrayKlass::make(T_BYTE), true, Offset::bottom);
646 TypeAryPtr::SHORTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::SHORT ,TypeInt::POS), ciTypeArrayKlass::make(T_SHORT), true, Offset::bottom);
647 TypeAryPtr::CHARS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::CHAR ,TypeInt::POS), ciTypeArrayKlass::make(T_CHAR), true, Offset::bottom);
648 TypeAryPtr::INTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::INT ,TypeInt::POS), ciTypeArrayKlass::make(T_INT), true, Offset::bottom);
649 TypeAryPtr::LONGS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeLong::LONG ,TypeInt::POS), ciTypeArrayKlass::make(T_LONG), true, Offset::bottom);
650 TypeAryPtr::FLOATS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::FLOAT ,TypeInt::POS), ciTypeArrayKlass::make(T_FLOAT), true, Offset::bottom);
651 TypeAryPtr::DOUBLES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::DOUBLE ,TypeInt::POS), ciTypeArrayKlass::make(T_DOUBLE), true, Offset::bottom);
652 TypeAryPtr::VALUES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeValueType::BOTTOM,TypeInt::POS), NULL, false, Offset::bottom);
653
654 // Nobody should ask _array_body_type[T_NARROWOOP]. Use NULL as assert.
655 TypeAryPtr::_array_body_type[T_NARROWOOP] = NULL;
656 TypeAryPtr::_array_body_type[T_OBJECT] = TypeAryPtr::OOPS;
657 TypeAryPtr::_array_body_type[T_VALUETYPE] = TypeAryPtr::OOPS;
658 TypeAryPtr::_array_body_type[T_ARRAY] = TypeAryPtr::OOPS; // arrays are stored in oop arrays
659 TypeAryPtr::_array_body_type[T_BYTE] = TypeAryPtr::BYTES;
660 TypeAryPtr::_array_body_type[T_BOOLEAN] = TypeAryPtr::BYTES; // boolean[] is a byte array
661 TypeAryPtr::_array_body_type[T_SHORT] = TypeAryPtr::SHORTS;
662 TypeAryPtr::_array_body_type[T_CHAR] = TypeAryPtr::CHARS;
663 TypeAryPtr::_array_body_type[T_INT] = TypeAryPtr::INTS;
664 TypeAryPtr::_array_body_type[T_LONG] = TypeAryPtr::LONGS;
665 TypeAryPtr::_array_body_type[T_FLOAT] = TypeAryPtr::FLOATS;
666 TypeAryPtr::_array_body_type[T_DOUBLE] = TypeAryPtr::DOUBLES;
667
668 TypeKlassPtr::OBJECT = TypeKlassPtr::make(TypePtr::NotNull, current->env()->Object_klass(), Offset(0) );
669 TypeKlassPtr::OBJECT_OR_NULL = TypeKlassPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), Offset(0) );
670
671 const Type **fi2c = TypeTuple::fields(2);
672 fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // Method*
2372 if (tklass->as_instance_klass()->is_final()) {
2373 if (tinst->is_valuetypeptr() && (tinst->ptr() == TypePtr::BotPTR || tinst->ptr() == TypePtr::TopPTR)) {
2374 return false;
2375 }
2376 return true;
2377 }
2378 return false;
2379 }
2380 const TypeAryPtr* tap;
2381 if (_elem->isa_narrowoop())
2382 tap = _elem->make_ptr()->isa_aryptr();
2383 else
2384 tap = _elem->isa_aryptr();
2385 if (tap)
2386 return tap->ary()->ary_must_be_exact();
2387 return false;
2388 }
2389
2390 //==============================TypeValueType=======================================
2391
2392 const TypeValueType *TypeValueType::BOTTOM;
2393
2394 //------------------------------make-------------------------------------------
2395 const TypeValueType* TypeValueType::make(ciValueKlass* vk, bool larval) {
2396 return (TypeValueType*)(new TypeValueType(vk, larval))->hashcons();
2397 }
2398
2399 //------------------------------meet-------------------------------------------
2400 // Compute the MEET of two types. It returns a new Type object.
2401 const Type* TypeValueType::xmeet(const Type* t) const {
2402 // Perform a fast test for common case; meeting the same types together.
2403 if(this == t) return this; // Meeting same type-rep?
2404
2405 // Current "this->_base" is ValueType
2406 switch (t->base()) { // switch on original type
2407
2408 case Int:
2409 case Long:
2410 case FloatTop:
2411 case FloatCon:
2412 case FloatBot:
2413 case DoubleTop:
2425
2426 case Top:
2427 return this;
2428
2429 case NarrowOop: {
2430 const Type* res = t->make_ptr()->xmeet(this);
2431 if (res->isa_ptr()) {
2432 return res->make_narrowoop();
2433 }
2434 return res;
2435 }
2436
2437 case AryPtr:
2438 case InstPtr: {
2439 return t->xmeet(this);
2440 }
2441
2442 case ValueType: {
2443 // All value types inherit from Object
2444 const TypeValueType* other = t->is_valuetype();
2445 if (_vk == NULL) {
2446 return this;
2447 } else if (other->_vk == NULL) {
2448 return other;
2449 } else if (_vk == other->_vk) {
2450 if (_larval == other->_larval ||
2451 !_larval) {
2452 return this;
2453 } else {
2454 return t;
2455 }
2456 }
2457 return TypeInstPtr::NOTNULL;
2458 }
2459
2460 default: // All else is a mistake
2461 typerr(t);
2462
2463 }
2464 return this;
2465 }
2466
2467 //------------------------------xdual------------------------------------------
2468 const Type* TypeValueType::xdual() const {
2469 return this;
2480 // Type-specific hashing function.
2481 int TypeValueType::hash(void) const {
2482 return (intptr_t)_vk;
2483 }
2484
2485 //------------------------------singleton--------------------------------------
2486 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple constants.
2487 bool TypeValueType::singleton(void) const {
2488 return false;
2489 }
2490
2491 //------------------------------empty------------------------------------------
2492 // TRUE if Type is a type with no values, FALSE otherwise.
2493 bool TypeValueType::empty(void) const {
2494 return false;
2495 }
2496
2497 //------------------------------dump2------------------------------------------
2498 #ifndef PRODUCT
2499 void TypeValueType::dump2(Dict &d, uint depth, outputStream* st) const {
2500 if (_vk == NULL) {
2501 st->print("BOTTOM valuetype");
2502 return;
2503 }
2504 int count = _vk->nof_declared_nonstatic_fields();
2505 st->print("valuetype[%d]:{", count);
2506 st->print("%s", count != 0 ? _vk->declared_nonstatic_field_at(0)->type()->name() : "empty");
2507 for (int i = 1; i < count; ++i) {
2508 st->print(", %s", _vk->declared_nonstatic_field_at(i)->type()->name());
2509 }
2510 st->print("}%s", _larval?" : larval":"");
2511 }
2512 #endif
2513
2514 //==============================TypeVect=======================================
2515 // Convenience common pre-built types.
2516 const TypeVect *TypeVect::VECTS = NULL; // 32-bit vectors
2517 const TypeVect *TypeVect::VECTD = NULL; // 64-bit vectors
2518 const TypeVect *TypeVect::VECTX = NULL; // 128-bit vectors
2519 const TypeVect *TypeVect::VECTY = NULL; // 256-bit vectors
2520 const TypeVect *TypeVect::VECTZ = NULL; // 512-bit vectors
2521
2522 //------------------------------make-------------------------------------------
2523 const TypeVect* TypeVect::make(const Type *elem, uint length) {
4347 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, depth);
4348 }
4349
4350 const TypePtr *TypeInstPtr::with_instance_id(int instance_id) const {
4351 assert(is_known_instance(), "should be known");
4352 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, instance_id, _speculative, _inline_depth);
4353 }
4354
4355 //=============================================================================
4356 // Convenience common pre-built types.
4357 const TypeAryPtr *TypeAryPtr::RANGE;
4358 const TypeAryPtr *TypeAryPtr::OOPS;
4359 const TypeAryPtr *TypeAryPtr::NARROWOOPS;
4360 const TypeAryPtr *TypeAryPtr::BYTES;
4361 const TypeAryPtr *TypeAryPtr::SHORTS;
4362 const TypeAryPtr *TypeAryPtr::CHARS;
4363 const TypeAryPtr *TypeAryPtr::INTS;
4364 const TypeAryPtr *TypeAryPtr::LONGS;
4365 const TypeAryPtr *TypeAryPtr::FLOATS;
4366 const TypeAryPtr *TypeAryPtr::DOUBLES;
4367 const TypeAryPtr *TypeAryPtr::VALUES;
4368
4369 //------------------------------make-------------------------------------------
4370 const TypeAryPtr* TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, Offset offset, Offset field_offset,
4371 int instance_id, const TypePtr* speculative, int inline_depth) {
4372 assert(!(k == NULL && ary->_elem->isa_int()),
4373 "integral arrays must be pre-equipped with a class");
4374 if (!xk) xk = ary->ary_must_be_exact();
4375 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
4376 if (!UseExactTypes) xk = (ptr == Constant);
4377 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, field_offset, instance_id, false, speculative, inline_depth))->hashcons();
4378 }
4379
4380 //------------------------------make-------------------------------------------
4381 const TypeAryPtr* TypeAryPtr::make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, Offset offset, Offset field_offset,
4382 int instance_id, const TypePtr* speculative, int inline_depth,
4383 bool is_autobox_cache) {
4384 assert(!(k == NULL && ary->_elem->isa_int()),
4385 "integral arrays must be pre-equipped with a class");
4386 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" );
4387 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact();
5343 return ft;
5344 }
5345
5346 //----------------------compute_klass------------------------------------------
5347 // Compute the defining klass for this class
5348 ciKlass* TypeAryPtr::compute_klass(DEBUG_ONLY(bool verify)) const {
5349 // Compute _klass based on element type.
5350 ciKlass* k_ary = NULL;
5351 const TypeAryPtr *tary;
5352 const Type* el = elem();
5353 if (el->isa_narrowoop()) {
5354 el = el->make_ptr();
5355 }
5356
5357 // Get element klass
5358 if (el->isa_instptr()) {
5359 // Compute object array klass from element klass
5360 bool null_free = el->is_valuetypeptr() && el->isa_instptr()->ptr() != TypePtr::TopPTR && !el->isa_instptr()->maybe_null();
5361 k_ary = ciArrayKlass::make(el->is_oopptr()->klass(), null_free);
5362 } else if (el->isa_valuetype()) {
5363 if (el->value_klass() != NULL) {
5364 k_ary = ciArrayKlass::make(el->value_klass(), /* null_free */ true);
5365 }
5366 } else if ((tary = el->isa_aryptr()) != NULL) {
5367 // Compute array klass from element klass
5368 ciKlass* k_elem = tary->klass();
5369 // If element type is something like bottom[], k_elem will be null.
5370 if (k_elem != NULL)
5371 k_ary = ciObjArrayKlass::make(k_elem);
5372 } else if ((el->base() == Type::Top) ||
5373 (el->base() == Type::Bottom)) {
5374 // element type of Bottom occurs from meet of basic type
5375 // and object; Top occurs when doing join on Bottom.
5376 // Leave k_ary at NULL.
5377 } else {
5378 // Cannot compute array klass directly from basic type,
5379 // since subtypes of TypeInt all have basic type T_INT.
5380 #ifdef ASSERT
5381 if (verify && el->isa_int()) {
5382 // Check simple cases when verifying klass.
5383 BasicType bt = T_ILLEGAL;
5384 if (el == TypeInt::BYTE) {
5385 bt = T_BYTE;
|