< prev index next >

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

Print this page




  60 
  61 inline AllocationContextStats& G1CollectedHeap::allocation_context_stats() {
  62   return _allocation_context_stats;
  63 }
  64 
  65 // Return the region with the given index. It assumes the index is valid.
  66 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrm.at(index); }
  67 
  68 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const {
  69   assert(is_in_reserved(addr),
  70          "Cannot calculate region index for address " PTR_FORMAT " that is outside of the heap [" PTR_FORMAT ", " PTR_FORMAT ")",
  71          p2i(addr), p2i(reserved_region().start()), p2i(reserved_region().end()));
  72   return (uint)(pointer_delta(addr, reserved_region().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
  73 }
  74 
  75 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const {
  76   return _hrm.reserved().start() + index * HeapRegion::GrainWords;
  77 }
  78 
  79 template <class T>
  80 inline HeapRegion* G1CollectedHeap::heap_region_containing_raw(const T addr) const {
  81   assert(addr != NULL, "invariant");
  82   assert(is_in_g1_reserved((const void*) addr),
  83          "Address " PTR_FORMAT " is outside of the heap ranging from [" PTR_FORMAT " to " PTR_FORMAT ")",
  84          p2i((void*)addr), p2i(g1_reserved().start()), p2i(g1_reserved().end()));
  85   return _hrm.addr_to_region((HeapWord*) addr);
  86 }
  87 
  88 template <class T>
  89 inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const {
  90   HeapRegion* hr = heap_region_containing_raw(addr);
  91   if (hr->is_continues_humongous()) {
  92     return hr->humongous_start_region();
  93   }
  94   return hr;
  95 }
  96 
  97 inline void G1CollectedHeap::reset_gc_time_stamp() {
  98   _gc_time_stamp = 0;
  99   OrderAccess::fence();
 100   // Clear the cached CSet starting regions and time stamps.
 101   // Their validity is dependent on the GC timestamp.
 102   clear_cset_start_regions();
 103 }
 104 
 105 inline void G1CollectedHeap::increment_gc_time_stamp() {
 106   ++_gc_time_stamp;
 107   OrderAccess::fence();
 108 }
 109 
 110 inline void G1CollectedHeap::old_set_add(HeapRegion* hr) {
 111   _old_set.add(hr);
 112 }
 113 
 114 inline void G1CollectedHeap::old_set_remove(HeapRegion* hr) {
 115   _old_set.remove(hr);
 116 }
 117 
 118 // It dirties the cards that cover the block so that so that the post
 119 // write barrier never queues anything when updating objects on this
 120 // block. It is assumed (and in fact we assert) that the block
 121 // belongs to a young region.
 122 inline void
 123 G1CollectedHeap::dirty_young_block(HeapWord* start, size_t word_size) {
 124   assert_heap_not_locked();
 125 
 126   // Assign the containing region to containing_hr so that we don't
 127   // have to keep calling heap_region_containing_raw() in the
 128   // asserts below.
 129   DEBUG_ONLY(HeapRegion* containing_hr = heap_region_containing_raw(start);)
 130   assert(word_size > 0, "pre-condition");
 131   assert(containing_hr->is_in(start), "it should contain start");
 132   assert(containing_hr->is_young(), "it should be young");
 133   assert(!containing_hr->is_humongous(), "it should not be humongous");
 134 
 135   HeapWord* end = start + word_size;
 136   assert(containing_hr->is_in(end - 1), "it should also contain end - 1");
 137 
 138   MemRegion mr(start, end);
 139   g1_barrier_set()->g1_mark_as_young(mr);
 140 }
 141 
 142 inline RefToScanQueue* G1CollectedHeap::task_queue(uint i) const {
 143   return _task_queues->queue(i);
 144 }
 145 
 146 inline bool G1CollectedHeap::isMarkedPrev(oop obj) const {
 147   return _cm->prevMarkBitMap()->isMarked((HeapWord *)obj);
 148 }
 149 




  60 
  61 inline AllocationContextStats& G1CollectedHeap::allocation_context_stats() {
  62   return _allocation_context_stats;
  63 }
  64 
  65 // Return the region with the given index. It assumes the index is valid.
  66 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrm.at(index); }
  67 
  68 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const {
  69   assert(is_in_reserved(addr),
  70          "Cannot calculate region index for address " PTR_FORMAT " that is outside of the heap [" PTR_FORMAT ", " PTR_FORMAT ")",
  71          p2i(addr), p2i(reserved_region().start()), p2i(reserved_region().end()));
  72   return (uint)(pointer_delta(addr, reserved_region().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
  73 }
  74 
  75 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const {
  76   return _hrm.reserved().start() + index * HeapRegion::GrainWords;
  77 }
  78 
  79 template <class T>
  80 inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const {
  81   assert(addr != NULL, "invariant");
  82   assert(is_in_g1_reserved((const void*) addr),
  83          "Address " PTR_FORMAT " is outside of the heap ranging from [" PTR_FORMAT " to " PTR_FORMAT ")",
  84          p2i((void*)addr), p2i(g1_reserved().start()), p2i(g1_reserved().end()));
  85   return _hrm.addr_to_region((HeapWord*) addr);
  86 }
  87 









  88 inline void G1CollectedHeap::reset_gc_time_stamp() {
  89   _gc_time_stamp = 0;
  90   OrderAccess::fence();
  91   // Clear the cached CSet starting regions and time stamps.
  92   // Their validity is dependent on the GC timestamp.
  93   clear_cset_start_regions();
  94 }
  95 
  96 inline void G1CollectedHeap::increment_gc_time_stamp() {
  97   ++_gc_time_stamp;
  98   OrderAccess::fence();
  99 }
 100 
 101 inline void G1CollectedHeap::old_set_add(HeapRegion* hr) {
 102   _old_set.add(hr);
 103 }
 104 
 105 inline void G1CollectedHeap::old_set_remove(HeapRegion* hr) {
 106   _old_set.remove(hr);
 107 }
 108 
 109 // It dirties the cards that cover the block so that so that the post
 110 // write barrier never queues anything when updating objects on this
 111 // block. It is assumed (and in fact we assert) that the block
 112 // belongs to a young region.
 113 inline void
 114 G1CollectedHeap::dirty_young_block(HeapWord* start, size_t word_size) {
 115   assert_heap_not_locked();
 116 
 117   // Assign the containing region to containing_hr so that we don't
 118   // have to keep calling heap_region_containing() in the
 119   // asserts below.
 120   DEBUG_ONLY(HeapRegion* containing_hr = heap_region_containing(start);)
 121   assert(word_size > 0, "pre-condition");
 122   assert(containing_hr->is_in(start), "it should contain start");
 123   assert(containing_hr->is_young(), "it should be young");
 124   assert(!containing_hr->is_humongous(), "it should not be humongous");
 125 
 126   HeapWord* end = start + word_size;
 127   assert(containing_hr->is_in(end - 1), "it should also contain end - 1");
 128 
 129   MemRegion mr(start, end);
 130   g1_barrier_set()->g1_mark_as_young(mr);
 131 }
 132 
 133 inline RefToScanQueue* G1CollectedHeap::task_queue(uint i) const {
 134   return _task_queues->queue(i);
 135 }
 136 
 137 inline bool G1CollectedHeap::isMarkedPrev(oop obj) const {
 138   return _cm->prevMarkBitMap()->isMarked((HeapWord *)obj);
 139 }
 140 


< prev index next >