annotate src/share/vm/services/memoryService.hpp @ 452:00b023ae2d78

6722113: CMS: Incorrect overflow handling during precleaning of Reference lists Summary: When we encounter marking stack overflow during precleaning of Reference lists, we were using the overflow list mechanism, which can cause problems on account of mutating the mark word of the header because of conflicts with mutator accesses and updates of that field. Instead we should use the usual mechanism for overflow handling in concurrent phases, namely dirtying of the card on which the overflowed object lies. Since precleaning effectively does a form of discovered list processing, albeit with discovery enabled, we needed to adjust some code to be correct in the face of interleaved processing and discovery. Reviewed-by: apetrusenko, jcoomes
author ysr
date Thu, 20 Nov 2008 12:27:41 -0800
parents a61af66fc99e
children db0d5eba9d20
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // Forward declaration
a61af66fc99e Initial load
duke
parents:
diff changeset
26 class MemoryPool;
a61af66fc99e Initial load
duke
parents:
diff changeset
27 class MemoryManager;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 class GCMemoryManager;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 class CollectedHeap;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 class Generation;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class DefNewGeneration;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 class PSYoungGen;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 class PSOldGen;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 class PSPermGen;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 class CodeHeap;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 class ContiguousSpace;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class CompactibleFreeListSpace;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 class PermanentGenerationSpec;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class GenCollectedHeap;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 class ParallelScavengeHeap;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 class CompactingPermGenGen;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 class CMSPermGenGen;
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // VM Monitoring and Management Support
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 class MemoryService : public AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
48 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 init_pools_list_size = 10,
a61af66fc99e Initial load
duke
parents:
diff changeset
50 init_managers_list_size = 5
a61af66fc99e Initial load
duke
parents:
diff changeset
51 };
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // index for minor and major generations
a61af66fc99e Initial load
duke
parents:
diff changeset
54 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 minor = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
56 major = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
57 n_gens = 2
a61af66fc99e Initial load
duke
parents:
diff changeset
58 };
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 static GrowableArray<MemoryPool*>* _pools_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 static GrowableArray<MemoryManager*>* _managers_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // memory managers for minor and major GC statistics
a61af66fc99e Initial load
duke
parents:
diff changeset
64 static GCMemoryManager* _major_gc_manager;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 static GCMemoryManager* _minor_gc_manager;
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // Code heap memory pool
a61af66fc99e Initial load
duke
parents:
diff changeset
68 static MemoryPool* _code_heap_pool;
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 static void add_generation_memory_pool(Generation* gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
71 MemoryManager* major_mgr,
a61af66fc99e Initial load
duke
parents:
diff changeset
72 MemoryManager* minor_mgr);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 static void add_generation_memory_pool(Generation* gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
74 MemoryManager* major_mgr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 add_generation_memory_pool(gen, major_mgr, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 static void add_compact_perm_gen_memory_pool(CompactingPermGenGen* perm_gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
79 MemoryManager* mgr);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 static void add_cms_perm_gen_memory_pool(CMSPermGenGen* perm_gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
81 MemoryManager* mgr);
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 static void add_psYoung_memory_pool(PSYoungGen* gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
84 MemoryManager* major_mgr,
a61af66fc99e Initial load
duke
parents:
diff changeset
85 MemoryManager* minor_mgr);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 static void add_psOld_memory_pool(PSOldGen* gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
87 MemoryManager* mgr);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 static void add_psPerm_memory_pool(PSPermGen* perm,
a61af66fc99e Initial load
duke
parents:
diff changeset
89 MemoryManager* mgr);
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 static MemoryPool* add_space(ContiguousSpace* space,
a61af66fc99e Initial load
duke
parents:
diff changeset
93 const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
94 bool is_heap,
a61af66fc99e Initial load
duke
parents:
diff changeset
95 size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 bool support_usage_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 static MemoryPool* add_survivor_spaces(DefNewGeneration* gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
98 const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
99 bool is_heap,
a61af66fc99e Initial load
duke
parents:
diff changeset
100 size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
101 bool support_usage_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 static MemoryPool* add_gen(Generation* gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
103 const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
104 bool is_heap,
a61af66fc99e Initial load
duke
parents:
diff changeset
105 bool support_usage_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 static MemoryPool* add_cms_space(CompactibleFreeListSpace* space,
a61af66fc99e Initial load
duke
parents:
diff changeset
107 const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
108 bool is_heap,
a61af66fc99e Initial load
duke
parents:
diff changeset
109 size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
110 bool support_usage_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 static void add_gen_collected_heap_info(GenCollectedHeap* heap);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 static void add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap);
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
116 static void set_universe_heap(CollectedHeap* heap);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 static void add_code_heap_memory_pool(CodeHeap* heap);
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 static MemoryPool* get_memory_pool(instanceHandle pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 static MemoryManager* get_memory_manager(instanceHandle mgr);
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 static const int num_memory_pools() {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 return _pools_list->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125 static const int num_memory_managers() {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 return _managers_list->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 static MemoryPool* get_memory_pool(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 return _pools_list->at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 static MemoryManager* get_memory_manager(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 return _managers_list->at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 static void track_memory_usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
138 static void track_code_cache_memory_usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 track_memory_pool_usage(_code_heap_pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 static void track_memory_pool_usage(MemoryPool* pool);
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 static void gc_begin(bool fullGC);
a61af66fc99e Initial load
duke
parents:
diff changeset
144 static void gc_end(bool fullGC);
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 static void oops_do(OopClosure* f);
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 static bool get_verbose() { return PrintGC; }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 static bool set_verbose(bool verbose);
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Create an instance of java/lang/management/MemoryUsage
a61af66fc99e Initial load
duke
parents:
diff changeset
152 static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 };
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 class TraceMemoryManagerStats : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
157 bool _fullGC;
a61af66fc99e Initial load
duke
parents:
diff changeset
158 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
159 TraceMemoryManagerStats(bool fullGC);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 TraceMemoryManagerStats(Generation::Name kind);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 ~TraceMemoryManagerStats();
a61af66fc99e Initial load
duke
parents:
diff changeset
162 };