hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp
changeset 24106 dae9277bdf2a
parent 24100 7e71ac14ec06
child 24351 61b33cc6d3cf
equal deleted inserted replaced
24105:93ea1c7cae36 24106:dae9277bdf2a
    40 // Return the region with the given index. It assumes the index is valid.
    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); }
    41 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrs.at(index); }
    42 
    42 
    43 template <class T>
    43 template <class T>
    44 inline HeapRegion*
    44 inline HeapRegion*
    45 G1CollectedHeap::heap_region_containing(const T addr) const {
    45 G1CollectedHeap::heap_region_containing_raw(const T addr) const {
    46   HeapRegion* hr = _hrs.addr_to_region((HeapWord*) addr);
    46   assert(addr != NULL, "invariant");
    47   // hr can be null if addr in perm_gen
    47   assert(_g1_reserved.contains((const void*) addr),
    48   if (hr != NULL && hr->continuesHumongous()) {
    48       err_msg("Address "PTR_FORMAT" is outside of the heap ranging from ["PTR_FORMAT" to "PTR_FORMAT")",
    49     hr = hr->humongous_start_region();
    49           (void*)addr, _g1_reserved.start(), _g1_reserved.end()));
    50   }
    50   return _hrs.addr_to_region((HeapWord*) addr);
    51   return hr;
       
    52 }
    51 }
    53 
    52 
    54 template <class T>
    53 template <class T>
    55 inline HeapRegion*
    54 inline HeapRegion*
    56 G1CollectedHeap::heap_region_containing_raw(const T addr) const {
    55 G1CollectedHeap::heap_region_containing(const T addr) const {
    57   assert(_g1_reserved.contains((const void*) addr), "invariant");
    56   HeapRegion* hr = heap_region_containing_raw(addr);
    58   HeapRegion* res = _hrs.addr_to_region_unsafe((HeapWord*) addr);
    57   if (hr->continuesHumongous()) {
    59   return res;
    58     return hr->humongous_start_region();
       
    59   }
       
    60   return hr;
    60 }
    61 }
    61 
    62 
    62 inline void G1CollectedHeap::old_set_remove(HeapRegion* hr) {
    63 inline void G1CollectedHeap::old_set_remove(HeapRegion* hr) {
    63   _old_set.remove(hr);
    64   _old_set.remove(hr);
    64 }
    65 }
   132 
   133 
   133   // Assign the containing region to containing_hr so that we don't
   134   // Assign the containing region to containing_hr so that we don't
   134   // have to keep calling heap_region_containing_raw() in the
   135   // have to keep calling heap_region_containing_raw() in the
   135   // asserts below.
   136   // asserts below.
   136   DEBUG_ONLY(HeapRegion* containing_hr = heap_region_containing_raw(start);)
   137   DEBUG_ONLY(HeapRegion* containing_hr = heap_region_containing_raw(start);)
   137   assert(containing_hr != NULL && start != NULL && word_size > 0,
   138   assert(word_size > 0, "pre-condition");
   138          "pre-condition");
       
   139   assert(containing_hr->is_in(start), "it should contain start");
   139   assert(containing_hr->is_in(start), "it should contain start");
   140   assert(containing_hr->is_young(), "it should be young");
   140   assert(containing_hr->is_young(), "it should be young");
   141   assert(!containing_hr->isHumongous(), "it should not be humongous");
   141   assert(!containing_hr->isHumongous(), "it should not be humongous");
   142 
   142 
   143   HeapWord* end = start + word_size;
   143   HeapWord* end = start + word_size;
   244   }
   244   }
   245 }
   245 }
   246 #endif  // #ifndef PRODUCT
   246 #endif  // #ifndef PRODUCT
   247 
   247 
   248 inline bool G1CollectedHeap::is_in_young(const oop obj) {
   248 inline bool G1CollectedHeap::is_in_young(const oop obj) {
   249   HeapRegion* hr = heap_region_containing(obj);
   249   if (obj == NULL) {
   250   return hr != NULL && hr->is_young();
   250     return false;
       
   251   }
       
   252   return heap_region_containing(obj)->is_young();
   251 }
   253 }
   252 
   254 
   253 // We don't need barriers for initializing stores to objects
   255 // We don't need barriers for initializing stores to objects
   254 // in the young gen: for the SATB pre-barrier, there is no
   256 // in the young gen: for the SATB pre-barrier, there is no
   255 // pre-value that needs to be remembered; for the remembered-set
   257 // pre-value that needs to be remembered; for the remembered-set
   258 inline bool G1CollectedHeap::can_elide_initializing_store_barrier(oop new_obj) {
   260 inline bool G1CollectedHeap::can_elide_initializing_store_barrier(oop new_obj) {
   259   return is_in_young(new_obj);
   261   return is_in_young(new_obj);
   260 }
   262 }
   261 
   263 
   262 inline bool G1CollectedHeap::is_obj_dead(const oop obj) const {
   264 inline bool G1CollectedHeap::is_obj_dead(const oop obj) const {
   263   const HeapRegion* hr = heap_region_containing(obj);
   265   if (obj == NULL) {
   264   if (hr == NULL) {
   266     return false;
   265     if (obj == NULL) return false;
   267   }
   266     else return true;
   268   return is_obj_dead(obj, heap_region_containing(obj));
   267   }
       
   268   else return is_obj_dead(obj, hr);
       
   269 }
   269 }
   270 
   270 
   271 inline bool G1CollectedHeap::is_obj_ill(const oop obj) const {
   271 inline bool G1CollectedHeap::is_obj_ill(const oop obj) const {
   272   const HeapRegion* hr = heap_region_containing(obj);
   272   if (obj == NULL) {
   273   if (hr == NULL) {
   273     return false;
   274     if (obj == NULL) return false;
   274   }
   275     else return true;
   275   return is_obj_ill(obj, heap_region_containing(obj));
   276   }
       
   277   else return is_obj_ill(obj, hr);
       
   278 }
   276 }
   279 
   277 
   280 template <class T> inline void G1ParScanThreadState::immediate_rs_update(HeapRegion* from, T* p, int tid) {
   278 template <class T> inline void G1ParScanThreadState::immediate_rs_update(HeapRegion* from, T* p, int tid) {
   281   if (!from->is_survivor()) {
   279   if (!from->is_survivor()) {
   282     _g1_rem->par_write_ref(from, p, tid);
   280     _g1_rem->par_write_ref(from, p, tid);