aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/gc_implementation
diff options
context:
space:
mode:
authorysr <none@none>2009-03-13 13:56:01 -0700
committerysr <none@none>2009-03-13 13:56:01 -0700
commit524bae2e0a82f19b64354b3c48f0e6f7819d2237 (patch)
treea7662a36ba86b7e8e2225029c78547bfdce808f8 /src/share/vm/gc_implementation
parent88235323dd684d7834ccd5a1a4592f640c30dbc3 (diff)
downloadjdk8u_hotspot-524bae2e0a82f19b64354b3c48f0e6f7819d2237.tar.gz
6808322: ParNew, CMS, G1: ParGCAllocBuffer overflow
Summary: Correct the overflow check in ParGCAllocBuffer::allocate(); simplify ParGCAllocBuffer::undo_allocation(). Reviewed-by: apetrusenko, jcoomes, jmasa, minqi, phh, tonyp
Diffstat (limited to 'src/share/vm/gc_implementation')
-rw-r--r--src/share/vm/gc_implementation/parNew/parGCAllocBuffer.hpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/share/vm/gc_implementation/parNew/parGCAllocBuffer.hpp b/src/share/vm/gc_implementation/parNew/parGCAllocBuffer.hpp
index 89331a81b..dddb3bb7d 100644
--- a/src/share/vm/gc_implementation/parNew/parGCAllocBuffer.hpp
+++ b/src/share/vm/gc_implementation/parNew/parGCAllocBuffer.hpp
@@ -63,9 +63,8 @@ public:
// return NULL.
HeapWord* allocate(size_t word_sz) {
HeapWord* res = _top;
- HeapWord* new_top = _top + word_sz;
- if (new_top <= _end) {
- _top = new_top;
+ if (pointer_delta(_end, _top) >= word_sz) {
+ _top = _top + word_sz;
return res;
} else {
return NULL;
@@ -75,10 +74,9 @@ public:
// Undo the last allocation in the buffer, which is required to be of the
// "obj" of the given "word_sz".
void undo_allocation(HeapWord* obj, size_t word_sz) {
- assert(_top - word_sz >= _bottom
- && _top - word_sz == obj,
- "Bad undo_allocation");
- _top = _top - word_sz;
+ assert(pointer_delta(_top, _bottom) >= word_sz, "Bad undo");
+ assert(pointer_delta(_top, obj) == word_sz, "Bad undo");
+ _top = obj;
}
// The total (word) size of the buffer, including both allocated and