src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp

Print this page




 499 class CMSRefProcTaskExecutor: public AbstractRefProcTaskExecutor {
 500 public:
 501 
 502   CMSRefProcTaskExecutor(CMSCollector& collector)
 503     : _collector(collector)
 504   { }
 505 
 506   // Executes a task using worker threads.
 507   virtual void execute(ProcessTask& task);
 508   virtual void execute(EnqueueTask& task);
 509 private:
 510   CMSCollector& _collector;
 511 };
 512 
 513 
 514 class CMSCollector: public CHeapObj<mtGC> {
 515   friend class VMStructs;
 516   friend class ConcurrentMarkSweepThread;
 517   friend class ConcurrentMarkSweepGeneration;
 518   friend class CompactibleFreeListSpace;


 519   friend class CMSParRemarkTask;
 520   friend class CMSConcMarkingTask;
 521   friend class CMSRefProcTaskProxy;
 522   friend class CMSRefProcTaskExecutor;
 523   friend class ScanMarkedObjectsAgainCarefullyClosure;  // for sampling eden
 524   friend class SurvivorSpacePrecleanClosure;            // --- ditto -------
 525   friend class PushOrMarkClosure;             // to access _restart_addr
 526   friend class Par_PushOrMarkClosure;             // to access _restart_addr
 527   friend class MarkFromRootsClosure;          //  -- ditto --
 528                                               // ... and for clearing cards
 529   friend class Par_MarkFromRootsClosure;      //  to access _restart_addr
 530                                               // ... and for clearing cards
 531   friend class Par_ConcMarkingClosure;        //  to access _restart_addr etc.
 532   friend class MarkFromRootsVerifyClosure;    // to access _restart_addr
 533   friend class PushAndMarkVerifyClosure;      //  -- ditto --
 534   friend class MarkRefsIntoAndScanClosure;    // to access _overflow_list
 535   friend class PushAndMarkClosure;            //  -- ditto --
 536   friend class Par_PushAndMarkClosure;        //  -- ditto --
 537   friend class CMSKeepAliveClosure;           //  -- ditto --
 538   friend class CMSDrainMarkingStackClosure;   //  -- ditto --


 735   enum CMS_op_type {
 736     CMS_op_checkpointRootsInitial,
 737     CMS_op_checkpointRootsFinal
 738   };
 739 
 740   void do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause);
 741   bool stop_world_and_do(CMS_op_type op);
 742 
 743   OopTaskQueueSet* task_queues() { return _task_queues; }
 744   int*             hash_seed(int i) { return &_hash_seed[i]; }
 745   YieldingFlexibleWorkGang* conc_workers() { return _conc_workers; }
 746 
 747   // Support for parallelizing Eden rescan in CMS remark phase
 748   void sample_eden(); // ... sample Eden space top
 749 
 750  private:
 751   // Support for parallelizing young gen rescan in CMS remark phase
 752   Generation* _young_gen;  // the younger gen
 753   HeapWord** _top_addr;    // ... Top of Eden
 754   HeapWord** _end_addr;    // ... End of Eden

 755   HeapWord** _eden_chunk_array; // ... Eden partitioning array
 756   size_t     _eden_chunk_index; // ... top (exclusive) of array
 757   size_t     _eden_chunk_capacity;  // ... max entries in array
 758 
 759   // Support for parallelizing survivor space rescan
 760   HeapWord** _survivor_chunk_array;
 761   size_t     _survivor_chunk_index;
 762   size_t     _survivor_chunk_capacity;
 763   size_t*    _cursor;
 764   ChunkArray* _survivor_plab_array;
 765 
 766   // Support for marking stack overflow handling
 767   bool take_from_overflow_list(size_t num, CMSMarkStack* to_stack);
 768   bool par_take_from_overflow_list(size_t num,
 769                                    OopTaskQueue* to_work_q,
 770                                    int no_of_gc_threads);
 771   void push_on_overflow_list(oop p);
 772   void par_push_on_overflow_list(oop p);
 773   // the following is, obviously, not, in general, "MT-stable"
 774   bool overflow_list_is_empty() const;


 936   void getFreelistLocks() const;
 937   void releaseFreelistLocks() const;
 938   bool haveFreelistLocks() const;
 939 
 940   // GC prologue and epilogue
 941   void gc_prologue(bool full);
 942   void gc_epilogue(bool full);
 943 
 944   jlong time_of_last_gc(jlong now) {
 945     if (_collectorState <= Idling) {
 946       // gc not in progress
 947       return _time_of_last_gc;
 948     } else {
 949       // collection in progress
 950       return now;
 951     }
 952   }
 953 
 954   // Support for parallel remark of survivor space
 955   void* get_data_recorder(int thr_num);

 956 
 957   CMSBitMap* markBitMap()  { return &_markBitMap; }
 958   void directAllocated(HeapWord* start, size_t size);
 959 
 960   // main CMS steps and related support
 961   void checkpointRootsInitial(bool asynch);
 962   bool markFromRoots(bool asynch);  // a return value of false indicates failure
 963                                     // due to stack overflow
 964   void preclean();
 965   void checkpointRootsFinal(bool asynch, bool clear_all_soft_refs,
 966                             bool init_mark_was_synchronous);
 967   void sweep(bool asynch);
 968 
 969   // Check that the currently executing thread is the expected
 970   // one (foreground collector or background collector).
 971   static void check_correct_thread_executing() PRODUCT_RETURN;
 972   // XXXPERM void print_statistics()           PRODUCT_RETURN;
 973 
 974   bool is_cms_reachable(HeapWord* addr);
 975 


1014   // debugging
1015   void verify();
1016   bool verify_after_remark();
1017   void verify_ok_to_terminate() const PRODUCT_RETURN;
1018   void verify_work_stacks_empty() const PRODUCT_RETURN;
1019   void verify_overflow_empty() const PRODUCT_RETURN;
1020 
1021   // convenience methods in support of debugging
1022   static const size_t skip_header_HeapWords() PRODUCT_RETURN0;
1023   HeapWord* block_start(const void* p) const PRODUCT_RETURN0;
1024 
1025   // accessors
1026   CMSMarkStack* verification_mark_stack() { return &_markStack; }
1027   CMSBitMap*    verification_mark_bm()    { return &_verification_mark_bm; }
1028 
1029   // Get the bit map with a perm gen "deadness" information.
1030   CMSBitMap* perm_gen_verify_bit_map()       { return &_perm_gen_verify_bit_map; }
1031 
1032   // Initialization errors
1033   bool completed_initialization() { return _completed_initialization; }


1034 };
1035 
1036 class CMSExpansionCause : public AllStatic  {
1037  public:
1038   enum Cause {
1039     _no_expansion,
1040     _satisfy_free_ratio,
1041     _satisfy_promotion,
1042     _satisfy_allocation,
1043     _allocate_par_lab,
1044     _allocate_par_spooling_space,
1045     _adaptive_size_policy
1046   };
1047   // Return a string describing the cause of the expansion.
1048   static const char* to_string(CMSExpansionCause::Cause cause);
1049 };
1050 
1051 class ConcurrentMarkSweepGeneration: public CardGeneration {
1052   friend class VMStructs;
1053   friend class ConcurrentMarkSweepThread;


1300   // Overriding of unused functionality (sharing not yet supported with CMS)
1301   void pre_adjust_pointers();
1302   void post_compact();
1303 
1304   // Debugging
1305   void prepare_for_verify();
1306   void verify();
1307   void print_statistics()               PRODUCT_RETURN;
1308 
1309   // Performance Counters support
1310   virtual void update_counters();
1311   virtual void update_counters(size_t used);
1312   void initialize_performance_counters();
1313   CollectorCounters* counters()  { return collector()->counters(); }
1314 
1315   // Support for parallel remark of survivor space
1316   void* get_data_recorder(int thr_num) {
1317     //Delegate to collector
1318     return collector()->get_data_recorder(thr_num);
1319   }




1320 
1321   // Printing
1322   const char* name() const;
1323   virtual const char* short_name() const { return "CMS"; }
1324   void        print() const;
1325   void printOccupancy(const char* s);
1326   bool must_be_youngest() const { return false; }
1327   bool must_be_oldest()   const { return true; }
1328 
1329   void compute_new_size();
1330 
1331   CollectionTypes debug_collection_type() { return _debug_collection_type; }
1332   void rotate_debug_collection_type();
1333 };
1334 
1335 class ASConcurrentMarkSweepGeneration : public ConcurrentMarkSweepGeneration {
1336 
1337   // Return the size policy from the heap's collector
1338   // policy casted to CMSAdaptiveSizePolicy*.
1339   CMSAdaptiveSizePolicy* cms_size_policy() const;




 499 class CMSRefProcTaskExecutor: public AbstractRefProcTaskExecutor {
 500 public:
 501 
 502   CMSRefProcTaskExecutor(CMSCollector& collector)
 503     : _collector(collector)
 504   { }
 505 
 506   // Executes a task using worker threads.
 507   virtual void execute(ProcessTask& task);
 508   virtual void execute(EnqueueTask& task);
 509 private:
 510   CMSCollector& _collector;
 511 };
 512 
 513 
 514 class CMSCollector: public CHeapObj<mtGC> {
 515   friend class VMStructs;
 516   friend class ConcurrentMarkSweepThread;
 517   friend class ConcurrentMarkSweepGeneration;
 518   friend class CompactibleFreeListSpace;
 519   friend class CMSParMarkTask;
 520   friend class CMSParInitialMarkTask;
 521   friend class CMSParRemarkTask;
 522   friend class CMSConcMarkingTask;
 523   friend class CMSRefProcTaskProxy;
 524   friend class CMSRefProcTaskExecutor;
 525   friend class ScanMarkedObjectsAgainCarefullyClosure;  // for sampling eden
 526   friend class SurvivorSpacePrecleanClosure;            // --- ditto -------
 527   friend class PushOrMarkClosure;             // to access _restart_addr
 528   friend class Par_PushOrMarkClosure;             // to access _restart_addr
 529   friend class MarkFromRootsClosure;          //  -- ditto --
 530                                               // ... and for clearing cards
 531   friend class Par_MarkFromRootsClosure;      //  to access _restart_addr
 532                                               // ... and for clearing cards
 533   friend class Par_ConcMarkingClosure;        //  to access _restart_addr etc.
 534   friend class MarkFromRootsVerifyClosure;    // to access _restart_addr
 535   friend class PushAndMarkVerifyClosure;      //  -- ditto --
 536   friend class MarkRefsIntoAndScanClosure;    // to access _overflow_list
 537   friend class PushAndMarkClosure;            //  -- ditto --
 538   friend class Par_PushAndMarkClosure;        //  -- ditto --
 539   friend class CMSKeepAliveClosure;           //  -- ditto --
 540   friend class CMSDrainMarkingStackClosure;   //  -- ditto --


 737   enum CMS_op_type {
 738     CMS_op_checkpointRootsInitial,
 739     CMS_op_checkpointRootsFinal
 740   };
 741 
 742   void do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause);
 743   bool stop_world_and_do(CMS_op_type op);
 744 
 745   OopTaskQueueSet* task_queues() { return _task_queues; }
 746   int*             hash_seed(int i) { return &_hash_seed[i]; }
 747   YieldingFlexibleWorkGang* conc_workers() { return _conc_workers; }
 748 
 749   // Support for parallelizing Eden rescan in CMS remark phase
 750   void sample_eden(); // ... sample Eden space top
 751 
 752  private:
 753   // Support for parallelizing young gen rescan in CMS remark phase
 754   Generation* _young_gen;  // the younger gen
 755   HeapWord** _top_addr;    // ... Top of Eden
 756   HeapWord** _end_addr;    // ... End of Eden
 757   Mutex*     _eden_chunk_lock;
 758   HeapWord** _eden_chunk_array; // ... Eden partitioning array
 759   size_t     _eden_chunk_index; // ... top (exclusive) of array
 760   size_t     _eden_chunk_capacity;  // ... max entries in array
 761 
 762   // Support for parallelizing survivor space rescan
 763   HeapWord** _survivor_chunk_array;
 764   size_t     _survivor_chunk_index;
 765   size_t     _survivor_chunk_capacity;
 766   size_t*    _cursor;
 767   ChunkArray* _survivor_plab_array;
 768 
 769   // Support for marking stack overflow handling
 770   bool take_from_overflow_list(size_t num, CMSMarkStack* to_stack);
 771   bool par_take_from_overflow_list(size_t num,
 772                                    OopTaskQueue* to_work_q,
 773                                    int no_of_gc_threads);
 774   void push_on_overflow_list(oop p);
 775   void par_push_on_overflow_list(oop p);
 776   // the following is, obviously, not, in general, "MT-stable"
 777   bool overflow_list_is_empty() const;


 939   void getFreelistLocks() const;
 940   void releaseFreelistLocks() const;
 941   bool haveFreelistLocks() const;
 942 
 943   // GC prologue and epilogue
 944   void gc_prologue(bool full);
 945   void gc_epilogue(bool full);
 946 
 947   jlong time_of_last_gc(jlong now) {
 948     if (_collectorState <= Idling) {
 949       // gc not in progress
 950       return _time_of_last_gc;
 951     } else {
 952       // collection in progress
 953       return now;
 954     }
 955   }
 956 
 957   // Support for parallel remark of survivor space
 958   void* get_data_recorder(int thr_num);
 959   void sample_eden_chunk();
 960 
 961   CMSBitMap* markBitMap()  { return &_markBitMap; }
 962   void directAllocated(HeapWord* start, size_t size);
 963 
 964   // main CMS steps and related support
 965   void checkpointRootsInitial(bool asynch);
 966   bool markFromRoots(bool asynch);  // a return value of false indicates failure
 967                                     // due to stack overflow
 968   void preclean();
 969   void checkpointRootsFinal(bool asynch, bool clear_all_soft_refs,
 970                             bool init_mark_was_synchronous);
 971   void sweep(bool asynch);
 972 
 973   // Check that the currently executing thread is the expected
 974   // one (foreground collector or background collector).
 975   static void check_correct_thread_executing() PRODUCT_RETURN;
 976   // XXXPERM void print_statistics()           PRODUCT_RETURN;
 977 
 978   bool is_cms_reachable(HeapWord* addr);
 979 


1018   // debugging
1019   void verify();
1020   bool verify_after_remark();
1021   void verify_ok_to_terminate() const PRODUCT_RETURN;
1022   void verify_work_stacks_empty() const PRODUCT_RETURN;
1023   void verify_overflow_empty() const PRODUCT_RETURN;
1024 
1025   // convenience methods in support of debugging
1026   static const size_t skip_header_HeapWords() PRODUCT_RETURN0;
1027   HeapWord* block_start(const void* p) const PRODUCT_RETURN0;
1028 
1029   // accessors
1030   CMSMarkStack* verification_mark_stack() { return &_markStack; }
1031   CMSBitMap*    verification_mark_bm()    { return &_verification_mark_bm; }
1032 
1033   // Get the bit map with a perm gen "deadness" information.
1034   CMSBitMap* perm_gen_verify_bit_map()       { return &_perm_gen_verify_bit_map; }
1035 
1036   // Initialization errors
1037   bool completed_initialization() { return _completed_initialization; }
1038 
1039   void print_eden_and_survivor_chunk_arrays();
1040 };
1041 
1042 class CMSExpansionCause : public AllStatic  {
1043  public:
1044   enum Cause {
1045     _no_expansion,
1046     _satisfy_free_ratio,
1047     _satisfy_promotion,
1048     _satisfy_allocation,
1049     _allocate_par_lab,
1050     _allocate_par_spooling_space,
1051     _adaptive_size_policy
1052   };
1053   // Return a string describing the cause of the expansion.
1054   static const char* to_string(CMSExpansionCause::Cause cause);
1055 };
1056 
1057 class ConcurrentMarkSweepGeneration: public CardGeneration {
1058   friend class VMStructs;
1059   friend class ConcurrentMarkSweepThread;


1306   // Overriding of unused functionality (sharing not yet supported with CMS)
1307   void pre_adjust_pointers();
1308   void post_compact();
1309 
1310   // Debugging
1311   void prepare_for_verify();
1312   void verify();
1313   void print_statistics()               PRODUCT_RETURN;
1314 
1315   // Performance Counters support
1316   virtual void update_counters();
1317   virtual void update_counters(size_t used);
1318   void initialize_performance_counters();
1319   CollectorCounters* counters()  { return collector()->counters(); }
1320 
1321   // Support for parallel remark of survivor space
1322   void* get_data_recorder(int thr_num) {
1323     //Delegate to collector
1324     return collector()->get_data_recorder(thr_num);
1325   }
1326   void sample_eden_chunk() {
1327     //Delegate to collector
1328     return collector()->sample_eden_chunk();
1329   }
1330 
1331   // Printing
1332   const char* name() const;
1333   virtual const char* short_name() const { return "CMS"; }
1334   void        print() const;
1335   void printOccupancy(const char* s);
1336   bool must_be_youngest() const { return false; }
1337   bool must_be_oldest()   const { return true; }
1338 
1339   void compute_new_size();
1340 
1341   CollectionTypes debug_collection_type() { return _debug_collection_type; }
1342   void rotate_debug_collection_type();
1343 };
1344 
1345 class ASConcurrentMarkSweepGeneration : public ConcurrentMarkSweepGeneration {
1346 
1347   // Return the size policy from the heap's collector
1348   // policy casted to CMSAdaptiveSizePolicy*.
1349   CMSAdaptiveSizePolicy* cms_size_policy() const;