Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 4711:adedfbbf0360
7120038: G1: ParallelGCThreads==0 is broken
Summary: Running G1 with ParallelGCThreads==0 results in various crashes and asserts. Most of these are caused by unguarded references to the worker threads array or an incorrect number of active workers.
Reviewed-by: jmasa, tonyp
author | johnc |
---|---|
date | Fri, 16 Dec 2011 11:40:00 -0800 |
parents | 41406797186b |
children | 441e946dc1af |
comparison
equal
deleted
inserted
replaced
4710:41406797186b | 4711:adedfbbf0360 |
---|---|
3785 } | 3785 } |
3786 | 3786 |
3787 double end_time_sec = os::elapsedTime(); | 3787 double end_time_sec = os::elapsedTime(); |
3788 double pause_time_ms = (end_time_sec - start_time_sec) * MILLIUNITS; | 3788 double pause_time_ms = (end_time_sec - start_time_sec) * MILLIUNITS; |
3789 g1_policy()->record_pause_time_ms(pause_time_ms); | 3789 g1_policy()->record_pause_time_ms(pause_time_ms); |
3790 int active_gc_threads = workers()->active_workers(); | 3790 int active_workers = (G1CollectedHeap::use_parallel_gc_threads() ? |
3791 g1_policy()->record_collection_pause_end(active_gc_threads); | 3791 workers()->active_workers() : 1); |
3792 g1_policy()->record_collection_pause_end(active_workers); | |
3792 | 3793 |
3793 MemoryService::track_memory_usage(); | 3794 MemoryService::track_memory_usage(); |
3794 | 3795 |
3795 // In prepare_for_verify() below we'll need to scan the deferred | 3796 // In prepare_for_verify() below we'll need to scan the deferred |
3796 // update buffers to bring the RSets up-to-date if | 3797 // update buffers to bring the RSets up-to-date if |
5310 // object discovered by the STW ref processor. | 5311 // object discovered by the STW ref processor. |
5311 | 5312 |
5312 int active_workers = (G1CollectedHeap::use_parallel_gc_threads() ? | 5313 int active_workers = (G1CollectedHeap::use_parallel_gc_threads() ? |
5313 workers()->active_workers() : 1); | 5314 workers()->active_workers() : 1); |
5314 | 5315 |
5315 assert(active_workers == workers()->active_workers(), | 5316 assert(!G1CollectedHeap::use_parallel_gc_threads() || |
5316 "Need to reset active_workers"); | 5317 active_workers == workers()->active_workers(), |
5318 "Need to reset active_workers"); | |
5319 | |
5317 set_par_threads(active_workers); | 5320 set_par_threads(active_workers); |
5318 G1ParPreserveCMReferentsTask keep_cm_referents(this, active_workers, _task_queues); | 5321 G1ParPreserveCMReferentsTask keep_cm_referents(this, active_workers, _task_queues); |
5319 | 5322 |
5320 if (G1CollectedHeap::use_parallel_gc_threads()) { | 5323 if (G1CollectedHeap::use_parallel_gc_threads()) { |
5321 workers()->run_task(&keep_cm_referents); | 5324 workers()->run_task(&keep_cm_referents); |
5449 workers()->active_workers(), | 5452 workers()->active_workers(), |
5450 Threads::number_of_non_daemon_threads()); | 5453 Threads::number_of_non_daemon_threads()); |
5451 assert(UseDynamicNumberOfGCThreads || | 5454 assert(UseDynamicNumberOfGCThreads || |
5452 n_workers == workers()->total_workers(), | 5455 n_workers == workers()->total_workers(), |
5453 "If not dynamic should be using all the workers"); | 5456 "If not dynamic should be using all the workers"); |
5457 workers()->set_active_workers(n_workers); | |
5454 set_par_threads(n_workers); | 5458 set_par_threads(n_workers); |
5455 } else { | 5459 } else { |
5456 assert(n_par_threads() == 0, | 5460 assert(n_par_threads() == 0, |
5457 "Should be the original non-parallel value"); | 5461 "Should be the original non-parallel value"); |
5458 n_workers = 1; | 5462 n_workers = 1; |
5459 } | 5463 } |
5460 workers()->set_active_workers(n_workers); | |
5461 | 5464 |
5462 G1ParTask g1_par_task(this, _task_queues); | 5465 G1ParTask g1_par_task(this, _task_queues); |
5463 | 5466 |
5464 init_for_evac_failure(NULL); | 5467 init_for_evac_failure(NULL); |
5465 | 5468 |
5477 workers()->active_workers() == workers()->total_workers(), | 5480 workers()->active_workers() == workers()->total_workers(), |
5478 "If not dynamic should be using all the workers"); | 5481 "If not dynamic should be using all the workers"); |
5479 workers()->run_task(&g1_par_task); | 5482 workers()->run_task(&g1_par_task); |
5480 } else { | 5483 } else { |
5481 StrongRootsScope srs(this); | 5484 StrongRootsScope srs(this); |
5485 g1_par_task.set_for_termination(n_workers); | |
5482 g1_par_task.work(0); | 5486 g1_par_task.work(0); |
5483 } | 5487 } |
5484 | 5488 |
5485 double par_time = (os::elapsedTime() - start_par) * 1000.0; | 5489 double par_time = (os::elapsedTime() - start_par) * 1000.0; |
5486 g1_policy()->record_par_time(par_time); | 5490 g1_policy()->record_par_time(par_time); |
5725 | 5729 |
5726 { | 5730 { |
5727 // Iterate over the dirty cards region list. | 5731 // Iterate over the dirty cards region list. |
5728 G1ParCleanupCTTask cleanup_task(ct_bs, this); | 5732 G1ParCleanupCTTask cleanup_task(ct_bs, this); |
5729 | 5733 |
5730 if (ParallelGCThreads > 0) { | 5734 if (G1CollectedHeap::use_parallel_gc_threads()) { |
5731 set_par_threads(workers()->total_workers()); | 5735 set_par_threads(); |
5732 workers()->run_task(&cleanup_task); | 5736 workers()->run_task(&cleanup_task); |
5733 set_par_threads(0); | 5737 set_par_threads(0); |
5734 } else { | 5738 } else { |
5735 while (_dirty_cards_region_list) { | 5739 while (_dirty_cards_region_list) { |
5736 HeapRegion* r = _dirty_cards_region_list; | 5740 HeapRegion* r = _dirty_cards_region_list; |
6134 } | 6138 } |
6135 | 6139 |
6136 void G1CollectedHeap::set_par_threads() { | 6140 void G1CollectedHeap::set_par_threads() { |
6137 // Don't change the number of workers. Use the value previously set | 6141 // Don't change the number of workers. Use the value previously set |
6138 // in the workgroup. | 6142 // in the workgroup. |
6143 assert(G1CollectedHeap::use_parallel_gc_threads(), "shouldn't be here otherwise"); | |
6139 int n_workers = workers()->active_workers(); | 6144 int n_workers = workers()->active_workers(); |
6140 assert(UseDynamicNumberOfGCThreads || | 6145 assert(UseDynamicNumberOfGCThreads || |
6141 n_workers == workers()->total_workers(), | 6146 n_workers == workers()->total_workers(), |
6142 "Otherwise should be using the total number of workers"); | 6147 "Otherwise should be using the total number of workers"); |
6143 if (n_workers == 0) { | 6148 if (n_workers == 0) { |
6144 assert(false, "Should have been set in prior evacuation pause."); | 6149 assert(false, "Should have been set in prior evacuation pause."); |
6145 n_workers = ParallelGCThreads; | 6150 n_workers = ParallelGCThreads; |