src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp

Print this page
rev 6923 : imported patch 8054819-rename-heapregionseq


  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_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
  27 
  28 #include "gc_implementation/g1/concurrentMark.hpp"
  29 #include "gc_implementation/g1/g1CollectedHeap.hpp"
  30 #include "gc_implementation/g1/g1AllocRegion.inline.hpp"
  31 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
  32 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"

  33 #include "gc_implementation/g1/heapRegionSet.inline.hpp"
  34 #include "gc_implementation/g1/heapRegionSeq.inline.hpp"
  35 #include "runtime/orderAccess.inline.hpp"
  36 #include "utilities/taskqueue.hpp"
  37 
  38 // Inline functions for G1CollectedHeap
  39 
  40 // Return the region with the given index. It assumes the index is valid.
  41 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrs.at(index); }
  42 
  43 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const {
  44   assert(is_in_reserved(addr),
  45          err_msg("Cannot calculate region index for address "PTR_FORMAT" that is outside of the heap ["PTR_FORMAT", "PTR_FORMAT")",
  46                  p2i(addr), p2i(_reserved.start()), p2i(_reserved.end())));
  47   return (uint)(pointer_delta(addr, _reserved.start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
  48 }
  49 
  50 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const {
  51   return _hrs.reserved().start() + index * HeapRegion::GrainWords;
  52 }
  53 
  54 template <class T>
  55 inline HeapRegion* G1CollectedHeap::heap_region_containing_raw(const T addr) const {
  56   assert(addr != NULL, "invariant");
  57   assert(is_in_g1_reserved((const void*) addr),
  58       err_msg("Address "PTR_FORMAT" is outside of the heap ranging from ["PTR_FORMAT" to "PTR_FORMAT")",
  59           p2i((void*)addr), p2i(g1_reserved().start()), p2i(g1_reserved().end())));
  60   return _hrs.addr_to_region((HeapWord*) addr);
  61 }
  62 
  63 template <class T>
  64 inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const {
  65   HeapRegion* hr = heap_region_containing_raw(addr);
  66   if (hr->continuesHumongous()) {
  67     return hr->humongous_start_region();
  68   }
  69   return hr;
  70 }
  71 
  72 inline void G1CollectedHeap::reset_gc_time_stamp() {
  73   _gc_time_stamp = 0;
  74   OrderAccess::fence();
  75   // Clear the cached CSet starting regions and time stamps.
  76   // Their validity is dependent on the GC timestamp.
  77   clear_cset_start_regions();
  78 }
  79 
  80 inline void G1CollectedHeap::increment_gc_time_stamp() {
  81   ++_gc_time_stamp;
  82   OrderAccess::fence();
  83 }
  84 
  85 inline void G1CollectedHeap::old_set_remove(HeapRegion* hr) {
  86   _old_set.remove(hr);
  87 }
  88 
  89 inline bool G1CollectedHeap::obj_in_cs(oop obj) {
  90   HeapRegion* r = _hrs.addr_to_region((HeapWord*) obj);
  91   return r != NULL && r->in_collection_set();
  92 }
  93 
  94 inline HeapWord* G1CollectedHeap::attempt_allocation(size_t word_size,
  95                                                      unsigned int* gc_count_before_ret,
  96                                                      int* gclocker_retry_count_ret) {
  97   assert_heap_not_locked_and_not_at_safepoint();
  98   assert(!isHumongous(word_size), "attempt_allocation() should not "
  99          "be called for humongous allocation requests");
 100 
 101   HeapWord* result = _mutator_alloc_region.attempt_allocation(word_size,
 102                                                       false /* bot_updates */);
 103   if (result == NULL) {
 104     result = attempt_allocation_slow(word_size,
 105                                      gc_count_before_ret,
 106                                      gclocker_retry_count_ret);
 107   }
 108   assert_heap_not_locked();
 109   if (result != NULL) {
 110     dirty_young_block(result, word_size);




  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_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
  27 
  28 #include "gc_implementation/g1/concurrentMark.hpp"
  29 #include "gc_implementation/g1/g1CollectedHeap.hpp"
  30 #include "gc_implementation/g1/g1AllocRegion.inline.hpp"
  31 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
  32 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
  33 #include "gc_implementation/g1/heapRegionManager.inline.hpp"
  34 #include "gc_implementation/g1/heapRegionSet.inline.hpp"

  35 #include "runtime/orderAccess.inline.hpp"
  36 #include "utilities/taskqueue.hpp"
  37 
  38 // Inline functions for G1CollectedHeap
  39 
  40 // Return the region with the given index. It assumes the index is valid.
  41 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrm.at(index); }
  42 
  43 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const {
  44   assert(is_in_reserved(addr),
  45          err_msg("Cannot calculate region index for address "PTR_FORMAT" that is outside of the heap ["PTR_FORMAT", "PTR_FORMAT")",
  46                  p2i(addr), p2i(_reserved.start()), p2i(_reserved.end())));
  47   return (uint)(pointer_delta(addr, _reserved.start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
  48 }
  49 
  50 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const {
  51   return _hrm.reserved().start() + index * HeapRegion::GrainWords;
  52 }
  53 
  54 template <class T>
  55 inline HeapRegion* G1CollectedHeap::heap_region_containing_raw(const T addr) const {
  56   assert(addr != NULL, "invariant");
  57   assert(is_in_g1_reserved((const void*) addr),
  58       err_msg("Address "PTR_FORMAT" is outside of the heap ranging from ["PTR_FORMAT" to "PTR_FORMAT")",
  59           p2i((void*)addr), p2i(g1_reserved().start()), p2i(g1_reserved().end())));
  60   return _hrm.addr_to_region((HeapWord*) addr);
  61 }
  62 
  63 template <class T>
  64 inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const {
  65   HeapRegion* hr = heap_region_containing_raw(addr);
  66   if (hr->continuesHumongous()) {
  67     return hr->humongous_start_region();
  68   }
  69   return hr;
  70 }
  71 
  72 inline void G1CollectedHeap::reset_gc_time_stamp() {
  73   _gc_time_stamp = 0;
  74   OrderAccess::fence();
  75   // Clear the cached CSet starting regions and time stamps.
  76   // Their validity is dependent on the GC timestamp.
  77   clear_cset_start_regions();
  78 }
  79 
  80 inline void G1CollectedHeap::increment_gc_time_stamp() {
  81   ++_gc_time_stamp;
  82   OrderAccess::fence();
  83 }
  84 
  85 inline void G1CollectedHeap::old_set_remove(HeapRegion* hr) {
  86   _old_set.remove(hr);
  87 }
  88 
  89 inline bool G1CollectedHeap::obj_in_cs(oop obj) {
  90   HeapRegion* r = _hrm.addr_to_region((HeapWord*) obj);
  91   return r != NULL && r->in_collection_set();
  92 }
  93 
  94 inline HeapWord* G1CollectedHeap::attempt_allocation(size_t word_size,
  95                                                      unsigned int* gc_count_before_ret,
  96                                                      int* gclocker_retry_count_ret) {
  97   assert_heap_not_locked_and_not_at_safepoint();
  98   assert(!isHumongous(word_size), "attempt_allocation() should not "
  99          "be called for humongous allocation requests");
 100 
 101   HeapWord* result = _mutator_alloc_region.attempt_allocation(word_size,
 102                                                       false /* bot_updates */);
 103   if (result == NULL) {
 104     result = attempt_allocation_slow(word_size,
 105                                      gc_count_before_ret,
 106                                      gclocker_retry_count_ret);
 107   }
 108   assert_heap_not_locked();
 109   if (result != NULL) {
 110     dirty_young_block(result, word_size);