src/share/vm/memory/universe.cpp

Print this page




1086 }
1087 
1088 void Universe::print_heap_before_gc() {
1089   LogHandle(gc, heap) log;
1090   if (log.is_trace()) {
1091     log.trace("Heap before GC invocations=%u (full %u):", heap()->total_collections(), heap()->total_full_collections());
1092     ResourceMark rm;
1093     heap()->print_on(log.trace_stream());
1094   }
1095 }
1096 
1097 void Universe::print_heap_after_gc() {
1098   LogHandle(gc, heap) log;
1099   if (log.is_trace()) {
1100     log.trace("Heap after GC invocations=%u (full %u):", heap()->total_collections(), heap()->total_full_collections());
1101     ResourceMark rm;
1102     heap()->print_on(log.trace_stream());
1103   }
1104 }
1105 











1106 void Universe::verify(VerifyOption option, const char* prefix) {
1107   // The use of _verify_in_progress is a temporary work around for
1108   // 6320749.  Don't bother with a creating a class to set and clear
1109   // it since it is only used in this method and the control flow is
1110   // straight forward.
1111   _verify_in_progress = true;
1112 
1113   COMPILER2_PRESENT(
1114     assert(!DerivedPointerTable::is_active(),
1115          "DPT should not be active during verification "
1116          "(of thread stacks below)");
1117   )
1118 
1119   ResourceMark rm;
1120   HandleMark hm;  // Handles created during verification can be zapped
1121   _verify_count++;
1122 
1123   FormatBuffer<> title("Verifying %s", prefix);
1124   GCTraceTime(Info, gc, verify) tm(title.buffer());

1125   log_debug(gc, verify)("Threads");
1126   Threads::verify();


1127   log_debug(gc, verify)("Heap");
1128   heap()->verify(option);


1129   log_debug(gc, verify)("SymbolTable");
1130   SymbolTable::verify();


1131   log_debug(gc, verify)("StringTable");
1132   StringTable::verify();


1133   {
1134     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1135     log_debug(gc, verify)("CodeCache");
1136     CodeCache::verify();
1137   }


1138   log_debug(gc, verify)("SystemDictionary");
1139   SystemDictionary::verify();

1140 #ifndef PRODUCT

1141   log_debug(gc, verify)("ClassLoaderDataGraph");
1142   ClassLoaderDataGraph::verify();

1143 #endif

1144   log_debug(gc, verify)("MetaspaceAux");
1145   MetaspaceAux::verify_free_chunks();


1146   log_debug(gc, verify)("JNIHandles");
1147   JNIHandles::verify();


1148   log_debug(gc, verify)("C-heap");
1149   os::check_heap();


1150   log_debug(gc, verify)("CodeCache Oops");
1151   CodeCache::verify_oops();

1152 
1153   _verify_in_progress = false;
1154 }
1155 
1156 
1157 #ifndef PRODUCT
1158 void Universe::calculate_verify_data(HeapWord* low_boundary, HeapWord* high_boundary) {
1159   assert(low_boundary < high_boundary, "bad interval");
1160 
1161   // decide which low-order bits we require to be clear:
1162   size_t alignSize = MinObjAlignmentInBytes;
1163   size_t min_object_size = CollectedHeap::min_fill_size();
1164 
1165   // make an inclusive limit:
1166   uintptr_t max = (uintptr_t)high_boundary - min_object_size*wordSize;
1167   uintptr_t min = (uintptr_t)low_boundary;
1168   assert(min < max, "bad interval");
1169   uintptr_t diff = max ^ min;
1170 
1171   // throw away enough low-order bits to make the diff vanish




1086 }
1087 
1088 void Universe::print_heap_before_gc() {
1089   LogHandle(gc, heap) log;
1090   if (log.is_trace()) {
1091     log.trace("Heap before GC invocations=%u (full %u):", heap()->total_collections(), heap()->total_full_collections());
1092     ResourceMark rm;
1093     heap()->print_on(log.trace_stream());
1094   }
1095 }
1096 
1097 void Universe::print_heap_after_gc() {
1098   LogHandle(gc, heap) log;
1099   if (log.is_trace()) {
1100     log.trace("Heap after GC invocations=%u (full %u):", heap()->total_collections(), heap()->total_full_collections());
1101     ResourceMark rm;
1102     heap()->print_on(log.trace_stream());
1103   }
1104 }
1105 
1106 bool Universe::should_verify_subset(const char* subset) {
1107   if (VerifySubSet == NULL || VerifySubSet[0] == '\0') {
1108     // VerifySubSet is not specified, verify everything
1109     return true;
1110   }
1111   if (strstr(VerifySubSet, subset)) {
1112     return true;
1113   }
1114   return false;
1115 }
1116 
1117 void Universe::verify(VerifyOption option, const char* prefix) {
1118   // The use of _verify_in_progress is a temporary work around for
1119   // 6320749.  Don't bother with a creating a class to set and clear
1120   // it since it is only used in this method and the control flow is
1121   // straight forward.
1122   _verify_in_progress = true;
1123 
1124   COMPILER2_PRESENT(
1125     assert(!DerivedPointerTable::is_active(),
1126          "DPT should not be active during verification "
1127          "(of thread stacks below)");
1128   )
1129 
1130   ResourceMark rm;
1131   HandleMark hm;  // Handles created during verification can be zapped
1132   _verify_count++;
1133 
1134   FormatBuffer<> title("Verifying %s", prefix);
1135   GCTraceTime(Info, gc, verify) tm(title.buffer());
1136   if (should_verify_subset("threads")) {
1137     log_debug(gc, verify)("Threads");
1138     Threads::verify();
1139   }
1140   if (should_verify_subset("heap")) {
1141     log_debug(gc, verify)("Heap");
1142     heap()->verify(option);
1143   }
1144   if (should_verify_subset("symbol_table")) {
1145     log_debug(gc, verify)("SymbolTable");
1146     SymbolTable::verify();
1147   }
1148   if (should_verify_subset("string_table")) {
1149     log_debug(gc, verify)("StringTable");
1150     StringTable::verify();
1151   }
1152   if (should_verify_subset("codecache")) {
1153   {
1154     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1155     log_debug(gc, verify)("CodeCache");
1156     CodeCache::verify();
1157   }
1158   }
1159   if (should_verify_subset("dictionary")) {
1160     log_debug(gc, verify)("SystemDictionary");
1161     SystemDictionary::verify();
1162   }
1163 #ifndef PRODUCT
1164   if (should_verify_subset("classloader_data_graph")) {
1165     log_debug(gc, verify)("ClassLoaderDataGraph");
1166     ClassLoaderDataGraph::verify();
1167   }
1168 #endif
1169   if (should_verify_subset("metaspace")) {
1170     log_debug(gc, verify)("MetaspaceAux");
1171     MetaspaceAux::verify_free_chunks();
1172   }
1173   if (should_verify_subset("jni_handles")) {
1174     log_debug(gc, verify)("JNIHandles");
1175     JNIHandles::verify();
1176   }
1177   if (should_verify_subset("c-heap")) {
1178     log_debug(gc, verify)("C-heap");
1179     os::check_heap();
1180   }
1181   if (should_verify_subset("codecache_oops")) {
1182     log_debug(gc, verify)("CodeCache Oops");
1183     CodeCache::verify_oops();
1184   }
1185 
1186   _verify_in_progress = false;
1187 }
1188 
1189 
1190 #ifndef PRODUCT
1191 void Universe::calculate_verify_data(HeapWord* low_boundary, HeapWord* high_boundary) {
1192   assert(low_boundary < high_boundary, "bad interval");
1193 
1194   // decide which low-order bits we require to be clear:
1195   size_t alignSize = MinObjAlignmentInBytes;
1196   size_t min_object_size = CollectedHeap::min_fill_size();
1197 
1198   // make an inclusive limit:
1199   uintptr_t max = (uintptr_t)high_boundary - min_object_size*wordSize;
1200   uintptr_t min = (uintptr_t)low_boundary;
1201   assert(min < max, "bad interval");
1202   uintptr_t diff = max ^ min;
1203 
1204   // throw away enough low-order bits to make the diff vanish