26 #define SHARE_VM_GC_SHARED_PLAB_INLINE_HPP
27
28 #include "gc/shared/collectedHeap.inline.hpp"
29 #include "gc/shared/plab.hpp"
30 #include "memory/allocation.inline.hpp"
31 #include "runtime/atomic.hpp"
32
33 inline HeapWord* PLAB::allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes) {
34 HeapWord* res = CollectedHeap::align_allocation_or_fail(_top, _end, alignment_in_bytes);
35 if (res == NULL) {
36 return NULL;
37 }
38
39 // Set _top so that allocate(), which expects _top to be correctly set,
40 // can be used below.
41 _top = res;
42 return allocate(word_sz);
43 }
44
45 void PLABStats::add_allocated(size_t v) {
46 Atomic::add_ptr(v, &_allocated);
47 }
48
49 void PLABStats::add_unused(size_t v) {
50 Atomic::add_ptr(v, &_unused);
51 }
52
53 void PLABStats::add_wasted(size_t v) {
54 Atomic::add_ptr(v, &_wasted);
55 }
56
57 void PLABStats::add_undo_wasted(size_t v) {
58 Atomic::add_ptr(v, &_undo_wasted);
59 }
60
61 #endif // SHARE_VM_GC_SHARED_PLAB_INLINE_HPP
|
26 #define SHARE_VM_GC_SHARED_PLAB_INLINE_HPP
27
28 #include "gc/shared/collectedHeap.inline.hpp"
29 #include "gc/shared/plab.hpp"
30 #include "memory/allocation.inline.hpp"
31 #include "runtime/atomic.hpp"
32
33 inline HeapWord* PLAB::allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes) {
34 HeapWord* res = CollectedHeap::align_allocation_or_fail(_top, _end, alignment_in_bytes);
35 if (res == NULL) {
36 return NULL;
37 }
38
39 // Set _top so that allocate(), which expects _top to be correctly set,
40 // can be used below.
41 _top = res;
42 return allocate(word_sz);
43 }
44
45 void PLABStats::add_allocated(size_t v) {
46 Atomic::add(v, &_allocated);
47 }
48
49 void PLABStats::add_unused(size_t v) {
50 Atomic::add(v, &_unused);
51 }
52
53 void PLABStats::add_wasted(size_t v) {
54 Atomic::add(v, &_wasted);
55 }
56
57 void PLABStats::add_undo_wasted(size_t v) {
58 Atomic::add(v, &_undo_wasted);
59 }
60
61 #endif // SHARE_VM_GC_SHARED_PLAB_INLINE_HPP
|