changeset 46565:8dcbf532ea00

8178490: Usages of is_object_aligned with pointers are broken Reviewed-by: tschatzl, kbarrett
author stefank
date Tue, 11 Apr 2017 23:45:37 +0200
parents 0ec329b23bbf
children 231c681fa946 4a430bd81cc6
files hotspot/src/share/vm/gc/parallel/asPSYoungGen.cpp hotspot/src/share/vm/gc/parallel/mutableSpace.cpp hotspot/src/share/vm/gc/parallel/psParallelCompact.inline.hpp hotspot/src/share/vm/gc/parallel/psPromotionLAB.hpp hotspot/src/share/vm/gc/parallel/psPromotionLAB.inline.hpp hotspot/src/share/vm/gc/parallel/psYoungGen.cpp hotspot/src/share/vm/utilities/globalDefinitions.hpp
diffstat 7 files changed, 18 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/share/vm/gc/parallel/asPSYoungGen.cpp	Thu Jun 22 09:07:47 2017 +0200
+++ b/hotspot/src/share/vm/gc/parallel/asPSYoungGen.cpp	Tue Apr 11 23:45:37 2017 +0200
@@ -419,9 +419,9 @@
             "from start moved to the right");
   guarantee((HeapWord*)from_end >= from_space()->top(),
             "from end moved into live data");
-  assert(is_object_aligned((intptr_t)eden_start), "checking alignment");
-  assert(is_object_aligned((intptr_t)from_start), "checking alignment");
-  assert(is_object_aligned((intptr_t)to_start), "checking alignment");
+  assert(is_ptr_object_aligned(eden_start), "checking alignment");
+  assert(is_ptr_object_aligned(from_start), "checking alignment");
+  assert(is_ptr_object_aligned(to_start), "checking alignment");
 
   MemRegion edenMR((HeapWord*)eden_start, (HeapWord*)eden_end);
   MemRegion toMR  ((HeapWord*)to_start,   (HeapWord*)to_end);
--- a/hotspot/src/share/vm/gc/parallel/mutableSpace.cpp	Thu Jun 22 09:07:47 2017 +0200
+++ b/hotspot/src/share/vm/gc/parallel/mutableSpace.cpp	Tue Apr 11 23:45:37 2017 +0200
@@ -177,7 +177,7 @@
   if (pointer_delta(end(), obj) >= size) {
     HeapWord* new_top = obj + size;
     set_top(new_top);
-    assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
+    assert(is_ptr_object_aligned(obj) && is_ptr_object_aligned(new_top),
            "checking alignment");
     return obj;
   } else {
@@ -198,7 +198,7 @@
       if (result != obj) {
         continue; // another thread beat us to the allocation, try again
       }
-      assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
+      assert(is_ptr_object_aligned(obj) && is_ptr_object_aligned(new_top),
              "checking alignment");
       return obj;
     } else {
--- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.inline.hpp	Thu Jun 22 09:07:47 2017 +0200
+++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.inline.hpp	Tue Apr 11 23:45:37 2017 +0200
@@ -88,7 +88,7 @@
 inline void PSParallelCompact::check_new_location(HeapWord* old_addr, HeapWord* new_addr) {
   assert(old_addr >= new_addr || space_id(old_addr) != space_id(new_addr),
          "must move left or to a different space");
-  assert(is_object_aligned((intptr_t)old_addr) && is_object_aligned((intptr_t)new_addr),
+  assert(is_ptr_object_aligned(old_addr) && is_ptr_object_aligned(new_addr),
          "checking alignment");
 }
 #endif // ASSERT
--- a/hotspot/src/share/vm/gc/parallel/psPromotionLAB.hpp	Thu Jun 22 09:07:47 2017 +0200
+++ b/hotspot/src/share/vm/gc/parallel/psPromotionLAB.hpp	Tue Apr 11 23:45:37 2017 +0200
@@ -122,7 +122,7 @@
     // The 'new_top>obj' check is needed to detect overflow of obj+size.
     if (new_top > obj && new_top <= end()) {
       set_top(new_top);
-      assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
+      assert(is_ptr_object_aligned(obj) && is_ptr_object_aligned(new_top),
              "checking alignment");
       _start_array->allocate_block(obj);
       return obj;
--- a/hotspot/src/share/vm/gc/parallel/psPromotionLAB.inline.hpp	Thu Jun 22 09:07:47 2017 +0200
+++ b/hotspot/src/share/vm/gc/parallel/psPromotionLAB.inline.hpp	Tue Apr 11 23:45:37 2017 +0200
@@ -40,7 +40,7 @@
   // The 'new_top>obj' check is needed to detect overflow of obj+size.
   if (new_top > obj && new_top <= end()) {
     set_top(new_top);
-    assert(is_ptr_aligned(obj, SurvivorAlignmentInBytes) && is_object_aligned((intptr_t)new_top),
+    assert(is_ptr_aligned(obj, SurvivorAlignmentInBytes) && is_ptr_object_aligned(new_top),
            "checking alignment");
     return obj;
   } else {
--- a/hotspot/src/share/vm/gc/parallel/psYoungGen.cpp	Thu Jun 22 09:07:47 2017 +0200
+++ b/hotspot/src/share/vm/gc/parallel/psYoungGen.cpp	Tue Apr 11 23:45:37 2017 +0200
@@ -193,9 +193,9 @@
   char *from_end   = from_start + survivor_size;
 
   assert(from_end == virtual_space()->high(), "just checking");
-  assert(is_object_aligned((intptr_t)eden_start), "checking alignment");
-  assert(is_object_aligned((intptr_t)to_start),   "checking alignment");
-  assert(is_object_aligned((intptr_t)from_start), "checking alignment");
+  assert(is_ptr_object_aligned(eden_start), "checking alignment");
+  assert(is_ptr_object_aligned(to_start),   "checking alignment");
+  assert(is_ptr_object_aligned(from_start), "checking alignment");
 
   MemRegion eden_mr((HeapWord*)eden_start, (HeapWord*)to_start);
   MemRegion to_mr  ((HeapWord*)to_start, (HeapWord*)from_start);
@@ -611,9 +611,9 @@
             "from start moved to the right");
   guarantee((HeapWord*)from_end >= from_space()->top(),
             "from end moved into live data");
-  assert(is_object_aligned((intptr_t)eden_start), "checking alignment");
-  assert(is_object_aligned((intptr_t)from_start), "checking alignment");
-  assert(is_object_aligned((intptr_t)to_start), "checking alignment");
+  assert(is_ptr_object_aligned(eden_start), "checking alignment");
+  assert(is_ptr_object_aligned(from_start), "checking alignment");
+  assert(is_ptr_object_aligned(to_start), "checking alignment");
 
   MemRegion edenMR((HeapWord*)eden_start, (HeapWord*)eden_end);
   MemRegion toMR  ((HeapWord*)to_start,   (HeapWord*)to_end);
--- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp	Thu Jun 22 09:07:47 2017 +0200
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp	Tue Apr 11 23:45:37 2017 +0200
@@ -556,6 +556,10 @@
   return addr == align_object_size(addr);
 }
 
+inline bool is_ptr_object_aligned(const void* addr) {
+  return is_ptr_aligned(addr, MinObjAlignmentInBytes);
+}
+
 // Pad out certain offsets to jlong alignment, in HeapWord units.
 
 inline intptr_t align_object_offset(intptr_t offset) {