< prev index next >

src/hotspot/share/gc/parallel/psScavenge.inline.hpp

Print this page




  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_PARALLEL_PSSCAVENGE_INLINE_HPP
  26 #define SHARE_VM_GC_PARALLEL_PSSCAVENGE_INLINE_HPP
  27 
  28 #include "gc/parallel/parallelScavengeHeap.hpp"
  29 #include "gc/parallel/psPromotionManager.inline.hpp"
  30 #include "gc/parallel/psScavenge.hpp"
  31 #include "logging/log.hpp"
  32 #include "memory/iterator.hpp"
  33 #include "memory/resourceArea.hpp"

  34 #include "utilities/globalDefinitions.hpp"
  35 
  36 inline void PSScavenge::save_to_space_top_before_gc() {
  37   ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
  38   _to_space_top_before_gc = heap->young_gen()->to_space()->top();
  39 }
  40 
  41 template <class T> inline bool PSScavenge::should_scavenge(T* p) {
  42   T heap_oop = oopDesc::load_heap_oop(p);
  43   return PSScavenge::is_obj_in_young(heap_oop);
  44 }
  45 
  46 template <class T>
  47 inline bool PSScavenge::should_scavenge(T* p, MutableSpace* to_space) {
  48   if (should_scavenge(p)) {
  49     oop obj = oopDesc::load_decode_heap_oop_not_null(p);
  50     // Skip objects copied to to_space since the scavenge started.
  51     HeapWord* const addr = (HeapWord*)obj;
  52     return addr < to_space_top_before_gc() || addr >= to_space->end();
  53   }
  54   return false;
  55 }
  56 
  57 template <class T>
  58 inline bool PSScavenge::should_scavenge(T* p, bool check_to_space) {
  59   if (check_to_space) {
  60     ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
  61     return should_scavenge(p, heap->young_gen()->to_space());
  62   }
  63   return should_scavenge(p);
  64 }
  65 
  66 template<bool promote_immediately>
  67 class PSRootsClosure: public OopClosure {
  68  private:
  69   PSPromotionManager* _promotion_manager;


  90   PSPromotionManager* _pm;
  91   // Used to redirty a scanned cld if it has oops
  92   // pointing to the young generation after being scanned.
  93   ClassLoaderData*    _scanned_cld;
  94  public:
  95   PSScavengeFromCLDClosure(PSPromotionManager* pm) : _pm(pm), _scanned_cld(NULL) { }
  96   void do_oop(narrowOop* p) { ShouldNotReachHere(); }
  97   void do_oop(oop* p)       {
  98     ParallelScavengeHeap* psh = ParallelScavengeHeap::heap();
  99     assert(!psh->is_in_reserved(p), "GC barrier needed");
 100     if (PSScavenge::should_scavenge(p)) {
 101       assert(PSScavenge::should_scavenge(p, true), "revisiting object?");
 102 
 103       oop o = *p;
 104       oop new_obj;
 105       if (o->is_forwarded()) {
 106         new_obj = o->forwardee();
 107       } else {
 108         new_obj = _pm->copy_to_survivor_space</*promote_immediately=*/false>(o);
 109       }
 110       oopDesc::encode_store_heap_oop_not_null(p, new_obj);
 111 
 112       if (PSScavenge::is_obj_in_young(new_obj)) {
 113         do_cld_barrier();
 114       }
 115     }
 116   }
 117 
 118   void set_scanned_cld(ClassLoaderData* cld) {
 119     assert(_scanned_cld == NULL || cld == NULL, "Should always only handling one cld at a time");
 120     _scanned_cld = cld;
 121   }
 122 
 123  private:
 124   void do_cld_barrier() {
 125     assert(_scanned_cld != NULL, "Should not be called without having a scanned cld");
 126     _scanned_cld->record_modified_oops();
 127   }
 128 };
 129 
 130 // Scavenges the oop in a ClassLoaderData.




  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_PARALLEL_PSSCAVENGE_INLINE_HPP
  26 #define SHARE_VM_GC_PARALLEL_PSSCAVENGE_INLINE_HPP
  27 
  28 #include "gc/parallel/parallelScavengeHeap.hpp"
  29 #include "gc/parallel/psPromotionManager.inline.hpp"
  30 #include "gc/parallel/psScavenge.hpp"
  31 #include "logging/log.hpp"
  32 #include "memory/iterator.hpp"
  33 #include "memory/resourceArea.hpp"
  34 #include "oops/access.inline.hpp"
  35 #include "utilities/globalDefinitions.hpp"
  36 
  37 inline void PSScavenge::save_to_space_top_before_gc() {
  38   ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
  39   _to_space_top_before_gc = heap->young_gen()->to_space()->top();
  40 }
  41 
  42 template <class T> inline bool PSScavenge::should_scavenge(T* p) {
  43   T heap_oop = RawAccess<>::oop_load(p);
  44   return PSScavenge::is_obj_in_young(heap_oop);
  45 }
  46 
  47 template <class T>
  48 inline bool PSScavenge::should_scavenge(T* p, MutableSpace* to_space) {
  49   if (should_scavenge(p)) {
  50     oop obj = RawAccess<OOP_NOT_NULL>::oop_load(p);
  51     // Skip objects copied to to_space since the scavenge started.
  52     HeapWord* const addr = (HeapWord*)obj;
  53     return addr < to_space_top_before_gc() || addr >= to_space->end();
  54   }
  55   return false;
  56 }
  57 
  58 template <class T>
  59 inline bool PSScavenge::should_scavenge(T* p, bool check_to_space) {
  60   if (check_to_space) {
  61     ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
  62     return should_scavenge(p, heap->young_gen()->to_space());
  63   }
  64   return should_scavenge(p);
  65 }
  66 
  67 template<bool promote_immediately>
  68 class PSRootsClosure: public OopClosure {
  69  private:
  70   PSPromotionManager* _promotion_manager;


  91   PSPromotionManager* _pm;
  92   // Used to redirty a scanned cld if it has oops
  93   // pointing to the young generation after being scanned.
  94   ClassLoaderData*    _scanned_cld;
  95  public:
  96   PSScavengeFromCLDClosure(PSPromotionManager* pm) : _pm(pm), _scanned_cld(NULL) { }
  97   void do_oop(narrowOop* p) { ShouldNotReachHere(); }
  98   void do_oop(oop* p)       {
  99     ParallelScavengeHeap* psh = ParallelScavengeHeap::heap();
 100     assert(!psh->is_in_reserved(p), "GC barrier needed");
 101     if (PSScavenge::should_scavenge(p)) {
 102       assert(PSScavenge::should_scavenge(p, true), "revisiting object?");
 103 
 104       oop o = *p;
 105       oop new_obj;
 106       if (o->is_forwarded()) {
 107         new_obj = o->forwardee();
 108       } else {
 109         new_obj = _pm->copy_to_survivor_space</*promote_immediately=*/false>(o);
 110       }
 111       RawAccess<>::oop_store(p, new_obj);
 112 
 113       if (PSScavenge::is_obj_in_young(new_obj)) {
 114         do_cld_barrier();
 115       }
 116     }
 117   }
 118 
 119   void set_scanned_cld(ClassLoaderData* cld) {
 120     assert(_scanned_cld == NULL || cld == NULL, "Should always only handling one cld at a time");
 121     _scanned_cld = cld;
 122   }
 123 
 124  private:
 125   void do_cld_barrier() {
 126     assert(_scanned_cld != NULL, "Should not be called without having a scanned cld");
 127     _scanned_cld->record_modified_oops();
 128   }
 129 };
 130 
 131 // Scavenges the oop in a ClassLoaderData.


< prev index next >