Thu, 15 Nov 2012 14:29:28 -0800
Merge
1.1 --- a/src/share/vm/memory/binaryTreeDictionary.cpp Wed Nov 14 10:13:51 2012 -0800 1.2 +++ b/src/share/vm/memory/binaryTreeDictionary.cpp Thu Nov 15 14:29:28 2012 -0800 1.3 @@ -239,7 +239,7 @@ 1.4 } else { 1.5 if (nextTC == NULL) { 1.6 // Removing chunk at tail of list 1.7 - link_tail(prevFC); 1.8 + this->link_tail(prevFC); 1.9 } 1.10 // Chunk is interior to the list 1.11 prevFC->link_after(nextTC); 1.12 @@ -296,7 +296,7 @@ 1.13 1.14 Chunk_t* fc = tail(); 1.15 fc->link_after(chunk); 1.16 - link_tail(chunk); 1.17 + this->link_tail(chunk); 1.18 1.19 assert(!tail() || size() == tail()->size(), "Wrong sized chunk in list"); 1.20 FreeList_t<Chunk_t>::increment_count(); 1.21 @@ -323,7 +323,7 @@ 1.22 chunk->link_after(fc); 1.23 } else { 1.24 assert(tail() == NULL, "List is inconsistent"); 1.25 - link_tail(chunk); 1.26 + this->link_tail(chunk); 1.27 } 1.28 head()->link_after(chunk); 1.29 assert(!head() || size() == head()->size(), "Wrong sized chunk in list"); 1.30 @@ -940,7 +940,7 @@ 1.31 void do_tree(TreeList<Chunk_t, FreeList_t>* tl) { 1.32 if (tl != NULL) { 1.33 do_tree(tl->left()); 1.34 - do_list(tl); 1.35 + this->do_list(tl); 1.36 do_tree(tl->right()); 1.37 } 1.38 } 1.39 @@ -952,7 +952,7 @@ 1.40 void do_tree(TreeList<Chunk_t, FreeList_t>* tl) { 1.41 if (tl != NULL) { 1.42 do_tree(tl->right()); 1.43 - do_list(tl); 1.44 + this->do_list(tl); 1.45 do_tree(tl->left()); 1.46 } 1.47 } 1.48 @@ -1022,7 +1022,7 @@ 1.49 bool do_tree(TreeList<Chunk_t, FreeList_t>* tl) { 1.50 if (tl != NULL) { 1.51 if (do_tree(tl->right())) return true; 1.52 - if (do_list(tl)) return true; 1.53 + if (this->do_list(tl)) return true; 1.54 if (do_tree(tl->left())) return true; 1.55 } 1.56 return false;
2.1 --- a/src/share/vm/memory/metaspace.cpp Wed Nov 14 10:13:51 2012 -0800 2.2 +++ b/src/share/vm/memory/metaspace.cpp Thu Nov 15 14:29:28 2012 -0800 2.3 @@ -42,6 +42,10 @@ 2.4 2.5 typedef BinaryTreeDictionary<Metablock, FreeList> BlockTreeDictionary; 2.6 typedef BinaryTreeDictionary<Metachunk, FreeList> ChunkTreeDictionary; 2.7 +// Define this macro to enable slow integrity checking of 2.8 +// the free chunk lists 2.9 +const bool metaspace_slow_verify = false; 2.10 + 2.11 2.12 // Parameters for stress mode testing 2.13 const uint metadata_deallocate_a_lot_block = 10; 2.14 @@ -161,7 +165,17 @@ 2.15 size_t sum_free_chunks_count(); 2.16 2.17 void locked_verify_free_chunks_total(); 2.18 + void slow_locked_verify_free_chunks_total() { 2.19 + if (metaspace_slow_verify) { 2.20 + locked_verify_free_chunks_total(); 2.21 + } 2.22 + } 2.23 void locked_verify_free_chunks_count(); 2.24 + void slow_locked_verify_free_chunks_count() { 2.25 + if (metaspace_slow_verify) { 2.26 + locked_verify_free_chunks_count(); 2.27 + } 2.28 + } 2.29 void verify_free_chunks_count(); 2.30 2.31 public: 2.32 @@ -201,7 +215,17 @@ 2.33 2.34 // Debug support 2.35 void verify(); 2.36 + void slow_verify() { 2.37 + if (metaspace_slow_verify) { 2.38 + verify(); 2.39 + } 2.40 + } 2.41 void locked_verify(); 2.42 + void slow_locked_verify() { 2.43 + if (metaspace_slow_verify) { 2.44 + locked_verify(); 2.45 + } 2.46 + } 2.47 void verify_free_chunks_total(); 2.48 2.49 void locked_print_free_chunks(outputStream* st); 2.50 @@ -1507,7 +1531,7 @@ 2.51 if (!UseConcMarkSweepGC && !SpaceManager::expand_lock()->is_locked()) { 2.52 MutexLockerEx cl(SpaceManager::expand_lock(), 2.53 Mutex::_no_safepoint_check_flag); 2.54 - locked_verify_free_chunks_total(); 2.55 + slow_locked_verify_free_chunks_total(); 2.56 } 2.57 #endif 2.58 return _free_chunks_total; 2.59 @@ -1524,10 +1548,10 @@ 2.60 Mutex::_no_safepoint_check_flag); 2.61 // This lock is only needed in debug because the verification 2.62 // of the _free_chunks_totals walks the list of free chunks 2.63 - locked_verify_free_chunks_count(); 2.64 + slow_locked_verify_free_chunks_count(); 2.65 } 2.66 #endif 2.67 - return _free_chunks_count; 2.68 + return _free_chunks_count; 2.69 } 2.70 2.71 void ChunkManager::locked_verify_free_chunks_total() { 2.72 @@ -1561,14 +1585,9 @@ 2.73 } 2.74 2.75 void ChunkManager::verify() { 2.76 -#ifdef ASSERT 2.77 - if (!UseConcMarkSweepGC) { 2.78 - MutexLockerEx cl(SpaceManager::expand_lock(), 2.79 - Mutex::_no_safepoint_check_flag); 2.80 - locked_verify_free_chunks_total(); 2.81 - locked_verify_free_chunks_count(); 2.82 - } 2.83 -#endif 2.84 + MutexLockerEx cl(SpaceManager::expand_lock(), 2.85 + Mutex::_no_safepoint_check_flag); 2.86 + locked_verify(); 2.87 } 2.88 2.89 void ChunkManager::locked_verify() { 2.90 @@ -1642,7 +1661,7 @@ 2.91 free_list->set_head(chunk); 2.92 // chunk is being returned to the chunk free list 2.93 inc_free_chunks_total(chunk->capacity_word_size()); 2.94 - locked_verify(); 2.95 + slow_locked_verify(); 2.96 } 2.97 2.98 void ChunkManager::chunk_freelist_deallocate(Metachunk* chunk) { 2.99 @@ -1650,8 +1669,8 @@ 2.100 // manangement code for a Metaspace and does not hold the 2.101 // lock. 2.102 assert(chunk != NULL, "Deallocating NULL"); 2.103 - // MutexLockerEx fcl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); 2.104 - locked_verify(); 2.105 + assert_lock_strong(SpaceManager::expand_lock()); 2.106 + slow_locked_verify(); 2.107 if (TraceMetadataChunkAllocation) { 2.108 tty->print_cr("ChunkManager::chunk_freelist_deallocate: chunk " 2.109 PTR_FORMAT " size " SIZE_FORMAT, 2.110 @@ -1663,7 +1682,7 @@ 2.111 Metachunk* ChunkManager::free_chunks_get(size_t word_size) { 2.112 assert_lock_strong(SpaceManager::expand_lock()); 2.113 2.114 - locked_verify(); 2.115 + slow_locked_verify(); 2.116 2.117 Metachunk* chunk = NULL; 2.118 if (!SpaceManager::is_humongous(word_size)) { 2.119 @@ -1708,13 +1727,13 @@ 2.120 #endif 2.121 } 2.122 } 2.123 - locked_verify(); 2.124 + slow_locked_verify(); 2.125 return chunk; 2.126 } 2.127 2.128 Metachunk* ChunkManager::chunk_freelist_allocate(size_t word_size) { 2.129 assert_lock_strong(SpaceManager::expand_lock()); 2.130 - locked_verify(); 2.131 + slow_locked_verify(); 2.132 2.133 // Take from the beginning of the list 2.134 Metachunk* chunk = free_chunks_get(word_size); 2.135 @@ -1959,7 +1978,7 @@ 2.136 2.137 ChunkManager* chunk_manager = vs_list()->chunk_manager(); 2.138 2.139 - chunk_manager->locked_verify(); 2.140 + chunk_manager->slow_locked_verify(); 2.141 2.142 if (TraceMetadataChunkAllocation && Verbose) { 2.143 gclog_or_tty->print_cr("~SpaceManager(): " PTR_FORMAT, this); 2.144 @@ -2015,7 +2034,7 @@ 2.145 humongous_chunks = next_humongous_chunks; 2.146 } 2.147 set_chunks_in_use(HumongousIndex, NULL); 2.148 - chunk_manager->locked_verify(); 2.149 + chunk_manager->slow_locked_verify(); 2.150 } 2.151 2.152 void SpaceManager::deallocate(MetaWord* p, size_t word_size) { 2.153 @@ -2330,8 +2349,7 @@ 2.154 ChunkManager* chunk = (mdtype == Metaspace::ClassType) ? 2.155 Metaspace::class_space_list()->chunk_manager() : 2.156 Metaspace::space_list()->chunk_manager(); 2.157 - 2.158 - chunk->verify_free_chunks_total(); 2.159 + chunk->slow_verify(); 2.160 return chunk->free_chunks_total(); 2.161 } 2.162 2.163 @@ -2435,6 +2453,11 @@ 2.164 print_waste(out); 2.165 } 2.166 2.167 +void MetaspaceAux::verify_free_chunks() { 2.168 + Metaspace::space_list()->chunk_manager()->verify(); 2.169 + Metaspace::class_space_list()->chunk_manager()->verify(); 2.170 +} 2.171 + 2.172 // Metaspace methods 2.173 2.174 size_t Metaspace::_first_chunk_word_size = 0;
3.1 --- a/src/share/vm/memory/metaspace.hpp Wed Nov 14 10:13:51 2012 -0800 3.2 +++ b/src/share/vm/memory/metaspace.hpp Thu Nov 15 14:29:28 2012 -0800 3.3 @@ -189,6 +189,7 @@ 3.4 3.5 static void print_waste(outputStream* out); 3.6 static void dump(outputStream* out); 3.7 + static void verify_free_chunks(); 3.8 }; 3.9 3.10 // Metaspace are deallocated when their class loader are GC'ed.
4.1 --- a/src/share/vm/memory/universe.cpp Wed Nov 14 10:13:51 2012 -0800 4.2 +++ b/src/share/vm/memory/universe.cpp Thu Nov 15 14:29:28 2012 -0800 4.3 @@ -1304,6 +1304,8 @@ 4.4 if (!silent) gclog_or_tty->print("cldg "); 4.5 ClassLoaderDataGraph::verify(); 4.6 #endif 4.7 + if (!silent) gclog_or_tty->print("metaspace chunks "); 4.8 + MetaspaceAux::verify_free_chunks(); 4.9 if (!silent) gclog_or_tty->print("hand "); 4.10 JNIHandles::verify(); 4.11 if (!silent) gclog_or_tty->print("C-heap ");