8184753: Asserts against MinObjectAlignment should avoid integer division
authorshade
Tue, 18 Jul 2017 10:20:52 +0200
changeset 46683 33808f7eadd5
parent 46682 b646732e1473
child 46684 a8121315a5b9
8184753: Asserts against MinObjectAlignment should avoid integer division Summary: Delegate to is_object_aligned that does the right thing Reviewed-by: mgerdin, tschatzl
hotspot/src/share/vm/gc/cms/compactibleFreeListSpace.cpp
hotspot/src/share/vm/gc/shared/collectedHeap.cpp
hotspot/src/share/vm/oops/oop.inline.hpp
--- a/hotspot/src/share/vm/gc/cms/compactibleFreeListSpace.cpp	Tue Jul 18 09:53:54 2017 +0200
+++ b/hotspot/src/share/vm/gc/cms/compactibleFreeListSpace.cpp	Tue Jul 18 10:20:52 2017 +0200
@@ -1202,7 +1202,7 @@
 
   size_t i;
   size_t currSize = numWords + MinChunkSize;
-  assert(currSize % MinObjAlignment == 0, "currSize should be aligned");
+  assert(is_object_aligned(currSize), "currSize should be aligned");
   for (i = currSize; i < IndexSetSize; i += IndexSetStride) {
     AdaptiveFreeList<FreeChunk>* fl = &_indexedFreeList[i];
     if (fl->head()) {
@@ -1733,7 +1733,7 @@
     AdaptiveFreeList<FreeChunk>* it   = _indexedFreeList;
     size_t    hint = _indexedFreeList[start].hint();
     while (hint < IndexSetSize) {
-      assert(hint % MinObjAlignment == 0, "hint should be aligned");
+      assert(is_object_aligned(hint), "hint should be aligned");
       AdaptiveFreeList<FreeChunk> *fl = &_indexedFreeList[hint];
       if (fl->surplus() > 0 && fl->head() != NULL) {
         // Found a list with surplus, reset original hint
--- a/hotspot/src/share/vm/gc/shared/collectedHeap.cpp	Tue Jul 18 09:53:54 2017 +0200
+++ b/hotspot/src/share/vm/gc/shared/collectedHeap.cpp	Tue Jul 18 10:20:52 2017 +0200
@@ -457,7 +457,7 @@
 void CollectedHeap::fill_args_check(HeapWord* start, size_t words)
 {
   assert(words >= min_fill_size(), "too small to fill");
-  assert(words % MinObjAlignment == 0, "unaligned size");
+  assert(is_object_aligned(words), "unaligned size");
   assert(Universe::heap()->is_in_reserved(start), "not in heap");
   assert(Universe::heap()->is_in_reserved(start + words - 1), "not in heap");
 }
--- a/hotspot/src/share/vm/oops/oop.inline.hpp	Tue Jul 18 09:53:54 2017 +0200
+++ b/hotspot/src/share/vm/oops/oop.inline.hpp	Tue Jul 18 10:20:52 2017 +0200
@@ -268,8 +268,8 @@
     }
   }
 
-  assert(s % MinObjAlignment == 0, "Oop size is not properly aligned: %d", s);
   assert(s > 0, "Oop size must be greater than zero, not %d", s);
+  assert(is_object_aligned(s), "Oop size is not properly aligned: %d", s);
   return s;
 }