< prev index next >

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

Print this page




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_OOP_INLINE_HPP
  26 #define SHARE_VM_OOPS_OOP_INLINE_HPP
  27 
  28 #include "gc_implementation/shared/ageTable.hpp"
  29 #include "gc_implementation/shared/markSweep.inline.hpp"
  30 #include "gc_interface/collectedHeap.inline.hpp"
  31 #include "memory/barrierSet.inline.hpp"
  32 #include "memory/cardTableModRefBS.hpp"
  33 #include "memory/genCollectedHeap.hpp"
  34 #include "memory/generation.hpp"
  35 #include "memory/specialized_oop_closures.hpp"
  36 #include "oops/arrayKlass.hpp"
  37 #include "oops/arrayOop.hpp"
  38 #include "oops/klass.inline.hpp"
  39 #include "oops/markOop.inline.hpp"
  40 #include "oops/oop.hpp"
  41 #include "runtime/atomic.inline.hpp"
  42 #include "runtime/orderAccess.inline.hpp"
  43 #include "runtime/os.hpp"
  44 #include "utilities/macros.hpp"
  45 
  46 // Implementation of all inlined member functions defined in oop.hpp
  47 // We need a separate file to avoid circular references
  48 
  49 inline void oopDesc::release_set_mark(markOop m) {
  50   OrderAccess::release_store_ptr(&_mark, m);
  51 }
  52 
  53 inline markOop oopDesc::cas_set_mark(markOop new_mark, markOop old_mark) {
  54   return (markOop) Atomic::cmpxchg_ptr(new_mark, &_mark, old_mark);
  55 }


 575   if (mark() != NULL) {
 576     return true;
 577   }
 578   return !SafepointSynchronize::is_at_safepoint();
 579 }
 580 
 581 
 582 // used only for asserts
 583 inline bool oopDesc::is_oop_or_null(bool ignore_mark_word) const {
 584   return this == NULL ? true : is_oop(ignore_mark_word);
 585 }
 586 
 587 #ifndef PRODUCT
 588 // used only for asserts
 589 inline bool oopDesc::is_unlocked_oop() const {
 590   if (!Universe::heap()->is_in_reserved(this)) return false;
 591   return mark()->is_unlocked();
 592 }
 593 #endif // PRODUCT
 594 
 595 inline void oopDesc::follow_contents(void) {
 596   assert (is_gc_marked(), "should be marked");
 597   klass()->oop_follow_contents(this);
 598 }
 599 
 600 inline bool oopDesc::is_scavengable() const {
 601   return Universe::heap()->is_scavengable(this);
 602 }
 603 
 604 // Used by scavengers
 605 inline bool oopDesc::is_forwarded() const {
 606   // The extra heap check is needed since the obj might be locked, in which case the
 607   // mark would point to a stack location and have the sentinel bit cleared
 608   return mark()->is_marked();
 609 }
 610 
 611 // Used by scavengers
 612 inline void oopDesc::forward_to(oop p) {
 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);


 689     set_displaced_mark(displaced_mark()->incr_age());
 690   } else {
 691     set_mark(mark()->incr_age());
 692   }
 693 }
 694 
 695 
 696 inline intptr_t oopDesc::identity_hash() {
 697   // Fast case; if the object is unlocked and the hash value is set, no locking is needed
 698   // Note: The mark must be read into local variable to avoid concurrent updates.
 699   markOop mrk = mark();
 700   if (mrk->is_unlocked() && !mrk->has_no_hash()) {
 701     return mrk->hash();
 702   } else if (mrk->is_marked()) {
 703     return mrk->hash();
 704   } else {
 705     return slow_identity_hash();
 706   }
 707 }
 708 
 709 inline int oopDesc::adjust_pointers() {




 710   debug_only(int check_size = size());
 711   int s = klass()->oop_adjust_pointers(this);
 712   assert(s == check_size, "should be the same");
 713   return s;
 714 }
 715 
























 716 #define OOP_ITERATE_DEFN(OopClosureType, nv_suffix)                        \
 717                                                                            \
 718 inline int oopDesc::oop_iterate(OopClosureType* blk) {                     \
 719   return klass()->oop_oop_iterate##nv_suffix(this, blk);               \
 720 }                                                                          \
 721                                                                            \
 722 inline int oopDesc::oop_iterate(OopClosureType* blk, MemRegion mr) {       \
 723   return klass()->oop_oop_iterate##nv_suffix##_m(this, blk, mr);       \
 724 }
 725 
 726 
 727 inline int oopDesc::oop_iterate_no_header(OopClosure* blk) {
 728   // The NoHeaderExtendedOopClosure wraps the OopClosure and proxies all
 729   // the do_oop calls, but turns off all other features in ExtendedOopClosure.
 730   NoHeaderExtendedOopClosure cl(blk);
 731   return oop_iterate(&cl);
 732 }
 733 
 734 inline int oopDesc::oop_iterate_no_header(OopClosure* blk, MemRegion mr) {
 735   NoHeaderExtendedOopClosure cl(blk);
 736   return oop_iterate(&cl, mr);
 737 }
 738 
 739 ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_ITERATE_DEFN)
 740 ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_ITERATE_DEFN)
 741 
 742 #if INCLUDE_ALL_GCS
 743 #define OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix)              \
 744                                                                            \
 745 inline int oopDesc::oop_iterate_backwards(OopClosureType* blk) {           \
 746   return klass()->oop_oop_iterate_backwards##nv_suffix(this, blk);     \
 747 }







 748 
 749 ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_ITERATE_BACKWARDS_DEFN)
 750 ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_ITERATE_BACKWARDS_DEFN)
 751 #endif // INCLUDE_ALL_GCS
 752 
 753 #endif // SHARE_VM_OOPS_OOP_INLINE_HPP


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_OOP_INLINE_HPP
  26 #define SHARE_VM_OOPS_OOP_INLINE_HPP
  27 
  28 #include "gc_implementation/shared/ageTable.hpp"

  29 #include "gc_interface/collectedHeap.inline.hpp"
  30 #include "memory/barrierSet.inline.hpp"
  31 #include "memory/cardTableModRefBS.hpp"
  32 #include "memory/genCollectedHeap.hpp"
  33 #include "memory/generation.hpp"

  34 #include "oops/arrayKlass.hpp"
  35 #include "oops/arrayOop.hpp"
  36 #include "oops/klass.inline.hpp"
  37 #include "oops/markOop.inline.hpp"
  38 #include "oops/oop.hpp"
  39 #include "runtime/atomic.inline.hpp"
  40 #include "runtime/orderAccess.inline.hpp"
  41 #include "runtime/os.hpp"
  42 #include "utilities/macros.hpp"
  43 
  44 // Implementation of all inlined member functions defined in oop.hpp
  45 // We need a separate file to avoid circular references
  46 
  47 inline void oopDesc::release_set_mark(markOop m) {
  48   OrderAccess::release_store_ptr(&_mark, m);
  49 }
  50 
  51 inline markOop oopDesc::cas_set_mark(markOop new_mark, markOop old_mark) {
  52   return (markOop) Atomic::cmpxchg_ptr(new_mark, &_mark, old_mark);
  53 }


 573   if (mark() != NULL) {
 574     return true;
 575   }
 576   return !SafepointSynchronize::is_at_safepoint();
 577 }
 578 
 579 
 580 // used only for asserts
 581 inline bool oopDesc::is_oop_or_null(bool ignore_mark_word) const {
 582   return this == NULL ? true : is_oop(ignore_mark_word);
 583 }
 584 
 585 #ifndef PRODUCT
 586 // used only for asserts
 587 inline bool oopDesc::is_unlocked_oop() const {
 588   if (!Universe::heap()->is_in_reserved(this)) return false;
 589   return mark()->is_unlocked();
 590 }
 591 #endif // PRODUCT
 592 





 593 inline bool oopDesc::is_scavengable() const {
 594   return Universe::heap()->is_scavengable(this);
 595 }
 596 
 597 // Used by scavengers
 598 inline bool oopDesc::is_forwarded() const {
 599   // The extra heap check is needed since the obj might be locked, in which case the
 600   // mark would point to a stack location and have the sentinel bit cleared
 601   return mark()->is_marked();
 602 }
 603 
 604 // Used by scavengers
 605 inline void oopDesc::forward_to(oop p) {
 606   assert(check_obj_alignment(p),
 607          "forwarding to something not aligned");
 608   assert(Universe::heap()->is_in_reserved(p),
 609          "forwarding to something not in heap");
 610   markOop m = markOopDesc::encode_pointer_as_mark(p);
 611   assert(m->decode_pointer() == p, "encoding must be reversable");
 612   set_mark(m);


 682     set_displaced_mark(displaced_mark()->incr_age());
 683   } else {
 684     set_mark(mark()->incr_age());
 685   }
 686 }
 687 
 688 
 689 inline intptr_t oopDesc::identity_hash() {
 690   // Fast case; if the object is unlocked and the hash value is set, no locking is needed
 691   // Note: The mark must be read into local variable to avoid concurrent updates.
 692   markOop mrk = mark();
 693   if (mrk->is_unlocked() && !mrk->has_no_hash()) {
 694     return mrk->hash();
 695   } else if (mrk->is_marked()) {
 696     return mrk->hash();
 697   } else {
 698     return slow_identity_hash();
 699   }
 700 }
 701 
 702 inline void oopDesc::ms_follow_contents() {
 703   klass()->oop_ms_follow_contents(this);
 704 }
 705 
 706 inline int oopDesc::ms_adjust_pointers() {
 707   debug_only(int check_size = size());
 708   int s = klass()->oop_ms_adjust_pointers(this);
 709   assert(s == check_size, "should be the same");
 710   return s;
 711 }
 712 
 713 #if INCLUDE_ALL_GCS
 714 inline void oopDesc::pc_follow_contents(ParCompactionManager* cm) {
 715   klass()->oop_pc_follow_contents(this, cm);
 716 }
 717 
 718 inline void oopDesc::pc_update_contents() {
 719   Klass* k = klass();
 720   if (!k->oop_is_typeArray()) {
 721     // It might contain oops beyond the header, so take the virtual call.
 722     k->oop_pc_update_pointers(this);
 723   }
 724   // Else skip it.  The TypeArrayKlass in the header never needs scavenging.
 725 }
 726 
 727 inline void oopDesc::ps_push_contents(PSPromotionManager* pm) {
 728   Klass* k = klass();
 729   if (!k->oop_is_typeArray()) {
 730     // It might contain oops beyond the header, so take the virtual call.
 731     k->oop_ps_push_contents(this, pm);
 732   }
 733   // Else skip it.  The TypeArrayKlass in the header never needs scavenging.
 734 }
 735 #endif
 736 
 737 #define OOP_ITERATE_DEFN(OopClosureType, nv_suffix)                   \
 738                                                                       \
 739 inline int oopDesc::oop_iterate(OopClosureType* blk) {                \
 740   return klass()->oop_oop_iterate##nv_suffix(this, blk);              \
 741 }                                                                     \
 742                                                                       \
 743 inline int oopDesc::oop_iterate(OopClosureType* blk, MemRegion mr) {  \
 744   return klass()->oop_oop_iterate##nv_suffix##_m(this, blk, mr);      \
 745 }
 746 
 747 
 748 inline int oopDesc::oop_iterate_no_header(OopClosure* blk) {
 749   // The NoHeaderExtendedOopClosure wraps the OopClosure and proxies all
 750   // the do_oop calls, but turns off all other features in ExtendedOopClosure.
 751   NoHeaderExtendedOopClosure cl(blk);
 752   return oop_iterate(&cl);
 753 }
 754 
 755 inline int oopDesc::oop_iterate_no_header(OopClosure* blk, MemRegion mr) {
 756   NoHeaderExtendedOopClosure cl(blk);
 757   return oop_iterate(&cl, mr);
 758 }
 759 



 760 #if INCLUDE_ALL_GCS
 761 #define OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix)       \
 762                                                                     \
 763 inline int oopDesc::oop_iterate_backwards(OopClosureType* blk) {    \
 764   return klass()->oop_oop_iterate_backwards##nv_suffix(this, blk);  \
 765 }
 766 #else
 767 #define OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix)
 768 #endif
 769 
 770 #define ALL_OOPDESC_OOP_ITERATE(OopClosureType, nv_suffix)  \
 771   OOP_ITERATE_DEFN(OopClosureType, nv_suffix)               \
 772   OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix)
 773 
 774 ALL_OOP_OOP_ITERATE_CLOSURES_1(ALL_OOPDESC_OOP_ITERATE)
 775 ALL_OOP_OOP_ITERATE_CLOSURES_2(ALL_OOPDESC_OOP_ITERATE)

 776 
 777 #endif // SHARE_VM_OOPS_OOP_INLINE_HPP
< prev index next >