|
1 /* |
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
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 |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 * |
|
23 */ |
|
24 |
|
25 #ifndef SHARE_VM_gc_G1_G1EVACSTATS_HPP |
|
26 #define SHARE_VM_gc_G1_G1EVACSTATS_HPP |
|
27 |
|
28 #include "gc/shared/plab.hpp" |
|
29 #include "runtime/atomic.hpp" |
|
30 |
|
31 // Records various memory allocation statistics gathered during evacuation. |
|
32 class G1EvacStats : public PLABStats { |
|
33 private: |
|
34 size_t _region_end_waste; // Number of words wasted due to skipping to the next region. |
|
35 uint _regions_filled; // Number of regions filled completely. |
|
36 size_t _direct_allocated; // Number of words allocated directly into the regions. |
|
37 |
|
38 // Number of words in live objects remaining in regions that ultimately suffered an |
|
39 // evacuation failure. This is used in the regions when the regions are made old regions. |
|
40 size_t _failure_used; |
|
41 // Number of words wasted in regions which failed evacuation. This is the sum of space |
|
42 // for objects successfully copied out of the regions (now dead space) plus waste at the |
|
43 // end of regions. |
|
44 size_t _failure_waste; |
|
45 |
|
46 virtual void reset() { |
|
47 PLABStats::reset(); |
|
48 _region_end_waste = 0; |
|
49 _regions_filled = 0; |
|
50 _direct_allocated = 0; |
|
51 _failure_used = 0; |
|
52 _failure_waste = 0; |
|
53 } |
|
54 |
|
55 public: |
|
56 G1EvacStats(size_t desired_plab_sz_, unsigned wt) : PLABStats(desired_plab_sz_, wt), |
|
57 _region_end_waste(0), _regions_filled(0), _direct_allocated(0), |
|
58 _failure_used(0), _failure_waste(0) { |
|
59 } |
|
60 |
|
61 virtual void adjust_desired_plab_sz(); |
|
62 |
|
63 size_t allocated() const { return _allocated; } |
|
64 size_t wasted() const { return _wasted; } |
|
65 size_t unused() const { return _unused; } |
|
66 size_t used() const { return allocated() - (wasted() + unused()); } |
|
67 size_t undo_wasted() const { return _undo_wasted; } |
|
68 |
|
69 uint regions_filled() const { return _regions_filled; } |
|
70 size_t region_end_waste() const { return _region_end_waste; } |
|
71 size_t direct_allocated() const { return _direct_allocated; } |
|
72 |
|
73 // Amount of space in heapwords used in the failing regions when an evacuation failure happens. |
|
74 size_t failure_used() const { return _failure_used; } |
|
75 // Amount of space in heapwords wasted (unused) in the failing regions when an evacuation failure happens. |
|
76 size_t failure_waste() const { return _failure_waste; } |
|
77 |
|
78 void add_direct_allocated(size_t value) { |
|
79 Atomic::add_ptr(value, &_direct_allocated); |
|
80 } |
|
81 |
|
82 void add_region_end_waste(size_t value) { |
|
83 Atomic::add_ptr(value, &_region_end_waste); |
|
84 Atomic::add_ptr(1, &_regions_filled); |
|
85 } |
|
86 |
|
87 void add_failure_used_and_waste(size_t used, size_t waste) { |
|
88 Atomic::add_ptr(used, &_failure_used); |
|
89 Atomic::add_ptr(waste, &_failure_waste); |
|
90 } |
|
91 }; |
|
92 |
|
93 #endif // SHARE_VM_gc_G1_G1EVACSTATS_HPP |