31 _def_use_cache(false), _use_cache(false), |
31 _def_use_cache(false), _use_cache(false), |
32 _n_periods(0), _total_cards(0), _total_travs(0), |
32 _n_periods(0), _total_cards(0), _total_travs(0), |
33 _threads(NULL), _n_threads(0) |
33 _threads(NULL), _n_threads(0) |
34 { |
34 { |
35 if (G1ConcRefine) { |
35 if (G1ConcRefine) { |
36 _n_threads = (G1ParallelRSetThreads > 0) ? G1ParallelRSetThreads : ParallelGCThreads; |
36 _n_threads = (int)thread_num(); |
37 if (_n_threads > 0) { |
37 if (_n_threads > 0) { |
38 _threads = NEW_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _n_threads); |
38 _threads = NEW_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _n_threads); |
|
39 int worker_id_offset = (int)DirtyCardQueueSet::num_par_ids(); |
39 ConcurrentG1RefineThread *next = NULL; |
40 ConcurrentG1RefineThread *next = NULL; |
40 for (int i = _n_threads - 1; i >= 0; i--) { |
41 for (int i = _n_threads - 1; i >= 0; i--) { |
41 ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, i); |
42 ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, worker_id_offset, i); |
42 assert(t != NULL, "Conc refine should have been created"); |
43 assert(t != NULL, "Conc refine should have been created"); |
43 assert(t->cg1r() == this, "Conc refine thread should refer to this"); |
44 assert(t->cg1r() == this, "Conc refine thread should refer to this"); |
44 _threads[i] = t; |
45 _threads[i] = t; |
45 next = t; |
46 next = t; |
46 } |
47 } |
47 } |
48 } |
48 } |
49 } |
|
50 } |
|
51 |
|
52 size_t ConcurrentG1Refine::thread_num() { |
|
53 if (G1ConcRefine) { |
|
54 return (G1ParallelRSetThreads > 0) ? G1ParallelRSetThreads : ParallelGCThreads; |
|
55 } |
|
56 return 0; |
49 } |
57 } |
50 |
58 |
51 void ConcurrentG1Refine::init() { |
59 void ConcurrentG1Refine::init() { |
52 if (G1ConcRSLogCacheSize > 0 || G1ConcRSCountTraversals) { |
60 if (G1ConcRSLogCacheSize > 0 || G1ConcRSCountTraversals) { |
53 G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
61 G1CollectedHeap* g1h = G1CollectedHeap::heap(); |