Print this page


Split Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp
          +++ new/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp
↓ open down ↓ 527 lines elided ↑ open up ↑
 528  528  
 529  529    // Performance Counters
 530  530    CollectorCounters* _gc_counters;
 531  531  
 532  532    // Initialization Errors
 533  533    bool _completed_initialization;
 534  534  
 535  535    // In support of ExplicitGCInvokesConcurrent
 536  536    static   bool _full_gc_requested;
 537  537    unsigned int  _collection_count_start;
      538 +  
 538  539    // Should we unload classes this concurrent cycle?
 539      -  // Set in response to a concurrent full gc request.
 540      -  bool _unload_classes;
 541      -  bool _unloaded_classes_last_cycle;
      540 +  bool _should_unload_classes;
      541 +  unsigned int  _concurrent_cycles_since_last_unload;
      542 +  unsigned int concurrent_cycles_since_last_unload() const {
      543 +    return _concurrent_cycles_since_last_unload;
      544 +  }
 542  545    // Did we (allow) unload classes in the previous concurrent cycle?
 543      -  bool cms_unloaded_classes_last_cycle() const {
 544      -    return _unloaded_classes_last_cycle || CMSClassUnloadingEnabled;
      546 +  bool unloaded_classes_last_cycle() const {
      547 +    return concurrent_cycles_since_last_unload() == 0;
 545  548    }
 546  549  
 547  550    // Verification support
 548  551    CMSBitMap     _verification_mark_bm;
 549  552    void verify_after_remark_work_1();
 550  553    void verify_after_remark_work_2();
 551  554  
 552  555    // true if any verification flag is on.
 553  556    bool _verifying;
 554  557    bool verifying() const { return _verifying; }
↓ open down ↓ 85 lines elided ↑ open up ↑
 640  643                                   // wants to go active
 641  644    static bool _foregroundGCShouldWait;  // true iff background GC is active and has not
 642  645                                   // yet passed the baton to the foreground GC
 643  646  
 644  647    // Support for CMSScheduleRemark (abortable preclean)
 645  648    bool _abort_preclean;
 646  649    bool _start_sampling;
 647  650  
 648  651    int    _numYields;
 649  652    size_t _numDirtyCards;
 650      -  uint   _sweepCount;
      653 +  size_t _sweep_count;
 651  654    // number of full gc's since the last concurrent gc.
 652  655    uint   _full_gcs_since_conc_gc;
 653  656  
 654      -  // if occupancy exceeds this, start a new gc cycle
 655      -  double _initiatingOccupancy;
 656  657    // occupancy used for bootstrapping stats
 657  658    double _bootstrap_occupancy;
 658  659  
 659  660    // timer
 660  661    elapsedTimer _timer;
 661  662  
 662  663    // Timing, allocation and promotion statistics, used for scheduling.
 663  664    CMSStats      _stats;
 664  665  
 665  666    // Allocation limits installed in the young gen, used only in
↓ open down ↓ 152 lines elided ↑ open up ↑
 818  819                 ConcurrentMarkSweepGeneration* permGen,
 819  820                 CardTableRS*                   ct,
 820  821                 ConcurrentMarkSweepPolicy*     cp);
 821  822    ConcurrentMarkSweepThread* cmsThread() { return _cmsThread; }
 822  823  
 823  824    ReferenceProcessor* ref_processor() { return _ref_processor; }
 824  825    void ref_processor_init();
 825  826  
 826  827    Mutex* bitMapLock()        const { return _markBitMap.lock();    }
 827  828    static CollectorState abstract_state() { return _collectorState;  }
 828      -  double initiatingOccupancy() const { return _initiatingOccupancy; }
 829  829  
 830  830    bool should_abort_preclean() const; // Whether preclean should be aborted.
 831  831    size_t get_eden_used() const;
 832  832    size_t get_eden_capacity() const;
 833  833  
 834  834    ConcurrentMarkSweepGeneration* cmsGen() { return _cmsGen; }
 835  835  
 836  836    // locking checks
 837  837    NOT_PRODUCT(static bool have_cms_token();)
 838  838  
↓ open down ↓ 3 lines elided ↑ open up ↑
 842  842    void collect(bool   full,
 843  843                 bool   clear_all_soft_refs,
 844  844                 size_t size,
 845  845                 bool   tlab);
 846  846    void collect_in_background(bool clear_all_soft_refs);
 847  847    void collect_in_foreground(bool clear_all_soft_refs);
 848  848  
 849  849    // In support of ExplicitGCInvokesConcurrent
 850  850    static void request_full_gc(unsigned int full_gc_count);
 851  851    // Should we unload classes in a particular concurrent cycle?
 852      -  bool cms_should_unload_classes() const {
 853      -    assert(!_unload_classes ||  ExplicitGCInvokesConcurrentAndUnloadsClasses,
 854      -           "Inconsistency; see CR 6541037");
 855      -    return _unload_classes || CMSClassUnloadingEnabled;
      852 +  bool should_unload_classes() const {
      853 +    return _should_unload_classes;
 856  854    }
      855 +  bool update_should_unload_classes();
 857  856  
 858  857    void direct_allocated(HeapWord* start, size_t size);
 859  858  
 860  859    // Object is dead if not marked and current phase is sweeping.
 861  860    bool is_dead_obj(oop obj) const;
 862  861  
 863  862    // After a promotion (of "start"), do any necessary marking.
 864  863    // If "par", then it's being done by a parallel GC thread.
 865  864    // The last two args indicate if we need precise marking
 866  865    // and if so the size of the object so it can be dirtied
↓ open down ↓ 57 lines elided ↑ open up ↑
 924  923    void resetYields()     { _numYields = 0;    }
 925  924    void incrementYields() { _numYields++;      }
 926  925    void resetNumDirtyCards()               { _numDirtyCards = 0; }
 927  926    void incrementNumDirtyCards(size_t num) { _numDirtyCards += num; }
 928  927    size_t  numDirtyCards()                 { return _numDirtyCards; }
 929  928  
 930  929    static bool foregroundGCShouldWait() { return _foregroundGCShouldWait; }
 931  930    static void set_foregroundGCShouldWait(bool v) { _foregroundGCShouldWait = v; }
 932  931    static bool foregroundGCIsActive() { return _foregroundGCIsActive; }
 933  932    static void set_foregroundGCIsActive(bool v) { _foregroundGCIsActive = v; }
 934      -  uint  sweepCount() const             { return _sweepCount; }
 935      -  void incrementSweepCount()           { _sweepCount++; }
      933 +  size_t sweep_count() const             { return _sweep_count; }
      934 +  void   increment_sweep_count()         { _sweep_count++; }
 936  935  
 937  936    // Timers/stats for gc scheduling and incremental mode pacing.
 938  937    CMSStats& stats() { return _stats; }
 939  938  
 940  939    // Convenience methods that check whether CMSIncrementalMode is enabled and
 941  940    // forward to the corresponding methods in ConcurrentMarkSweepThread.
 942  941    static void start_icms();
 943  942    static void stop_icms();    // Called at the end of the cms cycle.
 944  943    static void disable_icms(); // Called before a foreground collection.
 945  944    static void enable_icms();  // Called after a foreground collection.
↓ open down ↓ 69 lines elided ↑ open up ↑
1015 1014    bool incremental_collection_failed() {
1016 1015      return _incremental_collection_failed;
1017 1016    }
1018 1017    void set_incremental_collection_failed() {
1019 1018      _incremental_collection_failed = true;
1020 1019    }
1021 1020    void clear_incremental_collection_failed() {
1022 1021      _incremental_collection_failed = false;
1023 1022    }
1024 1023  
     1024 +  // accessors
     1025 +  void set_expansion_cause(CMSExpansionCause::Cause v) { _expansion_cause = v;}
     1026 +  CMSExpansionCause::Cause expansion_cause() const { return _expansion_cause; }
     1027 +
1025 1028   private:
1026 1029    // For parallel young-gen GC support.
1027 1030    CMSParGCThreadState** _par_gc_thread_states;
1028 1031  
1029 1032    // Reason generation was expanded
1030 1033    CMSExpansionCause::Cause _expansion_cause;
1031 1034  
1032      -  // accessors
1033      -  void set_expansion_cause(CMSExpansionCause::Cause v) { _expansion_cause = v;}
1034      -  CMSExpansionCause::Cause expansion_cause() { return _expansion_cause; }
1035      -
1036 1035    // In support of MinChunkSize being larger than min object size
1037 1036    const double _dilatation_factor;
1038 1037  
1039 1038    enum CollectionTypes {
1040 1039      Concurrent_collection_type          = 0,
1041 1040      MS_foreground_collection_type       = 1,
1042 1041      MSC_foreground_collection_type      = 2,
1043 1042      Unknown_collection_type             = 3
1044 1043    };
1045 1044  
1046 1045    CollectionTypes _debug_collection_type;
1047 1046  
     1047 +  // Fraction of current occupancy at which to start a CMS collection which
     1048 +  // will collect this generation (at least).
     1049 +  double _initiating_occupancy;
     1050 +
1048 1051   protected:
1049 1052    // Grow generation by specified size (returns false if unable to grow)
1050 1053    bool grow_by(size_t bytes);
1051 1054    // Grow generation to reserved size.
1052 1055    bool grow_to_reserved();
1053 1056    // Shrink generation by specified size (returns false if unable to shrink)
1054 1057    virtual void shrink_by(size_t bytes);
1055 1058  
1056 1059    // Update statistics for GC
1057 1060    virtual void update_gc_stats(int level, bool full);
1058 1061  
1059 1062    // Maximum available space in the generation (including uncommitted)
1060 1063    // space.
1061 1064    size_t max_available() const;
1062 1065  
     1066 +  // getter and initializer for _initiating_occupancy field.
     1067 +  double initiating_occupancy() const { return _initiating_occupancy; }
     1068 +  void   init_initiating_occupancy(intx io, intx tr);
     1069 +
1063 1070   public:
1064 1071    ConcurrentMarkSweepGeneration(ReservedSpace rs, size_t initial_byte_size,
1065 1072                                  int level, CardTableRS* ct,
1066 1073                                  bool use_adaptive_freelists,
1067 1074                                  FreeBlockDictionary::DictionaryChoice);
1068 1075  
1069 1076    // Accessors
1070 1077    CMSCollector* collector() const { return _collector; }
1071 1078    static void set_collector(CMSCollector* collector) {
1072 1079      assert(_collector == NULL, "already set");
↓ open down ↓ 23 lines elided ↑ open up ↑
1096 1103  
1097 1104    // Override
1098 1105    virtual void ref_processor_init();
1099 1106  
1100 1107    void clear_expansion_cause() { _expansion_cause = CMSExpansionCause::_no_expansion; }
1101 1108  
1102 1109    // Space enquiries
1103 1110    size_t capacity() const;
1104 1111    size_t used() const;
1105 1112    size_t free() const;
1106      -  double occupancy()      { return ((double)used())/((double)capacity()); }
     1113 +  double occupancy() const { return ((double)used())/((double)capacity()); }
1107 1114    size_t contiguous_available() const;
1108 1115    size_t unsafe_max_alloc_nogc() const;
1109 1116  
1110 1117    // over-rides
1111 1118    MemRegion used_region() const;
1112 1119    MemRegion used_region_at_save_marks() const;
1113 1120  
1114 1121    // Does a "full" (forced) collection invoked on this generation collect
1115 1122    // all younger generations as well? Note that the second conjunct is a
1116 1123    // hack to allow the collection of the younger gen first if the flag is
↓ open down ↓ 34 lines elided ↑ open up ↑
1151 1158    // This one should not be called for CMS.
1152 1159    virtual void par_promote_alloc_undo(int thread_num,
1153 1160                                        HeapWord* obj, size_t word_sz);
1154 1161    virtual void par_promote_alloc_done(int thread_num);
1155 1162    virtual void par_oop_since_save_marks_iterate_done(int thread_num);
1156 1163  
1157 1164    virtual bool promotion_attempt_is_safe(size_t promotion_in_bytes,
1158 1165      bool younger_handles_promotion_failure) const;
1159 1166  
1160 1167    bool should_collect(bool full, size_t size, bool tlab);
1161      -    // XXXPERM
1162      -  bool shouldConcurrentCollect(double initiatingOccupancy); // XXXPERM
     1168 +  virtual bool should_concurrent_collect() const;
     1169 +  virtual bool is_too_full() const;
1163 1170    void collect(bool   full,
1164 1171                 bool   clear_all_soft_refs,
1165 1172                 size_t size,
1166 1173                 bool   tlab);
1167 1174  
1168 1175    HeapWord* expand_and_allocate(size_t word_size,
1169 1176                                  bool tlab,
1170 1177                                  bool parallel = false);
1171 1178  
1172 1179    // GC prologue and epilogue
↓ open down ↓ 650 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX