# HG changeset patch # User ehelin # Date 1453200515 -3600 # Node ID 9fdbfe36e9cb368df013e02622e58a410729cf17 # Parent f8a8d6664a194019741ec810bd094d8959d2400c# Parent 39376b4613b5d4834007a91b8221d8c1b8886c97 Merge diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/classfile/altHashing.cpp --- a/hotspot/src/share/vm/classfile/altHashing.cpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/classfile/altHashing.cpp Tue Jan 19 11:48:35 2016 +0100 @@ -300,4 +300,8 @@ testMurmur3_32_ByteArray(); testEquivalentHashes(); } + +void AltHashing_test() { + AltHashing::test_alt_hash(); +} #endif // PRODUCT diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/compiler/directivesParser.cpp --- a/hotspot/src/share/vm/compiler/directivesParser.cpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/compiler/directivesParser.cpp Tue Jan 19 11:48:35 2016 +0100 @@ -608,7 +608,7 @@ cd.clean_tmp(); } -bool DirectivesParser::test() { +void DirectivesParser::test() { DirectivesParser::test("{}", false); DirectivesParser::test("[]", true); DirectivesParser::test("[{}]", false); @@ -742,8 +742,10 @@ " }" "\n" " }" "\n" "]" "\n", false); +} - return true; +void DirectivesParser_test() { + DirectivesParser::test(); } #endif diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/compiler/directivesParser.hpp --- a/hotspot/src/share/vm/compiler/directivesParser.hpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/compiler/directivesParser.hpp Tue Jan 19 11:48:35 2016 +0100 @@ -136,7 +136,7 @@ #ifndef PRODUCT static void test(const char* json, bool valid); public: - static bool test(); + static void test(); #endif }; diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/gc/shared/collectedHeap.cpp --- a/hotspot/src/share/vm/gc/shared/collectedHeap.cpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/gc/shared/collectedHeap.cpp Tue Jan 19 11:48:35 2016 +0100 @@ -630,4 +630,8 @@ assert(!heap->is_in(after_heap), "after_heap: " PTR_FORMAT " is unexpectedly in the heap", p2i(after_heap)); } + +void CollectedHeap_test() { + CollectedHeap::test_is_in(); +} #endif diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/gc/shared/gcTimer.cpp --- a/hotspot/src/share/vm/gc/shared/gcTimer.cpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/gc/shared/gcTimer.cpp Tue Jan 19 11:48:35 2016 +0100 @@ -388,7 +388,7 @@ } }; -void GCTimerAllTest::all() { +void GCTimer_test() { GCTimerTest::all(); TimePartitionPhasesIteratorTest::all(); } diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/gc/shared/gcTimer.hpp --- a/hotspot/src/share/vm/gc/shared/gcTimer.hpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/gc/shared/gcTimer.hpp Tue Jan 19 11:48:35 2016 +0100 @@ -185,16 +185,4 @@ virtual GCPhase* next(); }; - -/////////////// Unit tests /////////////// - -#ifndef PRODUCT - -class GCTimerAllTest { - public: - static void all(); -}; - -#endif - #endif // SHARE_VM_GC_SHARED_GCTIMER_HPP diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/memory/guardedMemory.cpp --- a/hotspot/src/share/vm/memory/guardedMemory.cpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/memory/guardedMemory.cpp Tue Jan 19 11:48:35 2016 +0100 @@ -157,5 +157,9 @@ assert(GuardedMemory::free_copy(no_data_copy), "Expected valid guards even for no data copy"); } +void GuardedMemory_test() { + GuardedMemory::test_guarded_memory(); +} + #endif // !PRODUCT diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/oops/arrayOop.cpp --- a/hotspot/src/share/vm/oops/arrayOop.cpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/oops/arrayOop.cpp Tue Jan 19 11:48:35 2016 +0100 @@ -39,21 +39,24 @@ return (julong)(size_t)bytes == bytes; } -void arrayOopDesc::test_max_array_length() { - assert(check_max_length_overflow(T_BOOLEAN), "size_t overflow for boolean array"); - assert(check_max_length_overflow(T_CHAR), "size_t overflow for char array"); - assert(check_max_length_overflow(T_FLOAT), "size_t overflow for float array"); - assert(check_max_length_overflow(T_DOUBLE), "size_t overflow for double array"); - assert(check_max_length_overflow(T_BYTE), "size_t overflow for byte array"); - assert(check_max_length_overflow(T_SHORT), "size_t overflow for short array"); - assert(check_max_length_overflow(T_INT), "size_t overflow for int array"); - assert(check_max_length_overflow(T_LONG), "size_t overflow for long array"); - assert(check_max_length_overflow(T_OBJECT), "size_t overflow for object array"); - assert(check_max_length_overflow(T_ARRAY), "size_t overflow for array array"); - assert(check_max_length_overflow(T_NARROWOOP), "size_t overflow for narrowOop array"); +static void test_max_array_length() { + assert(arrayOopDesc::check_max_length_overflow(T_BOOLEAN), "size_t overflow for boolean array"); + assert(arrayOopDesc::check_max_length_overflow(T_CHAR), "size_t overflow for char array"); + assert(arrayOopDesc::check_max_length_overflow(T_FLOAT), "size_t overflow for float array"); + assert(arrayOopDesc::check_max_length_overflow(T_DOUBLE), "size_t overflow for double array"); + assert(arrayOopDesc::check_max_length_overflow(T_BYTE), "size_t overflow for byte array"); + assert(arrayOopDesc::check_max_length_overflow(T_SHORT), "size_t overflow for short array"); + assert(arrayOopDesc::check_max_length_overflow(T_INT), "size_t overflow for int array"); + assert(arrayOopDesc::check_max_length_overflow(T_LONG), "size_t overflow for long array"); + assert(arrayOopDesc::check_max_length_overflow(T_OBJECT), "size_t overflow for object array"); + assert(arrayOopDesc::check_max_length_overflow(T_ARRAY), "size_t overflow for array array"); + assert(arrayOopDesc::check_max_length_overflow(T_NARROWOOP), "size_t overflow for narrowOop array"); // T_VOID and T_ADDRESS are not supported by max_array_length() } +void arrayOopDesc_test() { + test_max_array_length(); +} #endif //PRODUCT diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/oops/arrayOop.hpp --- a/hotspot/src/share/vm/oops/arrayOop.hpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/oops/arrayOop.hpp Tue Jan 19 11:48:35 2016 +0100 @@ -127,8 +127,6 @@ // for unit testing #ifndef PRODUCT static bool check_max_length_overflow(BasicType type); - static int32_t old_max_array_length(BasicType type); - static void test_max_array_length(); #endif }; diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/runtime/objectMonitor.cpp --- a/hotspot/src/share/vm/runtime/objectMonitor.cpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/runtime/objectMonitor.cpp Tue Jan 19 11:48:35 2016 +0100 @@ -2470,4 +2470,8 @@ void ObjectMonitor::print() { } + +void ObjectMonitor_test() { + ObjectMonitor::sanity_checks(); +} #endif diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/runtime/vmStructs.cpp --- a/hotspot/src/share/vm/runtime/vmStructs.cpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp Tue Jan 19 11:48:35 2016 +0100 @@ -3496,4 +3496,8 @@ } } } + +void VMStructs_test() { + VMStructs::test(); +} #endif diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/utilities/globalDefinitions.cpp --- a/hotspot/src/share/vm/utilities/globalDefinitions.cpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/utilities/globalDefinitions.cpp Tue Jan 19 11:48:35 2016 +0100 @@ -357,6 +357,11 @@ } #ifndef PRODUCT +// For unit testing only +class GlobalDefinitions { +public: + static void test_globals(); +}; void GlobalDefinitions::test_globals() { intptr_t page_sizes[] = { os::vm_page_size(), 4096, 8192, 65536, 2*1024*1024 }; @@ -384,4 +389,8 @@ } } +void GlobalDefinitions_test() { + GlobalDefinitions::test_globals(); +} + #endif // PRODUCT diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/utilities/globalDefinitions.hpp --- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp Tue Jan 19 11:48:35 2016 +0100 @@ -1452,14 +1452,4 @@ return *(void**)addr; } -#ifndef PRODUCT - -// For unit testing only -class GlobalDefinitions { -public: - static void test_globals(); -}; - -#endif // PRODUCT - #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/utilities/internalVMTests.cpp --- a/hotspot/src/share/vm/utilities/internalVMTests.cpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp Tue Jan 19 11:48:35 2016 +0100 @@ -26,22 +26,9 @@ #ifndef PRODUCT -#include "classfile/altHashing.hpp" -#include "compiler/directivesParser.hpp" -#include "gc/shared/collectedHeap.hpp" -#include "gc/shared/gcTimer.hpp" -#include "memory/guardedMemory.hpp" #include "utilities/internalVMTests.hpp" -#include "utilities/json.hpp" #include "utilities/macros.hpp" #include "utilities/ostream.hpp" -#include "utilities/quickSort.hpp" -#if INCLUDE_ALL_GCS -#include "gc/g1/heapRegionRemSet.hpp" -#endif -#if INCLUDE_VM_STRUCTS -#include "runtime/vmStructs.hpp" -#endif #define run_unit_test(unit_test_function_call) \ tty->print_cr("Running test: " #unit_test_function_call); \ @@ -67,6 +54,21 @@ void TestChunkedList_test(); void Test_log_length(); void Test_TempNewSymbol(); +void GlobalDefinitions_test(); +void GCTimer_test(); +void arrayOopDesc_test(); +void CollectedHeap_test(); +void QuickSort_test(); +void GuardedMemory_test(); +void AltHashing_test(); +void ObjectMonitor_test(); +void JSON_test(); +void DirectivesParser_test(); + +#if INCLUDE_VM_STRUCTS +void VMStructs_test(); +#endif + #if INCLUDE_ALL_GCS void TestOldFreeSpaceCalculation_test(); void TestG1BiasedArray_test(); @@ -74,7 +76,7 @@ void TestCodeCacheRemSet_test(); void FreeRegionList_test(); void IHOP_test(); -void test_memset_with_concurrent_readers() NOT_DEBUG_RETURN; +void test_memset_with_concurrent_readers(); void TestPredictions_test(); void WorkerDataArray_test(); #endif @@ -90,28 +92,28 @@ run_unit_test(TestMetaspaceAux_test()); run_unit_test(TestMetachunk_test()); run_unit_test(TestVirtualSpaceNode_test()); - run_unit_test(GlobalDefinitions::test_globals()); - run_unit_test(GCTimerAllTest::all()); - run_unit_test(arrayOopDesc::test_max_array_length()); - run_unit_test(CollectedHeap::test_is_in()); - run_unit_test(QuickSort::test_quick_sort()); - run_unit_test(GuardedMemory::test_guarded_memory()); - run_unit_test(AltHashing::test_alt_hash()); + run_unit_test(GlobalDefinitions_test()); + run_unit_test(GCTimer_test()); + run_unit_test(arrayOopDesc_test()); + run_unit_test(CollectedHeap_test()); + run_unit_test(QuickSort_test()); + run_unit_test(GuardedMemory_test()); + run_unit_test(AltHashing_test()); run_unit_test(TestNewSize_test()); run_unit_test(TestOldSize_test()); run_unit_test(TestKlass_test()); run_unit_test(TestBitMap_test()); run_unit_test(TestAsUtf8()); run_unit_test(TestResourcehash_test()); - run_unit_test(ObjectMonitor::sanity_checks()); + run_unit_test(ObjectMonitor_test()); run_unit_test(Test_linked_list()); run_unit_test(TestChunkedList_test()); - run_unit_test(JSONTest::test()); + run_unit_test(JSON_test()); run_unit_test(Test_log_length()); - run_unit_test(DirectivesParser::test()); + run_unit_test(DirectivesParser_test()); run_unit_test(Test_TempNewSymbol()); #if INCLUDE_VM_STRUCTS - run_unit_test(VMStructs::test()); + run_unit_test(VMStructs_test()); #endif #if INCLUDE_ALL_GCS run_unit_test(TestOldFreeSpaceCalculation_test()); diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/utilities/json.cpp --- a/hotspot/src/share/vm/utilities/json.cpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/utilities/json.cpp Tue Jan 19 11:48:35 2016 +0100 @@ -687,6 +687,24 @@ } #ifndef PRODUCT +class JSONTest : public JSON { + public: + static void test(); + + private: + JSONTest(const char* text); + static void test(const char* json, bool valid); + + void log(uint level, const char* format, ...) ATTRIBUTE_PRINTF(3, 4); + + bool callback(JSON_TYPE t, JSON_VAL* v, uint level); + JSON_TYPE prev; +}; + +void JSON_test() { + JSONTest::test(); +} + void JSONTest::test(const char* text, bool should_pass) { JSONTest json(text); if (should_pass) { @@ -707,7 +725,7 @@ parse(); } -bool JSONTest::test() { +void JSONTest::test() { JSONTest::test("{}", true); JSONTest::test("[]", true); JSONTest::test(" { } ", true); @@ -842,8 +860,6 @@ " blocking_compile: true" "\n" " }," "\n" "]" "\n", true); - - return true; } void JSONTest::log(uint indent, const char* format, ...) { diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/utilities/json.hpp --- a/hotspot/src/share/vm/utilities/json.hpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/utilities/json.hpp Tue Jan 19 11:48:35 2016 +0100 @@ -108,20 +108,4 @@ const char* strerror(JSON_ERROR e); }; -#ifndef PRODUCT -class JSONTest : public JSON { - public: - static bool test(); - - private: - JSONTest(const char* text); - static void test(const char* json, bool valid); - - void log(uint level, const char* format, ...) ATTRIBUTE_PRINTF(3, 4); - - bool callback(JSON_TYPE t, JSON_VAL* v, uint level); - JSON_TYPE prev; -}; -#endif - #endif // SHARE_VM_UTILITIES_JSON_HPP diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/utilities/quickSort.cpp --- a/hotspot/src/share/vm/utilities/quickSort.cpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/utilities/quickSort.cpp Tue Jan 19 11:48:35 2016 +0100 @@ -72,7 +72,7 @@ } } -void QuickSort::print_array(const char* prefix, int* array, int length) { +static void print_array(const char* prefix, int* array, int length) { tty->print("%s:", prefix); for (int i = 0; i < length; i++) { tty->print(" %d", array[i]); @@ -80,7 +80,7 @@ tty->cr(); } -bool QuickSort::compare_arrays(int* actual, int* expected, int length) { +static bool compare_arrays(int* actual, int* expected, int length) { for (int i = 0; i < length; i++) { if (actual[i] != expected[i]) { print_array("Sorted array ", actual, length); @@ -92,12 +92,12 @@ } template -bool QuickSort::sort_and_compare(int* arrayToSort, int* expectedResult, int length, C comparator, bool idempotent) { - sort(arrayToSort, length, comparator, idempotent); +static bool sort_and_compare(int* arrayToSort, int* expectedResult, int length, C comparator, bool idempotent = false) { + QuickSort::sort(arrayToSort, length, comparator, idempotent); return compare_arrays(arrayToSort, expectedResult, length); } -void QuickSort::test_quick_sort() { +void QuickSort_test() { { int* test_array = NULL; int* expected_array = NULL; @@ -208,15 +208,14 @@ // Now sort them once with the test_even_odd_comparator. Then sort the // test_array one more time with test_even_odd_comparator and verify that // it is idempotent. - sort(expected_array, length, test_even_odd_comparator, true); - sort(test_array, length, test_even_odd_comparator, true); + QuickSort::sort(expected_array, length, test_even_odd_comparator, true); + QuickSort::sort(test_array, length, test_even_odd_comparator, true); assert(compare_arrays(test_array, expected_array, length), "Sorting identical arrays rendered different results"); - sort(test_array, length, test_even_odd_comparator, true); + QuickSort::sort(test_array, length, test_even_odd_comparator, true); assert(compare_arrays(test_array, expected_array, length), "Sorting already sorted array changed order of elements - not idempotent"); FREE_C_HEAP_ARRAY(int, test_array); FREE_C_HEAP_ARRAY(int, expected_array); } } - #endif diff -r f8a8d6664a19 -r 9fdbfe36e9cb hotspot/src/share/vm/utilities/quickSort.hpp --- a/hotspot/src/share/vm/utilities/quickSort.hpp Tue Jan 19 10:02:22 2016 +0100 +++ b/hotspot/src/share/vm/utilities/quickSort.hpp Tue Jan 19 11:48:35 2016 +0100 @@ -124,14 +124,6 @@ inner_sort(array, length, comparator); } } - - // for unit testing -#ifndef PRODUCT - static void print_array(const char* prefix, int* array, int length); - static bool compare_arrays(int* actual, int* expected, int length); - template static bool sort_and_compare(int* arrayToSort, int* expectedResult, int length, C comparator, bool idempotent = false); - static void test_quick_sort(); -#endif };