|
57 | 57 | #include "gc/shared/referenceProcessorPhaseTimes.hpp"
|
58 | 58 | #include "gc/shared/spaceDecorator.inline.hpp"
|
59 | 59 | #include "gc/shared/taskTerminator.hpp"
|
60 |
| -#include "gc/shared/weakProcessor.hpp" |
| 60 | +#include "gc/shared/weakProcessor.inline.hpp" |
61 | 61 | #include "gc/shared/workerPolicy.hpp"
|
62 | 62 | #include "gc/shared/workgroup.hpp"
|
63 | 63 | #include "logging/log.hpp"
|
@@ -780,7 +780,7 @@ bool ParallelCompactData::summarize(SplitInfo& split_info,
|
780 | 780 | return true;
|
781 | 781 | }
|
782 | 782 |
|
783 |
| -HeapWord* ParallelCompactData::calc_new_pointer(HeapWord* addr, ParCompactionManager* cm) { |
| 783 | +HeapWord* ParallelCompactData::calc_new_pointer(HeapWord* addr, ParCompactionManager* cm) const { |
784 | 784 | assert(addr != NULL, "Should detect NULL oop earlier");
|
785 | 785 | assert(ParallelScavengeHeap::heap()->is_in(addr), "not in heap");
|
786 | 786 | assert(PSParallelCompact::mark_bitmap()->is_marked(addr), "not marked");
|
@@ -1788,8 +1788,6 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
|
1788 | 1788 | ParCompactionManager::manager_array(ParallelScavengeHeap::heap()->workers().total_workers());
|
1789 | 1789 |
|
1790 | 1790 | {
|
1791 |
| - ResourceMark rm; |
1792 |
| - |
1793 | 1791 | const uint active_workers =
|
1794 | 1792 | WorkerPolicy::calc_active_workers(ParallelScavengeHeap::heap()->workers().total_workers(),
|
1795 | 1793 | ParallelScavengeHeap::heap()->workers().active_workers(),
|
@@ -1834,7 +1832,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
|
1834 | 1832 |
|
1835 | 1833 | // adjust_roots() updates Universe::_intArrayKlassObj which is
|
1836 | 1834 | // needed by the compaction for filling holes in the dense prefix.
|
1837 |
| - adjust_roots(vmthread_cm); |
| 1835 | + adjust_roots(); |
1838 | 1836 |
|
1839 | 1837 | compaction_start.update();
|
1840 | 1838 | compact();
|
@@ -2209,35 +2207,81 @@ void PSParallelCompact::marking_phase(ParCompactionManager* cm,
|
2209 | 2207 | _gc_tracer.report_object_count_after_gc(is_alive_closure());
|
2210 | 2208 | }
|
2211 | 2209 |
|
2212 |
| -void PSParallelCompact::adjust_roots(ParCompactionManager* cm) { |
2213 |
| - // Adjust the pointers to reflect the new locations |
2214 |
| - GCTraceTime(Info, gc, phases) tm("Adjust Roots", &_gc_timer); |
| 2210 | +class PSAdjustTask final : public AbstractGangTask { |
| 2211 | + SubTasksDone _sub_tasks; |
| 2212 | + WeakProcessor::Task _weak_proc_task; |
| 2213 | + OopStorageSetStrongParState<false, false> _oop_storage_iter; |
| 2214 | + uint _nworkers; |
2215 | 2215 |
|
2216 |
| - // Need new claim bits when tracing through and adjusting pointers. |
2217 |
| - ClassLoaderDataGraph::clear_claimed_marks(); |
| 2216 | + enum PSAdjustSubTask { |
| 2217 | + PSAdjustSubTask_code_cache, |
| 2218 | + PSAdjustSubTask_aot, |
| 2219 | + PSAdjustSubTask_old_ref_process, |
| 2220 | + PSAdjustSubTask_young_ref_process, |
2218 | 2221 |
|
2219 |
| - PCAdjustPointerClosure oop_closure(cm); |
| 2222 | + PSAdjustSubTask_num_elements |
| 2223 | + }; |
2220 | 2224 |
|
2221 |
| - // General strong roots. |
2222 |
| - Threads::oops_do(&oop_closure, NULL); |
2223 |
| - OopStorageSet::strong_oops_do(&oop_closure); |
2224 |
| - CLDToOopClosure cld_closure(&oop_closure, ClassLoaderData::_claim_strong); |
2225 |
| - ClassLoaderDataGraph::cld_do(&cld_closure); |
| 2225 | +public: |
| 2226 | + PSAdjustTask(uint nworkers) : |
| 2227 | + AbstractGangTask("PSAdjust task"), |
| 2228 | + _sub_tasks(PSAdjustSubTask_num_elements), |
| 2229 | + _weak_proc_task(nworkers), |
| 2230 | + _nworkers(nworkers) { |
| 2231 | + // Need new claim bits when tracing through and adjusting pointers. |
| 2232 | + ClassLoaderDataGraph::clear_claimed_marks(); |
| 2233 | + if (nworkers > 1) { |
| 2234 | + Threads::change_thread_claim_token(); |
| 2235 | + } |
| 2236 | + } |
2226 | 2237 |
|
2227 |
| - // Now adjust pointers in remaining weak roots. (All of which should |
2228 |
| - // have been cleared if they pointed to non-surviving objects.) |
2229 |
| - WeakProcessor::oops_do(&oop_closure); |
| 2238 | + ~PSAdjustTask() { |
| 2239 | + Threads::assert_all_threads_claimed(); |
| 2240 | + } |
2230 | 2241 |
|
2231 |
| - CodeBlobToOopClosure adjust_from_blobs(&oop_closure, CodeBlobToOopClosure::FixRelocations); |
2232 |
| - CodeCache::blobs_do(&adjust_from_blobs); |
2233 |
| - AOT_ONLY(AOTLoader::oops_do(&oop_closure);) |
| 2242 | + void work(uint worker_id) { |
| 2243 | + ParCompactionManager* cm = ParCompactionManager::gc_thread_compaction_manager(worker_id); |
| 2244 | + PCAdjustPointerClosure adjust(cm); |
| 2245 | + { |
| 2246 | + ResourceMark rm; |
| 2247 | + Threads::possibly_parallel_oops_do(_nworkers > 1, &adjust, nullptr); |
| 2248 | + } |
| 2249 | + _oop_storage_iter.oops_do(&adjust); |
| 2250 | + { |
| 2251 | + CLDToOopClosure cld_closure(&adjust, ClassLoaderData::_claim_strong); |
| 2252 | + ClassLoaderDataGraph::cld_do(&cld_closure); |
| 2253 | + } |
| 2254 | + { |
| 2255 | + AlwaysTrueClosure always_alive; |
| 2256 | + _weak_proc_task.work(worker_id, &always_alive, &adjust); |
| 2257 | + } |
| 2258 | + if (_sub_tasks.try_claim_task(PSAdjustSubTask_code_cache)) { |
| 2259 | + CodeBlobToOopClosure adjust_code(&adjust, CodeBlobToOopClosure::FixRelocations); |
| 2260 | + CodeCache::blobs_do(&adjust_code); |
| 2261 | + } |
| 2262 | + if (_sub_tasks.try_claim_task(PSAdjustSubTask_aot)) { |
| 2263 | + AOT_ONLY(AOTLoader::oops_do(&adjust);) |
| 2264 | + } |
| 2265 | + if (_sub_tasks.try_claim_task(PSAdjustSubTask_old_ref_process)) { |
| 2266 | + PSParallelCompact::ref_processor()->weak_oops_do(&adjust); |
| 2267 | + } |
| 2268 | + if (_sub_tasks.try_claim_task(PSAdjustSubTask_young_ref_process)) { |
| 2269 | + // Roots were visited so references into the young gen in roots |
| 2270 | + // may have been scanned. Process them also. |
| 2271 | + // Should the reference processor have a span that excludes |
| 2272 | + // young gen objects? |
| 2273 | + PSScavenge::reference_processor()->weak_oops_do(&adjust); |
| 2274 | + } |
| 2275 | + _sub_tasks.all_tasks_claimed(); |
| 2276 | + } |
| 2277 | +}; |
2234 | 2278 |
|
2235 |
| - ref_processor()->weak_oops_do(&oop_closure); |
2236 |
| - // Roots were visited so references into the young gen in roots |
2237 |
| - // may have been scanned. Process them also. |
2238 |
| - // Should the reference processor have a span that excludes |
2239 |
| - // young gen objects? |
2240 |
| - PSScavenge::reference_processor()->weak_oops_do(&oop_closure); |
| 2279 | +void PSParallelCompact::adjust_roots() { |
| 2280 | + // Adjust the pointers to reflect the new locations |
| 2281 | + GCTraceTime(Info, gc, phases) tm("Adjust Roots", &_gc_timer); |
| 2282 | + uint nworkers = ParallelScavengeHeap::heap()->workers().active_workers(); |
| 2283 | + PSAdjustTask task(nworkers); |
| 2284 | + ParallelScavengeHeap::heap()->workers().run_task(&task); |
2241 | 2285 | }
|
2242 | 2286 |
|
2243 | 2287 | // Helper class to print 8 region numbers per line and then print the total at the end.
|
@@ -2306,7 +2350,7 @@ void PSParallelCompact::prepare_region_draining_tasks(uint parallel_gc_threads)
|
2306 | 2350 |
|
2307 | 2351 | for (size_t cur = end_region - 1; cur + 1 > beg_region; --cur) {
|
2308 | 2352 | if (sd.region(cur)->claim_unsafe()) {
|
2309 |
| - ParCompactionManager* cm = ParCompactionManager::manager_array(worker_id); |
| 2353 | + ParCompactionManager* cm = ParCompactionManager::gc_thread_compaction_manager(worker_id); |
2310 | 2354 | bool result = sd.region(cur)->mark_normal();
|
2311 | 2355 | assert(result, "Must succeed at this point.");
|
2312 | 2356 | cm->region_stack()->push(cur);
|
@@ -2505,7 +2549,6 @@ static void compaction_with_stealing_work(TaskTerminator* terminator, uint worke
|
2505 | 2549 | // Go around again.
|
2506 | 2550 | }
|
2507 | 2551 | }
|
2508 |
| - return; |
2509 | 2552 | }
|
2510 | 2553 |
|
2511 | 2554 | class UpdateDensePrefixAndCompactionTask: public AbstractGangTask {
|
@@ -3133,7 +3176,7 @@ void PSParallelCompact::initialize_shadow_regions(uint parallel_gc_threads)
|
3133 | 3176 |
|
3134 | 3177 | size_t beg_region = sd.addr_to_region_idx(_space_info[old_space_id].dense_prefix());
|
3135 | 3178 | for (uint i = 0; i < parallel_gc_threads; i++) {
|
3136 |
| - ParCompactionManager *cm = ParCompactionManager::manager_array(i); |
| 3179 | + ParCompactionManager *cm = ParCompactionManager::gc_thread_compaction_manager(i); |
3137 | 3180 | cm->set_next_shadow_region(beg_region + i);
|
3138 | 3181 | }
|
3139 | 3182 | }
|
|
0 commit comments