8011343: Add new flag for verifying the heap during startup
Summary: Perform verification during VM startup under control of new flag and within a VMOperation.
Reviewed-by: stefank, jmasa, brutisso
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp Thu Apr 04 21:15:43 2013 -0700
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp Fri Apr 05 10:20:04 2013 -0700
@@ -1592,9 +1592,10 @@
// 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);
--- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp Thu Apr 04 21:15:43 2013 -0700
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp Fri Apr 05 10:20:04 2013 -0700
@@ -819,12 +819,13 @@
// 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
--- a/hotspot/src/share/vm/runtime/arguments.cpp Thu Apr 04 21:15:43 2013 -0700
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Fri Apr 05 10:20:04 2013 -0700
@@ -2006,11 +2006,12 @@
// 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)");
--- a/hotspot/src/share/vm/runtime/globals.hpp Thu Apr 04 21:15:43 2013 -0700
+++ b/hotspot/src/share/vm/runtime/globals.hpp Fri Apr 05 10:20:04 2013 -0700
@@ -2123,6 +2123,10 @@
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") \
\
--- a/hotspot/src/share/vm/runtime/thread.cpp Thu Apr 04 21:15:43 2013 -0700
+++ b/hotspot/src/share/vm/runtime/thread.cpp Fri Apr 05 10:20:04 2013 -0700
@@ -3446,9 +3446,9 @@
}
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;
--- a/hotspot/src/share/vm/runtime/vm_operations.cpp Thu Apr 04 21:15:43 2013 -0700
+++ b/hotspot/src/share/vm/runtime/vm_operations.cpp Fri Apr 05 10:20:04 2013 -0700
@@ -175,7 +175,8 @@
}
void VM_Verify::doit() {
- Universe::verify();
+ Universe::heap()->prepare_for_verify();
+ Universe::verify(_silent);
}
bool VM_PrintThreads::doit_prologue() {
--- a/hotspot/src/share/vm/runtime/vm_operations.hpp Thu Apr 04 21:15:43 2013 -0700
+++ b/hotspot/src/share/vm/runtime/vm_operations.hpp Fri Apr 05 10:20:04 2013 -0700
@@ -300,9 +300,9 @@
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();
};
--- a/hotspot/test/gc/TestVerifyBeforeGCDuringStartup.java Thu Apr 04 21:15:43 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* @test TestVerifyBeforeGCDuringStartup.java
- * @key gc
- * @bug 8010463
- * @summary Simple test run with -XX:+VerifyBeforeGC -XX:-UseTLAB to verify 8010463
- * @library /testlibrary
- */
-
-import com.oracle.java.testlibrary.OutputAnalyzer;
-import com.oracle.java.testlibrary.ProcessTools;
-
-public class TestVerifyBeforeGCDuringStartup {
- public static void main(String args[]) throws Exception {
- ProcessBuilder pb =
- ProcessTools.createJavaProcessBuilder(System.getProperty("test.vm.opts"),
- "-XX:-UseTLAB",
- "-XX:+UnlockDiagnosticVMOptions",
- "-XX:+VerifyBeforeGC", "-version");
- OutputAnalyzer output = new OutputAnalyzer(pb.start());
- output.shouldContain("[Verifying");
- output.shouldHaveExitValue(0);
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/TestVerifyDuringStartup.java Fri Apr 05 10:20:04 2013 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test TestVerifyDuringStartup.java
+ * @key gc
+ * @bug 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 TestVerifyDuringStartup {
+ public static void main(String args[]) throws Exception {
+ ProcessBuilder pb =
+ ProcessTools.createJavaProcessBuilder(System.getProperty("test.vm.opts"),
+ "-XX:-UseTLAB",
+ "-XX:+UnlockDiagnosticVMOptions",
+ "-XX:+VerifyDuringStartup", "-version");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain("[Verifying");
+ output.shouldHaveExitValue(0);
+ }
+}