15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #ifndef SHARE_MEMORY_METASPACE_OCCUPANCYMAP_HPP_
27 #define SHARE_MEMORY_METASPACE_OCCUPANCYMAP_HPP_
28
29 #include "memory/allocation.hpp"
30 #include "utilities/debug.hpp"
31 #include "utilities/globalDefinitions.hpp"
32
33
34 namespace metaspace {
35 namespace internals {
36
37 class Metachunk;
38
39 // Helper for Occupancy Bitmap. A type trait to give an all-bits-are-one-unsigned constant.
40 template <typename T> struct all_ones { static const T value; };
41 template <> struct all_ones <uint64_t> { static const uint64_t value = 0xFFFFFFFFFFFFFFFFULL; };
42 template <> struct all_ones <uint32_t> { static const uint32_t value = 0xFFFFFFFF; };
43
44 // The OccupancyMap is a bitmap which, for a given VirtualSpaceNode,
45 // keeps information about
46 // - where a chunk starts
47 // - whether a chunk is in-use or free
48 // A bit in this bitmap represents one range of memory in the smallest
49 // chunk size (SpecializedChunk or ClassSpecializedChunk).
50 class OccupancyMap : public CHeapObj<mtInternal> {
51
52 // The address range this map covers.
53 const MetaWord* const _reference_address;
54 const size_t _word_size;
55
222 return is_any_bit_set_in_region(p, word_size, layer_in_use_map);
223 }
224
225 // Marks the region starting at p with the size word_size as in use
226 // or free, depending on v.
227 void set_region_in_use(MetaWord* p, size_t word_size, bool v) {
228 set_bits_of_region(p, word_size, layer_in_use_map, v);
229 }
230
231 // Verify occupancy map for the address range [from, to).
232 // We need to tell it the address range, because the memory the
233 // occupancy map is covering may not be fully comitted yet.
234 DEBUG_ONLY(void verify(MetaWord* from, MetaWord* to);)
235
236 // Verify that a given chunk is correctly accounted for in the bitmap.
237 DEBUG_ONLY(void verify_for_chunk(Metachunk* chunk);)
238
239 };
240
241 } // namespace metaspace
242 } // namespace internals
243
244 #endif /* SHARE_MEMORY_METASPACE_OCCUPANCYMAP_HPP_ */
|
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #ifndef SHARE_MEMORY_METASPACE_OCCUPANCYMAP_HPP_
27 #define SHARE_MEMORY_METASPACE_OCCUPANCYMAP_HPP_
28
29 #include "memory/allocation.hpp"
30 #include "utilities/debug.hpp"
31 #include "utilities/globalDefinitions.hpp"
32
33
34 namespace metaspace {
35
36 class Metachunk;
37
38 // Helper for Occupancy Bitmap. A type trait to give an all-bits-are-one-unsigned constant.
39 template <typename T> struct all_ones { static const T value; };
40 template <> struct all_ones <uint64_t> { static const uint64_t value = 0xFFFFFFFFFFFFFFFFULL; };
41 template <> struct all_ones <uint32_t> { static const uint32_t value = 0xFFFFFFFF; };
42
43 // The OccupancyMap is a bitmap which, for a given VirtualSpaceNode,
44 // keeps information about
45 // - where a chunk starts
46 // - whether a chunk is in-use or free
47 // A bit in this bitmap represents one range of memory in the smallest
48 // chunk size (SpecializedChunk or ClassSpecializedChunk).
49 class OccupancyMap : public CHeapObj<mtInternal> {
50
51 // The address range this map covers.
52 const MetaWord* const _reference_address;
53 const size_t _word_size;
54
221 return is_any_bit_set_in_region(p, word_size, layer_in_use_map);
222 }
223
224 // Marks the region starting at p with the size word_size as in use
225 // or free, depending on v.
226 void set_region_in_use(MetaWord* p, size_t word_size, bool v) {
227 set_bits_of_region(p, word_size, layer_in_use_map, v);
228 }
229
230 // Verify occupancy map for the address range [from, to).
231 // We need to tell it the address range, because the memory the
232 // occupancy map is covering may not be fully comitted yet.
233 DEBUG_ONLY(void verify(MetaWord* from, MetaWord* to);)
234
235 // Verify that a given chunk is correctly accounted for in the bitmap.
236 DEBUG_ONLY(void verify_for_chunk(Metachunk* chunk);)
237
238 };
239
240 } // namespace metaspace
241
242 #endif /* SHARE_MEMORY_METASPACE_OCCUPANCYMAP_HPP_ */
243
|