hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp
changeset 30150 d9c940aa42ef
parent 29792 8c6fa07f0869
child 30154 39cd4e2ccf1c
equal deleted inserted replaced
30149:c0f930abe5ed 30150:d9c940aa42ef
   949    public:
   949    public:
   950     FollowStackClosure(ParCompactionManager* cm) : _compaction_manager(cm) { }
   950     FollowStackClosure(ParCompactionManager* cm) : _compaction_manager(cm) { }
   951     virtual void do_void();
   951     virtual void do_void();
   952   };
   952   };
   953 
   953 
   954   class AdjustPointerClosure: public OopClosure {
   954   class AdjustPointerClosure: public ExtendedOopClosure {
   955    public:
   955    public:
       
   956     template <typename T> void do_oop_nv(T* p);
   956     virtual void do_oop(oop* p);
   957     virtual void do_oop(oop* p);
   957     virtual void do_oop(narrowOop* p);
   958     virtual void do_oop(narrowOop* p);
   958     // do not walk from thread stacks to the code cache on this phase
   959 
   959     virtual void do_code_blob(CodeBlob* cb) const { }
   960     // This closure provides its own oop verification code.
       
   961     debug_only(virtual bool should_verify_oops() { return false; })
   960   };
   962   };
   961 
   963 
   962   class AdjustKlassClosure : public KlassClosure {
   964   class AdjustKlassClosure : public KlassClosure {
   963    public:
   965    public:
   964     void do_klass(Klass* klass);
   966     void do_klass(Klass* klass);
  1137 
  1139 
  1138   // Reset time since last full gc
  1140   // Reset time since last full gc
  1139   static void reset_millis_since_last_gc();
  1141   static void reset_millis_since_last_gc();
  1140 
  1142 
  1141  public:
  1143  public:
  1142   class MarkAndPushClosure: public OopClosure {
  1144   class MarkAndPushClosure: public ExtendedOopClosure {
  1143    private:
  1145    private:
  1144     ParCompactionManager* _compaction_manager;
  1146     ParCompactionManager* _compaction_manager;
  1145    public:
  1147    public:
  1146     MarkAndPushClosure(ParCompactionManager* cm) : _compaction_manager(cm) { }
  1148     MarkAndPushClosure(ParCompactionManager* cm) : _compaction_manager(cm) { }
       
  1149 
       
  1150     template <typename T> void do_oop_nv(T* p);
  1147     virtual void do_oop(oop* p);
  1151     virtual void do_oop(oop* p);
  1148     virtual void do_oop(narrowOop* p);
  1152     virtual void do_oop(narrowOop* p);
       
  1153 
       
  1154     // This closure provides its own oop verification code.
       
  1155     debug_only(virtual bool should_verify_oops() { return false; })
  1149   };
  1156   };
  1150 
  1157 
  1151   // The one and only place to start following the classes.
  1158   // The one and only place to start following the classes.
  1152   // Should only be applied to the ClassLoaderData klasses list.
  1159   // Should only be applied to the ClassLoaderData klasses list.
  1153   class FollowKlassClosure : public KlassClosure {
  1160   class FollowKlassClosure : public KlassClosure {
  1175   // at a pointer where it would be appropriate to return a JNI_ENOMEM
  1182   // at a pointer where it would be appropriate to return a JNI_ENOMEM
  1176   // in the event of a failure.
  1183   // in the event of a failure.
  1177   static bool initialize();
  1184   static bool initialize();
  1178 
  1185 
  1179   // Closure accessors
  1186   // Closure accessors
  1180   static OopClosure* adjust_pointer_closure()      { return (OopClosure*)&_adjust_pointer_closure; }
  1187   static PSParallelCompact::AdjustPointerClosure* adjust_pointer_closure() {
       
  1188     return &_adjust_pointer_closure;
       
  1189   }
  1181   static KlassClosure* adjust_klass_closure()      { return (KlassClosure*)&_adjust_klass_closure; }
  1190   static KlassClosure* adjust_klass_closure()      { return (KlassClosure*)&_adjust_klass_closure; }
  1182   static BoolObjectClosure* is_alive_closure()     { return (BoolObjectClosure*)&_is_alive_closure; }
  1191   static BoolObjectClosure* is_alive_closure()     { return (BoolObjectClosure*)&_is_alive_closure; }
  1183 
  1192 
  1184   // Public accessors
  1193   // Public accessors
  1185   static elapsedTimer* accumulated_time() { return &_accumulated_time; }
  1194   static elapsedTimer* accumulated_time() { return &_accumulated_time; }
  1331 inline bool PSParallelCompact::is_marked(oop obj) {
  1340 inline bool PSParallelCompact::is_marked(oop obj) {
  1332   return mark_bitmap()->is_marked(obj);
  1341   return mark_bitmap()->is_marked(obj);
  1333 }
  1342 }
  1334 
  1343 
  1335 template <class T>
  1344 template <class T>
  1336 inline void PSParallelCompact::mark_and_push(ParCompactionManager* cm, T* p) {
       
  1337   T heap_oop = oopDesc::load_heap_oop(p);
       
  1338   if (!oopDesc::is_null(heap_oop)) {
       
  1339     oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
       
  1340     if (mark_bitmap()->is_unmarked(obj) && mark_obj(obj)) {
       
  1341       cm->push(obj);
       
  1342     }
       
  1343   }
       
  1344 }
       
  1345 
       
  1346 template <class T>
       
  1347 inline void PSParallelCompact::adjust_pointer(T* p) {
       
  1348   T heap_oop = oopDesc::load_heap_oop(p);
       
  1349   if (!oopDesc::is_null(heap_oop)) {
       
  1350     oop obj     = oopDesc::decode_heap_oop_not_null(heap_oop);
       
  1351     oop new_obj = (oop)summary_data().calc_new_pointer(obj);
       
  1352     assert(new_obj != NULL,                    // is forwarding ptr?
       
  1353            "should be forwarded");
       
  1354     // Just always do the update unconditionally?
       
  1355     if (new_obj != NULL) {
       
  1356       assert(Universe::heap()->is_in_reserved(new_obj),
       
  1357              "should be in object space");
       
  1358       oopDesc::encode_store_heap_oop_not_null(p, new_obj);
       
  1359     }
       
  1360   }
       
  1361 }
       
  1362 
       
  1363 inline void PSParallelCompact::follow_klass(ParCompactionManager* cm, Klass* klass) {
       
  1364   oop holder = klass->klass_holder();
       
  1365   PSParallelCompact::mark_and_push(cm, &holder);
       
  1366 }
       
  1367 
       
  1368 template <class T>
       
  1369 inline void PSParallelCompact::KeepAliveClosure::do_oop_work(T* p) {
  1345 inline void PSParallelCompact::KeepAliveClosure::do_oop_work(T* p) {
  1370   mark_and_push(_compaction_manager, p);
  1346   mark_and_push(_compaction_manager, p);
  1371 }
  1347 }
  1372 
  1348 
  1373 inline bool PSParallelCompact::print_phases() {
  1349 inline bool PSParallelCompact::print_phases() {