6833576: G1: assert illegal index, growableArray.hpp:186
authorjohnc
Tue, 05 May 2009 22:15:35 -0700
changeset 2742 5e88fa844ba0
parent 2741 34e2a243d69a
child 2743 c8d0d639daaf
6833576: G1: assert illegal index, growableArray.hpp:186 Summary: The code that calculates the heap region index for an object address incorrectly used signed arithmetic. Reviewed-by: jcoomes, ysr
hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp	Thu Apr 30 15:07:53 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp	Tue May 05 22:15:35 2009 -0700
@@ -37,8 +37,9 @@
 inline HeapRegion*
 G1CollectedHeap::heap_region_containing_raw(const void* addr) const {
   assert(_g1_reserved.contains(addr), "invariant");
-  size_t index = ((intptr_t) addr - (intptr_t) _g1_reserved.start())
-                                              >> HeapRegion::LogOfHRGrainBytes;
+  size_t index = pointer_delta(addr, _g1_reserved.start(), 1)
+                                        >> HeapRegion::LogOfHRGrainBytes;
+
   HeapRegion* res = _hrs->at(index);
   assert(res == _hrs->addr_to_region(addr), "sanity");
   return res;