Mercurial > hg > truffle
annotate src/share/vm/runtime/virtualspace.hpp @ 677:96b229c54d1e
6543938: G1: remove the concept of popularity
Reviewed-by: iveresov, tonyp
author | apetrusenko |
---|---|
date | Wed, 25 Mar 2009 13:10:54 -0700 |
parents | 660978a2a31a |
children | 6bdd6923ba16 |
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, |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
337
diff
changeset
|
76 char* requested_address, |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
337
diff
changeset
|
77 const size_t noaccess_prefix = 0); |
0 | 78 |
79 // Accessors | |
80 char* base() const { return _base; } | |
81 size_t size() const { return _size; } | |
82 size_t alignment() const { return _alignment; } | |
83 bool special() const { return _special; } | |
84 | |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
85 size_t noaccess_prefix() const { return _noaccess_prefix; } |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
86 |
0 | 87 bool is_reserved() const { return _base != NULL; } |
88 void release(); | |
89 | |
90 // Splitting | |
91 ReservedSpace first_part(size_t partition_size, size_t alignment, | |
92 bool split = false, bool realloc = true); | |
93 ReservedSpace last_part (size_t partition_size, size_t alignment); | |
94 | |
95 // These simply call the above using the default alignment. | |
96 inline ReservedSpace first_part(size_t partition_size, | |
97 bool split = false, bool realloc = true); | |
98 inline ReservedSpace last_part (size_t partition_size); | |
99 | |
100 // Alignment | |
101 static size_t page_align_size_up(size_t size); | |
102 static size_t page_align_size_down(size_t size); | |
103 static size_t allocation_align_size_up(size_t size); | |
104 static size_t allocation_align_size_down(size_t size); | |
105 }; | |
106 | |
107 ReservedSpace | |
108 ReservedSpace::first_part(size_t partition_size, bool split, bool realloc) | |
109 { | |
110 return first_part(partition_size, alignment(), split, realloc); | |
111 } | |
112 | |
113 ReservedSpace ReservedSpace::last_part(size_t partition_size) | |
114 { | |
115 return last_part(partition_size, alignment()); | |
116 } | |
117 | |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
118 // 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
|
119 class ReservedHeapSpace : public ReservedSpace { |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
120 public: |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
121 // Constructor |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
122 ReservedHeapSpace(size_t size, size_t forced_base_alignment, |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
123 bool large, char* requested_address); |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
124 ReservedHeapSpace(const size_t prefix_size, const size_t prefix_align, |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
337
diff
changeset
|
125 const size_t suffix_size, const size_t suffix_align, |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
337
diff
changeset
|
126 char* requested_address); |
237
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
127 }; |
1fdb98a17101
6716785: implicit null checks not triggering with CompressedOops
coleenp
parents:
0
diff
changeset
|
128 |
0 | 129 // VirtualSpace is data structure for committing a previously reserved address range in smaller chunks. |
130 | |
131 class VirtualSpace VALUE_OBJ_CLASS_SPEC { | |
132 friend class VMStructs; | |
133 private: | |
134 // Reserved area | |
135 char* _low_boundary; | |
136 char* _high_boundary; | |
137 | |
138 // Committed area | |
139 char* _low; | |
140 char* _high; | |
141 | |
142 // The entire space has been committed and pinned in memory, no | |
143 // os::commit_memory() or os::uncommit_memory(). | |
144 bool _special; | |
145 | |
146 // MPSS Support | |
147 // Each virtualspace region has a lower, middle, and upper region. | |
148 // Each region has an end boundary and a high pointer which is the | |
149 // high water mark for the last allocated byte. | |
150 // The lower and upper unaligned to LargePageSizeInBytes uses default page. | |
151 // size. The middle region uses large page size. | |
152 char* _lower_high; | |
153 char* _middle_high; | |
154 char* _upper_high; | |
155 | |
156 char* _lower_high_boundary; | |
157 char* _middle_high_boundary; | |
158 char* _upper_high_boundary; | |
159 | |
160 size_t _lower_alignment; | |
161 size_t _middle_alignment; | |
162 size_t _upper_alignment; | |
163 | |
164 // MPSS Accessors | |
165 char* lower_high() const { return _lower_high; } | |
166 char* middle_high() const { return _middle_high; } | |
167 char* upper_high() const { return _upper_high; } | |
168 | |
169 char* lower_high_boundary() const { return _lower_high_boundary; } | |
170 char* middle_high_boundary() const { return _middle_high_boundary; } | |
171 char* upper_high_boundary() const { return _upper_high_boundary; } | |
172 | |
173 size_t lower_alignment() const { return _lower_alignment; } | |
174 size_t middle_alignment() const { return _middle_alignment; } | |
175 size_t upper_alignment() const { return _upper_alignment; } | |
176 | |
177 public: | |
178 // Committed area | |
179 char* low() const { return _low; } | |
180 char* high() const { return _high; } | |
181 | |
182 // Reserved area | |
183 char* low_boundary() const { return _low_boundary; } | |
184 char* high_boundary() const { return _high_boundary; } | |
185 | |
186 bool special() const { return _special; } | |
187 | |
188 public: | |
189 // Initialization | |
190 VirtualSpace(); | |
191 bool initialize(ReservedSpace rs, size_t committed_byte_size); | |
192 | |
193 // Destruction | |
194 ~VirtualSpace(); | |
195 | |
196 // Testers (all sizes are byte sizes) | |
197 size_t committed_size() const; | |
198 size_t reserved_size() const; | |
199 size_t uncommitted_size() const; | |
200 bool contains(const void* p) const; | |
201 | |
202 // Operations | |
203 // returns true on success, false otherwise | |
204 bool expand_by(size_t bytes, bool pre_touch = false); | |
205 void shrink_by(size_t bytes); | |
206 void release(); | |
207 | |
208 void check_for_contiguity() PRODUCT_RETURN; | |
209 | |
210 // Debugging | |
211 void print() PRODUCT_RETURN; | |
212 }; |