23 */
24
25 #ifndef SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_INLINE_HPP
26 #define SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_INLINE_HPP
27
28 #include "gc/parallel/psPromotionLAB.hpp"
29 #include "gc/shared/collectedHeap.inline.hpp"
30
31 HeapWord* PSYoungPromotionLAB::allocate(size_t size) {
32 // Can't assert this, when young fills, we keep the LAB around, but flushed.
33 // assert(_state != flushed, "Sanity");
34 HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end(), SurvivorAlignmentInBytes);
35 if (obj == NULL) {
36 return NULL;
37 }
38
39 HeapWord* new_top = obj + size;
40 // The 'new_top>obj' check is needed to detect overflow of obj+size.
41 if (new_top > obj && new_top <= end()) {
42 set_top(new_top);
43 assert(is_ptr_aligned(obj, SurvivorAlignmentInBytes) && is_object_aligned((intptr_t)new_top),
44 "checking alignment");
45 return obj;
46 } else {
47 set_top(obj);
48 return NULL;
49 }
50 }
51
52 #endif // SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_INLINE_HPP
|
23 */
24
25 #ifndef SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_INLINE_HPP
26 #define SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_INLINE_HPP
27
28 #include "gc/parallel/psPromotionLAB.hpp"
29 #include "gc/shared/collectedHeap.inline.hpp"
30
31 HeapWord* PSYoungPromotionLAB::allocate(size_t size) {
32 // Can't assert this, when young fills, we keep the LAB around, but flushed.
33 // assert(_state != flushed, "Sanity");
34 HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end(), SurvivorAlignmentInBytes);
35 if (obj == NULL) {
36 return NULL;
37 }
38
39 HeapWord* new_top = obj + size;
40 // The 'new_top>obj' check is needed to detect overflow of obj+size.
41 if (new_top > obj && new_top <= end()) {
42 set_top(new_top);
43 assert(is_ptr_aligned(obj, SurvivorAlignmentInBytes) && is_ptr_object_aligned(new_top),
44 "checking alignment");
45 return obj;
46 } else {
47 set_top(obj);
48 return NULL;
49 }
50 }
51
52 #endif // SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_INLINE_HPP
|