comparison src/share/vm/gc_implementation/g1/heapRegion.inline.hpp @ 2433:abdfc822206f

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 Summary: 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
author tonyp
date Wed, 30 Mar 2011 10:26:59 -0400
parents f95d63e2154a
children 2ace1c4ee8da
comparison
equal deleted inserted replaced
2432:455328d90876 2433:abdfc822206f
36 // Because of the requirement of keeping "_offsets" up to date with the 36 // Because of the requirement of keeping "_offsets" up to date with the
37 // allocations, we sequentialize these with a lock. Therefore, best if 37 // allocations, we sequentialize these with a lock. Therefore, best if
38 // this is used for larger LAB allocations only. 38 // this is used for larger LAB allocations only.
39 inline HeapWord* G1OffsetTableContigSpace::par_allocate(size_t size) { 39 inline HeapWord* G1OffsetTableContigSpace::par_allocate(size_t size) {
40 MutexLocker x(&_par_alloc_lock); 40 MutexLocker x(&_par_alloc_lock);
41 // This ought to be just "allocate", because of the lock above, but that 41 // Given that we take the lock no need to use par_allocate() here.
42 // ContiguousSpace::allocate asserts that either the allocating thread 42 HeapWord* res = ContiguousSpace::allocate(size);
43 // holds the heap lock or it is the VM thread and we're at a safepoint.
44 // The best I (dld) could figure was to put a field in ContiguousSpace
45 // meaning "locking at safepoint taken care of", and set/reset that
46 // here. But this will do for now, especially in light of the comment
47 // above. Perhaps in the future some lock-free manner of keeping the
48 // coordination.
49 HeapWord* res = ContiguousSpace::par_allocate(size);
50 if (res != NULL) { 43 if (res != NULL) {
51 _offsets.alloc_block(res, size); 44 _offsets.alloc_block(res, size);
52 } 45 }
53 return res; 46 return res;
54 } 47 }