# HG changeset patch # User apetcher # Date 1535641681 14400 # Node ID 6ba2f471478ba594049d58a6620bd914fc679e69 # Parent 2aefd58f8ec55616df00a8419e58eaaa70c5070e# Parent 1ddd1ec044311512c55643bed641859e78b9d25e mrege diff -r 2aefd58f8ec5 -r 6ba2f471478b .hgtags --- a/.hgtags Wed Aug 29 14:48:09 2018 -0400 +++ b/.hgtags Thu Aug 30 11:08:01 2018 -0400 @@ -496,15 +496,17 @@ 14708e1acdc3974f4539027cbbcfa6d69f83cf51 jdk-11+21 00b16d0457e43d23f6ca5ade6b243edce62750a0 jdk-12+1 9937ef7499dcd7673714517fd5e450410c14ba4e jdk-11+22 +69b438908512d3dfef5852c6a843a5778333a309 jdk-12+2 1edcf36fe15f79d6228d1a63eb680878e2386480 jdk-11+23 +990db216e7199b2ba9989d8fa20b657e0ca7d969 jdk-12+3 ea900a7dc7d77dee30865c60eabd87fc24b1037c jdk-11+24 +499b873761d8e8a1cc4aa649daf04cbe98cbce77 jdk-12+4 331888ea4a788df801b1edf8836646cd25fc758b jdk-11+25 +f8696e0ab9b795030429fc3374ec03e378fd9ed7 jdk-12+5 945ba9278a272a5477ffb1b3ea1b04174fed8036 jdk-11+26 +7939b3c4e4088bf4f70ec5bbd8030393b653372f jdk-12+6 9d7d74c6f2cbe522e39fa22dc557fdd3f79b32ad jdk-11+27 -69b438908512d3dfef5852c6a843a5778333a309 jdk-12+2 -990db216e7199b2ba9989d8fa20b657e0ca7d969 jdk-12+3 -499b873761d8e8a1cc4aa649daf04cbe98cbce77 jdk-12+4 -f8696e0ab9b795030429fc3374ec03e378fd9ed7 jdk-12+5 -7939b3c4e4088bf4f70ec5bbd8030393b653372f jdk-12+6 ef57958c7c511162da8d9a75f0b977f0f7ac464e jdk-12+7 +76072a077ee1d815152d45d1692c4b36c53c5c49 jdk-11+28 492b366f8e5784cc4927c2c98f9b8a3f16c067eb jdk-12+8 +31b159f30fb281016c5f0c103552809aeda84063 jdk-12+9 diff -r 2aefd58f8ec5 -r 6ba2f471478b make/Docs.gmk --- a/make/Docs.gmk Wed Aug 29 14:48:09 2018 -0400 +++ b/make/Docs.gmk Thu Aug 30 11:08:01 2018 -0400 @@ -61,7 +61,7 @@ $(SUPPORT_OUTPUTDIR)/rmic/* $(TOPDIR)/src/*/share/doc/stub) # URLs -JAVADOC_BASE_URL := http://www.oracle.com/pls/topic/lookup?ctx=javase10&id=homepage +JAVADOC_BASE_URL := http://www.oracle.com/pls/topic/lookup?ctx=javase$(VERSION_NUMBER)&id=homepage BUG_SUBMIT_URL := http://bugreport.java.com/bugreport/ COPYRIGHT_URL := {@docroot}/../legal/copyright.html LICENSE_URL := http://www.oracle.com/technetwork/java/javase/terms/license/java$(VERSION_NUMBER)speclicense.html diff -r 2aefd58f8ec5 -r 6ba2f471478b make/autoconf/configure --- a/make/autoconf/configure Wed Aug 29 14:48:09 2018 -0400 +++ b/make/autoconf/configure Thu Aug 30 11:08:01 2018 -0400 @@ -122,14 +122,18 @@ if test "x$CUSTOM_CONFIG_DIR" != x; then # Generate configure script with custom hooks compiled in. custom_patcher='sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|"' + custom_script_dir_include="-I$CUSTOM_CONFIG_DIR" else custom_patcher='cat' + custom_script_dir_include="" fi mkdir -p $build_support_dir # Call autoconf but replace the "magic" variable in configure.ac if requested. + cat $conf_script_dir/configure.ac | eval $custom_patcher | \ - ${AUTOCONF} -W all -I$conf_script_dir - > $generated_script + ${AUTOCONF} -W all $custom_script_dir_include -I$conf_script_dir - \ + > $generated_script rm -rf autom4te.cache # Sanity check diff -r 2aefd58f8ec5 -r 6ba2f471478b make/autoconf/hotspot.m4 --- a/make/autoconf/hotspot.m4 Wed Aug 29 14:48:09 2018 -0400 +++ b/make/autoconf/hotspot.m4 Thu Aug 30 11:08:01 2018 -0400 @@ -517,9 +517,6 @@ # Used for verification of Makefiles by check-jvm-feature AC_SUBST(VALID_JVM_FEATURES) - - # We don't support --with-jvm-interpreter anymore, use zero instead. - BASIC_DEPRECATED_ARG_WITH(jvm-interpreter) ]) ############################################################################### diff -r 2aefd58f8ec5 -r 6ba2f471478b make/autoconf/jdk-options.m4 --- a/make/autoconf/jdk-options.m4 Wed Aug 29 14:48:09 2018 -0400 +++ b/make/autoconf/jdk-options.m4 Thu Aug 30 11:08:01 2018 -0400 @@ -126,10 +126,6 @@ else AC_MSG_ERROR([Invalid value for --enable-openjdk-only: $enable_openjdk_only]) fi - - # custom-make-dir is deprecated. Please use your custom-hook.m4 to override - # the IncludeCustomExtension macro. - BASIC_DEPRECATED_ARG_WITH(custom-make-dir) ]) AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS], @@ -350,16 +346,6 @@ AC_MSG_ERROR([Allowed native debug symbols are: none, internal, external, zipped]) fi - # --enable-debug-symbols is deprecated. - # Please use --with-native-debug-symbols=[internal,external,zipped] . - BASIC_DEPRECATED_ARG_ENABLE(debug-symbols, debug_symbols, - [Please use --with-native-debug-symbols=[[internal,external,zipped]] .]) - - # --enable-zip-debug-info is deprecated. - # Please use --with-native-debug-symbols=zipped . - BASIC_DEPRECATED_ARG_ENABLE(zip-debug-info, zip_debug_info, - [Please use --with-native-debug-symbols=zipped .]) - AC_SUBST(COMPILE_WITH_DEBUG_SYMBOLS) AC_SUBST(COPY_DEBUG_SYMBOLS) AC_SUBST(ZIP_EXTERNAL_DEBUG_SYMBOLS) diff -r 2aefd58f8ec5 -r 6ba2f471478b make/autoconf/jdk-version.m4 --- a/make/autoconf/jdk-version.m4 Wed Aug 29 14:48:09 2018 -0400 +++ b/make/autoconf/jdk-version.m4 Thu Aug 30 11:08:01 2018 -0400 @@ -57,15 +57,6 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS], [ - # Warn user that old version arguments are deprecated. - BASIC_DEPRECATED_ARG_WITH([milestone]) - BASIC_DEPRECATED_ARG_WITH([update-version]) - BASIC_DEPRECATED_ARG_WITH([user-release-suffix]) - BASIC_DEPRECATED_ARG_WITH([build-number]) - BASIC_DEPRECATED_ARG_WITH([version-major]) - BASIC_DEPRECATED_ARG_WITH([version-minor]) - BASIC_DEPRECATED_ARG_WITH([version-security]) - # Source the version numbers file . $AUTOCONF_DIR/version-numbers @@ -443,7 +434,7 @@ AC_MSG_ERROR([--with-version-date must have a value]) elif test "x$with_version_date" != x; then if [ ! [[ $with_version_date =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] ]; then - AC_MSG_ERROR(["$with_version_date" is not a valid version date]) + AC_MSG_ERROR(["$with_version_date" is not a valid version date]) else VERSION_DATE="$with_version_date" fi diff -r 2aefd58f8ec5 -r 6ba2f471478b make/autoconf/libraries.m4 --- a/make/autoconf/libraries.m4 Wed Aug 29 14:48:09 2018 -0400 +++ b/make/autoconf/libraries.m4 Thu Aug 30 11:08:01 2018 -0400 @@ -180,13 +180,6 @@ AC_SUBST(LIBDL) LIBS="$save_LIBS" - # Deprecated libraries, keep the flags for backwards compatibility - if test "x$OPENJDK_TARGET_OS" = "xwindows"; then - BASIC_DEPRECATED_ARG_WITH([dxsdk]) - BASIC_DEPRECATED_ARG_WITH([dxsdk-lib]) - BASIC_DEPRECATED_ARG_WITH([dxsdk-include]) - fi - # Control if libzip can use mmap. Available for purposes of overriding. LIBZIP_CAN_USE_MMAP=true AC_SUBST(LIBZIP_CAN_USE_MMAP) @@ -217,4 +210,3 @@ AC_SUBST(STLPORT_LIB) fi ]) - diff -r 2aefd58f8ec5 -r 6ba2f471478b make/nb_native/nbproject/configurations.xml --- a/make/nb_native/nbproject/configurations.xml Wed Aug 29 14:48:09 2018 -0400 +++ b/make/nb_native/nbproject/configurations.xml Thu Aug 30 11:08:01 2018 -0400 @@ -2843,8 +2843,6 @@ elfStringTable.hpp elfSymbolTable.cpp elfSymbolTable.hpp - errorReporter.cpp - errorReporter.hpp events.cpp events.hpp exceptions.cpp @@ -15166,16 +15164,6 @@ tool="3" flavor2="0"> - - - - - - - - = first_arg ; i-- ) { if (args[i].first()->is_Register()) { ; } else if (args[i].first()->is_FloatRegister()) { diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/cpu/ppc/frame_ppc.cpp --- a/src/hotspot/cpu/ppc/frame_ppc.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/cpu/ppc/frame_ppc.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -67,8 +67,8 @@ return false; } - // Unextended sp must be within the stack and above or equal sp - bool unextended_sp_safe = (unextended_sp < thread->stack_base()) && (unextended_sp >= sp); + // Unextended sp must be within the stack + bool unextended_sp_safe = (unextended_sp < thread->stack_base()); if (!unextended_sp_safe) { return false; @@ -76,9 +76,10 @@ // An fp must be within the stack and above (but not equal) sp. bool fp_safe = (fp <= thread->stack_base()) && (fp > sp); - // an interpreter fp must be within the stack and above (but not equal) sp - bool fp_interp_safe = (fp <= thread->stack_base()) && (fp > sp) && - ((fp - sp) >= (ijava_state_size + top_ijava_frame_abi_size)); + // An interpreter fp must be within the stack and above (but not equal) sp. + // Moreover, it must be at least the size of the ijava_state structure. + bool fp_interp_safe = (fp <= thread->stack_base()) && (fp > sp) && + ((fp - sp) >= ijava_state_size); // We know sp/unextended_sp are safe, only fp is questionable here diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp --- a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -1681,7 +1681,7 @@ __ z_lg(Z_R1/*active_handles*/, thread_(active_handles)); __ clear_mem(Address(Z_R1, JNIHandleBlock::top_offset_in_bytes()), 4); - // Bandle exceptions (exception handling will handle unlocking!). + // Handle exceptions (exception handling will handle unlocking!). { Label L; __ load_and_test_long(Z_R0/*pending_exception*/, thread_(pending_exception)); @@ -1710,17 +1710,9 @@ __ notify_method_exit(true/*native_method*/, ilgl, InterpreterMacroAssembler::NotifyJVMTI); // Move native method result back into proper registers and return. - // C++ interpreter does not use result handler. So do we need to here? TODO(ZASM): check if correct. - { NearLabel no_oop_or_null; __ mem2freg_opt(Z_FRET, Address(Z_fp, _z_ijava_state_neg(fresult))); - __ load_and_test_long(Z_RET, Address(Z_fp, _z_ijava_state_neg(lresult))); - __ z_bre(no_oop_or_null); // No unboxing if the result is NULL. - __ load_absolute_address(Z_R1, AbstractInterpreter::result_handler(T_OBJECT)); - __ compareU64_and_branch(Z_R1, Rresult_handler, Assembler::bcondNotEqual, no_oop_or_null); - __ z_lg(Z_RET, oop_tmp_offset, Z_fp); - __ verify_oop(Z_RET); - __ bind(no_oop_or_null); - } + __ mem2reg_opt(Z_RET, Address(Z_fp, _z_ijava_state_neg(lresult))); + __ call_stub(Rresult_handler); // Pop the native method's interpreter frame. __ pop_interpreter_frame(Z_R14 /*return_pc*/, Z_ARG2/*tmp1*/, Z_ARG3/*tmp2*/); diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/cpu/x86/globals_x86.hpp --- a/src/hotspot/cpu/x86/globals_x86.hpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/cpu/x86/globals_x86.hpp Thu Aug 30 11:08:01 2018 -0400 @@ -119,7 +119,7 @@ product(bool, UseStoreImmI16, true, \ "Use store immediate 16-bits value instruction on x86") \ \ - product(intx, UseAVX, 3, \ + product(intx, UseAVX, 2, \ "Highest supported AVX instructions set on x86/x64") \ range(0, 99) \ \ diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/os/solaris/attachListener_solaris.cpp --- a/src/hotspot/os/solaris/attachListener_solaris.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/os/solaris/attachListener_solaris.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -294,12 +294,17 @@ int return_fd = -1; SolarisAttachOperation* op = NULL; - // no listener + // wait up to 10 seconds for listener to be up and running jint res = 0; - if (!AttachListener::is_initialized()) { - // how did we get here? - debug_only(warning("door_call when not enabled")); - res = (jint)SolarisAttachListener::ATTACH_ERROR_INTERNAL; + int sleep_count = 0; + while (!AttachListener::is_initialized()) { + sleep(1); // 1 second + sleep_count++; + if (sleep_count > 10) { // try for 10 seconds + debug_only(warning("door_call when not enabled")); + res = (jint)SolarisAttachListener::ATTACH_ERROR_INTERNAL; + break; + } } // check client credentials diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/os/windows/attachListener_windows.cpp --- a/src/hotspot/os/windows/attachListener_windows.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/os/windows/attachListener_windows.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -184,9 +184,14 @@ // Also we need to be careful not to execute anything that results in more than a 4k stack. // int Win32AttachListener::enqueue(char* cmd, char* arg0, char* arg1, char* arg2, char* pipename) { - // listener not running - if (!AttachListener::is_initialized()) { - return ATTACH_ERROR_DISABLED; + // wait up to 10 seconds for listener to be up and running + int sleep_count = 0; + while (!AttachListener::is_initialized()) { + Sleep(1000); // 1 second + sleep_count++; + if (sleep_count > 10) { // try for 10 seconds + return ATTACH_ERROR_DISABLED; + } } // check that all paramteres to the operation diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/code/codeHeapState.cpp --- a/src/hotspot/share/code/codeHeapState.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/code/codeHeapState.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -2168,9 +2168,8 @@ // this_blob->as_nmethod_or_null() is safe. Inlined, maybe invisible on stack. nmethod* nm = this_blob->as_nmethod_or_null(); - Method* method = (nm == NULL) ? NULL : nm->method(); // may be uninitialized, i.e. != NULL, but invalid - if ((nm != NULL) && (method != NULL) && (cbType != nMethod_dead) && (cbType != nMethod_inconstruction) && - os::is_readable_pointer(method) && os::is_readable_pointer(method->constants())) { + if (CompiledMethod::nmethod_access_is_safe(nm)) { + Method* method = nm->method(); ResourceMark rm; //---< collect all data to locals as quickly as possible >--- unsigned int total_size = nm->total_size(); diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/code/compiledMethod.cpp --- a/src/hotspot/share/code/compiledMethod.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/code/compiledMethod.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -619,3 +619,18 @@ } } } + +// Iterating over all nmethods, e.g. with the help of CodeCache::nmethods_do(fun) was found +// to not be inherently safe. There is a chance that fields are seen which are not properly +// initialized. This happens despite the fact that nmethods_do() asserts the CodeCache_lock +// to be held. +// To bundle knowledge about necessary checks in one place, this function was introduced. +// It is not claimed that these checks are sufficient, but they were found to be necessary. +bool CompiledMethod::nmethod_access_is_safe(nmethod* nm) { + Method* method = (nm == NULL) ? NULL : nm->method(); // nm->method() may be uninitialized, i.e. != NULL, but invalid + return (nm != NULL) && (method != NULL) && (method->signature() != NULL) && + !nm->is_zombie() && !nm->is_not_installed() && + os::is_readable_pointer(method) && + os::is_readable_pointer(method->constants()) && + os::is_readable_pointer(method->signature()); +} diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/code/compiledMethod.hpp --- a/src/hotspot/share/code/compiledMethod.hpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/code/compiledMethod.hpp Thu Aug 30 11:08:01 2018 -0400 @@ -238,6 +238,8 @@ return _mark_for_deoptimization_status != deoptimize_noupdate; } + static bool nmethod_access_is_safe(nmethod* nm); + // tells whether frames described by this nmethod can be deoptimized // note: native wrappers cannot be deoptimized. bool can_be_deoptimized() const { return is_java_method(); } diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/compiler/compileBroker.cpp --- a/src/hotspot/share/compiler/compileBroker.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/compiler/compileBroker.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -1637,6 +1637,12 @@ * out to be a problem. */ void CompileBroker::shutdown_compiler_runtime(AbstractCompiler* comp, CompilerThread* thread) { + // Free buffer blob, if allocated + if (thread->get_buffer_blob() != NULL) { + MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); + CodeCache::free(thread->get_buffer_blob()); + } + if (comp->should_perform_shutdown()) { // There are two reasons for shutting down the compiler // 1) compiler runtime initialization failed @@ -1767,6 +1773,11 @@ tty->print_cr("Removing compiler thread %s after " JLONG_FORMAT " ms idle time", thread->name(), thread->idle_time_millis()); } + // Free buffer blob, if allocated + if (thread->get_buffer_blob() != NULL) { + MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); + CodeCache::free(thread->get_buffer_blob()); + } return; // Stop this thread. } } diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.cpp --- a/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, 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 @@ -28,23 +28,8 @@ #include "gc/g1/heapRegion.hpp" #include "memory/virtualspace.hpp" -void G1CMBitMap::print_on_error(outputStream* st, const char* prefix) const { - _bm.print_on_error(st, prefix); -} - -size_t G1CMBitMap::compute_size(size_t heap_size) { - return ReservedSpace::allocation_align_size_up(heap_size / mark_distance()); -} - -size_t G1CMBitMap::mark_distance() { - return MinObjAlignmentInBytes * BitsPerByte; -} - void G1CMBitMap::initialize(MemRegion heap, G1RegionToSpaceMapper* storage) { - _covered = heap; - - _bm = BitMapView((BitMap::bm_word_t*) storage->reserved().start(), _covered.word_size() >> _shifter); - + MarkBitMap::initialize(heap, storage->reserved()); storage->set_mapping_changed_listener(&_listener); } @@ -57,19 +42,17 @@ _bm->clear_range(mr); } -void G1CMBitMap::clear_range(MemRegion mr) { - MemRegion intersection = mr.intersection(_covered); - assert(!intersection.is_empty(), - "Given range from " PTR_FORMAT " to " PTR_FORMAT " is completely outside the heap", - p2i(mr.start()), p2i(mr.end())); - // convert address range into offset range - _bm.at_put_range(addr_to_offset(intersection.start()), - addr_to_offset(intersection.end()), false); -} - void G1CMBitMap::clear_region(HeapRegion* region) { if (!region->is_empty()) { MemRegion mr(region->bottom(), region->top()); clear_range(mr); } } + +#ifdef ASSERT +void G1CMBitMap::check_mark(HeapWord* addr) { + assert(G1CollectedHeap::heap()->is_in_exact(addr), + "Trying to access bitmap " PTR_FORMAT " for address " PTR_FORMAT " not in the heap.", + p2i(this), p2i(addr)); +} +#endif diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.hpp --- a/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.hpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.hpp Thu Aug 30 11:08:01 2018 -0400 @@ -26,6 +26,7 @@ #define SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_HPP #include "gc/g1/g1RegionToSpaceMapper.hpp" +#include "gc/shared/markBitMap.hpp" #include "memory/memRegion.hpp" #include "oops/oopsHierarchy.hpp" #include "utilities/bitMap.hpp" @@ -59,68 +60,24 @@ // A generic mark bitmap for concurrent marking. This is essentially a wrapper // around the BitMap class that is based on HeapWords, with one bit per (1 << _shifter) HeapWords. -class G1CMBitMap { - MemRegion _covered; // The heap area covered by this bitmap. - - const int _shifter; // Shift amount from heap index to bit index in the bitmap. - - BitMapView _bm; // The actual bitmap. +class G1CMBitMap : public MarkBitMap { G1CMBitMapMappingChangedListener _listener; - inline void check_mark(HeapWord* addr) NOT_DEBUG_RETURN; +protected: - // Convert from bit offset to address. - HeapWord* offset_to_addr(size_t offset) const { - return _covered.start() + (offset << _shifter); - } - // Convert from address to bit offset. - size_t addr_to_offset(const HeapWord* addr) const { - return pointer_delta(addr, _covered.start()) >> _shifter; - } + virtual void check_mark(HeapWord* addr) NOT_DEBUG_RETURN; + public: - static size_t compute_size(size_t heap_size); - // Returns the amount of bytes on the heap between two marks in the bitmap. - static size_t mark_distance(); - // Returns how many bytes (or bits) of the heap a single byte (or bit) of the - // mark bitmap corresponds to. This is the same as the mark distance above. - static size_t heap_map_factor() { - return mark_distance(); - } - G1CMBitMap() : _covered(), _shifter(LogMinObjAlignment), _bm(), _listener() { _listener.set_bitmap(this); } + G1CMBitMap() : MarkBitMap(), _listener() { _listener.set_bitmap(this); } // Initializes the underlying BitMap to cover the given area. void initialize(MemRegion heap, G1RegionToSpaceMapper* storage); - // Read marks - bool is_marked(oop obj) const; - bool is_marked(HeapWord* addr) const { - assert(_covered.contains(addr), - "Address " PTR_FORMAT " is outside underlying space from " PTR_FORMAT " to " PTR_FORMAT, - p2i(addr), p2i(_covered.start()), p2i(_covered.end())); - return _bm.at(addr_to_offset(addr)); - } - // Apply the closure to the addresses that correspond to marked bits in the bitmap. inline bool iterate(G1CMBitMapClosure* cl, MemRegion mr); - // Return the address corresponding to the next marked bit at or after - // "addr", and before "limit", if "limit" is non-NULL. If there is no - // such bit, returns "limit" if that is non-NULL, or else "endWord()". - inline HeapWord* get_next_marked_addr(const HeapWord* addr, - const HeapWord* limit) const; - - void print_on_error(outputStream* st, const char* prefix) const; - - // Write marks. - inline void mark(HeapWord* addr); - inline void clear(HeapWord* addr); - inline void clear(oop obj); - inline bool par_mark(HeapWord* addr); - inline bool par_mark(oop obj); - - void clear_range(MemRegion mr); void clear_region(HeapRegion* hr); }; diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.inline.hpp --- a/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.inline.hpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.inline.hpp Thu Aug 30 11:08:01 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, 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 @@ -26,6 +26,7 @@ #define SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_INLINE_HPP #include "gc/g1/g1ConcurrentMarkBitMap.hpp" +#include "gc/shared/markBitMap.inline.hpp" #include "memory/memRegion.hpp" #include "utilities/align.hpp" #include "utilities/bitMap.inline.hpp" @@ -50,49 +51,4 @@ return true; } -inline HeapWord* G1CMBitMap::get_next_marked_addr(const HeapWord* addr, - const HeapWord* limit) const { - assert(limit != NULL, "limit must not be NULL"); - // Round addr up to a possible object boundary to be safe. - size_t const addr_offset = addr_to_offset(align_up(addr, HeapWordSize << _shifter)); - size_t const limit_offset = addr_to_offset(limit); - size_t const nextOffset = _bm.get_next_one_offset(addr_offset, limit_offset); - return offset_to_addr(nextOffset); -} - -#ifdef ASSERT -inline void G1CMBitMap::check_mark(HeapWord* addr) { - assert(G1CollectedHeap::heap()->is_in_exact(addr), - "Trying to access bitmap " PTR_FORMAT " for address " PTR_FORMAT " not in the heap.", - p2i(this), p2i(addr)); -} -#endif - -inline void G1CMBitMap::mark(HeapWord* addr) { - check_mark(addr); - _bm.set_bit(addr_to_offset(addr)); -} - -inline void G1CMBitMap::clear(HeapWord* addr) { - check_mark(addr); - _bm.clear_bit(addr_to_offset(addr)); -} - -inline bool G1CMBitMap::par_mark(HeapWord* addr) { - check_mark(addr); - return _bm.par_set_bit(addr_to_offset(addr)); -} - -inline bool G1CMBitMap::par_mark(oop obj) { - return par_mark((HeapWord*) obj); -} - -inline bool G1CMBitMap::is_marked(oop obj) const{ - return is_marked((HeapWord*) obj); -} - -inline void G1CMBitMap::clear(oop obj) { - clear((HeapWord*) obj); -} - #endif // SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_INLINE_HPP diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/gc/shared/markBitMap.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/gc/shared/markBitMap.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018, 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. + * + */ + +#include "precompiled.hpp" +#include "gc/shared/markBitMap.inline.hpp" +#include "memory/virtualspace.hpp" + +void MarkBitMap::print_on_error(outputStream* st, const char* prefix) const { + _bm.print_on_error(st, prefix); +} + +size_t MarkBitMap::compute_size(size_t heap_size) { + return ReservedSpace::allocation_align_size_up(heap_size / mark_distance()); +} + +size_t MarkBitMap::mark_distance() { + return MinObjAlignmentInBytes * BitsPerByte; +} + +void MarkBitMap::initialize(MemRegion heap, MemRegion storage) { + _covered = heap; + + _bm = BitMapView((BitMap::bm_word_t*) storage.start(), _covered.word_size() >> _shifter); +} + +void MarkBitMap::clear_range(MemRegion mr) { + MemRegion intersection = mr.intersection(_covered); + assert(!intersection.is_empty(), + "Given range from " PTR_FORMAT " to " PTR_FORMAT " is completely outside the heap", + p2i(mr.start()), p2i(mr.end())); + // convert address range into offset range + _bm.at_put_range(addr_to_offset(intersection.start()), + addr_to_offset(intersection.end()), false); +} + +#ifdef ASSERT +void MarkBitMap::check_mark(HeapWord* addr) { + assert(Universe::heap()->is_in_reserved(addr), + "Trying to access bitmap " PTR_FORMAT " for address " PTR_FORMAT " not in the heap.", + p2i(this), p2i(addr)); +} +#endif diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/gc/shared/markBitMap.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/gc/shared/markBitMap.hpp Thu Aug 30 11:08:01 2018 -0400 @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2018, 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. + * + */ + +#ifndef SHARE_VM_GC_SHARED_MARKBITMAP_HPP +#define SHARE_VM_GC_SHARED_MARKBITMAP_HPP + +#include "memory/memRegion.hpp" +#include "oops/oopsHierarchy.hpp" +#include "utilities/bitMap.hpp" + +// A generic mark bitmap for concurrent marking. This is essentially a wrapper +// around the BitMap class that is based on HeapWords, with one bit per (1 << _shifter) HeapWords. +class MarkBitMap { +protected: + MemRegion _covered; // The heap area covered by this bitmap. + + const int _shifter; // Shift amount from heap index to bit index in the bitmap. + + BitMapView _bm; // The actual bitmap. + + virtual void check_mark(HeapWord* addr) NOT_DEBUG_RETURN; + + // Convert from bit offset to address. + HeapWord* offset_to_addr(size_t offset) const { + return _covered.start() + (offset << _shifter); + } + // Convert from address to bit offset. + size_t addr_to_offset(const HeapWord* addr) const { + return pointer_delta(addr, _covered.start()) >> _shifter; + } +public: + static size_t compute_size(size_t heap_size); + // Returns the amount of bytes on the heap between two marks in the bitmap. + static size_t mark_distance(); + // Returns how many bytes (or bits) of the heap a single byte (or bit) of the + // mark bitmap corresponds to. This is the same as the mark distance above. + static size_t heap_map_factor() { + return mark_distance(); + } + + MarkBitMap() : _covered(), _shifter(LogMinObjAlignment), _bm() {} + + // Initializes the underlying BitMap to cover the given area. + void initialize(MemRegion heap, MemRegion storage); + + // Read marks + bool is_marked(oop obj) const; + bool is_marked(HeapWord* addr) const { + assert(_covered.contains(addr), + "Address " PTR_FORMAT " is outside underlying space from " PTR_FORMAT " to " PTR_FORMAT, + p2i(addr), p2i(_covered.start()), p2i(_covered.end())); + return _bm.at(addr_to_offset(addr)); + } + + // Return the address corresponding to the next marked bit at or after + // "addr", and before "limit", if "limit" is non-NULL. If there is no + // such bit, returns "limit" if that is non-NULL, or else "endWord()". + inline HeapWord* get_next_marked_addr(const HeapWord* addr, + const HeapWord* limit) const; + + void print_on_error(outputStream* st, const char* prefix) const; + + // Write marks. + inline void mark(HeapWord* addr); + inline void clear(HeapWord* addr); + inline void clear(oop obj); + inline bool par_mark(HeapWord* addr); + inline bool par_mark(oop obj); + + void clear_range(MemRegion mr); +}; + +#endif // SHARE_VM_GC_SHARED_MARKBITMAP_HPP diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/gc/shared/markBitMap.inline.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/gc/shared/markBitMap.inline.hpp Thu Aug 30 11:08:01 2018 -0400 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2018, 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. + * + */ + +#ifndef SHARE_VM_GC_SHARED_MARKBITMAP_INLINE_HPP +#define SHARE_VM_GC_SHARED_MARKBITMAP_INLINE_HPP + +#include "gc/shared/collectedHeap.hpp" +#include "gc/shared/markBitMap.hpp" +#include "memory/memRegion.hpp" +#include "memory/universe.hpp" +#include "utilities/align.hpp" +#include "utilities/bitMap.inline.hpp" + +inline HeapWord* MarkBitMap::get_next_marked_addr(const HeapWord* addr, + const HeapWord* limit) const { + assert(limit != NULL, "limit must not be NULL"); + // Round addr up to a possible object boundary to be safe. + size_t const addr_offset = addr_to_offset(align_up(addr, HeapWordSize << _shifter)); + size_t const limit_offset = addr_to_offset(limit); + size_t const nextOffset = _bm.get_next_one_offset(addr_offset, limit_offset); + return offset_to_addr(nextOffset); +} + +inline void MarkBitMap::mark(HeapWord* addr) { + check_mark(addr); + _bm.set_bit(addr_to_offset(addr)); +} + +inline void MarkBitMap::clear(HeapWord* addr) { + check_mark(addr); + _bm.clear_bit(addr_to_offset(addr)); +} + +inline bool MarkBitMap::par_mark(HeapWord* addr) { + check_mark(addr); + return _bm.par_set_bit(addr_to_offset(addr)); +} + +inline bool MarkBitMap::par_mark(oop obj) { + return par_mark((HeapWord*) obj); +} + +inline bool MarkBitMap::is_marked(oop obj) const{ + return is_marked((HeapWord*) obj); +} + +inline void MarkBitMap::clear(oop obj) { + clear((HeapWord*) obj); +} + +#endif // SHARE_VM_GC_SHARED_MARKBITMAP_INLINE_HPP diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/gc/z/zBarrierSet.inline.hpp --- a/src/hotspot/share/gc/z/zBarrierSet.inline.hpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/gc/z/zBarrierSet.inline.hpp Thu Aug 30 11:08:01 2018 -0400 @@ -210,16 +210,10 @@ template template inline oop ZBarrierSet::AccessBarrier::oop_load_not_in_heap(T* addr) { - const oop o = Raw::oop_load_not_in_heap(addr); + verify_decorators_absent(); - if (HasDecorator::value) { - return load_barrier_on_oop_field_preloaded(addr, o); - } - - verify_decorators_present(); - verify_decorators_absent(); - - return o; + const oop o = Raw::oop_load_not_in_heap(addr); + return load_barrier_on_oop_field_preloaded(addr, o); } template diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/gc/z/zRootsIterator.cpp --- a/src/hotspot/share/gc/z/zRootsIterator.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/gc/z/zRootsIterator.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -52,28 +52,21 @@ static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots"); static const ZStatSubPhase ZSubPhasePauseRootsTeardown("Pause Roots Teardown"); static const ZStatSubPhase ZSubPhasePauseRootsUniverse("Pause Roots Universe"); -static const ZStatSubPhase ZSubPhasePauseRootsVMWeakHandles("Pause Roots VMWeakHandles"); static const ZStatSubPhase ZSubPhasePauseRootsJNIHandles("Pause Roots JNIHandles"); -static const ZStatSubPhase ZSubPhasePauseRootsJNIWeakHandles("Pause Roots JNIWeakHandles"); static const ZStatSubPhase ZSubPhasePauseRootsObjectSynchronizer("Pause Roots ObjectSynchronizer"); static const ZStatSubPhase ZSubPhasePauseRootsManagement("Pause Roots Management"); static const ZStatSubPhase ZSubPhasePauseRootsJVMTIExport("Pause Roots JVMTIExport"); static const ZStatSubPhase ZSubPhasePauseRootsJVMTIWeakExport("Pause Roots JVMTIWeakExport"); -static const ZStatSubPhase ZSubPhasePauseRootsJFRWeak("Pause Roots JRFWeak"); static const ZStatSubPhase ZSubPhasePauseRootsSystemDictionary("Pause Roots SystemDictionary"); static const ZStatSubPhase ZSubPhasePauseRootsClassLoaderDataGraph("Pause Roots ClassLoaderDataGraph"); static const ZStatSubPhase ZSubPhasePauseRootsThreads("Pause Roots Threads"); static const ZStatSubPhase ZSubPhasePauseRootsCodeCache("Pause Roots CodeCache"); -static const ZStatSubPhase ZSubPhasePauseRootsStringTable("Pause Roots StringTable"); static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup"); static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots"); static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown"); -static const ZStatSubPhase ZSubPhasePauseWeakRootsVMWeakHandles("Pause Weak Roots VMWeakHandles"); -static const ZStatSubPhase ZSubPhasePauseWeakRootsJNIWeakHandles("Pause Weak Roots JNIWeakHandles"); static const ZStatSubPhase ZSubPhasePauseWeakRootsJVMTIWeakExport("Pause Weak Roots JVMTIWeakExport"); static const ZStatSubPhase ZSubPhasePauseWeakRootsJFRWeak("Pause Weak Roots JFRWeak"); -static const ZStatSubPhase ZSubPhasePauseWeakRootsStringTable("Pause Weak Roots StringTable"); static const ZStatSubPhase ZSubPhaseConcurrentWeakRoots("Concurrent Weak Roots"); static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsVMWeakHandles("Concurrent Weak Roots VMWeakHandles"); @@ -135,24 +128,17 @@ } ZRootsIterator::ZRootsIterator() : - _vm_weak_handles_iter(SystemDictionary::vm_weak_oop_storage()), _jni_handles_iter(JNIHandles::global_handles()), - _jni_weak_handles_iter(JNIHandles::weak_global_handles()), - _string_table_iter(StringTable::weak_storage()), _universe(this), _object_synchronizer(this), _management(this), _jvmti_export(this), _jvmti_weak_export(this), - _jfr_weak(this), _system_dictionary(this), - _vm_weak_handles(this), _jni_handles(this), - _jni_weak_handles(this), _class_loader_data_graph(this), _threads(this), - _code_cache(this), - _string_table(this) { + _code_cache(this) { assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); ZStatTimer timer(ZSubPhasePauseRootsSetup); Threads::change_thread_claim_parity(); @@ -177,21 +163,11 @@ Universe::oops_do(cl); } -void ZRootsIterator::do_vm_weak_handles(OopClosure* cl) { - ZStatTimer timer(ZSubPhasePauseRootsVMWeakHandles); - _vm_weak_handles_iter.oops_do(cl); -} - void ZRootsIterator::do_jni_handles(OopClosure* cl) { ZStatTimer timer(ZSubPhasePauseRootsJNIHandles); _jni_handles_iter.oops_do(cl); } -void ZRootsIterator::do_jni_weak_handles(OopClosure* cl) { - ZStatTimer timer(ZSubPhasePauseRootsJNIWeakHandles); - _jni_weak_handles_iter.oops_do(cl); -} - void ZRootsIterator::do_object_synchronizer(OopClosure* cl) { ZStatTimer timer(ZSubPhasePauseRootsObjectSynchronizer); ObjectSynchronizer::oops_do(cl); @@ -213,14 +189,6 @@ JvmtiExport::weak_oops_do(&always_alive, cl); } -void ZRootsIterator::do_jfr_weak(OopClosure* cl) { -#if INCLUDE_JFR - ZStatTimer timer(ZSubPhasePauseRootsJFRWeak); - AlwaysTrueClosure always_alive; - Jfr::weak_oops_do(&always_alive, cl); -#endif -} - void ZRootsIterator::do_system_dictionary(OopClosure* cl) { ZStatTimer timer(ZSubPhasePauseRootsSystemDictionary); SystemDictionary::oops_do(cl); @@ -263,11 +231,6 @@ ZNMethodTable::oops_do(cl); } -void ZRootsIterator::do_string_table(OopClosure* cl) { - ZStatTimer timer(ZSubPhasePauseRootsStringTable); - _string_table_iter.oops_do(cl); -} - void ZRootsIterator::oops_do(OopClosure* cl, bool visit_jvmti_weak_export) { ZStatTimer timer(ZSubPhasePauseRoots); _universe.oops_do(cl); @@ -279,28 +242,14 @@ _class_loader_data_graph.oops_do(cl); _threads.oops_do(cl); _code_cache.oops_do(cl); - if (!ZWeakRoots) { + if (visit_jvmti_weak_export) { _jvmti_weak_export.oops_do(cl); - _jfr_weak.oops_do(cl); - _vm_weak_handles.oops_do(cl); - _jni_weak_handles.oops_do(cl); - _string_table.oops_do(cl); - } else { - if (visit_jvmti_weak_export) { - _jvmti_weak_export.oops_do(cl); - } } } ZWeakRootsIterator::ZWeakRootsIterator() : - _vm_weak_handles_iter(SystemDictionary::vm_weak_oop_storage()), - _jni_weak_handles_iter(JNIHandles::weak_global_handles()), - _string_table_iter(StringTable::weak_storage()), _jvmti_weak_export(this), - _jfr_weak(this), - _vm_weak_handles(this), - _jni_weak_handles(this), - _string_table(this) { + _jfr_weak(this) { assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); ZStatTimer timer(ZSubPhasePauseWeakRootsSetup); StringTable::reset_dead_counter(); @@ -311,16 +260,6 @@ StringTable::finish_dead_counter(); } -void ZWeakRootsIterator::do_vm_weak_handles(BoolObjectClosure* is_alive, OopClosure* cl) { - ZStatTimer timer(ZSubPhasePauseWeakRootsVMWeakHandles); - _vm_weak_handles_iter.weak_oops_do(is_alive, cl); -} - -void ZWeakRootsIterator::do_jni_weak_handles(BoolObjectClosure* is_alive, OopClosure* cl) { - ZStatTimer timer(ZSubPhasePauseWeakRootsJNIWeakHandles); - _jni_weak_handles_iter.weak_oops_do(is_alive, cl); -} - void ZWeakRootsIterator::do_jvmti_weak_export(BoolObjectClosure* is_alive, OopClosure* cl) { ZStatTimer timer(ZSubPhasePauseWeakRootsJVMTIWeakExport); JvmtiExport::weak_oops_do(is_alive, cl); @@ -333,51 +272,10 @@ #endif } -class ZStringTableDeadCounterBoolObjectClosure : public BoolObjectClosure { -private: - BoolObjectClosure* const _cl; - size_t _ndead; - -public: - ZStringTableDeadCounterBoolObjectClosure(BoolObjectClosure* cl) : - _cl(cl), - _ndead(0) {} - - ~ZStringTableDeadCounterBoolObjectClosure() { - StringTable::inc_dead_counter(_ndead); - } - - virtual bool do_object_b(oop obj) { - if (_cl->do_object_b(obj)) { - return true; - } - - _ndead++; - return false; - } -}; - -void ZWeakRootsIterator::do_string_table(BoolObjectClosure* is_alive, OopClosure* cl) { - ZStatTimer timer(ZSubPhasePauseWeakRootsStringTable); - ZStringTableDeadCounterBoolObjectClosure counter_is_alive(is_alive); - _string_table_iter.weak_oops_do(&counter_is_alive, cl); -} - void ZWeakRootsIterator::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* cl) { ZStatTimer timer(ZSubPhasePauseWeakRoots); - if (ZWeakRoots) { - _jvmti_weak_export.weak_oops_do(is_alive, cl); - _jfr_weak.weak_oops_do(is_alive, cl); - if (!ZConcurrentVMWeakHandles) { - _vm_weak_handles.weak_oops_do(is_alive, cl); - } - if (!ZConcurrentJNIWeakGlobalHandles) { - _jni_weak_handles.weak_oops_do(is_alive, cl); - } - if (!ZConcurrentStringTable) { - _string_table.weak_oops_do(is_alive, cl); - } - } + _jvmti_weak_export.weak_oops_do(is_alive, cl); + _jfr_weak.weak_oops_do(is_alive, cl); } void ZWeakRootsIterator::oops_do(OopClosure* cl) { @@ -443,17 +341,9 @@ void ZConcurrentWeakRootsIterator::oops_do(OopClosure* cl) { ZStatTimer timer(ZSubPhaseConcurrentWeakRoots); - if (ZWeakRoots) { - if (ZConcurrentVMWeakHandles) { - _vm_weak_handles.oops_do(cl); - } - if (ZConcurrentJNIWeakGlobalHandles) { - _jni_weak_handles.oops_do(cl); - } - if (ZConcurrentStringTable) { - _string_table.oops_do(cl); - } - } + _vm_weak_handles.oops_do(cl); + _jni_weak_handles.oops_do(cl); + _string_table.oops_do(cl); } ZThreadRootsIterator::ZThreadRootsIterator() : diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/gc/z/zRootsIterator.hpp --- a/src/hotspot/share/gc/z/zRootsIterator.hpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/gc/z/zRootsIterator.hpp Thu Aug 30 11:08:01 2018 -0400 @@ -78,40 +78,29 @@ class ZRootsIterator { private: - ZOopStorageIterator _vm_weak_handles_iter; ZOopStorageIterator _jni_handles_iter; - ZOopStorageIterator _jni_weak_handles_iter; - ZOopStorageIterator _string_table_iter; void do_universe(OopClosure* cl); - void do_vm_weak_handles(OopClosure* cl); void do_jni_handles(OopClosure* cl); - void do_jni_weak_handles(OopClosure* cl); void do_object_synchronizer(OopClosure* cl); void do_management(OopClosure* cl); void do_jvmti_export(OopClosure* cl); void do_jvmti_weak_export(OopClosure* cl); - void do_jfr_weak(OopClosure* cl); void do_system_dictionary(OopClosure* cl); void do_class_loader_data_graph(OopClosure* cl); void do_threads(OopClosure* cl); void do_code_cache(OopClosure* cl); - void do_string_table(OopClosure* cl); ZSerialOopsDo _universe; ZSerialOopsDo _object_synchronizer; ZSerialOopsDo _management; ZSerialOopsDo _jvmti_export; ZSerialOopsDo _jvmti_weak_export; - ZSerialOopsDo _jfr_weak; ZSerialOopsDo _system_dictionary; - ZParallelOopsDo _vm_weak_handles; ZParallelOopsDo _jni_handles; - ZParallelOopsDo _jni_weak_handles; ZParallelOopsDo _class_loader_data_graph; ZParallelOopsDo _threads; ZParallelOopsDo _code_cache; - ZParallelOopsDo _string_table; public: ZRootsIterator(); @@ -122,21 +111,11 @@ class ZWeakRootsIterator { private: - ZOopStorageIterator _vm_weak_handles_iter; - ZOopStorageIterator _jni_weak_handles_iter; - ZOopStorageIterator _string_table_iter; - - void do_vm_weak_handles(BoolObjectClosure* is_alive, OopClosure* cl); - void do_jni_weak_handles(BoolObjectClosure* is_alive, OopClosure* cl); void do_jvmti_weak_export(BoolObjectClosure* is_alive, OopClosure* cl); void do_jfr_weak(BoolObjectClosure* is_alive, OopClosure* cl); - void do_string_table(BoolObjectClosure* is_alive, OopClosure* cl); ZSerialWeakOopsDo _jvmti_weak_export; ZSerialWeakOopsDo _jfr_weak; - ZParallelWeakOopsDo _vm_weak_handles; - ZParallelWeakOopsDo _jni_weak_handles; - ZParallelWeakOopsDo _string_table; public: ZWeakRootsIterator(); diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/gc/z/z_globals.hpp --- a/src/hotspot/share/gc/z/z_globals.hpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/gc/z/z_globals.hpp Thu Aug 30 11:08:01 2018 -0400 @@ -79,18 +79,6 @@ diagnostic(bool, ZVerifyForwarding, false, \ "Verify forwarding tables") \ \ - diagnostic(bool, ZWeakRoots, true, \ - "Treat JNI WeakGlobalRefs and StringTable as weak roots") \ - \ - diagnostic(bool, ZConcurrentStringTable, true, \ - "Clean StringTable concurrently") \ - \ - diagnostic(bool, ZConcurrentVMWeakHandles, true, \ - "Clean VM WeakHandles concurrently") \ - \ - diagnostic(bool, ZConcurrentJNIWeakGlobalHandles, true, \ - "Clean JNI WeakGlobalRefs concurrently") \ - \ diagnostic(bool, ZOptimizeLoadBarriers, true, \ "Apply load barrier optimizations") \ \ diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/interpreter/rewriter.cpp --- a/src/hotspot/share/interpreter/rewriter.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/interpreter/rewriter.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -400,7 +400,9 @@ } } - assert(bc_length != 0, "impossible bytecode length"); + // Continuing with an invalid bytecode will fail in the loop below. + // So guarantee here. + guarantee(bc_length > 0, "Verifier should have caught this invalid bytecode"); switch (c) { case Bytecodes::_lookupswitch : { diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/prims/resolvedMethodTable.cpp --- a/src/hotspot/share/prims/resolvedMethodTable.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/prims/resolvedMethodTable.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -143,8 +143,7 @@ } // Removing entries -int ResolvedMethodTable::_oops_removed = 0; -int ResolvedMethodTable::_oops_counted = 0; +int ResolvedMethodTable::_total_oops_removed = 0; // There are no dead entries at start bool ResolvedMethodTable::_dead_entries = false; @@ -159,8 +158,8 @@ // This is done by the ServiceThread after being notified on class unloading void ResolvedMethodTable::unlink() { MutexLocker ml(ResolvedMethodTable_lock); - _oops_removed = 0; - _oops_counted = 0; + int _oops_removed = 0; + int _oops_counted = 0; for (int i = 0; i < _the_table->table_size(); ++i) { ResolvedMethodEntry** p = _the_table->bucket_addr(i); ResolvedMethodEntry* entry = _the_table->bucket(i); @@ -185,6 +184,7 @@ } log_debug(membername, table) ("ResolvedMethod entries counted %d removed %d", _oops_counted, _oops_removed); + _total_oops_removed += _oops_removed; _dead_entries = false; } diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/prims/resolvedMethodTable.hpp --- a/src/hotspot/share/prims/resolvedMethodTable.hpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/prims/resolvedMethodTable.hpp Thu Aug 30 11:08:01 2018 -0400 @@ -56,8 +56,7 @@ _table_size = 1007 }; - static int _oops_removed; - static int _oops_counted; + static int _total_oops_removed; static bool _dead_entries; @@ -95,6 +94,8 @@ static bool has_work() { return _dead_entries; } static void trigger_cleanup(); + static int removed_entries_count() { return _total_oops_removed; }; + #if INCLUDE_JVMTI // It is called at safepoint only for RedefineClasses static void adjust_method_entries(bool * trace_name_printed); diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/prims/whitebox.cpp --- a/src/hotspot/share/prims/whitebox.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/prims/whitebox.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -48,6 +48,7 @@ #include "oops/objArrayOop.inline.hpp" #include "oops/oop.inline.hpp" #include "oops/typeArrayOop.inline.hpp" +#include "prims/resolvedMethodTable.hpp" #include "prims/wbtestmethods/parserTests.hpp" #include "prims/whitebox.inline.hpp" #include "runtime/arguments.hpp" @@ -1972,6 +1973,10 @@ #endif WB_END +WB_ENTRY(jint, WB_ResolvedMethodRemovedCount(JNIEnv* env, jobject o)) + return (jint) ResolvedMethodTable::removed_entries_count(); +WB_END + #define CC (char*) @@ -2193,6 +2198,7 @@ {CC"isContainerized", CC"()Z", (void*)&WB_IsContainerized }, {CC"printOsInfo", CC"()V", (void*)&WB_PrintOsInfo }, {CC"disableElfSectionCache", CC"()V", (void*)&WB_DisableElfSectionCache }, + {CC"resolvedMethodRemovedCount", CC"()I", (void*)&WB_ResolvedMethodRemovedCount }, }; diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/runtime/arguments.cpp --- a/src/hotspot/share/runtime/arguments.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/runtime/arguments.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -572,6 +572,8 @@ { "PrintSafepointStatistics", JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) }, { "PrintSafepointStatisticsTimeout",JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) }, { "PrintSafepointStatisticsCount", JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) }, + { "TransmitErrorReport", JDK_Version::undefined(), JDK_Version::jdk(12), JDK_Version::jdk(13) }, + { "ErrorReportServer", JDK_Version::undefined(), JDK_Version::jdk(12), JDK_Version::jdk(13) }, #ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS { "dep > obs", JDK_Version::jdk(9), JDK_Version::jdk(8), JDK_Version::undefined() }, diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/runtime/globals.hpp --- a/src/hotspot/share/runtime/globals.hpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/runtime/globals.hpp Thu Aug 30 11:08:01 2018 -0400 @@ -2417,12 +2417,6 @@ manageable(bool, PrintConcurrentLocks, false, \ "Print java.util.concurrent locks in thread dump") \ \ - product(bool, TransmitErrorReport, false, \ - "Enable error report transmission on erroneous termination") \ - \ - product(ccstr, ErrorReportServer, NULL, \ - "Override built-in error report server address") \ - \ /* Shared spaces */ \ \ product(bool, UseSharedSpaces, true, \ diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/runtime/sharedRuntime.cpp --- a/src/hotspot/share/runtime/sharedRuntime.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/runtime/sharedRuntime.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -2135,16 +2135,14 @@ static int _max_size; // max. arg size seen static void add_method_to_histogram(nmethod* nm) { - // These checks are taken from CodeHeapState::print_names() - Method* m = (nm == NULL) ? NULL : nm->method(); // nm->method() may be uninitialized, i.e. != NULL, but invalid - if ((nm != NULL) && (m != NULL) && !nm->is_zombie() && !nm->is_not_installed() && - os::is_readable_pointer(m) && os::is_readable_pointer(m->constants())) { - ArgumentCount args(m->signature()); - int arity = args.size() + (m->is_static() ? 0 : 1); - int argsize = m->size_of_parameters(); + if (CompiledMethod::nmethod_access_is_safe(nm)) { + Method* method = nm->method(); + ArgumentCount args(method->signature()); + int arity = args.size() + (method->is_static() ? 0 : 1); + int argsize = method->size_of_parameters(); arity = MIN2(arity, MAX_ARITY-1); argsize = MIN2(argsize, MAX_ARITY-1); - int count = nm->method()->compiled_invocation_count(); + int count = method->compiled_invocation_count(); _arity_histogram[arity] += count; _size_histogram[argsize] += count; _max_arity = MAX2(_max_arity, arity); diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/runtime/thread.cpp --- a/src/hotspot/share/runtime/thread.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/runtime/thread.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -3340,11 +3340,6 @@ } CompilerThread::~CompilerThread() { - // Free buffer blob, if allocated - if (get_buffer_blob() != NULL) { - MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - CodeCache::free(get_buffer_blob()); - } // Delete objects which were allocated on heap. delete _counters; } diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/utilities/errorReporter.cpp --- a/src/hotspot/share/utilities/errorReporter.cpp Wed Aug 29 14:48:09 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2011, 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. - * - */ - -#include "precompiled.hpp" -#include "utilities/errorReporter.hpp" - -ErrorReporter::ErrorReporter() {} - -void ErrorReporter::call(FILE* fd, char* buffer, int length) { -} - diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/utilities/errorReporter.hpp --- a/src/hotspot/share/utilities/errorReporter.hpp Wed Aug 29 14:48:09 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011, 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. - * - */ - -#ifndef SHARE_VM_UTILITIES_ERRORREPORTER_HPP -#define SHARE_VM_UTILITIES_ERRORREPORTER_HPP - -#include "utilities/globalDefinitions.hpp" -#include "memory/allocation.hpp" - -class ErrorReporter : public StackObj { - -public: - ErrorReporter(); - ~ErrorReporter(){}; - - void call(FILE* fd, char *buffer, int length); -}; - -#endif // ndef SHARE_VM_UTILITIES_ERRORREPORTER_HPP diff -r 2aefd58f8ec5 -r 6ba2f471478b src/hotspot/share/utilities/vmError.cpp --- a/src/hotspot/share/utilities/vmError.cpp Wed Aug 29 14:48:09 2018 -0400 +++ b/src/hotspot/share/utilities/vmError.cpp Thu Aug 30 11:08:01 2018 -0400 @@ -47,7 +47,6 @@ #include "utilities/debug.hpp" #include "utilities/decoder.hpp" #include "utilities/defaultStream.hpp" -#include "utilities/errorReporter.hpp" #include "utilities/events.hpp" #include "utilities/vmError.hpp" #include "utilities/macros.hpp" @@ -1287,7 +1286,6 @@ // then save detailed information in log file (verbose = true). static bool out_done = false; // done printing to standard out static bool log_done = false; // done saving error log - static bool transmit_report_done = false; // done error reporting if (SuppressFatalErrorMessage) { os::abort(CreateCoredumpOnCrash); @@ -1433,9 +1431,6 @@ } else { out.print_raw_cr("# Can not save log file, dump to screen.."); log.set_fd(defaultStream::output_fd()); - /* Error reporting currently needs dumpfile. - * Maybe implement direct streaming in the future.*/ - transmit_report_done = true; } } @@ -1444,20 +1439,6 @@ _current_step = 0; _current_step_info = ""; - // Run error reporting to determine whether or not to report the crash. - if (!transmit_report_done && should_report_bug(_id)) { - transmit_report_done = true; - const int fd2 = ::dup(log.fd()); - if (fd2 != -1) { - FILE* const hs_err = ::fdopen(fd2, "r"); - if (NULL != hs_err) { - ErrorReporter er; - er.call(hs_err, buffer, O_BUFLEN); - ::fclose(hs_err); - } - } - } - if (log.fd() != defaultStream::output_fd()) { close(log.fd()); } diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/share/classes/sun/security/ssl/CertSignAlgsExtension.java --- a/src/java.base/share/classes/sun/security/ssl/CertSignAlgsExtension.java Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/CertSignAlgsExtension.java Thu Aug 30 11:08:01 2018 -0400 @@ -191,12 +191,12 @@ } // update the context - List shemes = + List schemes = SignatureScheme.getSupportedAlgorithms( shc.algorithmConstraints, shc.negotiatedProtocol, spec.signatureSchemes); - shc.peerRequestedCertSignSchemes = shemes; - shc.handshakeSession.setPeerSupportedSignatureAlgorithms(shemes); + shc.peerRequestedCertSignSchemes = schemes; + shc.handshakeSession.setPeerSupportedSignatureAlgorithms(schemes); if (!shc.isResumption && shc.negotiatedProtocol.useTLS13PlusSpec()) { if (shc.sslConfig.clientAuthType != @@ -337,12 +337,12 @@ } // update the context - List shemes = + List schemes = SignatureScheme.getSupportedAlgorithms( chc.algorithmConstraints, chc.negotiatedProtocol, spec.signatureSchemes); - chc.peerRequestedCertSignSchemes = shemes; - chc.handshakeSession.setPeerSupportedSignatureAlgorithms(shemes); + chc.peerRequestedCertSignSchemes = schemes; + chc.handshakeSession.setPeerSupportedSignatureAlgorithms(schemes); } } } diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/share/classes/sun/security/ssl/CertificateMessage.java --- a/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java Thu Aug 30 11:08:01 2018 -0400 @@ -1031,8 +1031,8 @@ // Don't select a signature scheme unless we will be able to // produce a CertificateVerify message later if (SignatureScheme.getPreferableAlgorithm( - hc.peerRequestedSignatureSchemes, - ss, hc.negotiatedProtocol) == null) { + hc.peerRequestedSignatureSchemes, + ss, hc.negotiatedProtocol) == null) { if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { SSLLogger.warning( diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java --- a/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java Thu Aug 30 11:08:01 2018 -0400 @@ -50,7 +50,7 @@ this.outputRecord = outputRecord; } - // Complete a handshakin message writing. Called by HandshakeMessage. + // Complete a handshaking message write. Called by HandshakeMessage. void complete() throws IOException { if (size() < 4) { // 4: handshake message header size // internal_error alert will be triggered diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/share/classes/sun/security/ssl/SSLCipher.java --- a/src/java.base/share/classes/sun/security/ssl/SSLCipher.java Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/SSLCipher.java Thu Aug 30 11:08:01 2018 -0400 @@ -379,10 +379,10 @@ private final Map.Entry[] writeCipherGenerators; - // Map of Ciphers listed in jdk.tls.KeyLimit + // Map of Ciphers listed in jdk.tls.keyLimits private static final HashMap cipherLimits = new HashMap<>(); - // Keywords found on the jdk.tls.KeyLimit security property. + // Keywords found on the jdk.tls.keyLimits security property. final static String tag[] = {"KEYUPDATE"}; static { @@ -407,7 +407,7 @@ index = 0; } else { if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { - SSLLogger.fine("jdk.net.keyLimits: Unknown action: " + + SSLLogger.fine("jdk.tls.keyLimits: Unknown action: " + entry); } continue; @@ -423,17 +423,18 @@ size = Long.parseLong(values[2]); } if (size < 1 || size > max) { - throw new NumberFormatException("Length exceeded limits"); + throw new NumberFormatException( + "Length exceeded limits"); } } catch (NumberFormatException e) { if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { - SSLLogger.fine("jdk.net.keyLimits: " + e.getMessage() + + SSLLogger.fine("jdk.tls.keyLimits: " + e.getMessage() + ": " + entry); } continue; } if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { - SSLLogger.fine("jdk.net.keyLimits: entry = " + entry + + SSLLogger.fine("jdk.tls.keyLimits: entry = " + entry + ". " + values[0] + ":" + tag[index] + " = " + size); } cipherLimits.put(values[0] + ":" + tag[index], size); diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java --- a/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java Thu Aug 30 11:08:01 2018 -0400 @@ -127,9 +127,7 @@ } // See if the handshaker needs to report back some SSLException. - if (conContext.outputRecord.isEmpty()) { - checkTaskThrown(); - } // Otherwise, deliver cached records before throwing task exception. + checkTaskThrown(); // check parameters checkParams(srcs, srcsOffset, srcsLength, dsts, dstsOffset, dstsLength); @@ -896,18 +894,58 @@ return true; } + /* + * Depending on whether the error was just a warning and the + * handshaker wasn't closed, or fatal and the handshaker is now + * null, report back the Exception that happened in the delegated + * task(s). + */ private synchronized void checkTaskThrown() throws SSLException { + + Exception exc = null; + + // First check the handshake context. HandshakeContext hc = conContext.handshakeContext; - if (hc != null && hc.delegatedThrown != null) { - try { - throw getTaskThrown(hc.delegatedThrown); - } finally { - hc.delegatedThrown = null; + if ((hc != null) && (hc.delegatedThrown != null)) { + exc = hc.delegatedThrown; + hc.delegatedThrown = null; + } + + /* + * hc.delegatedThrown and conContext.delegatedThrown are most likely + * the same, but it's possible we could have had a non-fatal + * exception and thus the new HandshakeContext is still valid + * (alert warning). If so, then we may have a secondary exception + * waiting to be reported from the TransportContext, so we will + * need to clear that on a successive call. Otherwise, clear it now. + */ + if (conContext.delegatedThrown != null) { + if (exc != null) { + // hc object comparison + if (conContext.delegatedThrown == exc) { + // clear if/only if both are the same + conContext.delegatedThrown = null; + } // otherwise report the hc delegatedThrown + } else { + // Nothing waiting in HandshakeContext, but one is in the + // TransportContext. + exc = conContext.delegatedThrown; + conContext.delegatedThrown = null; } } - if (conContext.isBroken && conContext.closeReason != null) { - throw getTaskThrown(conContext.closeReason); + // Anything to report? + if (exc == null) { + return; + } + + // If it wasn't a RuntimeException/SSLException, need to wrap it. + if (exc instanceof SSLException) { + throw (SSLException)exc; + } else if (exc instanceof RuntimeException) { + throw (RuntimeException)exc; + } else { + throw getTaskThrown(exc); } } @@ -963,20 +1001,41 @@ } catch (PrivilegedActionException pae) { // Get the handshake context again in case the // handshaking has completed. + Exception reportedException = pae.getException(); + + // Report to both the TransportContext... + if (engine.conContext.delegatedThrown == null) { + engine.conContext.delegatedThrown = reportedException; + } + + // ...and the HandshakeContext in case condition + // wasn't fatal and the handshakeContext is still + // around. hc = engine.conContext.handshakeContext; if (hc != null) { - hc.delegatedThrown = pae.getException(); + hc.delegatedThrown = reportedException; } else if (engine.conContext.closeReason != null) { + // Update the reason in case there was a previous. engine.conContext.closeReason = - getTaskThrown(pae.getException()); + getTaskThrown(reportedException); } } catch (RuntimeException rte) { // Get the handshake context again in case the // handshaking has completed. + + // Report to both the TransportContext... + if (engine.conContext.delegatedThrown == null) { + engine.conContext.delegatedThrown = rte; + } + + // ...and the HandshakeContext in case condition + // wasn't fatal and the handshakeContext is still + // around. hc = engine.conContext.handshakeContext; if (hc != null) { hc.delegatedThrown = rte; } else if (engine.conContext.closeReason != null) { + // Update the reason in case there was a previous. engine.conContext.closeReason = rte; } } @@ -1000,13 +1059,6 @@ @Override public Void run() throws Exception { while (!context.delegatedActions.isEmpty()) { - // Report back the task SSLException - if (context.delegatedThrown != null) { - Exception delegatedThrown = context.delegatedThrown; - context.delegatedThrown = null; - throw getTaskThrown(delegatedThrown); - } - Map.Entry me = context.delegatedActions.poll(); if (me != null) { diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/share/classes/sun/security/ssl/SSLTransport.java --- a/src/java.base/share/classes/sun/security/ssl/SSLTransport.java Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/SSLTransport.java Thu Aug 30 11:08:01 2018 -0400 @@ -167,9 +167,10 @@ if (plainText == null) { plainText = Plaintext.PLAINTEXT_NULL; } else { - // File the destination buffers. - if (dsts != null && dstsLength > 0 && - plainText.contentType == ContentType.APPLICATION_DATA.id) { + // Fill the destination buffers. + if ((dsts != null) && (dstsLength > 0) && + (plainText.contentType == + ContentType.APPLICATION_DATA.id)) { ByteBuffer fragment = plainText.fragment; int remains = fragment.remaining(); diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/share/classes/sun/security/ssl/ServerHello.java --- a/src/java.base/share/classes/sun/security/ssl/ServerHello.java Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/ServerHello.java Thu Aug 30 11:08:01 2018 -0400 @@ -40,6 +40,7 @@ import javax.crypto.spec.IvParameterSpec; import javax.net.ssl.SSLException; import javax.net.ssl.SSLHandshakeException; +import javax.net.ssl.SSLProtocolException; import sun.security.ssl.CipherSuite.KeyExchange; import sun.security.ssl.ClientHello.ClientHelloMessage; import sun.security.ssl.SSLCipher.SSLReadCipher; @@ -139,8 +140,11 @@ this.serverRandom = new RandomCookie(m); this.sessionId = new SessionId(Record.getBytes8(m)); - sessionId.checkLength(serverVersion.id); - + try { + sessionId.checkLength(serverVersion.id); + } catch (SSLProtocolException ex) { + handshakeContext.conContext.fatal(Alert.ILLEGAL_PARAMETER, ex); + } int cipherSuiteId = Record.getInt16(m); this.cipherSuite = CipherSuite.valueOf(cipherSuiteId); diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/share/classes/sun/security/ssl/SignatureAlgorithmsExtension.java --- a/src/java.base/share/classes/sun/security/ssl/SignatureAlgorithmsExtension.java Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/SignatureAlgorithmsExtension.java Thu Aug 30 11:08:01 2018 -0400 @@ -362,16 +362,16 @@ // certificates and server key exchange), it MUST send the // signature_algorithms extension, listing the algorithms it // is willing to accept. - List shemes = Arrays.asList( + List schemes = Arrays.asList( SignatureScheme.RSA_PKCS1_SHA1, SignatureScheme.DSA_SHA1, SignatureScheme.ECDSA_SHA1 ); - shc.peerRequestedSignatureSchemes = shemes; + shc.peerRequestedSignatureSchemes = schemes; if (shc.peerRequestedCertSignSchemes == null || - shc.peerRequestedCertSignSchemes.isEmpty()) { - shc.peerRequestedCertSignSchemes = shemes; + shc.peerRequestedCertSignSchemes.isEmpty()) { + shc.peerRequestedCertSignSchemes = schemes; } // Use the default peer signature algorithms. diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/share/classes/sun/security/ssl/SignatureScheme.java --- a/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java Thu Aug 30 11:08:01 2018 -0400 @@ -403,8 +403,8 @@ for (SignatureScheme ss : schemes) { if (ss.isAvailable && - ss.handshakeSupportedProtocols.contains(version) && - certScheme.keyAlgorithm.equalsIgnoreCase(ss.keyAlgorithm)) { + ss.handshakeSupportedProtocols.contains(version) && + certScheme.keyAlgorithm.equalsIgnoreCase(ss.keyAlgorithm)) { return ss; } diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/share/classes/sun/security/ssl/TransportContext.java --- a/src/java.base/share/classes/sun/security/ssl/TransportContext.java Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/TransportContext.java Thu Aug 30 11:08:01 2018 -0400 @@ -63,6 +63,7 @@ boolean isInputCloseNotified = false; boolean peerUserCanceled = false; Exception closeReason = null; + Exception delegatedThrown = null; // negotiated security parameters SSLSessionImpl conSession; @@ -364,12 +365,12 @@ } } - // terminal handshake context + // terminate the handshake context if (handshakeContext != null) { handshakeContext = null; } - // terminal the transport + // terminate the transport try { transport.shutdown(); } catch (IOException ioe) { diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/share/classes/sun/security/ssl/X509Authentication.java --- a/src/java.base/share/classes/sun/security/ssl/X509Authentication.java Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/X509Authentication.java Thu Aug 30 11:08:01 2018 -0400 @@ -73,7 +73,7 @@ } static X509Authentication valueOf(SignatureScheme signatureScheme) { - for (X509Authentication au: X509Authentication.values()) { + for (X509Authentication au : X509Authentication.values()) { if (au.keyType.equals(signatureScheme.keyAlgorithm)) { return au; } @@ -291,9 +291,9 @@ ((ECPublicKey)serverPublicKey).getParams(); NamedGroup namedGroup = NamedGroup.valueOf(params); if ((namedGroup == null) || - (!SupportedGroups.isSupported(namedGroup)) || - ((shc.clientRequestedNamedGroups != null) && - !shc.clientRequestedNamedGroups.contains(namedGroup))) { + (!SupportedGroups.isSupported(namedGroup)) || + ((shc.clientRequestedNamedGroups != null) && + !shc.clientRequestedNamedGroups.contains(namedGroup))) { if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { SSLLogger.warning( diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/share/classes/sun/security/util/math/intpoly/IntegerPolynomial.java --- a/src/java.base/share/classes/sun/security/util/math/intpoly/IntegerPolynomial.java Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/share/classes/sun/security/util/math/intpoly/IntegerPolynomial.java Thu Aug 30 11:08:01 2018 -0400 @@ -70,13 +70,28 @@ protected final int bitsPerLimb; private final long[] posModLimbs; - // must work when a==r + /** + * Multiply an IntegerPolynomial representation (a) with a long (b) and + * store the result in an IntegerPolynomial representation (r). Requires + * that a.length == r.length == numLimbs. It is allowed for a and r to be + * the same array. + */ protected abstract void multByInt(long[] a, long b, long[] r); - // must work when a==r + /** + * Multiply two IntegerPolynomial representations (a and b) and store the + * result in an IntegerPolynomial representation (r). Requires that + * a.length == b.length == r.length == numLimbs. It is allowed for a and r + * to be the same array. + */ protected abstract void mult(long[] a, long[] b, long[] r); - // must work when a==r + /** + * Multiply an IntegerPolynomial representation (a) with itself and store + * the result in an IntegerPolynomialRepresentation (r). Requires that + * a.length == r.length == numLimbs. It is allowed for a and r + * to be the same array. + */ protected abstract void square(long[] a, long[] r); IntegerPolynomial(int bitsPerLimb, @@ -240,7 +255,9 @@ carry(limbs, 0, limbs.length - 1); } - // carry out of the specified position and return the carry value + /** + * Carry out of the specified position and return the carry value. + */ protected long carryOut(long[] limbs, int index) { long carry = carryValue(limbs[index]); limbs[index] -= (carry << bitsPerLimb); @@ -261,9 +278,20 @@ } } + /** + * Carry out of the last limb and reduce back in. This method will be + * called as part of the "finalReduce" operation that puts the + * representation into a fully-reduced form. It is representation- + * specific, because representations have different amounts of empty + * space in the high-order limb. Requires that limbs.length=numLimbs. + */ protected abstract void finalCarryReduceLast(long[] limbs); - // Convert reduced limbs into a number between 0 and MODULUS-1 + /** + * Convert reduced limbs into a number between 0 and MODULUS-1. + * Requires that limbs.length == numLimbs. This method only works if the + * modulus has at most three terms. + */ protected void finalReduce(long[] limbs) { // This method works by doing several full carry/reduce operations. @@ -313,8 +341,10 @@ } - // v must be final reduced. I.e. all limbs in [0, bitsPerLimb) - // and value in [0, modulus) + /** + * Decode the value in v and store it in dst. Requires that v is final + * reduced. I.e. all limbs in [0, 2^bitsPerLimb) and value in [0, modulus). + */ protected void decode(long[] v, byte[] dst, int offset, int length) { int nextLimbIndex = 0; @@ -344,12 +374,25 @@ } } + /** + * Add two IntegerPolynomial representations (a and b) and store the result + * in an IntegerPolynomialRepresentation (dst). Requires that + * a.length == b.length == dst.length. It is allowed for a and + * dst to be the same array. + */ protected void addLimbs(long[] a, long[] b, long[] dst) { for (int i = 0; i < dst.length; i++) { dst[i] = a[i] + b[i]; } } + /** + * Branch-free conditional swap of a and b. Requires that swap is 0 or 1, + * and that a.length == b.length. If swap==0, then the values of a and b + * will be unchanged. If swap==1, then the values of a and b will be + * swapped. The behavior is undefined if swap has any value other than + * 0 or 1. + */ protected static void conditionalSwap(int swap, long[] a, long[] b) { int maskValue = 0 - swap; for (int i = 0; i < a.length; i++) { @@ -359,6 +402,9 @@ } } + /** + * Stores the reduced, little-endian value of limbs in result. + */ protected void limbsToByteArray(long[] limbs, byte[] result) { long[] reducedLimbs = limbs.clone(); @@ -367,6 +413,11 @@ decode(reducedLimbs, result, 0, result.length); } + /** + * Add the reduced number corresponding to limbs and other, and store + * the low-order bytes of the sum in result. Requires that + * limbs.length==other.length. The result array may have any length. + */ protected void addLimbsModPowerTwo(long[] limbs, long[] other, byte[] result) { diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/windows/native/libnet/Inet4AddressImpl.c --- a/src/java.base/windows/native/libnet/Inet4AddressImpl.c Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/windows/native/libnet/Inet4AddressImpl.c Thu Aug 30 11:08:01 2018 -0400 @@ -326,7 +326,7 @@ ReplyBuffer = (VOID *)malloc(ReplySize); if (ReplyBuffer == NULL) { IcmpCloseHandle(hIcmpFile); - NET_ThrowNew(env, WSAGetLastError(), "Unable to allocate memory"); + NET_ThrowNew(env, -1, "Unable to allocate memory"); return JNI_FALSE; } diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/windows/native/libnet/Inet6AddressImpl.c --- a/src/java.base/windows/native/libnet/Inet6AddressImpl.c Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/windows/native/libnet/Inet6AddressImpl.c Thu Aug 30 11:08:01 2018 -0400 @@ -396,7 +396,7 @@ ReplyBuffer = (VOID *)malloc(ReplySize); if (ReplyBuffer == NULL) { IcmpCloseHandle(hIcmpFile); - NET_ThrowNew(env, WSAGetLastError(), "Unable to allocate memory"); + NET_ThrowNew(env, -1, "Unable to allocate memory"); return JNI_FALSE; } diff -r 2aefd58f8ec5 -r 6ba2f471478b src/java.base/windows/native/libnet/SocketInputStream.c --- a/src/java.base/windows/native/libnet/SocketInputStream.c Wed Aug 29 14:48:09 2018 -0400 +++ b/src/java.base/windows/native/libnet/SocketInputStream.c Thu Aug 30 11:08:01 2018 -0400 @@ -122,12 +122,13 @@ (*env)->SetByteArrayRegion(env, data, off, nread, (jbyte *)bufP); } else { if (nread < 0) { + int err = WSAGetLastError(); // Check if the socket has been closed since we last checked. // This could be a reason for recv failing. if ((*env)->GetIntField(env, fdObj, IO_fd_fdID) == -1) { JNU_ThrowByName(env, "java/net/SocketException", "Socket closed"); } else { - switch (WSAGetLastError()) { + switch (err) { case WSAEINTR: JNU_ThrowByName(env, "java/net/SocketException", "socket closed"); diff -r 2aefd58f8ec5 -r 6ba2f471478b src/jdk.crypto.ec/share/classes/sun/security/ec/XDHKeyAgreement.java --- a/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHKeyAgreement.java Wed Aug 29 14:48:09 2018 -0400 +++ b/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHKeyAgreement.java Thu Aug 30 11:08:01 2018 -0400 @@ -189,7 +189,7 @@ throw new IllegalStateException("Not initialized correctly"); } int secretLen = this.secret.length; - if (offset + secretLen > sharedSecret.length) { + if (secretLen > sharedSecret.length - offset) { throw new ShortBufferException("Need " + secretLen + " bytes, only " + (sharedSecret.length - offset) + " available"); diff -r 2aefd58f8ec5 -r 6ba2f471478b src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_es_VE.properties --- a/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_es_VE.properties Wed Aug 29 14:48:09 2018 -0400 +++ b/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_es_VE.properties Thu Aug 30 11:08:01 2018 -0400 @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2018, 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 @@ -37,4 +37,4 @@ VEB=Bs VEF=Bs.F. - +VES=Bs.S. diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/ProblemList.txt --- a/test/hotspot/jtreg/ProblemList.txt Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/ProblemList.txt Thu Aug 30 11:08:01 2018 -0400 @@ -84,7 +84,6 @@ runtime/CompressedOops/UseCompressedOops.java 8079353 generic-all runtime/RedefineTests/RedefineRunningMethods.java 8208778 macosx-x64 runtime/SharedArchiveFile/SASymbolTableTest.java 8193639 solaris-all -runtime/MemberName/MemberNameLeak.java 8209844 generic-all ############################################################################# @@ -182,6 +181,7 @@ vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted003/TestDescription.java 6606767 generic-all vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted004/TestDescription.java 7013634,6606767 generic-all vmTestbase/nsk/jvmti/ThreadStart/threadstart001/TestDescription.java 8016181 generic-all +vmTestbase/nsk/jvmti/scenarios/allocation/AP10/ap10t001/TestDescription.java 8210131 generic-all vmTestbase/nsk/jvmti/scenarios/extension/EX03/ex03t001/TestDescription.java 8173658 generic-all vmTestbase/nsk/jvmti/scenarios/hotswap/HS102/hs102t002/TestDescription.java 8204506,8203350 generic-all vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t001/hs204t001.java 6813266 generic-all diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java --- a/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java Thu Aug 30 11:08:01 2018 -0400 @@ -65,7 +65,7 @@ "-XX:MetaspaceSize=4m", "-XX:MaxMetaspaceSize=16m", "-XX:InitialCodeCacheSize=512k", "-XX:ReservedCodeCacheSize=4m", "-XX:ThreadStackSize=512", "-XX:VMThreadStackSize=512", "-XX:CompilerThreadStackSize=512", "-XX:ParallelGCThreads=1", "-XX:CICompilerCount=2", - "-Xcomp", "-XX:CICrashAt=1", "-XX:+DumpReplayDataOnError", "-XX:-TransmitErrorReport", + "-Xcomp", "-XX:CICrashAt=1", "-XX:+DumpReplayDataOnError", "-XX:+PreferInterpreterNativeStubs", "-XX:+PrintCompilation", REPLAY_FILE_OPTION}; private static final String[] REPLAY_OPTIONS = new String[]{DISABLE_COREDUMP_ON_CRASH, "-XX:+ReplayCompiles", REPLAY_FILE_OPTION}; diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/compiler/floatingpoint/TestFloatSyncJNIArgs.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/compiler/floatingpoint/TestFloatSyncJNIArgs.java Thu Aug 30 11:08:01 2018 -0400 @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2015, 2016 SAP SE. All rights reserved. + * Copyright (c) 2018 Red Hat, Inc. 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 + * @bug 8207838 + * @summary Regression test for passing float args to a synchronized jni function. + * + * + * @run main/othervm/native compiler.floatingpoint.TestFloatSyncJNIArgs + */ + +package compiler.floatingpoint; + +public class TestFloatSyncJNIArgs { + static { + try { + System.loadLibrary("TestFloatSyncJNIArgs"); + } catch (UnsatisfiedLinkError e) { + System.out.println("could not load native lib: " + e); + } + } + + private static final int numberOfThreads = 8; + + static volatile Error testFailed = null; + + public synchronized static native float combine15floats( + float f1, float f2, float f3, float f4, + float f5, float f6, float f7, float f8, + float f9, float f10, float f11, float f12, + float f13, float f14, float f15); + + public synchronized static native double combine15doubles( + double d1, double d2, double d3, double d4, + double d5, double d6, double d7, double d8, + double d9, double d10, double d11, double d12, + double d13, double d14, double d15); + + static void test() throws Exception { + Thread[] threads = new Thread[numberOfThreads]; + + for (int i = 0; i < numberOfThreads; i++) { + threads[i] = new Thread(() -> { + for (int j = 0; j < 10000; j++) { + float f = combine15floats(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, + 9, 10, 11, 12, 13, 14, 15); + if (f != 81720.0f) { + testFailed = new Error("jni function didn't combine 15 float args properly: " + f); + throw testFailed; + } + } + }); + } + for (int i = 0; i < numberOfThreads; i++) { + threads[i].start(); + } + for (int i = 0; i < numberOfThreads; i++) { + threads[i].join(); + } + if (testFailed != null) { + throw testFailed; + } + + for (int i = 0; i < numberOfThreads; i++) { + threads[i] = new Thread(() -> { + for (int j = 0; j < 10000; j++) { + double d = combine15doubles(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, + 9, 10, 11, 12, 13, 14, 15); + if (d != 81720.0) { + testFailed = new Error("jni function didn't combine 15 double args properly: " + d); + throw testFailed; + } + } + }); + } + for (int i = 0; i < numberOfThreads; i++) { + threads[i].start(); + } + for (int i = 0; i < numberOfThreads; i++) { + threads[i].join(); + } + if (testFailed != null) { + throw testFailed; + } + } + + public static void main(String[] args) throws Exception { + for (int i = 0; i < 200; ++i) { + test(); + } + } +} diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/compiler/floatingpoint/libTestFloatSyncJNIArgs.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/compiler/floatingpoint/libTestFloatSyncJNIArgs.c Thu Aug 30 11:08:01 2018 -0400 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2018 Red Hat, Inc. 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. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Fletcher checksum. This is a nonlinear function which detects both */ +/* missing or otherwise incorrect arguments and arguments in the wrong */ +/* order. */ +static jfloat fcombine(jfloat f[], int len) { + int i; + jfloat sum = 0, sum_of_sums = 0; + for (i = 0; i < len; i++) { + sum += f[i]; + sum_of_sums += sum; + } + return sum + sum_of_sums * sum; +} + +static jdouble combine(jdouble f[], int len) { + int i; + double sum = 0, sum_of_sums = 0; + for (i = 0; i < len; i++) { + sum += f[i]; + sum_of_sums += sum; + } + return sum + sum_of_sums * sum; +} + +JNIEXPORT jfloat JNICALL Java_compiler_floatingpoint_TestFloatSyncJNIArgs_combine15floats + (JNIEnv *env, jclass cls, + jfloat f1, jfloat f2, jfloat f3, jfloat f4, + jfloat f5, jfloat f6, jfloat f7, jfloat f8, + jfloat f9, jfloat f10, jfloat f11, jfloat f12, + jfloat f13, jfloat f14, jfloat f15) { + + jfloat f[15]; + f[0] = f1; f[1] = f2; f[2] = f3; f[3] = f4; f[4] = f5; + f[5] = f6; f[6] = f7; f[7] = f8; f[8] = f9; f[9] = f10; + f[10] = f11; f[11] = f12; f[12] = f13; f[13] = f14; f[14] = f15; + + return fcombine(f, sizeof f / sizeof f[0]); +} + +JNIEXPORT jdouble JNICALL Java_compiler_floatingpoint_TestFloatSyncJNIArgs_combine15doubles + (JNIEnv *env, jclass cls, + jdouble f1, jdouble f2, jdouble f3, jdouble f4, + jdouble f5, jdouble f6, jdouble f7, jdouble f8, + jdouble f9, jdouble f10, jdouble f11, jdouble f12, + jdouble f13, jdouble f14, jdouble f15) { + + jdouble f[15]; + f[0] = f1; f[1] = f2; f[2] = f3; f[3] = f4; f[4] = f5; + f[5] = f6; f[6] = f7; f[7] = f8; f[8] = f9; f[9] = f10; + f[10] = f11; f[11] = f12; f[12] = f13; f[13] = f14; f[14] = f15; + + return combine(f, sizeof f / sizeof f[0]); +} + + +#ifdef __cplusplus +} +#endif diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/runtime/BoolReturn/JNIBooleanTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/runtime/BoolReturn/JNIBooleanTest.java Thu Aug 30 11:08:01 2018 -0400 @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2018 SAP SE. 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 + * @bug 8209637 + * @summary [s390x] Interpreter doesn't call result handler after native calls + * @author Volker Simonis + * + * @run main/othervm/native -XX:-UseOnStackReplacement -Xbatch JNIBooleanTest 50000 + * @run main/othervm/native -Xint JNIBooleanTest 256 + */ + +import java.lang.reflect.Method; + +public class JNIBooleanTest { + static native boolean foo(byte b); + + static boolean bar(byte b) { + return foo(b); + } + + public static void main(String args[]) throws Exception { + int count = args.length > 0 ? Integer.parseInt(args[0]) : 50_000; + byte b = 0; + for (int i = 0; i < count; i++) { + boolean bool = foo(b); + if ((b == 0 && bool) || (b != 0 && !bool)) { + throw new RuntimeException("Error: foo(" + b + ") = " + bool + " in iteration " + i); + } + b++; + } + + b = 0; + for (int i = 0; i < count; i++) { + boolean bool = bar(b); + if ((b == 0 && bool) || (b != 0 && !bool)) { + throw new RuntimeException("Error: bar(" + b + ") = " + bool + " in iteration " + i); + } + b++; + } + + Method foo = JNIBooleanTest.class.getDeclaredMethod("foo", byte.class); + + b = 0; + for (int i = 0; i < count; i++) { + boolean bool = ((Boolean)foo.invoke(null, b)).booleanValue(); + if ((b == 0 && bool) || (b != 0 && !bool)) { + throw new RuntimeException("Error: foo(" + b + ") = " + bool + " in iteration " + i + " (reflective)"); + } + b++; + } + + Method bar = JNIBooleanTest.class.getDeclaredMethod("bar", byte.class); + + b = 0; + for (int i = 0; i < count; i++) { + boolean bool = ((Boolean)bar.invoke(null, b)).booleanValue(); + if ((b == 0 && bool) || (b != 0 && !bool)) { + throw new RuntimeException("Error: bar(" + b + ") = " + bool + " in iteration " + i + " (reflective)"); + } + b++; + } + } + + static { + System.loadLibrary("JNIBooleanTest"); + } +} diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/runtime/BoolReturn/libJNIBooleanTest.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/runtime/BoolReturn/libJNIBooleanTest.c Thu Aug 30 11:08:01 2018 -0400 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018 SAP SE. 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. + */ + +#include "jni.h" + +JNIEXPORT jboolean JNICALL +Java_JNIBooleanTest_foo(JNIEnv *env, jclass cls, jbyte b) { + jboolean old = b; + return old; +} diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/runtime/ErrorHandling/CreateCoredumpOnCrash.java --- a/test/hotspot/jtreg/runtime/ErrorHandling/CreateCoredumpOnCrash.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/runtime/ErrorHandling/CreateCoredumpOnCrash.java Thu Aug 30 11:08:01 2018 -0400 @@ -57,7 +57,7 @@ public static OutputAnalyzer runTest(String option) throws Exception { return new OutputAnalyzer( ProcessTools.createJavaProcessBuilder( - "-Xmx128m", "-XX:-TransmitErrorReport", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName()) + "-Xmx128m", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName()) .start()); } } diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java --- a/test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java Thu Aug 30 11:08:01 2018 -0400 @@ -43,7 +43,7 @@ // The -XX:ErrorHandlerTest=N option requires debug bits. return new OutputAnalyzer( ProcessTools.createJavaProcessBuilder( - "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=" + testcase) + "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=" + testcase) .start()); } diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/runtime/ErrorHandling/ProblematicFrameTest.java --- a/test/hotspot/jtreg/runtime/ErrorHandling/ProblematicFrameTest.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/runtime/ErrorHandling/ProblematicFrameTest.java Thu Aug 30 11:08:01 2018 -0400 @@ -47,7 +47,7 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xmx64m", "-XX:-TransmitErrorReport", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", Crasher.class.getName()); + "-Xmx64m", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", Crasher.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Exception in thread"); output.shouldNotMatch("error occurred during error reporting \\(printing problematic frame\\)"); diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java Thu Aug 30 11:08:01 2018 -0400 @@ -41,7 +41,6 @@ String msg = "Test Succeeded"; ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=12", // trigger potential SEGV "-XX:OnError=echo " + msg, diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/runtime/MemberName/MemberNameLeak.java --- a/test/hotspot/jtreg/runtime/MemberName/MemberNameLeak.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/runtime/MemberName/MemberNameLeak.java Thu Aug 30 11:08:01 2018 -0400 @@ -34,7 +34,7 @@ import java.lang.invoke.*; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; - +import sun.hotspot.WhiteBox; import sun.hotspot.code.Compiler; public class MemberNameLeak { @@ -44,6 +44,9 @@ public static void main(String[] args) throws Throwable { Leak leak = new Leak(); + WhiteBox wb = WhiteBox.getWhiteBox(); + int removedCountOrig = wb.resolvedMethodRemovedCount(); + int removedCount; for (int i = 0; i < 10; i++) { MethodHandles.Lookup lookup = MethodHandles.lookup(); @@ -54,6 +57,11 @@ } System.gc(); // make mh unused + + // Wait until ServiceThread cleans ResolvedMethod table + do { + removedCount = wb.resolvedMethodRemovedCount(); + } while (removedCountOrig == removedCount); } } @@ -61,6 +69,8 @@ // Run this Leak class with logging ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-Xlog:membername+table=trace", + "-XX:+WhiteBoxAPI", + "-Xbootclasspath/a:.", gc, Leak.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("ResolvedMethod entry added for MemberNameLeak$Leak.callMe()V"); diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency1.java --- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency1.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency1.java Thu Aug 30 11:08:01 2018 -0400 @@ -50,7 +50,6 @@ "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", - "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-Xmx128m", "AssertSafepointCheckConsistency1", diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency2.java --- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency2.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency2.java Thu Aug 30 11:08:01 2018 -0400 @@ -50,7 +50,6 @@ "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", - "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-Xmx128m", "AssertSafepointCheckConsistency2", diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency3.java --- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency3.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency3.java Thu Aug 30 11:08:01 2018 -0400 @@ -50,7 +50,6 @@ "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", - "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-Xmx32m", "AssertSafepointCheckConsistency3", diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency4.java --- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency4.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency4.java Thu Aug 30 11:08:01 2018 -0400 @@ -50,7 +50,6 @@ "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", - "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-Xmx32m", "AssertSafepointCheckConsistency4", diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java --- a/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java Thu Aug 30 11:08:01 2018 -0400 @@ -48,7 +48,6 @@ true, "-Xmx128m", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", - "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-XX:-InlineUnsafeOps", // The compiler intrinsics doesn't have the assert DummyClassWithMainRangeCheck.class.getName()); diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/runtime/memory/ReserveMemory.java --- a/test/hotspot/jtreg/runtime/memory/ReserveMemory.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/runtime/memory/ReserveMemory.java Thu Aug 30 11:08:01 2018 -0400 @@ -55,7 +55,6 @@ "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", - "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-Xmx128m", "ReserveMemory", diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/serviceability/sa/TestJmapCore.java --- a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java Thu Aug 30 11:08:01 2018 -0400 @@ -87,7 +87,7 @@ static void test(String type) throws Throwable { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-XX:+CreateCoredumpOnCrash", - "-XX:MaxMetaspaceSize=64m", "-XX:+CrashOnOutOfMemoryError", "-XX:-TransmitErrorReport", + "-XX:MaxMetaspaceSize=64m", "-XX:+CrashOnOutOfMemoryError", TestJmapCore.class.getName(), type); boolean useDefaultUlimit = useDefaultUlimit(); diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001.java Thu Aug 30 11:08:01 2018 -0400 @@ -50,9 +50,9 @@ * To check up on the method, a debugger, * upon getting new set for ClassPrepareEvent, * suspends VM with the method VirtualMachine.suspend(), - * gets the List of geduggee's threads calling VM.allThreads(), + * gets the List of debuggee's threads calling VM.allThreads(), * invokes the method EventSet.resume(), and - * gets another List of geduggee's threads. + * gets another List of debuggee's threads. * The debugger then compares values of * each thread's suspendCount from first and second Lists. * @@ -63,6 +63,13 @@ * making special clases loaded and prepared to create the Events * - Upon getting the Events, * the debugger performs the check required. + * - The debugger informs the debuggee when it completes + * each test case, so it will wait before hitting + * communication breakpoints. + * This prevents the breakpoint SUSPEND_ALL policy + * disrupting the first test case check for + * SUSPEND_NONE, if the debuggee gets ahead of + * the debugger processing. */ public class resume001 extends TestDebuggerType1 { @@ -233,6 +240,7 @@ default: throw new Failure("** default case 1 **"); } + informDebuggeeTestCase(i); } display("......--> vm.resume()"); @@ -261,5 +269,22 @@ throw new Failure("** FAILURE to set up ClassPrepareRequest **"); } } - + /** + * Inform debuggee which thread test the debugger has completed. + * Used for synchronization, so the debuggee does not move too quickly. + * @param testCase index of just completed test + */ + void informDebuggeeTestCase(int testCase) { + try { + ((ClassType)debuggeeClass) + .setValue(debuggeeClass.fieldByName("testCase"), + vm.mirrorOf(testCase)); + } catch (InvalidTypeException ite) { + throw new Failure("** FAILURE setting testCase **"); + } catch (ClassNotLoadedException cnle) { + throw new Failure("** FAILURE notifying debuggee **"); + } catch (VMDisconnectedException e) { + throw new Failure("** FAILURE debuggee connection **"); + } + } } diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001a.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001a.java Thu Aug 30 11:08:01 2018 -0400 @@ -33,7 +33,7 @@ public class resume001a { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section static final int PASSED = 0; static final int FAILED = 2; @@ -57,6 +57,7 @@ static int exitCode = PASSED; + static int testCase = -1; static int instruction = 1; static int end = 0; // static int quit = 0; @@ -100,6 +101,10 @@ case 0: TestClass2 obj2 = new TestClass2(); + // Wait for debugger to complete the first test case + // before advancing to the first breakpoint + waitForTestCase(0); + break; case 1: @@ -119,6 +124,16 @@ log1("debuggee exits"); System.exit(exitCode + PASS_BASE); } + // Synchronize with debugger progression. + static void waitForTestCase(int t) { + while (testCase < t) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // ignored + } + } + } } class TestClass2 { diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java Thu Aug 30 11:08:01 2018 -0400 @@ -48,9 +48,9 @@ * To check up on the method, a debugger,
* upon getting new set for the EventSet,
* suspends VM with the method VirtualMachine.suspend(),
- * gets the List of geduggee's threads calling VM.allThreads(),
+ * gets the List of debuggee's threads calling VM.allThreads(),
* invokes the method EventSet.resume(), and
- * gets another List of geduggee's threads.
+ * gets another List of debuggee's threads.
* The debugger then compares values of
* each thread's suspendCount from first and second Lists.
*
@@ -87,12 +87,12 @@ public class resume002 { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section static final int PASSED = 0; static final int FAILED = 2; static final int PASS_BASE = 95; - //----------------------------------------------------- templete parameters + //----------------------------------------------------- template parameters static final String sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume002 ", sHeader2 = "--> debugger: ", @@ -503,6 +503,7 @@ log2("......--> vm.resume()"); vm.resume(); + informDebuggeeTestCase(i); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } log1(" TESTING ENDS"); @@ -642,5 +643,22 @@ throw new JDITestRuntimeException("** FAILURE to set up AccessWatchpointRequest **"); } } - + /** + * Inform debuggee which thread test the debugger has completed. + * Used for synchronization, so the debuggee does not move too quickly. + * @param testCase index of just completed test + */ + void informDebuggeeTestCase(int testCase) { + try { + ((ClassType)debuggeeClass) + .setValue(debuggeeClass.fieldByName("testCase"), + vm.mirrorOf(testCase)); + } catch (InvalidTypeException ite) { + throw new Failure("** FAILURE setting testCase **"); + } catch (ClassNotLoadedException cnle) { + throw new Failure("** FAILURE notifying debuggee **"); + } catch (VMDisconnectedException e) { + throw new Failure("** FAILURE debuggee connection **"); + } + } } diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002a.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002a.java Thu Aug 30 11:08:01 2018 -0400 @@ -33,7 +33,7 @@ public class resume002a { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section static final int PASSED = 0; static final int FAILED = 2; @@ -41,6 +41,7 @@ static ArgumentHandler argHandler; static Log log; + static int testCase = -1; //-------------------------------------------------- log procedures @@ -98,8 +99,12 @@ //------------------------------------------------------ section tested - case 0: resume002aTestClass.method(); - break; + case 0: + resume002aTestClass.method(); + // Wait for debugger to complete the first test case + // before advancing to the first breakpoint + waitForTestCase(0); + break; case 1: resume002aTestClass.method(); break; @@ -118,6 +123,17 @@ log1("debuggee exits"); System.exit(exitCode + PASS_BASE); } + // Synchronize with debugger progression. + static void waitForTestCase(int t) { + while (testCase < t) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // ignored + } + } + } + } class resume002aTestClass { diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java Thu Aug 30 11:08:01 2018 -0400 @@ -48,9 +48,9 @@ * To check up on the method, a debugger,
* upon getting new set for the EventSet,
* suspends VM with the method VirtualMachine.suspend(),
- * gets the List of geduggee's threads calling VM.allThreads(),
+ * gets the List of debuggee's threads calling VM.allThreads(),
* invokes the method EventSet.resume(), and
- * gets another List of geduggee's threads.
+ * gets another List of debuggee's threads.
* The debugger then compares values of
* each thread's suspendCount from first and second Lists.
*
@@ -87,12 +87,12 @@ public class resume003 { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section static final int PASSED = 0; static final int FAILED = 2; static final int PASS_BASE = 95; - //----------------------------------------------------- templete parameters + //----------------------------------------------------- template parameters static final String sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume003 ", sHeader2 = "--> debugger: ", @@ -503,6 +503,8 @@ log2("......--> vm.resume()"); vm.resume(); + informDebuggeeTestCase(i); + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } log1(" TESTING ENDS"); @@ -642,5 +644,22 @@ throw new JDITestRuntimeException("** FAILURE to set up ModificationWatchpointRequest **"); } } - + /** + * Inform debuggee which thread test the debugger has completed. + * Used for synchronization, so the debuggee does not move too quickly. + * @param testCase index of just completed test + */ + void informDebuggeeTestCase(int testCase) { + try { + ((ClassType)debuggeeClass) + .setValue(debuggeeClass.fieldByName("testCase"), + vm.mirrorOf(testCase)); + } catch (InvalidTypeException ite) { + throw new Failure("** FAILURE setting testCase **"); + } catch (ClassNotLoadedException cnle) { + throw new Failure("** FAILURE notifying debuggee **"); + } catch (VMDisconnectedException e) { + throw new Failure("** FAILURE debuggee connection **"); + } + } } diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003a.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003a.java Thu Aug 30 11:08:01 2018 -0400 @@ -33,7 +33,8 @@ public class resume003a { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section + static int testCase = -1; static final int PASSED = 0; static final int FAILED = 2; @@ -98,8 +99,12 @@ //------------------------------------------------------ section tested - case 0: resume003aTestClass.method(); - break; + case 0: + resume003aTestClass.method(); + // Wait for debugger to complete the first test case + // before advancing to the first breakpoint + waitForTestCase(0); + break; case 1: resume003aTestClass.method(); break; @@ -118,6 +123,16 @@ log1("debuggee exits"); System.exit(exitCode + PASS_BASE); } + // Synchronize with debugger progression. + static void waitForTestCase(int t) { + while (testCase < t) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // ignored + } + } + } } class resume003aTestClass { diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java Thu Aug 30 11:08:01 2018 -0400 @@ -48,9 +48,9 @@ * To check up on the method, a debugger,
* upon getting new set for the EventSet,
* suspends VM with the method VirtualMachine.suspend(),
- * gets the List of geduggee's threads calling VM.allThreads(),
+ * gets the List of debuggee's threads calling VM.allThreads(),
* invokes the method EventSet.resume(), and
- * gets another List of geduggee's threads.
+ * gets another List of debuggee's threads.
* The debugger then compares values of
* each thread's suspendCount from first and second Lists.
*
@@ -87,12 +87,12 @@ public class resume004 { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section static final int PASSED = 0; static final int FAILED = 2; static final int PASS_BASE = 95; - //----------------------------------------------------- templete parameters + //----------------------------------------------------- template parameters static final String sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume004 ", sHeader2 = "--> debugger: ", @@ -493,6 +493,7 @@ default: throw new JDITestRuntimeException("** default case 1 **"); } + informDebuggeeTestCase(i); } log2("......--> vm.resume()"); @@ -638,5 +639,22 @@ throw new JDITestRuntimeException("** FAILURE to set up BreakpointRequest **"); } } - + /** + * Inform debuggee which thread test the debugger has completed. + * Used for synchronization, so the debuggee does not move too quickly. + * @param testCase index of just completed test + */ + void informDebuggeeTestCase(int testCase) { + try { + ((ClassType)debuggeeClass) + .setValue(debuggeeClass.fieldByName("testCase"), + vm.mirrorOf(testCase)); + } catch (InvalidTypeException ite) { + throw new Failure("** FAILURE setting testCase **"); + } catch (ClassNotLoadedException cnle) { + throw new Failure("** FAILURE notifying debuggee **"); + } catch (VMDisconnectedException e) { + throw new Failure("** FAILURE debuggee connection **"); + } + } } diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004a.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004a.java Thu Aug 30 11:08:01 2018 -0400 @@ -33,7 +33,8 @@ public class resume004a { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section + static int testCase = -1; static final int PASSED = 0; static final int FAILED = 2; @@ -98,8 +99,10 @@ //------------------------------------------------------ section tested - case 0: resume004aTestClass.method(); - break; + case 0: + resume004aTestClass.method(); + waitForTestCase(0); + break; case 1: resume004aTestClass.method(); break; @@ -118,6 +121,16 @@ log1("debuggee exits"); System.exit(exitCode + PASS_BASE); } + // Synchronize with debugger progression. + static void waitForTestCase(int t) { + while (testCase < t) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // ignored + } + } + } } class resume004aTestClass { diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java Thu Aug 30 11:08:01 2018 -0400 @@ -48,9 +48,9 @@ * To check up on the method, a debugger,
* upon getting new set for the EventSet,
* suspends VM with the method VirtualMachine.suspend(),
- * gets the List of geduggee's threads calling VM.allThreads(),
+ * gets the List of debuggee's threads calling VM.allThreads(),
* invokes the method EventSet.resume(), and
- * gets another List of geduggee's threads.
+ * gets another List of debuggee's threads.
* The debugger then compares values of
* each thread's suspendCount from first and second Lists.
*
@@ -87,12 +87,12 @@ public class resume005 { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section static final int PASSED = 0; static final int FAILED = 2; static final int PASS_BASE = 95; - //----------------------------------------------------- templete parameters + //----------------------------------------------------- template parameters static final String sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume005 ", sHeader2 = "--> debugger: ", @@ -493,6 +493,7 @@ default: throw new JDITestRuntimeException("** default case 1 **"); } + informDebuggeeTestCase(i); } log2("......--> vm.resume()"); @@ -634,5 +635,22 @@ throw new JDITestRuntimeException("** FAILURE to set up ExceptionRequest **"); } } - + /** + * Inform debuggee which thread test the debugger has completed. + * Used for synchronization, so the debuggee does not move too quickly. + * @param testCase index of just completed test + */ + void informDebuggeeTestCase(int testCase) { + try { + ((ClassType)debuggeeClass) + .setValue(debuggeeClass.fieldByName("testCase"), + vm.mirrorOf(testCase)); + } catch (InvalidTypeException ite) { + throw new Failure("** FAILURE setting testCase **"); + } catch (ClassNotLoadedException cnle) { + throw new Failure("** FAILURE notifying debuggee **"); + } catch (VMDisconnectedException e) { + throw new Failure("** FAILURE debuggee connection **"); + } + } } diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005a.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005a.java Thu Aug 30 11:08:01 2018 -0400 @@ -33,7 +33,8 @@ public class resume005a { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section + static int testCase = -1; static final int PASSED = 0; static final int FAILED = 2; @@ -98,8 +99,10 @@ //------------------------------------------------------ section tested - case 0: resume005aTestClass.method(); - break; + case 0: + resume005aTestClass.method(); + waitForTestCase(0); + break; case 1: resume005aTestClass.method(); break; @@ -122,7 +125,16 @@ public static void nullMethod() { throw new NullPointerException("test"); } - + // Synchronize with debugger progression. + static void waitForTestCase(int t) { + while (testCase < t) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // ignored + } + } + } } class resume005aTestClass { diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java Thu Aug 30 11:08:01 2018 -0400 @@ -48,9 +48,9 @@ * To check up on the method, a debugger,
* upon getting new set for the EventSet,
* suspends VM with the method VirtualMachine.suspend(),
- * gets the List of geduggee's threads calling VM.allThreads(),
+ * gets the List of debuggee's threads calling VM.allThreads(),
* invokes the method EventSet.resume(), and
- * gets another List of geduggee's threads.
+ * gets another List of debuggee's threads.
* The debugger then compares values of
* each thread's suspendCount from first and second Lists.
*
@@ -87,12 +87,12 @@ public class resume006 { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section static final int PASSED = 0; static final int FAILED = 2; static final int PASS_BASE = 95; - //----------------------------------------------------- templete parameters + //----------------------------------------------------- template parameters static final String sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume006 ", sHeader2 = "--> debugger: ", @@ -495,6 +495,7 @@ log2("......--> vm.resume()"); vm.resume(); + informDebuggeeTestCase(i); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } log1(" TESTING ENDS"); @@ -632,5 +633,22 @@ throw new JDITestRuntimeException("** FAILURE to set up MethodEntryRequest **"); } } - + /** + * Inform debuggee which thread test the debugger has completed. + * Used for synchronization, so the debuggee does not move too quickly. + * @param testCase index of just completed test + */ + void informDebuggeeTestCase(int testCase) { + try { + ((ClassType)debuggeeClass) + .setValue(debuggeeClass.fieldByName("testCase"), + vm.mirrorOf(testCase)); + } catch (InvalidTypeException ite) { + throw new Failure("** FAILURE setting testCase **"); + } catch (ClassNotLoadedException cnle) { + throw new Failure("** FAILURE notifying debuggee **"); + } catch (VMDisconnectedException e) { + throw new Failure("** FAILURE debuggee connection **"); + } + } } diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006a.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006a.java Thu Aug 30 11:08:01 2018 -0400 @@ -33,7 +33,7 @@ public class resume006a { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section static final int PASSED = 0; static final int FAILED = 2; @@ -41,6 +41,7 @@ static ArgumentHandler argHandler; static Log log; + static int testCase = -1; //-------------------------------------------------- log procedures @@ -98,8 +99,12 @@ //------------------------------------------------------ section tested - case 0: resume006aTestClass.method(); - break; + case 0: + resume006aTestClass.method(); + // Wait for debugger to complete the first test case + // before advancing to the next breakpoint + waitForTestCase(0); + break; case 1: resume006aTestClass.method(); break; @@ -118,7 +123,16 @@ log1("debuggee exits"); System.exit(exitCode + PASS_BASE); } - + // Synchronize with debugger progression. + static void waitForTestCase(int t) { + while (testCase < t) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // ignored + } + } + } } class resume006aTestClass { diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java Thu Aug 30 11:08:01 2018 -0400 @@ -48,9 +48,9 @@ * To check up on the method, a debugger,
* upon getting new set for the EventSet,
* suspends VM with the method VirtualMachine.suspend(),
- * gets the List of geduggee's threads calling VM.allThreads(),
+ * gets the List of debuggee's threads calling VM.allThreads(),
* invokes the method EventSet.resume(), and
- * gets another List of geduggee's threads.
+ * gets another List of debuggee's threads.
* The debugger then compares values of
* each thread's suspendCount from first and second Lists.
*
@@ -87,12 +87,12 @@ public class resume007 { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section static final int PASSED = Consts.TEST_PASSED; static final int FAILED = Consts.TEST_FAILED; static final int PASS_BASE = Consts.JCK_STATUS_BASE; - //----------------------------------------------------- templete parameters + //----------------------------------------------------- template parameters static final String sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume007 ", sHeader2 = "--> debugger: ", @@ -490,6 +490,7 @@ default: throw new JDITestRuntimeException("** default case 1 **"); } + informDebuggeeTestCase(i); } log2("......--> vm.resume()"); @@ -631,5 +632,22 @@ throw new JDITestRuntimeException("** FAILURE to set up MethodExitRequest **"); } } - + /** + * Inform debuggee which thread test the debugger has completed. + * Used for synchronization, so the debuggee does not move too quickly. + * @param testCase index of just completed test + */ + void informDebuggeeTestCase(int testCase) { + try { + ((ClassType)debuggeeClass) + .setValue(debuggeeClass.fieldByName("testCase"), + vm.mirrorOf(testCase)); + } catch (InvalidTypeException ite) { + throw new Failure("** FAILURE setting testCase **"); + } catch (ClassNotLoadedException cnle) { + throw new Failure("** FAILURE notifying debuggee **"); + } catch (VMDisconnectedException e) { + throw new Failure("** FAILURE debuggee connection **"); + } + } } diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007a.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007a.java Thu Aug 30 11:08:01 2018 -0400 @@ -33,7 +33,8 @@ public class resume007a { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section + static int testCase = -1; static final int PASSED = 0; static final int FAILED = 2; @@ -98,8 +99,10 @@ //------------------------------------------------------ section tested - case 0: resume007aTestClass.method(); - break; + case 0: + resume007aTestClass.method(); + waitForTestCase(0); + break; case 1: resume007aTestClass.method(); break; @@ -118,7 +121,16 @@ log1("debuggee exits"); System.exit(exitCode + PASS_BASE); } - + // Synchronize with debugger progression. + static void waitForTestCase(int t) { + while (testCase < t) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // ignored + } + } + } } class resume007aTestClass { diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008.java Thu Aug 30 11:08:01 2018 -0400 @@ -50,9 +50,9 @@ * To check up on the method, a debugger, * upon getting new set for the EventSet, * suspends VM with the method VirtualMachine.suspend(), - * gets the List of geduggee's threads calling VM.allThreads(), + * gets the List of debuggee's threads calling VM.allThreads(), * invokes the method EventSet.resume(), and - * gets another List of geduggee's threads. + * gets another List of debuggee's threads. * The debugger then compares values of * each thread's suspendCount from first and second Lists. * @@ -63,6 +63,13 @@ * to be resulting in the event. * - Upon getting new event, the debugger * performs the check corresponding to the event. + * - The debugger informs the debuggee when it completes + * each test case, so it will wait before hitting + * communication breakpoints. + * This prevents the breakpoint SUSPEND_ALL policy + * disrupting the first test case check for + * SUSPEND_NONE, if the debuggee gets ahead of + * the debugger processing. */ public class resume008 extends TestDebuggerType1 { @@ -124,7 +131,9 @@ } display("......waiting for new ThreadStartEvent : " + i); - EventSet eventSet = eventHandler.waitForRequestedEventSet(new EventRequest[]{eventRequest}, waitTime, true); + EventSet eventSet = eventHandler + .waitForRequestedEventSet(new EventRequest[]{eventRequest}, + waitTime, true); EventIterator eventIterator = eventSet.eventIterator(); Event newEvent = eventIterator.nextEvent(); @@ -134,7 +143,8 @@ } else { String property = (String) newEvent.request().getProperty("number"); - display(" got new ThreadStartEvent with propety 'number' == " + property); + display(" got new ThreadStartEvent with propety 'number' == " + + property); display("......checking up on EventSet.resume()"); display("......--> vm.suspend();"); @@ -144,7 +154,8 @@ Map suspendsCounts1 = new HashMap(); for (ThreadReference threadReference : vm.allThreads()) { - suspendsCounts1.put(threadReference.name(), threadReference.suspendCount()); + suspendsCounts1.put(threadReference.name(), + threadReference.suspendCount()); } display(suspendsCounts1.toString()); @@ -154,7 +165,8 @@ display(" getting : Map suspendsCounts2"); Map suspendsCounts2 = new HashMap(); for (ThreadReference threadReference : vm.allThreads()) { - suspendsCounts2.put(threadReference.name(), threadReference.suspendCount()); + suspendsCounts2.put(threadReference.name(), + threadReference.suspendCount()); } display(suspendsCounts2.toString()); @@ -163,85 +175,90 @@ switch (policy) { - case SUSPEND_NONE : - display(" case SUSPEND_NONE"); - for (String threadName : suspendsCounts1.keySet()) { - display(" checking " + threadName); - if (!suspendsCounts2.containsKey(threadName)) { - complain("ERROR: couldn't get ThreadReference for " + threadName); - testExitCode = TEST_FAILED; - break; - } - int count1 = suspendsCounts1.get(threadName); - int count2 = suspendsCounts2.get(threadName); - if (count1 != count2) { - complain("ERROR: suspendCounts don't match for : " + threadName); - complain("before resuming : " + count1); - complain("after resuming : " + count2); - testExitCode = TEST_FAILED; - break; - } - } - break; + case SUSPEND_NONE : + display(" case SUSPEND_NONE"); + for (String threadName : suspendsCounts1.keySet()) { + display(" checking " + threadName); + if (!suspendsCounts2.containsKey(threadName)) { + complain("ERROR: couldn't get ThreadReference for " + + threadName); + testExitCode = TEST_FAILED; + break; + } + int count1 = suspendsCounts1.get(threadName); + int count2 = suspendsCounts2.get(threadName); + if (count1 != count2) { + complain("ERROR: suspendCounts don't match for : " + + threadName); + complain("before resuming : " + count1); + complain("after resuming : " + count2); + testExitCode = TEST_FAILED; + break; + } + } + break; - case SUSPEND_THREAD : - display(" case SUSPEND_THREAD"); - for (String threadName : suspendsCounts1.keySet()) { - display("checking " + threadName); - if (!suspendsCounts2.containsKey(threadName)) { - complain("ERROR: couldn't get ThreadReference for " + threadName); - testExitCode = TEST_FAILED; - break; - } - int count1 = suspendsCounts1.get(threadName); - int count2 = suspendsCounts2.get(threadName); - String eventThreadName = ((ThreadStartEvent)newEvent).thread().name(); - int expectedValue = count2 + (eventThreadName.equals(threadName) ? 1 : 0); - if (count1 != expectedValue) { - complain("ERROR: suspendCounts don't match for : " + threadName); - complain("before resuming : " + count1); - complain("after resuming : " + count2); - testExitCode = TEST_FAILED; - break; - } - } - break; - - case SUSPEND_ALL : + case SUSPEND_THREAD : + display(" case SUSPEND_THREAD"); + for (String threadName : suspendsCounts1.keySet()) { + display("checking " + threadName); + if (!suspendsCounts2.containsKey(threadName)) { + complain("ERROR: couldn't get ThreadReference for " + + threadName); + testExitCode = TEST_FAILED; + break; + } + int count1 = suspendsCounts1.get(threadName); + int count2 = suspendsCounts2.get(threadName); + String eventThreadName = ((ThreadStartEvent)newEvent) + .thread().name(); + int expectedValue = count2 + + (eventThreadName.equals(threadName) ? 1 : 0); + if (count1 != expectedValue) { + complain("ERROR: suspendCounts don't match for : " + + threadName); + complain("before resuming : " + count1); + complain("after resuming : " + count2); + testExitCode = TEST_FAILED; + break; + } + } + break; - display(" case SUSPEND_ALL"); - for (String threadName : suspendsCounts1.keySet()) { - display("checking " + threadName); + case SUSPEND_ALL : + display(" case SUSPEND_ALL"); + for (String threadName : suspendsCounts1.keySet()) { + display("checking " + threadName); + if (!newEvent.request().equals(eventRequest)) + break; + if (!suspendsCounts2.containsKey(threadName)) { + complain("ERROR: couldn't get ThreadReference for " + + threadName); + testExitCode = TEST_FAILED; + break; + } + int count1 = suspendsCounts1.get(threadName); + int count2 = suspendsCounts2.get(threadName); + if (count1 != count2 + 1) { + complain("ERROR: suspendCounts don't match for : " + + threadName); + complain("before resuming : " + count1); + complain("after resuming : " + count2); + testExitCode = TEST_FAILED; + break; + } + } + break; + default: throw new Failure("** default case 1 **"); + } + informDebuggeeTestCase(i); - if (!newEvent.request().equals(eventRequest)) - break; - if (!suspendsCounts2.containsKey(threadName)) { - complain("ERROR: couldn't get ThreadReference for " + threadName); - testExitCode = TEST_FAILED; - break; - } - int count1 = suspendsCounts1.get(threadName); - int count2 = suspendsCounts2.get(threadName); - if (count1 != count2 + 1) { - complain("ERROR: suspendCounts don't match for : " + threadName); - complain("before resuming : " + count1); - complain("after resuming : " + count2); - testExitCode = TEST_FAILED; - break; - } - } - break; - - default: throw new Failure("** default case 1 **"); - } } - display("......--> vm.resume()"); vm.resume(); } return; } - private ThreadStartRequest settingThreadStartRequest(int suspendPolicy, String property) { try { @@ -254,5 +271,22 @@ throw new Failure("** FAILURE to set up ThreadStartRequest **"); } } - + /** + * Inform debuggee which thread test the debugger has completed. + * Used for synchronization, so the debuggee does not move too quickly. + * @param testCase index of just completed test + */ + void informDebuggeeTestCase(int testCase) { + try { + ((ClassType)debuggeeClass) + .setValue(debuggeeClass.fieldByName("testCase"), + vm.mirrorOf(testCase)); + } catch (InvalidTypeException ite) { + throw new Failure("** FAILURE setting testCase **"); + } catch (ClassNotLoadedException cnle) { + throw new Failure("** FAILURE notifying debuggee **"); + } catch (VMDisconnectedException e) { + throw new Failure("** FAILURE debuggee connection **"); + } + } } diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008a.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008a.java Thu Aug 30 11:08:01 2018 -0400 @@ -33,7 +33,7 @@ public class resume008a { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section static final int PASSED = 0; static final int FAILED = 2; @@ -62,6 +62,7 @@ static int exitCode = PASSED; + static int testCase = -1; static int instruction = 1; static int end = 0; // static int quit = 0; @@ -70,6 +71,7 @@ static int lineForComm = 2; + // Debugger sets a breakpoint here to track debuggee private static void methodForCommunication() { int i1 = instruction; int i2 = i1; @@ -85,47 +87,38 @@ log1("debuggee started!"); label0: - for (int i = 0; ; i++) { - - if (instruction > maxInstr) { - logErr("ERROR: unexpected instruction: " + instruction); - exitCode = FAILED; - break ; - } - - switch (i) { - + for (int i = 0; ; i++) { + if (instruction > maxInstr) { + logErr("ERROR: unexpected instruction: " + instruction); + exitCode = FAILED; + break ; + } + switch (i) { //------------------------------------------------------ section tested - - case 0: - thread0 = new Threadresume008a("thread0"); - methodForCommunication(); - - threadStart(thread0); - - thread1 = new Threadresume008a("thread1"); - methodForCommunication(); - break; - - case 1: - threadStart(thread1); - - thread2 = new Threadresume008a("thread2"); - methodForCommunication(); - break; - - case 2: - threadStart(thread2); - - //------------------------------------------------- standard end section - - default: - instruction = end; - methodForCommunication(); - break label0; - } + case 0: + thread0 = new Threadresume008a("thread0"); + methodForCommunication(); + threadStart(thread0); + thread1 = new Threadresume008a("thread1"); + // Wait for debugger to complete the first test case + // before advancing to the first breakpoint + waitForTestCase(0); + methodForCommunication(); + break; + case 1: + threadStart(thread1); + thread2 = new Threadresume008a("thread2"); + methodForCommunication(); + break; + case 2: + threadStart(thread2); + //------------------------------------------------- standard end section + default: + instruction = end; + methodForCommunication(); + break label0; } - + } log1("debuggee exits"); System.exit(exitCode + PASS_BASE); } @@ -145,24 +138,29 @@ } return PASSED; } - + // Synchronize with debugger progression. + static void waitForTestCase(int t) { + while (testCase < t) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // ignored + } + } + } static class Threadresume008a extends Thread { - String tName = null; - public Threadresume008a(String threadName) { super(threadName); tName = threadName; } - public void run() { log1(" 'run': enter :: threadName == " + tName); synchronized (waitnotifyObj) { - waitnotifyObj.notify(); + waitnotifyObj.notify(); } log1(" 'run': exit :: threadName == " + tName); return; } } - } diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009.java Thu Aug 30 11:08:01 2018 -0400 @@ -50,9 +50,9 @@ * To check up on the method, a debugger, * upon getting new set for the EventSet, * suspends VM with the method VirtualMachine.suspend(), - * gets the List of geduggee's threads calling VM.allThreads(), + * gets the List of debuggee's threads calling VM.allThreads(), * invokes the method EventSet.resume(), and - * gets another List of geduggee's threads. + * gets another List of debuggee's threads. * The debugger then compares values of * each thread's suspendCount from first and second Lists. * @@ -63,6 +63,13 @@ * to be resulting in the event. * - Upon getting new event, the debugger * performs the check corresponding to the event. + * - The debugger informs the debuggee when it completes + * each test case, so it will wait before hitting + * communication breakpoints. + * This prevents the breakpoint SUSPEND_ALL policy + * disrupting the first test case check for + * SUSPEND_NONE, if the debuggee gets ahead of + * the debugger processing. */ public class resume009 extends TestDebuggerType1 { @@ -233,6 +240,7 @@ default: throw new Failure("** default case 1 **"); } + informDebuggeeTestCase(i); } display("......--> vm.resume()"); @@ -253,5 +261,22 @@ throw new Failure("** FAILURE to set up ThreadDeathRequest **"); } } - + /** + * Inform debuggee which thread test the debugger has completed. + * Used for synchronization, so the debuggee does not move too quickly. + * @param testCase index of just completed test + */ + void informDebuggeeTestCase(int testCase) { + try { + ((ClassType)debuggeeClass) + .setValue(debuggeeClass.fieldByName("testCase"), + vm.mirrorOf(testCase)); + } catch (InvalidTypeException ite) { + throw new Failure("** FAILURE setting testCase **"); + } catch (ClassNotLoadedException cnle) { + throw new Failure("** FAILURE notifying debuggee **"); + } catch (VMDisconnectedException e) { + throw new Failure("** FAILURE debuggee connection **"); + } + } } diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009a.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009a.java Thu Aug 30 11:08:01 2018 -0400 @@ -33,7 +33,7 @@ public class resume009a { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section static final int PASSED = 0; static final int FAILED = 2; @@ -62,6 +62,7 @@ static int exitCode = PASSED; + static int testCase = -1; static int instruction = 1; static int end = 0; // static int quit = 0; @@ -104,6 +105,9 @@ threadRun(thread0); thread1 = new Threadresume009a("thread1"); + // Wait for debugger to complete the first test case + // before advancing to the first breakpoint + waitForTestCase(0); methodForCommunication(); break; @@ -152,6 +156,16 @@ } return PASSED; } + // Synchronize with debugger progression. + static void waitForTestCase(int t) { + while (testCase < t) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // ignored + } + } + } static class Threadresume009a extends Thread { diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java Thu Aug 30 11:08:01 2018 -0400 @@ -48,9 +48,9 @@ * To check up on the method, a debugger,
* upon getting new set for the EventSet,
* suspends VM with the method VirtualMachine.suspend(),
- * gets the List of geduggee's threads calling VM.allThreads(),
+ * gets the List of debuggee's threads calling VM.allThreads(),
* invokes the method EventSet.resume(), and
- * gets another List of geduggee's threads.
+ * gets another List of debuggee's threads.
* The debugger then compares values of
* each thread's suspendCount from first and second Lists.
*
@@ -87,12 +87,12 @@ public class resume010 { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section static final int PASSED = 0; static final int FAILED = 2; static final int PASS_BASE = 95; - //----------------------------------------------------- templete parameters + //----------------------------------------------------- template parameters static final String sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume010 ", sHeader2 = "--> debugger: ", @@ -488,6 +488,7 @@ default: throw new JDITestRuntimeException("** default case 1 **"); } + informDebuggeeTestCase(i); } log2("......--> vm.resume()"); @@ -627,5 +628,22 @@ throw new JDITestRuntimeException("** FAILURE to set up StepRequest **"); } } - + /** + * Inform debuggee which thread test the debugger has completed. + * Used for synchronization, so the debuggee does not move too quickly. + * @param testCase index of just completed test + */ + void informDebuggeeTestCase(int testCase) { + try { + ((ClassType)debuggeeClass) + .setValue(debuggeeClass.fieldByName("testCase"), + vm.mirrorOf(testCase)); + } catch (InvalidTypeException ite) { + throw new Failure("** FAILURE setting testCase **"); + } catch (ClassNotLoadedException cnle) { + throw new Failure("** FAILURE notifying debuggee **"); + } catch (VMDisconnectedException e) { + throw new Failure("** FAILURE debuggee connection **"); + } + } } diff -r 2aefd58f8ec5 -r 6ba2f471478b test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010a.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010a.java Thu Aug 30 11:08:01 2018 -0400 @@ -33,7 +33,7 @@ public class resume010a { - //----------------------------------------------------- templete section + //----------------------------------------------------- template section static final int PASSED = 0; static final int FAILED = 2; @@ -60,6 +60,7 @@ static int exitCode = PASSED; + static int testCase = -1; static int instruction = 1; static int end = 0; // static int quit = 0; @@ -98,8 +99,12 @@ //------------------------------------------------------ section tested - case 0: resume010aTestClass.method(); - break; + case 0: + resume010aTestClass.method(); + // Wait for debugger to complete the first test case + // before advancing to the first breakpoint + waitForTestCase(0); + break; case 1: resume010aTestClass.method(); break; @@ -117,7 +122,16 @@ System.exit(exitCode + PASS_BASE); } - + // Synchronize with debugger progression. + static void waitForTestCase(int t) { + while (testCase < t) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // ignored + } + } + } } class resume010aTestClass { diff -r 2aefd58f8ec5 -r 6ba2f471478b test/jdk/java/text/Format/NumberFormat/CurrencyFormat.java --- a/test/jdk/java/text/Format/NumberFormat/CurrencyFormat.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/jdk/java/text/Format/NumberFormat/CurrencyFormat.java Thu Aug 30 11:08:01 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2018, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 4290801 4942982 5102005 8008577 8021121 + * @bug 4290801 4942982 5102005 8008577 8021121 8210153 * @summary Basic tests for currency formatting. * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=JRE,SPI CurrencyFormat diff -r 2aefd58f8ec5 -r 6ba2f471478b test/jdk/java/text/Format/NumberFormat/CurrencySymbols.properties --- a/test/jdk/java/text/Format/NumberFormat/CurrencySymbols.properties Wed Aug 29 14:48:09 2018 -0400 +++ b/test/jdk/java/text/Format/NumberFormat/CurrencySymbols.properties Thu Aug 30 11:08:01 2018 -0400 @@ -66,7 +66,7 @@ es_PY=G es_SV=C es_UY=NU$ -es_VE=Bs.F. +es_VE=Bs.S. et=\u00A4 et_EE=\u20AC fi=\u00A4 diff -r 2aefd58f8ec5 -r 6ba2f471478b test/jdk/javax/net/ssl/templates/SSLEngineTemplate.java --- a/test/jdk/javax/net/ssl/templates/SSLEngineTemplate.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/jdk/javax/net/ssl/templates/SSLEngineTemplate.java Thu Aug 30 11:08:01 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, 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 @@ -30,7 +30,6 @@ * @summary SSLEngine has not yet caused Solaris kernel to panic * @run main/othervm SSLEngineTemplate */ - /** * A SSLEngine usage example which simplifies the presentation * by removing the I/O and multi-threading concerns. @@ -66,7 +65,6 @@ * unwrap() ... ChangeCipherSpec * unwrap() ... Finished */ - import javax.net.ssl.*; import javax.net.ssl.SSLEngineResult.*; import java.io.*; @@ -115,7 +113,7 @@ private static final String pathToStores = "../etc"; private static final String keyStoreFile = "keystore"; private static final String trustStoreFile = "truststore"; - private static final String passwd = "passphrase"; + private static final char[] passphrase = "passphrase".toCharArray(); private static final String keyFilename = System.getProperty("test.src", ".") + "/" + pathToStores + @@ -146,8 +144,6 @@ KeyStore ks = KeyStore.getInstance("JKS"); KeyStore ts = KeyStore.getInstance("JKS"); - char[] passphrase = "passphrase".toCharArray(); - ks.load(new FileInputStream(keyFilename), passphrase); ts.load(new FileInputStream(trustFilename), passphrase); @@ -187,8 +183,11 @@ createSSLEngines(); createBuffers(); - SSLEngineResult clientResult; // results from client's last operation - SSLEngineResult serverResult; // results from server's last operation + // results from client's last operation + SSLEngineResult clientResult; + + // results from server's last operation + SSLEngineResult serverResult; /* * Examining the SSLEngineResults could be much more involved, @@ -198,31 +197,62 @@ * to write to the output pipe, we could reallocate a larger * pipe, but instead we wait for the peer to drain it. */ - while (!isEngineClosed(clientEngine) || - !isEngineClosed(serverEngine)) { + Exception clientException = null; + Exception serverException = null; + + while (!isEngineClosed(clientEngine) + || !isEngineClosed(serverEngine)) { log("================"); - clientResult = clientEngine.wrap(clientOut, cTOs); - log("client wrap: ", clientResult); - runDelegatedTasks(clientResult, clientEngine); + try { + clientResult = clientEngine.wrap(clientOut, cTOs); + log("client wrap: ", clientResult); + } catch (Exception e) { + clientException = e; + System.out.println("Client wrap() threw: " + e.getMessage()); + } + logEngineStatus(clientEngine); + runDelegatedTasks(clientEngine); - serverResult = serverEngine.wrap(serverOut, sTOc); - log("server wrap: ", serverResult); - runDelegatedTasks(serverResult, serverEngine); + log("----"); + + try { + serverResult = serverEngine.wrap(serverOut, sTOc); + log("server wrap: ", serverResult); + } catch (Exception e) { + serverException = e; + System.out.println("Server wrap() threw: " + e.getMessage()); + } + logEngineStatus(serverEngine); + runDelegatedTasks(serverEngine); cTOs.flip(); sTOc.flip(); + log("--------"); + + try { + clientResult = clientEngine.unwrap(sTOc, clientIn); + log("client unwrap: ", clientResult); + } catch (Exception e) { + clientException = e; + System.out.println("Client unwrap() threw: " + e.getMessage()); + } + logEngineStatus(clientEngine); + runDelegatedTasks(clientEngine); + log("----"); - clientResult = clientEngine.unwrap(sTOc, clientIn); - log("client unwrap: ", clientResult); - runDelegatedTasks(clientResult, clientEngine); - - serverResult = serverEngine.unwrap(cTOs, serverIn); - log("server unwrap: ", serverResult); - runDelegatedTasks(serverResult, serverEngine); + try { + serverResult = serverEngine.unwrap(cTOs, serverIn); + log("server unwrap: ", serverResult); + } catch (Exception e) { + serverException = e; + System.out.println("Server unwrap() threw: " + e.getMessage()); + } + logEngineStatus(serverEngine); + runDelegatedTasks(serverEngine); cTOs.compact(); sTOc.compact(); @@ -244,13 +274,22 @@ log("\tClosing clientEngine's *OUTBOUND*..."); clientEngine.closeOutbound(); + logEngineStatus(clientEngine); + dataDone = true; log("\tClosing serverEngine's *OUTBOUND*..."); serverEngine.closeOutbound(); + logEngineStatus(serverEngine); } } } + private static void logEngineStatus(SSLEngine engine) { + log("\tCurrent HS State " + engine.getHandshakeStatus().toString()); + log("\tisInboundDone(): " + engine.isInboundDone()); + log("\tisOutboundDone(): " + engine.isOutboundDone()); + } + /* * Using the SSLContext created during object creation, * create/configure the SSLEngines we'll use for this test. @@ -264,11 +303,19 @@ serverEngine.setUseClientMode(false); serverEngine.setNeedClientAuth(true); + // Get/set parameters if needed + SSLParameters paramsServer = serverEngine.getSSLParameters(); + serverEngine.setSSLParameters(paramsServer); + /* * Similar to above, but using client mode instead. */ clientEngine = sslc.createSSLEngine("client", 80); clientEngine.setUseClientMode(true); + + // Get/set parameters if needed + SSLParameters paramsClient = clientEngine.getSSLParameters(); + clientEngine.setSSLParameters(paramsClient); } /* @@ -307,13 +354,12 @@ * If the result indicates that we have outstanding tasks to do, * go ahead and run them in this thread. */ - private static void runDelegatedTasks(SSLEngineResult result, - SSLEngine engine) throws Exception { + private static void runDelegatedTasks(SSLEngine engine) throws Exception { - if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { + if (engine.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { Runnable runnable; while ((runnable = engine.getDelegatedTask()) != null) { - log("\trunning delegated task..."); + log(" running delegated task..."); runnable.run(); } HandshakeStatus hsStatus = engine.getHandshakeStatus(); @@ -321,7 +367,7 @@ throw new Exception( "handshake shouldn't need additional tasks"); } - log("\tnew HandshakeStatus: " + hsStatus); + logEngineStatus(engine); } } @@ -361,14 +407,14 @@ if (resultOnce) { resultOnce = false; System.out.println("The format of the SSLEngineResult is: \n" + - "\t\"getStatus() / getHandshakeStatus()\" +\n" + - "\t\"bytesConsumed() / bytesProduced()\"\n"); + "\t\"getStatus() / getHandshakeStatus()\" +\n" + + "\t\"bytesConsumed() / bytesProduced()\"\n"); } HandshakeStatus hsStatus = result.getHandshakeStatus(); log(str + - result.getStatus() + "/" + hsStatus + ", " + - result.bytesConsumed() + "/" + result.bytesProduced() + - " bytes"); + result.getStatus() + "/" + hsStatus + ", " + + result.bytesConsumed() + "/" + result.bytesProduced() + + " bytes"); if (hsStatus == HandshakeStatus.FINISHED) { log("\t...ready for application data"); } diff -r 2aefd58f8ec5 -r 6ba2f471478b test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java --- a/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java Thu Aug 30 11:08:01 2018 -0400 @@ -69,7 +69,6 @@ ProcessTools.createJavaProcessBuilder(true, "-Xmx64m", "-Xint", - "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:StartFlightRecording=dumponexit=true", diff -r 2aefd58f8ec5 -r 6ba2f471478b test/jdk/sun/security/ssl/ClientHandshaker/LengthCheckTest.java --- a/test/jdk/sun/security/ssl/ClientHandshaker/LengthCheckTest.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/jdk/sun/security/ssl/ClientHandshaker/LengthCheckTest.java Thu Aug 30 11:08:01 2018 -0400 @@ -74,6 +74,7 @@ import java.nio.*; import java.util.List; import java.util.ArrayList; +import java.util.Iterator; public class LengthCheckTest { @@ -203,7 +204,11 @@ // Now send each ByteBuffer (each being a complete // TLS record) into the client-side unwrap. - for (ByteBuffer bBuf : recList) { + // for (ByteBuffer bBuf : recList) { + + Iterator iter = recList.iterator(); + while (!gotException && (iter.hasNext())) { + ByteBuffer bBuf = iter.next(); dumpByteBuffer("SERVER-TO-CLIENT", bBuf); try { clientResult = clientEngine.unwrap(bBuf, clientIn); @@ -232,8 +237,8 @@ // was thrown and the proper action (a TLS alert) was // sent back to the server. if (gotException == false || - !isTlsMessage(cTOs, TLS_RECTYPE_ALERT, TLS_ALERT_LVL_FATAL, - TLS_ALERT_UNEXPECTED_MSG)) { + !isTlsMessage(cTOs, TLS_RECTYPE_ALERT, TLS_ALERT_LVL_FATAL, + TLS_ALERT_ILLEGAL_PARAMETER)) { throw new SSLException( "Client failed to throw Alert:fatal:internal_error"); } @@ -253,38 +258,36 @@ ByteBuffer evilClientHello = createEvilClientHello(64); dumpByteBuffer("CLIENT-TO-SERVER", evilClientHello); + // Server consumes Client Hello + serverResult = serverEngine.unwrap(evilClientHello, serverIn); + log("server unwrap: ", serverResult); + runDelegatedTasks(serverResult, serverEngine); + evilClientHello.compact(); + + // Under normal circumstances this should be a ServerHello + // But should throw an exception instead due to the invalid + // session ID. try { - // Server consumes Client Hello - serverResult = serverEngine.unwrap(evilClientHello, serverIn); - log("server unwrap: ", serverResult); - runDelegatedTasks(serverResult, serverEngine); - evilClientHello.compact(); - - // Under normal circumstances this should be a ServerHello - // But should throw an exception instead due to the invalid - // session ID. serverResult = serverEngine.wrap(serverOut, sTOc); log("server wrap: ", serverResult); runDelegatedTasks(serverResult, serverEngine); - sTOc.flip(); - dumpByteBuffer("SERVER-TO-CLIENT", sTOc); - - // We expect to see the server generate an alert here - serverResult = serverEngine.wrap(serverOut, sTOc); - log("server wrap: ", serverResult); - runDelegatedTasks(serverResult, serverEngine); - sTOc.flip(); - dumpByteBuffer("SERVER-TO-CLIENT", sTOc); } catch (SSLProtocolException ssle) { log("Received expected SSLProtocolException: " + ssle); gotException = true; } + // We expect to see the server generate an alert here + serverResult = serverEngine.wrap(serverOut, sTOc); + log("server wrap: ", serverResult); + runDelegatedTasks(serverResult, serverEngine); + sTOc.flip(); + dumpByteBuffer("SERVER-TO-CLIENT", sTOc); + // At this point we can verify that both an exception // was thrown and the proper action (a TLS alert) was // sent back to the client. if (gotException == false || - !isTlsMessage(sTOc, TLS_RECTYPE_ALERT, TLS_ALERT_LVL_FATAL, + !isTlsMessage(sTOc, TLS_RECTYPE_ALERT, TLS_ALERT_LVL_FATAL, TLS_ALERT_ILLEGAL_PARAMETER)) { throw new SSLException( "Server failed to throw Alert:fatal:internal_error"); diff -r 2aefd58f8ec5 -r 6ba2f471478b test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineFailedALPN.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineFailedALPN.java Thu Aug 30 11:08:01 2018 -0400 @@ -0,0 +1,449 @@ +/* + * Copyright (c) 2003, 2018, 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. + */ + +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. + +/* + * @test + * @bug 8207317 + * @summary SSLEngine negotiation fail Exception behavior changed from + * fail-fast to fail-lazy + * @run main/othervm SSLEngineFailedALPN + */ +/** + * A SSLEngine usage example which simplifies the presentation + * by removing the I/O and multi-threading concerns. + * + * The test creates two SSLEngines, simulating a client and server. + * The "transport" layer consists two byte buffers: think of them + * as directly connected pipes. + * + * Note, this is a *very* simple example: real code will be much more + * involved. For example, different threading and I/O models could be + * used, transport mechanisms could close unexpectedly, and so on. + * + * When this application runs, notice that several messages + * (wrap/unwrap) pass before any application data is consumed or + * produced. (For more information, please see the SSL/TLS + * specifications.) There may several steps for a successful handshake, + * so it's typical to see the following series of operations: + * + * client server message + * ====== ====== ======= + * wrap() ... ClientHello + * ... unwrap() ClientHello + * ... wrap() ServerHello/Certificate + * unwrap() ... ServerHello/Certificate + * wrap() ... ClientKeyExchange + * wrap() ... ChangeCipherSpec + * wrap() ... Finished + * ... unwrap() ClientKeyExchange + * ... unwrap() ChangeCipherSpec + * ... unwrap() Finished + * ... wrap() ChangeCipherSpec + * ... wrap() Finished + * unwrap() ... ChangeCipherSpec + * unwrap() ... Finished + */ +import javax.net.ssl.*; +import javax.net.ssl.SSLEngineResult.*; +import java.io.*; +import java.security.*; +import java.nio.*; + +public class SSLEngineFailedALPN { + + /* + * Enables logging of the SSLEngine operations. + */ + private static final boolean logging = true; + + /* + * Enables the JSSE system debugging system property: + * + * -Djavax.net.debug=all + * + * This gives a lot of low-level information about operations underway, + * including specific handshake messages, and might be best examined + * after gaining some familiarity with this application. + */ + private static final boolean debug = false; + + private final SSLContext sslc; + + private SSLEngine clientEngine; // client Engine + private ByteBuffer clientOut; // write side of clientEngine + private ByteBuffer clientIn; // read side of clientEngine + + private SSLEngine serverEngine; // server Engine + private ByteBuffer serverOut; // write side of serverEngine + private ByteBuffer serverIn; // read side of serverEngine + + /* + * For data transport, this example uses local ByteBuffers. This + * isn't really useful, but the purpose of this example is to show + * SSLEngine concepts, not how to do network transport. + */ + private ByteBuffer cTOs; // "reliable" transport client->server + private ByteBuffer sTOc; // "reliable" transport server->client + + /* + * The following is to set up the keystores. + */ + private static final String pathToStores = "../../../../javax/net/ssl/etc"; + private static final String keyStoreFile = "keystore"; + private static final String trustStoreFile = "truststore"; + private static final char[] passphrase = "passphrase".toCharArray(); + + private static final String keyFilename = + System.getProperty("test.src", ".") + "/" + pathToStores + + "/" + keyStoreFile; + private static final String trustFilename = + System.getProperty("test.src", ".") + "/" + pathToStores + + "/" + trustStoreFile; + + /* + * Main entry point for this test. + */ + public static void main(String args[]) throws Exception { + if (debug) { + System.setProperty("javax.net.debug", "all"); + } + + SSLEngineFailedALPN test = new SSLEngineFailedALPN(); + test.runTest(); + + System.out.println("Test Passed."); + } + + /* + * Create an initialized SSLContext to use for these tests. + */ + public SSLEngineFailedALPN() throws Exception { + + KeyStore ks = KeyStore.getInstance("JKS"); + KeyStore ts = KeyStore.getInstance("JKS"); + + ks.load(new FileInputStream(keyFilename), passphrase); + ts.load(new FileInputStream(trustFilename), passphrase); + + KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); + kmf.init(ks, passphrase); + + TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); + tmf.init(ts); + + SSLContext sslCtx = SSLContext.getInstance("TLS"); + + sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); + + sslc = sslCtx; + } + + /* + * Run the test. + * + * Sit in a tight loop, both engines calling wrap/unwrap regardless + * of whether data is available or not. We do this until both engines + * report back they are closed. + * + * The main loop handles all of the I/O phases of the SSLEngine's + * lifetime: + * + * initial handshaking + * application data transfer + * engine closing + * + * One could easily separate these phases into separate + * sections of code. + */ + private void runTest() throws Exception { + boolean dataDone = false; + + createSSLEngines(); + createBuffers(); + + // results from client's last operation + SSLEngineResult clientResult; + + // results from server's last operation + SSLEngineResult serverResult; + + /* + * Examining the SSLEngineResults could be much more involved, + * and may alter the overall flow of the application. + * + * For example, if we received a BUFFER_OVERFLOW when trying + * to write to the output pipe, we could reallocate a larger + * pipe, but instead we wait for the peer to drain it. + */ + Exception clientException = null; + Exception serverException = null; + + while (!isEngineClosed(clientEngine) + || !isEngineClosed(serverEngine)) { + + log("================"); + + try { + clientResult = clientEngine.wrap(clientOut, cTOs); + log("client wrap: ", clientResult); + } catch (Exception e) { + clientException = e; + System.out.println("Client wrap() threw: " + e.getMessage()); + } + logEngineStatus(clientEngine); + runDelegatedTasks(clientEngine); + + log("----"); + + try { + serverResult = serverEngine.wrap(serverOut, sTOc); + log("server wrap: ", serverResult); + } catch (Exception e) { + serverException = e; + System.out.println("Server wrap() threw: " + e.getMessage()); + } + logEngineStatus(serverEngine); + runDelegatedTasks(serverEngine); + + cTOs.flip(); + sTOc.flip(); + + log("--------"); + + try { + clientResult = clientEngine.unwrap(sTOc, clientIn); + log("client unwrap: ", clientResult); + } catch (Exception e) { + clientException = e; + System.out.println("Client unwrap() threw: " + e.getMessage()); + } + logEngineStatus(clientEngine); + runDelegatedTasks(clientEngine); + + log("----"); + + try { + serverResult = serverEngine.unwrap(cTOs, serverIn); + log("server unwrap: ", serverResult); + } catch (Exception e) { + serverException = e; + System.out.println("Server unwrap() threw: " + e.getMessage()); + } + logEngineStatus(serverEngine); + runDelegatedTasks(serverEngine); + + cTOs.compact(); + sTOc.compact(); + + /* + * After we've transfered all application data between the client + * and server, we close the clientEngine's outbound stream. + * This generates a close_notify handshake message, which the + * server engine receives and responds by closing itself. + */ + if (!dataDone && (clientOut.limit() == serverIn.position()) && + (serverOut.limit() == clientIn.position())) { + + /* + * A sanity check to ensure we got what was sent. + */ + checkTransfer(serverOut, clientIn); + checkTransfer(clientOut, serverIn); + + log("\tClosing clientEngine's *OUTBOUND*..."); + clientEngine.closeOutbound(); + logEngineStatus(clientEngine); + + dataDone = true; + log("\tClosing serverEngine's *OUTBOUND*..."); + serverEngine.closeOutbound(); + logEngineStatus(serverEngine); + } + } + + log("================"); + + if ((clientException != null) && + (clientException instanceof SSLHandshakeException)) { + log("Client threw proper exception"); + clientException.printStackTrace(System.out); + } else { + throw new Exception("Client Exception not seen"); + } + + if ((serverException != null) && + (serverException instanceof SSLHandshakeException)) { + log("Server threw proper exception:"); + serverException.printStackTrace(System.out); + } else { + throw new Exception("Server Exception not seen"); + } + } + + private static void logEngineStatus(SSLEngine engine) { + log("\tCurrent HS State " + engine.getHandshakeStatus().toString()); + log("\tisInboundDone(): " + engine.isInboundDone()); + log("\tisOutboundDone(): " + engine.isOutboundDone()); + } + + /* + * Using the SSLContext created during object creation, + * create/configure the SSLEngines we'll use for this test. + */ + private void createSSLEngines() throws Exception { + /* + * Configure the serverEngine to act as a server in the SSL/TLS + * handshake. Also, require SSL client authentication. + */ + serverEngine = sslc.createSSLEngine(); + serverEngine.setUseClientMode(false); + serverEngine.setNeedClientAuth(true); + + // Get/set parameters if needed + SSLParameters paramsServer = serverEngine.getSSLParameters(); + paramsServer.setApplicationProtocols(new String[]{"one"}); + serverEngine.setSSLParameters(paramsServer); + + /* + * Similar to above, but using client mode instead. + */ + clientEngine = sslc.createSSLEngine("client", 80); + clientEngine.setUseClientMode(true); + + // Get/set parameters if needed + SSLParameters paramsClient = clientEngine.getSSLParameters(); + paramsClient.setApplicationProtocols(new String[]{"two"}); + clientEngine.setSSLParameters(paramsClient); + } + + /* + * Create and size the buffers appropriately. + */ + private void createBuffers() { + + /* + * We'll assume the buffer sizes are the same + * between client and server. + */ + SSLSession session = clientEngine.getSession(); + int appBufferMax = session.getApplicationBufferSize(); + int netBufferMax = session.getPacketBufferSize(); + + /* + * We'll make the input buffers a bit bigger than the max needed + * size, so that unwrap()s following a successful data transfer + * won't generate BUFFER_OVERFLOWS. + * + * We'll use a mix of direct and indirect ByteBuffers for + * tutorial purposes only. In reality, only use direct + * ByteBuffers when they give a clear performance enhancement. + */ + clientIn = ByteBuffer.allocate(appBufferMax + 50); + serverIn = ByteBuffer.allocate(appBufferMax + 50); + + cTOs = ByteBuffer.allocateDirect(netBufferMax); + sTOc = ByteBuffer.allocateDirect(netBufferMax); + + clientOut = ByteBuffer.wrap("Hi Server, I'm Client".getBytes()); + serverOut = ByteBuffer.wrap("Hello Client, I'm Server".getBytes()); + } + + /* + * If the result indicates that we have outstanding tasks to do, + * go ahead and run them in this thread. + */ + private static void runDelegatedTasks(SSLEngine engine) throws Exception { + + if (engine.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { + Runnable runnable; + while ((runnable = engine.getDelegatedTask()) != null) { + log(" running delegated task..."); + runnable.run(); + } + HandshakeStatus hsStatus = engine.getHandshakeStatus(); + if (hsStatus == HandshakeStatus.NEED_TASK) { + throw new Exception( + "handshake shouldn't need additional tasks"); + } + logEngineStatus(engine); + } + } + + private static boolean isEngineClosed(SSLEngine engine) { + return (engine.isOutboundDone() && engine.isInboundDone()); + } + + /* + * Simple check to make sure everything came across as expected. + */ + private static void checkTransfer(ByteBuffer a, ByteBuffer b) + throws Exception { + a.flip(); + b.flip(); + + if (!a.equals(b)) { + throw new Exception("Data didn't transfer cleanly"); + } else { + log("\tData transferred cleanly"); + } + + a.position(a.limit()); + b.position(b.limit()); + a.limit(a.capacity()); + b.limit(b.capacity()); + } + + /* + * Logging code + */ + private static boolean resultOnce = true; + + private static void log(String str, SSLEngineResult result) { + if (!logging) { + return; + } + if (resultOnce) { + resultOnce = false; + System.out.println("The format of the SSLEngineResult is: \n" + + "\t\"getStatus() / getHandshakeStatus()\" +\n" + + "\t\"bytesConsumed() / bytesProduced()\"\n"); + } + HandshakeStatus hsStatus = result.getHandshakeStatus(); + log(str + + result.getStatus() + "/" + hsStatus + ", " + + result.bytesConsumed() + "/" + result.bytesProduced() + + " bytes"); + if (hsStatus == HandshakeStatus.FINISHED) { + log("\t...ready for application data"); + } + } + + private static void log(String str) { + if (logging) { + System.out.println(str); + } + } +} diff -r 2aefd58f8ec5 -r 6ba2f471478b test/lib/sun/hotspot/WhiteBox.java --- a/test/lib/sun/hotspot/WhiteBox.java Wed Aug 29 14:48:09 2018 -0400 +++ b/test/lib/sun/hotspot/WhiteBox.java Thu Aug 30 11:08:01 2018 -0400 @@ -536,4 +536,7 @@ // Decoder public native void disableElfSectionCache(); + + // Resolved Method Table + public native int resolvedMethodRemovedCount(); }