1 /* 2 * Copyright (c) 2013, 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_G1REMSETSUMMARY_HPP 26 #define SHARE_VM_GC_G1_G1REMSETSUMMARY_HPP 27 28 #include "utilities/ostream.hpp" 29 30 class G1RemSet; 31 32 // A G1RemSetSummary manages statistical information about the G1RemSet 33 34 class G1RemSetSummary VALUE_OBJ_CLASS_SPEC { 35 private: 36 friend class GetRSThreadVTimeClosure; 37 38 G1RemSet* _remset; 39 40 G1RemSet* remset() const { 41 return _remset; 42 } 43 44 size_t _num_refined_cards; 45 size_t _num_processed_buf_mutator; 46 size_t _num_processed_buf_rs_threads; 47 48 size_t _num_coarsenings; 49 50 double* _rs_threads_vtimes; 51 size_t _num_vtimes; 52 53 double _sampling_thread_vtime; 54 55 void set_rs_thread_vtime(uint thread, double value); 56 void set_sampling_thread_vtime(double value) { 57 _sampling_thread_vtime = value; 58 } 59 60 void free_and_null() { 61 if (_rs_threads_vtimes) { 62 FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes); 63 _rs_threads_vtimes = NULL; 64 _num_vtimes = 0; 65 } 66 } 67 68 // update this summary with current data from various places 69 void update(); 70 71 public: 72 G1RemSetSummary() : _remset(NULL), _num_refined_cards(0), 73 _num_processed_buf_mutator(0), _num_processed_buf_rs_threads(0), _num_coarsenings(0), 74 _rs_threads_vtimes(NULL), _num_vtimes(0), _sampling_thread_vtime(0.0f) { 75 } 76 77 ~G1RemSetSummary() { 78 free_and_null(); 79 } 80 81 // set the counters in this summary to the values of the others 82 void set(G1RemSetSummary* other); 83 // subtract all counters from the other summary, and set them in the current 84 void subtract_from(G1RemSetSummary* other); 85 86 // initialize and get the first sampling 87 void initialize(G1RemSet* remset); 88 89 void print_on(outputStream* out); 90 91 double rs_thread_vtime(uint thread) const; 92 93 double sampling_thread_vtime() const { 94 return _sampling_thread_vtime; 95 } 96 97 size_t num_concurrent_refined_cards() const { 98 return _num_refined_cards; 99 } 100 101 size_t num_processed_buf_mutator() const { 102 return _num_processed_buf_mutator; 103 } 104 105 size_t num_processed_buf_rs_threads() const { 106 return _num_processed_buf_rs_threads; 107 } 108 109 size_t num_processed_buf_total() const { 110 return num_processed_buf_mutator() + num_processed_buf_rs_threads(); 111 } 112 113 size_t num_coarsenings() const { 114 return _num_coarsenings; 115 } 116 }; 117 118 #endif // SHARE_VM_GC_G1_G1REMSETSUMMARY_HPP