src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.hpp
author eosterlund
Mon, 26 Feb 2018 09:34:12 +0100
changeset 49164 7e958a8ebcd3
parent 48831 05894c073b7e
child 49377 ecd91135d645
permissions -rw-r--r--
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy Reviewed-by: stefank, coleenp, kvn, ehelin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
48831
05894c073b7e 8196199: Remove miscellaneous oop comparison operators
coleenp
parents: 47580
diff changeset
     2
 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5343
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5343
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5343
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30581
diff changeset
    25
#ifndef SHARE_VM_GC_CMS_CONCURRENTMARKSWEEPGENERATION_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30581
diff changeset
    26
#define SHARE_VM_GC_CMS_CONCURRENTMARKSWEEPGENERATION_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30581
diff changeset
    28
#include "gc/cms/cmsOopClosures.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30581
diff changeset
    29
#include "gc/cms/gSpaceCounters.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30581
diff changeset
    30
#include "gc/cms/yieldingWorkgroup.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30581
diff changeset
    31
#include "gc/shared/cardGeneration.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30581
diff changeset
    32
#include "gc/shared/gcHeapSummary.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30581
diff changeset
    33
#include "gc/shared/gcStats.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30581
diff changeset
    34
#include "gc/shared/gcWhen.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30581
diff changeset
    35
#include "gc/shared/generationCounters.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30581
diff changeset
    36
#include "gc/shared/space.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30581
diff changeset
    37
#include "gc/shared/taskqueue.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34293
diff changeset
    38
#include "logging/log.hpp"
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    39
#include "memory/iterator.hpp"
30291
54cdc5c1a9cb 8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents: 30175
diff changeset
    40
#include "memory/virtualspace.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
    41
#include "runtime/mutexLocker.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
    42
#include "services/memoryService.hpp"
30175
543725014c9d 8076457: Fix includes of inline.hpp in GC code
stefank
parents: 29701
diff changeset
    43
#include "utilities/bitMap.hpp"
543725014c9d 8076457: Fix includes of inline.hpp in GC code
stefank
parents: 29701
diff changeset
    44
#include "utilities/stack.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
    45
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
// ConcurrentMarkSweepGeneration is in support of a concurrent
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// mark-sweep old generation in the Detlefs-Printezis--Boehm-Demers-Schenker
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// style. We assume, for now, that this generation is always the
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    49
// seniormost generation and for simplicity
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// in the first implementation, that this generation is a single compactible
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
// space. Neither of these restrictions appears essential, and will be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
// relaxed in the future when more time is available to implement the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// greater generality (and there's a need for it).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// Concurrent mode failures are currently handled by
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// means of a sliding mark-compact.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
25485
9c3d427eed01 8034246: remove CMS and ParNew adaptive size policy code
jcoomes
parents: 25356
diff changeset
    58
class AdaptiveSizePolicy;
29701
f638fc81a3d0 8075803: Fix GC includes and forward declarations
stefank
parents: 28511
diff changeset
    59
class CMSCollector;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
class CMSConcMarkingTask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
class CMSGCAdaptivePolicyCounters;
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
    62
class CMSTracer;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
    63
class ConcurrentGCTimer;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
class ConcurrentMarkSweepGeneration;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
class ConcurrentMarkSweepPolicy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
class ConcurrentMarkSweepThread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
class CompactibleFreeListSpace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
class FreeChunk;
29701
f638fc81a3d0 8075803: Fix GC includes and forward declarations
stefank
parents: 28511
diff changeset
    69
class ParNewGeneration;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
class PromotionInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
class ScanMarkedObjectsAgainCarefullyClosure;
16681
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15605
diff changeset
    72
class TenuredGeneration;
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
    73
class SerialOldTracer;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
// A generic CMS bit map. It's the basis for both the CMS marking bit map
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
// as well as for the mod union table (in each case only a subset of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
// methods are used). This is essentially a wrapper around the BitMap class,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
// with one bit per (1<<_shifter) HeapWords. (i.e. for the marking bit map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
// we have _shifter == 0. and for the mod union table we have
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48831
diff changeset
    80
// shifter == CardTable::card_shift - LogHeapWordSize.)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// XXX 64-bit issues in BitMap?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
class CMSBitMap VALUE_OBJ_CLASS_SPEC {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37235
diff changeset
    85
  HeapWord*    _bmStartWord;   // base address of range covered by map
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37235
diff changeset
    86
  size_t       _bmWordSize;    // map size (in #HeapWords covered)
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37235
diff changeset
    87
  const int    _shifter;       // shifts to convert HeapWord to bit position
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  VirtualSpace _virtual_space; // underlying the bit map
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37235
diff changeset
    89
  BitMapView   _bm;            // the bit map itself
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37235
diff changeset
    90
  Mutex* const _lock;          // mutex protecting _bm;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  // constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  CMSBitMap(int shifter, int mutex_rank, const char* mutex_name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // allocates the actual storage for the map
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  bool allocate(MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // field getter
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  Mutex* lock() const { return _lock; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // locking verifier convenience function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  void assert_locked() const PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // inquiries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  HeapWord* startWord()   const { return _bmStartWord; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  size_t    sizeInWords() const { return _bmWordSize;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  size_t    sizeInBits()  const { return _bm.size();   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // the following is one past the last word in space
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  HeapWord* endWord()     const { return _bmStartWord + _bmWordSize; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // reading marks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  bool isMarked(HeapWord* addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  bool par_isMarked(HeapWord* addr) const; // do not lock checks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  bool isUnmarked(HeapWord* addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  bool isAllClear() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // writing marks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  void mark(HeapWord* addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // For marking by parallel GC threads;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  // returns true if we did, false if another thread did
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  bool par_mark(HeapWord* addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  void mark_range(MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  void par_mark_range(MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  void mark_large_range(MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  void par_mark_large_range(MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  void par_clear(HeapWord* addr); // For unmarking by parallel GC threads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  void clear_range(MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  void par_clear_range(MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  void clear_large_range(MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  void par_clear_large_range(MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  void clear_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  void clear_all_incrementally();  // Not yet implemented!!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  NOT_PRODUCT(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    // checks the memory region for validity
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    void region_invariant(MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // iteration
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  void iterate(BitMapClosure* cl) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    _bm.iterate(cl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  void iterate(BitMapClosure* cl, HeapWord* left, HeapWord* right);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  void dirty_range_iterate_clear(MemRegionClosure* cl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  void dirty_range_iterate_clear(MemRegion mr, MemRegionClosure* cl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  // auxiliary support for iteration
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  HeapWord* getNextMarkedWordAddress(HeapWord* addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  HeapWord* getNextMarkedWordAddress(HeapWord* start_addr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
                                            HeapWord* end_addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  HeapWord* getNextUnmarkedWordAddress(HeapWord* addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  HeapWord* getNextUnmarkedWordAddress(HeapWord* start_addr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
                                              HeapWord* end_addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  MemRegion getAndClearMarkedRegion(HeapWord* addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  MemRegion getAndClearMarkedRegion(HeapWord* start_addr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
                                           HeapWord* end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  // conversion utilities
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  HeapWord* offsetToHeapWord(size_t offset) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  size_t    heapWordToOffset(HeapWord* addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  size_t    heapWordDiffToOffsetDiff(size_t diff) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
16685
41c34debcde0 8011872: Include Bit Map addresses in the hs_err files
stefank
parents: 16681
diff changeset
   163
  void print_on_error(outputStream* st, const char* prefix) const;
41c34debcde0 8011872: Include Bit Map addresses in the hs_err files
stefank
parents: 16681
diff changeset
   164
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  // debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  // is this address range covered by the bit-map?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  NOT_PRODUCT(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    bool covers(MemRegion mr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    bool covers(HeapWord* start, size_t size = 0) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  void verifyNoOneBitsInRange(HeapWord* left, HeapWord* right) PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
// Represents a marking stack used by the CMS collector.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
// Ideally this should be GrowableArray<> just like MSC's marking stack(s).
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12630
diff changeset
   176
class CMSMarkStack: public CHeapObj<mtGC>  {
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   177
  friend class CMSCollector;   // To get at expansion stats further below.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   179
  VirtualSpace _virtual_space;  // Space for the stack
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   180
  oop*   _base;      // Bottom of stack
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   181
  size_t _index;     // One more than last occupied index
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   182
  size_t _capacity;  // Max #elements
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   183
  Mutex  _par_lock;  // An advisory lock used in case of parallel access
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   184
  NOT_PRODUCT(size_t _max_depth;)  // Max depth plumbed during run
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
 protected:
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   187
  size_t _hit_limit;      // We hit max stack size limit
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   188
  size_t _failed_double;  // We failed expansion before hitting limit
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  CMSMarkStack():
28163
322d55d167be 8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents: 27903
diff changeset
   192
    _par_lock(Mutex::event, "CMSMarkStack._par_lock", true,
322d55d167be 8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents: 27903
diff changeset
   193
              Monitor::_safepoint_check_never),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
    _hit_limit(0),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    _failed_double(0) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  bool allocate(size_t size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  size_t capacity() const { return _capacity; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  oop pop() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    if (!isEmpty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
      return _base[--_index] ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  bool push(oop ptr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    if (isFull()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
      _base[_index++] = ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      NOT_PRODUCT(_max_depth = MAX2(_max_depth, _index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  bool isEmpty() const { return _index == 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  bool isFull()  const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    assert(_index <= _capacity, "buffer overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    return _index == _capacity;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  size_t length() { return _index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  // "Parallel versions" of some of the above
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  oop par_pop() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
    // lock and pop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    MutexLockerEx x(&_par_lock, Mutex::_no_safepoint_check_flag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
    return pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  bool par_push(oop ptr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    // lock and push
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    MutexLockerEx x(&_par_lock, Mutex::_no_safepoint_check_flag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    return push(ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  // Forcibly reset the stack, losing all of its contents.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  void reset() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    _index = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   244
  // Expand the stack, typically in response to an overflow condition.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  void expand();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  // Compute the least valued stack element.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  oop least_value(HeapWord* low) {
48831
05894c073b7e 8196199: Remove miscellaneous oop comparison operators
coleenp
parents: 47580
diff changeset
   249
    HeapWord* least = low;
05894c073b7e 8196199: Remove miscellaneous oop comparison operators
coleenp
parents: 47580
diff changeset
   250
    for (size_t i = 0; i < _index; i++) {
05894c073b7e 8196199: Remove miscellaneous oop comparison operators
coleenp
parents: 47580
diff changeset
   251
      least = MIN2(least, (HeapWord*)_base[i]);
05894c073b7e 8196199: Remove miscellaneous oop comparison operators
coleenp
parents: 47580
diff changeset
   252
    }
05894c073b7e 8196199: Remove miscellaneous oop comparison operators
coleenp
parents: 47580
diff changeset
   253
    return (oop)least;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   256
  // Exposed here to allow stack expansion in || case.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  Mutex* par_lock() { return &_par_lock; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
class CardTableRS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
class CMSParGCThreadState;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
class ModUnionClosure: public MemRegionClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  CMSBitMap* _t;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  ModUnionClosure(CMSBitMap* t): _t(t) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  void do_MemRegion(MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
class ModUnionClosurePar: public ModUnionClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  ModUnionClosurePar(CMSBitMap* t): ModUnionClosure(t) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  void do_MemRegion(MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
// Survivor Chunk Array in support of parallelization of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
// Survivor Space rescan.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12630
diff changeset
   279
class ChunkArray: public CHeapObj<mtGC> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  size_t _index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  size_t _capacity;
6423
1ef0582c27c2 6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents: 6258
diff changeset
   282
  size_t _overflows;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  HeapWord** _array;   // storage for array
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
 public:
6423
1ef0582c27c2 6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents: 6258
diff changeset
   286
  ChunkArray() : _index(0), _capacity(0), _overflows(0), _array(NULL) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  ChunkArray(HeapWord** a, size_t c):
6423
1ef0582c27c2 6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents: 6258
diff changeset
   288
    _index(0), _capacity(c), _overflows(0), _array(a) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  HeapWord** array() { return _array; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  void set_array(HeapWord** a) { _array = a; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  size_t capacity() { return _capacity; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  void set_capacity(size_t c) { _capacity = c; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  size_t end() {
6423
1ef0582c27c2 6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents: 6258
diff changeset
   297
    assert(_index <= capacity(),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32623
diff changeset
   298
           "_index (" SIZE_FORMAT ") > _capacity (" SIZE_FORMAT "): out of bounds",
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32623
diff changeset
   299
           _index, _capacity);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
    return _index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  }  // exclusive
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  HeapWord* nth(size_t n) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
    assert(n < end(), "Out of bounds access");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    return _array[n];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  void reset() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    _index = 0;
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34293
diff changeset
   310
    if (_overflows > 0) {
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34293
diff changeset
   311
      log_trace(gc)("CMS: ChunkArray[" SIZE_FORMAT "] overflowed " SIZE_FORMAT " times", _capacity, _overflows);
6423
1ef0582c27c2 6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents: 6258
diff changeset
   312
    }
1ef0582c27c2 6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents: 6258
diff changeset
   313
    _overflows = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  void record_sample(HeapWord* p, size_t sz) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
    // For now we do not do anything with the size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    if (_index < _capacity) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
      _array[_index++] = p;
6423
1ef0582c27c2 6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents: 6258
diff changeset
   320
    } else {
1ef0582c27c2 6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents: 6258
diff changeset
   321
      ++_overflows;
1ef0582c27c2 6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents: 6258
diff changeset
   322
      assert(_index == _capacity,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32623
diff changeset
   323
             "_index (" SIZE_FORMAT ") > _capacity (" SIZE_FORMAT
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32623
diff changeset
   324
             "): out of bounds at overflow#" SIZE_FORMAT,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32623
diff changeset
   325
             _index, _capacity, _overflows);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
// Timing, allocation and promotion statistics for gc scheduling and incremental
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
// mode pacing.  Most statistics are exponential averages.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
class CMSStats VALUE_OBJ_CLASS_SPEC {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  ConcurrentMarkSweepGeneration* const _cms_gen;   // The cms (old) gen.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  // The following are exponential averages with factor alpha:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  //   avg = (100 - alpha) * avg + alpha * cur_sample
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  //   The durations measure:  end_time[n] - start_time[n]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  //   The periods measure:    start_time[n] - start_time[n-1]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  // The cms period and duration include only concurrent collections; time spent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  // in foreground cms collections due to System.gc() or because of a failure to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  // keep up are not included.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  // There are 3 alphas to "bootstrap" the statistics.  The _saved_alpha is the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  // real value, but is used only after the first period.  A value of 100 is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  // used for the first sample so it gets the entire weight.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  unsigned int _saved_alpha; // 0-100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  unsigned int _gc0_alpha;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  unsigned int _cms_alpha;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  double _gc0_duration;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  double _gc0_period;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  size_t _gc0_promoted;         // bytes promoted per gc0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  double _cms_duration;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  double _cms_duration_pre_sweep; // time from initiation to start of sweep
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  double _cms_period;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  size_t _cms_allocated;        // bytes of direct allocation per gc0 period
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  // Timers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  elapsedTimer _cms_timer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  TimeStamp    _gc0_begin_time;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  TimeStamp    _cms_begin_time;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  TimeStamp    _cms_end_time;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  // Snapshots of the amount used in the CMS generation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  size_t _cms_used_at_gc0_begin;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  size_t _cms_used_at_gc0_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  size_t _cms_used_at_cms_begin;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  // Used to prevent the duty cycle from being reduced in the middle of a cms
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  // cycle.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  bool _allow_duty_cycle_reduction;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
    _GC0_VALID = 0x1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
    _CMS_VALID = 0x2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
    _ALL_VALID = _GC0_VALID | _CMS_VALID
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  unsigned int _valid_bits;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
 protected:
4574
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
   387
  // In support of adjusting of cms trigger ratios based on history
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
   388
  // of concurrent mode failure.
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
   389
  double cms_free_adjustment_factor(size_t free) const;
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
   390
  void   adjust_cms_free_adjustment_factor(bool fail, size_t free);
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
   391
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  CMSStats(ConcurrentMarkSweepGeneration* cms_gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
           unsigned int alpha = CMSExpAvgFactor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  // Whether or not the statistics contain valid data; higher level statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  // cannot be called until this returns true (they require at least one young
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  // gen and one cms cycle to have completed).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  bool valid() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  // Record statistics.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  void record_gc0_begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  void record_gc0_end(size_t cms_gen_bytes_used);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  void record_cms_begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  void record_cms_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  // Allow management of the cms timer, which must be stopped/started around
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  // yield points.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  elapsedTimer& cms_timer()     { return _cms_timer; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  void start_cms_timer()        { _cms_timer.start(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  void stop_cms_timer()         { _cms_timer.stop(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  // Basic statistics; units are seconds or bytes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  double gc0_period() const     { return _gc0_period; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  double gc0_duration() const   { return _gc0_duration; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  size_t gc0_promoted() const   { return _gc0_promoted; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  double cms_period() const          { return _cms_period; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  double cms_duration() const        { return _cms_duration; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  size_t cms_allocated() const       { return _cms_allocated; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  size_t cms_used_at_gc0_end() const { return _cms_used_at_gc0_end;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  // Seconds since the last background cms cycle began or ended.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  double cms_time_since_begin() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  double cms_time_since_end() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  // Higher level statistics--caller must check that valid() returns true before
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  // calling.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  // Returns bytes promoted per second of wall clock time.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  double promotion_rate() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  // Returns bytes directly allocated per second of wall clock time.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  double cms_allocation_rate() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  // Rate at which space in the cms generation is being consumed (sum of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  // above two).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  double cms_consumption_rate() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  // Returns an estimate of the number of seconds until the cms generation will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  // fill up, assuming no collection work is done.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  double time_until_cms_gen_full() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  // Returns an estimate of the number of seconds remaining until
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  // the cms generation collection should start.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  double time_until_cms_start() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  // End of higher level statistics.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  // Debugging.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  void print_on(outputStream* st) const PRODUCT_RETURN;
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34293
diff changeset
   452
  void print() const { print_on(tty); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
// A closure related to weak references processing which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
// we embed in the CMSCollector, since we need to pass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
// it to the reference processor for secondary filtering
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
// of references based on reachability of referent;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
// see role of _is_alive_non_header closure in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
// ReferenceProcessor class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
// For objects in the CMS generation, this closure checks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
// if the object is "live" (reachable). Used in weak
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
// reference processing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
class CMSIsAliveClosure: public BoolObjectClosure {
390
2e094c1be4af 6662086: 6u4+, 7b11+: CMS never clears referents when -XX:+ParallelRefProcEnabled
ysr
parents: 360
diff changeset
   465
  const MemRegion  _span;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  const CMSBitMap* _bit_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  friend class CMSCollector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  CMSIsAliveClosure(MemRegion span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
                    CMSBitMap* bit_map):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
    _span(span),
390
2e094c1be4af 6662086: 6u4+, 7b11+: CMS never clears referents when -XX:+ParallelRefProcEnabled
ysr
parents: 360
diff changeset
   473
    _bit_map(bit_map) {
2e094c1be4af 6662086: 6u4+, 7b11+: CMS never clears referents when -XX:+ParallelRefProcEnabled
ysr
parents: 360
diff changeset
   474
    assert(!span.is_empty(), "Empty span could spell trouble");
2e094c1be4af 6662086: 6u4+, 7b11+: CMS never clears referents when -XX:+ParallelRefProcEnabled
ysr
parents: 360
diff changeset
   475
  }
2e094c1be4af 6662086: 6u4+, 7b11+: CMS never clears referents when -XX:+ParallelRefProcEnabled
ysr
parents: 360
diff changeset
   476
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  bool do_object_b(oop obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
// Implements AbstractRefProcTaskExecutor for CMS.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
class CMSRefProcTaskExecutor: public AbstractRefProcTaskExecutor {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  CMSRefProcTaskExecutor(CMSCollector& collector)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    : _collector(collector)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  // Executes a task using worker threads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  virtual void execute(ProcessTask& task);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  virtual void execute(EnqueueTask& task);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  CMSCollector& _collector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12630
diff changeset
   497
class CMSCollector: public CHeapObj<mtGC> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  friend class ConcurrentMarkSweepThread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  friend class ConcurrentMarkSweepGeneration;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  friend class CompactibleFreeListSpace;
18996
05c86e558c94 6412968: CMS Long initial mark pauses
jmasa
parents: 18994
diff changeset
   502
  friend class CMSParMarkTask;
05c86e558c94 6412968: CMS Long initial mark pauses
jmasa
parents: 18994
diff changeset
   503
  friend class CMSParInitialMarkTask;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  friend class CMSParRemarkTask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  friend class CMSConcMarkingTask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  friend class CMSRefProcTaskProxy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  friend class CMSRefProcTaskExecutor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  friend class ScanMarkedObjectsAgainCarefullyClosure;  // for sampling eden
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  friend class SurvivorSpacePrecleanClosure;            // --- ditto -------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  friend class PushOrMarkClosure;             // to access _restart_addr
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35204
diff changeset
   511
  friend class ParPushOrMarkClosure;          // to access _restart_addr
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
  friend class MarkFromRootsClosure;          //  -- ditto --
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
                                              // ... and for clearing cards
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35204
diff changeset
   514
  friend class ParMarkFromRootsClosure;       //  to access _restart_addr
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
                                              // ... and for clearing cards
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35204
diff changeset
   516
  friend class ParConcMarkingClosure;         //  to access _restart_addr etc.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  friend class MarkFromRootsVerifyClosure;    // to access _restart_addr
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
  friend class PushAndMarkVerifyClosure;      //  -- ditto --
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  friend class MarkRefsIntoAndScanClosure;    // to access _overflow_list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  friend class PushAndMarkClosure;            //  -- ditto --
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35204
diff changeset
   521
  friend class ParPushAndMarkClosure;         //  -- ditto --
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  friend class CMSKeepAliveClosure;           //  -- ditto --
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  friend class CMSDrainMarkingStackClosure;   //  -- ditto --
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  friend class CMSInnerParMarkAndPushClosure; //  -- ditto --
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  NOT_PRODUCT(friend class ScanMarkedObjectsAgainClosure;) //  assertion on _overflow_list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  friend class ReleaseForegroundGC;  // to access _foregroundGCShouldWait
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  friend class VM_CMS_Operation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  friend class VM_CMS_Initial_Mark;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  friend class VM_CMS_Final_Remark;
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   530
  friend class TraceCMSMemoryManagerStats;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  jlong _time_of_last_gc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  void update_time_of_last_gc(jlong now) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
    _time_of_last_gc = now;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  OopTaskQueueSet* _task_queues;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  // Overflow list of grey objects, threaded through mark-word
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
  // Manipulated with CAS in the parallel/multi-threaded case.
41317
ba006b931e27 8165857: CMS _overflow_list is missing volatile specifiers.
eosterlund
parents: 41283
diff changeset
   542
  oopDesc* volatile _overflow_list;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  // The following array-pair keeps track of mark words
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   544
  // displaced for accommodating overflow list above.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
  // This code will likely be revisited under RFE#4922830.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12630
diff changeset
   546
  Stack<oop, mtGC>     _preserved_oop_stack;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12630
diff changeset
   547
  Stack<markOop, mtGC> _preserved_mark_stack;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  int*             _hash_seed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  // In support of multi-threaded concurrent phases
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
  YieldingFlexibleWorkGang* _conc_workers;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
  // Performance Counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  CollectorCounters* _gc_counters;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  // Initialization Errors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
  bool _completed_initialization;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  // In support of ExplicitGCInvokesConcurrent
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   561
  static bool _full_gc_requested;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   562
  static GCCause::Cause _full_gc_cause;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   563
  unsigned int _collection_count_start;
341
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
   564
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  // Should we unload classes this concurrent cycle?
341
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
   566
  bool _should_unload_classes;
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
   567
  unsigned int  _concurrent_cycles_since_last_unload;
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
   568
  unsigned int concurrent_cycles_since_last_unload() const {
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
   569
    return _concurrent_cycles_since_last_unload;
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
   570
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  // Did we (allow) unload classes in the previous concurrent cycle?
341
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
   572
  bool unloaded_classes_last_cycle() const {
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
   573
    return concurrent_cycles_since_last_unload() == 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  }
2885
7dd49b9daa4a 6848641: CMSCollector::_roots_scanning_options should be initialized
ysr
parents: 2105
diff changeset
   575
  // Root scanning options for perm gen
7dd49b9daa4a 6848641: CMSCollector::_roots_scanning_options should be initialized
ysr
parents: 2105
diff changeset
   576
  int _roots_scanning_options;
7dd49b9daa4a 6848641: CMSCollector::_roots_scanning_options should be initialized
ysr
parents: 2105
diff changeset
   577
  int roots_scanning_options() const      { return _roots_scanning_options; }
7dd49b9daa4a 6848641: CMSCollector::_roots_scanning_options should be initialized
ysr
parents: 2105
diff changeset
   578
  void add_root_scanning_option(int o)    { _roots_scanning_options |= o;   }
7dd49b9daa4a 6848641: CMSCollector::_roots_scanning_options should be initialized
ysr
parents: 2105
diff changeset
   579
  void remove_root_scanning_option(int o) { _roots_scanning_options &= ~o;  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
  // Verification support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
  CMSBitMap     _verification_mark_bm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  void verify_after_remark_work_1();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
  void verify_after_remark_work_2();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   586
  // True if any verification flag is on.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
  bool _verifying;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
  bool verifying() const { return _verifying; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  void set_verifying(bool v) { _verifying = v; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  // Collector policy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
  ConcurrentMarkSweepPolicy* _collector_policy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  ConcurrentMarkSweepPolicy* collector_policy() { return _collector_policy; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
17325
694922ea5785 8013184: CMS: Call reset_after_compaction() only if a compaction has been done
jmasa
parents: 17112
diff changeset
   595
  void set_did_compact(bool v);
694922ea5785 8013184: CMS: Call reset_after_compaction() only if a compaction has been done
jmasa
parents: 17112
diff changeset
   596
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  // XXX Move these to CMSStats ??? FIX ME !!!
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   598
  elapsedTimer _inter_sweep_timer;   // Time between sweeps
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   599
  elapsedTimer _intra_sweep_timer;   // Time _in_ sweeps
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   600
  // Padded decaying average estimates of the above
4574
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
   601
  AdaptivePaddedAverage _inter_sweep_estimate;
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
   602
  AdaptivePaddedAverage _intra_sweep_estimate;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   604
  CMSTracer* _gc_tracer_cm;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   605
  ConcurrentGCTimer* _gc_timer_cm;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   606
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   607
  bool _cms_start_registered;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   608
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   609
  GCHeapSummary _last_heap_summary;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   610
  MetaspaceSummary _last_metaspace_summary;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   611
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   612
  void register_gc_start(GCCause::Cause cause);
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   613
  void register_gc_end();
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   614
  void save_heap_summary();
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   615
  void report_heap_summary(GCWhen::Type when);
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   616
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
 protected:
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   618
  ConcurrentMarkSweepGeneration* _cmsGen;  // Old gen (CMS)
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   619
  MemRegion                      _span;    // Span covering above two
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   620
  CardTableRS*                   _ct;      // Card table
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
  // CMS marking support structures
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
  CMSBitMap     _markBitMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  CMSBitMap     _modUnionTable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
  CMSMarkStack  _markStack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   627
  HeapWord*     _restart_addr; // In support of marking stack overflow
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  void          lower_restart_addr(HeapWord* low);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
  // Counters in support of marking stack / work queue overflow handling:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
  // a non-zero value indicates certain types of overflow events during
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  // the current CMS cycle and could lead to stack resizing efforts at
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
  // an opportune future time.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
  size_t        _ser_pmc_preclean_ovflw;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
  size_t        _ser_pmc_remark_ovflw;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
  size_t        _par_pmc_remark_ovflw;
1605
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 1388
diff changeset
   637
  size_t        _ser_kac_preclean_ovflw;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
  size_t        _ser_kac_ovflw;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
  size_t        _par_kac_ovflw;
1910
386106352d02 6786503: Overflow list performance can be improved
ysr
parents: 1893
diff changeset
   640
  NOT_PRODUCT(ssize_t _num_par_pushes;)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   642
  // ("Weak") Reference processing support.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
  ReferenceProcessor*            _ref_processor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
  CMSIsAliveClosure              _is_alive_closure;
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   645
  // Keep this textually after _markBitMap and _span; c'tor dependency.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   647
  ConcurrentMarkSweepThread*     _cmsThread;   // The thread doing the work
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
  ModUnionClosurePar _modUnionClosurePar;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  // CMS abstract state machine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
  // initial_state: Idling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
  // next_state(Idling)            = {Marking}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
  // next_state(Marking)           = {Precleaning, Sweeping}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
  // next_state(Precleaning)       = {AbortablePreclean, FinalMarking}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
  // next_state(AbortablePreclean) = {FinalMarking}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
  // next_state(FinalMarking)      = {Sweeping}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
  // next_state(Sweeping)          = {Resizing}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
  // next_state(Resizing)          = {Resetting}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
  // next_state(Resetting)         = {Idling}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
  // The numeric values below are chosen so that:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
  // . _collectorState <= Idling ==  post-sweep && pre-mark
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
  // . _collectorState in (Idling, Sweeping) == {initial,final}marking ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
  //                                            precleaning || abortablePrecleanb
4574
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
   664
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
  enum CollectorState {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
    Resizing            = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
    Resetting           = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
    Idling              = 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
    InitialMarking      = 3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
    Marking             = 4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
    Precleaning         = 5,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
    AbortablePreclean   = 6,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
    FinalMarking        = 7,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
    Sweeping            = 8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
  };
4574
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
   676
 protected:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
  static CollectorState _collectorState;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
  // State related to prologue/epilogue invocation for my generations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
  bool _between_prologue_and_epilogue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   682
  // Signaling/State related to coordination between fore- and background GC
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
  // Note: When the baton has been passed from background GC to foreground GC,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
  // _foregroundGCIsActive is true and _foregroundGCShouldWait is false.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
  static bool _foregroundGCIsActive;    // true iff foreground collector is active or
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
                                 // wants to go active
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
  static bool _foregroundGCShouldWait;  // true iff background GC is active and has not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
                                 // yet passed the baton to the foreground GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
  // Support for CMSScheduleRemark (abortable preclean)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
  bool _abort_preclean;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
  bool _start_sampling;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
  int    _numYields;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  size_t _numDirtyCards;
4574
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
   696
  size_t _sweep_count;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   698
  // Occupancy used for bootstrapping stats
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
  double _bootstrap_occupancy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   701
  // Timer
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
  elapsedTimer _timer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
  // Timing, allocation and promotion statistics, used for scheduling.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
  CMSStats      _stats;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
  enum CMS_op_type {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
    CMS_op_checkpointRootsInitial,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
    CMS_op_checkpointRootsFinal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
12630
ddf6ee008138 7166894: Add gc cause to GC logging for all collectors
brutisso
parents: 12507
diff changeset
   712
  void do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
  bool stop_world_and_do(CMS_op_type op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
  OopTaskQueueSet* task_queues() { return _task_queues; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
  int*             hash_seed(int i) { return &_hash_seed[i]; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  YieldingFlexibleWorkGang* conc_workers() { return _conc_workers; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
  // Support for parallelizing Eden rescan in CMS remark phase
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
  void sample_eden(); // ... sample Eden space top
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
  // Support for parallelizing young gen rescan in CMS remark phase
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 32195
diff changeset
   724
  ParNewGeneration* _young_gen;
27903
14c6e2f23fa0 8065992: Change CMSCollector::_young_gen to be a ParNewGeneration*
brutisso
parents: 27899
diff changeset
   725
41283
2615c024f3eb 8033552: Fix missing missing volatile specifiers in CAS operations in GC code
eosterlund
parents: 38704
diff changeset
   726
  HeapWord* volatile* _top_addr;    // ... Top of Eden
2615c024f3eb 8033552: Fix missing missing volatile specifiers in CAS operations in GC code
eosterlund
parents: 38704
diff changeset
   727
  HeapWord**          _end_addr;    // ... End of Eden
2615c024f3eb 8033552: Fix missing missing volatile specifiers in CAS operations in GC code
eosterlund
parents: 38704
diff changeset
   728
  Mutex*              _eden_chunk_lock;
2615c024f3eb 8033552: Fix missing missing volatile specifiers in CAS operations in GC code
eosterlund
parents: 38704
diff changeset
   729
  HeapWord**          _eden_chunk_array; // ... Eden partitioning array
2615c024f3eb 8033552: Fix missing missing volatile specifiers in CAS operations in GC code
eosterlund
parents: 38704
diff changeset
   730
  size_t              _eden_chunk_index; // ... top (exclusive) of array
2615c024f3eb 8033552: Fix missing missing volatile specifiers in CAS operations in GC code
eosterlund
parents: 38704
diff changeset
   731
  size_t              _eden_chunk_capacity;  // ... max entries in array
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
  // Support for parallelizing survivor space rescan
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
  HeapWord** _survivor_chunk_array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
  size_t     _survivor_chunk_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
  size_t     _survivor_chunk_capacity;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
  size_t*    _cursor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
  ChunkArray* _survivor_plab_array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
  // Support for marking stack overflow handling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
  bool take_from_overflow_list(size_t num, CMSMarkStack* to_stack);
6759
67b1a69ef5aa 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 6423
diff changeset
   742
  bool par_take_from_overflow_list(size_t num,
67b1a69ef5aa 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 6423
diff changeset
   743
                                   OopTaskQueue* to_work_q,
67b1a69ef5aa 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 6423
diff changeset
   744
                                   int no_of_gc_threads);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
  void push_on_overflow_list(oop p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
  void par_push_on_overflow_list(oop p);
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   747
  // The following is, obviously, not, in general, "MT-stable"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
  bool overflow_list_is_empty() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
  void preserve_mark_if_necessary(oop p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
  void par_preserve_mark_if_necessary(oop p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
  void preserve_mark_work(oop p, markOop m);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
  void restore_preserved_marks_if_any();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
  NOT_PRODUCT(bool no_preserved_marks() const;)
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   755
  // In support of testing overflow code
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
  NOT_PRODUCT(int _overflow_counter;)
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   757
  NOT_PRODUCT(bool simulate_overflow();)       // Sequential
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
  NOT_PRODUCT(bool par_simulate_overflow();)   // MT version
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
  // CMS work methods
27686
f91c482793e6 8064702: Remove the CMS foreground collector
brutisso
parents: 27625
diff changeset
   761
  void checkpointRootsInitialWork(); // Initial checkpoint work
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   763
  // A return value of false indicates failure due to stack overflow
27686
f91c482793e6 8064702: Remove the CMS foreground collector
brutisso
parents: 27625
diff changeset
   764
  bool markFromRootsWork();  // Concurrent marking work
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
 public:   // FIX ME!!! only for testing
27686
f91c482793e6 8064702: Remove the CMS foreground collector
brutisso
parents: 27625
diff changeset
   767
  bool do_marking_st();      // Single-threaded marking
f91c482793e6 8064702: Remove the CMS foreground collector
brutisso
parents: 27625
diff changeset
   768
  bool do_marking_mt();      // Multi-threaded  marking
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   772
  // Concurrent precleaning work
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 32195
diff changeset
   773
  size_t preclean_mod_union_table(ConcurrentMarkSweepGeneration* old_gen,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
                                  ScanMarkedObjectsAgainCarefullyClosure* cl);
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 32195
diff changeset
   775
  size_t preclean_card_table(ConcurrentMarkSweepGeneration* old_gen,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
                             ScanMarkedObjectsAgainCarefullyClosure* cl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
  // Does precleaning work, returning a quantity indicative of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
  // the amount of "useful work" done.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
  size_t preclean_work(bool clean_refs, bool clean_survivors);
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
   780
  void preclean_cld(MarkRefsIntoAndScanClosure* cl, Mutex* freelistLock);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
  void abortable_preclean(); // Preclean while looking for possible abort
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
  void initialize_sequential_subtasks_for_young_gen_rescan(int i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
  // Helper function for above; merge-sorts the per-thread plab samples
6759
67b1a69ef5aa 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 6423
diff changeset
   784
  void merge_survivor_plab_arrays(ContiguousSpace* surv, int no_of_gc_threads);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
  // Resets (i.e. clears) the per-thread plab sample vectors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
  void reset_survivor_plab_arrays();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   788
  // Final (second) checkpoint work
27686
f91c482793e6 8064702: Remove the CMS foreground collector
brutisso
parents: 27625
diff changeset
   789
  void checkpointRootsFinalWork();
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   790
  // Work routine for parallel version of remark
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
  void do_remark_parallel();
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   792
  // Work routine for non-parallel version of remark
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
  void do_remark_non_parallel();
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   794
  // Reference processing work routine (during second checkpoint)
27686
f91c482793e6 8064702: Remove the CMS foreground collector
brutisso
parents: 27625
diff changeset
   795
  void refProcessingWork();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   797
  // Concurrent sweeping work
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 32195
diff changeset
   798
  void sweepWork(ConcurrentMarkSweepGeneration* old_gen);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
33153
b9545e2c94df 8139294: TestGCEventMixedWithCMSConcurrent.java still fails after JDK-8134953
brutisso
parents: 33105
diff changeset
   800
  // Concurrent resetting of support data structures
b9545e2c94df 8139294: TestGCEventMixedWithCMSConcurrent.java still fails after JDK-8134953
brutisso
parents: 33105
diff changeset
   801
  void reset_concurrent();
b9545e2c94df 8139294: TestGCEventMixedWithCMSConcurrent.java still fails after JDK-8134953
brutisso
parents: 33105
diff changeset
   802
  // Resetting of support data structures from a STW full GC
b9545e2c94df 8139294: TestGCEventMixedWithCMSConcurrent.java still fails after JDK-8134953
brutisso
parents: 33105
diff changeset
   803
  void reset_stw();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
  // Clear _expansion_cause fields of constituent generations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
  void clear_expansion_cause();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   808
  // An auxiliary method used to record the ends of
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
  // used regions of each generation to limit the extent of sweep
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
  void save_sweep_limits();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
  // A work method used by the foreground collector to do
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
  // a mark-sweep-compact.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
  void do_compaction_work(bool clear_all_soft_refs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   816
  // Work methods for reporting concurrent mode interruption or failure
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   817
  bool is_external_interruption();
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   818
  void report_concurrent_mode_interruption();
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   819
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   820
  // If the background GC is active, acquire control from the background
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
  // GC and do the collection.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
  void acquire_control_and_collect(bool   full, bool clear_all_soft_refs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
  // For synchronizing passing of control from background to foreground
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
  // GC.  waitForForegroundGC() is called by the background
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
  // collector.  It if had to wait for a foreground collection,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
  // it returns true and the background collection should assume
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
  // that the collection was finished by the foreground
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
  // collector.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
  bool waitForForegroundGC();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
  size_t block_size_using_printezis_bits(HeapWord* addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
  size_t block_size_if_printezis_bits(HeapWord* addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
  HeapWord* next_card_start_after_block(HeapWord* addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
  void setup_cms_unloading_and_verification_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
  CMSCollector(ConcurrentMarkSweepGeneration* cmsGen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
               CardTableRS*                   ct,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
               ConcurrentMarkSweepPolicy*     cp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
  ConcurrentMarkSweepThread* cmsThread() { return _cmsThread; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
  ReferenceProcessor* ref_processor() { return _ref_processor; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
  void ref_processor_init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
  Mutex* bitMapLock()        const { return _markBitMap.lock();    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
  static CollectorState abstract_state() { return _collectorState;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
  bool should_abort_preclean() const; // Whether preclean should be aborted.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
  size_t get_eden_used() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
  size_t get_eden_capacity() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
  ConcurrentMarkSweepGeneration* cmsGen() { return _cmsGen; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   855
  // Locking checks
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
  NOT_PRODUCT(static bool have_cms_token();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
  bool shouldConcurrentCollect();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
  void collect(bool   full,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
               bool   clear_all_soft_refs,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
               size_t size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
               bool   tlab);
27686
f91c482793e6 8064702: Remove the CMS foreground collector
brutisso
parents: 27625
diff changeset
   864
  void collect_in_background(GCCause::Cause cause);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
  // In support of ExplicitGCInvokesConcurrent
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17625
diff changeset
   867
  static void request_full_gc(unsigned int full_gc_count, GCCause::Cause cause);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
  // Should we unload classes in a particular concurrent cycle?
341
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
   869
  bool should_unload_classes() const {
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
   870
    return _should_unload_classes;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   872
  void update_should_unload_classes();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
  void direct_allocated(HeapWord* start, size_t size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
  // Object is dead if not marked and current phase is sweeping.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
  bool is_dead_obj(oop obj) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
  // After a promotion (of "start"), do any necessary marking.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
  // If "par", then it's being done by a parallel GC thread.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
  // The last two args indicate if we need precise marking
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
  // and if so the size of the object so it can be dirtied
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
  // in its entirety.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
  void promoted(bool par, HeapWord* start,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
                bool is_obj_array, size_t obj_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
  void getFreelistLocks() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
  void releaseFreelistLocks() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
  bool haveFreelistLocks() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
16681
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15605
diff changeset
   891
  // Adjust size of underlying generation
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15605
diff changeset
   892
  void compute_new_size();
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15605
diff changeset
   893
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
  // GC prologue and epilogue
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
  void gc_prologue(bool full);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
  void gc_epilogue(bool full);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
  jlong time_of_last_gc(jlong now) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
    if (_collectorState <= Idling) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
      // gc not in progress
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
      return _time_of_last_gc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
      // collection in progress
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
      return now;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
  // Support for parallel remark of survivor space
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
  void* get_data_recorder(int thr_num);
18994
d32a17b7502c 6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents: 18687
diff changeset
   910
  void sample_eden_chunk();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
  CMSBitMap* markBitMap()  { return &_markBitMap; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
  void directAllocated(HeapWord* start, size_t size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   915
  // Main CMS steps and related support
27686
f91c482793e6 8064702: Remove the CMS foreground collector
brutisso
parents: 27625
diff changeset
   916
  void checkpointRootsInitial();
f91c482793e6 8064702: Remove the CMS foreground collector
brutisso
parents: 27625
diff changeset
   917
  bool markFromRoots();  // a return value of false indicates failure
f91c482793e6 8064702: Remove the CMS foreground collector
brutisso
parents: 27625
diff changeset
   918
                         // due to stack overflow
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
  void preclean();
27686
f91c482793e6 8064702: Remove the CMS foreground collector
brutisso
parents: 27625
diff changeset
   920
  void checkpointRootsFinal();
f91c482793e6 8064702: Remove the CMS foreground collector
brutisso
parents: 27625
diff changeset
   921
  void sweep();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
  // Check that the currently executing thread is the expected
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
  // one (foreground collector or background collector).
4574
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
   925
  static void check_correct_thread_executing() PRODUCT_RETURN;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
34293
4c3fe9d26a2a 8143544: Make CMSCollector::is_cms_reachable() non-product
brutisso
parents: 33587
diff changeset
   927
  NOT_PRODUCT(bool is_cms_reachable(HeapWord* addr);)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
  // Performance Counter Support
37235
d9a0c407ac98 8153302: [BACKOUT] STW phases at Concurrent GC should count in PerfCounter
dcubed
parents: 37218
diff changeset
   930
  CollectorCounters* counters()    { return _gc_counters; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   932
  // Timer stuff
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
  void    startTimer() { assert(!_timer.is_active(), "Error"); _timer.start();   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
  void    stopTimer()  { assert( _timer.is_active(), "Error"); _timer.stop();    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
  void    resetTimer() { assert(!_timer.is_active(), "Error"); _timer.reset();   }
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34293
diff changeset
   936
  jlong   timerTicks() { assert(!_timer.is_active(), "Error"); return _timer.ticks(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
  int  yields()          { return _numYields; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
  void resetYields()     { _numYields = 0;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
  void incrementYields() { _numYields++;      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
  void resetNumDirtyCards()               { _numDirtyCards = 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
  void incrementNumDirtyCards(size_t num) { _numDirtyCards += num; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
  size_t  numDirtyCards()                 { return _numDirtyCards; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
  static bool foregroundGCShouldWait() { return _foregroundGCShouldWait; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
  static void set_foregroundGCShouldWait(bool v) { _foregroundGCShouldWait = v; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
  static bool foregroundGCIsActive() { return _foregroundGCIsActive; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
  static void set_foregroundGCIsActive(bool v) { _foregroundGCIsActive = v; }
4574
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
   949
  size_t sweep_count() const             { return _sweep_count; }
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
   950
  void   increment_sweep_count()         { _sweep_count++; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
  // Timers/stats for gc scheduling and incremental mode pacing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
  CMSStats& stats() { return _stats; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
  // Adaptive size policy
25485
9c3d427eed01 8034246: remove CMS and ParNew adaptive size policy code
jcoomes
parents: 25356
diff changeset
   956
  AdaptiveSizePolicy* size_policy();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
16685
41c34debcde0 8011872: Include Bit Map addresses in the hs_err files
stefank
parents: 16681
diff changeset
   958
  static void print_on_error(outputStream* st);
41c34debcde0 8011872: Include Bit Map addresses in the hs_err files
stefank
parents: 16681
diff changeset
   959
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   960
  // Debugging
12379
2cf45b79ce3a 4988100: oop_verify_old_oop appears to be dead
brutisso
parents: 10240
diff changeset
   961
  void verify();
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34293
diff changeset
   962
  bool verify_after_remark();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
  void verify_ok_to_terminate() const PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
  void verify_work_stacks_empty() const PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
  void verify_overflow_empty() const PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   967
  // Convenience methods in support of debugging
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
  static const size_t skip_header_HeapWords() PRODUCT_RETURN0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
  HeapWord* block_start(const void* p) const PRODUCT_RETURN0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
   971
  // Accessors
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
  CMSMarkStack* verification_mark_stack() { return &_markStack; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
  CMSBitMap*    verification_mark_bm()    { return &_verification_mark_bm; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
  // Initialization errors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
  bool completed_initialization() { return _completed_initialization; }
18994
d32a17b7502c 6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents: 18687
diff changeset
   977
d32a17b7502c 6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents: 18687
diff changeset
   978
  void print_eden_and_survivor_chunk_arrays();
35204
78a0fd90a70f 8068394: Trace event for concurrent GC phases
sangheki
parents: 35061
diff changeset
   979
78a0fd90a70f 8068394: Trace event for concurrent GC phases
sangheki
parents: 35061
diff changeset
   980
  ConcurrentGCTimer* gc_timer_cm() const { return _gc_timer_cm; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
class CMSExpansionCause : public AllStatic  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
  enum Cause {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
    _no_expansion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
    _satisfy_free_ratio,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
    _satisfy_promotion,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
    _satisfy_allocation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
    _allocate_par_lab,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
    _allocate_par_spooling_space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
    _adaptive_size_policy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
  // Return a string describing the cause of the expansion.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
  static const char* to_string(CMSExpansionCause::Cause cause);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
class ConcurrentMarkSweepGeneration: public CardGeneration {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
  friend class ConcurrentMarkSweepThread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
  friend class ConcurrentMarkSweep;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
  friend class CMSCollector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
  static CMSCollector*       _collector; // the collector that collects us
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
  CompactibleFreeListSpace*  _cmsSpace;  // underlying space (only one for now)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
  // Performance Counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
  GenerationCounters*      _gen_counters;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
  GSpaceCounters*          _space_counters;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
  // Words directly allocated, used by CMSStats.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
  size_t _direct_allocated_words;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
  // Non-product stat counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
  NOT_PRODUCT(
6258
68f252c6e825 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 6245
diff changeset
  1016
    size_t _numObjectsPromoted;
68f252c6e825 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 6245
diff changeset
  1017
    size_t _numWordsPromoted;
68f252c6e825 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 6245
diff changeset
  1018
    size_t _numObjectsAllocated;
68f252c6e825 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 6245
diff changeset
  1019
    size_t _numWordsAllocated;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
  // Used for sizing decisions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
  bool _incremental_collection_failed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
  bool incremental_collection_failed() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
    return _incremental_collection_failed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
  void set_incremental_collection_failed() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
    _incremental_collection_failed = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
  void clear_incremental_collection_failed() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
    _incremental_collection_failed = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
341
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
  1034
  // accessors
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
  1035
  void set_expansion_cause(CMSExpansionCause::Cause v) { _expansion_cause = v;}
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
  1036
  CMSExpansionCause::Cause expansion_cause() const { return _expansion_cause; }
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
  1037
28033
ab63acbd99ec 8066782: Move common code from CMSGeneration and TenuredGeneration to CardGeneration
brutisso
parents: 28031
diff changeset
  1038
  // Accessing spaces
ab63acbd99ec 8066782: Move common code from CMSGeneration and TenuredGeneration to CardGeneration
brutisso
parents: 28031
diff changeset
  1039
  CompactibleSpace* space() const { return (CompactibleSpace*)_cmsSpace; }
ab63acbd99ec 8066782: Move common code from CMSGeneration and TenuredGeneration to CardGeneration
brutisso
parents: 28031
diff changeset
  1040
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
  // For parallel young-gen GC support.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
  CMSParGCThreadState** _par_gc_thread_states;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
  // Reason generation was expanded
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
  CMSExpansionCause::Cause _expansion_cause;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
  // In support of MinChunkSize being larger than min object size
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
  const double _dilatation_factor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
  1051
  // True if a compacting collection was done.
17325
694922ea5785 8013184: CMS: Call reset_after_compaction() only if a compaction has been done
jmasa
parents: 17112
diff changeset
  1052
  bool _did_compact;
694922ea5785 8013184: CMS: Call reset_after_compaction() only if a compaction has been done
jmasa
parents: 17112
diff changeset
  1053
  bool did_compact() { return _did_compact; }
694922ea5785 8013184: CMS: Call reset_after_compaction() only if a compaction has been done
jmasa
parents: 17112
diff changeset
  1054
341
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
  1055
  // Fraction of current occupancy at which to start a CMS collection which
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
  1056
  // will collect this generation (at least).
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
  1057
  double _initiating_occupancy;
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
  1058
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
  // Shrink generation by specified size (returns false if unable to shrink)
16681
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15605
diff changeset
  1061
  void shrink_free_list_by(size_t bytes);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
  // Update statistics for GC
31358
693058672cc6 8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents: 30764
diff changeset
  1064
  virtual void update_gc_stats(Generation* current_generation, bool full);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
  // Maximum available space in the generation (including uncommitted)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
  // space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
  size_t max_available() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
341
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
  1070
  // getter and initializer for _initiating_occupancy field.
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
  1071
  double initiating_occupancy() const { return _initiating_occupancy; }
15605
bf7de87bbe3a 8006432: Ratio flags should be unsigned
jwilhelm
parents: 13728
diff changeset
  1072
  void   init_initiating_occupancy(intx io, uintx tr);
341
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
  1073
28033
ab63acbd99ec 8066782: Move common code from CMSGeneration and TenuredGeneration to CardGeneration
brutisso
parents: 28031
diff changeset
  1074
  void expand_for_gc_cause(size_t bytes, size_t expand_bytes, CMSExpansionCause::Cause cause);
ab63acbd99ec 8066782: Move common code from CMSGeneration and TenuredGeneration to CardGeneration
brutisso
parents: 28031
diff changeset
  1075
ab63acbd99ec 8066782: Move common code from CMSGeneration and TenuredGeneration to CardGeneration
brutisso
parents: 28031
diff changeset
  1076
  void assert_correct_size_change_locking();
ab63acbd99ec 8066782: Move common code from CMSGeneration and TenuredGeneration to CardGeneration
brutisso
parents: 28031
diff changeset
  1077
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
 public:
33587
c04a7462b0e6 8139952: Remove UseCMSAdaptiveFreeLists, UseAsyncConcMarkSweepGC, CMSDictionaryChoice, CMSOverflowEarlyRestoration and CMSTestInFreeList
david
parents: 33580
diff changeset
  1079
  ConcurrentMarkSweepGeneration(ReservedSpace rs, size_t initial_byte_size, CardTableRS* ct);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
  CMSCollector* collector() const { return _collector; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
  static void set_collector(CMSCollector* collector) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
    assert(_collector == NULL, "already set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
    _collector = collector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
  CompactibleFreeListSpace*  cmsSpace() const { return _cmsSpace;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
  Mutex* freelistLock() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
  virtual Generation::Name kind() { return Generation::ConcurrentMarkSweep; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
17325
694922ea5785 8013184: CMS: Call reset_after_compaction() only if a compaction has been done
jmasa
parents: 17112
diff changeset
  1093
  void set_did_compact(bool v) { _did_compact = v; }
694922ea5785 8013184: CMS: Call reset_after_compaction() only if a compaction has been done
jmasa
parents: 17112
diff changeset
  1094
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
  bool refs_discovery_is_atomic() const { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
  bool refs_discovery_is_mt()     const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
    // Note: CMS does MT-discovery during the parallel-remark
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
    // phases. Use ReferenceProcessorMTMutator to make refs
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
    // discovery MT-safe during such phases or other parallel
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
    // discovery phases in the future. This may all go away
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
    // if/when we decide that refs discovery is sufficiently
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
    // rare that the cost of the CAS's involved is in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
    // noise. That's a measurement that should be done, and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
    // the code simplified if that turns out to be the case.
8688
493d12ccc6db 6668573: CMS: reference processing crash if ParallelCMSThreads > ParallelGCThreads
ysr
parents: 7903
diff changeset
  1105
    return ConcGCThreads > 1;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
  // Override
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
  virtual void ref_processor_init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
  void clear_expansion_cause() { _expansion_cause = CMSExpansionCause::_no_expansion; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
  // Space enquiries
341
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
  1114
  double occupancy() const { return ((double)used())/((double)capacity()); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
  size_t contiguous_available() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
  size_t unsafe_max_alloc_nogc() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
  // over-rides
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
  MemRegion used_region_at_save_marks() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
  1121
  // Adjust quantities in the generation affected by
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
  // the compaction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
  void reset_after_compaction();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
  // Allocation support
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
  HeapWord* allocate(size_t size, bool tlab);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
  HeapWord* have_lock_and_allocate(size_t size, bool tlab);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 341
diff changeset
  1128
  oop       promote(oop obj, size_t obj_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
  HeapWord* par_allocate(size_t size, bool tlab) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
    return allocate(size, tlab);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
  // Used by CMSStats to track direct allocation.  The value is sampled and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
  // reset after each young gen collection.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
  size_t direct_allocated_words() const { return _direct_allocated_words; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
  void reset_direct_allocated_words()   { _direct_allocated_words = 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
  // Overrides for parallel promotion.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
  virtual oop par_promote(int thread_num,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
                          oop obj, markOop m, size_t word_sz);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
  virtual void par_promote_alloc_done(int thread_num);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
  virtual void par_oop_since_save_marks_iterate_done(int thread_num);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
6985
e9364ec299ac 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 6762
diff changeset
  1145
  virtual bool promotion_attempt_is_safe(size_t promotion_in_bytes) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 32195
diff changeset
  1147
  // Inform this (old) generation that a promotion failure was
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 32195
diff changeset
  1148
  // encountered during a collection of the young generation.
4574
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
  1149
  virtual void promotion_failure_occurred();
b2d5b0975515 6631166: CMS: better heuristics when combatting fragmentation
ysr
parents: 3690
diff changeset
  1150
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
  bool should_collect(bool full, size_t size, bool tlab);
341
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
  1152
  virtual bool should_concurrent_collect() const;
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
  1153
  virtual bool is_too_full() const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
  void collect(bool   full,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
               bool   clear_all_soft_refs,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
               size_t size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
               bool   tlab);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
  HeapWord* expand_and_allocate(size_t word_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
                                bool tlab,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
                                bool parallel = false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
  // GC prologue and epilogue
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
  void gc_prologue(bool full);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
  void gc_prologue_work(bool full, bool registerClosure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
                        ModUnionClosure* modUnionClosure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
  void gc_epilogue(bool full);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
  void gc_epilogue_work(bool full);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
  // Time since last GC of this generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
  jlong time_of_last_gc(jlong now) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
    return collector()->time_of_last_gc(now);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
  void update_time_of_last_gc(jlong now) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
    collector()-> update_time_of_last_gc(now);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
  // Allocation failure
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
  void shrink(size_t bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
  HeapWord* expand_and_par_lab_allocate(CMSParGCThreadState* ps, size_t word_sz);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
  bool expand_and_ensure_spooling_space(PromotionInfo* promo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
  // Iteration support and related enquiries
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
  void save_marks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
  bool no_allocs_since_save_marks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
  // Iteration support specific to CMS generations
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
  void save_sweep_limit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
  // More iteration support
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
  1191
  virtual void oop_iterate(ExtendedOopClosure* cl);
1893
c82e388e17c5 6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents: 1605
diff changeset
  1192
  virtual void safe_object_iterate(ObjectClosure* cl);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1193
  virtual void object_iterate(ObjectClosure* cl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1194
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
  // Need to declare the full complement of closures, whether we'll
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
  // override them or not, or get message from the compiler:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
  //   oop_since_save_marks_iterate_nv hides virtual function...
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
  #define CMS_SINCE_SAVE_MARKS_DECL(OopClosureType, nv_suffix) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
    void oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
  ALL_SINCE_SAVE_MARKS_CLOSURES(CMS_SINCE_SAVE_MARKS_DECL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
  // Smart allocation  XXX -- move to CFLSpace?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
  void setNearLargestChunk();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
  bool isNearLargestChunk(HeapWord* addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
  1206
  // Get the chunk at the end of the space.  Delegates to
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
  // the space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
  FreeChunk* find_chunk_at_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
  void post_compact();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
  // Debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1213
  void prepare_for_verify();
12379
2cf45b79ce3a 4988100: oop_verify_old_oop appears to be dead
brutisso
parents: 10240
diff changeset
  1214
  void verify();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1215
  void print_statistics()               PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
  // Performance Counters support
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1218
  virtual void update_counters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
  virtual void update_counters(size_t used);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
  void initialize_performance_counters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1221
  CollectorCounters* counters()  { return collector()->counters(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
  // Support for parallel remark of survivor space
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1224
  void* get_data_recorder(int thr_num) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1225
    //Delegate to collector
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1226
    return collector()->get_data_recorder(thr_num);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
  }
18994
d32a17b7502c 6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents: 18687
diff changeset
  1228
  void sample_eden_chunk() {
d32a17b7502c 6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents: 18687
diff changeset
  1229
    //Delegate to collector
d32a17b7502c 6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents: 18687
diff changeset
  1230
    return collector()->sample_eden_chunk();
d32a17b7502c 6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents: 18687
diff changeset
  1231
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
  // Printing
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
  const char* name() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
  virtual const char* short_name() const { return "CMS"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
  void        print() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
16681
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15605
diff changeset
  1238
  // Resize the generation after a compacting GC.  The
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15605
diff changeset
  1239
  // generation can be treated as a contiguous space
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15605
diff changeset
  1240
  // after the compaction.
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15605
diff changeset
  1241
  virtual void compute_new_size();
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15605
diff changeset
  1242
  // Resize the generation after a non-compacting
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15605
diff changeset
  1243
  // collection.
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15605
diff changeset
  1244
  void compute_new_size_free_list();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1248
// Closures of various sorts used by CMS to accomplish its work
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1249
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
// This closure is used to do concurrent marking from the roots
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
// following the first checkpoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
class MarkFromRootsClosure: public BitMapClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
  CMSCollector*  _collector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1255
  MemRegion      _span;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
  CMSBitMap*     _bitMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1257
  CMSBitMap*     _mut;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1258
  CMSMarkStack*  _markStack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1259
  bool           _yield;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1260
  int            _skipBits;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
  HeapWord*      _finger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1262
  HeapWord*      _threshold;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1263
  DEBUG_ONLY(bool _verifying;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1264
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
  MarkFromRootsClosure(CMSCollector* collector, MemRegion span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1267
                       CMSBitMap* bitMap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
                       CMSMarkStack*  markStack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
                       bool should_yield, bool verifying = false);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 390
diff changeset
  1270
  bool do_bit(size_t offset);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
  void reset(HeapWord* addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
  inline void do_yield_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
  void scanOopsInOop(HeapWord* ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
  void do_yield_work();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1277
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1279
// This closure is used to do concurrent multi-threaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
// marking from the roots following the first checkpoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
// XXX This should really be a subclass of The serial version
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
// above, but i have not had the time to refactor things cleanly.
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35204
diff changeset
  1283
class ParMarkFromRootsClosure: public BitMapClosure {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
  CMSCollector*  _collector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
  MemRegion      _whole_span;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1286
  MemRegion      _span;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
  CMSBitMap*     _bit_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
  CMSBitMap*     _mut;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
  OopTaskQueue*  _work_queue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
  CMSMarkStack*  _overflow_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
  int            _skip_bits;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
  HeapWord*      _finger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
  HeapWord*      _threshold;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
  CMSConcMarkingTask* _task;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
 public:
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35204
diff changeset
  1296
  ParMarkFromRootsClosure(CMSConcMarkingTask* task, CMSCollector* collector,
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35204
diff changeset
  1297
                          MemRegion span,
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35204
diff changeset
  1298
                          CMSBitMap* bit_map,
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35204
diff changeset
  1299
                          OopTaskQueue* work_queue,
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35204
diff changeset
  1300
                          CMSMarkStack*  overflow_stack);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 390
diff changeset
  1301
  bool do_bit(size_t offset);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1302
  inline void do_yield_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1303
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
  void scan_oops_in_oop(HeapWord* ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
  void do_yield_work();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
  bool get_work_from_overflow_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1309
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
// The following closures are used to do certain kinds of verification of
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
// CMS marking.
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 24941
diff changeset
  1312
class PushAndMarkVerifyClosure: public MetadataAwareOopClosure {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1313
  CMSCollector*    _collector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
  MemRegion        _span;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
  CMSBitMap*       _verification_bm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1316
  CMSBitMap*       _cms_bm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
  CMSMarkStack*    _mark_stack;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 341
diff changeset
  1318
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 341
diff changeset
  1319
  void do_oop(oop p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 341
diff changeset
  1320
  template <class T> inline void do_oop_work(T *p) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
  1321
    oop obj = oopDesc::load_decode_heap_oop(p);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 341
diff changeset
  1322
    do_oop(obj);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 341
diff changeset
  1323
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
  PushAndMarkVerifyClosure(CMSCollector* cms_collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
                           MemRegion span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
                           CMSBitMap* verification_bm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
                           CMSBitMap* cms_bm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
                           CMSMarkStack*  mark_stack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
  void do_oop(oop* p);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 341
diff changeset
  1331
  void do_oop(narrowOop* p);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
  1332
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
  // Deal with a stack overflow condition
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
  void handle_stack_overflow(HeapWord* lost);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1335
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1336
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1337
class MarkFromRootsVerifyClosure: public BitMapClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
  CMSCollector*  _collector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
  MemRegion      _span;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
  CMSBitMap*     _verification_bm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
  CMSBitMap*     _cms_bm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
  CMSMarkStack*  _mark_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
  HeapWord*      _finger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
  PushAndMarkVerifyClosure _pam_verify_closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
  MarkFromRootsVerifyClosure(CMSCollector* collector, MemRegion span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
                             CMSBitMap* verification_bm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
                             CMSBitMap* cms_bm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
                             CMSMarkStack*  mark_stack);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 390
diff changeset
  1350
  bool do_bit(size_t offset);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
  void reset(HeapWord* addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
// This closure is used to check that a certain set of bits is
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
// "empty" (i.e. the bit vector doesn't have any 1-bits).
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
class FalseBitMapClosure: public BitMapClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
 public:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 390
diff changeset
  1359
  bool do_bit(size_t offset) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
    guarantee(false, "Should not have a 1 bit");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 390
diff changeset
  1361
    return true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
23535
6306204d22a9 8038404: Move object_iterate_mem from Space to CMS since it is only ever used by CMS
mgerdin
parents: 23508
diff changeset
  1365
// A version of ObjectClosure with "memory" (see _previous_address below)
6306204d22a9 8038404: Move object_iterate_mem from Space to CMS since it is only ever used by CMS
mgerdin
parents: 23508
diff changeset
  1366
class UpwardsObjectClosure: public BoolObjectClosure {
6306204d22a9 8038404: Move object_iterate_mem from Space to CMS since it is only ever used by CMS
mgerdin
parents: 23508
diff changeset
  1367
  HeapWord* _previous_address;
6306204d22a9 8038404: Move object_iterate_mem from Space to CMS since it is only ever used by CMS
mgerdin
parents: 23508
diff changeset
  1368
 public:
6306204d22a9 8038404: Move object_iterate_mem from Space to CMS since it is only ever used by CMS
mgerdin
parents: 23508
diff changeset
  1369
  UpwardsObjectClosure() : _previous_address(NULL) { }
6306204d22a9 8038404: Move object_iterate_mem from Space to CMS since it is only ever used by CMS
mgerdin
parents: 23508
diff changeset
  1370
  void set_previous(HeapWord* addr) { _previous_address = addr; }
6306204d22a9 8038404: Move object_iterate_mem from Space to CMS since it is only ever used by CMS
mgerdin
parents: 23508
diff changeset
  1371
  HeapWord* previous()              { return _previous_address; }
6306204d22a9 8038404: Move object_iterate_mem from Space to CMS since it is only ever used by CMS
mgerdin
parents: 23508
diff changeset
  1372
  // A return value of "true" can be used by the caller to decide
6306204d22a9 8038404: Move object_iterate_mem from Space to CMS since it is only ever used by CMS
mgerdin
parents: 23508
diff changeset
  1373
  // if this object's end should *NOT* be recorded in
6306204d22a9 8038404: Move object_iterate_mem from Space to CMS since it is only ever used by CMS
mgerdin
parents: 23508
diff changeset
  1374
  // _previous_address above.
6306204d22a9 8038404: Move object_iterate_mem from Space to CMS since it is only ever used by CMS
mgerdin
parents: 23508
diff changeset
  1375
  virtual bool do_object_bm(oop obj, MemRegion mr) = 0;
6306204d22a9 8038404: Move object_iterate_mem from Space to CMS since it is only ever used by CMS
mgerdin
parents: 23508
diff changeset
  1376
};
6306204d22a9 8038404: Move object_iterate_mem from Space to CMS since it is only ever used by CMS
mgerdin
parents: 23508
diff changeset
  1377
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
// This closure is used during the second checkpointing phase
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
// to rescan the marked objects on the dirty cards in the mod
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
// union table and the card table proper. It's invoked via
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
// MarkFromDirtyCardsClosure below. It uses either
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
// [Par_]MarkRefsIntoAndScanClosure (Par_ in the parallel case)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
// declared in genOopClosures.hpp to accomplish some of its work.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
// In the parallel case the bitMap is shared, so access to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
// it needs to be suitably synchronized for updates by embedded
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
// closures that update it; however, this closure itself only
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
// reads the bit_map and because it is idempotent, is immune to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
// reading stale values.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
class ScanMarkedObjectsAgainClosure: public UpwardsObjectClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
  #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
    CMSCollector*          _collector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
    MemRegion              _span;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
    union {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
      CMSMarkStack*        _mark_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
      OopTaskQueue*        _work_queue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
    };
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
  #endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
  bool                       _parallel;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
  CMSBitMap*                 _bit_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1400
  union {
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35204
diff changeset
  1401
    MarkRefsIntoAndScanClosure*    _scan_closure;
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35204
diff changeset
  1402
    ParMarkRefsIntoAndScanClosure* _par_scan_closure;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
  ScanMarkedObjectsAgainClosure(CMSCollector* collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
                                MemRegion span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
                                ReferenceProcessor* rp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
                                CMSBitMap* bit_map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1410
                                CMSMarkStack*  mark_stack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
                                MarkRefsIntoAndScanClosure* cl):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1412
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1413
      _collector(collector),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1414
      _span(span),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1415
      _mark_stack(mark_stack),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1416
    #endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1417
    _parallel(false),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
    _bit_map(bit_map),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1419
    _scan_closure(cl) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1421
  ScanMarkedObjectsAgainClosure(CMSCollector* collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1422
                                MemRegion span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1423
                                ReferenceProcessor* rp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1424
                                CMSBitMap* bit_map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1425
                                OopTaskQueue* work_queue,
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35204
diff changeset
  1426
                                ParMarkRefsIntoAndScanClosure* cl):
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1428
      _collector(collector),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1429
      _span(span),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1430
      _work_queue(work_queue),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1431
    #endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1432
    _parallel(true),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1433
    _bit_map(bit_map),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1434
    _par_scan_closure(cl) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1435
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1436
  bool do_object_b(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1437
    guarantee(false, "Call do_object_b(oop, MemRegion) form instead");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1438
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1439
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1440
  bool do_object_bm(oop p, MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1441
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1443
// This closure is used during the second checkpointing phase
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1444
// to rescan the marked objects on the dirty cards in the mod
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1445
// union table and the card table proper. It invokes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1446
// ScanMarkedObjectsAgainClosure above to accomplish much of its work.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1447
// In the parallel case, the bit map is shared and requires
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1448
// synchronized access.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1449
class MarkFromDirtyCardsClosure: public MemRegionClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1450
  CompactibleFreeListSpace*      _space;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1451
  ScanMarkedObjectsAgainClosure  _scan_cl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1452
  size_t                         _num_dirty_cards;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1453
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1454
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1455
  MarkFromDirtyCardsClosure(CMSCollector* collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1456
                            MemRegion span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
                            CompactibleFreeListSpace* space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
                            CMSBitMap* bit_map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
                            CMSMarkStack* mark_stack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1460
                            MarkRefsIntoAndScanClosure* cl):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1461
    _space(space),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1462
    _num_dirty_cards(0),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1463
    _scan_cl(collector, span, collector->ref_processor(), bit_map,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
  1464
                 mark_stack, cl) { }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1466
  MarkFromDirtyCardsClosure(CMSCollector* collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
                            MemRegion span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
                            CompactibleFreeListSpace* space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
                            CMSBitMap* bit_map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
                            OopTaskQueue* work_queue,
35492
c8c0273e6b91 8146690: Make all classes in GC follow the naming convention.
david
parents: 35204
diff changeset
  1471
                            ParMarkRefsIntoAndScanClosure* cl):
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
    _space(space),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
    _num_dirty_cards(0),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
    _scan_cl(collector, span, collector->ref_processor(), bit_map,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
  1475
             work_queue, cl) { }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1476
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1477
  void do_MemRegion(MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1478
  void set_space(CompactibleFreeListSpace* space) { _space = space; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1479
  size_t num_dirty_cards() { return _num_dirty_cards; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
// This closure is used in the non-product build to check
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
// that there are no MemRegions with a certain property.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1484
class FalseMemRegionClosure: public MemRegionClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
  void do_MemRegion(MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
    guarantee(!mr.is_empty(), "Shouldn't be empty");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
    guarantee(false, "Should never be here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
// This closure is used during the precleaning phase
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
// to "carefully" rescan marked objects on dirty cards.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
// It uses MarkRefsIntoAndScanClosure declared in genOopClosures.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
// to accomplish some of its work.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
class ScanMarkedObjectsAgainCarefullyClosure: public ObjectClosureCareful {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
  CMSCollector*                  _collector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
  MemRegion                      _span;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
  bool                           _yield;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
  Mutex*                         _freelistLock;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
  CMSBitMap*                     _bitMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
  CMSMarkStack*                  _markStack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
  MarkRefsIntoAndScanClosure*    _scanningClosure;
38704
eb96c446c3a5 8156548: gc/gctests/StringInternSyncWithGC2 fails with Test level exit status: 151
kbarrett
parents: 38177
diff changeset
  1503
  DEBUG_ONLY(HeapWord*           _last_scanned_object;)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1506
  ScanMarkedObjectsAgainCarefullyClosure(CMSCollector* collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
                                         MemRegion     span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
                                         CMSBitMap* bitMap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
                                         CMSMarkStack*  markStack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
                                         MarkRefsIntoAndScanClosure* cl,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
                                         bool should_yield):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
    _collector(collector),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1513
    _span(span),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
    _yield(should_yield),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1515
    _bitMap(bitMap),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
    _markStack(markStack),
38704
eb96c446c3a5 8156548: gc/gctests/StringInternSyncWithGC2 fails with Test level exit status: 151
kbarrett
parents: 38177
diff changeset
  1517
    _scanningClosure(cl)
eb96c446c3a5 8156548: gc/gctests/StringInternSyncWithGC2 fails with Test level exit status: 151
kbarrett
parents: 38177
diff changeset
  1518
    DEBUG_ONLY(COMMA _last_scanned_object(NULL))
eb96c446c3a5 8156548: gc/gctests/StringInternSyncWithGC2 fails with Test level exit status: 151
kbarrett
parents: 38177
diff changeset
  1519
  { }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1521
  void do_object(oop p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
    guarantee(false, "call do_object_careful instead");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1523
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
  size_t      do_object_careful(oop p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
    guarantee(false, "Unexpected caller");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
    return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1528
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1529
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1530
  size_t      do_object_careful_m(oop p, MemRegion mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1531
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
  void setFreelistLock(Mutex* m) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1533
    _freelistLock = m;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
    _scanningClosure->set_freelistLock(m);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1535
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1537
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
  inline bool do_yield_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1539
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1540
  void do_yield_work();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1541
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1542
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1543
class SurvivorSpacePrecleanClosure: public ObjectClosureCareful {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1544
  CMSCollector*                  _collector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1545
  MemRegion                      _span;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1546
  bool                           _yield;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1547
  CMSBitMap*                     _bit_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1548
  CMSMarkStack*                  _mark_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1549
  PushAndMarkClosure*            _scanning_closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1550
  unsigned int                   _before_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1551
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1552
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1553
  SurvivorSpacePrecleanClosure(CMSCollector* collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1554
                               MemRegion     span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1555
                               CMSBitMap*    bit_map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1556
                               CMSMarkStack* mark_stack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1557
                               PushAndMarkClosure* cl,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1558
                               unsigned int  before_count,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1559
                               bool          should_yield):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1560
    _collector(collector),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1561
    _span(span),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1562
    _yield(should_yield),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1563
    _bit_map(bit_map),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1564
    _mark_stack(mark_stack),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1565
    _scanning_closure(cl),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1566
    _before_count(before_count)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1567
  { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1568
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1569
  void do_object(oop p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1570
    guarantee(false, "call do_object_careful instead");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1571
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1572
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1573
  size_t      do_object_careful(oop p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1574
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1575
  size_t      do_object_careful_m(oop p, MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1576
    guarantee(false, "Unexpected caller");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1577
    return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1578
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1579
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1580
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1581
  inline void do_yield_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1582
  void do_yield_work();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1583
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1584
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1585
// This closure is used to accomplish the sweeping work
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1586
// after the second checkpoint but before the concurrent reset
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1587
// phase.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1588
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1589
// Terminology
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1590
//   left hand chunk (LHC) - block of one or more chunks currently being
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1591
//     coalesced.  The LHC is available for coalescing with a new chunk.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1592
//   right hand chunk (RHC) - block that is currently being swept that is
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1593
//     free or garbage that can be coalesced with the LHC.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1594
// _inFreeRange is true if there is currently a LHC
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1595
// _lastFreeRangeCoalesced is true if the LHC consists of more than one chunk.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1596
// _freeRangeInFreeLists is true if the LHC is in the free lists.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1597
// _freeFinger is the address of the current LHC
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1598
class SweepClosure: public BlkClosureCareful {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1599
  CMSCollector*                  _collector;  // collector doing the work
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1600
  ConcurrentMarkSweepGeneration* _g;    // Generation being swept
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1601
  CompactibleFreeListSpace*      _sp;   // Space being swept
9969
57932d7294a9 7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents: 9623
diff changeset
  1602
  HeapWord*                      _limit;// the address at or above which the sweep should stop
57932d7294a9 7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents: 9623
diff changeset
  1603
                                        // because we do not expect newly garbage blocks
57932d7294a9 7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents: 9623
diff changeset
  1604
                                        // eligible for sweeping past that address.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1605
  Mutex*                         _freelistLock; // Free list lock (in space)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1606
  CMSBitMap*                     _bitMap;       // Marking bit map (in
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1607
                                                // generation)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1608
  bool                           _inFreeRange;  // Indicates if we are in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1609
                                                // midst of a free run
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1610
  bool                           _freeRangeInFreeLists;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1611
                                        // Often, we have just found
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1612
                                        // a free chunk and started
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1613
                                        // a new free range; we do not
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
                                        // eagerly remove this chunk from
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1615
                                        // the free lists unless there is
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1616
                                        // a possibility of coalescing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1617
                                        // When true, this flag indicates
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1618
                                        // that the _freeFinger below
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1619
                                        // points to a potentially free chunk
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1620
                                        // that may still be in the free lists
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1621
  bool                           _lastFreeRangeCoalesced;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1622
                                        // free range contains chunks
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1623
                                        // coalesced
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1624
  bool                           _yield;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1625
                                        // Whether sweeping should be
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1626
                                        // done with yields. For instance
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1627
                                        // when done by the foreground
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1628
                                        // collector we shouldn't yield.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1629
  HeapWord*                      _freeFinger;   // When _inFreeRange is set, the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1630
                                                // pointer to the "left hand
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1631
                                                // chunk"
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1632
  size_t                         _freeRangeSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1633
                                        // When _inFreeRange is set, this
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1634
                                        // indicates the accumulated size
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1635
                                        // of the "left hand chunk"
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1636
  NOT_PRODUCT(
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1637
    size_t                       _numObjectsFreed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1638
    size_t                       _numWordsFreed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1639
    size_t                       _numObjectsLive;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1640
    size_t                       _numWordsLive;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1641
    size_t                       _numObjectsAlreadyFree;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1642
    size_t                       _numWordsAlreadyFree;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1643
    FreeChunk*                   _last_fc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1644
  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1645
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1646
  // Code that is common to a free chunk or garbage when
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1647
  // encountered during sweeping.
7903
c694e52ff9cb 7008136: CMS: assert((HeapWord*)nextChunk <= _limit) failed: sweep invariant
ysr
parents: 7397
diff changeset
  1648
  void do_post_free_or_garbage_chunk(FreeChunk *fc, size_t chunkSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1649
  // Process a free chunk during sweeping.
7903
c694e52ff9cb 7008136: CMS: assert((HeapWord*)nextChunk <= _limit) failed: sweep invariant
ysr
parents: 7397
diff changeset
  1650
  void do_already_free_chunk(FreeChunk *fc);
9969
57932d7294a9 7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents: 9623
diff changeset
  1651
  // Work method called when processing an already free or a
57932d7294a9 7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents: 9623
diff changeset
  1652
  // freshly garbage chunk to do a lookahead and possibly a
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
  1653
  // preemptive flush if crossing over _limit.
9969
57932d7294a9 7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents: 9623
diff changeset
  1654
  void lookahead_and_flush(FreeChunk* fc, size_t chunkSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1655
  // Process a garbage chunk during sweeping.
7903
c694e52ff9cb 7008136: CMS: assert((HeapWord*)nextChunk <= _limit) failed: sweep invariant
ysr
parents: 7397
diff changeset
  1656
  size_t do_garbage_chunk(FreeChunk *fc);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1657
  // Process a live chunk during sweeping.
7903
c694e52ff9cb 7008136: CMS: assert((HeapWord*)nextChunk <= _limit) failed: sweep invariant
ysr
parents: 7397
diff changeset
  1658
  size_t do_live_chunk(FreeChunk* fc);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1659
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1660
  // Accessors.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1661
  HeapWord* freeFinger() const          { return _freeFinger; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1662
  void set_freeFinger(HeapWord* v)      { _freeFinger = v; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1663
  bool inFreeRange()    const           { return _inFreeRange; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1664
  void set_inFreeRange(bool v)          { _inFreeRange = v; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1665
  bool lastFreeRangeCoalesced() const    { return _lastFreeRangeCoalesced; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1666
  void set_lastFreeRangeCoalesced(bool v) { _lastFreeRangeCoalesced = v; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1667
  bool freeRangeInFreeLists() const     { return _freeRangeInFreeLists; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1668
  void set_freeRangeInFreeLists(bool v) { _freeRangeInFreeLists = v; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1669
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1670
  // Initialize a free range.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1671
  void initialize_free_range(HeapWord* freeFinger, bool freeRangeInFreeLists);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1672
  // Return this chunk to the free lists.
7903
c694e52ff9cb 7008136: CMS: assert((HeapWord*)nextChunk <= _limit) failed: sweep invariant
ysr
parents: 7397
diff changeset
  1673
  void flush_cur_free_chunk(HeapWord* chunk, size_t size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1674
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1675
  // Check if we should yield and do so when necessary.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1676
  inline void do_yield_check(HeapWord* addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1677
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1678
  // Yield
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1679
  void do_yield_work(HeapWord* addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1680
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1681
  // Debugging/Printing
9969
57932d7294a9 7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents: 9623
diff changeset
  1682
  void print_free_block_coalesced(FreeChunk* fc) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1683
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1684
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1685
  SweepClosure(CMSCollector* collector, ConcurrentMarkSweepGeneration* g,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1686
               CMSBitMap* bitMap, bool should_yield);
9969
57932d7294a9 7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents: 9623
diff changeset
  1687
  ~SweepClosure() PRODUCT_RETURN;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1688
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1689
  size_t       do_blk_careful(HeapWord* addr);
9969
57932d7294a9 7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents: 9623
diff changeset
  1690
  void         print() const { print_on(tty); }
57932d7294a9 7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents: 9623
diff changeset
  1691
  void         print_on(outputStream *st) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1692
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1693
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1694
// Closures related to weak references processing
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1695
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1696
// During CMS' weak reference processing, this is a
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1697
// work-routine/closure used to complete transitive
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1698
// marking of objects as live after a certain point
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1699
// in which an initial set has been completely accumulated.
1605
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 1388
diff changeset
  1700
// This closure is currently used both during the final
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 1388
diff changeset
  1701
// remark stop-world phase, as well as during the concurrent
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 1388
diff changeset
  1702
// precleaning of the discovered reference lists.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1703
class CMSDrainMarkingStackClosure: public VoidClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1704
  CMSCollector*        _collector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1705
  MemRegion            _span;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1706
  CMSMarkStack*        _mark_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1707
  CMSBitMap*           _bit_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1708
  CMSKeepAliveClosure* _keep_alive;
1605
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 1388
diff changeset
  1709
  bool                 _concurrent_precleaning;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1710
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1711
  CMSDrainMarkingStackClosure(CMSCollector* collector, MemRegion span,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1712
                      CMSBitMap* bit_map, CMSMarkStack* mark_stack,
1605
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 1388
diff changeset
  1713
                      CMSKeepAliveClosure* keep_alive,
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 1388
diff changeset
  1714
                      bool cpc):
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1715
    _collector(collector),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1716
    _span(span),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1717
    _bit_map(bit_map),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1718
    _mark_stack(mark_stack),
1605
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 1388
diff changeset
  1719
    _keep_alive(keep_alive),
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 1388
diff changeset
  1720
    _concurrent_precleaning(cpc) {
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 1388
diff changeset
  1721
    assert(_concurrent_precleaning == _keep_alive->concurrent_precleaning(),
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 1388
diff changeset
  1722
           "Mismatch");
6b43d186eb8d 6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents: 1388
diff changeset
  1723
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1724
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1725
  void do_void();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1726
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1727
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1728
// A parallel version of CMSDrainMarkingStackClosure above.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1729
class CMSParDrainMarkingStackClosure: public VoidClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1730
  CMSCollector*           _collector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1731
  MemRegion               _span;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1732
  OopTaskQueue*           _work_queue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1733
  CMSBitMap*              _bit_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1734
  CMSInnerParMarkAndPushClosure _mark_and_push;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1735
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1736
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1737
  CMSParDrainMarkingStackClosure(CMSCollector* collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1738
                                 MemRegion span, CMSBitMap* bit_map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1739
                                 OopTaskQueue* work_queue):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1740
    _collector(collector),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1741
    _span(span),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1742
    _bit_map(bit_map),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1743
    _work_queue(work_queue),
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
  1744
    _mark_and_push(collector, span, bit_map, work_queue) { }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1745
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1746
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1747
  void trim_queue(uint max);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1748
  void do_void();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1749
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1750
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1751
// Allow yielding or short-circuiting of reference list
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18996
diff changeset
  1752
// precleaning work.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1753
class CMSPrecleanRefsYieldClosure: public YieldClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1754
  CMSCollector* _collector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1755
  void do_yield_work();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1756
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1757
  CMSPrecleanRefsYieldClosure(CMSCollector* collector):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1758
    _collector(collector) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1759
  virtual bool should_return();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1760
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1761
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1762
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1763
// Convenience class that locks free list locks for given CMS collector
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1764
class FreelistLocker: public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1765
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1766
  CMSCollector* _collector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1767
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1768
  FreelistLocker(CMSCollector* collector):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1769
    _collector(collector) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1770
    _collector->getFreelistLocks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1771
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1772
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1773
  ~FreelistLocker() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1774
    _collector->releaseFreelistLocks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1775
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1776
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1777
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1778
// Mark all dead objects in a given space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1779
class MarkDeadObjectsClosure: public BlkClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1780
  const CMSCollector*             _collector;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1781
  const CompactibleFreeListSpace* _sp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1782
  CMSBitMap*                      _live_bit_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1783
  CMSBitMap*                      _dead_bit_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1784
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1785
  MarkDeadObjectsClosure(const CMSCollector* collector,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1786
                         const CompactibleFreeListSpace* sp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1787
                         CMSBitMap *live_bit_map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1788
                         CMSBitMap *dead_bit_map) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1789
    _collector(collector),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1790
    _sp(sp),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1791
    _live_bit_map(live_bit_map),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1792
    _dead_bit_map(dead_bit_map) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1793
  size_t do_blk(HeapWord* addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1794
};
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
  1795
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
  1796
class TraceCMSMemoryManagerStats : public TraceMemoryManagerStats {
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
  1797
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
  1798
 public:
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8688
diff changeset
  1799
  TraceCMSMemoryManagerStats(CMSCollector::CollectorState phase, GCCause::Cause cause);
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
  1800
};
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
  1801
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
  1802
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30581
diff changeset
  1803
#endif // SHARE_VM_GC_CMS_CONCURRENTMARKSWEEPGENERATION_HPP