18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP
27
28 #include "gc_implementation/shared/gcUtil.hpp"
29 #include "memory/allocation.hpp"
30 #include "runtime/atomic.hpp"
31 #include "utilities/globalDefinitions.hpp"
32
33 // Forward declarations.
34 class PLABStats;
35
36 // A per-thread allocation buffer used during GC.
37 class ParGCAllocBuffer: public CHeapObj<mtGC> {
38 protected:
39 char head[32];
40 size_t _word_sz; // In HeapWord units
41 HeapWord* _bottom;
42 HeapWord* _top;
43 HeapWord* _end; // Last allocatable address + 1
44 HeapWord* _hard_end; // _end + AlignmentReserve
45 // In support of ergonomic sizing of PLAB's
46 size_t _allocated; // in HeapWord units
47 size_t _wasted; // in HeapWord units
48 char tail[32];
49 static size_t AlignmentReserve;
50
51 // Force future allocations to fail and queries for contains()
52 // to return false. Returns the amount of unused space in this PLAB.
53 size_t invalidate() {
54 _end = _hard_end;
55 size_t remaining = pointer_delta(_end, _top); // Calculate remaining space.
56 _top = _end; // Force future allocations to fail.
57 _bottom = _end; // Force future contains() queries to return false.
58 return remaining;
59 }
60
61 // Fill in remaining space with a dummy object and invalidate the PLAB. Returns
62 // the amount of remaining space.
63 size_t retire_internal();
64
65 public:
66 // Initializes the buffer to be empty, but with the given "word_sz".
67 // Must get initialized with "set_buf" for an allocation to succeed.
68 ParGCAllocBuffer(size_t word_sz);
69 virtual ~ParGCAllocBuffer() {}
127 _end = _hard_end - AlignmentReserve;
128 assert(_end >= _top, "Negative buffer");
129 // In support of ergonomic sizing
130 _allocated += word_sz();
131 }
132
133 // Flush allocation statistics into the given PLABStats supporting ergonomic
134 // sizing of PLAB's and retire the current buffer. To be called at the end of
135 // GC.
136 void flush_and_retire_stats(PLABStats* stats);
137
138 // Fills in the unallocated portion of the buffer with a garbage object and updates
139 // statistics. To be called during GC.
140 virtual void retire();
141
142 void print() PRODUCT_RETURN;
143 };
144
145 // PLAB book-keeping.
146 class PLABStats VALUE_OBJ_CLASS_SPEC {
147 size_t _allocated; // Total allocated
148 size_t _wasted; // of which wasted (internal fragmentation)
149 size_t _unused; // Unused in last buffer
150 size_t _desired_plab_sz;// Output of filter (below), suitably trimmed and quantized
151 AdaptiveWeightedAverage
152 _filter; // Integrator with decay
153
154 void reset() {
155 _allocated = 0;
156 _wasted = 0;
157 _unused = 0;
158 }
159 public:
160 PLABStats(size_t desired_plab_sz_, unsigned wt) :
161 _allocated(0),
162 _wasted(0),
163 _unused(0),
164 _desired_plab_sz(desired_plab_sz_),
165 _filter(wt)
166 { }
167
168 static const size_t min_size() {
169 return ParGCAllocBuffer::min_size();
170 }
171
172 static const size_t max_size() {
173 return ParGCAllocBuffer::max_size();
174 }
|
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP
27
28 #include "gc_implementation/shared/gcUtil.hpp"
29 #include "memory/allocation.hpp"
30 #include "runtime/atomic.hpp"
31 #include "utilities/globalDefinitions.hpp"
32
33 // Forward declarations.
34 class PLABStats;
35
36 // A per-thread allocation buffer used during GC.
37 class ParGCAllocBuffer: public CHeapObj<mtGC> {
38 public:
39 static size_t AlignmentReserve;
40 protected:
41 char head[32];
42 size_t _word_sz; // In HeapWord units
43 HeapWord* _bottom;
44 HeapWord* _top;
45 HeapWord* _end; // Last allocatable address + 1
46 HeapWord* _hard_end; // _end + AlignmentReserve
47 // In support of ergonomic sizing of PLAB's
48 size_t _allocated; // in HeapWord units
49 size_t _wasted; // in HeapWord units
50 char tail[32];
51
52 // Force future allocations to fail and queries for contains()
53 // to return false. Returns the amount of unused space in this PLAB.
54 size_t invalidate() {
55 _end = _hard_end;
56 size_t remaining = pointer_delta(_end, _top); // Calculate remaining space.
57 _top = _end; // Force future allocations to fail.
58 _bottom = _end; // Force future contains() queries to return false.
59 return remaining;
60 }
61
62 // Fill in remaining space with a dummy object and invalidate the PLAB. Returns
63 // the amount of remaining space.
64 size_t retire_internal();
65
66 public:
67 // Initializes the buffer to be empty, but with the given "word_sz".
68 // Must get initialized with "set_buf" for an allocation to succeed.
69 ParGCAllocBuffer(size_t word_sz);
70 virtual ~ParGCAllocBuffer() {}
128 _end = _hard_end - AlignmentReserve;
129 assert(_end >= _top, "Negative buffer");
130 // In support of ergonomic sizing
131 _allocated += word_sz();
132 }
133
134 // Flush allocation statistics into the given PLABStats supporting ergonomic
135 // sizing of PLAB's and retire the current buffer. To be called at the end of
136 // GC.
137 void flush_and_retire_stats(PLABStats* stats);
138
139 // Fills in the unallocated portion of the buffer with a garbage object and updates
140 // statistics. To be called during GC.
141 virtual void retire();
142
143 void print() PRODUCT_RETURN;
144 };
145
146 // PLAB book-keeping.
147 class PLABStats VALUE_OBJ_CLASS_SPEC {
148 protected:
149 size_t _allocated; // Total allocated
150 size_t _wasted; // of which wasted (internal fragmentation)
151 size_t _unused; // Unused in last buffer
152 size_t _desired_plab_sz;// Output of filter (below), suitably trimmed and quantized
153 AdaptiveWeightedAverage
154 _filter; // Integrator with decay
155
156 virtual void reset() {
157 _allocated = 0;
158 _wasted = 0;
159 _unused = 0;
160 }
161 public:
162 PLABStats(size_t desired_plab_sz_, unsigned wt) :
163 _allocated(0),
164 _wasted(0),
165 _unused(0),
166 _desired_plab_sz(desired_plab_sz_),
167 _filter(wt)
168 { }
169
170 static const size_t min_size() {
171 return ParGCAllocBuffer::min_size();
172 }
173
174 static const size_t max_size() {
175 return ParGCAllocBuffer::max_size();
176 }
|