提交 86a31080 编写于 作者: J johnc

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
上级 c1ad8783
...@@ -1592,9 +1592,10 @@ Symbol* SystemDictionary::find_placeholder(Symbol* class_name, ...@@ -1592,9 +1592,10 @@ Symbol* SystemDictionary::find_placeholder(Symbol* class_name,
// Used for assertions and verification only // Used for assertions and verification only
Klass* SystemDictionary::find_class(Symbol* class_name, ClassLoaderData* loader_data) { Klass* SystemDictionary::find_class(Symbol* class_name, ClassLoaderData* loader_data) {
#ifndef ASSERT #ifndef ASSERT
guarantee(VerifyBeforeGC || guarantee(VerifyBeforeGC ||
VerifyDuringGC || VerifyDuringGC ||
VerifyBeforeExit || VerifyBeforeExit ||
VerifyDuringStartup ||
VerifyAfterGC, "too expensive"); VerifyAfterGC, "too expensive");
#endif #endif
assert_locked_or_safepoint(SystemDictionary_lock); assert_locked_or_safepoint(SystemDictionary_lock);
......
...@@ -819,12 +819,13 @@ bool GenCollectedHeap::is_in_young(oop p) { ...@@ -819,12 +819,13 @@ bool GenCollectedHeap::is_in_young(oop p) {
// Returns "TRUE" iff "p" points into the committed areas of the heap. // Returns "TRUE" iff "p" points into the committed areas of the heap.
bool GenCollectedHeap::is_in(const void* p) const { bool GenCollectedHeap::is_in(const void* p) const {
#ifndef ASSERT #ifndef ASSERT
guarantee(VerifyBeforeGC || guarantee(VerifyBeforeGC ||
VerifyDuringGC || VerifyDuringGC ||
VerifyBeforeExit || VerifyBeforeExit ||
PrintAssembly || VerifyDuringStartup ||
tty->count() != 0 || // already printing PrintAssembly ||
VerifyAfterGC || tty->count() != 0 || // already printing
VerifyAfterGC ||
VMError::fatal_error_in_progress(), "too expensive"); VMError::fatal_error_in_progress(), "too expensive");
#endif #endif
......
...@@ -2006,11 +2006,12 @@ bool Arguments::check_vm_args_consistency() { ...@@ -2006,11 +2006,12 @@ bool Arguments::check_vm_args_consistency() {
// than just disable the lock verification. This will be fixed under // than just disable the lock verification. This will be fixed under
// bug 4788986. // bug 4788986.
if (UseConcMarkSweepGC && FLSVerifyAllHeapReferences) { if (UseConcMarkSweepGC && FLSVerifyAllHeapReferences) {
if (VerifyGCStartAt == 0) { if (VerifyDuringStartup) {
warning("Heap verification at start-up disabled " warning("Heap verification at start-up disabled "
"(due to current incompatibility with FLSVerifyAllHeapReferences)"); "(due to current incompatibility with FLSVerifyAllHeapReferences)");
VerifyGCStartAt = 1; // Disable verification at start-up VerifyDuringStartup = false; // Disable verification at start-up
} }
if (VerifyBeforeExit) { if (VerifyBeforeExit) {
warning("Heap verification at shutdown disabled " warning("Heap verification at shutdown disabled "
"(due to current incompatibility with FLSVerifyAllHeapReferences)"); "(due to current incompatibility with FLSVerifyAllHeapReferences)");
......
...@@ -2123,6 +2123,10 @@ class CommandLineFlags { ...@@ -2123,6 +2123,10 @@ 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, VerifyDuringStartup, false, \
"Verify memory system before executing any Java code " \
"during VM initialization") \
\
diagnostic(bool, VerifyBeforeExit, trueInDebug, \ diagnostic(bool, VerifyBeforeExit, trueInDebug, \
"Verify system before exiting") \ "Verify system before exiting") \
\ \
......
...@@ -3446,9 +3446,9 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { ...@@ -3446,9 +3446,9 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
} }
assert (Universe::is_fully_initialized(), "not initialized"); assert (Universe::is_fully_initialized(), "not initialized");
if (VerifyBeforeGC && VerifyGCStartAt == 0) { if (VerifyDuringStartup) {
Universe::heap()->prepare_for_verify(); VM_Verify verify_op(false /* silent */); // make sure we're starting with a clean slate
Universe::verify(); // make sure we're starting with a clean slate VMThread::execute(&verify_op);
} }
EXCEPTION_MARK; EXCEPTION_MARK;
......
...@@ -175,7 +175,8 @@ void VM_HandleFullCodeCache::doit() { ...@@ -175,7 +175,8 @@ void VM_HandleFullCodeCache::doit() {
} }
void VM_Verify::doit() { void VM_Verify::doit() {
Universe::verify(); Universe::heap()->prepare_for_verify();
Universe::verify(_silent);
} }
bool VM_PrintThreads::doit_prologue() { bool VM_PrintThreads::doit_prologue() {
......
...@@ -300,9 +300,9 @@ class VM_UnlinkSymbols: public VM_Operation { ...@@ -300,9 +300,9 @@ class VM_UnlinkSymbols: public VM_Operation {
class VM_Verify: public VM_Operation { class VM_Verify: public VM_Operation {
private: private:
KlassHandle _dependee; bool _silent;
public: public:
VM_Verify() {} VM_Verify(bool silent) : _silent(silent) {}
VMOp_Type type() const { return VMOp_Verify; } VMOp_Type type() const { return VMOp_Verify; }
void doit(); void doit();
}; };
......
...@@ -21,23 +21,23 @@ ...@@ -21,23 +21,23 @@
* questions. * questions.
*/ */
/* @test TestVerifyBeforeGCDuringStartup.java /* @test TestVerifyDuringStartup.java
* @key gc * @key gc
* @bug 8010463 * @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 * @library /testlibrary
*/ */
import com.oracle.java.testlibrary.OutputAnalyzer; import com.oracle.java.testlibrary.OutputAnalyzer;
import com.oracle.java.testlibrary.ProcessTools; import com.oracle.java.testlibrary.ProcessTools;
public class TestVerifyBeforeGCDuringStartup { public class TestVerifyDuringStartup {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
ProcessBuilder pb = ProcessBuilder pb =
ProcessTools.createJavaProcessBuilder(System.getProperty("test.vm.opts"), ProcessTools.createJavaProcessBuilder(System.getProperty("test.vm.opts"),
"-XX:-UseTLAB", "-XX:-UseTLAB",
"-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockDiagnosticVMOptions",
"-XX:+VerifyBeforeGC", "-version"); "-XX:+VerifyDuringStartup", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start()); OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("[Verifying"); output.shouldContain("[Verifying");
output.shouldHaveExitValue(0); output.shouldHaveExitValue(0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册