mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 20:44:41 +02:00
Merge
This commit is contained in:
commit
33eb983620
4 changed files with 215 additions and 23 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -129,6 +129,7 @@ oop Universe::_delayed_stack_overflow_error_message = NULL;
|
||||||
objArrayOop Universe::_preallocated_out_of_memory_error_array = NULL;
|
objArrayOop Universe::_preallocated_out_of_memory_error_array = NULL;
|
||||||
volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0;
|
volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0;
|
||||||
bool Universe::_verify_in_progress = false;
|
bool Universe::_verify_in_progress = false;
|
||||||
|
long Universe::verify_flags = Universe::Verify_All;
|
||||||
oop Universe::_null_ptr_exception_instance = NULL;
|
oop Universe::_null_ptr_exception_instance = NULL;
|
||||||
oop Universe::_arithmetic_exception_instance = NULL;
|
oop Universe::_arithmetic_exception_instance = NULL;
|
||||||
oop Universe::_virtual_machine_error_instance = NULL;
|
oop Universe::_virtual_machine_error_instance = NULL;
|
||||||
|
@ -669,6 +670,9 @@ jint universe_init() {
|
||||||
MetaspaceShared::prepare_for_dumping();
|
MetaspaceShared::prepare_for_dumping();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (strlen(VerifySubSet) > 0) {
|
||||||
|
Universe::initialize_verify_flags();
|
||||||
|
}
|
||||||
|
|
||||||
return JNI_OK;
|
return JNI_OK;
|
||||||
}
|
}
|
||||||
|
@ -1103,6 +1107,53 @@ void Universe::print_heap_after_gc() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Universe::initialize_verify_flags() {
|
||||||
|
verify_flags = 0;
|
||||||
|
const char delimiter[] = " ,";
|
||||||
|
|
||||||
|
size_t length = strlen(VerifySubSet);
|
||||||
|
char* subset_list = NEW_C_HEAP_ARRAY(char, length + 1, mtInternal);
|
||||||
|
strncpy(subset_list, VerifySubSet, length + 1);
|
||||||
|
|
||||||
|
char* token = strtok(subset_list, delimiter);
|
||||||
|
while (token != NULL) {
|
||||||
|
if (strcmp(token, "threads") == 0) {
|
||||||
|
verify_flags |= Verify_Threads;
|
||||||
|
} else if (strcmp(token, "heap") == 0) {
|
||||||
|
verify_flags |= Verify_Heap;
|
||||||
|
} else if (strcmp(token, "symbol_table") == 0) {
|
||||||
|
verify_flags |= Verify_SymbolTable;
|
||||||
|
} else if (strcmp(token, "string_table") == 0) {
|
||||||
|
verify_flags |= Verify_StringTable;
|
||||||
|
} else if (strcmp(token, "codecache") == 0) {
|
||||||
|
verify_flags |= Verify_CodeCache;
|
||||||
|
} else if (strcmp(token, "dictionary") == 0) {
|
||||||
|
verify_flags |= Verify_SystemDictionary;
|
||||||
|
} else if (strcmp(token, "classloader_data_graph") == 0) {
|
||||||
|
verify_flags |= Verify_ClassLoaderDataGraph;
|
||||||
|
} else if (strcmp(token, "metaspace") == 0) {
|
||||||
|
verify_flags |= Verify_MetaspaceAux;
|
||||||
|
} else if (strcmp(token, "jni_handles") == 0) {
|
||||||
|
verify_flags |= Verify_JNIHandles;
|
||||||
|
} else if (strcmp(token, "c-heap") == 0) {
|
||||||
|
verify_flags |= Verify_CHeap;
|
||||||
|
} else if (strcmp(token, "codecache_oops") == 0) {
|
||||||
|
verify_flags |= Verify_CodeCacheOops;
|
||||||
|
} else {
|
||||||
|
vm_exit_during_initialization(err_msg("VerifySubSet: \'%s\' memory sub-system is unknown, please correct it", token));
|
||||||
|
}
|
||||||
|
token = strtok(NULL, delimiter);
|
||||||
|
}
|
||||||
|
FREE_C_HEAP_ARRAY(char, subset_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Universe::should_verify_subset(uint subset) {
|
||||||
|
if (verify_flags & subset) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Universe::verify(VerifyOption option, const char* prefix) {
|
void Universe::verify(VerifyOption option, const char* prefix) {
|
||||||
// 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
|
||||||
|
@ -1122,33 +1173,55 @@ void Universe::verify(VerifyOption option, const char* prefix) {
|
||||||
|
|
||||||
FormatBuffer<> title("Verifying %s", prefix);
|
FormatBuffer<> title("Verifying %s", prefix);
|
||||||
GCTraceTime(Info, gc, verify) tm(title.buffer());
|
GCTraceTime(Info, gc, verify) tm(title.buffer());
|
||||||
log_debug(gc, verify)("Threads");
|
if (should_verify_subset(Verify_Threads)) {
|
||||||
Threads::verify();
|
log_debug(gc, verify)("Threads");
|
||||||
log_debug(gc, verify)("Heap");
|
Threads::verify();
|
||||||
heap()->verify(option);
|
}
|
||||||
log_debug(gc, verify)("SymbolTable");
|
if (should_verify_subset(Verify_Heap)) {
|
||||||
SymbolTable::verify();
|
log_debug(gc, verify)("Heap");
|
||||||
log_debug(gc, verify)("StringTable");
|
heap()->verify(option);
|
||||||
StringTable::verify();
|
}
|
||||||
|
if (should_verify_subset(Verify_SymbolTable)) {
|
||||||
|
log_debug(gc, verify)("SymbolTable");
|
||||||
|
SymbolTable::verify();
|
||||||
|
}
|
||||||
|
if (should_verify_subset(Verify_StringTable)) {
|
||||||
|
log_debug(gc, verify)("StringTable");
|
||||||
|
StringTable::verify();
|
||||||
|
}
|
||||||
|
if (should_verify_subset(Verify_CodeCache)) {
|
||||||
{
|
{
|
||||||
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
|
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
|
||||||
log_debug(gc, verify)("CodeCache");
|
log_debug(gc, verify)("CodeCache");
|
||||||
CodeCache::verify();
|
CodeCache::verify();
|
||||||
}
|
}
|
||||||
log_debug(gc, verify)("SystemDictionary");
|
}
|
||||||
SystemDictionary::verify();
|
if (should_verify_subset(Verify_SystemDictionary)) {
|
||||||
|
log_debug(gc, verify)("SystemDictionary");
|
||||||
|
SystemDictionary::verify();
|
||||||
|
}
|
||||||
#ifndef PRODUCT
|
#ifndef PRODUCT
|
||||||
log_debug(gc, verify)("ClassLoaderDataGraph");
|
if (should_verify_subset(Verify_ClassLoaderDataGraph)) {
|
||||||
ClassLoaderDataGraph::verify();
|
log_debug(gc, verify)("ClassLoaderDataGraph");
|
||||||
|
ClassLoaderDataGraph::verify();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
log_debug(gc, verify)("MetaspaceAux");
|
if (should_verify_subset(Verify_MetaspaceAux)) {
|
||||||
MetaspaceAux::verify_free_chunks();
|
log_debug(gc, verify)("MetaspaceAux");
|
||||||
log_debug(gc, verify)("JNIHandles");
|
MetaspaceAux::verify_free_chunks();
|
||||||
JNIHandles::verify();
|
}
|
||||||
log_debug(gc, verify)("C-heap");
|
if (should_verify_subset(Verify_JNIHandles)) {
|
||||||
os::check_heap();
|
log_debug(gc, verify)("JNIHandles");
|
||||||
log_debug(gc, verify)("CodeCache Oops");
|
JNIHandles::verify();
|
||||||
CodeCache::verify_oops();
|
}
|
||||||
|
if (should_verify_subset(Verify_CHeap)) {
|
||||||
|
log_debug(gc, verify)("C-heap");
|
||||||
|
os::check_heap();
|
||||||
|
}
|
||||||
|
if (should_verify_subset(Verify_CodeCacheOops)) {
|
||||||
|
log_debug(gc, verify)("CodeCache Oops");
|
||||||
|
CodeCache::verify_oops();
|
||||||
|
}
|
||||||
|
|
||||||
_verify_in_progress = false;
|
_verify_in_progress = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -255,6 +255,7 @@ class Universe: AllStatic {
|
||||||
|
|
||||||
// True during call to verify(). Should only be set/cleared in verify().
|
// True during call to verify(). Should only be set/cleared in verify().
|
||||||
static bool _verify_in_progress;
|
static bool _verify_in_progress;
|
||||||
|
static long verify_flags;
|
||||||
|
|
||||||
static uintptr_t _verify_oop_mask;
|
static uintptr_t _verify_oop_mask;
|
||||||
static uintptr_t _verify_oop_bits;
|
static uintptr_t _verify_oop_bits;
|
||||||
|
@ -463,6 +464,22 @@ class Universe: AllStatic {
|
||||||
static void init_self_patching_vtbl_list(void** list, int count);
|
static void init_self_patching_vtbl_list(void** list, int count);
|
||||||
|
|
||||||
// Debugging
|
// Debugging
|
||||||
|
enum VERIFY_FLAGS {
|
||||||
|
Verify_Threads = 1,
|
||||||
|
Verify_Heap = 2,
|
||||||
|
Verify_SymbolTable = 4,
|
||||||
|
Verify_StringTable = 8,
|
||||||
|
Verify_CodeCache = 16,
|
||||||
|
Verify_SystemDictionary = 32,
|
||||||
|
Verify_ClassLoaderDataGraph = 64,
|
||||||
|
Verify_MetaspaceAux = 128,
|
||||||
|
Verify_JNIHandles = 256,
|
||||||
|
Verify_CHeap = 512,
|
||||||
|
Verify_CodeCacheOops = 1024,
|
||||||
|
Verify_All = -1
|
||||||
|
};
|
||||||
|
static void initialize_verify_flags();
|
||||||
|
static bool should_verify_subset(uint subset);
|
||||||
static bool verify_in_progress() { return _verify_in_progress; }
|
static bool verify_in_progress() { return _verify_in_progress; }
|
||||||
static void verify(VerifyOption option, const char* prefix);
|
static void verify(VerifyOption option, const char* prefix);
|
||||||
static void verify(const char* prefix) {
|
static void verify(const char* prefix) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -2334,6 +2334,14 @@ public:
|
||||||
diagnostic(bool, VerifyDuringGC, false, \
|
diagnostic(bool, VerifyDuringGC, false, \
|
||||||
"Verify memory system during GC (between phases)") \
|
"Verify memory system during GC (between phases)") \
|
||||||
\
|
\
|
||||||
|
diagnostic(ccstrlist, VerifySubSet, "", \
|
||||||
|
"Memory sub-systems to verify when Verify*GC flag(s) " \
|
||||||
|
"are enabled. One or more sub-systems can be specified " \
|
||||||
|
"in a comma separated string. Sub-systems are: " \
|
||||||
|
"threads, heap, symbol_table, string_table, codecache, " \
|
||||||
|
"dictionary, classloader_data_graph, metaspace, jni_handles, " \
|
||||||
|
"c-heap, codecache_oops") \
|
||||||
|
\
|
||||||
diagnostic(bool, GCParallelVerificationEnabled, true, \
|
diagnostic(bool, GCParallelVerificationEnabled, true, \
|
||||||
"Enable parallel memory system verification") \
|
"Enable parallel memory system verification") \
|
||||||
\
|
\
|
||||||
|
|
94
hotspot/test/gc/TestVerifySubSet.java
Normal file
94
hotspot/test/gc/TestVerifySubSet.java
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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 TestVerifySubSet.java
|
||||||
|
* @key gc
|
||||||
|
* @bug 8072725
|
||||||
|
* @summary Test VerifySubSet option
|
||||||
|
* @library /testlibrary
|
||||||
|
* @modules java.base/sun.misc
|
||||||
|
* java.management
|
||||||
|
*/
|
||||||
|
|
||||||
|
import jdk.test.lib.OutputAnalyzer;
|
||||||
|
import jdk.test.lib.ProcessTools;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
class RunSystemGC {
|
||||||
|
public static void main(String args[]) throws Exception {
|
||||||
|
System.gc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TestVerifySubSet {
|
||||||
|
private static String[] getTestJavaOpts() {
|
||||||
|
String testVmOptsStr = System.getProperty("test.java.opts");
|
||||||
|
if (!testVmOptsStr.isEmpty()) {
|
||||||
|
return testVmOptsStr.split(" ");
|
||||||
|
} else {
|
||||||
|
return new String[] {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OutputAnalyzer runTest(String subset) throws Exception {
|
||||||
|
ArrayList<String> vmOpts = new ArrayList();
|
||||||
|
|
||||||
|
Collections.addAll(vmOpts, getTestJavaOpts());
|
||||||
|
Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
|
||||||
|
"-XX:+VerifyBeforeGC",
|
||||||
|
"-XX:+VerifyAfterGC",
|
||||||
|
"-Xlog:gc+verify=debug",
|
||||||
|
"-XX:VerifySubSet="+subset,
|
||||||
|
RunSystemGC.class.getName()});
|
||||||
|
ProcessBuilder pb =
|
||||||
|
ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
|
||||||
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||||
|
|
||||||
|
System.out.println("Output:\n" + output.getOutput());
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String args[]) throws Exception {
|
||||||
|
|
||||||
|
OutputAnalyzer output;
|
||||||
|
|
||||||
|
output = runTest("heap, threads, codecache, metaspace");
|
||||||
|
output.shouldContain("Heap");
|
||||||
|
output.shouldContain("Threads");
|
||||||
|
output.shouldContain("CodeCache");
|
||||||
|
output.shouldContain("MetaspaceAux");
|
||||||
|
output.shouldNotContain("SymbolTable");
|
||||||
|
output.shouldNotContain("StringTable");
|
||||||
|
output.shouldNotContain("SystemDictionary");
|
||||||
|
output.shouldNotContain("CodeCache Oops");
|
||||||
|
output.shouldHaveExitValue(0);
|
||||||
|
|
||||||
|
output = runTest("hello, threads, codecache, metaspace");
|
||||||
|
output.shouldContain("memory sub-system is unknown, please correct it");
|
||||||
|
output.shouldNotContain("Threads");
|
||||||
|
output.shouldNotContain("CodeCache");
|
||||||
|
output.shouldNotContain("MetaspaceAux");
|
||||||
|
output.shouldHaveExitValue(1);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue