8031323: Optionally align objects copied to survivor spaces

Reviewed-by: brutisso, tschatzl
This commit is contained in:
Jon Masamitsu 2014-08-01 15:40:12 -07:00
parent a959c0971e
commit 5f2c33e42b
16 changed files with 201 additions and 25 deletions

View file

@ -28,6 +28,7 @@
#include "gc_implementation/shared/liveRange.hpp"
#include "gc_implementation/shared/markSweep.hpp"
#include "gc_implementation/shared/spaceDecorator.hpp"
#include "gc_interface/collectedHeap.inline.hpp"
#include "memory/blockOffsetTable.inline.hpp"
#include "memory/defNewGeneration.hpp"
#include "memory/genCollectedHeap.hpp"
@ -720,6 +721,27 @@ inline HeapWord* ContiguousSpace::par_allocate_impl(size_t size,
} while (true);
}
HeapWord* ContiguousSpace::allocate_aligned(size_t size) {
assert(Heap_lock->owned_by_self() || (SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread()), "not locked");
HeapWord* end_value = end();
HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end_value, SurvivorAlignmentInBytes);
if (obj == NULL) {
return NULL;
}
if (pointer_delta(end_value, obj) >= size) {
HeapWord* new_top = obj + size;
set_top(new_top);
assert(is_ptr_aligned(obj, SurvivorAlignmentInBytes) && is_aligned(new_top),
"checking alignment");
return obj;
} else {
set_top(obj);
return NULL;
}
}
// Requires locking.
HeapWord* ContiguousSpace::allocate(size_t size) {
return allocate_impl(size, end());