mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 19:44:41 +02:00
6808322: ParNew, CMS, G1: ParGCAllocBuffer overflow
Correct the overflow check in ParGCAllocBuffer::allocate(); simplify ParGCAllocBuffer::undo_allocation(). Reviewed-by: apetrusenko, jcoomes, jmasa, minqi, phh, tonyp
This commit is contained in:
parent
1e875ce562
commit
a45005f646
1 changed files with 5 additions and 7 deletions
|
@ -63,9 +63,8 @@ public:
|
||||||
// return NULL.
|
// return NULL.
|
||||||
HeapWord* allocate(size_t word_sz) {
|
HeapWord* allocate(size_t word_sz) {
|
||||||
HeapWord* res = _top;
|
HeapWord* res = _top;
|
||||||
HeapWord* new_top = _top + word_sz;
|
if (pointer_delta(_end, _top) >= word_sz) {
|
||||||
if (new_top <= _end) {
|
_top = _top + word_sz;
|
||||||
_top = new_top;
|
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -75,10 +74,9 @@ public:
|
||||||
// Undo the last allocation in the buffer, which is required to be of the
|
// Undo the last allocation in the buffer, which is required to be of the
|
||||||
// "obj" of the given "word_sz".
|
// "obj" of the given "word_sz".
|
||||||
void undo_allocation(HeapWord* obj, size_t word_sz) {
|
void undo_allocation(HeapWord* obj, size_t word_sz) {
|
||||||
assert(_top - word_sz >= _bottom
|
assert(pointer_delta(_top, _bottom) >= word_sz, "Bad undo");
|
||||||
&& _top - word_sz == obj,
|
assert(pointer_delta(_top, obj) == word_sz, "Bad undo");
|
||||||
"Bad undo_allocation");
|
_top = obj;
|
||||||
_top = _top - word_sz;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The total (word) size of the buffer, including both allocated and
|
// The total (word) size of the buffer, including both allocated and
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue