提交 7b3dcc29 编写于 作者: S stefank

8013132: Add a flag to turn off the output of the verbose verification code

Reviewed-by: johnc, brutisso
上级 563afc34
...@@ -2444,8 +2444,7 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) { ...@@ -2444,8 +2444,7 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) {
// initial marking in checkpointRootsInitialWork has been completed // initial marking in checkpointRootsInitialWork has been completed
if (VerifyDuringGC && if (VerifyDuringGC &&
GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) {
gclog_or_tty->print("Verify before initial mark: "); Universe::verify("Verify before initial mark: ");
Universe::verify();
} }
{ {
bool res = markFromRoots(false); bool res = markFromRoots(false);
...@@ -2456,8 +2455,7 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) { ...@@ -2456,8 +2455,7 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) {
case FinalMarking: case FinalMarking:
if (VerifyDuringGC && if (VerifyDuringGC &&
GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) {
gclog_or_tty->print("Verify before re-mark: "); Universe::verify("Verify before re-mark: ");
Universe::verify();
} }
checkpointRootsFinal(false, clear_all_soft_refs, checkpointRootsFinal(false, clear_all_soft_refs,
init_mark_was_synchronous); init_mark_was_synchronous);
...@@ -2468,8 +2466,7 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) { ...@@ -2468,8 +2466,7 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) {
// final marking in checkpointRootsFinal has been completed // final marking in checkpointRootsFinal has been completed
if (VerifyDuringGC && if (VerifyDuringGC &&
GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) {
gclog_or_tty->print("Verify before sweep: "); Universe::verify("Verify before sweep: ");
Universe::verify();
} }
sweep(false); sweep(false);
assert(_collectorState == Resizing, "Incorrect state"); assert(_collectorState == Resizing, "Incorrect state");
...@@ -2484,8 +2481,7 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) { ...@@ -2484,8 +2481,7 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) {
// The heap has been resized. // The heap has been resized.
if (VerifyDuringGC && if (VerifyDuringGC &&
GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) {
gclog_or_tty->print("Verify before reset: "); Universe::verify("Verify before reset: ");
Universe::verify();
} }
reset(false); reset(false);
assert(_collectorState == Idling, "Collector state should " assert(_collectorState == Idling, "Collector state should "
...@@ -2853,8 +2849,8 @@ class VerifyMarkedClosure: public BitMapClosure { ...@@ -2853,8 +2849,8 @@ class VerifyMarkedClosure: public BitMapClosure {
bool failed() { return _failed; } bool failed() { return _failed; }
}; };
bool CMSCollector::verify_after_remark() { bool CMSCollector::verify_after_remark(bool silent) {
gclog_or_tty->print(" [Verifying CMS Marking... "); if (!silent) gclog_or_tty->print(" [Verifying CMS Marking... ");
MutexLockerEx ml(verification_mark_bm()->lock(), Mutex::_no_safepoint_check_flag); MutexLockerEx ml(verification_mark_bm()->lock(), Mutex::_no_safepoint_check_flag);
static bool init = false; static bool init = false;
...@@ -2915,7 +2911,7 @@ bool CMSCollector::verify_after_remark() { ...@@ -2915,7 +2911,7 @@ bool CMSCollector::verify_after_remark() {
warning("Unrecognized value %d for CMSRemarkVerifyVariant", warning("Unrecognized value %d for CMSRemarkVerifyVariant",
CMSRemarkVerifyVariant); CMSRemarkVerifyVariant);
} }
gclog_or_tty->print(" done] "); if (!silent) gclog_or_tty->print(" done] ");
return true; return true;
} }
......
...@@ -990,7 +990,7 @@ class CMSCollector: public CHeapObj<mtGC> { ...@@ -990,7 +990,7 @@ class CMSCollector: public CHeapObj<mtGC> {
// debugging // debugging
void verify(); void verify();
bool verify_after_remark(); bool verify_after_remark(bool silent = VerifySilently);
void verify_ok_to_terminate() const PRODUCT_RETURN; void verify_ok_to_terminate() const PRODUCT_RETURN;
void verify_work_stacks_empty() const PRODUCT_RETURN; void verify_work_stacks_empty() const PRODUCT_RETURN;
void verify_overflow_empty() const PRODUCT_RETURN; void verify_overflow_empty() const PRODUCT_RETURN;
......
...@@ -1273,10 +1273,9 @@ void ConcurrentMark::checkpointRootsFinal(bool clear_all_soft_refs) { ...@@ -1273,10 +1273,9 @@ void ConcurrentMark::checkpointRootsFinal(bool clear_all_soft_refs) {
if (VerifyDuringGC) { if (VerifyDuringGC) {
HandleMark hm; // handle scope HandleMark hm; // handle scope
gclog_or_tty->print(" VerifyDuringGC:(before)");
Universe::heap()->prepare_for_verify(); Universe::heap()->prepare_for_verify();
Universe::verify(/* silent */ false, Universe::verify(VerifyOption_G1UsePrevMarking,
/* option */ VerifyOption_G1UsePrevMarking); " VerifyDuringGC:(before)");
} }
G1CollectorPolicy* g1p = g1h->g1_policy(); G1CollectorPolicy* g1p = g1h->g1_policy();
...@@ -1300,10 +1299,9 @@ void ConcurrentMark::checkpointRootsFinal(bool clear_all_soft_refs) { ...@@ -1300,10 +1299,9 @@ void ConcurrentMark::checkpointRootsFinal(bool clear_all_soft_refs) {
// Verify the heap w.r.t. the previous marking bitmap. // Verify the heap w.r.t. the previous marking bitmap.
if (VerifyDuringGC) { if (VerifyDuringGC) {
HandleMark hm; // handle scope HandleMark hm; // handle scope
gclog_or_tty->print(" VerifyDuringGC:(overflow)");
Universe::heap()->prepare_for_verify(); Universe::heap()->prepare_for_verify();
Universe::verify(/* silent */ false, Universe::verify(VerifyOption_G1UsePrevMarking,
/* option */ VerifyOption_G1UsePrevMarking); " VerifyDuringGC:(overflow)");
} }
// Clear the marking state because we will be restarting // Clear the marking state because we will be restarting
...@@ -1323,10 +1321,9 @@ void ConcurrentMark::checkpointRootsFinal(bool clear_all_soft_refs) { ...@@ -1323,10 +1321,9 @@ void ConcurrentMark::checkpointRootsFinal(bool clear_all_soft_refs) {
if (VerifyDuringGC) { if (VerifyDuringGC) {
HandleMark hm; // handle scope HandleMark hm; // handle scope
gclog_or_tty->print(" VerifyDuringGC:(after)");
Universe::heap()->prepare_for_verify(); Universe::heap()->prepare_for_verify();
Universe::verify(/* silent */ false, Universe::verify(VerifyOption_G1UseNextMarking,
/* option */ VerifyOption_G1UseNextMarking); " VerifyDuringGC:(after)");
} }
assert(!restart_for_overflow(), "sanity"); assert(!restart_for_overflow(), "sanity");
// Completely reset the marking state since marking completed // Completely reset the marking state since marking completed
...@@ -1972,10 +1969,9 @@ void ConcurrentMark::cleanup() { ...@@ -1972,10 +1969,9 @@ void ConcurrentMark::cleanup() {
if (VerifyDuringGC) { if (VerifyDuringGC) {
HandleMark hm; // handle scope HandleMark hm; // handle scope
gclog_or_tty->print(" VerifyDuringGC:(before)");
Universe::heap()->prepare_for_verify(); Universe::heap()->prepare_for_verify();
Universe::verify(/* silent */ false, Universe::verify(VerifyOption_G1UsePrevMarking,
/* option */ VerifyOption_G1UsePrevMarking); " VerifyDuringGC:(before)");
} }
G1CollectorPolicy* g1p = G1CollectedHeap::heap()->g1_policy(); G1CollectorPolicy* g1p = G1CollectedHeap::heap()->g1_policy();
...@@ -2127,10 +2123,9 @@ void ConcurrentMark::cleanup() { ...@@ -2127,10 +2123,9 @@ void ConcurrentMark::cleanup() {
if (VerifyDuringGC) { if (VerifyDuringGC) {
HandleMark hm; // handle scope HandleMark hm; // handle scope
gclog_or_tty->print(" VerifyDuringGC:(after)");
Universe::heap()->prepare_for_verify(); Universe::heap()->prepare_for_verify();
Universe::verify(/* silent */ false, Universe::verify(VerifyOption_G1UsePrevMarking,
/* option */ VerifyOption_G1UsePrevMarking); " VerifyDuringGC:(after)");
} }
g1h->verify_region_sets_optional(); g1h->verify_region_sets_optional();
......
...@@ -1271,9 +1271,8 @@ double G1CollectedHeap::verify(bool guard, const char* msg) { ...@@ -1271,9 +1271,8 @@ double G1CollectedHeap::verify(bool guard, const char* msg) {
if (guard && total_collections() >= VerifyGCStartAt) { if (guard && total_collections() >= VerifyGCStartAt) {
double verify_start = os::elapsedTime(); double verify_start = os::elapsedTime();
HandleMark hm; // Discard invalid handles created during verification HandleMark hm; // Discard invalid handles created during verification
gclog_or_tty->print(msg);
prepare_for_verify(); prepare_for_verify();
Universe::verify(false /* silent */, VerifyOption_G1UsePrevMarking); Universe::verify(VerifyOption_G1UsePrevMarking, msg);
verify_time_ms = (os::elapsedTime() - verify_start) * 1000; verify_time_ms = (os::elapsedTime() - verify_start) * 1000;
} }
......
...@@ -170,7 +170,6 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, ...@@ -170,7 +170,6 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
if (VerifyDuringGC) { if (VerifyDuringGC) {
HandleMark hm; // handle scope HandleMark hm; // handle scope
COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact); COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact);
gclog_or_tty->print(" VerifyDuringGC:(full)[Verifying ");
Universe::heap()->prepare_for_verify(); Universe::heap()->prepare_for_verify();
// Note: we can verify only the heap here. When an object is // Note: we can verify only the heap here. When an object is
// marked, the previous value of the mark word (including // marked, the previous value of the mark word (including
...@@ -182,11 +181,13 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, ...@@ -182,11 +181,13 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
// fail. At the end of the GC, the orginal mark word values // fail. At the end of the GC, the orginal mark word values
// (including hash values) are restored to the appropriate // (including hash values) are restored to the appropriate
// objects. // objects.
Universe::heap()->verify(/* silent */ false, if (!VerifySilently) {
/* option */ VerifyOption_G1UseMarkWord); gclog_or_tty->print(" VerifyDuringGC:(full)[Verifying ");
}
G1CollectedHeap* g1h = G1CollectedHeap::heap(); Universe::heap()->verify(VerifySilently, VerifyOption_G1UseMarkWord);
gclog_or_tty->print_cr("]"); if (!VerifySilently) {
gclog_or_tty->print_cr("]");
}
} }
} }
......
...@@ -138,8 +138,7 @@ bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) { ...@@ -138,8 +138,7 @@ bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) {
if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) { if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) {
HandleMark hm; // Discard invalid handles created during verification HandleMark hm; // Discard invalid handles created during verification
gclog_or_tty->print(" VerifyBeforeGC:"); Universe::verify(" VerifyBeforeGC:");
Universe::verify();
} }
// Verify object start arrays // Verify object start arrays
...@@ -341,8 +340,7 @@ bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) { ...@@ -341,8 +340,7 @@ bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) {
if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) { if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) {
HandleMark hm; // Discard invalid handles created during verification HandleMark hm; // Discard invalid handles created during verification
gclog_or_tty->print(" VerifyAfterGC:"); Universe::verify(" VerifyAfterGC:");
Universe::verify();
} }
// Re-verify object start arrays // Re-verify object start arrays
......
...@@ -966,8 +966,7 @@ void PSParallelCompact::pre_compact(PreGCValues* pre_gc_values) ...@@ -966,8 +966,7 @@ void PSParallelCompact::pre_compact(PreGCValues* pre_gc_values)
if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) { if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) {
HandleMark hm; // Discard invalid handles created during verification HandleMark hm; // Discard invalid handles created during verification
gclog_or_tty->print(" VerifyBeforeGC:"); Universe::verify(" VerifyBeforeGC:");
Universe::verify();
} }
// Verify object start arrays // Verify object start arrays
...@@ -2168,8 +2167,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) { ...@@ -2168,8 +2167,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) { if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) {
HandleMark hm; // Discard invalid handles created during verification HandleMark hm; // Discard invalid handles created during verification
gclog_or_tty->print(" VerifyAfterGC:"); Universe::verify(" VerifyAfterGC:");
Universe::verify();
} }
// Re-verify object start arrays // Re-verify object start arrays
......
...@@ -314,8 +314,7 @@ bool PSScavenge::invoke_no_policy() { ...@@ -314,8 +314,7 @@ bool PSScavenge::invoke_no_policy() {
if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) { if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) {
HandleMark hm; // Discard invalid handles created during verification HandleMark hm; // Discard invalid handles created during verification
gclog_or_tty->print(" VerifyBeforeGC:"); Universe::verify(" VerifyBeforeGC:");
Universe::verify();
} }
{ {
...@@ -638,8 +637,7 @@ bool PSScavenge::invoke_no_policy() { ...@@ -638,8 +637,7 @@ bool PSScavenge::invoke_no_policy() {
if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) { if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) {
HandleMark hm; // Discard invalid handles created during verification HandleMark hm; // Discard invalid handles created during verification
gclog_or_tty->print(" VerifyAfterGC:"); Universe::verify(" VerifyAfterGC:");
Universe::verify();
} }
heap->print_heap_after_gc(); heap->print_heap_after_gc();
......
...@@ -447,8 +447,7 @@ void GenCollectedHeap::do_collection(bool full, ...@@ -447,8 +447,7 @@ void GenCollectedHeap::do_collection(bool full,
prepare_for_verify(); prepare_for_verify();
prepared_for_verification = true; prepared_for_verification = true;
} }
gclog_or_tty->print(" VerifyBeforeGC:"); Universe::verify(" VerifyBeforeGC:");
Universe::verify();
} }
COMPILER2_PRESENT(DerivedPointerTable::clear()); COMPILER2_PRESENT(DerivedPointerTable::clear());
...@@ -519,8 +518,7 @@ void GenCollectedHeap::do_collection(bool full, ...@@ -519,8 +518,7 @@ void GenCollectedHeap::do_collection(bool full,
if (VerifyAfterGC && i >= VerifyGCLevel && if (VerifyAfterGC && i >= VerifyGCLevel &&
total_collections() >= VerifyGCStartAt) { total_collections() >= VerifyGCStartAt) {
HandleMark hm; // Discard invalid handles created during verification HandleMark hm; // Discard invalid handles created during verification
gclog_or_tty->print(" VerifyAfterGC:"); Universe::verify(" VerifyAfterGC:");
Universe::verify();
} }
if (PrintGCDetails) { if (PrintGCDetails) {
......
...@@ -1270,7 +1270,7 @@ void Universe::print_heap_after_gc(outputStream* st, bool ignore_extended) { ...@@ -1270,7 +1270,7 @@ void Universe::print_heap_after_gc(outputStream* st, bool ignore_extended) {
st->print_cr("}"); st->print_cr("}");
} }
void Universe::verify(bool silent, VerifyOption option) { void Universe::verify(VerifyOption option, const char* prefix, bool silent) {
// The use of _verify_in_progress is a temporary work around for // The use of _verify_in_progress is a temporary work around for
// 6320749. Don't bother with a creating a class to set and clear // 6320749. Don't bother with a creating a class to set and clear
// it since it is only used in this method and the control flow is // it since it is only used in this method and the control flow is
...@@ -1287,11 +1287,12 @@ void Universe::verify(bool silent, VerifyOption option) { ...@@ -1287,11 +1287,12 @@ void Universe::verify(bool silent, VerifyOption option) {
HandleMark hm; // Handles created during verification can be zapped HandleMark hm; // Handles created during verification can be zapped
_verify_count++; _verify_count++;
if (!silent) gclog_or_tty->print(prefix);
if (!silent) gclog_or_tty->print("[Verifying "); if (!silent) gclog_or_tty->print("[Verifying ");
if (!silent) gclog_or_tty->print("threads "); if (!silent) gclog_or_tty->print("threads ");
Threads::verify(); Threads::verify();
if (!silent) gclog_or_tty->print("heap ");
heap()->verify(silent, option); heap()->verify(silent, option);
if (!silent) gclog_or_tty->print("syms "); if (!silent) gclog_or_tty->print("syms ");
SymbolTable::verify(); SymbolTable::verify();
if (!silent) gclog_or_tty->print("strs "); if (!silent) gclog_or_tty->print("strs ");
......
...@@ -445,12 +445,12 @@ class Universe: AllStatic { ...@@ -445,12 +445,12 @@ class Universe: AllStatic {
// Debugging // Debugging
static bool verify_in_progress() { return _verify_in_progress; } static bool verify_in_progress() { return _verify_in_progress; }
static void verify(bool silent, VerifyOption option); static void verify(VerifyOption option, const char* prefix, bool silent = VerifySilently);
static void verify(bool silent) { static void verify(const char* prefix, bool silent = VerifySilently) {
verify(silent, VerifyOption_Default /* option */); verify(VerifyOption_Default, prefix, silent);
} }
static void verify() { static void verify(bool silent = VerifySilently) {
verify(false /* silent */); verify("", silent);
} }
static int verify_count() { return _verify_count; } static int verify_count() { return _verify_count; }
......
...@@ -2123,6 +2123,9 @@ class CommandLineFlags { ...@@ -2123,6 +2123,9 @@ class CommandLineFlags {
product(intx, PrefetchFieldsAhead, -1, \ product(intx, PrefetchFieldsAhead, -1, \
"How many fields ahead to prefetch in oop scan (<= 0 means off)") \ "How many fields ahead to prefetch in oop scan (<= 0 means off)") \
\ \
diagnostic(bool, VerifySilently, false, \
"Don't print print the verification progress") \
\
diagnostic(bool, VerifyDuringStartup, false, \ diagnostic(bool, VerifyDuringStartup, false, \
"Verify memory system before executing any Java code " \ "Verify memory system before executing any Java code " \
"during VM initialization") \ "during VM initialization") \
......
...@@ -3447,7 +3447,8 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { ...@@ -3447,7 +3447,8 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
assert (Universe::is_fully_initialized(), "not initialized"); assert (Universe::is_fully_initialized(), "not initialized");
if (VerifyDuringStartup) { if (VerifyDuringStartup) {
VM_Verify verify_op(false /* silent */); // make sure we're starting with a clean slate // Make sure we're starting with a clean slate.
VM_Verify verify_op;
VMThread::execute(&verify_op); VMThread::execute(&verify_op);
} }
......
...@@ -293,7 +293,7 @@ void VMThread::run() { ...@@ -293,7 +293,7 @@ void VMThread::run() {
os::check_heap(); os::check_heap();
// Silent verification so as not to pollute normal output, // Silent verification so as not to pollute normal output,
// unless we really asked for it. // unless we really asked for it.
Universe::verify(!(PrintGCDetails || Verbose)); Universe::verify(!(PrintGCDetails || Verbose) || VerifySilently);
} }
CompileBroker::set_should_block(); CompileBroker::set_should_block();
......
...@@ -302,7 +302,7 @@ class VM_Verify: public VM_Operation { ...@@ -302,7 +302,7 @@ class VM_Verify: public VM_Operation {
private: private:
bool _silent; bool _silent;
public: public:
VM_Verify(bool silent) : _silent(silent) {} VM_Verify(bool silent = VerifySilently) : _silent(silent) {}
VMOp_Type type() const { return VMOp_Verify; } VMOp_Type type() const { return VMOp_Verify; }
void doit(); void doit();
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册