hotspot/src/share/vm/memory/generationSpec.hpp
author acorn
Thu, 05 Mar 2009 22:07:29 -0500
changeset 2140 07437c6a4cd4
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2001-2004 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// The specification of a generation.  This class also encapsulates
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
// some generation-specific behavior.  This is done here rather than as a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// virtual function of Generation because these methods are needed in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// initialization of the Generations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
class GenerationSpec : public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  Generation::Name _name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  size_t           _init_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  size_t           _max_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  GenerationSpec(Generation::Name name, size_t init_size, size_t max_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    _name = name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    _init_size = init_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    _max_size = max_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  Generation* init(ReservedSpace rs, int level, GenRemSet* remset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  Generation::Name name()        const { return _name; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  size_t init_size()             const { return _init_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  void set_init_size(size_t size)      { _init_size = size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  size_t max_size()              const { return _max_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  void set_max_size(size_t size)       { _max_size = size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  // Alignment
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  void align(size_t alignment) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    set_init_size(align_size_up(init_size(), alignment));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    set_max_size(align_size_up(max_size(), alignment));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // Return the number of regions contained in the generation which
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // might need to be independently covered by a remembered set.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  virtual int n_covered_regions() const { return 1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
typedef GenerationSpec* GenerationSpecPtr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
// The specification of a permanent generation. This class is very
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
// similar to GenerationSpec in use. Due to PermGen's not being a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
// true Generation, we cannot combine the spec classes either.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
class PermanentGenerationSpec : public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  PermGen::Name    _name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  size_t           _init_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  size_t           _max_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  size_t           _read_only_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  size_t           _read_write_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  size_t           _misc_data_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  size_t           _misc_code_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  bool             _enable_shared_spaces;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    _n_spaces = 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  PermanentGenerationSpec(PermGen::Name name, size_t init_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
                          size_t max_size, size_t read_only_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
                          size_t read_write_size, size_t misc_data_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
                          size_t misc_code_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  PermGen* init(ReservedSpace rs, size_t init_size, GenRemSet* remset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  void disable_sharing() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    _enable_shared_spaces = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    _read_only_size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    _read_write_size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    _misc_data_size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    _misc_code_size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  PermGen::Name name()           const { return _name; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  size_t init_size()             const { return _init_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  void set_init_size(size_t size)      { _init_size = size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  // Max size for user DOES NOT include shared spaces.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // Max size for space allocation DOES include shared spaces.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  size_t max_size() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    return _max_size + _read_only_size + _read_write_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  // Need one covered region for the main space, and one for the shared
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // spaces (together).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  int n_covered_regions() const { return 2; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  void align(size_t alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  size_t read_only_size() const { return _read_only_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  size_t read_write_size() const { return _read_write_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  size_t misc_data_size() const { return _misc_data_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  size_t misc_code_size() const { return _misc_code_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  bool enable_shared_spaces()    const { return _enable_shared_spaces; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
};