hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp
changeset 41683 cd5d2527e163
parent 41682 b63330180476
child 42650 1f304d0c888b
--- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp	Wed Oct 21 15:18:30 2015 +0200
+++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp	Wed Oct 05 13:35:57 2016 +0200
@@ -613,16 +613,6 @@
     SystemDictionary::roots_oops_do(strong_roots, weak_roots);
   }
 
-  // All threads execute the following. A specific chunk of buckets
-  // from the StringTable are the individual tasks.
-  if (weak_roots != NULL) {
-    if (is_par) {
-      StringTable::possibly_parallel_oops_do(weak_roots);
-    } else {
-      StringTable::oops_do(weak_roots);
-    }
-  }
-
   if (!_process_strong_tasks->is_task_claimed(GCH_PS_CodeCache_oops_do)) {
     if (so & SO_ScavengeCodeCache) {
       assert(code_roots != NULL, "must supply closure for code cache");
@@ -644,6 +634,18 @@
   }
 }
 
+void GenCollectedHeap::process_string_table_roots(StrongRootsScope* scope,
+                                                  OopClosure* root_closure) {
+  assert(root_closure != NULL, "Must be set");
+  // All threads execute the following. A specific chunk of buckets
+  // from the StringTable are the individual tasks.
+  if (scope->n_threads() > 1) {
+    StringTable::possibly_parallel_oops_do(root_closure);
+  } else {
+    StringTable::oops_do(root_closure);
+  }
+}
+
 void GenCollectedHeap::young_process_roots(StrongRootsScope* scope,
                                            OopsInGenClosure* root_closure,
                                            OopsInGenClosure* old_gen_closure,
@@ -652,6 +654,7 @@
 
   process_roots(scope, SO_ScavengeCodeCache, root_closure, root_closure,
                 cld_closure, cld_closure, &mark_code_closure);
+  process_string_table_roots(scope, root_closure);
 
   if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
     root_closure->reset_generation();
@@ -666,19 +669,20 @@
   _process_strong_tasks->all_tasks_completed(scope->n_threads());
 }
 
-void GenCollectedHeap::old_process_roots(StrongRootsScope* scope,
+void GenCollectedHeap::cms_process_roots(StrongRootsScope* scope,
                                          bool young_gen_as_roots,
                                          ScanningOption so,
                                          bool only_strong_roots,
                                          OopsInGenClosure* root_closure,
                                          CLDClosure* cld_closure) {
-  const bool is_moving_collection = !only_strong_roots && !young_gen_as_roots;
-
-  MarkingCodeBlobClosure mark_code_closure(root_closure, is_moving_collection);
+  MarkingCodeBlobClosure mark_code_closure(root_closure, !CodeBlobToOopClosure::FixRelocations);
   OopsInGenClosure* weak_roots = only_strong_roots ? NULL : root_closure;
   CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
 
   process_roots(scope, so, root_closure, weak_roots, cld_closure, weak_cld_closure, &mark_code_closure);
+  if (!only_strong_roots) {
+    process_string_table_roots(scope, root_closure);
+  }
 
   if (young_gen_as_roots &&
       !_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
@@ -690,6 +694,27 @@
   _process_strong_tasks->all_tasks_completed(scope->n_threads());
 }
 
+void GenCollectedHeap::full_process_roots(StrongRootsScope* scope,
+                                          bool is_adjust_phase,
+                                          ScanningOption so,
+                                          bool only_strong_roots,
+                                          OopsInGenClosure* root_closure,
+                                          CLDClosure* cld_closure) {
+  MarkingCodeBlobClosure mark_code_closure(root_closure, is_adjust_phase);
+  OopsInGenClosure* weak_roots = only_strong_roots ? NULL : root_closure;
+  CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
+
+  process_roots(scope, so, root_closure, weak_roots, cld_closure, weak_cld_closure, &mark_code_closure);
+  if (is_adjust_phase) {
+    // We never treat the string table as roots during marking
+    // for the full gc, so we only need to process it during
+    // the adjust phase.
+    process_string_table_roots(scope, root_closure);
+  }
+
+  _process_strong_tasks->all_tasks_completed(scope->n_threads());
+}
+
 void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) {
   JNIHandles::weak_oops_do(root_closure);
   _young_gen->ref_processor()->weak_oops_do(root_closure);