1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/services/g1MemoryPool.cpp Fri Nov 20 14:47:01 2009 -0500 1.3 @@ -0,0 +1,153 @@ 1.4 +/* 1.5 + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +# include "incls/_precompiled.incl" 1.29 +# include "incls/_g1MemoryPool.cpp.incl" 1.30 + 1.31 +G1MemoryPoolSuper::G1MemoryPoolSuper(G1CollectedHeap* g1h, 1.32 + const char* name, 1.33 + size_t init_size, 1.34 + size_t max_size, 1.35 + bool support_usage_threshold) : 1.36 + _g1h(g1h), CollectedMemoryPool(name, 1.37 + MemoryPool::Heap, 1.38 + init_size, 1.39 + max_size, 1.40 + support_usage_threshold) { 1.41 + assert(UseG1GC, "sanity"); 1.42 +} 1.43 + 1.44 +// See the comment at the top of g1MemoryPool.hpp 1.45 +size_t G1MemoryPoolSuper::eden_space_committed(G1CollectedHeap* g1h) { 1.46 + return eden_space_used(g1h); 1.47 +} 1.48 + 1.49 +// See the comment at the top of g1MemoryPool.hpp 1.50 +size_t G1MemoryPoolSuper::eden_space_used(G1CollectedHeap* g1h) { 1.51 + size_t young_list_length = g1h->young_list_length(); 1.52 + size_t eden_used = young_list_length * HeapRegion::GrainBytes; 1.53 + size_t survivor_used = survivor_space_used(g1h); 1.54 + eden_used = subtract_up_to_zero(eden_used, survivor_used); 1.55 + return eden_used; 1.56 +} 1.57 + 1.58 +// See the comment at the top of g1MemoryPool.hpp 1.59 +size_t G1MemoryPoolSuper::eden_space_max(G1CollectedHeap* g1h) { 1.60 + return eden_space_committed(g1h); 1.61 +} 1.62 + 1.63 +// See the comment at the top of g1MemoryPool.hpp 1.64 +size_t G1MemoryPoolSuper::survivor_space_committed(G1CollectedHeap* g1h) { 1.65 + return survivor_space_used(g1h); 1.66 +} 1.67 + 1.68 +// See the comment at the top of g1MemoryPool.hpp 1.69 +size_t G1MemoryPoolSuper::survivor_space_used(G1CollectedHeap* g1h) { 1.70 + size_t survivor_num = g1h->g1_policy()->recorded_survivor_regions(); 1.71 + size_t survivor_used = survivor_num * HeapRegion::GrainBytes; 1.72 + return survivor_used; 1.73 +} 1.74 + 1.75 +// See the comment at the top of g1MemoryPool.hpp 1.76 +size_t G1MemoryPoolSuper::survivor_space_max(G1CollectedHeap* g1h) { 1.77 + return survivor_space_committed(g1h); 1.78 +} 1.79 + 1.80 +// See the comment at the top of g1MemoryPool.hpp 1.81 +size_t G1MemoryPoolSuper::old_space_committed(G1CollectedHeap* g1h) { 1.82 + size_t committed = overall_committed(g1h); 1.83 + size_t eden_committed = eden_space_committed(g1h); 1.84 + size_t survivor_committed = survivor_space_committed(g1h); 1.85 + committed = subtract_up_to_zero(committed, eden_committed); 1.86 + committed = subtract_up_to_zero(committed, survivor_committed); 1.87 + return committed; 1.88 +} 1.89 + 1.90 +// See the comment at the top of g1MemoryPool.hpp 1.91 +size_t G1MemoryPoolSuper::old_space_used(G1CollectedHeap* g1h) { 1.92 + size_t used = overall_used(g1h); 1.93 + size_t eden_used = eden_space_used(g1h); 1.94 + size_t survivor_used = survivor_space_used(g1h); 1.95 + used = subtract_up_to_zero(used, eden_used); 1.96 + used = subtract_up_to_zero(used, survivor_used); 1.97 + return used; 1.98 +} 1.99 + 1.100 +// See the comment at the top of g1MemoryPool.hpp 1.101 +size_t G1MemoryPoolSuper::old_space_max(G1CollectedHeap* g1h) { 1.102 + size_t max = g1h->g1_reserved_obj_bytes(); 1.103 + size_t eden_max = eden_space_max(g1h); 1.104 + size_t survivor_max = survivor_space_max(g1h); 1.105 + max = subtract_up_to_zero(max, eden_max); 1.106 + max = subtract_up_to_zero(max, survivor_max); 1.107 + return max; 1.108 +} 1.109 + 1.110 +G1EdenPool::G1EdenPool(G1CollectedHeap* g1h) : 1.111 + G1MemoryPoolSuper(g1h, 1.112 + "G1 Eden", 1.113 + eden_space_committed(g1h), /* init_size */ 1.114 + eden_space_max(g1h), /* max_size */ 1.115 + false /* support_usage_threshold */) { 1.116 +} 1.117 + 1.118 +MemoryUsage G1EdenPool::get_memory_usage() { 1.119 + size_t maxSize = max_size(); 1.120 + size_t used = used_in_bytes(); 1.121 + size_t committed = eden_space_committed(); 1.122 + 1.123 + return MemoryUsage(initial_size(), used, committed, maxSize); 1.124 +} 1.125 + 1.126 +G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h) : 1.127 + G1MemoryPoolSuper(g1h, 1.128 + "G1 Survivor", 1.129 + survivor_space_committed(g1h), /* init_size */ 1.130 + survivor_space_max(g1h), /* max_size */ 1.131 + false /* support_usage_threshold */) { 1.132 +} 1.133 + 1.134 +MemoryUsage G1SurvivorPool::get_memory_usage() { 1.135 + size_t maxSize = max_size(); 1.136 + size_t used = used_in_bytes(); 1.137 + size_t committed = survivor_space_committed(); 1.138 + 1.139 + return MemoryUsage(initial_size(), used, committed, maxSize); 1.140 +} 1.141 + 1.142 +G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h) : 1.143 + G1MemoryPoolSuper(g1h, 1.144 + "G1 Old Gen", 1.145 + old_space_committed(g1h), /* init_size */ 1.146 + old_space_max(g1h), /* max_size */ 1.147 + true /* support_usage_threshold */) { 1.148 +} 1.149 + 1.150 +MemoryUsage G1OldGenPool::get_memory_usage() { 1.151 + size_t maxSize = max_size(); 1.152 + size_t used = used_in_bytes(); 1.153 + size_t committed = old_space_committed(); 1.154 + 1.155 + return MemoryUsage(initial_size(), used, committed, maxSize); 1.156 +}