< prev index next >

src/share/vm/memory/space.hpp

Print this page
rev 7209 : [mq]: inccms


  24 
  25 #ifndef SHARE_VM_MEMORY_SPACE_HPP
  26 #define SHARE_VM_MEMORY_SPACE_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "memory/blockOffsetTable.hpp"
  30 #include "memory/cardTableModRefBS.hpp"
  31 #include "memory/iterator.hpp"
  32 #include "memory/memRegion.hpp"
  33 #include "memory/watermark.hpp"
  34 #include "oops/markOop.hpp"
  35 #include "runtime/mutexLocker.hpp"
  36 #include "utilities/macros.hpp"
  37 #include "utilities/workgroup.hpp"
  38 
  39 // A space is an abstraction for the "storage units" backing
  40 // up the generation abstraction. It includes specific
  41 // implementations for keeping track of free and used space,
  42 // for iterating over objects and free blocks, etc.
  43 
  44 // Here's the Space hierarchy:
  45 //
  46 // - Space               -- an abstract base class describing a heap area
  47 //   - CompactibleSpace  -- a space supporting compaction
  48 //     - CompactibleFreeListSpace -- (used for CMS generation)
  49 //     - ContiguousSpace -- a compactible space in which all free space
  50 //                          is contiguous
  51 //       - EdenSpace     -- contiguous space used as nursery
  52 //         - ConcEdenSpace -- contiguous space with a 'soft end safe' allocation
  53 //       - OffsetTableContigSpace -- contiguous space with a block offset array
  54 //                          that allows "fast" block_start calls
  55 //         - TenuredSpace -- (used for TenuredGeneration)
  56 
  57 // Forward decls.
  58 class Space;
  59 class BlockOffsetArray;
  60 class BlockOffsetArrayContigSpace;
  61 class Generation;
  62 class CompactibleSpace;
  63 class BlockOffsetTable;
  64 class GenRemSet;
  65 class CardTableRS;
  66 class DirtyCardToOopClosure;
  67 
  68 // A Space describes a heap area. Class Space is an abstract
  69 // base class.
  70 //
  71 // Space supports allocation, size computation and GC support is provided.
  72 //
  73 // Invariant: bottom() and end() are on page_size boundaries and
  74 // bottom() <= top() <= end()
  75 // top() is inclusive and end() is exclusive.
  76 


 450   bool insert_deadspace(size_t& allowed_deadspace_words, HeapWord* q,
 451                         size_t word_len);
 452 };
 453 
 454 class GenSpaceMangler;
 455 
 456 // A space in which the free area is contiguous.  It therefore supports
 457 // faster allocation, and compaction.
 458 class ContiguousSpace: public CompactibleSpace {
 459   friend class OneContigSpaceCardGeneration;
 460   friend class VMStructs;
 461  protected:
 462   HeapWord* _top;
 463   HeapWord* _concurrent_iteration_safe_limit;
 464   // A helper for mangling the unused area of the space in debug builds.
 465   GenSpaceMangler* _mangler;
 466 
 467   GenSpaceMangler* mangler() { return _mangler; }
 468 
 469   // Allocation helpers (return NULL if full).
 470   inline HeapWord* allocate_impl(size_t word_size, HeapWord* end_value);
 471   inline HeapWord* par_allocate_impl(size_t word_size, HeapWord* end_value);
 472 
 473  public:
 474   ContiguousSpace();
 475   ~ContiguousSpace();
 476 
 477   virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space);
 478   virtual void clear(bool mangle_space);
 479 
 480   // Accessors
 481   HeapWord* top() const            { return _top;    }
 482   void set_top(HeapWord* value)    { _top = value; }
 483 
 484   void set_saved_mark()            { _saved_mark_word = top();    }
 485   void reset_saved_mark()          { _saved_mark_word = bottom(); }
 486 
 487   WaterMark bottom_mark()     { return WaterMark(this, bottom()); }
 488   WaterMark top_mark()        { return WaterMark(this, top()); }
 489   WaterMark saved_mark()      { return WaterMark(this, saved_mark_word()); }
 490   bool saved_mark_at_top() const { return saved_mark_word() == top(); }
 491 


 667 
 668 class ContiguousSpaceDCTOC : public Filtering_DCTOC {
 669 protected:
 670   // Overrides.
 671   HeapWord* get_actual_top(HeapWord* top, HeapWord* top_obj);
 672 
 673   virtual void walk_mem_region_with_cl(MemRegion mr,
 674                                        HeapWord* bottom, HeapWord* top,
 675                                        ExtendedOopClosure* cl);
 676   virtual void walk_mem_region_with_cl(MemRegion mr,
 677                                        HeapWord* bottom, HeapWord* top,
 678                                        FilteringClosure* cl);
 679 
 680 public:
 681   ContiguousSpaceDCTOC(ContiguousSpace* sp, ExtendedOopClosure* cl,
 682                        CardTableModRefBS::PrecisionStyle precision,
 683                        HeapWord* boundary) :
 684     Filtering_DCTOC(sp, cl, precision, boundary)
 685   {}
 686 };
 687 
 688 
 689 // Class EdenSpace describes eden-space in new generation.
 690 
 691 class DefNewGeneration;
 692 
 693 class EdenSpace : public ContiguousSpace {
 694   friend class VMStructs;
 695  private:
 696   DefNewGeneration* _gen;
 697 
 698   // _soft_end is used as a soft limit on allocation.  As soft limits are
 699   // reached, the slow-path allocation code can invoke other actions and then
 700   // adjust _soft_end up to a new soft limit or to end().
 701   HeapWord* _soft_end;
 702 
 703  public:
 704   EdenSpace(DefNewGeneration* gen) :
 705    _gen(gen), _soft_end(NULL) {}
 706 
 707   // Get/set just the 'soft' limit.
 708   HeapWord* soft_end()               { return _soft_end; }
 709   HeapWord** soft_end_addr()         { return &_soft_end; }
 710   void set_soft_end(HeapWord* value) { _soft_end = value; }
 711 
 712   // Override.
 713   void clear(bool mangle_space);
 714 
 715   // Set both the 'hard' and 'soft' limits (_end and _soft_end).
 716   void set_end(HeapWord* value) {
 717     set_soft_end(value);
 718     ContiguousSpace::set_end(value);
 719   }
 720 
 721   // Allocation (return NULL if full)
 722   HeapWord* allocate(size_t word_size);
 723   HeapWord* par_allocate(size_t word_size);
 724 };
 725 
 726 // Class ConcEdenSpace extends EdenSpace for the sake of safe
 727 // allocation while soft-end is being modified concurrently
 728 
 729 class ConcEdenSpace : public EdenSpace {
 730  public:
 731   ConcEdenSpace(DefNewGeneration* gen) : EdenSpace(gen) { }
 732 
 733   // Allocation (return NULL if full)
 734   HeapWord* par_allocate(size_t word_size);
 735 };
 736 
 737 
 738 // A ContigSpace that Supports an efficient "block_start" operation via
 739 // a BlockOffsetArray (whose BlockOffsetSharedArray may be shared with
 740 // other spaces.)  This is the abstract base class for old generation
 741 // (tenured) spaces.
 742 
 743 class OffsetTableContigSpace: public ContiguousSpace {
 744   friend class VMStructs;
 745  protected:
 746   BlockOffsetArrayContigSpace _offsets;
 747   Mutex _par_alloc_lock;
 748 
 749  public:
 750   // Constructor
 751   OffsetTableContigSpace(BlockOffsetSharedArray* sharedOffsetArray,
 752                          MemRegion mr);
 753 
 754   void set_bottom(HeapWord* value);
 755   void set_end(HeapWord* value);
 756 




  24 
  25 #ifndef SHARE_VM_MEMORY_SPACE_HPP
  26 #define SHARE_VM_MEMORY_SPACE_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "memory/blockOffsetTable.hpp"
  30 #include "memory/cardTableModRefBS.hpp"
  31 #include "memory/iterator.hpp"
  32 #include "memory/memRegion.hpp"
  33 #include "memory/watermark.hpp"
  34 #include "oops/markOop.hpp"
  35 #include "runtime/mutexLocker.hpp"
  36 #include "utilities/macros.hpp"
  37 #include "utilities/workgroup.hpp"
  38 
  39 // A space is an abstraction for the "storage units" backing
  40 // up the generation abstraction. It includes specific
  41 // implementations for keeping track of free and used space,
  42 // for iterating over objects and free blocks, etc.
  43 













  44 // Forward decls.
  45 class Space;
  46 class BlockOffsetArray;
  47 class BlockOffsetArrayContigSpace;
  48 class Generation;
  49 class CompactibleSpace;
  50 class BlockOffsetTable;
  51 class GenRemSet;
  52 class CardTableRS;
  53 class DirtyCardToOopClosure;
  54 
  55 // A Space describes a heap area. Class Space is an abstract
  56 // base class.
  57 //
  58 // Space supports allocation, size computation and GC support is provided.
  59 //
  60 // Invariant: bottom() and end() are on page_size boundaries and
  61 // bottom() <= top() <= end()
  62 // top() is inclusive and end() is exclusive.
  63 


 437   bool insert_deadspace(size_t& allowed_deadspace_words, HeapWord* q,
 438                         size_t word_len);
 439 };
 440 
 441 class GenSpaceMangler;
 442 
 443 // A space in which the free area is contiguous.  It therefore supports
 444 // faster allocation, and compaction.
 445 class ContiguousSpace: public CompactibleSpace {
 446   friend class OneContigSpaceCardGeneration;
 447   friend class VMStructs;
 448  protected:
 449   HeapWord* _top;
 450   HeapWord* _concurrent_iteration_safe_limit;
 451   // A helper for mangling the unused area of the space in debug builds.
 452   GenSpaceMangler* _mangler;
 453 
 454   GenSpaceMangler* mangler() { return _mangler; }
 455 
 456   // Allocation helpers (return NULL if full).
 457   inline HeapWord* allocate_impl(size_t word_size);
 458   inline HeapWord* par_allocate_impl(size_t word_size);
 459 
 460  public:
 461   ContiguousSpace();
 462   ~ContiguousSpace();
 463 
 464   virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space);
 465   virtual void clear(bool mangle_space);
 466 
 467   // Accessors
 468   HeapWord* top() const            { return _top;    }
 469   void set_top(HeapWord* value)    { _top = value; }
 470 
 471   void set_saved_mark()            { _saved_mark_word = top();    }
 472   void reset_saved_mark()          { _saved_mark_word = bottom(); }
 473 
 474   WaterMark bottom_mark()     { return WaterMark(this, bottom()); }
 475   WaterMark top_mark()        { return WaterMark(this, top()); }
 476   WaterMark saved_mark()      { return WaterMark(this, saved_mark_word()); }
 477   bool saved_mark_at_top() const { return saved_mark_word() == top(); }
 478 


 654 
 655 class ContiguousSpaceDCTOC : public Filtering_DCTOC {
 656 protected:
 657   // Overrides.
 658   HeapWord* get_actual_top(HeapWord* top, HeapWord* top_obj);
 659 
 660   virtual void walk_mem_region_with_cl(MemRegion mr,
 661                                        HeapWord* bottom, HeapWord* top,
 662                                        ExtendedOopClosure* cl);
 663   virtual void walk_mem_region_with_cl(MemRegion mr,
 664                                        HeapWord* bottom, HeapWord* top,
 665                                        FilteringClosure* cl);
 666 
 667 public:
 668   ContiguousSpaceDCTOC(ContiguousSpace* sp, ExtendedOopClosure* cl,
 669                        CardTableModRefBS::PrecisionStyle precision,
 670                        HeapWord* boundary) :
 671     Filtering_DCTOC(sp, cl, precision, boundary)
 672   {}
 673 };


















































 674 
 675 // A ContigSpace that Supports an efficient "block_start" operation via
 676 // a BlockOffsetArray (whose BlockOffsetSharedArray may be shared with
 677 // other spaces.)  This is the abstract base class for old generation
 678 // (tenured) spaces.
 679 
 680 class OffsetTableContigSpace: public ContiguousSpace {
 681   friend class VMStructs;
 682  protected:
 683   BlockOffsetArrayContigSpace _offsets;
 684   Mutex _par_alloc_lock;
 685 
 686  public:
 687   // Constructor
 688   OffsetTableContigSpace(BlockOffsetSharedArray* sharedOffsetArray,
 689                          MemRegion mr);
 690 
 691   void set_bottom(HeapWord* value);
 692   void set_end(HeapWord* value);
 693 


< prev index next >