--- old/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp 2016-04-01 13:46:20.348748957 -0700 +++ new/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp 2016-04-01 13:46:20.240748961 -0700 @@ -36,6 +36,7 @@ #include "utilities/defaultStream.hpp" #if INCLUDE_ALL_GCS +#include "gc/cms/concurrentMarkSweepGeneration.inline.hpp" #include "gc/g1/g1_globals.hpp" #include "gc/g1/heapRegionBounds.inline.hpp" #include "gc/shared/plab.hpp" @@ -472,6 +473,27 @@ } #endif return Flag::SUCCESS; +} + +Flag::Error CMSBitMapYieldQuantumConstraintFunc(size_t value, bool verbose) { +#if INCLUDE_ALL_GCS + // Skip for current default value. + if (UseConcMarkSweepGC && FLAG_IS_CMDLINE(CMSBitMapYieldQuantum)) { + // CMSBitMapYieldQuantum should be compared with mark bitmap size. + ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*)GenCollectedHeap::heap()->old_gen(); + size_t bitmap_size = cms->collector()->markBitMap()->sizeInWords(); + + if (value > bitmap_size) { + CommandLineError::print(verbose, + "CMSBitMapYieldQuantum (" SIZE_FORMAT ") must " + "be less than or equal to bitmap size (" SIZE_FORMAT ") " + "whose size corresponds to the size of old generation of the Java heap\n", + value, bitmap_size); + return Flag::VIOLATES_CONSTRAINT; + } + } +#endif + return Flag::SUCCESS; } Flag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose) { --- old/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp 2016-04-01 13:46:20.976748936 -0700 +++ new/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp 2016-04-01 13:46:20.880748939 -0700 @@ -63,6 +63,7 @@ Flag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose); Flag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose); Flag::Error CMSWorkQueueDrainThresholdConstraintFunc(uintx value, bool verbose); +Flag::Error CMSBitMapYieldQuantumConstraintFunc(size_t value, bool verbose); Flag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose); Flag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose); Flag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose); --- old/src/share/vm/runtime/globals.hpp 2016-04-01 13:46:21.568748915 -0700 +++ new/src/share/vm/runtime/globals.hpp 2016-04-01 13:46:21.460748919 -0700 @@ -1921,6 +1921,7 @@ "Bitmap operations should process at most this many bits " \ "between yields") \ range(1, max_uintx) \ + constraint(CMSBitMapYieldQuantumConstraintFunc,AfterMemoryInit) \ \ product(bool, CMSPrintChunksInDump, false, \ "If logging for the \"gc\" and \"promotion\" tags is enabled on" \ --- old/src/share/vm/utilities/bitMap.cpp 2016-04-01 13:46:22.272748890 -0700 +++ new/src/share/vm/utilities/bitMap.cpp 2016-04-01 13:46:22.152748895 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -163,8 +163,10 @@ idx_t beg_full_word = word_index_round_up(beg); idx_t end_full_word = word_index(end); - assert(end_full_word - beg_full_word >= 32, - "the range must include at least 32 bytes"); + if (end_full_word - beg_full_word < 32) { + clear_range(beg, end); + return; + } // The range includes at least one full word. clear_range_within_word(beg, bit_index(beg_full_word)); --- old/src/share/vm/utilities/bitMap.inline.hpp 2016-04-01 13:46:22.852748870 -0700 +++ new/src/share/vm/utilities/bitMap.inline.hpp 2016-04-01 13:46:22.744748874 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -93,7 +93,7 @@ } inline void BitMap::clear_range(idx_t beg, idx_t end, RangeSizeHint hint) { - if (hint == small_range && end - beg == 1) { + if (end - beg == 1) { clear_bit(beg); } else { if (hint == large_range) {