< prev index next >

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

Print this page
rev 11970 : imported patch 8157952-parallelize-memory-pretouch


  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1PAGEBASEDVIRTUALSPACE_HPP
  26 #define SHARE_VM_GC_G1_G1PAGEBASEDVIRTUALSPACE_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "memory/memRegion.hpp"
  30 #include "memory/virtualspace.hpp"
  31 #include "utilities/bitMap.hpp"
  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 page size.
  39 // The actual size requested need not be aligned to that page size, but the size
  40 // of the reservation passed may be rounded up to this page size. Any fragment
  41 // (less than the page 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 size of the tail in bytes of the handled space that needs to be committed


  99   bool is_after_last_page(size_t index) const;
 100   // Is the last page only partially covered by this space?
 101   bool is_last_page_partial() const { return !is_ptr_aligned(_high_boundary, _page_size); }
 102   // Returns the end address of the given page bounded by the reserved space.
 103   char* bounded_end_addr(size_t end_page) const;
 104 
 105   // Returns true if the entire area is backed by committed memory.
 106   bool is_area_committed(size_t start_page, size_t size_in_pages) const;
 107   // Returns true if the entire area is not backed by committed memory.
 108   bool is_area_uncommitted(size_t start_page, size_t size_in_pages) const;
 109 
 110   void initialize_with_page_size(ReservedSpace rs, size_t used_size, size_t page_size);
 111  public:
 112 
 113   // Commit the given area of pages starting at start being size_in_pages large.
 114   // Returns true if the given area is zero filled upon completion.
 115   bool commit(size_t start_page, size_t size_in_pages);
 116 
 117   // Uncommit the given area of pages starting at start being size_in_pages large.
 118   void uncommit(size_t start_page, size_t size_in_pages);


 119 
 120   // Initialize the given reserved space with the given base address and the size
 121   // actually used.
 122   // Prefer to commit in page_size chunks.
 123   G1PageBasedVirtualSpace(ReservedSpace rs, size_t used_size, size_t page_size);
 124 
 125   // Destruction
 126   ~G1PageBasedVirtualSpace();
 127 
 128   // Amount of reserved memory.
 129   size_t reserved_size() const;
 130   // Memory used in this virtual space.
 131   size_t committed_size() const;
 132   // Memory left to use/expand in this virtual space.
 133   size_t uncommitted_size() const;
 134 
 135   bool contains(const void* p) const;
 136 
 137   MemRegion reserved() {
 138     MemRegion x((HeapWord*)_low_boundary, reserved_size() / HeapWordSize);


  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1PAGEBASEDVIRTUALSPACE_HPP
  26 #define SHARE_VM_GC_G1_G1PAGEBASEDVIRTUALSPACE_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "memory/memRegion.hpp"
  30 #include "memory/virtualspace.hpp"
  31 #include "utilities/bitMap.hpp"
  32 
  33 class WorkGang;
  34 
  35 // Virtual space management helper for a virtual space with an OS page allocation
  36 // granularity.
  37 // (De-)Allocation requests are always OS page aligned by passing a page index
  38 // and multiples of pages.
  39 // For systems that only commits of memory in a given size (always greater than
  40 // page size) the base address is required to be aligned to that page size.
  41 // The actual size requested need not be aligned to that page size, but the size
  42 // of the reservation passed may be rounded up to this page size. Any fragment
  43 // (less than the page size) of the actual size at the tail of the request will
  44 // be committed using OS small pages.
  45 // The implementation gives an error when trying to commit or uncommit pages that
  46 // have already been committed or uncommitted.
  47 class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC {
  48   friend class VMStructs;
  49  private:
  50   // Reserved area addresses.
  51   char* _low_boundary;
  52   char* _high_boundary;
  53 
  54   // The size of the tail in bytes of the handled space that needs to be committed


 101   bool is_after_last_page(size_t index) const;
 102   // Is the last page only partially covered by this space?
 103   bool is_last_page_partial() const { return !is_ptr_aligned(_high_boundary, _page_size); }
 104   // Returns the end address of the given page bounded by the reserved space.
 105   char* bounded_end_addr(size_t end_page) const;
 106 
 107   // Returns true if the entire area is backed by committed memory.
 108   bool is_area_committed(size_t start_page, size_t size_in_pages) const;
 109   // Returns true if the entire area is not backed by committed memory.
 110   bool is_area_uncommitted(size_t start_page, size_t size_in_pages) const;
 111 
 112   void initialize_with_page_size(ReservedSpace rs, size_t used_size, size_t page_size);
 113  public:
 114 
 115   // Commit the given area of pages starting at start being size_in_pages large.
 116   // Returns true if the given area is zero filled upon completion.
 117   bool commit(size_t start_page, size_t size_in_pages);
 118 
 119   // Uncommit the given area of pages starting at start being size_in_pages large.
 120   void uncommit(size_t start_page, size_t size_in_pages);
 121 
 122   void pretouch(size_t start_page, size_t size_in_pages, WorkGang* pretouch_gang = NULL);
 123 
 124   // Initialize the given reserved space with the given base address and the size
 125   // actually used.
 126   // Prefer to commit in page_size chunks.
 127   G1PageBasedVirtualSpace(ReservedSpace rs, size_t used_size, size_t page_size);
 128 
 129   // Destruction
 130   ~G1PageBasedVirtualSpace();
 131 
 132   // Amount of reserved memory.
 133   size_t reserved_size() const;
 134   // Memory used in this virtual space.
 135   size_t committed_size() const;
 136   // Memory left to use/expand in this virtual space.
 137   size_t uncommitted_size() const;
 138 
 139   bool contains(const void* p) const;
 140 
 141   MemRegion reserved() {
 142     MemRegion x((HeapWord*)_low_boundary, reserved_size() / HeapWordSize);
< prev index next >