2454 // to a handle at compile time. This handle is embedded in the generated
2455 // code and dereferenced at the time the nmethod is made. Until that time,
2456 // it is not reasonable to do arithmetic with the addresses of oops (we don't
2457 // have access to the addresses!). This does not seem to currently happen,
2458 // but this assertion here is to help prevent its occurrance.
2459 tty->print_cr("Found oop constant with non-zero offset");
2460 ShouldNotReachHere();
2461 }
2462
2463 return (intptr_t)const_oop()->encoding();
2464 }
2465
2466
2467 //-----------------------------filter------------------------------------------
2468 // Do not allow interface-vs.-noninterface joins to collapse to top.
2469 const Type *TypeOopPtr::filter( const Type *kills ) const {
2470
2471 const Type* ft = join(kills);
2472 const TypeInstPtr* ftip = ft->isa_instptr();
2473 const TypeInstPtr* ktip = kills->isa_instptr();
2474
2475 if (ft->empty()) {
2476 // Check for evil case of 'this' being a class and 'kills' expecting an
2477 // interface. This can happen because the bytecodes do not contain
2478 // enough type info to distinguish a Java-level interface variable
2479 // from a Java-level object variable. If we meet 2 classes which
2480 // both implement interface I, but their meet is at 'j/l/O' which
2481 // doesn't implement I, we have no way to tell if the result should
2482 // be 'I' or 'j/l/O'. Thus we'll pick 'j/l/O'. If this then flows
2483 // into a Phi which "knows" it's an Interface type we'll have to
2484 // uplift the type.
2485 if (!empty() && ktip != NULL && ktip->is_loaded() && ktip->klass()->is_interface())
2486 return kills; // Uplift to interface
2487
2488 return Type::TOP; // Canonical empty value
2489 }
2490
2491 // If we have an interface-typed Phi or cast and we narrow to a class type,
2492 // the join should report back the class. However, if we have a J/L/Object
2493 // class-typed Phi and an interface flows in, it's possible that the meet &
2494 // join report an interface back out. This isn't possible but happens
2495 // because the type system doesn't interact well with interfaces.
2496 if (ftip != NULL && ktip != NULL &&
2497 ftip->is_loaded() && ftip->klass()->is_interface() &&
2498 ktip->is_loaded() && !ktip->klass()->is_interface()) {
2499 // Happens in a CTW of rt.jar, 320-341, no extra flags
2500 return ktip->cast_to_ptr_type(ftip->ptr());
2501 }
2502
2503 return ft;
2504 }
2505
2506 //------------------------------eq---------------------------------------------
2507 // Structural equality check for Type representations
2508 bool TypeOopPtr::eq( const Type *t ) const {
2509 const TypeOopPtr *a = (const TypeOopPtr*)t;
2510 if (_klass_is_exact != a->_klass_is_exact ||
2511 _instance_id != a->_instance_id) return false;
2512 ciObject* one = const_oop();
2513 ciObject* two = a->const_oop();
2514 if (one == NULL || two == NULL) {
2515 return (one == two) && TypePtr::eq(t);
2516 } else {
2517 return one->equals(two) && TypePtr::eq(t);
2518 }
2519 }
2520
2521 //------------------------------hash-------------------------------------------
|
2454 // to a handle at compile time. This handle is embedded in the generated
2455 // code and dereferenced at the time the nmethod is made. Until that time,
2456 // it is not reasonable to do arithmetic with the addresses of oops (we don't
2457 // have access to the addresses!). This does not seem to currently happen,
2458 // but this assertion here is to help prevent its occurrance.
2459 tty->print_cr("Found oop constant with non-zero offset");
2460 ShouldNotReachHere();
2461 }
2462
2463 return (intptr_t)const_oop()->encoding();
2464 }
2465
2466
2467 //-----------------------------filter------------------------------------------
2468 // Do not allow interface-vs.-noninterface joins to collapse to top.
2469 const Type *TypeOopPtr::filter( const Type *kills ) const {
2470
2471 const Type* ft = join(kills);
2472 const TypeInstPtr* ftip = ft->isa_instptr();
2473 const TypeInstPtr* ktip = kills->isa_instptr();
2474 const TypeKlassPtr* ftkp = ft->isa_klassptr();
2475 const TypeKlassPtr* ktkp = kills->isa_klassptr();
2476
2477 if (ft->empty()) {
2478 // Check for evil case of 'this' being a class and 'kills' expecting an
2479 // interface. This can happen because the bytecodes do not contain
2480 // enough type info to distinguish a Java-level interface variable
2481 // from a Java-level object variable. If we meet 2 classes which
2482 // both implement interface I, but their meet is at 'j/l/O' which
2483 // doesn't implement I, we have no way to tell if the result should
2484 // be 'I' or 'j/l/O'. Thus we'll pick 'j/l/O'. If this then flows
2485 // into a Phi which "knows" it's an Interface type we'll have to
2486 // uplift the type.
2487 if (!empty() && ktip != NULL && ktip->is_loaded() && ktip->klass()->is_interface())
2488 return kills; // Uplift to interface
2489 if (!empty() && ktkp != NULL && ktkp->klass()->is_loaded() && ktkp->klass()->is_interface())
2490 return kills; // Uplift to interface
2491
2492 return Type::TOP; // Canonical empty value
2493 }
2494
2495 // If we have an interface-typed Phi or cast and we narrow to a class type,
2496 // the join should report back the class. However, if we have a J/L/Object
2497 // class-typed Phi and an interface flows in, it's possible that the meet &
2498 // join report an interface back out. This isn't possible but happens
2499 // because the type system doesn't interact well with interfaces.
2500 if (ftip != NULL && ktip != NULL &&
2501 ftip->is_loaded() && ftip->klass()->is_interface() &&
2502 ktip->is_loaded() && !ktip->klass()->is_interface()) {
2503 // Happens in a CTW of rt.jar, 320-341, no extra flags
2504 return ktip->cast_to_ptr_type(ftip->ptr());
2505 }
2506 if (ftkp != NULL && ktkp != NULL &&
2507 ftkp->is_loaded() && ftkp->klass()->is_interface() &&
2508 ktkp->is_loaded() && !ktkp->klass()->is_interface()) {
2509 // Happens in a CTW of rt.jar, 320-341, no extra flags
2510 return ktkp->cast_to_ptr_type(ftkp->ptr());
2511 }
2512
2513 return ft;
2514 }
2515
2516 //------------------------------eq---------------------------------------------
2517 // Structural equality check for Type representations
2518 bool TypeOopPtr::eq( const Type *t ) const {
2519 const TypeOopPtr *a = (const TypeOopPtr*)t;
2520 if (_klass_is_exact != a->_klass_is_exact ||
2521 _instance_id != a->_instance_id) return false;
2522 ciObject* one = const_oop();
2523 ciObject* two = a->const_oop();
2524 if (one == NULL || two == NULL) {
2525 return (one == two) && TypePtr::eq(t);
2526 } else {
2527 return one->equals(two) && TypePtr::eq(t);
2528 }
2529 }
2530
2531 //------------------------------hash-------------------------------------------
|