--- old/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp 2016-03-28 09:56:11.061268641 -0700 +++ new/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp 2016-03-28 09:56:10.957268645 -0700 @@ -382,6 +382,39 @@ return Flag::SUCCESS; } +Flag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose) { +#if INCLUDE_ALL_GCS + if (UseConcMarkSweepGC) { + // ParGCCardsPerStrideChunk shoule be compared with card table size. + // As CardTableModRefBS::_last_valid_index is 'protected', calculate it in a same way. + size_t heap_size = Universe::heap()->reserved_region().word_size(); + size_t card_table_size = align_size_up(heap_size, CardTableModRefBS::card_size_in_words); + card_table_size /= (CardTableModRefBS::card_size_in_words + 1); + card_table_size -= 1; + + if ((size_t)value > card_table_size) { + CommandLineError::print(verbose, + "ParGCCardsPerStrideChunk (" INTX_FORMAT ") must be " + "less than or equal to card table size (" SIZE_FORMAT ")\n", + value, card_table_size); + return Flag::VIOLATES_CONSTRAINT; + } + + // If n_strides which is used with ParGCCardsPerStrideChunk is really large, we would face an overflow. + 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;