@@ -1784,8 +1784,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
1784
1784
const PreGenGCValues pre_gc_values = heap->get_pre_gc_values ();
1785
1785
1786
1786
// Get the compaction manager reserved for the VM thread.
1787
- ParCompactionManager* const vmthread_cm =
1788
- ParCompactionManager::manager_array (ParallelScavengeHeap::heap ()->workers ().total_workers ());
1787
+ ParCompactionManager* const vmthread_cm = ParCompactionManager::get_vmthread_cm ();
1789
1788
1790
1789
{
1791
1790
const uint active_workers =
@@ -1837,6 +1836,8 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
1837
1836
compaction_start.update ();
1838
1837
compact ();
1839
1838
1839
+ ParCompactionManager::verify_all_region_stack_empty ();
1840
+
1840
1841
// Reset the mark bitmap, summary data, and do other bookkeeping. Must be
1841
1842
// done before resizing.
1842
1843
post_compact ();
@@ -1933,15 +1934,6 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
1933
1934
heap->post_full_gc_dump (&_gc_timer);
1934
1935
}
1935
1936
1936
- #ifdef ASSERT
1937
- for (size_t i = 0 ; i < ParallelGCThreads + 1 ; ++i) {
1938
- ParCompactionManager* const cm =
1939
- ParCompactionManager::manager_array (int (i));
1940
- assert (cm->marking_stack ()->is_empty (), " should be empty" );
1941
- assert (cm->region_stack ()->is_empty (), " Region stack " SIZE_FORMAT " is not empty" , i);
1942
- }
1943
- #endif // ASSERT
1944
-
1945
1937
if (VerifyAfterGC && heap->total_collections () >= VerifyGCStartAt) {
1946
1938
Universe::verify (" After GC" );
1947
1939
}
@@ -2181,7 +2173,7 @@ void PSParallelCompact::marking_phase(ParCompactionManager* cm,
2181
2173
}
2182
2174
2183
2175
// This is the point where the entire marking should have completed.
2184
- assert (cm-> marking_stacks_empty (), " Marking should have completed " );
2176
+ ParCompactionManager::verify_all_marking_stack_empty ( );
2185
2177
2186
2178
{
2187
2179
GCTraceTime (Debug, gc, phases) tm (" Weak Processing" , &_gc_timer);
@@ -2207,6 +2199,19 @@ void PSParallelCompact::marking_phase(ParCompactionManager* cm,
2207
2199
_gc_tracer.report_object_count_after_gc (is_alive_closure ());
2208
2200
}
2209
2201
2202
+ #ifdef ASSERT
2203
+ void PCAdjustPointerClosure::verify_cm (ParCompactionManager* cm) {
2204
+ assert (cm != NULL , " associate ParCompactionManage should not be NULL" );
2205
+ auto vmthread_cm = ParCompactionManager::get_vmthread_cm ();
2206
+ if (Thread::current ()->is_VM_thread ()) {
2207
+ assert (cm == vmthread_cm, " VM threads should use ParCompactionManager from get_vmthread_cm()" );
2208
+ } else {
2209
+ assert (Thread::current ()->is_GC_task_thread (), " Must be a GC thread" );
2210
+ assert (cm != vmthread_cm, " GC threads should use ParCompactionManager from gc_thread_compaction_manager()" );
2211
+ }
2212
+ }
2213
+ #endif
2214
+
2210
2215
class PSAdjustTask final : public AbstractGangTask {
2211
2216
SubTasksDone _sub_tasks;
2212
2217
WeakProcessor::Task _weak_proc_task;
@@ -2614,9 +2619,11 @@ void PSParallelCompact::compact() {
2614
2619
}
2615
2620
2616
2621
{
2617
- // Update the deferred objects, if any. Any compaction manager can be used.
2618
2622
GCTraceTime (Trace, gc, phases) tm (" Deferred Updates" , &_gc_timer);
2619
- ParCompactionManager* cm = ParCompactionManager::manager_array (0 );
2623
+ // Update the deferred objects, if any. In principle, any compaction
2624
+ // manager can be used. However, since the current thread is VM thread, we
2625
+ // use the rightful one to keep the verification logic happy.
2626
+ ParCompactionManager* cm = ParCompactionManager::get_vmthread_cm ();
2620
2627
for (unsigned int id = old_space_id; id < last_space_id; ++id) {
2621
2628
update_deferred_objects (cm, SpaceId (id));
2622
2629
}
0 commit comments