changeset 9008:cfe3264deba4

8225716: G1 GC: Undefined behaviour in G1BlockOffsetTablePart::block_at_or_preceding Reviewed-by: kbarrett, tschatzl
author aph
date Wed, 19 Jun 2019 16:36:26 +0100
parents 17778f8991c8
children 75f4e02f1113
files src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp
diffstat 3 files changed, 7 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp	Wed Jun 05 05:15:56 2019 +0100
+++ b/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp	Wed Jun 19 16:36:26 2019 +0100
@@ -447,8 +447,6 @@
 }
 
 HeapWord* G1BlockOffsetArrayContigSpace::initialize_threshold_raw() {
-  assert(!Universe::heap()->is_in_reserved(_array->_offset_array),
-         "just checking");
   _next_offset_index = _array->index_for_raw(_bottom);
   _next_offset_index++;
   _next_offset_threshold =
@@ -457,8 +455,6 @@
 }
 
 void G1BlockOffsetArrayContigSpace::zero_bottom_entry_raw() {
-  assert(!Universe::heap()->is_in_reserved(_array->_offset_array),
-         "just checking");
   size_t bottom_index = _array->index_for_raw(_bottom);
   assert(_array->address_for_index_raw(bottom_index) == _bottom,
          "Precondition of call");
@@ -466,8 +462,6 @@
 }
 
 HeapWord* G1BlockOffsetArrayContigSpace::initialize_threshold() {
-  assert(!Universe::heap()->is_in_reserved(_array->_offset_array),
-         "just checking");
   _next_offset_index = _array->index_for(_bottom);
   _next_offset_index++;
   _next_offset_threshold =
--- a/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp	Wed Jun 05 05:15:56 2019 +0100
+++ b/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp	Wed Jun 19 16:36:26 2019 +0100
@@ -145,7 +145,7 @@
 
   // Array for keeping offsets for retrieving object start fast given an
   // address.
-  u_char* _offset_array;          // byte array keeping backwards offsets
+  volatile u_char* _offset_array;          // byte array keeping backwards offsets
 
   void check_offset(size_t offset, const char* msg) const {
     assert(offset <= N_words,
@@ -158,9 +158,7 @@
   // For performance these have to devolve to array accesses in product builds.
   inline u_char offset_array(size_t index) const;
 
-  void set_offset_array_raw(size_t index, u_char offset) {
-    _offset_array[index] = offset;
-  }
+  inline void set_offset_array_raw(size_t index, u_char offset);
 
   inline void set_offset_array(size_t index, u_char offset);
 
--- a/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp	Wed Jun 05 05:15:56 2019 +0100
+++ b/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp	Wed Jun 19 16:36:26 2019 +0100
@@ -63,6 +63,10 @@
   return _offset_array[index];
 }
 
+inline void G1BlockOffsetSharedArray::set_offset_array_raw(size_t index, u_char offset) {
+  _offset_array[index] = offset;
+}
+
 void G1BlockOffsetSharedArray::set_offset_array(size_t index, u_char offset) {
   check_index(index, "index out of range");
   set_offset_array_raw(index, offset);
@@ -81,7 +85,7 @@
   assert(left <= right, "indexes out of order");
   size_t num_cards = right - left + 1;
   if (UseMemSetInBOT) {
-    memset(&_offset_array[left], offset, num_cards);
+    memset(const_cast<u_char*> (&_offset_array[left]), offset, num_cards);
   } else {
     size_t i = left;
     const size_t end = i + num_cards;