< prev index next >

src/share/vm/gc_implementation/g1/g1PageBasedVirtualSpace.hpp

Print this page
rev 7993 : imported patch per-comments


  32 
  33 // Virtual space management helper for a virtual space with an OS page allocation
  34 // granularity.
  35 // (De-)Allocation requests are always OS page aligned by passing a page index
  36 // and multiples of pages.
  37 // For systems that only commits of memory in a given size (always greater than
  38 // page size) the base address is required to be aligned to that commit size.
  39 // The actual size requested need not be aligned to the commit size, but the size
  40 // of the reservation passed may be rounded up to the commit size. Any fragment
  41 // (less than the commit size) of the actual size at the tail of the request will
  42 // be committed using OS small pages.
  43 // The implementation gives an error when trying to commit or uncommit pages that
  44 // have already been committed or uncommitted.
  45 class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC {
  46   friend class VMStructs;
  47  private:
  48   // Reserved area addresses.
  49   char* _low_boundary;
  50   char* _high_boundary;
  51 
  52   // The preferred commit/uncommit granularity in bytes.
  53   size_t _commit_size;
  54 
  55   // Bitmap used for verification of commit/uncommit operations.
  56   BitMap _committed;
  57 
  58   // Bitmap used to keep track of which pages are dirty or not for _special
  59   // spaces. This is needed because for those spaces the underlying memory
  60   // will only be zero filled the first time it is committed. Calls to commit
  61   // will use this bitmap and return whether or not the memory is zero filled.
  62   BitMap _dirty;
  63 
  64   // Indicates that the entire space has been committed and pinned in memory,
  65   // os::commit_memory() or os::uncommit_memory() have no function.
  66   bool _special;
  67 
  68   // Indicates whether the committed space should be executable.
  69   bool _executable;
  70 
  71   // Commit the given memory range by using _commit_size pages as much as possible
  72   // and the remainder with small sized pages. The start address must be _commit_size
  73   // aligned.
  74   void commit_internal(char* start, char* end);






  75   // Uncommit the given memory range.
  76   void uncommit_internal(char* start, char* end);



  77 
  78   // Returns the index of the page which contains the given address.
  79   uintptr_t  addr_to_page_index(char* addr) const;
  80   // Returns the address of the given page index.
  81   char*  page_start(uintptr_t index);
  82   // Returns the address of the end of the page given the page index ranging
  83   // from 0..size_in_pages-2. For the last page, return _high_boundary.
  84   char*  page_end(uintptr_t index);






  85 
  86   // Returns true if the entire area is backed by committed memory.
  87   bool is_area_committed(uintptr_t start, size_t size_in_pages) const;
  88   // Returns true if the entire area is not backed by committed memory.
  89   bool is_area_uncommitted(uintptr_t start, size_t size_in_pages) const;
  90 

  91  public:
  92 
  93   // Commit the given area of pages starting at start being size_in_pages large.
  94   // Returns true if the given area is zero filled upon completion.
  95   bool commit(uintptr_t start, size_t size_in_pages);
  96 
  97   // Uncommit the given area of pages starting at start being size_in_pages large.
  98   void uncommit(uintptr_t start, size_t size_in_pages);
  99 
 100   // Initialization
 101   G1PageBasedVirtualSpace();
 102   // Initialize the given reserved space with the given base address and actual size.
 103   // Prefer to commit in commit_size chunks.
 104   bool initialize_with_granularity(ReservedSpace rs, size_t actual_size, size_t commit_size);
 105 
 106   // Destruction
 107   ~G1PageBasedVirtualSpace();
 108 
 109   // Amount of reserved memory.
 110   size_t reserved_size() const;
 111   // Memory used in this virtual space.
 112   size_t committed_size() const;
 113   // Memory left to use/expand in this virtual space.
 114   size_t uncommitted_size() const;
 115 
 116   bool contains(const void* p) const;
 117 
 118   MemRegion reserved() {
 119     MemRegion x((HeapWord*)_low_boundary, reserved_size() / HeapWordSize);
 120     return x;
 121   }
 122 
 123   void release();
 124 


  32 
  33 // Virtual space management helper for a virtual space with an OS page allocation
  34 // granularity.
  35 // (De-)Allocation requests are always OS page aligned by passing a page index
  36 // and multiples of pages.
  37 // For systems that only commits of memory in a given size (always greater than
  38 // page size) the base address is required to be aligned to that commit size.
  39 // The actual size requested need not be aligned to the commit size, but the size
  40 // of the reservation passed may be rounded up to the commit size. Any fragment
  41 // (less than the commit size) of the actual size at the tail of the request will
  42 // be committed using OS small pages.
  43 // The implementation gives an error when trying to commit or uncommit pages that
  44 // have already been committed or uncommitted.
  45 class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC {
  46   friend class VMStructs;
  47  private:
  48   // Reserved area addresses.
  49   char* _low_boundary;
  50   char* _high_boundary;
  51 
  52   // The preferred page size used for commit/uncommit in bytes.
  53   size_t _page_size;
  54 
  55   // Bitmap used for verification of commit/uncommit operations.
  56   BitMap _committed;
  57 
  58   // Bitmap used to keep track of which pages are dirty or not for _special
  59   // spaces. This is needed because for those spaces the underlying memory
  60   // will only be zero filled the first time it is committed. Calls to commit
  61   // will use this bitmap and return whether or not the memory is zero filled.
  62   BitMap _dirty;
  63 
  64   // Indicates that the entire space has been committed and pinned in memory,
  65   // os::commit_memory() or os::uncommit_memory() have no function.
  66   bool _special;
  67 
  68   // Indicates whether the committed space should be executable.
  69   bool _executable;
  70 
  71   // Commit the given memory range by using _page_size pages as much as possible
  72   // and the remainder with small sized pages. The start address must be _page_size
  73   // aligned.
  74   void commit_internal(size_t start_page, size_t end_page);
  75   // Commit num_pages full pages of _page_size size starting from start. All argument
  76   // checking has been performed.
  77   void commit_full_pages(size_t start_page, size_t end_page);
  78   // Commit the tail area.
  79   void commit_tail();
  80 
  81   // Uncommit the given memory range.
  82   void uncommit_internal(size_t start_page, size_t end_page);
  83 
  84   // Pretouch the given memory range.
  85   void pretouch_internal(size_t start_page, size_t end_page);
  86 
  87   // Returns the index of the page which contains the given address.
  88   uintptr_t  addr_to_page_index(char* addr) const;
  89   // Returns the address of the given page index.
  90   char*  page_start(size_t index);
  91 
  92   // Is the given page index the last page?
  93   bool is_last_page(size_t index) { return index == (_committed.size() - 1); }
  94   // Is the given page index the first after last page?
  95   bool is_after_last_page(size_t index);
  96   // Is the last page only partially covered by this space?
  97   bool is_last_page_partial() { return !is_ptr_aligned(_high_boundary, _page_size); }
  98   // Returns the end address of the given page bounded by the reserved space.
  99   char* bounded_end_addr(size_t end_page);
 100  
 101   // Returns true if the entire area is backed by committed memory.
 102   bool is_area_committed(size_t start, size_t size_in_pages) const;
 103   // Returns true if the entire area is not backed by committed memory.
 104   bool is_area_uncommitted(size_t start, size_t size_in_pages) const;
 105 
 106   void initialize_with_page_size(ReservedSpace rs, size_t used_size, size_t page_size);
 107  public:
 108 
 109   // Commit the given area of pages starting at start being size_in_pages large.
 110   // Returns true if the given area is zero filled upon completion.
 111   bool commit(size_t start, size_t size_in_pages);
 112 
 113   // Uncommit the given area of pages starting at start being size_in_pages large.
 114   void uncommit(size_t start, size_t size_in_pages);
 115 
 116   // Initialize the given reserved space with the given base address and the size
 117   // actually used.
 118   // Prefer to commit in page_size chunks.
 119   G1PageBasedVirtualSpace(ReservedSpace rs, size_t used_size, size_t page_size);

 120 
 121   // Destruction
 122   ~G1PageBasedVirtualSpace();
 123 
 124   // Amount of reserved memory.
 125   size_t reserved_size() const;
 126   // Memory used in this virtual space.
 127   size_t committed_size() const;
 128   // Memory left to use/expand in this virtual space.
 129   size_t uncommitted_size() const;
 130 
 131   bool contains(const void* p) const;
 132 
 133   MemRegion reserved() {
 134     MemRegion x((HeapWord*)_low_boundary, reserved_size() / HeapWordSize);
 135     return x;
 136   }
 137 
 138   void release();
 139 
< prev index next >