< prev index next >

src/share/vm/gc/g1/g1Allocator.hpp

Print this page




 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();
 348 
 349 public:
 350   G1ArchiveAllocator(G1CollectedHeap* g1h) :
 351     _g1h(g1h),
 352     _allocation_region(NULL),
 353     _allocated_regions((ResourceObj::set_allocation_type((address) &_allocated_regions,
 354                                                          ResourceObj::C_HEAP),
 355                         2), true /* C_Heap */),
 356     _summary_bytes_used(0),
 357     _bottom(NULL),
 358     _top(NULL),
 359     _max(NULL) { }

 360 
 361   virtual ~G1ArchiveAllocator() {
 362     assert(_allocation_region == NULL, "_allocation_region not NULL");
 363   }
 364 
 365   static G1ArchiveAllocator* create_allocator(G1CollectedHeap* g1h);
 366 
 367   // Allocate memory for an individual object.
 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


 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   bool _open; // An 'open' archive region may contain references pointing to
 330               // non-archive heap region. GC can adjust pointers in 'open'
 331               // archive region.
 332   G1CollectedHeap* _g1h;
 333 
 334   // The current allocation region
 335   HeapRegion* _allocation_region;
 336 
 337   // Regions allocated for the current archive range.
 338   GrowableArray<HeapRegion*> _allocated_regions;
 339 
 340   // The number of bytes used in the current range.
 341   size_t _summary_bytes_used;
 342 
 343   // Current allocation window within the current region.
 344   HeapWord* _bottom;
 345   HeapWord* _top;
 346   HeapWord* _max;
 347 
 348   // Allocate a new region for this archive allocator.
 349   // Allocation is from the top of the reserved heap downward.
 350   bool alloc_new_region();
 351 
 352 public:
 353   G1ArchiveAllocator(G1CollectedHeap* g1h, bool open) :
 354     _g1h(g1h),
 355     _allocation_region(NULL),
 356     _allocated_regions((ResourceObj::set_allocation_type((address) &_allocated_regions,
 357                                                          ResourceObj::C_HEAP),
 358                         2), true /* C_Heap */),
 359     _summary_bytes_used(0),
 360     _bottom(NULL),
 361     _top(NULL),
 362     _max(NULL),
 363     _open(open) { }
 364 
 365   virtual ~G1ArchiveAllocator() {
 366     assert(_allocation_region == NULL, "_allocation_region not NULL");
 367   }
 368 
 369   static G1ArchiveAllocator* create_allocator(G1CollectedHeap* g1h, bool open);
 370 
 371   // Allocate memory for an individual object.
 372   HeapWord* archive_mem_allocate(size_t word_size);
 373 
 374   // Return the memory ranges used in the current archive, after
 375   // aligning to the requested alignment.
 376   void complete_archive(GrowableArray<MemRegion>* ranges,
 377                         size_t end_alignment_in_bytes);
 378 
 379   // The number of bytes allocated by this allocator.
 380   size_t used() {
 381     return _summary_bytes_used;
 382   }
 383 
 384   // Clear the count of bytes allocated in prior G1 regions. This
 385   // must be done when recalculate_use is used to reset the counter
 386   // for the generic allocator, since it counts bytes in all G1
 387   // regions, including those still associated with this allocator.
 388   void clear_used() {
 389     _summary_bytes_used = 0;
 390   }
 391 
 392   // Create the _archive_region_map which is used to identify archive objects.
 393   static inline void enable_archive_object_check();
 394 
 395   // Set the regions containing the specified address range as archive/non-archive.
 396   static inline void set_range_archive(MemRegion range, bool open);
 397 
 398   // Check if the object is in closed archive
 399   static inline bool is_closed_archive_object(oop object);
 400   // Check if the object is in open archive
 401   static inline bool is_open_archive_object(oop object);
 402   // Check if the object is either in closed archive or open archive
 403   static inline bool is_archive_object(oop object);
 404 
 405 private:
 406   static bool _archive_check_enabled;
 407   static G1ArchiveRegionMap  _closed_archive_region_map;
 408   static G1ArchiveRegionMap  _open_archive_region_map;
 409 
 410   // Check if an object is in a closed archive region using the _closed_archive_region_map.
 411   static inline bool in_closed_archive_range(oop object);
 412   // Check if an object is in open archive region using the _open_archive_region_map.
 413   static inline bool in_open_archive_range(oop object);
 414 
 415   // Check if archive object checking is enabled, to avoid calling in_open/closed_archive_range
 416   // unnecessarily.
 417   static inline bool archive_check_enabled();
 418 };
 419 
 420 #endif // SHARE_VM_GC_G1_G1ALLOCATOR_HPP
< prev index next >