34 #include "memory/allocation.inline.hpp"
35 #include "runtime/thread.inline.hpp"
36
37 class GetRSThreadVTimeClosure : public ThreadClosure {
38 private:
39 G1RemSetSummary* _summary;
40 uint _counter;
41
42 public:
43 GetRSThreadVTimeClosure(G1RemSetSummary * summary) : ThreadClosure(), _summary(summary), _counter(0) {
44 assert(_summary != NULL, "just checking");
45 }
46
47 virtual void do_thread(Thread* t) {
48 ConcurrentG1RefineThread* crt = (ConcurrentG1RefineThread*) t;
49 _summary->set_rs_thread_vtime(_counter, crt->vtime_accum());
50 _counter++;
51 }
52 };
53
54 void G1RemSetSummary::update() {
55 _num_conc_refined_cards = remset()->num_conc_refined_cards();
56 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
57 _num_processed_buf_mutator = dcqs.processed_buffers_mut();
58 _num_processed_buf_rs_threads = dcqs.processed_buffers_rs_thread();
59
60 _num_coarsenings = HeapRegionRemSet::n_coarsenings();
61
62 ConcurrentG1Refine * cg1r = G1CollectedHeap::heap()->concurrent_g1_refine();
63 if (_rs_threads_vtimes != NULL) {
64 GetRSThreadVTimeClosure p(this);
65 cg1r->worker_threads_do(&p);
66 }
67 set_sampling_thread_vtime(cg1r->sampling_thread()->vtime_accum());
68 }
69
70 void G1RemSetSummary::set_rs_thread_vtime(uint thread, double value) {
71 assert(_rs_threads_vtimes != NULL, "just checking");
72 assert(thread < _num_vtimes, "just checking");
73 _rs_threads_vtimes[thread] = value;
74 }
75
76 double G1RemSetSummary::rs_thread_vtime(uint thread) const {
77 assert(_rs_threads_vtimes != NULL, "just checking");
78 assert(thread < _num_vtimes, "just checking");
79 return _rs_threads_vtimes[thread];
80 }
81
82 void G1RemSetSummary::initialize(G1RemSet* remset) {
83 assert(_rs_threads_vtimes == NULL, "just checking");
84 assert(remset != NULL, "just checking");
85
86 _remset = remset;
87 _num_vtimes = ConcurrentG1Refine::thread_num();
88 _rs_threads_vtimes = NEW_C_HEAP_ARRAY(double, _num_vtimes, mtGC);
89 memset(_rs_threads_vtimes, 0, sizeof(double) * _num_vtimes);
90
91 update();
92 }
93
94 G1RemSetSummary::G1RemSetSummary() :
95 _remset(NULL),
96 _num_conc_refined_cards(0),
97 _num_processed_buf_mutator(0),
98 _num_processed_buf_rs_threads(0),
99 _num_coarsenings(0),
100 _rs_threads_vtimes(NULL),
101 _num_vtimes(0),
102 _sampling_thread_vtime(0.0f) {
103 }
104
105 G1RemSetSummary::~G1RemSetSummary() {
106 if (_rs_threads_vtimes) {
107 FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes);
108 }
109 }
110
111 void G1RemSetSummary::set(G1RemSetSummary* other) {
112 assert(other != NULL, "just checking");
113 assert(remset() == other->remset(), "just checking");
114 assert(_num_vtimes == other->_num_vtimes, "just checking");
115
116 _num_conc_refined_cards = other->num_conc_refined_cards();
117
118 _num_processed_buf_mutator = other->num_processed_buf_mutator();
119 _num_processed_buf_rs_threads = other->num_processed_buf_rs_threads();
120
121 _num_coarsenings = other->_num_coarsenings;
122
|
34 #include "memory/allocation.inline.hpp"
35 #include "runtime/thread.inline.hpp"
36
37 class GetRSThreadVTimeClosure : public ThreadClosure {
38 private:
39 G1RemSetSummary* _summary;
40 uint _counter;
41
42 public:
43 GetRSThreadVTimeClosure(G1RemSetSummary * summary) : ThreadClosure(), _summary(summary), _counter(0) {
44 assert(_summary != NULL, "just checking");
45 }
46
47 virtual void do_thread(Thread* t) {
48 ConcurrentG1RefineThread* crt = (ConcurrentG1RefineThread*) t;
49 _summary->set_rs_thread_vtime(_counter, crt->vtime_accum());
50 _counter++;
51 }
52 };
53
54 G1RemSet* G1RemSetSummary::remset() const {
55 return G1CollectedHeap::heap()->g1_rem_set();
56 }
57
58 void G1RemSetSummary::update() {
59 _num_conc_refined_cards = remset()->num_conc_refined_cards();
60 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
61 _num_processed_buf_mutator = dcqs.processed_buffers_mut();
62 _num_processed_buf_rs_threads = dcqs.processed_buffers_rs_thread();
63
64 _num_coarsenings = HeapRegionRemSet::n_coarsenings();
65
66 ConcurrentG1Refine * cg1r = G1CollectedHeap::heap()->concurrent_g1_refine();
67 if (_rs_threads_vtimes != NULL) {
68 GetRSThreadVTimeClosure p(this);
69 cg1r->worker_threads_do(&p);
70 }
71 set_sampling_thread_vtime(cg1r->sampling_thread()->vtime_accum());
72 }
73
74 void G1RemSetSummary::set_rs_thread_vtime(uint thread, double value) {
75 assert(_rs_threads_vtimes != NULL, "just checking");
76 assert(thread < _num_vtimes, "just checking");
77 _rs_threads_vtimes[thread] = value;
78 }
79
80 double G1RemSetSummary::rs_thread_vtime(uint thread) const {
81 assert(_rs_threads_vtimes != NULL, "just checking");
82 assert(thread < _num_vtimes, "just checking");
83 return _rs_threads_vtimes[thread];
84 }
85
86 G1RemSetSummary::G1RemSetSummary() :
87 _num_conc_refined_cards(0),
88 _num_processed_buf_mutator(0),
89 _num_processed_buf_rs_threads(0),
90 _num_coarsenings(0),
91 _num_vtimes(ConcurrentG1Refine::thread_num()),
92 _rs_threads_vtimes(NEW_C_HEAP_ARRAY(double, _num_vtimes, mtGC)),
93 _sampling_thread_vtime(0.0f) {
94
95 memset(_rs_threads_vtimes, 0, sizeof(double) * _num_vtimes);
96 }
97
98 G1RemSetSummary::~G1RemSetSummary() {
99 if (_rs_threads_vtimes) {
100 FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes);
101 }
102 }
103
104 void G1RemSetSummary::set(G1RemSetSummary* other) {
105 assert(other != NULL, "just checking");
106 assert(remset() == other->remset(), "just checking");
107 assert(_num_vtimes == other->_num_vtimes, "just checking");
108
109 _num_conc_refined_cards = other->num_conc_refined_cards();
110
111 _num_processed_buf_mutator = other->num_processed_buf_mutator();
112 _num_processed_buf_rs_threads = other->num_processed_buf_rs_threads();
113
114 _num_coarsenings = other->_num_coarsenings;
115
|