src/share/vm/services/memoryService.hpp

Wed, 02 Feb 2011 14:38:01 -0500

author
kamg
date
Wed, 02 Feb 2011 14:38:01 -0500
changeset 2511
bf8517f4e4d0
parent 2314
f95d63e2154a
child 2888
78542e2b5e35
permissions
-rw-r--r--

6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
Summary: Defer posting events from the compiler thread: use service thread
Reviewed-by: coleenp, dholmes, never, dcubed

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_SERVICES_MEMORYSERVICE_HPP
stefank@2314 26 #define SHARE_VM_SERVICES_MEMORYSERVICE_HPP
stefank@2314 27
stefank@2314 28 #include "memory/allocation.hpp"
stefank@2314 29 #include "memory/generation.hpp"
stefank@2314 30 #include "runtime/handles.hpp"
stefank@2314 31 #include "services/memoryUsage.hpp"
stefank@2314 32
duke@435 33 // Forward declaration
duke@435 34 class MemoryPool;
duke@435 35 class MemoryManager;
duke@435 36 class GCMemoryManager;
duke@435 37 class CollectedHeap;
duke@435 38 class Generation;
duke@435 39 class DefNewGeneration;
duke@435 40 class PSYoungGen;
duke@435 41 class PSOldGen;
duke@435 42 class PSPermGen;
duke@435 43 class CodeHeap;
duke@435 44 class ContiguousSpace;
duke@435 45 class CompactibleFreeListSpace;
duke@435 46 class PermanentGenerationSpec;
duke@435 47 class GenCollectedHeap;
duke@435 48 class ParallelScavengeHeap;
duke@435 49 class CompactingPermGenGen;
duke@435 50 class CMSPermGenGen;
tonyp@1524 51 class G1CollectedHeap;
duke@435 52
duke@435 53 // VM Monitoring and Management Support
duke@435 54
duke@435 55 class MemoryService : public AllStatic {
duke@435 56 private:
duke@435 57 enum {
duke@435 58 init_pools_list_size = 10,
duke@435 59 init_managers_list_size = 5
duke@435 60 };
duke@435 61
duke@435 62 // index for minor and major generations
duke@435 63 enum {
duke@435 64 minor = 0,
duke@435 65 major = 1,
duke@435 66 n_gens = 2
duke@435 67 };
duke@435 68
duke@435 69 static GrowableArray<MemoryPool*>* _pools_list;
duke@435 70 static GrowableArray<MemoryManager*>* _managers_list;
duke@435 71
duke@435 72 // memory managers for minor and major GC statistics
duke@435 73 static GCMemoryManager* _major_gc_manager;
duke@435 74 static GCMemoryManager* _minor_gc_manager;
duke@435 75
duke@435 76 // Code heap memory pool
duke@435 77 static MemoryPool* _code_heap_pool;
duke@435 78
duke@435 79 static void add_generation_memory_pool(Generation* gen,
duke@435 80 MemoryManager* major_mgr,
duke@435 81 MemoryManager* minor_mgr);
duke@435 82 static void add_generation_memory_pool(Generation* gen,
duke@435 83 MemoryManager* major_mgr) {
duke@435 84 add_generation_memory_pool(gen, major_mgr, NULL);
duke@435 85 }
duke@435 86
duke@435 87 static void add_compact_perm_gen_memory_pool(CompactingPermGenGen* perm_gen,
duke@435 88 MemoryManager* mgr);
duke@435 89 static void add_cms_perm_gen_memory_pool(CMSPermGenGen* perm_gen,
duke@435 90 MemoryManager* mgr);
duke@435 91
duke@435 92 static void add_psYoung_memory_pool(PSYoungGen* gen,
duke@435 93 MemoryManager* major_mgr,
duke@435 94 MemoryManager* minor_mgr);
duke@435 95 static void add_psOld_memory_pool(PSOldGen* gen,
duke@435 96 MemoryManager* mgr);
duke@435 97 static void add_psPerm_memory_pool(PSPermGen* perm,
duke@435 98 MemoryManager* mgr);
duke@435 99
tonyp@1524 100 static void add_g1YoungGen_memory_pool(G1CollectedHeap* g1h,
tonyp@1524 101 MemoryManager* major_mgr,
tonyp@1524 102 MemoryManager* minor_mgr);
tonyp@1524 103 static void add_g1OldGen_memory_pool(G1CollectedHeap* g1h,
tonyp@1524 104 MemoryManager* mgr);
tonyp@1524 105 static void add_g1PermGen_memory_pool(G1CollectedHeap* g1h,
tonyp@1524 106 MemoryManager* mgr);
duke@435 107
duke@435 108 static MemoryPool* add_space(ContiguousSpace* space,
duke@435 109 const char* name,
duke@435 110 bool is_heap,
duke@435 111 size_t max_size,
duke@435 112 bool support_usage_threshold);
duke@435 113 static MemoryPool* add_survivor_spaces(DefNewGeneration* gen,
duke@435 114 const char* name,
duke@435 115 bool is_heap,
duke@435 116 size_t max_size,
duke@435 117 bool support_usage_threshold);
duke@435 118 static MemoryPool* add_gen(Generation* gen,
duke@435 119 const char* name,
duke@435 120 bool is_heap,
duke@435 121 bool support_usage_threshold);
duke@435 122 static MemoryPool* add_cms_space(CompactibleFreeListSpace* space,
duke@435 123 const char* name,
duke@435 124 bool is_heap,
duke@435 125 size_t max_size,
duke@435 126 bool support_usage_threshold);
duke@435 127
duke@435 128 static void add_gen_collected_heap_info(GenCollectedHeap* heap);
duke@435 129 static void add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap);
tonyp@1524 130 static void add_g1_heap_info(G1CollectedHeap* g1h);
duke@435 131
duke@435 132 public:
duke@435 133 static void set_universe_heap(CollectedHeap* heap);
duke@435 134 static void add_code_heap_memory_pool(CodeHeap* heap);
duke@435 135
duke@435 136 static MemoryPool* get_memory_pool(instanceHandle pool);
duke@435 137 static MemoryManager* get_memory_manager(instanceHandle mgr);
duke@435 138
duke@435 139 static const int num_memory_pools() {
duke@435 140 return _pools_list->length();
duke@435 141 }
duke@435 142 static const int num_memory_managers() {
duke@435 143 return _managers_list->length();
duke@435 144 }
duke@435 145
duke@435 146 static MemoryPool* get_memory_pool(int index) {
duke@435 147 return _pools_list->at(index);
duke@435 148 }
duke@435 149
duke@435 150 static MemoryManager* get_memory_manager(int index) {
duke@435 151 return _managers_list->at(index);
duke@435 152 }
duke@435 153
duke@435 154 static void track_memory_usage();
duke@435 155 static void track_code_cache_memory_usage() {
duke@435 156 track_memory_pool_usage(_code_heap_pool);
duke@435 157 }
duke@435 158 static void track_memory_pool_usage(MemoryPool* pool);
duke@435 159
kevinw@2058 160 static void gc_begin(bool fullGC, bool recordGCBeginTime,
kevinw@2058 161 bool recordAccumulatedGCTime,
kevinw@2058 162 bool recordPreGCUsage, bool recordPeakUsage);
kevinw@2058 163 static void gc_end(bool fullGC, bool recordPostGCUsage,
kevinw@2058 164 bool recordAccumulatedGCTime,
kevinw@2058 165 bool recordGCEndTime, bool countCollection);
kevinw@2058 166
duke@435 167
duke@435 168 static void oops_do(OopClosure* f);
duke@435 169
duke@435 170 static bool get_verbose() { return PrintGC; }
duke@435 171 static bool set_verbose(bool verbose);
duke@435 172
duke@435 173 // Create an instance of java/lang/management/MemoryUsage
duke@435 174 static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS);
duke@435 175 };
duke@435 176
duke@435 177 class TraceMemoryManagerStats : public StackObj {
duke@435 178 private:
duke@435 179 bool _fullGC;
kevinw@2058 180 bool _recordGCBeginTime;
kevinw@2058 181 bool _recordPreGCUsage;
kevinw@2058 182 bool _recordPeakUsage;
kevinw@2058 183 bool _recordPostGCUsage;
kevinw@2058 184 bool _recordAccumulatedGCTime;
kevinw@2058 185 bool _recordGCEndTime;
kevinw@2058 186 bool _countCollection;
kevinw@2058 187
duke@435 188 public:
kevinw@2058 189 TraceMemoryManagerStats() {}
kevinw@2058 190 TraceMemoryManagerStats(bool fullGC,
kevinw@2058 191 bool recordGCBeginTime = true,
kevinw@2058 192 bool recordPreGCUsage = true,
kevinw@2058 193 bool recordPeakUsage = true,
kevinw@2058 194 bool recordPostGCUsage = true,
kevinw@2058 195 bool recordAccumulatedGCTime = true,
kevinw@2058 196 bool recordGCEndTime = true,
kevinw@2058 197 bool countCollection = true);
kevinw@2058 198
kevinw@2058 199 void initialize(bool fullGC,
kevinw@2058 200 bool recordGCBeginTime,
kevinw@2058 201 bool recordPreGCUsage,
kevinw@2058 202 bool recordPeakUsage,
kevinw@2058 203 bool recordPostGCUsage,
kevinw@2058 204 bool recordAccumulatedGCTime,
kevinw@2058 205 bool recordGCEndTime,
kevinw@2058 206 bool countCollection);
kevinw@2058 207
duke@435 208 TraceMemoryManagerStats(Generation::Name kind);
duke@435 209 ~TraceMemoryManagerStats();
duke@435 210 };
stefank@2314 211
stefank@2314 212 #endif // SHARE_VM_SERVICES_MEMORYSERVICE_HPP

mercurial