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 // Indicates that the entire space has been committed and pinned in memory,
53 // os::commit_memory() or os::uncommit_memory() have no function.
54 bool _special;
55
56 // Indicates whether the committed space should be executable.
57 bool _executable;
58
59 // Returns the index of the page which contains the given address.
60 uintptr_t addr_to_page_index(char* addr) const;
61 // Returns the address of the given page index.
62 char* page_start(uintptr_t index);
63 // Returns the byte size of the given number of pages.
64 size_t byte_size_for_pages(size_t num);
65
66 // Returns true if the entire area is backed by committed memory.
67 bool is_area_committed(uintptr_t start, size_t size_in_pages) const;
68 // Returns true if the entire area is not backed by committed memory.
69 bool is_area_uncommitted(uintptr_t start, size_t size_in_pages) const;
70
71 public:
72
73 // Commit the given area of pages starting at start being size_in_pages large.
74 MemRegion commit(uintptr_t start, size_t size_in_pages);
75
76 // Uncommit the given area of pages starting at start being size_in_pages large.
77 MemRegion uncommit(uintptr_t start, size_t size_in_pages);
78
79 bool special() const { return _special; }
80
81 // Initialization
82 G1PageBasedVirtualSpace();
83 bool initialize_with_granularity(ReservedSpace rs, size_t page_size);
84
85 // Destruction
86 ~G1PageBasedVirtualSpace();
87
88 // Amount of reserved memory.
89 size_t reserved_size() const;
90 // Memory used in this virtual space.
91 size_t committed_size() const;
92 // Memory left to use/expand in this virtual space.
93 size_t uncommitted_size() const;
94
95 bool contains(const void* p) const;
96
97 MemRegion reserved() {
98 MemRegion x((HeapWord*)_low_boundary, reserved_size() / HeapWordSize);
99 return x;
|
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 // For _special spaces we need to keep track if the memory needs to be zeroed
53 // after commit or not.
54 BitMap _needs_zeroing;
55
56 // Indicates that the entire space has been committed and pinned in memory,
57 // os::commit_memory() or os::uncommit_memory() have no function.
58 bool _special;
59
60 // Indicates whether the committed space should be executable.
61 bool _executable;
62
63 // Returns the index of the page which contains the given address.
64 uintptr_t addr_to_page_index(char* addr) const;
65 // Returns the address of the given page index.
66 char* page_start(uintptr_t index);
67 // Returns the byte size of the given number of pages.
68 size_t byte_size_for_pages(size_t num);
69
70 // Returns true if the entire area is backed by committed memory.
71 bool is_area_committed(uintptr_t start, size_t size_in_pages) const;
72 // Returns true if the entire area is not backed by committed memory.
73 bool is_area_uncommitted(uintptr_t start, size_t size_in_pages) const;
74
75 public:
76
77 // Commit the given area of pages starting at start being size_in_pages large.
78 // Returns true if the given area is zero filled upon completion.
79 bool commit(uintptr_t start, size_t size_in_pages);
80
81 // Uncommit the given area of pages starting at start being size_in_pages large.
82 void uncommit(uintptr_t start, size_t size_in_pages);
83
84 // Initialization
85 G1PageBasedVirtualSpace();
86 bool initialize_with_granularity(ReservedSpace rs, size_t page_size);
87
88 // Destruction
89 ~G1PageBasedVirtualSpace();
90
91 // Amount of reserved memory.
92 size_t reserved_size() const;
93 // Memory used in this virtual space.
94 size_t committed_size() const;
95 // Memory left to use/expand in this virtual space.
96 size_t uncommitted_size() const;
97
98 bool contains(const void* p) const;
99
100 MemRegion reserved() {
101 MemRegion x((HeapWord*)_low_boundary, reserved_size() / HeapWordSize);
102 return x;
|