< prev index next >

src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp

Print this page




 493   virtual void execute(EnqueueTask& task);
 494 private:
 495   CMSCollector& _collector;
 496 };
 497 
 498 
 499 class CMSCollector: public CHeapObj<mtGC> {
 500   friend class VMStructs;
 501   friend class ConcurrentMarkSweepThread;
 502   friend class ConcurrentMarkSweepGeneration;
 503   friend class CompactibleFreeListSpace;
 504   friend class CMSParMarkTask;
 505   friend class CMSParInitialMarkTask;
 506   friend class CMSParRemarkTask;
 507   friend class CMSConcMarkingTask;
 508   friend class CMSRefProcTaskProxy;
 509   friend class CMSRefProcTaskExecutor;
 510   friend class ScanMarkedObjectsAgainCarefullyClosure;  // for sampling eden
 511   friend class SurvivorSpacePrecleanClosure;            // --- ditto -------
 512   friend class PushOrMarkClosure;             // to access _restart_addr
 513   friend class Par_PushOrMarkClosure;             // to access _restart_addr
 514   friend class MarkFromRootsClosure;          //  -- ditto --
 515                                               // ... and for clearing cards
 516   friend class Par_MarkFromRootsClosure;      //  to access _restart_addr
 517                                               // ... and for clearing cards
 518   friend class Par_ConcMarkingClosure;        //  to access _restart_addr etc.
 519   friend class MarkFromRootsVerifyClosure;    // to access _restart_addr
 520   friend class PushAndMarkVerifyClosure;      //  -- ditto --
 521   friend class MarkRefsIntoAndScanClosure;    // to access _overflow_list
 522   friend class PushAndMarkClosure;            //  -- ditto --
 523   friend class Par_PushAndMarkClosure;        //  -- ditto --
 524   friend class CMSKeepAliveClosure;           //  -- ditto --
 525   friend class CMSDrainMarkingStackClosure;   //  -- ditto --
 526   friend class CMSInnerParMarkAndPushClosure; //  -- ditto --
 527   NOT_PRODUCT(friend class ScanMarkedObjectsAgainClosure;) //  assertion on _overflow_list
 528   friend class ReleaseForegroundGC;  // to access _foregroundGCShouldWait
 529   friend class VM_CMS_Operation;
 530   friend class VM_CMS_Initial_Mark;
 531   friend class VM_CMS_Final_Remark;
 532   friend class TraceCMSMemoryManagerStats;
 533 
 534  private:
 535   jlong _time_of_last_gc;
 536   void update_time_of_last_gc(jlong now) {
 537     _time_of_last_gc = now;
 538   }
 539 
 540   OopTaskQueueSet* _task_queues;
 541 
 542   // Overflow list of grey objects, threaded through mark-word
 543   // Manipulated with CAS in the parallel/multi-threaded case.


1265   DEBUG_ONLY(bool _verifying;)
1266 
1267  public:
1268   MarkFromRootsClosure(CMSCollector* collector, MemRegion span,
1269                        CMSBitMap* bitMap,
1270                        CMSMarkStack*  markStack,
1271                        bool should_yield, bool verifying = false);
1272   bool do_bit(size_t offset);
1273   void reset(HeapWord* addr);
1274   inline void do_yield_check();
1275 
1276  private:
1277   void scanOopsInOop(HeapWord* ptr);
1278   void do_yield_work();
1279 };
1280 
1281 // This closure is used to do concurrent multi-threaded
1282 // marking from the roots following the first checkpoint.
1283 // XXX This should really be a subclass of The serial version
1284 // above, but i have not had the time to refactor things cleanly.
1285 class Par_MarkFromRootsClosure: public BitMapClosure {
1286   CMSCollector*  _collector;
1287   MemRegion      _whole_span;
1288   MemRegion      _span;
1289   CMSBitMap*     _bit_map;
1290   CMSBitMap*     _mut;
1291   OopTaskQueue*  _work_queue;
1292   CMSMarkStack*  _overflow_stack;
1293   int            _skip_bits;
1294   HeapWord*      _finger;
1295   HeapWord*      _threshold;
1296   CMSConcMarkingTask* _task;
1297  public:
1298   Par_MarkFromRootsClosure(CMSConcMarkingTask* task, CMSCollector* collector,
1299                        MemRegion span,
1300                        CMSBitMap* bit_map,
1301                        OopTaskQueue* work_queue,
1302                        CMSMarkStack*  overflow_stack);
1303   bool do_bit(size_t offset);
1304   inline void do_yield_check();
1305 
1306  private:
1307   void scan_oops_in_oop(HeapWord* ptr);
1308   void do_yield_work();
1309   bool get_work_from_overflow_stack();
1310 };
1311 
1312 // The following closures are used to do certain kinds of verification of
1313 // CMS marking.
1314 class PushAndMarkVerifyClosure: public MetadataAwareOopClosure {
1315   CMSCollector*    _collector;
1316   MemRegion        _span;
1317   CMSBitMap*       _verification_bm;
1318   CMSBitMap*       _cms_bm;


1384 // [Par_]MarkRefsIntoAndScanClosure (Par_ in the parallel case)
1385 // declared in genOopClosures.hpp to accomplish some of its work.
1386 // In the parallel case the bitMap is shared, so access to
1387 // it needs to be suitably synchronized for updates by embedded
1388 // closures that update it; however, this closure itself only
1389 // reads the bit_map and because it is idempotent, is immune to
1390 // reading stale values.
1391 class ScanMarkedObjectsAgainClosure: public UpwardsObjectClosure {
1392   #ifdef ASSERT
1393     CMSCollector*          _collector;
1394     MemRegion              _span;
1395     union {
1396       CMSMarkStack*        _mark_stack;
1397       OopTaskQueue*        _work_queue;
1398     };
1399   #endif // ASSERT
1400   bool                       _parallel;
1401   CMSBitMap*                 _bit_map;
1402   union {
1403     MarkRefsIntoAndScanClosure*     _scan_closure;
1404     Par_MarkRefsIntoAndScanClosure* _par_scan_closure;
1405   };
1406 
1407  public:
1408   ScanMarkedObjectsAgainClosure(CMSCollector* collector,
1409                                 MemRegion span,
1410                                 ReferenceProcessor* rp,
1411                                 CMSBitMap* bit_map,
1412                                 CMSMarkStack*  mark_stack,
1413                                 MarkRefsIntoAndScanClosure* cl):
1414     #ifdef ASSERT
1415       _collector(collector),
1416       _span(span),
1417       _mark_stack(mark_stack),
1418     #endif // ASSERT
1419     _parallel(false),
1420     _bit_map(bit_map),
1421     _scan_closure(cl) { }
1422 
1423   ScanMarkedObjectsAgainClosure(CMSCollector* collector,
1424                                 MemRegion span,
1425                                 ReferenceProcessor* rp,
1426                                 CMSBitMap* bit_map,
1427                                 OopTaskQueue* work_queue,
1428                                 Par_MarkRefsIntoAndScanClosure* cl):
1429     #ifdef ASSERT
1430       _collector(collector),
1431       _span(span),
1432       _work_queue(work_queue),
1433     #endif // ASSERT
1434     _parallel(true),
1435     _bit_map(bit_map),
1436     _par_scan_closure(cl) { }
1437 
1438   bool do_object_b(oop obj) {
1439     guarantee(false, "Call do_object_b(oop, MemRegion) form instead");
1440     return false;
1441   }
1442   bool do_object_bm(oop p, MemRegion mr);
1443 };
1444 
1445 // This closure is used during the second checkpointing phase
1446 // to rescan the marked objects on the dirty cards in the mod
1447 // union table and the card table proper. It invokes
1448 // ScanMarkedObjectsAgainClosure above to accomplish much of its work.


1453   ScanMarkedObjectsAgainClosure  _scan_cl;
1454   size_t                         _num_dirty_cards;
1455 
1456  public:
1457   MarkFromDirtyCardsClosure(CMSCollector* collector,
1458                             MemRegion span,
1459                             CompactibleFreeListSpace* space,
1460                             CMSBitMap* bit_map,
1461                             CMSMarkStack* mark_stack,
1462                             MarkRefsIntoAndScanClosure* cl):
1463     _space(space),
1464     _num_dirty_cards(0),
1465     _scan_cl(collector, span, collector->ref_processor(), bit_map,
1466                  mark_stack, cl) { }
1467 
1468   MarkFromDirtyCardsClosure(CMSCollector* collector,
1469                             MemRegion span,
1470                             CompactibleFreeListSpace* space,
1471                             CMSBitMap* bit_map,
1472                             OopTaskQueue* work_queue,
1473                             Par_MarkRefsIntoAndScanClosure* cl):
1474     _space(space),
1475     _num_dirty_cards(0),
1476     _scan_cl(collector, span, collector->ref_processor(), bit_map,
1477              work_queue, cl) { }
1478 
1479   void do_MemRegion(MemRegion mr);
1480   void set_space(CompactibleFreeListSpace* space) { _space = space; }
1481   size_t num_dirty_cards() { return _num_dirty_cards; }
1482 };
1483 
1484 // This closure is used in the non-product build to check
1485 // that there are no MemRegions with a certain property.
1486 class FalseMemRegionClosure: public MemRegionClosure {
1487   void do_MemRegion(MemRegion mr) {
1488     guarantee(!mr.is_empty(), "Shouldn't be empty");
1489     guarantee(false, "Should never be here");
1490   }
1491 };
1492 
1493 // This closure is used during the precleaning phase




 493   virtual void execute(EnqueueTask& task);
 494 private:
 495   CMSCollector& _collector;
 496 };
 497 
 498 
 499 class CMSCollector: public CHeapObj<mtGC> {
 500   friend class VMStructs;
 501   friend class ConcurrentMarkSweepThread;
 502   friend class ConcurrentMarkSweepGeneration;
 503   friend class CompactibleFreeListSpace;
 504   friend class CMSParMarkTask;
 505   friend class CMSParInitialMarkTask;
 506   friend class CMSParRemarkTask;
 507   friend class CMSConcMarkingTask;
 508   friend class CMSRefProcTaskProxy;
 509   friend class CMSRefProcTaskExecutor;
 510   friend class ScanMarkedObjectsAgainCarefullyClosure;  // for sampling eden
 511   friend class SurvivorSpacePrecleanClosure;            // --- ditto -------
 512   friend class PushOrMarkClosure;             // to access _restart_addr
 513   friend class ParPushOrMarkClosure;          // to access _restart_addr
 514   friend class MarkFromRootsClosure;          //  -- ditto --
 515                                               // ... and for clearing cards
 516   friend class ParMarkFromRootsClosure;       //  to access _restart_addr
 517                                               // ... and for clearing cards
 518   friend class ParConcMarkingClosure;         //  to access _restart_addr etc.
 519   friend class MarkFromRootsVerifyClosure;    // to access _restart_addr
 520   friend class PushAndMarkVerifyClosure;      //  -- ditto --
 521   friend class MarkRefsIntoAndScanClosure;    // to access _overflow_list
 522   friend class PushAndMarkClosure;            //  -- ditto --
 523   friend class ParPushAndMarkClosure;         //  -- ditto --
 524   friend class CMSKeepAliveClosure;           //  -- ditto --
 525   friend class CMSDrainMarkingStackClosure;   //  -- ditto --
 526   friend class CMSInnerParMarkAndPushClosure; //  -- ditto --
 527   NOT_PRODUCT(friend class ScanMarkedObjectsAgainClosure;) //  assertion on _overflow_list
 528   friend class ReleaseForegroundGC;  // to access _foregroundGCShouldWait
 529   friend class VM_CMS_Operation;
 530   friend class VM_CMS_Initial_Mark;
 531   friend class VM_CMS_Final_Remark;
 532   friend class TraceCMSMemoryManagerStats;
 533 
 534  private:
 535   jlong _time_of_last_gc;
 536   void update_time_of_last_gc(jlong now) {
 537     _time_of_last_gc = now;
 538   }
 539 
 540   OopTaskQueueSet* _task_queues;
 541 
 542   // Overflow list of grey objects, threaded through mark-word
 543   // Manipulated with CAS in the parallel/multi-threaded case.


1265   DEBUG_ONLY(bool _verifying;)
1266 
1267  public:
1268   MarkFromRootsClosure(CMSCollector* collector, MemRegion span,
1269                        CMSBitMap* bitMap,
1270                        CMSMarkStack*  markStack,
1271                        bool should_yield, bool verifying = false);
1272   bool do_bit(size_t offset);
1273   void reset(HeapWord* addr);
1274   inline void do_yield_check();
1275 
1276  private:
1277   void scanOopsInOop(HeapWord* ptr);
1278   void do_yield_work();
1279 };
1280 
1281 // This closure is used to do concurrent multi-threaded
1282 // marking from the roots following the first checkpoint.
1283 // XXX This should really be a subclass of The serial version
1284 // above, but i have not had the time to refactor things cleanly.
1285 class ParMarkFromRootsClosure: public BitMapClosure {
1286   CMSCollector*  _collector;
1287   MemRegion      _whole_span;
1288   MemRegion      _span;
1289   CMSBitMap*     _bit_map;
1290   CMSBitMap*     _mut;
1291   OopTaskQueue*  _work_queue;
1292   CMSMarkStack*  _overflow_stack;
1293   int            _skip_bits;
1294   HeapWord*      _finger;
1295   HeapWord*      _threshold;
1296   CMSConcMarkingTask* _task;
1297  public:
1298   ParMarkFromRootsClosure(CMSConcMarkingTask* task, CMSCollector* collector,
1299                           MemRegion span,
1300                           CMSBitMap* bit_map,
1301                           OopTaskQueue* work_queue,
1302                           CMSMarkStack*  overflow_stack);
1303   bool do_bit(size_t offset);
1304   inline void do_yield_check();
1305 
1306  private:
1307   void scan_oops_in_oop(HeapWord* ptr);
1308   void do_yield_work();
1309   bool get_work_from_overflow_stack();
1310 };
1311 
1312 // The following closures are used to do certain kinds of verification of
1313 // CMS marking.
1314 class PushAndMarkVerifyClosure: public MetadataAwareOopClosure {
1315   CMSCollector*    _collector;
1316   MemRegion        _span;
1317   CMSBitMap*       _verification_bm;
1318   CMSBitMap*       _cms_bm;


1384 // [Par_]MarkRefsIntoAndScanClosure (Par_ in the parallel case)
1385 // declared in genOopClosures.hpp to accomplish some of its work.
1386 // In the parallel case the bitMap is shared, so access to
1387 // it needs to be suitably synchronized for updates by embedded
1388 // closures that update it; however, this closure itself only
1389 // reads the bit_map and because it is idempotent, is immune to
1390 // reading stale values.
1391 class ScanMarkedObjectsAgainClosure: public UpwardsObjectClosure {
1392   #ifdef ASSERT
1393     CMSCollector*          _collector;
1394     MemRegion              _span;
1395     union {
1396       CMSMarkStack*        _mark_stack;
1397       OopTaskQueue*        _work_queue;
1398     };
1399   #endif // ASSERT
1400   bool                       _parallel;
1401   CMSBitMap*                 _bit_map;
1402   union {
1403     MarkRefsIntoAndScanClosure*    _scan_closure;
1404     ParMarkRefsIntoAndScanClosure* _par_scan_closure;
1405   };
1406 
1407  public:
1408   ScanMarkedObjectsAgainClosure(CMSCollector* collector,
1409                                 MemRegion span,
1410                                 ReferenceProcessor* rp,
1411                                 CMSBitMap* bit_map,
1412                                 CMSMarkStack*  mark_stack,
1413                                 MarkRefsIntoAndScanClosure* cl):
1414     #ifdef ASSERT
1415       _collector(collector),
1416       _span(span),
1417       _mark_stack(mark_stack),
1418     #endif // ASSERT
1419     _parallel(false),
1420     _bit_map(bit_map),
1421     _scan_closure(cl) { }
1422 
1423   ScanMarkedObjectsAgainClosure(CMSCollector* collector,
1424                                 MemRegion span,
1425                                 ReferenceProcessor* rp,
1426                                 CMSBitMap* bit_map,
1427                                 OopTaskQueue* work_queue,
1428                                 ParMarkRefsIntoAndScanClosure* cl):
1429     #ifdef ASSERT
1430       _collector(collector),
1431       _span(span),
1432       _work_queue(work_queue),
1433     #endif // ASSERT
1434     _parallel(true),
1435     _bit_map(bit_map),
1436     _par_scan_closure(cl) { }
1437 
1438   bool do_object_b(oop obj) {
1439     guarantee(false, "Call do_object_b(oop, MemRegion) form instead");
1440     return false;
1441   }
1442   bool do_object_bm(oop p, MemRegion mr);
1443 };
1444 
1445 // This closure is used during the second checkpointing phase
1446 // to rescan the marked objects on the dirty cards in the mod
1447 // union table and the card table proper. It invokes
1448 // ScanMarkedObjectsAgainClosure above to accomplish much of its work.


1453   ScanMarkedObjectsAgainClosure  _scan_cl;
1454   size_t                         _num_dirty_cards;
1455 
1456  public:
1457   MarkFromDirtyCardsClosure(CMSCollector* collector,
1458                             MemRegion span,
1459                             CompactibleFreeListSpace* space,
1460                             CMSBitMap* bit_map,
1461                             CMSMarkStack* mark_stack,
1462                             MarkRefsIntoAndScanClosure* cl):
1463     _space(space),
1464     _num_dirty_cards(0),
1465     _scan_cl(collector, span, collector->ref_processor(), bit_map,
1466                  mark_stack, cl) { }
1467 
1468   MarkFromDirtyCardsClosure(CMSCollector* collector,
1469                             MemRegion span,
1470                             CompactibleFreeListSpace* space,
1471                             CMSBitMap* bit_map,
1472                             OopTaskQueue* work_queue,
1473                             ParMarkRefsIntoAndScanClosure* cl):
1474     _space(space),
1475     _num_dirty_cards(0),
1476     _scan_cl(collector, span, collector->ref_processor(), bit_map,
1477              work_queue, cl) { }
1478 
1479   void do_MemRegion(MemRegion mr);
1480   void set_space(CompactibleFreeListSpace* space) { _space = space; }
1481   size_t num_dirty_cards() { return _num_dirty_cards; }
1482 };
1483 
1484 // This closure is used in the non-product build to check
1485 // that there are no MemRegions with a certain property.
1486 class FalseMemRegionClosure: public MemRegionClosure {
1487   void do_MemRegion(MemRegion mr) {
1488     guarantee(!mr.is_empty(), "Shouldn't be empty");
1489     guarantee(false, "Should never be here");
1490   }
1491 };
1492 
1493 // This closure is used during the precleaning phase


< prev index next >