8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
authorsangheki
Tue, 05 Apr 2016 16:15:53 -0700
changeset 37264 d9b0f2b53b73
parent 37262 e7b7bc691d7d
child 37265 ff874750de46
8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range Summary: Let BitMap::clear_large_range call clear_range instead of firing an assert Reviewed-by: jmasa, jwilhelm
hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp
hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp
hotspot/src/share/vm/runtime/globals.hpp
hotspot/src/share/vm/utilities/bitMap.cpp
hotspot/src/share/vm/utilities/bitMap.inline.hpp
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp	Tue Apr 05 11:17:50 2016 -0400
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp	Tue Apr 05 16:15:53 2016 -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"
@@ -507,6 +508,27 @@
   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) {
 #if INCLUDE_ALL_GCS
   if (UseG1GC && FLAG_IS_CMDLINE(MaxGCPauseMillis) && (value >= GCPauseIntervalMillis)) {
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp	Tue Apr 05 11:17:50 2016 -0400
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp	Tue Apr 05 16:15:53 2016 -0700
@@ -64,6 +64,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);
--- a/hotspot/src/share/vm/runtime/globals.hpp	Tue Apr 05 11:17:50 2016 -0400
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Tue Apr 05 16:15:53 2016 -0700
@@ -1927,6 +1927,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"  \
--- a/hotspot/src/share/vm/utilities/bitMap.cpp	Tue Apr 05 11:17:50 2016 -0400
+++ b/hotspot/src/share/vm/utilities/bitMap.cpp	Tue Apr 05 16:15:53 2016 -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));
--- a/hotspot/src/share/vm/utilities/bitMap.inline.hpp	Tue Apr 05 11:17:50 2016 -0400
+++ b/hotspot/src/share/vm/utilities/bitMap.inline.hpp	Tue Apr 05 16:15:53 2016 -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) {