Mercurial > hg > truffle
annotate src/share/vm/runtime/virtualspace.hpp @ 483:0f773163217d
6765954: par compact - stress mode for splitting young gen spaces
Reviewed-by: jmasa
author | jcoomes |
---|---|
date | Thu, 11 Dec 2008 12:05:21 -0800 |
parents | 9ee9cf798b59 |
children | 660978a2a31a |
rev | line source |
---|---|
0 | 1 /* |
337 | 2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 // ReservedSpace is a data structure for reserving a contiguous address range. | |
26 | |
27 class ReservedSpace VALUE_OBJ_CLASS_SPEC { | |
28 friend class VMStructs; | |
29 private: | |
30 char* _base; | |
31 size_t _size; | |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
32 size_t _noaccess_prefix; |
0 | 33 size_t _alignment; |
34 bool _special; | |
35 | |
36 // ReservedSpace | |
37 ReservedSpace(char* base, size_t size, size_t alignment, bool special); | |
38 void initialize(size_t size, size_t alignment, bool large, | |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
39 char* requested_address, |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
40 const size_t noaccess_prefix); |
0 | 41 |
42 // Release parts of an already-reserved memory region [addr, addr + len) to | |
43 // get a new region that has "compound alignment." Return the start of the | |
44 // resulting region, or NULL on failure. | |
45 // | |
46 // The region is logically divided into a prefix and a suffix. The prefix | |
47 // starts at the result address, which is aligned to prefix_align. The suffix | |
48 // starts at result address + prefix_size, which is aligned to suffix_align. | |
49 // The total size of the result region is size prefix_size + suffix_size. | |
50 char* align_reserved_region(char* addr, const size_t len, | |
51 const size_t prefix_size, | |
52 const size_t prefix_align, | |
53 const size_t suffix_size, | |
54 const size_t suffix_align); | |
55 | |
56 // Reserve memory, call align_reserved_region() to alignment it and return the | |
57 // result. | |
58 char* reserve_and_align(const size_t reserve_size, | |
59 const size_t prefix_size, | |
60 const size_t prefix_align, | |
61 const size_t suffix_size, | |
62 const size_t suffix_align); | |
63 | |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
64 protected: |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
65 // Create protection page at the beginning of the space. |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
66 void protect_noaccess_prefix(const size_t size); |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
67 |
0 | 68 public: |
69 // Constructor | |
70 ReservedSpace(size_t size); | |
71 ReservedSpace(size_t size, size_t alignment, bool large, | |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
72 char* requested_address = NULL, |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
73 const size_t noaccess_prefix = 0); |
0 | 74 ReservedSpace(const size_t prefix_size, const size_t prefix_align, |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
75 const size_t suffix_size, const size_t suffix_align, |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
76 const size_t noaccess_prefix); |
0 | 77 |
78 // Accessors | |
79 char* base() const { return _base; } | |
80 size_t size() const { return _size; } | |
81 size_t alignment() const { return _alignment; } | |
82 bool special() const { return _special; } | |
83 | |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
84 size_t noaccess_prefix() const { return _noaccess_prefix; } |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
85 |
0 | 86 bool is_reserved() const { return _base != NULL; } |
87 void release(); | |
88 | |
89 // Splitting | |
90 ReservedSpace first_part(size_t partition_size, size_t alignment, | |
91 bool split = false, bool realloc = true); | |
92 ReservedSpace last_part (size_t partition_size, size_t alignment); | |
93 | |
94 // These simply call the above using the default alignment. | |
95 inline ReservedSpace first_part(size_t partition_size, | |
96 bool split = false, bool realloc = true); | |
97 inline ReservedSpace last_part (size_t partition_size); | |
98 | |
99 // Alignment | |
100 static size_t page_align_size_up(size_t size); | |
101 static size_t page_align_size_down(size_t size); | |
102 static size_t allocation_align_size_up(size_t size); | |
103 static size_t allocation_align_size_down(size_t size); | |
104 }; | |
105 | |
106 ReservedSpace | |
107 ReservedSpace::first_part(size_t partition_size, bool split, bool realloc) | |
108 { | |
109 return first_part(partition_size, alignment(), split, realloc); | |
110 } | |
111 | |
112 ReservedSpace ReservedSpace::last_part(size_t partition_size) | |
113 { | |
114 return last_part(partition_size, alignment()); | |
115 } | |
116 | |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
117 // Class encapsulating behavior specific of memory space reserved for Java heap |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
118 class ReservedHeapSpace : public ReservedSpace { |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
119 public: |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
120 // Constructor |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
121 ReservedHeapSpace(size_t size, size_t forced_base_alignment, |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
122 bool large, char* requested_address); |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
123 ReservedHeapSpace(const size_t prefix_size, const size_t prefix_align, |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
124 const size_t suffix_size, const size_t suffix_align); |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
125 }; |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
126 |
0 | 127 // VirtualSpace is data structure for committing a previously reserved address range in smaller chunks. |
128 | |
129 class VirtualSpace VALUE_OBJ_CLASS_SPEC { | |
130 friend class VMStructs; | |
131 private: | |
132 // Reserved area | |
133 char* _low_boundary; | |
134 char* _high_boundary; | |
135 | |
136 // Committed area | |
137 char* _low; | |
138 char* _high; | |
139 | |
140 // The entire space has been committed and pinned in memory, no | |
141 // os::commit_memory() or os::uncommit_memory(). | |
142 bool _special; | |
143 | |
144 // MPSS Support | |
145 // Each virtualspace region has a lower, middle, and upper region. | |
146 // Each region has an end boundary and a high pointer which is the | |
147 // high water mark for the last allocated byte. | |
148 // The lower and upper unaligned to LargePageSizeInBytes uses default page. | |
149 // size. The middle region uses large page size. | |
150 char* _lower_high; | |
151 char* _middle_high; | |
152 char* _upper_high; | |
153 | |
154 char* _lower_high_boundary; | |
155 char* _middle_high_boundary; | |
156 char* _upper_high_boundary; | |
157 | |
158 size_t _lower_alignment; | |
159 size_t _middle_alignment; | |
160 size_t _upper_alignment; | |
161 | |
162 // MPSS Accessors | |
163 char* lower_high() const { return _lower_high; } | |
164 char* middle_high() const { return _middle_high; } | |
165 char* upper_high() const { return _upper_high; } | |
166 | |
167 char* lower_high_boundary() const { return _lower_high_boundary; } | |
168 char* middle_high_boundary() const { return _middle_high_boundary; } | |
169 char* upper_high_boundary() const { return _upper_high_boundary; } | |
170 | |
171 size_t lower_alignment() const { return _lower_alignment; } | |
172 size_t middle_alignment() const { return _middle_alignment; } | |
173 size_t upper_alignment() const { return _upper_alignment; } | |
174 | |
175 public: | |
176 // Committed area | |
177 char* low() const { return _low; } | |
178 char* high() const { return _high; } | |
179 | |
180 // Reserved area | |
181 char* low_boundary() const { return _low_boundary; } | |
182 char* high_boundary() const { return _high_boundary; } | |
183 | |
184 bool special() const { return _special; } | |
185 | |
186 public: | |
187 // Initialization | |
188 VirtualSpace(); | |
189 bool initialize(ReservedSpace rs, size_t committed_byte_size); | |
190 | |
191 // Destruction | |
192 ~VirtualSpace(); | |
193 | |
194 // Testers (all sizes are byte sizes) | |
195 size_t committed_size() const; | |
196 size_t reserved_size() const; | |
197 size_t uncommitted_size() const; | |
198 bool contains(const void* p) const; | |
199 | |
200 // Operations | |
201 // returns true on success, false otherwise | |
202 bool expand_by(size_t bytes, bool pre_touch = false); | |
203 void shrink_by(size_t bytes); | |
204 void release(); | |
205 | |
206 void check_for_contiguity() PRODUCT_RETURN; | |
207 | |
208 // Debugging | |
209 void print() PRODUCT_RETURN; | |
210 }; |