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

Print this page




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

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


 933 
 934   // Adjust size of underlying generation
 935   void compute_new_size();
 936 
 937   // GC prologue and epilogue
 938   void gc_prologue(bool full);
 939   void gc_epilogue(bool full);
 940 
 941   jlong time_of_last_gc(jlong now) {
 942     if (_collectorState <= Idling) {
 943       // gc not in progress
 944       return _time_of_last_gc;
 945     } else {
 946       // collection in progress
 947       return now;
 948     }
 949   }
 950 
 951   // Support for parallel remark of survivor space
 952   void* get_data_recorder(int thr_num);

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


1010 
1011   static void print_on_error(outputStream* st);
1012 
1013   // debugging
1014   void verify();
1015   bool verify_after_remark(bool silent = VerifySilently);
1016   void verify_ok_to_terminate() const PRODUCT_RETURN;
1017   void verify_work_stacks_empty() const PRODUCT_RETURN;
1018   void verify_overflow_empty() const PRODUCT_RETURN;
1019 
1020   // convenience methods in support of debugging
1021   static const size_t skip_header_HeapWords() PRODUCT_RETURN0;
1022   HeapWord* block_start(const void* p) const PRODUCT_RETURN0;
1023 
1024   // accessors
1025   CMSMarkStack* verification_mark_stack() { return &_markStack; }
1026   CMSBitMap*    verification_mark_bm()    { return &_verification_mark_bm; }
1027 
1028   // Initialization errors
1029   bool completed_initialization() { return _completed_initialization; }


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


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




1320   }
1321 
1322   // Printing
1323   const char* name() const;
1324   virtual const char* short_name() const { return "CMS"; }
1325   void        print() const;
1326   void printOccupancy(const char* s);
1327   bool must_be_youngest() const { return false; }
1328   bool must_be_oldest()   const { return true; }
1329 
1330   // Resize the generation after a compacting GC.  The
1331   // generation can be treated as a contiguous space
1332   // after the compaction.
1333   virtual void compute_new_size();
1334   // Resize the generation after a non-compacting
1335   // collection.
1336   void compute_new_size_free_list();
1337 
1338   CollectionTypes debug_collection_type() { return _debug_collection_type; }
1339   void rotate_debug_collection_type();




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


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


1012 
1013   static void print_on_error(outputStream* st);
1014 
1015   // debugging
1016   void verify();
1017   bool verify_after_remark(bool silent = VerifySilently);
1018   void verify_ok_to_terminate() const PRODUCT_RETURN;
1019   void verify_work_stacks_empty() const PRODUCT_RETURN;
1020   void verify_overflow_empty() const PRODUCT_RETURN;
1021 
1022   // convenience methods in support of debugging
1023   static const size_t skip_header_HeapWords() PRODUCT_RETURN0;
1024   HeapWord* block_start(const void* p) const PRODUCT_RETURN0;
1025 
1026   // accessors
1027   CMSMarkStack* verification_mark_stack() { return &_markStack; }
1028   CMSBitMap*    verification_mark_bm()    { return &_verification_mark_bm; }
1029 
1030   // Initialization errors
1031   bool completed_initialization() { return _completed_initialization; }
1032 
1033   void print_eden_and_survivor_chunk_arrays();
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;


1304   // the space.
1305   FreeChunk* find_chunk_at_end();
1306 
1307   void post_compact();
1308 
1309   // Debugging
1310   void prepare_for_verify();
1311   void verify();
1312   void print_statistics()               PRODUCT_RETURN;
1313 
1314   // Performance Counters support
1315   virtual void update_counters();
1316   virtual void update_counters(size_t used);
1317   void initialize_performance_counters();
1318   CollectorCounters* counters()  { return collector()->counters(); }
1319 
1320   // Support for parallel remark of survivor space
1321   void* get_data_recorder(int thr_num) {
1322     //Delegate to collector
1323     return collector()->get_data_recorder(thr_num);
1324   }
1325   void sample_eden_chunk() {
1326     //Delegate to collector
1327     return collector()->sample_eden_chunk();
1328   }
1329 
1330   // Printing
1331   const char* name() const;
1332   virtual const char* short_name() const { return "CMS"; }
1333   void        print() const;
1334   void printOccupancy(const char* s);
1335   bool must_be_youngest() const { return false; }
1336   bool must_be_oldest()   const { return true; }
1337 
1338   // Resize the generation after a compacting GC.  The
1339   // generation can be treated as a contiguous space
1340   // after the compaction.
1341   virtual void compute_new_size();
1342   // Resize the generation after a non-compacting
1343   // collection.
1344   void compute_new_size_free_list();
1345 
1346   CollectionTypes debug_collection_type() { return _debug_collection_type; }
1347   void rotate_debug_collection_type();