38 SharedHeap* SharedHeap::_sh; |
38 SharedHeap* SharedHeap::_sh; |
39 |
39 |
40 SharedHeap::SharedHeap(CollectorPolicy* policy_) : |
40 SharedHeap::SharedHeap(CollectorPolicy* policy_) : |
41 CollectedHeap(), |
41 CollectedHeap(), |
42 _collector_policy(policy_), |
42 _collector_policy(policy_), |
43 _strong_roots_parity(0), |
|
44 _workers(NULL) |
43 _workers(NULL) |
45 { |
44 { |
46 _sh = this; // ch is static, should be set only once. |
45 _sh = this; // ch is static, should be set only once. |
47 if (UseConcMarkSweepGC || UseG1GC) { |
46 if (UseConcMarkSweepGC || UseG1GC) { |
48 _workers = new FlexibleWorkGang("GC Thread", ParallelGCThreads, |
47 _workers = new FlexibleWorkGang("GC Thread", ParallelGCThreads, |
66 void SharedHeap::set_par_threads(uint t) { |
65 void SharedHeap::set_par_threads(uint t) { |
67 assert(t == 0 || !UseSerialGC, "Cannot have parallel threads"); |
66 assert(t == 0 || !UseSerialGC, "Cannot have parallel threads"); |
68 _n_par_threads = t; |
67 _n_par_threads = t; |
69 } |
68 } |
70 |
69 |
71 void SharedHeap::change_strong_roots_parity() { |
|
72 // Also set the new collection parity. |
|
73 assert(_strong_roots_parity >= 0 && _strong_roots_parity <= 2, |
|
74 "Not in range."); |
|
75 _strong_roots_parity++; |
|
76 if (_strong_roots_parity == 3) _strong_roots_parity = 1; |
|
77 assert(_strong_roots_parity >= 1 && _strong_roots_parity <= 2, |
|
78 "Not in range."); |
|
79 } |
|
80 |
|
81 SharedHeap::StrongRootsScope::StrongRootsScope(SharedHeap* heap, bool activate) |
70 SharedHeap::StrongRootsScope::StrongRootsScope(SharedHeap* heap, bool activate) |
82 : MarkScope(activate), _sh(heap) |
71 : MarkScope(activate), _sh(heap) |
83 { |
72 { |
84 if (_active) { |
73 if (_active) { |
85 _sh->change_strong_roots_parity(); |
74 Threads::change_thread_claim_parity(); |
86 // Zero the claimed high water mark in the StringTable |
75 // Zero the claimed high water mark in the StringTable |
87 StringTable::clear_parallel_claimed_index(); |
76 StringTable::clear_parallel_claimed_index(); |
88 } |
77 } |
|
78 } |
|
79 |
|
80 SharedHeap::StrongRootsScope::~StrongRootsScope() { |
|
81 Threads::assert_all_threads_claimed(); |
89 } |
82 } |
90 |
83 |
91 void SharedHeap::set_barrier_set(BarrierSet* bs) { |
84 void SharedHeap::set_barrier_set(BarrierSet* bs) { |
92 _barrier_set = bs; |
85 _barrier_set = bs; |
93 // Cached barrier set for fast access in oops |
86 // Cached barrier set for fast access in oops |