8139768: Running with -XX:CMSOldPLABNumRefills=2147483648 causes EXCEPTION_INT_DIVIDE_BY_ZERO on Windows i586
Summary: Use double arithmetic to avoid integer overflow
Reviewed-by: jwilhelm, tbenson
--- a/hotspot/src/share/vm/gc/cms/compactibleFreeListSpace.cpp Mon Dec 07 17:16:13 2015 +0000
+++ b/hotspot/src/share/vm/gc/cms/compactibleFreeListSpace.cpp Mon Dec 14 17:06:06 2015 -0500
@@ -2517,7 +2517,11 @@
// Lacking sufficient experience, CMSOldPLABResizeQuicker is disabled by
// default.
if (ResizeOldPLAB && CMSOldPLABResizeQuicker) {
- size_t multiple = _num_blocks[word_sz]/(CMSOldPLABToleranceFactor*CMSOldPLABNumRefills*n_blks);
+ //
+ // On a 32-bit VM, the denominator can become zero because of integer overflow,
+ // which is why there is a cast to double.
+ //
+ size_t multiple = (size_t) (_num_blocks[word_sz]/(((double)CMSOldPLABToleranceFactor)*CMSOldPLABNumRefills*n_blks));
n_blks += CMSOldPLABReactivityFactor*multiple*n_blks;
n_blks = MIN2(n_blks, CMSOldPLABMax);
}