147 // Create a new tlab. All TLAB allocations must go through this.
148 // To allow more flexible TLAB allocations min_size specifies
149 // the minimum size needed, while requested_size is the requested
150 // size based on ergonomics. The actually allocated size will be
151 // returned in actual_size.
152 virtual HeapWord* allocate_new_tlab(size_t min_size,
153 size_t requested_size,
154 size_t* actual_size);
155
156 // Reinitialize tlabs before resuming mutators.
157 virtual void resize_all_tlabs();
158
159 // Raw memory allocation facilities
160 // The obj and array allocate methods are covers for these methods.
161 // mem_allocate() should never be
162 // called to allocate TLABs, only individual objects.
163 virtual HeapWord* mem_allocate(size_t size,
164 bool* gc_overhead_limit_was_exceeded) = 0;
165
166 // Filler object utilities.
167 static inline size_t filler_array_hdr_size();
168 static inline size_t filler_array_min_size();
169
170 static inline void zap_filler_array_with(HeapWord* start, size_t words, juint value);
171 DEBUG_ONLY(static void fill_args_check(HeapWord* start, size_t words);)
172 DEBUG_ONLY(static void zap_filler_array(HeapWord* start, size_t words, bool zap = true);)
173
174 // Fill with a single array; caller must ensure filler_array_min_size() <=
175 // words <= filler_array_max_size().
176 static inline void fill_with_array(HeapWord* start, size_t words, bool zap = true);
177
178 // Fill with a single object (either an int array or a java.lang.Object).
179 static inline void fill_with_object_impl(HeapWord* start, size_t words, bool zap = true);
180
181 virtual void trace_heap(GCWhen::Type when, const GCTracer* tracer);
182
183 // Verification functions
184 debug_only(static void check_for_valid_allocation_state();)
185
186 public:
187 enum Name {
291 // min_fill_size() is the smallest region that can be filled.
292 // fill_with_objects() can fill arbitrary-sized regions of the heap using
293 // multiple objects. fill_with_object() is for regions known to be smaller
294 // than the largest array of integers; it uses a single object to fill the
295 // region and has slightly less overhead.
296 static size_t min_fill_size() {
297 return size_t(align_object_size(oopDesc::header_size()));
298 }
299
300 static void fill_with_objects(HeapWord* start, size_t words, bool zap = true);
301
302 static void fill_with_object(HeapWord* start, size_t words, bool zap = true);
303 static void fill_with_object(MemRegion region, bool zap = true) {
304 fill_with_object(region.start(), region.word_size(), zap);
305 }
306 static void fill_with_object(HeapWord* start, HeapWord* end, bool zap = true) {
307 fill_with_object(start, pointer_delta(end, start), zap);
308 }
309
310 virtual void fill_with_dummy_object(HeapWord* start, HeapWord* end, bool zap);
311 static constexpr size_t min_dummy_object_size() {
312 return oopDesc::header_size();
313 }
314
315 static size_t lab_alignment_reserve() {
316 assert(_lab_alignment_reserve != SIZE_MAX, "uninitialized");
317 return _lab_alignment_reserve;
318 }
319
320 // Some heaps may be in an unparseable state at certain times between
321 // collections. This may be necessary for efficient implementation of
322 // certain allocation-related activities. Calling this function before
323 // attempting to parse a heap ensures that the heap is in a parsable
324 // state (provided other concurrent activity does not introduce
325 // unparsability). It is normally expected, therefore, that this
326 // method is invoked with the world stopped.
327 // NOTE: if you override this method, make sure you call
328 // super::ensure_parsability so that the non-generational
329 // part of the work gets done. See implementation of
330 // CollectedHeap::ensure_parsability and, for instance,
331 // that of GenCollectedHeap::ensure_parsability().
|
147 // Create a new tlab. All TLAB allocations must go through this.
148 // To allow more flexible TLAB allocations min_size specifies
149 // the minimum size needed, while requested_size is the requested
150 // size based on ergonomics. The actually allocated size will be
151 // returned in actual_size.
152 virtual HeapWord* allocate_new_tlab(size_t min_size,
153 size_t requested_size,
154 size_t* actual_size);
155
156 // Reinitialize tlabs before resuming mutators.
157 virtual void resize_all_tlabs();
158
159 // Raw memory allocation facilities
160 // The obj and array allocate methods are covers for these methods.
161 // mem_allocate() should never be
162 // called to allocate TLABs, only individual objects.
163 virtual HeapWord* mem_allocate(size_t size,
164 bool* gc_overhead_limit_was_exceeded) = 0;
165
166 // Filler object utilities.
167 static inline size_t filler_array_min_size();
168
169 static inline void zap_filler_array_with(HeapWord* start, size_t words, juint value);
170 DEBUG_ONLY(static void fill_args_check(HeapWord* start, size_t words);)
171 DEBUG_ONLY(static void zap_filler_array(HeapWord* start, size_t words, bool zap = true);)
172
173 // Fill with a single array; caller must ensure filler_array_min_size() <=
174 // words <= filler_array_max_size().
175 static inline void fill_with_array(HeapWord* start, size_t words, bool zap = true);
176
177 // Fill with a single object (either an int array or a java.lang.Object).
178 static inline void fill_with_object_impl(HeapWord* start, size_t words, bool zap = true);
179
180 virtual void trace_heap(GCWhen::Type when, const GCTracer* tracer);
181
182 // Verification functions
183 debug_only(static void check_for_valid_allocation_state();)
184
185 public:
186 enum Name {
290 // min_fill_size() is the smallest region that can be filled.
291 // fill_with_objects() can fill arbitrary-sized regions of the heap using
292 // multiple objects. fill_with_object() is for regions known to be smaller
293 // than the largest array of integers; it uses a single object to fill the
294 // region and has slightly less overhead.
295 static size_t min_fill_size() {
296 return size_t(align_object_size(oopDesc::header_size()));
297 }
298
299 static void fill_with_objects(HeapWord* start, size_t words, bool zap = true);
300
301 static void fill_with_object(HeapWord* start, size_t words, bool zap = true);
302 static void fill_with_object(MemRegion region, bool zap = true) {
303 fill_with_object(region.start(), region.word_size(), zap);
304 }
305 static void fill_with_object(HeapWord* start, HeapWord* end, bool zap = true) {
306 fill_with_object(start, pointer_delta(end, start), zap);
307 }
308
309 virtual void fill_with_dummy_object(HeapWord* start, HeapWord* end, bool zap);
310 static size_t min_dummy_object_size() {
311 return oopDesc::header_size();
312 }
313
314 static size_t lab_alignment_reserve() {
315 assert(_lab_alignment_reserve != SIZE_MAX, "uninitialized");
316 return _lab_alignment_reserve;
317 }
318
319 // Some heaps may be in an unparseable state at certain times between
320 // collections. This may be necessary for efficient implementation of
321 // certain allocation-related activities. Calling this function before
322 // attempting to parse a heap ensures that the heap is in a parsable
323 // state (provided other concurrent activity does not introduce
324 // unparsability). It is normally expected, therefore, that this
325 // method is invoked with the world stopped.
326 // NOTE: if you override this method, make sure you call
327 // super::ensure_parsability so that the non-generational
328 // part of the work gets done. See implementation of
329 // CollectedHeap::ensure_parsability and, for instance,
330 // that of GenCollectedHeap::ensure_parsability().
|