comparison src/share/vm/opto/type.cpp @ 1000:a1423fe86a18

Merge
author trims
date Fri, 09 Oct 2009 15:18:52 -0700
parents 6a8ccac44f41
children 03b336640699
comparison
equal deleted inserted replaced
984:6ddec5389232 1000:a1423fe86a18
294 TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass()); 294 TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass());
295 TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), 295 TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(),
296 false, 0, oopDesc::mark_offset_in_bytes()); 296 false, 0, oopDesc::mark_offset_in_bytes());
297 TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), 297 TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(),
298 false, 0, oopDesc::klass_offset_in_bytes()); 298 false, 0, oopDesc::klass_offset_in_bytes());
299 TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot); 299 TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot);
300 300
301 TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR ); 301 TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR );
302 TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM ); 302 TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM );
303 303
304 mreg2type[Op_Node] = Type::BOTTOM; 304 mreg2type[Op_Node] = Type::BOTTOM;
490 //----------------------interface_vs_oop--------------------------------------- 490 //----------------------interface_vs_oop---------------------------------------
491 #ifdef ASSERT 491 #ifdef ASSERT
492 bool Type::interface_vs_oop(const Type *t) const { 492 bool Type::interface_vs_oop(const Type *t) const {
493 bool result = false; 493 bool result = false;
494 494
495 const TypeInstPtr* this_inst = this->isa_instptr(); 495 const TypePtr* this_ptr = this->make_ptr(); // In case it is narrow_oop
496 const TypeInstPtr* t_inst = t->isa_instptr(); 496 const TypePtr* t_ptr = t->make_ptr();
497 if( this_ptr == NULL || t_ptr == NULL )
498 return result;
499
500 const TypeInstPtr* this_inst = this_ptr->isa_instptr();
501 const TypeInstPtr* t_inst = t_ptr->isa_instptr();
497 if( this_inst && this_inst->is_loaded() && t_inst && t_inst->is_loaded() ) { 502 if( this_inst && this_inst->is_loaded() && t_inst && t_inst->is_loaded() ) {
498 bool this_interface = this_inst->klass()->is_interface(); 503 bool this_interface = this_inst->klass()->is_interface();
499 bool t_interface = t_inst->klass()->is_interface(); 504 bool t_interface = t_inst->klass()->is_interface();
500 result = this_interface ^ t_interface; 505 result = this_interface ^ t_interface;
501 } 506 }
2247 2252
2248 //------------------------------cast_to_ptr_type------------------------------- 2253 //------------------------------cast_to_ptr_type-------------------------------
2249 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { 2254 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
2250 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); 2255 assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
2251 if( ptr == _ptr ) return this; 2256 if( ptr == _ptr ) return this;
2252 return make(ptr, _offset); 2257 return make(ptr, _offset, _instance_id);
2253 } 2258 }
2254 2259
2255 //-----------------------------cast_to_instance_id---------------------------- 2260 //-----------------------------cast_to_instance_id----------------------------
2256 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const { 2261 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
2257 // There are no instances of a general oop. 2262 // There are no instances of a general oop.
2317 switch (tp->ptr()) { 2322 switch (tp->ptr()) {
2318 case Null: 2323 case Null:
2319 if (ptr == Null) return TypePtr::make(AnyPtr, ptr, offset); 2324 if (ptr == Null) return TypePtr::make(AnyPtr, ptr, offset);
2320 // else fall through: 2325 // else fall through:
2321 case TopPTR: 2326 case TopPTR:
2322 case AnyNull: 2327 case AnyNull: {
2323 return make(ptr, offset); 2328 int instance_id = meet_instance_id(InstanceTop);
2329 return make(ptr, offset, instance_id);
2330 }
2324 case BotPTR: 2331 case BotPTR:
2325 case NotNull: 2332 case NotNull:
2326 return TypePtr::make(AnyPtr, ptr, offset); 2333 return TypePtr::make(AnyPtr, ptr, offset);
2327 default: typerr(t); 2334 default: typerr(t);
2328 } 2335 }
2409 } 2416 }
2410 } 2417 }
2411 2418
2412 //------------------------------make_from_constant----------------------------- 2419 //------------------------------make_from_constant-----------------------------
2413 // Make a java pointer from an oop constant 2420 // Make a java pointer from an oop constant
2414 const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o) { 2421 const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o, bool require_constant) {
2415 if (o->is_method_data() || o->is_method()) { 2422 if (o->is_method_data() || o->is_method()) {
2416 // Treat much like a typeArray of bytes, like below, but fake the type... 2423 // Treat much like a typeArray of bytes, like below, but fake the type...
2417 assert(o->has_encoding(), "must be a perm space object");
2418 const Type* etype = (Type*)get_const_basic_type(T_BYTE); 2424 const Type* etype = (Type*)get_const_basic_type(T_BYTE);
2419 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); 2425 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS);
2420 ciKlass *klass = ciTypeArrayKlass::make((BasicType) T_BYTE); 2426 ciKlass *klass = ciTypeArrayKlass::make((BasicType) T_BYTE);
2421 assert(o->has_encoding(), "method data oops should be tenured"); 2427 assert(o->can_be_constant(), "method data oops should be tenured");
2422 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); 2428 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
2423 return arr; 2429 return arr;
2424 } else { 2430 } else {
2425 assert(o->is_java_object(), "must be java language object"); 2431 assert(o->is_java_object(), "must be java language object");
2426 assert(!o->is_null_object(), "null object not yet handled here."); 2432 assert(!o->is_null_object(), "null object not yet handled here.");
2427 ciKlass *klass = o->klass(); 2433 ciKlass *klass = o->klass();
2428 if (klass->is_instance_klass()) { 2434 if (klass->is_instance_klass()) {
2429 // Element is an instance 2435 // Element is an instance
2430 if (!o->has_encoding()) { // not a perm-space constant 2436 if (require_constant) {
2431 // %%% remove this restriction by rewriting non-perm ConPNodes in a later phase 2437 if (!o->can_be_constant()) return NULL;
2438 } else if (!o->should_be_constant()) {
2432 return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0); 2439 return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0);
2433 } 2440 }
2434 return TypeInstPtr::make(o); 2441 return TypeInstPtr::make(o);
2435 } else if (klass->is_obj_array_klass()) { 2442 } else if (klass->is_obj_array_klass()) {
2436 // Element is an object array. Recursively call ourself. 2443 // Element is an object array. Recursively call ourself.
2438 TypeOopPtr::make_from_klass_raw(klass->as_obj_array_klass()->element_klass()); 2445 TypeOopPtr::make_from_klass_raw(klass->as_obj_array_klass()->element_klass());
2439 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); 2446 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
2440 // We used to pass NotNull in here, asserting that the sub-arrays 2447 // We used to pass NotNull in here, asserting that the sub-arrays
2441 // are all not-null. This is not true in generally, as code can 2448 // are all not-null. This is not true in generally, as code can
2442 // slam NULLs down in the subarrays. 2449 // slam NULLs down in the subarrays.
2443 if (!o->has_encoding()) { // not a perm-space constant 2450 if (require_constant) {
2444 // %%% remove this restriction by rewriting non-perm ConPNodes in a later phase 2451 if (!o->can_be_constant()) return NULL;
2452 } else if (!o->should_be_constant()) {
2445 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); 2453 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
2446 } 2454 }
2447 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); 2455 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
2448 return arr; 2456 return arr;
2449 } else if (klass->is_type_array_klass()) { 2457 } else if (klass->is_type_array_klass()) {
2451 const Type* etype = 2459 const Type* etype =
2452 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type()); 2460 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type());
2453 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); 2461 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
2454 // We used to pass NotNull in here, asserting that the array pointer 2462 // We used to pass NotNull in here, asserting that the array pointer
2455 // is not-null. That was not true in general. 2463 // is not-null. That was not true in general.
2456 if (!o->has_encoding()) { // not a perm-space constant 2464 if (require_constant) {
2457 // %%% remove this restriction by rewriting non-perm ConPNodes in a later phase 2465 if (!o->can_be_constant()) return NULL;
2466 } else if (!o->should_be_constant()) {
2458 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); 2467 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
2459 } 2468 }
2460 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); 2469 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
2461 return arr; 2470 return arr;
2462 } 2471 }
2481 // but this assertion here is to help prevent its occurence. 2490 // but this assertion here is to help prevent its occurence.
2482 tty->print_cr("Found oop constant with non-zero offset"); 2491 tty->print_cr("Found oop constant with non-zero offset");
2483 ShouldNotReachHere(); 2492 ShouldNotReachHere();
2484 } 2493 }
2485 2494
2486 return (intptr_t)const_oop()->encoding(); 2495 return (intptr_t)const_oop()->constant_encoding();
2487 } 2496 }
2488 2497
2489 2498
2490 //-----------------------------filter------------------------------------------ 2499 //-----------------------------filter------------------------------------------
2491 // Do not allow interface-vs.-noninterface joins to collapse to top. 2500 // Do not allow interface-vs.-noninterface joins to collapse to top.
2589 return (_offset == 0) && !below_centerline(_ptr); 2598 return (_offset == 0) && !below_centerline(_ptr);
2590 } 2599 }
2591 2600
2592 //------------------------------add_offset------------------------------------- 2601 //------------------------------add_offset-------------------------------------
2593 const TypePtr *TypeOopPtr::add_offset( intptr_t offset ) const { 2602 const TypePtr *TypeOopPtr::add_offset( intptr_t offset ) const {
2594 return make( _ptr, xadd_offset(offset) ); 2603 return make( _ptr, xadd_offset(offset), _instance_id);
2595 } 2604 }
2596 2605
2597 //------------------------------meet_instance_id-------------------------------- 2606 //------------------------------meet_instance_id--------------------------------
2598 int TypeOopPtr::meet_instance_id( int instance_id ) const { 2607 int TypeOopPtr::meet_instance_id( int instance_id ) const {
2599 // Either is 'TOP' instance? Return the other instance! 2608 // Either is 'TOP' instance? Return the other instance!
2692 // Compute the MEET of two InstPtrs when at least one is unloaded. 2701 // Compute the MEET of two InstPtrs when at least one is unloaded.
2693 // Assume classes are different since called after check for same name/class-loader 2702 // Assume classes are different since called after check for same name/class-loader
2694 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { 2703 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const {
2695 int off = meet_offset(tinst->offset()); 2704 int off = meet_offset(tinst->offset());
2696 PTR ptr = meet_ptr(tinst->ptr()); 2705 PTR ptr = meet_ptr(tinst->ptr());
2706 int instance_id = meet_instance_id(tinst->instance_id());
2697 2707
2698 const TypeInstPtr *loaded = is_loaded() ? this : tinst; 2708 const TypeInstPtr *loaded = is_loaded() ? this : tinst;
2699 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; 2709 const TypeInstPtr *unloaded = is_loaded() ? tinst : this;
2700 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) { 2710 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) {
2701 // 2711 //
2712 // BOTTOM | ........................Object-BOTTOM ..................| 2722 // BOTTOM | ........................Object-BOTTOM ..................|
2713 // 2723 //
2714 assert(loaded->ptr() != TypePtr::Null, "insanity check"); 2724 assert(loaded->ptr() != TypePtr::Null, "insanity check");
2715 // 2725 //
2716 if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; } 2726 if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; }
2717 else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make( ptr, unloaded->klass() ); } 2727 else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make( ptr, unloaded->klass(), false, NULL, off, instance_id ); }
2718 else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } 2728 else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; }
2719 else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) { 2729 else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) {
2720 if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } 2730 if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; }
2721 else { return TypeInstPtr::NOTNULL; } 2731 else { return TypeInstPtr::NOTNULL; }
2722 } 2732 }
3336 return make( ptr, const_oop(), tary, lazy_klass, xk, off, instance_id ); 3346 return make( ptr, const_oop(), tary, lazy_klass, xk, off, instance_id );
3337 case Constant: { 3347 case Constant: {
3338 ciObject* o = const_oop(); 3348 ciObject* o = const_oop();
3339 if( _ptr == Constant ) { 3349 if( _ptr == Constant ) {
3340 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) { 3350 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) {
3351 xk = (klass() == tap->klass());
3341 ptr = NotNull; 3352 ptr = NotNull;
3342 o = NULL; 3353 o = NULL;
3343 instance_id = InstanceBot; 3354 instance_id = InstanceBot;
3355 } else {
3356 xk = true;
3344 } 3357 }
3345 } else if( above_centerline(_ptr) ) { 3358 } else if( above_centerline(_ptr) ) {
3346 o = tap->const_oop(); 3359 o = tap->const_oop();
3360 xk = true;
3361 } else {
3362 xk = this->_klass_is_exact;
3347 } 3363 }
3348 xk = true;
3349 return TypeAryPtr::make( ptr, o, tary, tap->_klass, xk, off, instance_id ); 3364 return TypeAryPtr::make( ptr, o, tary, tap->_klass, xk, off, instance_id );
3350 } 3365 }
3351 case NotNull: 3366 case NotNull:
3352 case BotPTR: 3367 case BotPTR:
3353 // Compute new klass on demand, do not use tap->_klass 3368 // Compute new klass on demand, do not use tap->_klass