< prev index next >

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

Print this page
rev 13280 : imported patch 8184346-cleanup-g1cmbitmap
rev 13282 : imported patch 8184346-erikd-mgerdin-review


  96 
  97 // Because of the requirement of keeping "_offsets" up to date with the
  98 // allocations, we sequentialize these with a lock.  Therefore, best if
  99 // this is used for larger LAB allocations only.
 100 inline HeapWord* G1ContiguousSpace::par_allocate(size_t min_word_size,
 101                                                  size_t desired_word_size,
 102                                                  size_t* actual_size) {
 103   MutexLocker x(&_par_alloc_lock);
 104   return allocate(min_word_size, desired_word_size, actual_size);
 105 }
 106 
 107 inline HeapWord* G1ContiguousSpace::block_start(const void* p) {
 108   return _bot_part.block_start(p);
 109 }
 110 
 111 inline HeapWord*
 112 G1ContiguousSpace::block_start_const(const void* p) const {
 113   return _bot_part.block_start_const(p);
 114 }
 115 
 116 inline bool HeapRegion::is_obj_dead_with_size(const oop obj, G1CMBitMapRO* prev_bitmap, size_t* size) const {
 117   HeapWord* addr = (HeapWord*) obj;
 118 
 119   assert(addr < top(), "must be");
 120   assert(!is_archive(), "Archive regions should not have references into interesting regions.");
 121   assert(!is_humongous(), "Humongous objects not handled here");
 122   bool obj_is_dead = is_obj_dead(obj, prev_bitmap);
 123 
 124   if (ClassUnloadingWithConcurrentMark && obj_is_dead) {
 125     assert(!block_is_obj(addr), "must be");
 126     *size = block_size_using_bitmap(addr, prev_bitmap);
 127   } else {
 128     assert(block_is_obj(addr), "must be");
 129     *size = obj->size();
 130   }
 131   return obj_is_dead;
 132 }
 133 
 134 inline bool
 135 HeapRegion::block_is_obj(const HeapWord* p) const {
 136   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 137 
 138   if (!this->is_in(p)) {
 139     assert(is_continues_humongous(), "This case can only happen for humongous regions");
 140     return (p == humongous_start_region()->bottom());
 141   }
 142   if (ClassUnloadingWithConcurrentMark) {
 143     return !g1h->is_obj_dead(oop(p), this);
 144   }
 145   return p < top();
 146 }
 147 
 148 inline size_t HeapRegion::block_size_using_bitmap(const HeapWord* addr, const G1CMBitMapRO* prev_bitmap) const {
 149   assert(ClassUnloadingWithConcurrentMark,
 150          "All blocks should be objects if class unloading isn't used, so this method should not be called. "
 151          "HR: [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ") "
 152          "addr: " PTR_FORMAT,
 153          p2i(bottom()), p2i(top()), p2i(end()), p2i(addr));
 154 
 155   // Old regions' dead objects may have dead classes
 156   // We need to find the next live object using the bitmap
 157   HeapWord* next = prev_bitmap->getNextMarkedWordAddress(addr, prev_top_at_mark_start());
 158 
 159   assert(next > addr, "must get the next live object");
 160   return pointer_delta(next, addr);
 161 }
 162 
 163 inline bool HeapRegion::is_obj_dead(const oop obj, const G1CMBitMapRO* prev_bitmap) const {
 164   assert(is_in_reserved(obj), "Object " PTR_FORMAT " must be in region", p2i(obj));
 165   return !obj_allocated_since_prev_marking(obj) && !prev_bitmap->isMarked((HeapWord*)obj);
 166 }
 167 
 168 inline size_t HeapRegion::block_size(const HeapWord *addr) const {
 169   if (addr == top()) {
 170     return pointer_delta(end(), addr);
 171   }
 172 
 173   if (block_is_obj(addr)) {
 174     return oop(addr)->size();
 175   }
 176 
 177   return block_size_using_bitmap(addr, G1CollectedHeap::heap()->concurrent_mark()->prevMarkBitMap());
 178 }
 179 
 180 inline HeapWord* HeapRegion::par_allocate_no_bot_updates(size_t min_word_size,
 181                                                          size_t desired_word_size,
 182                                                          size_t* actual_word_size) {
 183   assert(is_young(), "we can only skip BOT updates on young regions");
 184   return par_allocate_impl(min_word_size, desired_word_size, actual_word_size);
 185 }


 314 
 315   // Cache the boundaries of the memory region in some const locals
 316   HeapWord* const start = mr.start();
 317   HeapWord* const end = mr.end();
 318 
 319   // Find the obj that extends onto mr.start().
 320   // Update BOT as needed while finding start of (possibly dead)
 321   // object containing the start of the region.
 322   HeapWord* cur = block_start(start);
 323 
 324 #ifdef ASSERT
 325   {
 326     assert(cur <= start,
 327            "cur: " PTR_FORMAT ", start: " PTR_FORMAT, p2i(cur), p2i(start));
 328     HeapWord* next = cur + block_size(cur);
 329     assert(start < next,
 330            "start: " PTR_FORMAT ", next: " PTR_FORMAT, p2i(start), p2i(next));
 331   }
 332 #endif
 333 
 334   G1CMBitMapRO* bitmap = g1h->concurrent_mark()->prevMarkBitMap();
 335   do {
 336     oop obj = oop(cur);
 337     assert(obj->is_oop(true), "Not an oop at " PTR_FORMAT, p2i(cur));
 338     assert(obj->klass_or_null() != NULL,
 339            "Unparsable heap at " PTR_FORMAT, p2i(cur));
 340 
 341     size_t size;
 342     bool is_dead = is_obj_dead_with_size(obj, bitmap, &size);
 343 
 344     cur += size;
 345     if (!is_dead) {
 346       // Process live object's references.
 347 
 348       // Non-objArrays are usually marked imprecise at the object
 349       // start, in which case we need to iterate over them in full.
 350       // objArrays are precisely marked, but can still be iterated
 351       // over in full if completely covered.
 352       if (!obj->is_objArray() || (((HeapWord*)obj) >= start && cur <= end)) {
 353         obj->oop_iterate(cl);
 354       } else {


  96 
  97 // Because of the requirement of keeping "_offsets" up to date with the
  98 // allocations, we sequentialize these with a lock.  Therefore, best if
  99 // this is used for larger LAB allocations only.
 100 inline HeapWord* G1ContiguousSpace::par_allocate(size_t min_word_size,
 101                                                  size_t desired_word_size,
 102                                                  size_t* actual_size) {
 103   MutexLocker x(&_par_alloc_lock);
 104   return allocate(min_word_size, desired_word_size, actual_size);
 105 }
 106 
 107 inline HeapWord* G1ContiguousSpace::block_start(const void* p) {
 108   return _bot_part.block_start(p);
 109 }
 110 
 111 inline HeapWord*
 112 G1ContiguousSpace::block_start_const(const void* p) const {
 113   return _bot_part.block_start_const(p);
 114 }
 115 
 116 inline bool HeapRegion::is_obj_dead_with_size(const oop obj, const G1CMBitMap* const prev_bitmap, size_t* size) const {
 117   HeapWord* addr = (HeapWord*) obj;
 118 
 119   assert(addr < top(), "must be");
 120   assert(!is_archive(), "Archive regions should not have references into interesting regions.");
 121   assert(!is_humongous(), "Humongous objects not handled here");
 122   bool obj_is_dead = is_obj_dead(obj, prev_bitmap);
 123 
 124   if (ClassUnloadingWithConcurrentMark && obj_is_dead) {
 125     assert(!block_is_obj(addr), "must be");
 126     *size = block_size_using_bitmap(addr, prev_bitmap);
 127   } else {
 128     assert(block_is_obj(addr), "must be");
 129     *size = obj->size();
 130   }
 131   return obj_is_dead;
 132 }
 133 
 134 inline bool
 135 HeapRegion::block_is_obj(const HeapWord* p) const {
 136   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 137 
 138   if (!this->is_in(p)) {
 139     assert(is_continues_humongous(), "This case can only happen for humongous regions");
 140     return (p == humongous_start_region()->bottom());
 141   }
 142   if (ClassUnloadingWithConcurrentMark) {
 143     return !g1h->is_obj_dead(oop(p), this);
 144   }
 145   return p < top();
 146 }
 147 
 148 inline size_t HeapRegion::block_size_using_bitmap(const HeapWord* addr, const G1CMBitMap* const prev_bitmap) const {
 149   assert(ClassUnloadingWithConcurrentMark,
 150          "All blocks should be objects if class unloading isn't used, so this method should not be called. "
 151          "HR: [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ") "
 152          "addr: " PTR_FORMAT,
 153          p2i(bottom()), p2i(top()), p2i(end()), p2i(addr));
 154 
 155   // Old regions' dead objects may have dead classes
 156   // We need to find the next live object using the bitmap
 157   HeapWord* next = prev_bitmap->get_next_marked_addr(addr, prev_top_at_mark_start());
 158 
 159   assert(next > addr, "must get the next live object");
 160   return pointer_delta(next, addr);
 161 }
 162 
 163 inline bool HeapRegion::is_obj_dead(const oop obj, const G1CMBitMap* const prev_bitmap) const {
 164   assert(is_in_reserved(obj), "Object " PTR_FORMAT " must be in region", p2i(obj));
 165   return !obj_allocated_since_prev_marking(obj) && !prev_bitmap->is_marked((HeapWord*)obj);
 166 }
 167 
 168 inline size_t HeapRegion::block_size(const HeapWord *addr) const {
 169   if (addr == top()) {
 170     return pointer_delta(end(), addr);
 171   }
 172 
 173   if (block_is_obj(addr)) {
 174     return oop(addr)->size();
 175   }
 176 
 177   return block_size_using_bitmap(addr, G1CollectedHeap::heap()->concurrent_mark()->prevMarkBitMap());
 178 }
 179 
 180 inline HeapWord* HeapRegion::par_allocate_no_bot_updates(size_t min_word_size,
 181                                                          size_t desired_word_size,
 182                                                          size_t* actual_word_size) {
 183   assert(is_young(), "we can only skip BOT updates on young regions");
 184   return par_allocate_impl(min_word_size, desired_word_size, actual_word_size);
 185 }


 314 
 315   // Cache the boundaries of the memory region in some const locals
 316   HeapWord* const start = mr.start();
 317   HeapWord* const end = mr.end();
 318 
 319   // Find the obj that extends onto mr.start().
 320   // Update BOT as needed while finding start of (possibly dead)
 321   // object containing the start of the region.
 322   HeapWord* cur = block_start(start);
 323 
 324 #ifdef ASSERT
 325   {
 326     assert(cur <= start,
 327            "cur: " PTR_FORMAT ", start: " PTR_FORMAT, p2i(cur), p2i(start));
 328     HeapWord* next = cur + block_size(cur);
 329     assert(start < next,
 330            "start: " PTR_FORMAT ", next: " PTR_FORMAT, p2i(start), p2i(next));
 331   }
 332 #endif
 333 
 334   const G1CMBitMap* const bitmap = g1h->concurrent_mark()->prevMarkBitMap();
 335   do {
 336     oop obj = oop(cur);
 337     assert(obj->is_oop(true), "Not an oop at " PTR_FORMAT, p2i(cur));
 338     assert(obj->klass_or_null() != NULL,
 339            "Unparsable heap at " PTR_FORMAT, p2i(cur));
 340 
 341     size_t size;
 342     bool is_dead = is_obj_dead_with_size(obj, bitmap, &size);
 343 
 344     cur += size;
 345     if (!is_dead) {
 346       // Process live object's references.
 347 
 348       // Non-objArrays are usually marked imprecise at the object
 349       // start, in which case we need to iterate over them in full.
 350       // objArrays are precisely marked, but can still be iterated
 351       // over in full if completely covered.
 352       if (!obj->is_objArray() || (((HeapWord*)obj) >= start && cur <= end)) {
 353         obj->oop_iterate(cl);
 354       } else {
< prev index next >