< prev index next >

src/hotspot/share/gc/parallel/psOldGen.hpp

Print this page
rev 57719 : imported patch 8235860-remove-serial-old-gc
rev 57721 : [mq]: 8235860-lkorinth-review
   1 /*
   2  * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_GC_PARALLEL_PSOLDGEN_HPP
  26 #define SHARE_GC_PARALLEL_PSOLDGEN_HPP
  27 
  28 #include "gc/parallel/mutableSpace.hpp"
  29 #include "gc/parallel/objectStartArray.hpp"
  30 #include "gc/parallel/psGenerationCounters.hpp"
  31 #include "gc/parallel/psVirtualspace.hpp"
  32 #include "gc/parallel/spaceCounters.hpp"
  33 #include "runtime/safepoint.hpp"
  34 
  35 class PSMarkSweepDecorator;
  36 
  37 class PSOldGen : public CHeapObj<mtGC> {
  38   friend class VMStructs;
  39   friend class PSPromotionManager; // Uses the cas_allocate methods
  40   friend class ParallelScavengeHeap;
  41   friend class AdjoiningGenerations;
  42 
  43  protected:
  44   MemRegion                _reserved;          // Used for simple containment tests
  45   PSVirtualSpace*          _virtual_space;     // Controls mapping and unmapping of virtual mem
  46   ObjectStartArray         _start_array;       // Keeps track of where objects start in a 512b block
  47   MutableSpace*            _object_space;      // Where all the objects live
  48 #if INCLUDE_SERIALGC
  49   PSMarkSweepDecorator*    _object_mark_sweep; // The mark sweep view of _object_space
  50 #endif
  51   const char* const        _name;              // Name of this generation.
  52 
  53   // Performance Counters
  54   PSGenerationCounters*    _gen_counters;
  55   SpaceCounters*           _space_counters;
  56 
  57   // Sizing information, in bytes, set in constructor
  58   const size_t _init_gen_size;
  59   const size_t _min_gen_size;
  60   const size_t _max_gen_size;
  61 
  62   // Used when initializing the _name field.
  63   static inline const char* select_name();
  64 
  65 #ifdef ASSERT
  66   void assert_block_in_covered_region(MemRegion new_memregion) {
  67     // Explictly capture current covered_region in a local
  68     MemRegion covered_region = this->start_array()->covered_region();
  69     assert(covered_region.contains(new_memregion),
  70            "new region is not in covered_region [ " PTR_FORMAT ", " PTR_FORMAT " ], "
  71            "new region [ " PTR_FORMAT ", " PTR_FORMAT " ], "
  72            "object space [ " PTR_FORMAT ", " PTR_FORMAT " ]",
  73            p2i(covered_region.start()),
  74            p2i(covered_region.end()),
  75            p2i(new_memregion.start()),
  76            p2i(new_memregion.end()),
  77            p2i(this->object_space()->used_region().start()),
  78            p2i(this->object_space()->used_region().end()));
  79   }
  80 #endif
  81 
  82   HeapWord* allocate_noexpand(size_t word_size) {
  83     // We assume the heap lock is held here.
  84     assert_locked_or_safepoint(Heap_lock);


 135   virtual void initialize_performance_counters(const char* perf_data_name, int level);
 136 
 137   MemRegion reserved() const                { return _reserved; }
 138   virtual size_t max_gen_size()             { return _max_gen_size; }
 139   size_t min_gen_size()                     { return _min_gen_size; }
 140 
 141   // Returns limit on the maximum size of the generation.  This
 142   // is the same as _max_gen_size for PSOldGen but need not be
 143   // for a derived class.
 144   virtual size_t gen_size_limit();
 145 
 146   bool is_in(const void* p) const           {
 147     return _virtual_space->contains((void *)p);
 148   }
 149 
 150   bool is_in_reserved(const void* p) const {
 151     return reserved().contains(p);
 152   }
 153 
 154   MutableSpace*         object_space() const      { return _object_space; }
 155 #if INCLUDE_SERIALGC
 156   PSMarkSweepDecorator* object_mark_sweep() const { return _object_mark_sweep; }
 157 #endif
 158   ObjectStartArray*     start_array()             { return &_start_array; }
 159   PSVirtualSpace*       virtual_space() const     { return _virtual_space;}
 160 
 161   // Has the generation been successfully allocated?
 162   bool is_allocated();
 163 
 164 #if INCLUDE_SERIALGC
 165   // MarkSweep methods
 166   virtual void precompact();
 167   void adjust_pointers();
 168   void compact();
 169 #endif
 170 
 171   // Size info
 172   size_t capacity_in_bytes() const        { return object_space()->capacity_in_bytes(); }
 173   size_t used_in_bytes() const            { return object_space()->used_in_bytes(); }
 174   size_t free_in_bytes() const            { return object_space()->free_in_bytes(); }
 175 
 176   size_t capacity_in_words() const        { return object_space()->capacity_in_words(); }
 177   size_t used_in_words() const            { return object_space()->used_in_words(); }
 178   size_t free_in_words() const            { return object_space()->free_in_words(); }
 179 
 180   // Includes uncommitted memory
 181   size_t contiguous_available() const;
 182 
 183   bool is_maximal_no_gc() const {
 184     return virtual_space()->uncommitted_size() == 0;
 185   }
 186 
 187   // Calculating new sizes
 188   void resize(size_t desired_free_space);
 189 
 190   // Allocation. We report all successful allocations to the size policy


 198   // Debugging - do not use for time critical operations
 199   virtual void print() const;
 200   virtual void print_on(outputStream* st) const;
 201 
 202   void verify();
 203   void verify_object_start_array();
 204 
 205   // These should not used
 206   virtual void reset_after_change();
 207 
 208   // These should not used
 209   virtual size_t available_for_expansion();
 210   virtual size_t available_for_contraction();
 211 
 212   void space_invariants() PRODUCT_RETURN;
 213 
 214   // Performance Counter support
 215   void update_counters();
 216 
 217   // Printing support
 218   virtual const char* name() const { return _name; }
 219 
 220   // Debugging support
 221   // Save the tops of all spaces for later use during mangling.
 222   void record_spaces_top() PRODUCT_RETURN;
 223 };
 224 
 225 #endif // SHARE_GC_PARALLEL_PSOLDGEN_HPP
   1 /*
   2  * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_GC_PARALLEL_PSOLDGEN_HPP
  26 #define SHARE_GC_PARALLEL_PSOLDGEN_HPP
  27 
  28 #include "gc/parallel/mutableSpace.hpp"
  29 #include "gc/parallel/objectStartArray.hpp"
  30 #include "gc/parallel/psGenerationCounters.hpp"
  31 #include "gc/parallel/psVirtualspace.hpp"
  32 #include "gc/parallel/spaceCounters.hpp"
  33 #include "runtime/safepoint.hpp"
  34 


  35 class PSOldGen : public CHeapObj<mtGC> {
  36   friend class VMStructs;
  37   friend class PSPromotionManager; // Uses the cas_allocate methods
  38   friend class ParallelScavengeHeap;
  39   friend class AdjoiningGenerations;
  40 
  41  protected:
  42   MemRegion                _reserved;          // Used for simple containment tests
  43   PSVirtualSpace*          _virtual_space;     // Controls mapping and unmapping of virtual mem
  44   ObjectStartArray         _start_array;       // Keeps track of where objects start in a 512b block
  45   MutableSpace*            _object_space;      // Where all the objects live




  46 
  47   // Performance Counters
  48   PSGenerationCounters*    _gen_counters;
  49   SpaceCounters*           _space_counters;
  50 
  51   // Sizing information, in bytes, set in constructor
  52   const size_t _init_gen_size;
  53   const size_t _min_gen_size;
  54   const size_t _max_gen_size;
  55 



  56 #ifdef ASSERT
  57   void assert_block_in_covered_region(MemRegion new_memregion) {
  58     // Explictly capture current covered_region in a local
  59     MemRegion covered_region = this->start_array()->covered_region();
  60     assert(covered_region.contains(new_memregion),
  61            "new region is not in covered_region [ " PTR_FORMAT ", " PTR_FORMAT " ], "
  62            "new region [ " PTR_FORMAT ", " PTR_FORMAT " ], "
  63            "object space [ " PTR_FORMAT ", " PTR_FORMAT " ]",
  64            p2i(covered_region.start()),
  65            p2i(covered_region.end()),
  66            p2i(new_memregion.start()),
  67            p2i(new_memregion.end()),
  68            p2i(this->object_space()->used_region().start()),
  69            p2i(this->object_space()->used_region().end()));
  70   }
  71 #endif
  72 
  73   HeapWord* allocate_noexpand(size_t word_size) {
  74     // We assume the heap lock is held here.
  75     assert_locked_or_safepoint(Heap_lock);


 126   virtual void initialize_performance_counters(const char* perf_data_name, int level);
 127 
 128   MemRegion reserved() const                { return _reserved; }
 129   virtual size_t max_gen_size()             { return _max_gen_size; }
 130   size_t min_gen_size()                     { return _min_gen_size; }
 131 
 132   // Returns limit on the maximum size of the generation.  This
 133   // is the same as _max_gen_size for PSOldGen but need not be
 134   // for a derived class.
 135   virtual size_t gen_size_limit();
 136 
 137   bool is_in(const void* p) const           {
 138     return _virtual_space->contains((void *)p);
 139   }
 140 
 141   bool is_in_reserved(const void* p) const {
 142     return reserved().contains(p);
 143   }
 144 
 145   MutableSpace*         object_space() const      { return _object_space; }



 146   ObjectStartArray*     start_array()             { return &_start_array; }
 147   PSVirtualSpace*       virtual_space() const     { return _virtual_space;}
 148 
 149   // Has the generation been successfully allocated?
 150   bool is_allocated();
 151 







 152   // Size info
 153   size_t capacity_in_bytes() const        { return object_space()->capacity_in_bytes(); }
 154   size_t used_in_bytes() const            { return object_space()->used_in_bytes(); }
 155   size_t free_in_bytes() const            { return object_space()->free_in_bytes(); }
 156 
 157   size_t capacity_in_words() const        { return object_space()->capacity_in_words(); }
 158   size_t used_in_words() const            { return object_space()->used_in_words(); }
 159   size_t free_in_words() const            { return object_space()->free_in_words(); }
 160 
 161   // Includes uncommitted memory
 162   size_t contiguous_available() const;
 163 
 164   bool is_maximal_no_gc() const {
 165     return virtual_space()->uncommitted_size() == 0;
 166   }
 167 
 168   // Calculating new sizes
 169   void resize(size_t desired_free_space);
 170 
 171   // Allocation. We report all successful allocations to the size policy


 179   // Debugging - do not use for time critical operations
 180   virtual void print() const;
 181   virtual void print_on(outputStream* st) const;
 182 
 183   void verify();
 184   void verify_object_start_array();
 185 
 186   // These should not used
 187   virtual void reset_after_change();
 188 
 189   // These should not used
 190   virtual size_t available_for_expansion();
 191   virtual size_t available_for_contraction();
 192 
 193   void space_invariants() PRODUCT_RETURN;
 194 
 195   // Performance Counter support
 196   void update_counters();
 197 
 198   // Printing support
 199   virtual const char* name() const { return "ParOldGen"; }
 200 
 201   // Debugging support
 202   // Save the tops of all spaces for later use during mangling.
 203   void record_spaces_top() PRODUCT_RETURN;
 204 };
 205 
 206 #endif // SHARE_GC_PARALLEL_PSOLDGEN_HPP
< prev index next >