src/share/vm/gc_implementation/parallelScavenge/psYoungGen.hpp

Fri, 16 Jul 2010 21:33:21 -0700

author
jcoomes
date
Fri, 16 Jul 2010 21:33:21 -0700
changeset 2020
a93a9eda13f7
parent 1907
c18cbe5936b8
child 2314
f95d63e2154a
permissions
-rw-r--r--

6962947: shared TaskQueue statistics
Reviewed-by: tonyp, ysr

     1 /*
     2  * Copyright (c) 2001, 2008, 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  */
    25 class PSMarkSweepDecorator;
    27 class PSYoungGen : public CHeapObj {
    28   friend class VMStructs;
    29   friend class ParallelScavengeHeap;
    30   friend class AdjoiningGenerations;
    32  protected:
    33   MemRegion       _reserved;
    34   PSVirtualSpace* _virtual_space;
    36   // Spaces
    37   MutableSpace* _eden_space;
    38   MutableSpace* _from_space;
    39   MutableSpace* _to_space;
    42   // MarkSweep Decorators
    43   PSMarkSweepDecorator* _eden_mark_sweep;
    44   PSMarkSweepDecorator* _from_mark_sweep;
    45   PSMarkSweepDecorator* _to_mark_sweep;
    47   // Sizing information, in bytes, set in constructor
    48   const size_t _init_gen_size;
    49   const size_t _min_gen_size;
    50   const size_t _max_gen_size;
    52   // Performance counters
    53   PSGenerationCounters*     _gen_counters;
    54   SpaceCounters*            _eden_counters;
    55   SpaceCounters*            _from_counters;
    56   SpaceCounters*            _to_counters;
    58   // Initialize the space boundaries
    59   void compute_initial_space_boundaries();
    61   // Space boundary helper
    62   void set_space_boundaries(size_t eden_size, size_t survivor_size);
    64   virtual bool resize_generation(size_t eden_size, size_t survivor_size);
    65   virtual void resize_spaces(size_t eden_size, size_t survivor_size);
    67   // Adjust the spaces to be consistent with the virtual space.
    68   void post_resize();
    70   // Return number of bytes that the generation can change.
    71   // These should not be used by PSYoungGen
    72   virtual size_t available_for_expansion();
    73   virtual size_t available_for_contraction();
    75   // Given a desired shrinkage in the size of the young generation,
    76   // return the actual size available for shrinkage.
    77   virtual size_t limit_gen_shrink(size_t desired_change);
    78   // returns the number of bytes available from the current size
    79   // down to the minimum generation size.
    80   size_t available_to_min_gen();
    81   // Return the number of bytes available for shrinkage considering
    82   // the location the live data in the generation.
    83   virtual size_t available_to_live();
    85  public:
    86   // Initialize the generation.
    87   PSYoungGen(size_t        initial_byte_size,
    88              size_t        minimum_byte_size,
    89              size_t        maximum_byte_size);
    90   void initialize_work();
    91   virtual void initialize(ReservedSpace rs, size_t alignment);
    92   virtual void initialize_virtual_space(ReservedSpace rs, size_t alignment);
    94   MemRegion reserved() const            { return _reserved; }
    96   bool is_in(const void* p) const   {
    97       return _virtual_space->contains((void *)p);
    98   }
   100   bool is_in_reserved(const void* p) const   {
   101       return reserved().contains((void *)p);
   102   }
   104   MutableSpace*   eden_space() const    { return _eden_space; }
   105   MutableSpace*   from_space() const    { return _from_space; }
   106   MutableSpace*   to_space() const      { return _to_space; }
   107   PSVirtualSpace* virtual_space() const { return _virtual_space; }
   109   // For Adaptive size policy
   110   size_t min_gen_size() { return _min_gen_size; }
   112   // MarkSweep support
   113   PSMarkSweepDecorator* eden_mark_sweep() const    { return _eden_mark_sweep; }
   114   PSMarkSweepDecorator* from_mark_sweep() const    { return _from_mark_sweep; }
   115   PSMarkSweepDecorator* to_mark_sweep() const      { return _to_mark_sweep;   }
   117   void precompact();
   118   void adjust_pointers();
   119   void compact();
   121   // Parallel Old
   122   void move_and_update(ParCompactionManager* cm);
   124   // Called during/after gc
   125   void swap_spaces();
   127   // Resize generation using suggested free space size and survivor size
   128   // NOTE:  "eden_size" and "survivor_size" are suggestions only. Current
   129   //        heap layout (particularly, live objects in from space) might
   130   //        not allow us to use these values.
   131   void resize(size_t eden_size, size_t survivor_size);
   133   // Size info
   134   size_t capacity_in_bytes() const;
   135   size_t used_in_bytes() const;
   136   size_t free_in_bytes() const;
   138   size_t capacity_in_words() const;
   139   size_t used_in_words() const;
   140   size_t free_in_words() const;
   142   // The max this generation can grow to
   143   size_t max_size() const            { return _reserved.byte_size(); }
   145   // The max this generation can grow to if the boundary between
   146   // the generations are allowed to move.
   147   size_t gen_size_limit() const { return _max_gen_size; }
   149   bool is_maximal_no_gc() const {
   150     return true;  // never expands except at a GC
   151   }
   153   // Allocation
   154   HeapWord* allocate(size_t word_size, bool is_tlab) {
   155     HeapWord* result = eden_space()->cas_allocate(word_size);
   156     return result;
   157   }
   159   HeapWord** top_addr() const   { return eden_space()->top_addr(); }
   160   HeapWord** end_addr() const   { return eden_space()->end_addr(); }
   162   // Iteration.
   163   void oop_iterate(OopClosure* cl);
   164   void object_iterate(ObjectClosure* cl);
   166   virtual void reset_after_change();
   167   virtual void reset_survivors_after_shrink();
   169   // Performance Counter support
   170   void update_counters();
   172   // Debugging - do not use for time critical operations
   173   void print() const;
   174   void print_on(outputStream* st) const;
   175   void print_used_change(size_t prev_used) const;
   176   virtual const char* name() const { return "PSYoungGen"; }
   178   void verify(bool allow_dirty);
   180   // Space boundary invariant checker
   181   void space_invariants() PRODUCT_RETURN;
   183   // Helper for mangling survivor spaces.
   184   void mangle_survivors(MutableSpace* s1,
   185                         MemRegion s1MR,
   186                         MutableSpace* s2,
   187                         MemRegion s2MR) PRODUCT_RETURN;
   189   void record_spaces_top() PRODUCT_RETURN;
   190 };

mercurial