comparison src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp @ 17844:8847586c9037

8016302: Change type of the number of GC workers to unsigned int (2) Reviewed-by: tschatzl, jwilhelm
author vkempik
date Thu, 03 Apr 2014 17:49:31 +0400
parents 1de8e5356754
children 52b4284cb496 570cb6369f17
comparison
equal deleted inserted replaced
17843:81d7a4b28dc5 17844:8847586c9037
55 55
56 reset_threshold_step(); 56 reset_threshold_step();
57 57
58 _threads = NEW_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _n_threads, mtGC); 58 _threads = NEW_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _n_threads, mtGC);
59 59
60 int worker_id_offset = (int)DirtyCardQueueSet::num_par_ids(); 60 uint worker_id_offset = DirtyCardQueueSet::num_par_ids();
61 61
62 ConcurrentG1RefineThread *next = NULL; 62 ConcurrentG1RefineThread *next = NULL;
63 for (int i = _n_threads - 1; i >= 0; i--) { 63 for (uint i = _n_threads - 1; i != UINT_MAX; i--) {
64 ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, worker_id_offset, i); 64 ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, worker_id_offset, i);
65 assert(t != NULL, "Conc refine should have been created"); 65 assert(t != NULL, "Conc refine should have been created");
66 if (t->osthread() == NULL) { 66 if (t->osthread() == NULL) {
67 vm_shutdown_during_initialization("Could not create ConcurrentG1RefineThread"); 67 vm_shutdown_during_initialization("Could not create ConcurrentG1RefineThread");
68 } 68 }
85 _hot_card_cache.initialize(); 85 _hot_card_cache.initialize();
86 } 86 }
87 87
88 void ConcurrentG1Refine::stop() { 88 void ConcurrentG1Refine::stop() {
89 if (_threads != NULL) { 89 if (_threads != NULL) {
90 for (int i = 0; i < _n_threads; i++) { 90 for (uint i = 0; i < _n_threads; i++) {
91 _threads[i]->stop(); 91 _threads[i]->stop();
92 } 92 }
93 } 93 }
94 } 94 }
95 95
96 void ConcurrentG1Refine::reinitialize_threads() { 96 void ConcurrentG1Refine::reinitialize_threads() {
97 reset_threshold_step(); 97 reset_threshold_step();
98 if (_threads != NULL) { 98 if (_threads != NULL) {
99 for (int i = 0; i < _n_threads; i++) { 99 for (uint i = 0; i < _n_threads; i++) {
100 _threads[i]->initialize(); 100 _threads[i]->initialize();
101 } 101 }
102 } 102 }
103 } 103 }
104 104
105 ConcurrentG1Refine::~ConcurrentG1Refine() { 105 ConcurrentG1Refine::~ConcurrentG1Refine() {
106 if (_threads != NULL) { 106 if (_threads != NULL) {
107 for (int i = 0; i < _n_threads; i++) { 107 for (uint i = 0; i < _n_threads; i++) {
108 delete _threads[i]; 108 delete _threads[i];
109 } 109 }
110 FREE_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _threads, mtGC); 110 FREE_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _threads, mtGC);
111 } 111 }
112 } 112 }
113 113
114 void ConcurrentG1Refine::threads_do(ThreadClosure *tc) { 114 void ConcurrentG1Refine::threads_do(ThreadClosure *tc) {
115 if (_threads != NULL) { 115 if (_threads != NULL) {
116 for (int i = 0; i < _n_threads; i++) { 116 for (uint i = 0; i < _n_threads; i++) {
117 tc->do_thread(_threads[i]); 117 tc->do_thread(_threads[i]);
118 } 118 }
119 } 119 }
120 } 120 }
121 121
122 void ConcurrentG1Refine::worker_threads_do(ThreadClosure * tc) { 122 void ConcurrentG1Refine::worker_threads_do(ThreadClosure * tc) {
123 if (_threads != NULL) { 123 if (_threads != NULL) {
124 for (int i = 0; i < worker_thread_num(); i++) { 124 for (uint i = 0; i < worker_thread_num(); i++) {
125 tc->do_thread(_threads[i]); 125 tc->do_thread(_threads[i]);
126 } 126 }
127 } 127 }
128 } 128 }
129 129
130 int ConcurrentG1Refine::thread_num() { 130 uint ConcurrentG1Refine::thread_num() {
131 int n_threads = (G1ConcRefinementThreads > 0) ? G1ConcRefinementThreads 131 uint n_threads = (G1ConcRefinementThreads > 0) ? G1ConcRefinementThreads
132 : ParallelGCThreads; 132 : ParallelGCThreads;
133 return MAX2<int>(n_threads, 1); 133 return MAX2<uint>(n_threads, 1);
134 } 134 }
135 135
136 void ConcurrentG1Refine::print_worker_threads_on(outputStream* st) const { 136 void ConcurrentG1Refine::print_worker_threads_on(outputStream* st) const {
137 for (int i = 0; i < _n_threads; ++i) { 137 for (uint i = 0; i < _n_threads; ++i) {
138 _threads[i]->print_on(st); 138 _threads[i]->print_on(st);
139 st->cr(); 139 st->cr();
140 } 140 }
141 } 141 }
142 142