7023069: G1: Introduce symmetric locking in the slow allocation path

7023151: G1: refactor the code that operates on _cur_alloc_region to be re-used for allocs by the GC threads
7018286: G1: humongous allocation attempts should take the GC locker into account

First, this change replaces the asymmetric locking scheme in the G1 slow alloc path by a summetric one. Second, it factors out the code that operates on _cur_alloc_region so that it can be re-used for allocations by the GC threads in the future.

Reviewed-by: stefank, brutisso, johnc
This commit is contained in:
Antonios Printezis 2011-03-30 10:26:59 -04:00
parent 349d820dd1
commit 3e9fe24ddd
11 changed files with 920 additions and 747 deletions

View file

@ -818,9 +818,14 @@ size_t ContiguousSpace::block_size(const HeapWord* p) const {
// This version requires locking.
inline HeapWord* ContiguousSpace::allocate_impl(size_t size,
HeapWord* const end_value) {
// In G1 there are places where a GC worker can allocates into a
// region using this serial allocation code without being prone to a
// race with other GC workers (we ensure that no other GC worker can
// access the same region at the same time). So the assert below is
// too strong in the case of G1.
assert(Heap_lock->owned_by_self() ||
(SafepointSynchronize::is_at_safepoint() &&
Thread::current()->is_VM_thread()),
(Thread::current()->is_VM_thread() || UseG1GC)),
"not locked");
HeapWord* obj = top();
if (pointer_delta(end_value, obj) >= size) {