hotspot/src/share/vm/gc_implementation/parallelScavenge/adjoiningVirtualSpaces.hpp
changeset 1 489c9b5090e2
child 5547 f4b087cbb361
equal deleted inserted replaced
0:fd16c54261b3 1:489c9b5090e2
       
     1 /*
       
     2  * Copyright 2003 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    21  * have any questions.
       
    22  *
       
    23  */
       
    24 
       
    25 
       
    26 // Contains two virtual spaces that each can individually span
       
    27 // most of the reserved region but committed parts of which
       
    28 // cannot overlap.
       
    29 //
       
    30 //      +-------+ <--- high_boundary for H
       
    31 //      |       |
       
    32 //      |   H   |
       
    33 //      |       |
       
    34 //      |       |
       
    35 //      |       |
       
    36 //      --------- <--- low for H
       
    37 //      |       |
       
    38 //      ========= <--- low_boundary for H, high_boundary for L
       
    39 //      |       |
       
    40 //      |       |
       
    41 //      |       |
       
    42 //      --------- <--- high for L
       
    43 //      |       |
       
    44 //      |   L   |
       
    45 //      |       |
       
    46 //      |       |
       
    47 //      |       |
       
    48 //      +-------+ <--- low_boundary for L
       
    49 //
       
    50 // Each virtual space in the AdjoiningVirtualSpaces grows and shrink
       
    51 // within its reserved region (between the low_boundary and the
       
    52 // boundary) independently.  If L want to grow above its high_boundary,
       
    53 // then the high_boundary of L and the low_boundary of H must be
       
    54 // moved up consistently.  AdjoiningVirtualSpaces provide the
       
    55 // interfaces for moving the this boundary.
       
    56 
       
    57 class AdjoiningVirtualSpaces {
       
    58   // space at the high end and the low end, respectively
       
    59   PSVirtualSpace*    _high;
       
    60   PSVirtualSpace*    _low;
       
    61 
       
    62   // The reserved space spanned by the two spaces.
       
    63   ReservedSpace      _reserved_space;
       
    64 
       
    65   // The minimum byte size for the low space.  It will not
       
    66   // be shrunk below this value.
       
    67   size_t _min_low_byte_size;
       
    68   // Same for the high space
       
    69   size_t _min_high_byte_size;
       
    70 
       
    71   const size_t _alignment;
       
    72 
       
    73  public:
       
    74   // Allocates two virtual spaces that will be located at the
       
    75   // high and low ends.  Does no initialization.
       
    76   AdjoiningVirtualSpaces(ReservedSpace rs,
       
    77                          size_t min_low_byte_size,
       
    78                          size_t min_high_byte_size,
       
    79                          size_t alignment);
       
    80 
       
    81   // accessors
       
    82   PSVirtualSpace* high() { return _high; }
       
    83   PSVirtualSpace* low()  { return _low; }
       
    84   ReservedSpace reserved_space() { return _reserved_space; }
       
    85   size_t min_low_byte_size() { return _min_low_byte_size; }
       
    86   size_t min_high_byte_size() { return _min_high_byte_size; }
       
    87   size_t alignment() const { return _alignment; }
       
    88 
       
    89   // move boundary between the two spaces up
       
    90   bool adjust_boundary_up(size_t size_in_bytes);
       
    91   // and down
       
    92   bool adjust_boundary_down(size_t size_in_bytes);
       
    93 
       
    94   // Maximum byte size for the high space.
       
    95   size_t high_byte_size_limit() {
       
    96     return _reserved_space.size() - _min_low_byte_size;
       
    97   }
       
    98   // Maximum byte size for the low space.
       
    99   size_t low_byte_size_limit() {
       
   100     return _reserved_space.size() - _min_high_byte_size;
       
   101   }
       
   102 
       
   103   // Sets the boundaries for the virtual spaces and commits and
       
   104   // initial size;
       
   105   void initialize(size_t max_low_byte_size,
       
   106                   size_t init_low_byte_size,
       
   107                   size_t init_high_byte_size);
       
   108 };