hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp
changeset 37233 e8e674469545
parent 37157 2a0fdb3e2a19
child 37234 07d212151499
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp	Fri Apr 01 16:15:37 2016 +0300
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp	Fri Apr 01 09:43:13 2016 -0700
@@ -382,6 +382,39 @@
   return Flag::SUCCESS;
 }
 
+Flag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose) {
+#if INCLUDE_ALL_GCS
+  if (UseConcMarkSweepGC) {
+    // ParGCCardsPerStrideChunk should be compared with card table size.
+    size_t heap_size = Universe::heap()->reserved_region().word_size();
+    CardTableModRefBS* bs = (CardTableModRefBS*)GenCollectedHeap::heap()->rem_set()->bs();
+    size_t card_table_size = bs->cards_required(heap_size) - 1; // Valid card table size
+
+    if ((size_t)value > card_table_size) {
+      CommandLineError::print(verbose,
+                              "ParGCCardsPerStrideChunk (" INTX_FORMAT ") is too large for the heap size and "
+                              "must be less than or equal to card table size (" SIZE_FORMAT ")\n",
+                              value, card_table_size);
+      return Flag::VIOLATES_CONSTRAINT;
+    }
+
+    // ParGCCardsPerStrideChunk is used with n_strides(ParallelGCThreads*ParGCStridesPerThread)
+    // from CardTableModRefBSForCTRS::process_stride(). Note that ParGCStridesPerThread is already checked
+    // not to make an overflow with ParallelGCThreads from its constraint function.
+    uintx n_strides = ParallelGCThreads * ParGCStridesPerThread;
+    uintx ergo_max = max_uintx / n_strides;
+    if ((uintx)value > ergo_max) {
+      CommandLineError::print(verbose,
+                              "ParGCCardsPerStrideChunk (" INTX_FORMAT ") must be "
+                              "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n",
+                              value, ergo_max);
+      return Flag::VIOLATES_CONSTRAINT;
+    }
+  }
+#endif
+  return Flag::SUCCESS;
+}
+
 Flag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose) {
   Flag::Error status = Flag::SUCCESS;