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 // We only support reservations which base address is aligned to a given commit
38 // size. The length of the area managed need not commit size aligned (but OS default
39 // page size aligned) because some OSes cannot provide a an os_commit_size aligned
40 // reservation without also being size-aligned. Any tail area is committed using OS
41 // small pages.
42 // The implementation gives an error when trying to commit or uncommit pages that
43 // have already been committed or uncommitted.
44 class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC {
45 friend class VMStructs;
46 private:
47 // Reserved area addresses.
48 char* _low_boundary;
49 char* _high_boundary;
50
51 // The preferred commit/uncommit granularity in bytes.
52 size_t _commit_size;
53
54 // Bitmap used for verification of commit/uncommit operations.
55 BitMap _committed;
56
57 // Bitmap used to keep track of which pages are dirty or not for _special
58 // spaces. This is needed because for those spaces the underlying memory
59 // will only be zero filled the first time it is committed. Calls to commit
60 // will use this bitmap and return whether or not the memory is zero filled.
61 BitMap _dirty;
62
63 // Indicates that the entire space has been committed and pinned in memory,
64 // os::commit_memory() or os::uncommit_memory() have no function.
65 bool _special;
66
67 // Indicates whether the committed space should be executable.
68 bool _executable;
69
70 // Commit the given memory range by using _commit_size pages as much as possible
71 // and the remainder with small sized pages. The start address must be _commit_size
72 // aligned.
73 void commit_int(char* start, char* end);
74 // Uncommit the given memory range.
75 void uncommit_int(char* start, char* end);
76
77 // Returns the index of the page which contains the given address.
78 uintptr_t addr_to_page_index(char* addr) const;
79 // Returns the address of the given page index.
80 char* page_start(uintptr_t index);
81 // Returns the address of the given page index ranging from 0..size_in_pages-1.
82 char* page_end(uintptr_t index);
83
84 // Returns true if the entire area is backed by committed memory.
85 bool is_area_committed(uintptr_t start, size_t size_in_pages) const;
86 // Returns true if the entire area is not backed by committed memory.
87 bool is_area_uncommitted(uintptr_t start, size_t size_in_pages) const;
88
89 public:
90
91 // Commit the given area of pages starting at start being size_in_pages large.
92 // Returns true if the given area is zero filled upon completion.
93 bool commit(uintptr_t start, size_t size_in_pages);
94
95 // Uncommit the given area of pages starting at start being size_in_pages large.
96 void uncommit(uintptr_t start, size_t size_in_pages);
97
98 // Initialization
99 G1PageBasedVirtualSpace();
100 // Initialize the given reserved space with the given base address and actual size.
101 // Prefer to commit in commit_size chunks.
|
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 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.
|