equal
deleted
inserted
replaced
53 #include "utilities/macros.hpp" |
53 #include "utilities/macros.hpp" |
54 |
54 |
55 typedef BinaryTreeDictionary<Metablock, FreeList<Metablock> > BlockTreeDictionary; |
55 typedef BinaryTreeDictionary<Metablock, FreeList<Metablock> > BlockTreeDictionary; |
56 typedef BinaryTreeDictionary<Metachunk, FreeList<Metachunk> > ChunkTreeDictionary; |
56 typedef BinaryTreeDictionary<Metachunk, FreeList<Metachunk> > ChunkTreeDictionary; |
57 |
57 |
58 // Set this constant to enable slow integrity checking of the free chunk lists |
|
59 const bool metaspace_slow_verify = false; |
|
60 |
|
61 // Helper function that does a bunch of checks for a chunk. |
58 // Helper function that does a bunch of checks for a chunk. |
62 DEBUG_ONLY(static void do_verify_chunk(Metachunk* chunk);) |
59 DEBUG_ONLY(static void do_verify_chunk(Metachunk* chunk);) |
63 |
60 |
64 // Given a Metachunk, update its in-use information (both in the |
61 // Given a Metachunk, update its in-use information (both in the |
65 // chunk and the occupancy map). |
62 // chunk and the occupancy map). |
205 size_t sum_free_chunks(); |
202 size_t sum_free_chunks(); |
206 size_t sum_free_chunks_count(); |
203 size_t sum_free_chunks_count(); |
207 |
204 |
208 void locked_verify_free_chunks_total(); |
205 void locked_verify_free_chunks_total(); |
209 void slow_locked_verify_free_chunks_total() { |
206 void slow_locked_verify_free_chunks_total() { |
210 if (metaspace_slow_verify) { |
207 if (VerifyMetaspace) { |
211 locked_verify_free_chunks_total(); |
208 locked_verify_free_chunks_total(); |
212 } |
209 } |
213 } |
210 } |
214 void locked_verify_free_chunks_count(); |
211 void locked_verify_free_chunks_count(); |
215 void slow_locked_verify_free_chunks_count() { |
212 void slow_locked_verify_free_chunks_count() { |
216 if (metaspace_slow_verify) { |
213 if (VerifyMetaspace) { |
217 locked_verify_free_chunks_count(); |
214 locked_verify_free_chunks_count(); |
218 } |
215 } |
219 } |
216 } |
220 void verify_free_chunks_count(); |
217 void verify_free_chunks_count(); |
221 |
218 |
344 } |
341 } |
345 |
342 |
346 // Debug support |
343 // Debug support |
347 void verify(); |
344 void verify(); |
348 void slow_verify() { |
345 void slow_verify() { |
349 if (metaspace_slow_verify) { |
346 if (VerifyMetaspace) { |
350 verify(); |
347 verify(); |
351 } |
348 } |
352 } |
349 } |
353 void locked_verify(); |
350 void locked_verify(); |
354 void slow_locked_verify() { |
351 void slow_locked_verify() { |
355 if (metaspace_slow_verify) { |
352 if (VerifyMetaspace) { |
356 locked_verify(); |
353 locked_verify(); |
357 } |
354 } |
358 } |
355 } |
359 void verify_free_chunks_total(); |
356 void verify_free_chunks_total(); |
360 |
357 |
1692 occupancy_map()->set_chunk_starts_at_address((MetaWord*)result, true); |
1689 occupancy_map()->set_chunk_starts_at_address((MetaWord*)result, true); |
1693 do_update_in_use_info_for_chunk(result, true); |
1690 do_update_in_use_info_for_chunk(result, true); |
1694 |
1691 |
1695 inc_container_count(); |
1692 inc_container_count(); |
1696 |
1693 |
1697 if (metaspace_slow_verify) { |
1694 if (VerifyMetaspace) { |
1698 DEBUG_ONLY(chunk_manager->locked_verify()); |
1695 DEBUG_ONLY(chunk_manager->locked_verify()); |
1699 DEBUG_ONLY(this->verify()); |
1696 DEBUG_ONLY(this->verify()); |
1700 } |
1697 } |
1701 |
1698 |
1702 DEBUG_ONLY(do_verify_chunk(result)); |
1699 DEBUG_ONLY(do_verify_chunk(result)); |
1947 // VirtualSpaceNode::container_count does not have to be modified: |
1944 // VirtualSpaceNode::container_count does not have to be modified: |
1948 // it means "number of active (non-free) chunks", so merging free chunks |
1945 // it means "number of active (non-free) chunks", so merging free chunks |
1949 // should not affect that count. |
1946 // should not affect that count. |
1950 |
1947 |
1951 // At the end of a chunk merge, run verification tests. |
1948 // At the end of a chunk merge, run verification tests. |
1952 if (metaspace_slow_verify) { |
1949 if (VerifyMetaspace) { |
1953 DEBUG_ONLY(this->locked_verify()); |
1950 DEBUG_ONLY(this->locked_verify()); |
1954 DEBUG_ONLY(vsn->verify()); |
1951 DEBUG_ONLY(vsn->verify()); |
1955 } |
1952 } |
1956 |
1953 |
1957 return true; |
1954 return true; |
2969 chunk->set_next(NULL); |
2966 chunk->set_next(NULL); |
2970 chunk->set_prev(NULL); |
2967 chunk->set_prev(NULL); |
2971 |
2968 |
2972 // Run some verifications (some more if we did a chunk split) |
2969 // Run some verifications (some more if we did a chunk split) |
2973 #ifdef ASSERT |
2970 #ifdef ASSERT |
2974 if (metaspace_slow_verify) { |
2971 if (VerifyMetaspace) { |
2975 locked_verify(); |
2972 locked_verify(); |
2976 VirtualSpaceNode* const vsn = chunk->container(); |
2973 VirtualSpaceNode* const vsn = chunk->container(); |
2977 vsn->verify(); |
2974 vsn->verify(); |
2978 if (we_did_split_a_chunk) { |
2975 if (we_did_split_a_chunk) { |
2979 vsn->verify_free_chunks_are_ideally_merged(); |
2976 vsn->verify_free_chunks_are_ideally_merged(); |