< prev index next >

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

Print this page
rev 8048 : 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
Summary: Allow partial use of large pages for auxiliary data structures in G1.
Reviewed-by: jmasa
rev 8049 : imported patch 8058354-stefank-review
rev 8050 : imported patch 8058354-more-stefank-review
rev 8051 : imported patch 8058354-more-more-stefank-review
rev 8052 : imported patch per-comments
rev 8054 : [mq]: jon-comments2


  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_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "memory/memRegion.hpp"
  30 #include "runtime/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 // The implementation gives an error when trying to commit or uncommit pages that
  38 // have already been committed or uncommitted.
  39 class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC {
  40   friend class VMStructs;
  41  private:
  42   // Reserved area addresses.
  43   char* _low_boundary;
  44   char* _high_boundary;
  45 
  46   // The commit/uncommit granularity in bytes.




  47   size_t _page_size;
  48 
  49   // Bitmap used for verification of commit/uncommit operations.
  50   BitMap _committed;
  51 
  52   // Bitmap used to keep track of which pages are dirty or not for _special
  53   // spaces. This is needed because for those spaces the underlying memory
  54   // will only be zero filled the first time it is committed. Calls to commit
  55   // will use this bitmap and return whether or not the memory is zero filled.
  56   BitMap _dirty;
  57 
  58   // Indicates that the entire space has been committed and pinned in memory,
  59   // os::commit_memory() or os::uncommit_memory() have no function.
  60   bool _special;
  61 
  62   // Indicates whether the committed space should be executable.
  63   bool _executable;
  64 
















  65   // Returns the index of the page which contains the given address.
  66   uintptr_t  addr_to_page_index(char* addr) const;
  67   // Returns the address of the given page index.
  68   char*  page_start(uintptr_t index);
  69   // Returns the byte size of the given number of pages.
  70   size_t byte_size_for_pages(size_t num);







  71 
  72   // Returns true if the entire area is backed by committed memory.
  73   bool is_area_committed(uintptr_t start, size_t size_in_pages) const;
  74   // Returns true if the entire area is not backed by committed memory.
  75   bool is_area_uncommitted(uintptr_t start, size_t size_in_pages) const;
  76 

  77  public:
  78 
  79   // Commit the given area of pages starting at start being size_in_pages large.
  80   // Returns true if the given area is zero filled upon completion.
  81   bool commit(uintptr_t start, size_t size_in_pages);
  82 
  83   // Uncommit the given area of pages starting at start being size_in_pages large.
  84   void uncommit(uintptr_t start, size_t size_in_pages);
  85 
  86   // Initialization
  87   G1PageBasedVirtualSpace();
  88   bool initialize_with_granularity(ReservedSpace rs, size_t page_size);

  89 
  90   // Destruction
  91   ~G1PageBasedVirtualSpace();
  92 
  93   // Amount of reserved memory.
  94   size_t reserved_size() const;
  95   // Memory used in this virtual space.
  96   size_t committed_size() const;
  97   // Memory left to use/expand in this virtual space.
  98   size_t uncommitted_size() const;
  99 
 100   bool contains(const void* p) const;
 101 
 102   MemRegion reserved() {
 103     MemRegion x((HeapWord*)_low_boundary, reserved_size() / HeapWordSize);
 104     return x;
 105   }
 106 
 107   void release();
 108 


  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_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "memory/memRegion.hpp"
  30 #include "runtime/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
  53   // using small pages.
  54   size_t _tail_size;
  55 
  56   // The preferred page size used for commit/uncommit in bytes.
  57   size_t _page_size;
  58 
  59   // Bitmap used for verification of commit/uncommit operations.
  60   BitMap _committed;
  61 
  62   // Bitmap used to keep track of which pages are dirty or not for _special
  63   // spaces. This is needed because for those spaces the underlying memory
  64   // will only be zero filled the first time it is committed. Calls to commit
  65   // will use this bitmap and return whether or not the memory is zero filled.
  66   BitMap _dirty;
  67 
  68   // Indicates that the entire space has been committed and pinned in memory,
  69   // os::commit_memory() or os::uncommit_memory() have no function.
  70   bool _special;
  71 
  72   // Indicates whether the committed space should be executable.
  73   bool _executable;
  74 
  75   // Helper function for committing memory. Commit the given memory range by using
  76   // _page_size pages as much as possible and the remainder with small sized pages.
  77   void commit_internal(size_t start_page, size_t end_page);
  78   // Commit num_pages pages of _page_size size starting from start. All argument
  79   // checking has been performed.
  80   void commit_preferred_pages(size_t start_page, size_t end_page);
  81   // Commit space at the high end of the space that needs to be committed with small
  82   // sized pages.
  83   void commit_tail();
  84 
  85   // Uncommit the given memory range.
  86   void uncommit_internal(size_t start_page, size_t end_page);
  87 
  88   // Pretouch the given memory range.
  89   void pretouch_internal(size_t start_page, size_t end_page);
  90 
  91   // Returns the index of the page which contains the given address.
  92   uintptr_t  addr_to_page_index(char* addr) const;
  93   // Returns the address of the given page index.
  94   char*  page_start(size_t index) const;
  95 
  96   // Is the given page index the last page?
  97   bool is_last_page(size_t index) const { return index == (_committed.size() - 1); }
  98   // Is the given page index the first after last page?
  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);
 139     return x;
 140   }
 141 
 142   void release();
 143 
< prev index next >