--- old/src/share/vm/gc/shared/cardTableModRefBS.hpp 2016-03-29 11:56:35.286007330 -0700 +++ new/src/share/vm/gc/shared/cardTableModRefBS.hpp 2016-03-29 11:56:35.154007334 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,14 +89,6 @@ MemRegion _guard_region; protected: - // Initialization utilities; covered_words is the size of the covered region - // in, um, words. - inline size_t cards_required(size_t covered_words) { - // Add one for a guard card, used to detect errors. - const size_t words = align_size_up(covered_words, card_size_in_words); - return words / card_size_in_words + 1; - } - inline size_t compute_byte_map_size(); // Finds and return the index of the region, if any, to which the given @@ -172,6 +164,14 @@ bool has_write_ref_pre_barrier() { return false; } + // Initialization utilities; covered_words is the size of the covered region + // in, um, words. + inline size_t cards_required(size_t covered_words) { + // Add one for a guard card, used to detect errors. + const size_t words = align_size_up(covered_words, card_size_in_words); + return words / card_size_in_words + 1; + } + protected: CardTableModRefBS(MemRegion whole_heap, const BarrierSet::FakeRtti& fake_rtti); --- old/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp 2016-03-29 11:56:35.802007312 -0700 +++ new/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp 2016-03-29 11:56:35.658007317 -0700 @@ -386,21 +386,21 @@ #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; + 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 ") must be " - "less than or equal to card table size (" SIZE_FORMAT ")\n", + "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; } - // If n_strides which is used with ParGCCardsPerStrideChunk is really large, we would face an overflow. + // ParGCCardsPerStrideChunk is used with n_strides(ParallelGCThreads*ParGCStridesPerThread) + // from CardTableModRefBSForCTRS::process_stride(). However, 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) {