annotate src/share/vm/memory/generationSpec.hpp @ 6197:d2a62e0f25eb

6995781: Native Memory Tracking (Phase 1) 7151532: DCmd for hotspot native memory tracking Summary: Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd Reviewed-by: acorn, coleenp, fparain
author zgu
date Thu, 28 Jun 2012 17:03:16 -0400
parents f95d63e2154a
children da91efe96a93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_MEMORY_GENERATIONSPEC_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_MEMORY_GENERATIONSPEC_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/generation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/permGen.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // The specification of a generation. This class also encapsulates
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // some generation-specific behavior. This is done here rather than as a
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // virtual function of Generation because these methods are needed in
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // initialization of the Generations.
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
35 class GenerationSpec : public CHeapObj<mtGC> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
38 Generation::Name _name;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 size_t _init_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 size_t _max_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
43 GenerationSpec(Generation::Name name, size_t init_size, size_t max_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 _name = name;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 _init_size = init_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 _max_size = max_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 }
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 Generation* init(ReservedSpace rs, int level, GenRemSet* remset);
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
52 Generation::Name name() const { return _name; }
a61af66fc99e Initial load
duke
parents:
diff changeset
53 size_t init_size() const { return _init_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 void set_init_size(size_t size) { _init_size = size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
55 size_t max_size() const { return _max_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
56 void set_max_size(size_t size) { _max_size = size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // Alignment
a61af66fc99e Initial load
duke
parents:
diff changeset
59 void align(size_t alignment) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 set_init_size(align_size_up(init_size(), alignment));
a61af66fc99e Initial load
duke
parents:
diff changeset
61 set_max_size(align_size_up(max_size(), alignment));
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // Return the number of regions contained in the generation which
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // might need to be independently covered by a remembered set.
a61af66fc99e Initial load
duke
parents:
diff changeset
66 virtual int n_covered_regions() const { return 1; }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 };
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 typedef GenerationSpec* GenerationSpecPtr;
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // The specification of a permanent generation. This class is very
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // similar to GenerationSpec in use. Due to PermGen's not being a
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // true Generation, we cannot combine the spec classes either.
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
74 class PermanentGenerationSpec : public CHeapObj<mtGC> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
75 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
77 PermGen::Name _name;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 size_t _init_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 size_t _max_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 size_t _read_only_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 size_t _read_write_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 size_t _misc_data_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 size_t _misc_code_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 bool _enable_shared_spaces;
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 _n_spaces = 2
a61af66fc99e Initial load
duke
parents:
diff changeset
88 };
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
91 PermanentGenerationSpec(PermGen::Name name, size_t init_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
92 size_t max_size, size_t read_only_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
93 size_t read_write_size, size_t misc_data_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
94 size_t misc_code_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 PermGen* init(ReservedSpace rs, size_t init_size, GenRemSet* remset);
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 void disable_sharing() {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 _enable_shared_spaces = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 _read_only_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 _read_write_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 _misc_data_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 _misc_code_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
107 PermGen::Name name() const { return _name; }
a61af66fc99e Initial load
duke
parents:
diff changeset
108 size_t init_size() const { return _init_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 void set_init_size(size_t size) { _init_size = size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // Max size for user DOES NOT include shared spaces.
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // Max size for space allocation DOES include shared spaces.
a61af66fc99e Initial load
duke
parents:
diff changeset
113 size_t max_size() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 return _max_size + _read_only_size + _read_write_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // Need one covered region for the main space, and one for the shared
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // spaces (together).
a61af66fc99e Initial load
duke
parents:
diff changeset
119 int n_covered_regions() const { return 2; }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 void align(size_t alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 size_t read_only_size() const { return _read_only_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 size_t read_write_size() const { return _read_write_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
125 size_t misc_data_size() const { return _misc_data_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
126 size_t misc_code_size() const { return _misc_code_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
127 bool enable_shared_spaces() const { return _enable_shared_spaces; }
a61af66fc99e Initial load
duke
parents:
diff changeset
128 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
129
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
130 #endif // SHARE_VM_MEMORY_GENERATIONSPEC_HPP