8011343: Add new flag for verifying the heap during startup

Perform verification during VM startup under control of new flag and within a VMOperation.

Reviewed-by: stefank, jmasa, brutisso
This commit is contained in:
John Cuthbertson 2013-04-05 10:20:04 -07:00
parent 0afa77628c
commit 90d010120f
8 changed files with 29 additions and 21 deletions

View File

@ -1592,9 +1592,10 @@ Symbol* SystemDictionary::find_placeholder(Symbol* class_name,
// Used for assertions and verification only
Klass* SystemDictionary::find_class(Symbol* class_name, ClassLoaderData* loader_data) {
#ifndef ASSERT
guarantee(VerifyBeforeGC ||
VerifyDuringGC ||
VerifyBeforeExit ||
guarantee(VerifyBeforeGC ||
VerifyDuringGC ||
VerifyBeforeExit ||
VerifyDuringStartup ||
VerifyAfterGC, "too expensive");
#endif
assert_locked_or_safepoint(SystemDictionary_lock);

View File

@ -819,12 +819,13 @@ bool GenCollectedHeap::is_in_young(oop p) {
// Returns "TRUE" iff "p" points into the committed areas of the heap.
bool GenCollectedHeap::is_in(const void* p) const {
#ifndef ASSERT
guarantee(VerifyBeforeGC ||
VerifyDuringGC ||
VerifyBeforeExit ||
PrintAssembly ||
tty->count() != 0 || // already printing
VerifyAfterGC ||
guarantee(VerifyBeforeGC ||
VerifyDuringGC ||
VerifyBeforeExit ||
VerifyDuringStartup ||
PrintAssembly ||
tty->count() != 0 || // already printing
VerifyAfterGC ||
VMError::fatal_error_in_progress(), "too expensive");
#endif

View File

@ -2006,11 +2006,12 @@ bool Arguments::check_vm_args_consistency() {
// than just disable the lock verification. This will be fixed under
// bug 4788986.
if (UseConcMarkSweepGC && FLSVerifyAllHeapReferences) {
if (VerifyGCStartAt == 0) {
if (VerifyDuringStartup) {
warning("Heap verification at start-up disabled "
"(due to current incompatibility with FLSVerifyAllHeapReferences)");
VerifyGCStartAt = 1; // Disable verification at start-up
VerifyDuringStartup = false; // Disable verification at start-up
}
if (VerifyBeforeExit) {
warning("Heap verification at shutdown disabled "
"(due to current incompatibility with FLSVerifyAllHeapReferences)");

View File

@ -2123,6 +2123,10 @@ class CommandLineFlags {
product(intx, PrefetchFieldsAhead, -1, \
"How many fields ahead to prefetch in oop scan (<= 0 means off)") \
\
diagnostic(bool, VerifyDuringStartup, false, \
"Verify memory system before executing any Java code " \
"during VM initialization") \
\
diagnostic(bool, VerifyBeforeExit, trueInDebug, \
"Verify system before exiting") \
\

View File

@ -3446,9 +3446,9 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
}
assert (Universe::is_fully_initialized(), "not initialized");
if (VerifyBeforeGC && VerifyGCStartAt == 0) {
Universe::heap()->prepare_for_verify();
Universe::verify(); // make sure we're starting with a clean slate
if (VerifyDuringStartup) {
VM_Verify verify_op(false /* silent */); // make sure we're starting with a clean slate
VMThread::execute(&verify_op);
}
EXCEPTION_MARK;

View File

@ -175,7 +175,8 @@ void VM_HandleFullCodeCache::doit() {
}
void VM_Verify::doit() {
Universe::verify();
Universe::heap()->prepare_for_verify();
Universe::verify(_silent);
}
bool VM_PrintThreads::doit_prologue() {

View File

@ -300,9 +300,9 @@ class VM_UnlinkSymbols: public VM_Operation {
class VM_Verify: public VM_Operation {
private:
KlassHandle _dependee;
bool _silent;
public:
VM_Verify() {}
VM_Verify(bool silent) : _silent(silent) {}
VMOp_Type type() const { return VMOp_Verify; }
void doit();
};

View File

@ -21,23 +21,23 @@
* questions.
*/
/* @test TestVerifyBeforeGCDuringStartup.java
/* @test TestVerifyDuringStartup.java
* @key gc
* @bug 8010463
* @summary Simple test run with -XX:+VerifyBeforeGC -XX:-UseTLAB to verify 8010463
* @summary Simple test run with -XX:+VerifyDuringStartup -XX:-UseTLAB to verify 8010463
* @library /testlibrary
*/
import com.oracle.java.testlibrary.OutputAnalyzer;
import com.oracle.java.testlibrary.ProcessTools;
public class TestVerifyBeforeGCDuringStartup {
public class TestVerifyDuringStartup {
public static void main(String args[]) throws Exception {
ProcessBuilder pb =
ProcessTools.createJavaProcessBuilder(System.getProperty("test.vm.opts"),
"-XX:-UseTLAB",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+VerifyBeforeGC", "-version");
"-XX:+VerifyDuringStartup", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("[Verifying");
output.shouldHaveExitValue(0);