comparison src/share/vm/services/g1MemoryPool.cpp @ 3289:b52782ae3880

6946417: G1: Java VisualVM does not support G1 properly. Summary: Added counters for jstat Reviewed-by: tonyp, jwilhelm, stefank, ysr, johnc
author jmasa
date Thu, 21 Apr 2011 10:23:44 -0700
parents f95d63e2154a
children 114e52976463
comparison
equal deleted inserted replaced
3288:c0dcda80820f 3289:b52782ae3880
1 /* 1 /*
2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
32 G1MemoryPoolSuper::G1MemoryPoolSuper(G1CollectedHeap* g1h, 32 G1MemoryPoolSuper::G1MemoryPoolSuper(G1CollectedHeap* g1h,
33 const char* name, 33 const char* name,
34 size_t init_size, 34 size_t init_size,
35 bool support_usage_threshold) : 35 bool support_usage_threshold) :
36 _g1h(g1h), CollectedMemoryPool(name, 36 _g1h(g1h), CollectedMemoryPool(name,
37 MemoryPool::Heap, 37 MemoryPool::Heap,
38 init_size, 38 init_size,
39 undefined_max(), 39 undefined_max(),
40 support_usage_threshold) { 40 support_usage_threshold) {
41 assert(UseG1GC, "sanity"); 41 assert(UseG1GC, "sanity");
42 } 42 }
43 43
44 // See the comment at the top of g1MemoryPool.hpp 44 // See the comment at the top of g1MemoryPool.hpp
45 size_t G1MemoryPoolSuper::eden_space_committed(G1CollectedHeap* g1h) { 45 size_t G1MemoryPoolSuper::eden_space_committed(G1CollectedHeap* g1h) {
46 return MAX2(eden_space_used(g1h), (size_t) HeapRegion::GrainBytes); 46 return MAX2(eden_space_used(g1h), (size_t) HeapRegion::GrainBytes);
47 } 47 }
48 48
49 // See the comment at the top of g1MemoryPool.hpp 49 // See the comment at the top of g1MemoryPool.hpp
50 size_t G1MemoryPoolSuper::eden_space_used(G1CollectedHeap* g1h) { 50 size_t G1MemoryPoolSuper::eden_space_used(G1CollectedHeap* g1h) {
51 size_t young_list_length = g1h->young_list()->length(); 51 return g1h->g1mm()->eden_space_used();
52 size_t eden_used = young_list_length * HeapRegion::GrainBytes;
53 size_t survivor_used = survivor_space_used(g1h);
54 eden_used = subtract_up_to_zero(eden_used, survivor_used);
55 return eden_used;
56 } 52 }
57 53
58 // See the comment at the top of g1MemoryPool.hpp 54 // See the comment at the top of g1MemoryPool.hpp
59 size_t G1MemoryPoolSuper::survivor_space_committed(G1CollectedHeap* g1h) { 55 size_t G1MemoryPoolSuper::survivor_space_committed(G1CollectedHeap* g1h) {
60 return MAX2(survivor_space_used(g1h), (size_t) HeapRegion::GrainBytes); 56 return g1h->g1mm()->survivor_space_committed();
61 } 57 }
62 58
63 // See the comment at the top of g1MemoryPool.hpp 59 // See the comment at the top of g1MemoryPool.hpp
64 size_t G1MemoryPoolSuper::survivor_space_used(G1CollectedHeap* g1h) { 60 size_t G1MemoryPoolSuper::survivor_space_used(G1CollectedHeap* g1h) {
65 size_t survivor_num = g1h->g1_policy()->recorded_survivor_regions(); 61 return g1h->g1mm()->survivor_space_used();
66 size_t survivor_used = survivor_num * HeapRegion::GrainBytes;
67 return survivor_used;
68 } 62 }
69 63
70 // See the comment at the top of g1MemoryPool.hpp 64 // See the comment at the top of g1MemoryPool.hpp
71 size_t G1MemoryPoolSuper::old_space_committed(G1CollectedHeap* g1h) { 65 size_t G1MemoryPoolSuper::old_space_committed(G1CollectedHeap* g1h) {
72 size_t committed = overall_committed(g1h); 66 return g1h->g1mm()->old_space_committed();
73 size_t eden_committed = eden_space_committed(g1h);
74 size_t survivor_committed = survivor_space_committed(g1h);
75 committed = subtract_up_to_zero(committed, eden_committed);
76 committed = subtract_up_to_zero(committed, survivor_committed);
77 committed = MAX2(committed, (size_t) HeapRegion::GrainBytes);
78 return committed;
79 } 67 }
80 68
81 // See the comment at the top of g1MemoryPool.hpp 69 // See the comment at the top of g1MemoryPool.hpp
82 size_t G1MemoryPoolSuper::old_space_used(G1CollectedHeap* g1h) { 70 size_t G1MemoryPoolSuper::old_space_used(G1CollectedHeap* g1h) {
83 size_t used = overall_used(g1h); 71 return g1h->g1mm()->old_space_used();
84 size_t eden_used = eden_space_used(g1h);
85 size_t survivor_used = survivor_space_used(g1h);
86 used = subtract_up_to_zero(used, eden_used);
87 used = subtract_up_to_zero(used, survivor_used);
88 return used;
89 } 72 }
90 73
91 G1EdenPool::G1EdenPool(G1CollectedHeap* g1h) : 74 G1EdenPool::G1EdenPool(G1CollectedHeap* g1h) :
92 G1MemoryPoolSuper(g1h, 75 G1MemoryPoolSuper(g1h,
93 "G1 Eden", 76 "G1 Eden",