< prev index next >

src/share/vm/gc/shared/space.hpp

Print this page




 345 //  - adjust_obj_size  and adjust_pointers()
 346 //  - obj_size         and compact().
 347 //
 348 // Additionally, this also means that changes to block_size() or block_is_obj() that
 349 // should be effective during the compaction operations must provide a corresponding
 350 // definition of scanned_block_size/scanned_block_is_obj respectively.
 351 class CompactibleSpace: public Space {
 352   friend class VMStructs;
 353   friend class CompactibleFreeListSpace;
 354 private:
 355   HeapWord* _compaction_top;
 356   CompactibleSpace* _next_compaction_space;
 357 
 358   // Auxiliary functions for scan_and_{forward,adjust_pointers,compact} support.
 359   inline size_t adjust_obj_size(size_t size) const {
 360     return size;
 361   }
 362 
 363   inline size_t obj_size(const HeapWord* addr) const;
 364 






 365 public:
 366   CompactibleSpace() :
 367    _compaction_top(NULL), _next_compaction_space(NULL) {}
 368 
 369   virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space);
 370   virtual void clear(bool mangle_space);
 371 
 372   // Used temporarily during a compaction phase to hold the value
 373   // top should have when compaction is complete.
 374   HeapWord* compaction_top() const { return _compaction_top;    }
 375 
 376   void set_compaction_top(HeapWord* value) {
 377     assert(value == NULL || (value >= bottom() && value <= end()),
 378       "should point inside space");
 379     _compaction_top = value;
 380   }
 381 
 382   // Perform operations on the space needed after a compaction
 383   // has been performed.
 384   virtual void reset_after_compaction() = 0;


 437   virtual HeapWord* forward(oop q, size_t size, CompactPoint* cp,
 438                     HeapWord* compact_top);
 439 
 440   // Return a size with adjustments as required of the space.
 441   virtual size_t adjust_object_size_v(size_t size) const { return size; }
 442 
 443 protected:
 444   // Used during compaction.
 445   HeapWord* _first_dead;
 446   HeapWord* _end_of_live;
 447 
 448   // Minimum size of a free block.
 449   virtual size_t minimum_free_block_size() const { return 0; }
 450 
 451   // This the function is invoked when an allocation of an object covering
 452   // "start" to "end occurs crosses the threshold; returns the next
 453   // threshold.  (The default implementation does nothing.)
 454   virtual HeapWord* cross_threshold(HeapWord* start, HeapWord* the_end) {
 455     return end();
 456   }
 457 
 458   // Requires "allowed_deadspace_words > 0", that "q" is the start of a
 459   // free block of the given "word_len", and that "q", were it an object,
 460   // would not move if forwarded.  If the size allows, fill the free
 461   // block with an object, to prevent excessive compaction.  Returns "true"
 462   // iff the free region was made deadspace, and modifies
 463   // "allowed_deadspace_words" to reflect the number of available deadspace
 464   // words remaining after this operation.
 465   bool insert_deadspace(size_t& allowed_deadspace_words, HeapWord* q,
 466                         size_t word_len);
 467 
 468   // Below are template functions for scan_and_* algorithms (avoiding virtual calls).
 469   // The space argument should be a subclass of CompactibleSpace, implementing
 470   // scan_limit(), scanned_block_is_obj(), and scanned_block_size(),
 471   // and possibly also overriding obj_size(), and adjust_obj_size().
 472   // These functions should avoid virtual calls whenever possible.
 473 
 474   // Frequently calls adjust_obj_size().
 475   template <class SpaceType>
 476   static inline void scan_and_adjust_pointers(SpaceType* space);
 477 
 478   // Frequently calls obj_size().
 479   template <class SpaceType>
 480   static inline void scan_and_compact(SpaceType* space);
 481 
 482   // Frequently calls scanned_block_is_obj() and scanned_block_size().
 483   // Requires the scan_limit() function.
 484   template <class SpaceType>
 485   static inline void scan_and_forward(SpaceType* space, CompactPoint* cp);
 486 };




 345 //  - adjust_obj_size  and adjust_pointers()
 346 //  - obj_size         and compact().
 347 //
 348 // Additionally, this also means that changes to block_size() or block_is_obj() that
 349 // should be effective during the compaction operations must provide a corresponding
 350 // definition of scanned_block_size/scanned_block_is_obj respectively.
 351 class CompactibleSpace: public Space {
 352   friend class VMStructs;
 353   friend class CompactibleFreeListSpace;
 354 private:
 355   HeapWord* _compaction_top;
 356   CompactibleSpace* _next_compaction_space;
 357 
 358   // Auxiliary functions for scan_and_{forward,adjust_pointers,compact} support.
 359   inline size_t adjust_obj_size(size_t size) const {
 360     return size;
 361   }
 362 
 363   inline size_t obj_size(const HeapWord* addr) const;
 364 
 365   template <class SpaceType>
 366   static inline void verify_up_to_first_dead(SpaceType* space) NOT_DEBUG_RETURN;
 367 
 368   template <class SpaceType>
 369   static inline void clear_empty_region(SpaceType* space);
 370 
 371 public:
 372   CompactibleSpace() :
 373    _compaction_top(NULL), _next_compaction_space(NULL) {}
 374 
 375   virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space);
 376   virtual void clear(bool mangle_space);
 377 
 378   // Used temporarily during a compaction phase to hold the value
 379   // top should have when compaction is complete.
 380   HeapWord* compaction_top() const { return _compaction_top;    }
 381 
 382   void set_compaction_top(HeapWord* value) {
 383     assert(value == NULL || (value >= bottom() && value <= end()),
 384       "should point inside space");
 385     _compaction_top = value;
 386   }
 387 
 388   // Perform operations on the space needed after a compaction
 389   // has been performed.
 390   virtual void reset_after_compaction() = 0;


 443   virtual HeapWord* forward(oop q, size_t size, CompactPoint* cp,
 444                     HeapWord* compact_top);
 445 
 446   // Return a size with adjustments as required of the space.
 447   virtual size_t adjust_object_size_v(size_t size) const { return size; }
 448 
 449 protected:
 450   // Used during compaction.
 451   HeapWord* _first_dead;
 452   HeapWord* _end_of_live;
 453 
 454   // Minimum size of a free block.
 455   virtual size_t minimum_free_block_size() const { return 0; }
 456 
 457   // This the function is invoked when an allocation of an object covering
 458   // "start" to "end occurs crosses the threshold; returns the next
 459   // threshold.  (The default implementation does nothing.)
 460   virtual HeapWord* cross_threshold(HeapWord* start, HeapWord* the_end) {
 461     return end();
 462   }










 463 
 464   // Below are template functions for scan_and_* algorithms (avoiding virtual calls).
 465   // The space argument should be a subclass of CompactibleSpace, implementing
 466   // scan_limit(), scanned_block_is_obj(), and scanned_block_size(),
 467   // and possibly also overriding obj_size(), and adjust_obj_size().
 468   // These functions should avoid virtual calls whenever possible.
 469 
 470   // Frequently calls adjust_obj_size().
 471   template <class SpaceType>
 472   static inline void scan_and_adjust_pointers(SpaceType* space);
 473 
 474   // Frequently calls obj_size().
 475   template <class SpaceType>
 476   static inline void scan_and_compact(SpaceType* space);
 477 
 478   // Frequently calls scanned_block_is_obj() and scanned_block_size().
 479   // Requires the scan_limit() function.
 480   template <class SpaceType>
 481   static inline void scan_and_forward(SpaceType* space, CompactPoint* cp);
 482 };


< prev index next >