< prev index next >

src/share/vm/oops/oop.inline.hpp

Print this page




 613   assert(check_obj_alignment(p),
 614          "forwarding to something not aligned");
 615   assert(Universe::heap()->is_in_reserved(p),
 616          "forwarding to something not in heap");
 617   markOop m = markOopDesc::encode_pointer_as_mark(p);
 618   assert(m->decode_pointer() == p, "encoding must be reversable");
 619   set_mark(m);
 620 }
 621 
 622 // Used by parallel scavengers
 623 inline bool oopDesc::cas_forward_to(oop p, markOop compare) {
 624   assert(check_obj_alignment(p),
 625          "forwarding to something not aligned");
 626   assert(Universe::heap()->is_in_reserved(p),
 627          "forwarding to something not in heap");
 628   markOop m = markOopDesc::encode_pointer_as_mark(p);
 629   assert(m->decode_pointer() == p, "encoding must be reversable");
 630   return cas_set_mark(m, compare) == compare;
 631 }
 632 
























 633 // Note that the forwardee is not the same thing as the displaced_mark.
 634 // The forwardee is used when copying during scavenge and mark-sweep.
 635 // It does need to clear the low two locking- and GC-related bits.
 636 inline oop oopDesc::forwardee() const {
 637   return (oop) mark()->decode_pointer();
 638 }
 639 
 640 inline bool oopDesc::has_displaced_mark() const {
 641   return mark()->has_displaced_mark_helper();
 642 }
 643 
 644 inline markOop oopDesc::displaced_mark() const {
 645   return mark()->displaced_mark_helper();
 646 }
 647 
 648 inline void oopDesc::set_displaced_mark(markOop m) {
 649   mark()->set_displaced_mark_helper(m);
 650 }
 651 
 652 // The following method needs to be MT safe.




 613   assert(check_obj_alignment(p),
 614          "forwarding to something not aligned");
 615   assert(Universe::heap()->is_in_reserved(p),
 616          "forwarding to something not in heap");
 617   markOop m = markOopDesc::encode_pointer_as_mark(p);
 618   assert(m->decode_pointer() == p, "encoding must be reversable");
 619   set_mark(m);
 620 }
 621 
 622 // Used by parallel scavengers
 623 inline bool oopDesc::cas_forward_to(oop p, markOop compare) {
 624   assert(check_obj_alignment(p),
 625          "forwarding to something not aligned");
 626   assert(Universe::heap()->is_in_reserved(p),
 627          "forwarding to something not in heap");
 628   markOop m = markOopDesc::encode_pointer_as_mark(p);
 629   assert(m->decode_pointer() == p, "encoding must be reversable");
 630   return cas_set_mark(m, compare) == compare;
 631 }
 632 
 633 #if INCLUDE_ALL_GCS
 634 inline oop oopDesc::forward_to_atomic(oop p) {
 635   markOop oldMark = mark();
 636   markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p);
 637   markOop curMark;
 638 
 639   assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable");
 640   assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this.");
 641 
 642   while (!oldMark->is_marked()) {
 643     curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark);
 644     assert(is_forwarded(), "object should have been forwarded");
 645     if (curMark == oldMark) {
 646       return NULL;
 647     }
 648     // If the CAS was unsuccessful then curMark->is_marked()
 649     // should return true as another thread has CAS'd in another
 650     // forwarding pointer.
 651     oldMark = curMark;
 652   }
 653   return forwardee();
 654 }
 655 #endif
 656 
 657 // Note that the forwardee is not the same thing as the displaced_mark.
 658 // The forwardee is used when copying during scavenge and mark-sweep.
 659 // It does need to clear the low two locking- and GC-related bits.
 660 inline oop oopDesc::forwardee() const {
 661   return (oop) mark()->decode_pointer();
 662 }
 663 
 664 inline bool oopDesc::has_displaced_mark() const {
 665   return mark()->has_displaced_mark_helper();
 666 }
 667 
 668 inline markOop oopDesc::displaced_mark() const {
 669   return mark()->displaced_mark_helper();
 670 }
 671 
 672 inline void oopDesc::set_displaced_mark(markOop m) {
 673   mark()->set_displaced_mark_helper(m);
 674 }
 675 
 676 // The following method needs to be MT safe.


< prev index next >