295 G1PLAB _surviving_alloc_buffer;
296 G1PLAB _tenured_alloc_buffer;
297 G1PLAB* _alloc_buffers[InCSetState::Num];
298
299 public:
300 G1DefaultPLABAllocator(G1Allocator* _allocator);
301
302 virtual G1PLAB* alloc_buffer(InCSetState dest, AllocationContext_t context) {
303 assert(dest.is_valid(),
304 "Allocation buffer index out-of-bounds: " CSETSTATE_FORMAT, dest.value());
305 assert(_alloc_buffers[dest.value()] != NULL,
306 "Allocation buffer is NULL: " CSETSTATE_FORMAT, dest.value());
307 return _alloc_buffers[dest.value()];
308 }
309
310 virtual void flush_and_retire_stats();
311
312 virtual void waste(size_t& wasted, size_t& undo_wasted);
313 };
314
315 // G1ArchiveAllocator is used to allocate memory in archive
316 // regions. Such regions are not modifiable by GC, being neither
317 // scavenged nor compacted, or even marked in the object header.
318 // They can contain no pointers to non-archive heap regions,
319 class G1ArchiveAllocator : public CHeapObj<mtGC> {
320
321 protected:
322 G1CollectedHeap* _g1h;
323
324 // The current allocation region
325 HeapRegion* _allocation_region;
326
327 // Regions allocated for the current archive range.
328 GrowableArray<HeapRegion*> _allocated_regions;
329
330 // The number of bytes used in the current range.
331 size_t _summary_bytes_used;
332
333 // Current allocation window within the current region.
334 HeapWord* _bottom;
335 HeapWord* _top;
336 HeapWord* _max;
337
338 // Allocate a new region for this archive allocator.
339 // Allocation is from the top of the reserved heap downward.
340 bool alloc_new_region();
361 HeapWord* archive_mem_allocate(size_t word_size);
362
363 // Return the memory ranges used in the current archive, after
364 // aligning to the requested alignment.
365 void complete_archive(GrowableArray<MemRegion>* ranges,
366 size_t end_alignment_in_bytes);
367
368 // The number of bytes allocated by this allocator.
369 size_t used() {
370 return _summary_bytes_used;
371 }
372
373 // Clear the count of bytes allocated in prior G1 regions. This
374 // must be done when recalculate_use is used to reset the counter
375 // for the generic allocator, since it counts bytes in all G1
376 // regions, including those still associated with this allocator.
377 void clear_used() {
378 _summary_bytes_used = 0;
379 }
380
381 };
382
383 #endif // SHARE_VM_GC_G1_G1ALLOCATOR_HPP
|
295 G1PLAB _surviving_alloc_buffer;
296 G1PLAB _tenured_alloc_buffer;
297 G1PLAB* _alloc_buffers[InCSetState::Num];
298
299 public:
300 G1DefaultPLABAllocator(G1Allocator* _allocator);
301
302 virtual G1PLAB* alloc_buffer(InCSetState dest, AllocationContext_t context) {
303 assert(dest.is_valid(),
304 "Allocation buffer index out-of-bounds: " CSETSTATE_FORMAT, dest.value());
305 assert(_alloc_buffers[dest.value()] != NULL,
306 "Allocation buffer is NULL: " CSETSTATE_FORMAT, dest.value());
307 return _alloc_buffers[dest.value()];
308 }
309
310 virtual void flush_and_retire_stats();
311
312 virtual void waste(size_t& wasted, size_t& undo_wasted);
313 };
314
315 // G1ArchiveRegionMap is a boolean array used to mark G1 regions as
316 // archive regions. This allows a quick check for whether an object
317 // should not be marked because it is in an archive region.
318 class G1ArchiveRegionMap : public G1BiasedMappedArray<bool> {
319 protected:
320 bool default_value() const { return false; }
321 };
322
323 // G1ArchiveAllocator is used to allocate memory in archive
324 // regions. Such regions are not modifiable by GC, being neither
325 // scavenged nor compacted, or even marked in the object header.
326 // They can contain no pointers to non-archive heap regions,
327 class G1ArchiveAllocator : public CHeapObj<mtGC> {
328 protected:
329 G1CollectedHeap* _g1h;
330
331 // The current allocation region
332 HeapRegion* _allocation_region;
333
334 // Regions allocated for the current archive range.
335 GrowableArray<HeapRegion*> _allocated_regions;
336
337 // The number of bytes used in the current range.
338 size_t _summary_bytes_used;
339
340 // Current allocation window within the current region.
341 HeapWord* _bottom;
342 HeapWord* _top;
343 HeapWord* _max;
344
345 // Allocate a new region for this archive allocator.
346 // Allocation is from the top of the reserved heap downward.
347 bool alloc_new_region();
368 HeapWord* archive_mem_allocate(size_t word_size);
369
370 // Return the memory ranges used in the current archive, after
371 // aligning to the requested alignment.
372 void complete_archive(GrowableArray<MemRegion>* ranges,
373 size_t end_alignment_in_bytes);
374
375 // The number of bytes allocated by this allocator.
376 size_t used() {
377 return _summary_bytes_used;
378 }
379
380 // Clear the count of bytes allocated in prior G1 regions. This
381 // must be done when recalculate_use is used to reset the counter
382 // for the generic allocator, since it counts bytes in all G1
383 // regions, including those still associated with this allocator.
384 void clear_used() {
385 _summary_bytes_used = 0;
386 }
387
388 // Create the _archive_region_map which is used to identify archive objects.
389 static inline void enable_archive_object_check();
390
391 // Set the regions containing the specified address range as archive/non-archive.
392 static inline void set_range_archive(MemRegion range, bool is_archive);
393
394 static inline bool is_archive_object(oop object);
395
396 private:
397 static bool _archive_check_enabled;
398 static G1ArchiveRegionMap _archive_region_map;
399
400 // Check if an object is in an archive region using the _archive_region_map.
401 static inline bool in_archive_range(oop object);
402
403 // Check if archive object checking is enabled, to avoid calling in_archive_range
404 // unnecessarily.
405 static inline bool archive_check_enabled();
406 };
407
408 #endif // SHARE_VM_GC_G1_G1ALLOCATOR_HPP
|