157 inline static void post_allocation_setup_array(Klass* klass,
158 HeapWord* obj, int length);
159
160 inline static void post_allocation_setup_class(Klass* klass, HeapWord* obj, int size);
161
162 // Clears an allocated object.
163 inline static void init_obj(HeapWord* obj, size_t size);
164
165 // Filler object utilities.
166 static inline size_t filler_array_hdr_size();
167 static inline size_t filler_array_min_size();
168
169 DEBUG_ONLY(static void fill_args_check(HeapWord* start, size_t words);)
170 DEBUG_ONLY(static void zap_filler_array(HeapWord* start, size_t words, bool zap = true);)
171
172 // Fill with a single array; caller must ensure filler_array_min_size() <=
173 // words <= filler_array_max_size().
174 static inline void fill_with_array(HeapWord* start, size_t words, bool zap = true);
175
176 // Fill with a single object (either an int array or a java.lang.Object).
177 static inline void fill_with_object_impl(HeapWord* start, size_t words, bool zap = true);
178
179 virtual void trace_heap(GCWhen::Type when, const GCTracer* tracer);
180
181 // Verification functions
182 virtual void check_for_bad_heap_word_value(HeapWord* addr, size_t size)
183 PRODUCT_RETURN;
184 virtual void check_for_non_bad_heap_word_value(HeapWord* addr, size_t size)
185 PRODUCT_RETURN;
186 debug_only(static void check_for_valid_allocation_state();)
187
188 public:
189 enum Name {
190 None,
191 Serial,
192 Parallel,
193 CMS,
194 G1,
195 Shenandoah
196 };
197
198 static inline size_t filler_array_max_size() {
199 return _filler_array_max_size;
200 }
201
202 virtual Name kind() const = 0;
203
204 virtual HeapWord* tlab_post_allocation_setup(HeapWord* obj);
205
206 virtual const char* name() const = 0;
207
208 /**
209 * Returns JNI error code JNI_ENOMEM if memory could not be allocated,
210 * and JNI_OK on success.
211 */
212 virtual jint initialize() = 0;
213
214 // In many heaps, there will be a need to perform some initialization activities
215 // after the Universe is fully formed, but before general heap allocation is allowed.
216 // This is the correct place to place such initialization methods.
217 virtual void post_initialize();
218
219 // Stop any onging concurrent work and prepare for exit.
220 virtual void stop() {}
221
222 // Stop and resume concurrent GC threads interfering with safepoint operations
223 virtual void safepoint_synchronize_begin() {}
224 virtual void safepoint_synchronize_end() {}
225
300 _gc_cause = v;
301 }
302 GCCause::Cause gc_cause() { return _gc_cause; }
303
304 // General obj/array allocation facilities.
305 inline static oop obj_allocate(Klass* klass, int size, TRAPS);
306 inline static oop array_allocate(Klass* klass, int size, int length, TRAPS);
307 inline static oop array_allocate_nozero(Klass* klass, int size, int length, TRAPS);
308 inline static oop class_allocate(Klass* klass, int size, TRAPS);
309
310 virtual uint oop_extra_words();
311
312 #ifndef CC_INTERP
313 virtual void compile_prepare_oop(MacroAssembler* masm, Register obj);
314 #endif
315
316 // Raw memory allocation facilities
317 // The obj and array allocate methods are covers for these methods.
318 // mem_allocate() should never be
319 // called to allocate TLABs, only individual objects.
320 virtual HeapWord* mem_allocate(size_t size,
321 bool* gc_overhead_limit_was_exceeded) = 0;
322
323 // Utilities for turning raw memory into filler objects.
324 //
325 // min_fill_size() is the smallest region that can be filled.
326 // fill_with_objects() can fill arbitrary-sized regions of the heap using
327 // multiple objects. fill_with_object() is for regions known to be smaller
328 // than the largest array of integers; it uses a single object to fill the
329 // region and has slightly less overhead.
330 static size_t min_fill_size() {
331 return size_t(align_object_size(oopDesc::header_size()));
332 }
333
334 static void fill_with_objects(HeapWord* start, size_t words, bool zap = true);
335
336 static void fill_with_object(HeapWord* start, size_t words, bool zap = true);
337 static void fill_with_object(MemRegion region, bool zap = true) {
338 fill_with_object(region.start(), region.word_size(), zap);
339 }
340 static void fill_with_object(HeapWord* start, HeapWord* end, bool zap = true) {
|
157 inline static void post_allocation_setup_array(Klass* klass,
158 HeapWord* obj, int length);
159
160 inline static void post_allocation_setup_class(Klass* klass, HeapWord* obj, int size);
161
162 // Clears an allocated object.
163 inline static void init_obj(HeapWord* obj, size_t size);
164
165 // Filler object utilities.
166 static inline size_t filler_array_hdr_size();
167 static inline size_t filler_array_min_size();
168
169 DEBUG_ONLY(static void fill_args_check(HeapWord* start, size_t words);)
170 DEBUG_ONLY(static void zap_filler_array(HeapWord* start, size_t words, bool zap = true);)
171
172 // Fill with a single array; caller must ensure filler_array_min_size() <=
173 // words <= filler_array_max_size().
174 static inline void fill_with_array(HeapWord* start, size_t words, bool zap = true);
175
176 // Fill with a single object (either an int array or a java.lang.Object).
177 virtual void fill_with_object_impl(HeapWord* start, size_t words, bool zap = true);
178
179 virtual void trace_heap(GCWhen::Type when, const GCTracer* tracer);
180
181 // Verification functions
182 virtual void check_for_bad_heap_word_value(HeapWord* addr, size_t size)
183 PRODUCT_RETURN;
184 virtual void check_for_non_bad_heap_word_value(HeapWord* addr, size_t size)
185 PRODUCT_RETURN;
186 debug_only(static void check_for_valid_allocation_state();)
187
188 public:
189 enum Name {
190 None,
191 Serial,
192 Parallel,
193 CMS,
194 G1,
195 Shenandoah
196 };
197
198 static inline size_t filler_array_max_size() {
199 return _filler_array_max_size;
200 }
201
202 virtual Name kind() const = 0;
203
204 virtual const char* name() const = 0;
205
206 /**
207 * Returns JNI error code JNI_ENOMEM if memory could not be allocated,
208 * and JNI_OK on success.
209 */
210 virtual jint initialize() = 0;
211
212 // In many heaps, there will be a need to perform some initialization activities
213 // after the Universe is fully formed, but before general heap allocation is allowed.
214 // This is the correct place to place such initialization methods.
215 virtual void post_initialize();
216
217 // Stop any onging concurrent work and prepare for exit.
218 virtual void stop() {}
219
220 // Stop and resume concurrent GC threads interfering with safepoint operations
221 virtual void safepoint_synchronize_begin() {}
222 virtual void safepoint_synchronize_end() {}
223
298 _gc_cause = v;
299 }
300 GCCause::Cause gc_cause() { return _gc_cause; }
301
302 // General obj/array allocation facilities.
303 inline static oop obj_allocate(Klass* klass, int size, TRAPS);
304 inline static oop array_allocate(Klass* klass, int size, int length, TRAPS);
305 inline static oop array_allocate_nozero(Klass* klass, int size, int length, TRAPS);
306 inline static oop class_allocate(Klass* klass, int size, TRAPS);
307
308 virtual uint oop_extra_words();
309
310 #ifndef CC_INTERP
311 virtual void compile_prepare_oop(MacroAssembler* masm, Register obj);
312 #endif
313
314 // Raw memory allocation facilities
315 // The obj and array allocate methods are covers for these methods.
316 // mem_allocate() should never be
317 // called to allocate TLABs, only individual objects.
318 virtual HeapWord* mem_allocate(size_t size, Klass* klass, Thread* thread,
319 bool* gc_overhead_limit_was_exceeded) = 0;
320
321 // Utilities for turning raw memory into filler objects.
322 //
323 // min_fill_size() is the smallest region that can be filled.
324 // fill_with_objects() can fill arbitrary-sized regions of the heap using
325 // multiple objects. fill_with_object() is for regions known to be smaller
326 // than the largest array of integers; it uses a single object to fill the
327 // region and has slightly less overhead.
328 static size_t min_fill_size() {
329 return size_t(align_object_size(oopDesc::header_size()));
330 }
331
332 static void fill_with_objects(HeapWord* start, size_t words, bool zap = true);
333
334 static void fill_with_object(HeapWord* start, size_t words, bool zap = true);
335 static void fill_with_object(MemRegion region, bool zap = true) {
336 fill_with_object(region.start(), region.word_size(), zap);
337 }
338 static void fill_with_object(HeapWord* start, HeapWord* end, bool zap = true) {
|