From 6fad78894d84dc204e2ec59253d294b5b2eb09ad Mon Sep 17 00:00:00 2001 From: Jerry Zhou Date: Mon, 21 Jan 2019 02:43:33 +0000 Subject: [PATCH 001/101] 8217352: Remove EA from version string starting with Initial RC promotion Reviewed-by: erikj, tbell --- make/conf/jib-profiles.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js index 8cf01a4e0eb..ab45e1c2c3c 100644 --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -1154,7 +1154,7 @@ var versionArgs = function(input, common) { args = concat(args, // This needs to be changed when we start building release candidates // with-version-pre must be set to ea for 'ea' and empty for fcs build - "--with-version-pre=ea", + "--with-version-pre=", "--without-version-opt"); } else { args = concat(args, "--with-version-opt=" + common.build_id); From 3a509a38decdd9f4d6f4d5f878602e65e3da436f Mon Sep 17 00:00:00 2001 From: Jesper Wilhelmsson Date: Thu, 7 Feb 2019 02:53:27 +0100 Subject: [PATCH 002/101] Added tag jdk-12+31 for changeset b5f7bb57de2f --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 0b32ba30f54..0a2ba5b9f1a 100644 --- a/.hgtags +++ b/.hgtags @@ -533,3 +533,4 @@ f15d443f97318e9b40e6f451e327ff69ed4ec361 jdk-12+27 659b004b6a1bd8c31e766cbdf328d8f8473fd4d7 jdk-12+28 44f41693631f9b5ac78ff4d2bfabd6734fe46df2 jdk-12+29 6c377af36a5c4203f16aed8a5e4c2ecc08fcd8bd jdk-12+30 +b5f7bb57de2f797be34f6c75d45c3245ad37ab97 jdk-12+31 From 551a272ced8d2bd53ac21e5b3e7f2c18de859ae9 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Thu, 7 Feb 2019 10:26:32 +0100 Subject: [PATCH 003/101] 8218565: HandleMark cleanup Reviewed-by: coleenp, kbarrett, rehn --- src/hotspot/share/runtime/handles.cpp | 37 ++++++-------------- src/hotspot/share/runtime/handles.hpp | 2 ++ src/hotspot/share/runtime/handles.inline.hpp | 21 +++++------ 3 files changed, 21 insertions(+), 39 deletions(-) diff --git a/src/hotspot/share/runtime/handles.cpp b/src/hotspot/share/runtime/handles.cpp index 4c902df6363..a91dcff8520 100644 --- a/src/hotspot/share/runtime/handles.cpp +++ b/src/hotspot/share/runtime/handles.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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,7 +26,6 @@ #include "memory/allocation.inline.hpp" #include "oops/constantPool.hpp" #include "oops/oop.inline.hpp" -#include "runtime/atomic.hpp" #include "runtime/handles.inline.hpp" #include "runtime/thread.inline.hpp" @@ -102,9 +101,6 @@ static uintx chunk_oops_do(OopClosure* f, Chunk* chunk, char* chunk_top) { return handles_visited; } -// Used for debugging handle allocation. -NOT_PRODUCT(jint _nof_handlemarks = 0;) - void HandleArea::oops_do(OopClosure* f) { uintx handles_visited = 0; // First handle the current chunk. It is filled to the high water mark. @@ -130,46 +126,35 @@ void HandleMark::initialize(Thread* thread) { _size_in_bytes = _area->_size_in_bytes; debug_only(_area->_handle_mark_nesting++); assert(_area->_handle_mark_nesting > 0, "must stack allocate HandleMarks"); - debug_only(Atomic::inc(&_nof_handlemarks);) // Link this in the thread set_previous_handle_mark(thread->last_handle_mark()); thread->set_last_handle_mark(this); } - HandleMark::~HandleMark() { - HandleArea* area = _area; // help compilers with poor alias analysis - assert(area == _thread->handle_area(), "sanity check"); - assert(area->_handle_mark_nesting > 0, "must stack allocate HandleMarks" ); - debug_only(area->_handle_mark_nesting--); + assert(_area == _thread->handle_area(), "sanity check"); + assert(_area->_handle_mark_nesting > 0, "must stack allocate HandleMarks" ); - // Delete later chunks - if( _chunk->next() ) { - // reset arena size before delete chunks. Otherwise, the total - // arena size could exceed total chunk size - assert(area->size_in_bytes() > size_in_bytes(), "Sanity check"); - area->set_size_in_bytes(size_in_bytes()); - _chunk->next_chop(); - } else { - assert(area->size_in_bytes() == size_in_bytes(), "Sanity check"); - } - // Roll back arena to saved top markers - area->_chunk = _chunk; - area->_hwm = _hwm; - area->_max = _max; + pop_and_restore(); #ifdef ASSERT // clear out first chunk (to detect allocation bugs) if (ZapVMHandleArea) { memset(_hwm, badHandleValue, _max - _hwm); } - Atomic::dec(&_nof_handlemarks); #endif // Unlink this from the thread _thread->set_last_handle_mark(previous_handle_mark()); } +void HandleMark::chop_later_chunks() { + // reset arena size before delete chunks. Otherwise, the total + // arena size could exceed total chunk size + _area->set_size_in_bytes(size_in_bytes()); + _chunk->next_chop(); +} + void* HandleMark::operator new(size_t size) throw() { return AllocateHeap(size, mtThread); } diff --git a/src/hotspot/share/runtime/handles.hpp b/src/hotspot/share/runtime/handles.hpp index 23a4a3bd72c..1bae5d7b782 100644 --- a/src/hotspot/share/runtime/handles.hpp +++ b/src/hotspot/share/runtime/handles.hpp @@ -253,6 +253,8 @@ class HandleMark { HandleMark* previous_handle_mark() const { return _previous_handle_mark; } size_t size_in_bytes() const { return _size_in_bytes; } + // remove all chunks beginning with the next + void chop_later_chunks(); public: HandleMark(); // see handles_inline.hpp HandleMark(Thread* thread) { initialize(thread); } diff --git a/src/hotspot/share/runtime/handles.inline.hpp b/src/hotspot/share/runtime/handles.inline.hpp index 17a3cc49fdb..825e8cfba82 100644 --- a/src/hotspot/share/runtime/handles.inline.hpp +++ b/src/hotspot/share/runtime/handles.inline.hpp @@ -79,7 +79,6 @@ inline HandleMark::HandleMark() { initialize(Thread::current()); } - inline void HandleMark::push() { // This is intentionally a NOP. pop_and_restore will reset // values to the HandleMark further down the stack, typically @@ -88,22 +87,18 @@ inline void HandleMark::push() { } inline void HandleMark::pop_and_restore() { - HandleArea* area = _area; // help compilers with poor alias analysis // Delete later chunks - if( _chunk->next() ) { - // reset arena size before delete chunks. Otherwise, the total - // arena size could exceed total chunk size - assert(area->size_in_bytes() > size_in_bytes(), "Sanity check"); - area->set_size_in_bytes(size_in_bytes()); - _chunk->next_chop(); + if(_chunk->next() != NULL) { + assert(_area->size_in_bytes() > size_in_bytes(), "Sanity check"); + chop_later_chunks(); } else { - assert(area->size_in_bytes() == size_in_bytes(), "Sanity check"); + assert(_area->size_in_bytes() == size_in_bytes(), "Sanity check"); } // Roll back arena to saved top markers - area->_chunk = _chunk; - area->_hwm = _hwm; - area->_max = _max; - debug_only(area->_handle_mark_nesting--); + _area->_chunk = _chunk; + _area->_hwm = _hwm; + _area->_max = _max; + debug_only(_area->_handle_mark_nesting--); } inline HandleMarkCleaner::HandleMarkCleaner(Thread* thread) { From 80473f3e12cbe2093a3c661e553aab148d105e38 Mon Sep 17 00:00:00 2001 From: Leo Jiang Date: Thu, 7 Feb 2019 01:49:10 -0800 Subject: [PATCH 004/101] 8218411: JDK 12 L10n resource file update msg drop 20 Reviewed-by: naoto --- .../com/sun/tools/javac/resources/javac_ja.properties | 6 +++--- .../com/sun/tools/javac/resources/javac_zh_CN.properties | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_ja.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_ja.properties index e60f62e9c75..f44b40fa3a2 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_ja.properties +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_ja.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 2019, 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 @@ -53,7 +53,7 @@ javac.opt.J=\u3092\u5B9F\u884C\u30B7\u30B9\u30C6\u30E0\u306B\u76F4\u63A5\u javac.opt.encoding=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u4F7F\u7528\u3059\u308B\u6587\u5B57\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u3092\u6307\u5B9A\u3059\u308B javac.opt.profile=\u4F7F\u7528\u3055\u308C\u3066\u3044\u308BAPI\u304C\u6307\u5B9A\u3057\u305F\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u3067\u4F7F\u7528\u53EF\u80FD\u304B\u3069\u3046\u304B\u3092\u78BA\u8A8D\u3057\u307E\u3059 javac.opt.target=\u7279\u5B9A\u306EVM\u30D0\u30FC\u30B8\u30E7\u30F3\u7528\u306E\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u751F\u6210\u3057\u307E\u3059\u3002\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u308B\u30D0\u30FC\u30B8\u30E7\u30F3: {0} -javac.opt.release=\u7279\u5B9A\u306E\u30EA\u30EA\u30FC\u30B9\u7528\u306B\u306B\u30B3\u30F3\u30D1\u30A4\u30EB\u3057\u307E\u3059\u3002\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u308B\u30EA\u30EA\u30FC\u30B9: {0} +javac.opt.release=\u7279\u5B9A\u306E\u30EA\u30EA\u30FC\u30B9\u7528\u306B\u30B3\u30F3\u30D1\u30A4\u30EB\u3057\u307E\u3059\u3002\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u308B\u30EA\u30EA\u30FC\u30B9: {0} javac.opt.source=\u6307\u5B9A\u3055\u308C\u305F\u30EA\u30EA\u30FC\u30B9\u3068\u30BD\u30FC\u30B9\u306E\u4E92\u63DB\u6027\u3092\u4FDD\u6301\u3057\u307E\u3059\u3002\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u308B\u30EA\u30EA\u30FC\u30B9: {0} javac.opt.Werror=\u8B66\u544A\u304C\u767A\u751F\u3057\u305F\u5834\u5408\u306B\u30B3\u30F3\u30D1\u30A4\u30EB\u3092\u7D42\u4E86\u3059\u308B javac.opt.A=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306B\u6E21\u3055\u308C\u308B\u30AA\u30D7\u30B7\u30E7\u30F3 @@ -66,7 +66,7 @@ javac.opt.arg.flag= javac.opt.arg.key.equals.value=key[=value] javac.opt.arg.path= javac.opt.arg.mspath= -javac.opt.arg.m= +javac.opt.arg.m=(,)* javac.opt.arg.jdk=|none javac.opt.arg.dirs= javac.opt.arg.directory= diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties index fedf94cae68..d88a59b0027 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 2019, 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 @@ -34,7 +34,7 @@ javac.opt.deprecation=\u8F93\u51FA\u4F7F\u7528\u5DF2\u8FC7\u65F6\u7684 API \u768 javac.opt.classpath=\u6307\u5B9A\u67E5\u627E\u7528\u6237\u7C7B\u6587\u4EF6\u548C\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u7684\u4F4D\u7F6E javac.opt.modulepath=\u6307\u5B9A\u67E5\u627E\u5E94\u7528\u7A0B\u5E8F\u6A21\u5757\u7684\u4F4D\u7F6E javac.opt.sourcepath=\u6307\u5B9A\u67E5\u627E\u8F93\u5165\u6E90\u6587\u4EF6\u7684\u4F4D\u7F6E -javac.opt.m=\u53EA\u7F16\u8BD1\u6307\u5B9A\u7684\u6A21\u5757, \u8BF7\u68C0\u67E5\u65F6\u95F4\u6233 +javac.opt.m=\u53EA\u7F16\u8BD1\u6307\u5B9A\u7684\u6A21\u5757\uFF0C\u8BF7\u68C0\u67E5\u65F6\u95F4\u6233 javac.opt.modulesourcepath=\u6307\u5B9A\u67E5\u627E\u591A\u4E2A\u6A21\u5757\u7684\u8F93\u5165\u6E90\u6587\u4EF6\u7684\u4F4D\u7F6E javac.opt.bootclasspath=\u8986\u76D6\u5F15\u5BFC\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E javac.opt.system=\u8986\u76D6\u7CFB\u7EDF\u6A21\u5757\u4F4D\u7F6E @@ -66,7 +66,7 @@ javac.opt.arg.flag= javac.opt.arg.key.equals.value=key[=value] javac.opt.arg.path= javac.opt.arg.mspath= -javac.opt.arg.m= +javac.opt.arg.m=<\u6A21\u5757>(,<\u6A21\u5757>)* javac.opt.arg.jdk=|none javac.opt.arg.dirs= javac.opt.arg.directory= From 208c58c8621247023e39c98a7b81638c62daedec Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Thu, 7 Feb 2019 12:35:45 +0100 Subject: [PATCH 005/101] 8218431: Improved platform checking in makefiles Reviewed-by: erikj --- make/Bundles.gmk | 6 +- make/CompileDemos.gmk | 2 +- make/CompileJavaModules.gmk | 20 ++-- make/CopyImportModules.gmk | 2 +- make/CreateJmods.gmk | 2 +- make/Images.gmk | 6 +- make/InitSupport.gmk | 2 +- make/MacBundles.gmk | 2 +- make/Main.gmk | 2 +- make/ModuleWrapper.gmk | 2 +- make/RunTests.gmk | 8 +- make/TestImage.gmk | 2 +- make/ZipSecurity.gmk | 4 +- make/common/MakeBase.gmk | 6 +- make/common/Modules.gmk | 4 +- make/common/NativeCompilation.gmk | 22 ++--- make/common/Utils.gmk | 61 ++++++++++++ make/copy/Copy-java.base.gmk | 10 +- make/copy/Copy-jdk.crypto.cryptoki.gmk | 2 +- make/copy/Copy-jdk.crypto.ucrypto.gmk | 2 +- make/gensrc/Gensrc-java.desktop.gmk | 10 +- make/gensrc/Gensrc-jdk.hotspot.agent.gmk | 2 +- make/gensrc/GensrcIcons.gmk | 2 +- make/gensrc/GensrcMisc.gmk | 4 +- make/hotspot/CopyToExplodedJdk.gmk | 2 +- make/hotspot/gensrc/GensrcAdlc.gmk | 20 ++-- make/hotspot/gensrc/GensrcDtrace.gmk | 8 +- make/hotspot/ide/CreateVSProject.gmk | 6 +- make/hotspot/lib/CompileDtraceLibraries.gmk | 2 +- make/hotspot/lib/CompileGtest.gmk | 4 +- make/hotspot/lib/CompileJvm.gmk | 28 +++--- make/hotspot/lib/JvmDtraceObjects.gmk | 4 +- make/hotspot/lib/JvmFeatures.gmk | 4 +- make/hotspot/lib/JvmFlags.gmk | 2 +- make/hotspot/lib/JvmMapfile.gmk | 20 ++-- make/hotspot/lib/JvmOverrideFiles.gmk | 16 ++-- make/hotspot/test/GtestImage.gmk | 4 +- make/launcher/Launcher-java.base.gmk | 6 +- make/launcher/Launcher-java.security.jgss.gmk | 2 +- make/launcher/Launcher-jdk.accessibility.gmk | 4 +- make/launcher/Launcher-jdk.pack.gmk | 2 +- make/launcher/LauncherCommon.gmk | 8 +- make/lib/Awt2dLibraries.gmk | 96 +++++++++---------- make/lib/CoreLibraries.gmk | 12 +-- make/lib/Lib-java.base.gmk | 6 +- make/lib/Lib-java.desktop.gmk | 9 +- make/lib/Lib-java.instrument.gmk | 4 +- make/lib/Lib-java.management.gmk | 3 +- make/lib/Lib-java.prefs.gmk | 2 +- make/lib/Lib-java.security.jgss.gmk | 4 +- make/lib/Lib-jdk.accessibility.gmk | 4 +- make/lib/Lib-jdk.attach.gmk | 2 +- make/lib/Lib-jdk.crypto.mscapi.gmk | 2 +- make/lib/Lib-jdk.crypto.ucrypto.gmk | 2 +- make/lib/Lib-jdk.hotspot.agent.gmk | 10 +- make/lib/Lib-jdk.internal.le.gmk | 4 +- make/lib/Lib-jdk.jdi.gmk | 4 +- make/lib/Lib-jdk.management.gmk | 5 +- make/lib/Lib-jdk.net.gmk | 2 +- make/lib/Lib-jdk.sctp.gmk | 4 +- make/test/BuildFailureHandler.gmk | 4 +- make/test/JtregNativeHotspot.gmk | 10 +- make/test/JtregNativeJdk.gmk | 8 +- test/make/TestMakeBase.gmk | 22 +++++ test/make/UtilsForTests.gmk | 2 +- 65 files changed, 312 insertions(+), 236 deletions(-) diff --git a/make/Bundles.gmk b/make/Bundles.gmk index 891681588d3..5ccace6a6d1 100644 --- a/make/Bundles.gmk +++ b/make/Bundles.gmk @@ -35,7 +35,7 @@ DOCS_TARGETS := # On Windows tar frequently complains that "file changed as we read it" for # some random source files. This seems to be cause by anti virus scanners and # is most likely safe to ignore. When it happens, tar returns '1'. -ifeq ($(OPENJDK_BUILD_OS), windows) +ifeq ($(call isBuildOs, windows), true) TAR_IGNORE_EXIT_VALUE := || test "$$$$?" = "1" endif @@ -144,7 +144,7 @@ endef # On Macosx, we bundle up the macosx specific images which already have the # correct base directories. -ifeq ($(OPENJDK_TARGET_OS)-$(DEBUG_LEVEL), macosx-release) +ifeq ($(call isTargetOs, macosx)+$(DEBUG_LEVEL), true+release) JDK_IMAGE_DIR := $(JDK_MACOSX_BUNDLE_DIR) JDK_IMAGE_HOMEDIR := $(JDK_MACOSX_CONTENTS_DIR)/Home JDK_BUNDLE_SUBDIR := @@ -167,7 +167,7 @@ ifneq ($(filter product-bundles, $(MAKECMDGOALS)), ) # Create special filter rules when dealing with unzipped .dSYM directories on # macosx - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), false) JDK_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \ $(call containing, .dSYM/, $(patsubst $(JDK_IMAGE_DIR)/%, %, $(ALL_JDK_FILES)))) diff --git a/make/CompileDemos.gmk b/make/CompileDemos.gmk index c80bfb8f994..18f8593ce81 100644 --- a/make/CompileDemos.gmk +++ b/make/CompileDemos.gmk @@ -234,7 +234,7 @@ $(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%: $(DEMO_SHARE_SRC)/nbproject/% $(call install-file) $(CHMOD) -f ug+w $@ -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) TARGETS += $(patsubst $(DEMO_SHARE_SRC)/nbproject/%, \ $(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%, \ $(call CacheFind, $(DEMO_SHARE_SRC)/nbproject)) diff --git a/make/CompileJavaModules.gmk b/make/CompileJavaModules.gmk index 3f19e7d242d..14653e668c0 100644 --- a/make/CompileJavaModules.gmk +++ b/make/CompileJavaModules.gmk @@ -51,21 +51,18 @@ java.base_EXCLUDES += java/lang/doc-files # data files and shouldn't go in the product java.base_EXCLUDE_FILES += sun/text/resources/BreakIteratorRules.java -ifneq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), false) java.base_EXCLUDE_FILES += \ SolarisLoginModule.java \ SolarisSystem.java \ # endif -ifeq ($(filter $(OPENJDK_TARGET_OS), solaris macosx aix), ) - # - # only solaris, macosx and aix - # +ifeq ($(call isTargetOs, solaris macosx aix), false) java.base_EXCLUDE_FILES += sun/nio/fs/PollingWatchService.java endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) java.base_EXCLUDE_FILES += \ sun/nio/ch/SimpleAsynchronousFileChannelImpl.java \ # @@ -124,7 +121,7 @@ java.desktop_EXCLUDE_FILES += \ .template \ # -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) # exclude all X11 on Mac. java.desktop_EXCLUDES += \ sun/awt/X11 \ @@ -186,7 +183,7 @@ else sun/awt/X11/XwcTextItem.java endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) java.desktop_EXCLUDES += com/sun/java/swing/plaf/gtk endif @@ -194,8 +191,7 @@ ifdef BUILD_HEADLESS_ONLY java.desktop_EXCLUDES += sun/applet endif -# Used on windows and macosx -ifeq ($(filter $(OPENJDK_TARGET_OS), windows macosx), ) +ifeq ($(call isTargetOs, windows macosx), false) java.desktop_EXCLUDE_FILES += sun/awt/AWTCharset.java endif @@ -374,11 +370,11 @@ SCTP_IMPL_CLASSES = \ $(TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SendFailed.java \ $(TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/Shutdown.java -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) jdk.sctp_EXCLUDE_FILES += $(SCTP_IMPL_CLASSES) endif -ifeq ($(OPENJDK_TARGET_OS),aix) +ifeq ($(call isTargetOs, aix), true) jdk.sctp_EXCLUDE_FILES += $(SCTP_IMPL_CLASSES) endif diff --git a/make/CopyImportModules.gmk b/make/CopyImportModules.gmk index 3ea6a134c87..9742e91fa78 100644 --- a/make/CopyImportModules.gmk +++ b/make/CopyImportModules.gmk @@ -38,7 +38,7 @@ CONF_DIR := $(wildcard $(addsuffix /$(MODULE), $(IMPORT_MODULES_CONF))) $(eval $(call FillCacheFind, $(LIBS_DIR) $(CMDS_DIR) $(CONF_DIR))) ifneq ($(LIBS_DIR), ) - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) TO_BIN_FILTER := %$(SHARED_LIBRARY_SUFFIX) %.diz %.pdb %.map $(eval $(call SetupCopyFiles, COPY_LIBS_TO_BIN, \ diff --git a/make/CreateJmods.gmk b/make/CreateJmods.gmk index 1e391c3f4e5..4d643ce1d9d 100644 --- a/make/CreateJmods.gmk +++ b/make/CreateJmods.gmk @@ -118,7 +118,7 @@ ifeq ($(MODULE), java.base) endif endif else # not java.base - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) # Only java.base needs to include the MSVC*_DLLs. Make sure no other module # tries to include them (typically imported ones). ifneq ($(MSVCR_DLL), ) diff --git a/make/Images.gmk b/make/Images.gmk index a0d3599ceaf..22b634a1fe0 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -144,7 +144,7 @@ ifneq ($(filter jdk, $(MAKECMDGOALS)), ) ) ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true) - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) DEMO_FILES := $(call not-containing, .dSYM, $(DEMO_FILES)) else DEMO_FILES := $(filter-out %.debuginfo %.pdb %.map, $(DEMO_FILES)) @@ -192,7 +192,7 @@ ALL_JDK_MODULES := $(JDK_MODULES) ALL_JRE_MODULES := $(sort $(JRE_MODULES), $(foreach m, $(JRE_MODULES), \ $(call FindTransitiveDepsForModule, $m))) -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) LIBS_TARGET_SUBDIR := bin else LIBS_TARGET_SUBDIR := lib @@ -211,7 +211,7 @@ else DEBUGINFO_SUFFIXES := .debuginfo .pdb .map # On Macosx, if debug symbols have not been zipped, find all files inside *.dSYM # dirs. - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) $(eval $(call FillCacheFind, \ $(SUPPORT_OUTPUTDIR)/modules_cmds $(SUPPORT_OUTPUTDIR)/modules_libs)) FindDebuginfoFiles = \ diff --git a/make/InitSupport.gmk b/make/InitSupport.gmk index f038476c071..8e157839c2e 100644 --- a/make/InitSupport.gmk +++ b/make/InitSupport.gmk @@ -483,7 +483,7 @@ else # $(HAS_SPEC)=true $(TOUCH) $(SJAVAC_SERVER_DIR)/server.port.stop; true endef - ifeq ($(OPENJDK_BUILD_OS), windows) + ifeq ($(call isBuildOs, windows), true) # On windows we need to synchronize with the javac server to be able to # move or remove the build output directory. Since we have no proper # synchronization process, wait for a while and hope it helps. This is only diff --git a/make/MacBundles.gmk b/make/MacBundles.gmk index 381de56654e..eff09eb84d9 100644 --- a/make/MacBundles.gmk +++ b/make/MacBundles.gmk @@ -30,7 +30,7 @@ include TextFileProcessing.gmk default: bundles # Only macosx has bundles defined. -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) bundles: jre-bundle jdk-bundle diff --git a/make/Main.gmk b/make/Main.gmk index 511b1020cb7..4cfcec5ef0e 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -1032,7 +1032,7 @@ ifneq ($(CREATE_BUILDJDK), true) endif endif -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) product-images: mac-jdk-bundle endif diff --git a/make/ModuleWrapper.gmk b/make/ModuleWrapper.gmk index f0291aa422d..929b11c33ad 100644 --- a/make/ModuleWrapper.gmk +++ b/make/ModuleWrapper.gmk @@ -42,7 +42,7 @@ TARGETS := include $(MAKEFILE_PREFIX)-$(MODULE).gmk # Setup copy rules from the modules directories to the jdk image directory. -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) TO_BIN_FILTER := %$(SHARED_LIBRARY_SUFFIX) %.diz %.pdb %.map $(eval $(call SetupCopyFiles, COPY_LIBS_TO_BIN, \ diff --git a/make/RunTests.gmk b/make/RunTests.gmk index 38a8d354ae0..37a21829947 100644 --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -61,7 +61,7 @@ define SetTestOpt endef # Setup _NT_SYMBOL_PATH on Windows -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) ifndef _NT_SYMBOL_PATH # Can't use PathList here as it adds quotes around the value. _NT_SYMBOL_PATH := \ @@ -224,7 +224,7 @@ TEST_JOBS_FACTOR_MACHINE ?= 1 ifeq ($(TEST_JOBS), 0) CORES_DIVIDER := 2 - ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc) + ifeq ($(call isTargetCpuArch, sparc), true) # For smaller SPARC machines we see reasonable scaling of throughput up to # cpus/4 without affecting test reliability. On the bigger machines, cpus/4 # causes intermittent timeouts. @@ -808,7 +808,7 @@ define SetupRunJtregTestBody $1_JTREG_MAX_RAM_PERCENTAGE := $$(shell $$(EXPR) 25 / $$($1_JTREG_JOBS)) # SPARC is in general slower per core so need to scale up timeouts a bit. - ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc) + ifeq ($(call isTargetCpuArch, sparc), true) JTREG_TIMEOUT_FACTOR ?= 8 else JTREG_TIMEOUT_FACTOR ?= 4 @@ -835,7 +835,7 @@ define SetupRunJtregTestBody $1_JTREG_BASIC_OPTIONS += -e:JDK8_HOME=$$(BOOT_JDK) # If running on Windows, propagate the _NT_SYMBOL_PATH to enable # symbol lookup in hserr files - ifeq ($$(OPENJDK_TARGET_OS), windows) + ifeq ($$(call isTargetOs, windows), true) $1_JTREG_BASIC_OPTIONS += -e:_NT_SYMBOL_PATH endif diff --git a/make/TestImage.gmk b/make/TestImage.gmk index 75595a7eddb..99e52490c0e 100644 --- a/make/TestImage.gmk +++ b/make/TestImage.gmk @@ -30,7 +30,7 @@ include MakeBase.gmk ############################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) FIXPATH_COPY := $(TEST_IMAGE_DIR)/bin/fixpath.exe $(FIXPATH_COPY): $(firstword $(FIXPATH)) diff --git a/make/ZipSecurity.gmk b/make/ZipSecurity.gmk index ba5664122ce..cbe1e216415 100644 --- a/make/ZipSecurity.gmk +++ b/make/ZipSecurity.gmk @@ -70,7 +70,7 @@ TARGETS += $(IMAGES_OUTPUTDIR)/sec-bin.zip # # Windows specific binary security packages. # -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) # sec-windows-bin.zip is used by builds where the corresponding sources are not available $(eval $(call SetupZipArchive,BUILD_SEC_WINDOWS_BIN_ZIP, \ SRC := $(JDK_OUTPUTDIR), \ @@ -80,7 +80,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) TARGETS += $(IMAGES_OUTPUTDIR)/sec-windows-bin.zip # JGSS files contain the native Kerberos library - ifeq ($(OPENJDK_TARGET_CPU), x86_64) + ifeq ($(call isTargetCpu, x86_64), true) JGSS_ZIP_NAME = jgss-windows-x64-bin.zip else JGSS_ZIP_NAME = jgss-windows-i586-bin.zip diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk index 3cae04f7724..201695600f3 100644 --- a/make/common/MakeBase.gmk +++ b/make/common/MakeBase.gmk @@ -258,7 +258,7 @@ MakeTargetDir = \ ################################################################################ # All install-file and related macros automatically call DecodeSpace when needed. -ifeq ($(OPENJDK_TARGET_OS),solaris) +ifeq ($(call isTargetOs, solaris), true) # On Solaris, if the target is a symlink and exists, cp won't overwrite. # Cp has to operate in recursive mode to allow for -P flag, to preserve soft links. If the # name of the target file differs from the source file, rename after copy. @@ -284,7 +284,7 @@ ifeq ($(OPENJDK_TARGET_OS),solaris) $(CP) -f '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'; \ fi endef -else ifeq ($(OPENJDK_TARGET_OS),macosx) +else ifeq ($(call isTargetOs, macosx), true) # On mac, extended attributes sometimes creep into the source files, which may later # cause the creation of ._* files which confuses testing. Clear these with xattr if # set. Some files get their write permissions removed after being copied to the @@ -418,7 +418,7 @@ endif # unchanged. # This is normally not needed since we use the FIXPATH prefix for command lines, # but might be needed in certain circumstances. -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) FixPath = \ $(shell $(CYGPATH) -m $1) else diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk index b2f67a4a50d..55a4e52861f 100644 --- a/make/common/Modules.gmk +++ b/make/common/Modules.gmk @@ -117,11 +117,11 @@ PLATFORM_MODULES += \ jdk.zipfs \ # -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) PLATFORM_MODULES += jdk.crypto.mscapi endif -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) PLATFORM_MODULES += jdk.crypto.ucrypto endif diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index 0c23e3cdc4d..937f7580fb5 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -175,9 +175,9 @@ $(strip \ ) endef -ifeq ($(OPENJDK_BUILD_OS_ENV), windows.cygwin) +ifeq ($(call isBuildOsEnv, windows.cygwin), true) UNIX_PATH_PREFIX := /cygdrive -else ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys) +else ifeq ($(call isBuildOsEnv, windows.msys), true) UNIX_PATH_PREFIX := endif @@ -770,7 +770,7 @@ define SetupNativeCompilationBody $(TOUCH) $$@ # On windows we need to create a resource file - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) ifneq ($$($1_VERSIONINFO_RESOURCE), ) $1_RES := $$($1_OBJECT_DIR)/$$($1_BASENAME).res $1_RES_DEP := $$($1_RES).d @@ -808,7 +808,7 @@ define SetupNativeCompilationBody ifneq ($(DISABLE_MAPFILES), true) $1_REAL_MAPFILE := $$($1_MAPFILE) - ifneq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), false) ifneq ($$($1_REORDER), ) $1_REAL_MAPFILE := $$($1_OBJECT_DIR)/mapfile @@ -845,13 +845,13 @@ define SetupNativeCompilationBody # Only copy debug symbols for dynamic libraries and programs. ifneq ($$($1_TYPE), STATIC_LIBRARY) # Generate debuginfo files. - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb" \ "-map:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map" $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb \ $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map - else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), ) + else ifeq ($(call isTargetOs, linux solaris), true) $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).debuginfo # Setup the command line creating debuginfo files, to be run after linking. # It cannot be run separately since it updates the original target file @@ -860,13 +860,13 @@ define SetupNativeCompilationBody $(CD) $$($1_OUTPUT_DIR) && \ $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET) - else ifeq ($(OPENJDK_TARGET_OS), macosx) + else ifeq ($(call isTargetOs, macosx), true) $1_DEBUGINFO_FILES := \ $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \ $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME) $1_CREATE_DEBUGINFO_CMDS := \ $(DSYMUTIL) --out $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET) - endif # OPENJDK_TARGET_OS + endif # Since the link rule creates more than one file that we want to track, # we have to use some tricks to get make to cooperate. To properly @@ -952,7 +952,7 @@ define SetupNativeCompilationBody endif endif - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) ifeq ($$($1_EMBED_MANIFEST), true) $1_EXTRA_LDFLAGS += -manifest:embed endif @@ -1032,7 +1032,7 @@ define SetupNativeCompilationBody # Keep as much as possible on one execution line for best performance # on Windows $$(call LogInfo, Linking $$($1_BASENAME)) - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \ @@ -1050,7 +1050,7 @@ define SetupNativeCompilationBody $$($1_CREATE_DEBUGINFO_CMDS) $$($1_STRIP_CMD) endif - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) ifneq ($$($1_MANIFEST), ) $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1 endif diff --git a/make/common/Utils.gmk b/make/common/Utils.gmk index 175489925c1..726101693a4 100644 --- a/make/common/Utils.gmk +++ b/make/common/Utils.gmk @@ -180,6 +180,23 @@ uppercase = \ $(uppercase_result) \ ) +################################################################################ +# Boolean operators. + +# Return the word "true" if all the boolean words given as argument is "true", +# and returns "false" otherwise. Boolean words must be "true" or "false". It is +# an error to supply a non-boolean word. An empty string is considered "true". +And = \ + $(strip $(if $(filter-out true false, $1), $(error Non-boolean values: $1)) \ + $(if $(strip $(filter-out true, $1)), false, true)) + +# Return the word "false" if all the boolean words given as argument is "false", +# and returns "true" otherwise. Boolean words must be "true" or "false". It is +# an error to supply a non-boolean word. An empty string is considered "false". +Or = \ + $(strip $(if $(filter-out true false, $1), $(error Non-boolean values: $1)) \ + $(if $(strip $(filter-out false, $1)), true, false)) + ################################################################################ # Parse a multiple-keyword variable, like FOO="KEYWORD1=val1;KEYWORD2=val2;..." # These will be converted into a series of variables like FOO_KEYWORD1=val1, @@ -268,6 +285,50 @@ check-jvm-variant = \ $(error Internal error: Invalid variant tested: $1)) \ $(if $(filter $1, $(JVM_VARIANTS)), true, false)) +################################################################################ +# Check if our build or target conforms to certain restrictions. This set of +# functions all work in similar ways, testing the property that the name +# implies, so e.g. isTargetCpu test the CPU of the target system. +# +# $1 - A property, or a space separated list of properties to test for. +# +# Returns true if the actual property matches one of the properties in the list, +# and false otherwise. +# +# Examples: $(call isTargetOs, linux solaris) will return true when executed +# on either linux or solaris, and false otherwise. +# $(call isBuildCpuArch, x86) will return true iff the build CPU Arch is x86. + +isTargetOs = \ + $(strip $(if $(filter $(OPENJDK_TARGET_OS), $1), true, false)) + +isTargetOsType = \ + $(strip $(if $(filter $(OPENJDK_TARGET_OS_TYPE), $1), true, false)) + +isTargetCpu = \ + $(strip $(if $(filter $(OPENJDK_TARGET_CPU), $1), true, false)) + +isTargetCpuArch = \ + $(strip $(if $(filter $(OPENJDK_TARGET_CPU_ARCH), $1), true, false)) + +isTargetCpuBits = \ + $(strip $(if $(filter $(OPENJDK_TARGET_CPU_BITS), $1), true, false)) + +isBuildOs = \ + $(strip $(if $(filter $(OPENJDK_BUILD_OS), $1), true, false)) + +isBuildOsType = \ + $(strip $(if $(filter $(OPENJDK_BUILD_OS_TYPE), $1), true, false)) + +isBuildOsEnv = \ + $(strip $(if $(filter $(OPENJDK_BUILD_OS_ENV), $1), true, false)) + +isBuildCpu = \ + $(strip $(if $(filter $(OPENJDK_BUILD_CPU), $1), true, false)) + +isBuildCpuArch = \ + $(strip $(if $(filter $(OPENJDK_BUILD_CPU_ARCH), $1), true, false)) + ################################################################################ # Converts a space separated list to a comma separated list. # diff --git a/make/copy/Copy-java.base.gmk b/make/copy/Copy-java.base.gmk index 800ec0d846f..8afed3162b0 100644 --- a/make/copy/Copy-java.base.gmk +++ b/make/copy/Copy-java.base.gmk @@ -31,7 +31,7 @@ $(eval $(call IncludeCustomExtension, copy/Copy-java.base.gmk)) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), aix) +ifeq ($(call isTargetOs, aix), true) TZMAPPINGS_SRC := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/conf @@ -44,7 +44,7 @@ endif ################################################################################ # Copy the microsoft runtime libraries on windows -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) # Chmod to avoid permission issues if bundles are unpacked on unix platforms. define copy-and-chmod @@ -81,7 +81,7 @@ endif ################################################################################ # In jvm.cfg, the first listed KNOWN variant is the default. On most build # configurations, that is the server variant. -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), windows-x86) +ifeq ($(call And, $(call isTargetOs, windows) $(call isTargetCpu, x86)), true) DEFAULT_CFG_VARIANT ?= client endif DEFAULT_CFG_VARIANT ?= server @@ -143,7 +143,7 @@ DEF_POLICY_DST := $(LIB_DST_DIR)/security/default.policy DEF_POLICY_SRC_LIST := $(DEF_POLICY_SRC) DEF_POLICY_SRC_LIST += $(CUSTOM_POLICY_SRC_LIST) -ifneq ($(filter $(OPENJDK_TARGET_OS), windows solaris), ) +ifeq ($(call isTargetOs, windows solaris), true) DEF_POLICY_SRC_LIST += $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/lib/security/default.policy endif @@ -183,7 +183,7 @@ $(eval $(call SetupCopyFiles, COPY_NET_PROPERTIES, \ TARGETS += $(COPY_NET_PROPERTIES) -ifneq ($(filter $(OPENJDK_TARGET_OS), solaris linux), ) +ifeq ($(call isTargetOs, solaris linux), true) $(eval $(call SetupCopyFiles, COPY_SDP_CONF, \ FILES := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/sdp/sdp.conf.template, \ DEST := $(CONF_DST_DIR)/sdp, \ diff --git a/make/copy/Copy-jdk.crypto.cryptoki.gmk b/make/copy/Copy-jdk.crypto.cryptoki.gmk index 7965c568545..f5d1632e7cb 100644 --- a/make/copy/Copy-jdk.crypto.cryptoki.gmk +++ b/make/copy/Copy-jdk.crypto.cryptoki.gmk @@ -27,7 +27,7 @@ include CopyCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) SUNPKCS11_CFG_SRC := \ $(TOPDIR)/src/jdk.crypto.cryptoki/solaris/conf/security/sunpkcs11-solaris.cfg diff --git a/make/copy/Copy-jdk.crypto.ucrypto.gmk b/make/copy/Copy-jdk.crypto.ucrypto.gmk index 0007e4471ba..a9320e834ce 100644 --- a/make/copy/Copy-jdk.crypto.ucrypto.gmk +++ b/make/copy/Copy-jdk.crypto.ucrypto.gmk @@ -27,7 +27,7 @@ include CopyCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) UCRYPTO_CFG_SRC := $(TOPDIR)/src/jdk.crypto.ucrypto/solaris/conf/security/ucrypto-solaris.cfg UCRYPTO_CFG_DST := $(CONF_DST_DIR)/security/ucrypto-solaris.cfg diff --git a/make/gensrc/Gensrc-java.desktop.gmk b/make/gensrc/Gensrc-java.desktop.gmk index aca529c8134..af5ed4fe7a5 100644 --- a/make/gensrc/Gensrc-java.desktop.gmk +++ b/make/gensrc/Gensrc-java.desktop.gmk @@ -28,11 +28,11 @@ include GensrcCommonJdk.gmk # Hook to include the corresponding custom file, if present. $(eval $(call IncludeCustomExtension, gensrc/Gensrc-java.desktop.gmk)) -ifneq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), false) include GensrcIcons.gmk endif -ifneq ($(filter $(OPENJDK_TARGET_OS), linux solaris aix), ) +ifeq ($(call isTargetOs, linux solaris aix), true) include GensrcX11Wrappers.gmk endif @@ -52,21 +52,21 @@ PROP_SRC_DIRS := \ $(TOPDIR)/src/java.desktop/share/classes/sun/print/resources \ # -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) PROP_SRC_DIRS += \ $(TOPDIR)/src/java.desktop/macosx/classes/com/apple/laf/resources \ $(TOPDIR)/src/java.desktop/macosx/classes/sun/awt/resources \ # endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) PROP_SRC_DIRS += \ $(TOPDIR)/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/resources \ $(TOPDIR)/src/java.desktop/windows/classes/sun/awt/windows \ # endif -ifeq ($(filter $(OPENJDK_TARGET_OS), windows macosx), ) +ifeq ($(call isTargetOs, windows macosx), false) PROP_SRC_DIRS += $(TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/resources endif diff --git a/make/gensrc/Gensrc-jdk.hotspot.agent.gmk b/make/gensrc/Gensrc-jdk.hotspot.agent.gmk index a368a5c109a..6345f12ebb4 100644 --- a/make/gensrc/Gensrc-jdk.hotspot.agent.gmk +++ b/make/gensrc/Gensrc-jdk.hotspot.agent.gmk @@ -42,7 +42,7 @@ TARGETS += $(SA_PROPERTIES) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) MIG_OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent MACH_EXC_HEADER := $(MIG_OUTPUT_DIR)/mach_exc.h MACH_EXC_USER := $(MIG_OUTPUT_DIR)/mach_excUser.c diff --git a/make/gensrc/GensrcIcons.gmk b/make/gensrc/GensrcIcons.gmk index de04286e62d..d036618f610 100644 --- a/make/gensrc/GensrcIcons.gmk +++ b/make/gensrc/GensrcIcons.gmk @@ -108,7 +108,7 @@ GENSRC_JAVA_DESKTOP += $(GENSRC_AWT_ICONS) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) GENSRC_OSX_ICONS_DST := $(SUPPORT_OUTPUTDIR)/headers/java.desktop GENSRC_OSX_ICONS := $(GENSRC_OSX_ICONS_DST)/AWTIconData.h diff --git a/make/gensrc/GensrcMisc.gmk b/make/gensrc/GensrcMisc.gmk index 3c54753c93e..27682d12437 100644 --- a/make/gensrc/GensrcMisc.gmk +++ b/make/gensrc/GensrcMisc.gmk @@ -89,7 +89,7 @@ GENSRC_JAVA_BASE += $(GENSRC_SOR_FILE) ################################################################################ -ifneq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), false) GENSRC_UC_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/fs/UnixConstants.java @@ -103,7 +103,7 @@ endif ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) GENSRC_SC_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/fs/SolarisConstants.java diff --git a/make/hotspot/CopyToExplodedJdk.gmk b/make/hotspot/CopyToExplodedJdk.gmk index eee2d0cd81e..2413dfcefef 100644 --- a/make/hotspot/CopyToExplodedJdk.gmk +++ b/make/hotspot/CopyToExplodedJdk.gmk @@ -25,7 +25,7 @@ # Copy all built libraries into exploded jdk LIB_TARGETS := $(filter $(LIB_OUTPUTDIR)/%, $(TARGETS)) -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupCopyFiles, COPY_LIBS_BIN, \ SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \ DEST := $(JDK_OUTPUTDIR)/bin, \ diff --git a/make/hotspot/gensrc/GensrcAdlc.gmk b/make/hotspot/gensrc/GensrcAdlc.gmk index bbdfc38ca4f..deb59966032 100644 --- a/make/hotspot/gensrc/GensrcAdlc.gmk +++ b/make/hotspot/gensrc/GensrcAdlc.gmk @@ -34,16 +34,16 @@ ifeq ($(call check-jvm-feature, compiler2), true) # Flags depending on the build platform/tool chain # NOTE: No optimization or debug flags set here - ifeq ($(OPENJDK_BUILD_OS), linux) + ifeq ($(call isBuildOs, linux), true) ADLC_CFLAGS := -fno-exceptions -DLINUX - else ifeq ($(OPENJDK_BUILD_OS), solaris) + else ifeq ($(call isBuildOs, solaris), true) ADLC_LDFLAGS := -m64 ADLC_CFLAGS := -m64 ADLC_CFLAGS_WARNINGS := +w - else ifeq ($(OPENJDK_BUILD_OS), aix) + else ifeq ($(call isBuildOs, aix), true) ADLC_LDFLAGS := -q64 ADLC_CFLAGS := -qnortti -qeh -q64 -DAIX - else ifeq ($(OPENJDK_BUILD_OS), windows) + else ifeq ($(call isBuildOs, windows), true) ADLC_LDFLAGS := -nologo ADLC_CFLAGS := -nologo -EHsc # NOTE: The old build also have -D_CRT_SECURE_NO_DEPRECATE but it doesn't @@ -87,17 +87,17 @@ ifeq ($(call check-jvm-feature, compiler2), true) ADLCFLAGS += -q -T # ADLC flags depending on target OS - ifeq ($(OPENJDK_TARGET_OS), linux) + ifeq ($(call isTargetOs, linux), true) ADLCFLAGS += -DLINUX=1 -D_GNU_SOURCE=1 - else ifeq ($(OPENJDK_TARGET_OS), solaris) + else ifeq ($(call isTargetOs, solaris), true) ADLCFLAGS += -DSOLARIS=1 -DSPARC_WORKS=1 - else ifeq ($(OPENJDK_TARGET_OS), aix) + else ifeq ($(call isTargetOs, aix), true) ADLCFLAGS += -DAIX=1 - else ifeq ($(OPENJDK_TARGET_OS), macosx) + else ifeq ($(call isTargetOs, macosx), true) ADLCFLAGS += -D_ALLBSD_SOURCE=1 -D_GNU_SOURCE=1 endif - ifneq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), false) # NOTE: Windows adlc flags was different in the old build. Is this really # correct? @@ -109,7 +109,7 @@ ifeq ($(call check-jvm-feature, compiler2), true) # This generates checks in the generated C++ files that _LP64 is correctly # (un)defined when compiling them. - ifeq ($(OPENJDK_TARGET_CPU_BITS), 64) + ifeq ($(call isTargetCpuBits, 64), true) ADLCFLAGS += -D_LP64=1 else ADLCFLAGS += -U_LP64 diff --git a/make/hotspot/gensrc/GensrcDtrace.gmk b/make/hotspot/gensrc/GensrcDtrace.gmk index 71036284087..b25cfd462ae 100644 --- a/make/hotspot/gensrc/GensrcDtrace.gmk +++ b/make/hotspot/gensrc/GensrcDtrace.gmk @@ -28,12 +28,12 @@ ifeq ($(call check-jvm-feature, dtrace), true) - ifeq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), true) DTRACE_FLAGS := -64 DTRACE_CPP_FLAGS := -D_LP64 - else ifeq ($(OPENJDK_TARGET_OS), macosx) + else ifeq ($(call isTargetOs, macosx), true) DTRACE_CPP_FLAGS := -D_LP64 -x c - else ifeq ($(OPENJDK_TARGET_OS), linux) + else ifeq ($(call isTargetOs, linux), true) DTRACE_CPP_FLAGS := -x c endif @@ -54,7 +54,7 @@ ifeq ($(call check-jvm-feature, dtrace), true) TARGETS += $(patsubst $(DTRACE_SOURCE_DIR)/%.d, \ $(DTRACE_GENSRC_DIR)/%.h, $(wildcard $(DTRACE_SOURCE_DIR)/*.d)) - ifeq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), true) ############################################################################ # First we need to generate the dtraceGenOffsets tool. When run, this will # produce two header files and a C++ file. Note that generateJvmOffsets.cpp diff --git a/make/hotspot/ide/CreateVSProject.gmk b/make/hotspot/ide/CreateVSProject.gmk index 55188b95c1f..5b0c59754e4 100644 --- a/make/hotspot/ide/CreateVSProject.gmk +++ b/make/hotspot/ide/CreateVSProject.gmk @@ -31,7 +31,7 @@ include MakeBase.gmk include JavaCompilation.gmk include SetupJavaCompilers.gmk -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) # The next part is a bit hacky. We include the CompileJvm.gmk to be # able to extact flags, but we do not wish to execute the rules. @@ -46,12 +46,12 @@ ifeq ($(OPENJDK_TARGET_OS), windows) # Helper macro to convert a unix path to a Windows path, suitable for # inclusion in a command line. - ifeq ($(OPENJDK_BUILD_OS_ENV), windows.cygwin) + ifeq ($(call isBuildOsEnv, windows.cygwin), true) FixPath = \ $(strip $(subst \,\\,$(shell $(CYGPATH) -w $1))) FixLinuxExecutable = \ $(call FixPath, $1) - else ifeq ($(OPENJDK_BUILD_OS_ENV), windows.wsl) + else ifeq ($(call isBuildOsEnv, windows.wsl), true) FixPath = \ $(strip $(subst \,\\,$(shell $(WSLPATH) -w $1))) FixLinuxExecutable = \ diff --git a/make/hotspot/lib/CompileDtraceLibraries.gmk b/make/hotspot/lib/CompileDtraceLibraries.gmk index 185b64053ae..1ec7979129d 100644 --- a/make/hotspot/lib/CompileDtraceLibraries.gmk +++ b/make/hotspot/lib/CompileDtraceLibraries.gmk @@ -24,7 +24,7 @@ # ifeq ($(call check-jvm-feature, dtrace), true) - ifeq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), true) JNI_INCLUDE_FLAGS := \ -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base \ -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base/$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \ diff --git a/make/hotspot/lib/CompileGtest.gmk b/make/hotspot/lib/CompileGtest.gmk index 8e61c45c7c3..69167935b1b 100644 --- a/make/hotspot/lib/CompileGtest.gmk +++ b/make/hotspot/lib/CompileGtest.gmk @@ -31,7 +31,7 @@ GTEST_FRAMEWORK_SRC := $(TOPDIR)/test/fmw/gtest # On Windows, there are no internal debug symbols so must set copying to true # to get any at all. -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) GTEST_COPY_DEBUG_SYMBOLS := true else GTEST_COPY_DEBUG_SYMBOLS := false @@ -39,7 +39,7 @@ endif ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) GTEST_JVM_MAPFILE := $(JVM_MAPFILE) else GTEST_JVM_MAPFILE := $(JVM_OUTPUTDIR)/gtest/mapfile diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk index 01f4e6219c9..543cf4455dc 100644 --- a/make/hotspot/lib/CompileJvm.gmk +++ b/make/hotspot/lib/CompileJvm.gmk @@ -56,9 +56,9 @@ JVM_EXCLUDE_FILES += args.cc JVM_EXCLUDES += adlc # Needed by vm_version.cpp -ifeq ($(OPENJDK_TARGET_CPU), x86_64) +ifeq ($(call isTargetCpu, x86_64), true) OPENJDK_TARGET_CPU_VM_VERSION := amd64 -else ifeq ($(OPENJDK_TARGET_CPU), sparcv9) +else ifeq ($(call isTargetCpu, sparcv9), true) OPENJDK_TARGET_CPU_VM_VERSION := sparc else OPENJDK_TARGET_CPU_VM_VERSION := $(OPENJDK_TARGET_CPU) @@ -107,10 +107,10 @@ DISABLED_WARNINGS_microsoft := # ARM source selection -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), linux-arm) +ifeq ($(call And, $(call isTargetOs, linux) $(call isTargetCpu, arm)), true) JVM_EXCLUDE_PATTERNS += arm_64 -else ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), linux-aarch64) +else ifeq ($(call And, $(call isTargetOs, linux) $(call isTargetCpu, aarch64)), true) # For 64-bit arm builds, we use the 64 bit hotspot/src/cpu/arm # hotspot sources if HOTSPOT_TARGET_CPU_ARCH is set to arm. # Exclude the aarch64 and 32 bit arm files for this build. @@ -119,21 +119,21 @@ else ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), linux-aarch64) endif endif -ifneq ($(filter $(OPENJDK_TARGET_OS), linux macosx windows), ) +ifeq ($(call isTargetOs, linux macosx windows), true) JVM_PRECOMPILED_HEADER := $(TOPDIR)/src/hotspot/share/precompiled/precompiled.hpp endif -ifeq ($(OPENJDK_TARGET_CPU), x86) +ifeq ($(call isTargetCpu, x86), true) JVM_EXCLUDE_PATTERNS += x86_64 -else ifeq ($(OPENJDK_TARGET_CPU), x86_64) +else ifeq ($(call isTargetCpu, x86_64), true) JVM_EXCLUDE_PATTERNS += x86_32 endif # Inline assembly for solaris -ifeq ($(OPENJDK_TARGET_OS), solaris) - ifeq ($(OPENJDK_TARGET_CPU), x86_64) +ifeq ($(call isTargetOs, solaris), true) + ifeq ($(call isTargetCpu, x86_64), true) JVM_CFLAGS += $(TOPDIR)/src/hotspot/os_cpu/solaris_x86/solaris_x86_64.il - else ifeq ($(OPENJDK_TARGET_CPU), sparcv9) + else ifeq ($(call isTargetCpu, sparcv9), true) JVM_CFLAGS += $(TOPDIR)/src/hotspot/os_cpu/solaris_sparc/solaris_sparc.il endif # Exclude warnings in devstudio 12.6 @@ -143,7 +143,7 @@ ifeq ($(OPENJDK_TARGET_OS), solaris) endif endif -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-sparcv9) +ifeq ($(call And, $(call isTargetOs, solaris) $(call isTargetCpu, sparcv9)), true) ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), false) # NOTE: In the old build, we weirdly enough set -g/-g0 always, regardless # of if debug symbols were needed. Without it, compilation fails on @@ -152,8 +152,8 @@ ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-sparcv9) endif endif -ifeq ($(OPENJDK_TARGET_OS), windows) - ifeq ($(OPENJDK_TARGET_CPU_BITS), 64) +ifeq ($(call isTargetOs, windows), true) + ifeq ($(call isTargetCpuBits, 64), true) RC_DESC := 64-Bit$(SPACE) endif JVM_RCFLAGS += -D"HS_FILEDESC=$(HOTSPOT_VM_DISTRO) $(RC_DESC)$(JVM_VARIANT) VM" @@ -209,7 +209,7 @@ $(VM_VERSION_OBJ): $(filter-out $(VM_VERSION_OBJ) $(JVM_MAPFILE), \ $(BUILD_LIBJVM_TARGET_DEPS)) ifneq ($(GENERATE_COMPILE_COMMANDS_ONLY), true) - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) # It doesn't matter which jvm.lib file gets exported, but we need # to pick just one. ifeq ($(JVM_VARIANT), $(JVM_VARIANT_MAIN)) diff --git a/make/hotspot/lib/JvmDtraceObjects.gmk b/make/hotspot/lib/JvmDtraceObjects.gmk index 7e17f1e31a9..6c589326db7 100644 --- a/make/hotspot/lib/JvmDtraceObjects.gmk +++ b/make/hotspot/lib/JvmDtraceObjects.gmk @@ -24,7 +24,7 @@ # ifeq ($(call check-jvm-feature, dtrace), true) - ifeq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), true) ############################################################################ # Integrate with libjvm. Here we generate two object files which are @@ -131,7 +131,7 @@ ifeq ($(call check-jvm-feature, dtrace), true) > $(DTRACE_SUPPORT_DIR)/$(@F).d)) $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -o $@ \ -s $(DTRACE_SUPPORT_DIR)/$(@F).d) - ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc) + ifeq ($(call isTargetCpuArch, sparc), true) $(call ExecuteWithLog, $@.elfedit, $(ELFEDIT) $(call GetElfeditCommands) $@) endif diff --git a/make/hotspot/lib/JvmFeatures.gmk b/make/hotspot/lib/JvmFeatures.gmk index ceee2ea72a4..5575234adff 100644 --- a/make/hotspot/lib/JvmFeatures.gmk +++ b/make/hotspot/lib/JvmFeatures.gmk @@ -47,14 +47,14 @@ endif ifeq ($(call check-jvm-feature, zero), true) JVM_CFLAGS_FEATURES += -DZERO -DCC_INTERP -DZERO_LIBARCH='"$(OPENJDK_TARGET_CPU_LEGACY_LIB)"' $(LIBFFI_CFLAGS) JVM_LIBS_FEATURES += $(LIBFFI_LIBS) - ifeq ($(OPENJDK_TARGET_CPU), sparcv9) + ifeq ($(call isTargetCpu, sparcv9), true) BUILD_LIBJVM_EXTRA_FILES := $(TOPDIR)/src/hotspot/cpu/sparc/memset_with_concurrent_readers_sparc.cpp endif endif ifeq ($(call check-jvm-feature, minimal), true) JVM_CFLAGS_FEATURES += -DMINIMAL_JVM -DVMTYPE=\"Minimal\" - ifeq ($(OPENJDK_TARGET_OS), linux) + ifeq ($(call isTargetOs, linux), true) # Override the default -g with a more liberal strip policy for the minimal JVM JVM_STRIPFLAGS := --strip-unneeded endif diff --git a/make/hotspot/lib/JvmFlags.gmk b/make/hotspot/lib/JvmFlags.gmk index c344d4838bc..251c731ea71 100644 --- a/make/hotspot/lib/JvmFlags.gmk +++ b/make/hotspot/lib/JvmFlags.gmk @@ -74,7 +74,7 @@ ifeq ($(DEBUG_LEVEL), release) endif else ifeq ($(DEBUG_LEVEL), fastdebug) JVM_CFLAGS_DEBUGLEVEL := -DASSERT - ifeq ($(filter $(OPENJDK_TARGET_OS), windows aix), ) + ifeq ($call isTargetOs, windows aix), false) # NOTE: Old build did not define CHECK_UNHANDLED_OOPS on Windows and AIX. JVM_CFLAGS_DEBUGLEVEL += -DCHECK_UNHANDLED_OOPS endif diff --git a/make/hotspot/lib/JvmMapfile.gmk b/make/hotspot/lib/JvmMapfile.gmk index 81bc880fd4f..ba44e579832 100644 --- a/make/hotspot/lib/JvmMapfile.gmk +++ b/make/hotspot/lib/JvmMapfile.gmk @@ -28,13 +28,13 @@ $(eval $(call IncludeCustomExtension, hotspot/lib/JvmMapfile.gmk)) ################################################################################ # Combine a list of static symbols -ifneq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), windows-x86_64) +ifeq ($(call And, $(call isTargetOs, windows) $(call isTargetCpu, x86_64)), false) # On Windows x86_64, we should not have any symbols at all, since that # results in duplicate warnings from the linker (JDK-8043491). SYMBOLS_SRC += $(TOPDIR)/make/hotspot/symbols/symbols-shared endif -ifeq ($(OPENJDK_TARGET_OS_TYPE), unix) +ifeq ($(call isTargetOsType, unix), true) SYMBOLS_SRC += $(TOPDIR)/make/hotspot/symbols/symbols-unix endif @@ -48,7 +48,7 @@ ifneq ($(findstring debug, $(DEBUG_LEVEL)), ) endif endif -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) ifeq ($(call check-jvm-feature, dtrace), true) # Additional mapfiles that are only used when dtrace is enabled ifeq ($(call check-jvm-feature, compiler2), true) @@ -64,7 +64,7 @@ endif # Create a dynamic list of symbols from the built object files. This is highly # platform dependent. -ifeq ($(OPENJDK_TARGET_OS), linux) +ifeq ($(call isTargetOs, linux), true) DUMP_SYMBOLS_CMD := $(NM) --defined-only *.o ifneq ($(FILTER_SYMBOLS_PATTERN), ) FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)| @@ -76,7 +76,7 @@ ifeq ($(OPENJDK_TARGET_OS), linux) if ($$3 ~ /$(FILTER_SYMBOLS_PATTERN)/) print $$3; \ }' -else ifeq ($(OPENJDK_TARGET_OS), solaris) +else ifeq ($(call isTargetOs, solaris), true) DUMP_SYMBOLS_CMD := $(NM) -p *.o ifneq ($(FILTER_SYMBOLS_PATTERN), ) FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)| @@ -90,7 +90,7 @@ else ifeq ($(OPENJDK_TARGET_OS), solaris) if ($$3 ~ /$(FILTER_SYMBOLS_PATTERN)/) print $$3; \ }' -else ifeq ($(OPENJDK_TARGET_OS), macosx) +else ifeq ($(call isTargetOs, macosx), true) # nm on macosx prints out "warning: nm: no name list" to stderr for # files without symbols. Hide this, even at the expense of hiding real errors. DUMP_SYMBOLS_CMD := $(NM) -Uj *.o 2> /dev/null @@ -107,7 +107,7 @@ else ifeq ($(OPENJDK_TARGET_OS), macosx) # The script below might be what was intended, but it failes to link with tons # of 'cannot export hidden symbol vtable for X'. # '{ if ($$1 ~ /^__ZTV/ || $$1 ~ /^_gHotSpotVM/) print substr($$1, 2) }' -else ifeq ($(OPENJDK_TARGET_OS), aix) +else ifeq ($(call isTargetOs, aix), true) # NOTE: The old build had the solution below. This should to be fixed in # configure instead. @@ -123,7 +123,7 @@ else ifeq ($(OPENJDK_TARGET_OS), aix) if ($$3 ~ /^SharedArchivePath__9Arguments$$/) print $$3; \ }' -else ifeq ($(OPENJDK_TARGET_OS), windows) +else ifeq ($(call isTargetOs, windows), true) DUMP_SYMBOLS_CMD := $(DUMPBIN) -symbols *.obj FILTER_SYMBOLS_AWK_SCRIPT := \ '{ \ @@ -153,12 +153,12 @@ $(JVM_OUTPUTDIR)/symbols: $(SYMBOLS_SRC) ################################################################################ # Finally convert the symbol list into a platform-specific mapfile -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) # On macosx, we need to add a leading underscore define create-mapfile-work $(AWK) '{ if ($$0 ~ ".") { print " _" $$0 } }' < $^ > $@.tmp endef -else ifeq ($(OPENJDK_TARGET_OS), windows) +else ifeq ($(call isTargetOs, windows), true) # On windows, add an 'EXPORTS' header define create-mapfile-work $(ECHO) "EXPORTS" > $@.tmp diff --git a/make/hotspot/lib/JvmOverrideFiles.gmk b/make/hotspot/lib/JvmOverrideFiles.gmk index 7d45dd331af..24b8027e42d 100644 --- a/make/hotspot/lib/JvmOverrideFiles.gmk +++ b/make/hotspot/lib/JvmOverrideFiles.gmk @@ -51,7 +51,7 @@ ifneq ($(FDLIBM_CFLAGS), ) LIBJVM_FDLIBM_COPY_OPT_FLAG := $(CXX_O_FLAG_NORM) endif -ifeq ($(OPENJDK_TARGET_OS), linux) +ifeq ($(call isTargetOs, linux), true) BUILD_LIBJVM_ostream.cpp_CXXFLAGS := -D_FILE_OFFSET_BITS=64 BUILD_LIBJVM_logFileOutput.cpp_CXXFLAGS := -D_FILE_OFFSET_BITS=64 @@ -65,7 +65,7 @@ ifeq ($(OPENJDK_TARGET_OS), linux) # endif - ifeq ($(OPENJDK_TARGET_CPU), x86) + ifeq ($(call isTargetCpu, x86), true) # Performance measurements show that by compiling GC related code, we could # significantly reduce the GC pause time on 32 bit Linux/Unix platforms by # compiling without the PIC flag (-fPIC on linux). @@ -83,7 +83,7 @@ ifeq ($(OPENJDK_TARGET_OS), linux) $(foreach s, $(NONPIC_SRC), $(eval BUILD_LIBJVM_$(notdir $s)_CXXFLAGS := -fno-PIC)) endif -else ifeq ($(OPENJDK_TARGET_OS), solaris) +else ifeq ($(call isTargetOs, solaris), true) ifneq ($(DEBUG_LEVEL), slowdebug) # dev studio 12.6 workaround BUILD_LIBJVM_arguments.cpp_OPTIMIZATION := LOW @@ -97,7 +97,7 @@ else ifeq ($(OPENJDK_TARGET_OS), solaris) BUILD_LIBJVM_jni.cpp_CXXFLAGS := -Qoption ube -O~yz BUILD_LIBJVM_stubGenerator_$(HOTSPOT_TARGET_CPU).cpp_CXXFLAGS := -xspace - ifeq ($(OPENJDK_TARGET_CPU), x86_64) + ifeq ($(call isTargetCpu, x86_64), true) # Temporary until SS10 C++ compiler is fixed BUILD_LIBJVM_generateOptoStub.cpp_CXXFLAGS := -xO2 # Temporary util SS12u1 C++ compiler is fixed @@ -118,7 +118,7 @@ else ifeq ($(OPENJDK_TARGET_OS), solaris) BUILD_LIBJVM_bytecodeInterpreter.cpp_CXXFLAGS := +d BUILD_LIBJVM_bytecodeInterpreterWithChecks.cpp_CXXFLAGS := +d - ifeq ($(OPENJDK_TARGET_CPU_ARCH), x86) + ifeq ($(call isTargetCpuArch, x86), true) # ube explodes on x86 BUILD_LIBJVM_bytecodeInterpreter.cpp_CXXFLAGS += -xO1 BUILD_LIBJVM_bytecodeInterpreterWithChecks.cpp_CXXFLAGS += -xO1 @@ -129,7 +129,7 @@ else ifeq ($(OPENJDK_TARGET_OS), solaris) # Workaround for jvmciCompilerToVM.cpp long compilation time BUILD_LIBJVM_jvmciCompilerToVMInit.cpp_OPTIMIZATION := NONE -else ifeq ($(OPENJDK_TARGET_OS), macosx) +else ifeq ($(call isTargetOs, macosx), true) # The copied fdlibm routines in these files must not be optimized BUILD_LIBJVM_sharedRuntimeTrig.cpp_CXXFLAGS := $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG) BUILD_LIBJVM_sharedRuntimeTrans.cpp_CXXFLAGS := $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG) @@ -160,7 +160,7 @@ else ifeq ($(OPENJDK_TARGET_OS), macosx) # endif -else ifeq ($(OPENJDK_TARGET_OS), aix) +else ifeq ($(call isTargetOs, aix), true) BUILD_LIBJVM_synchronizer.cpp_CXXFLAGS := -qnoinline BUILD_LIBJVM_sharedRuntimeTrans.cpp_CXXFLAGS := $(CXX_O_FLAG_NONE) # Disable aggressive optimizations for functions in sharedRuntimeTrig.cpp @@ -185,7 +185,7 @@ else ifeq ($(OPENJDK_TARGET_OS), aix) # Disable ELF decoder on AIX (AIX uses XCOFF). JVM_EXCLUDE_PATTERNS += elf -else ifeq ($(OPENJDK_TARGET_OS), windows) +else ifeq ($(call isTargetOs, windows), true) JVM_PRECOMPILED_HEADER_EXCLUDE := \ bytecodeInterpreter.cpp \ bytecodeInterpreterWithChecks.cpp \ diff --git a/make/hotspot/test/GtestImage.gmk b/make/hotspot/test/GtestImage.gmk index f24b1a73fcd..e58a1bb936d 100644 --- a/make/hotspot/test/GtestImage.gmk +++ b/make/hotspot/test/GtestImage.gmk @@ -37,7 +37,7 @@ $(foreach v, $(JVM_VARIANTS), \ $(eval TARGETS += $$(COPY_GTEST_$v)) \ ) -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(foreach v, $(JVM_VARIANTS), \ $(eval $(call SetupCopyFiles, COPY_GTEST_MSVCR_$v, \ DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \ @@ -54,7 +54,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) ) endif -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) $(foreach v, $(JVM_VARIANTS), \ $(eval $(call SetupCopyFiles, COPY_GTEST_STLPORT_$v, \ DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \ diff --git a/make/launcher/Launcher-java.base.gmk b/make/launcher/Launcher-java.base.gmk index 960a92f6ea5..14229e13e08 100644 --- a/make/launcher/Launcher-java.base.gmk +++ b/make/launcher/Launcher-java.base.gmk @@ -51,7 +51,7 @@ $(SUPPORT_OUTPUTDIR)/modules_cmds/java.base/java$(EXE_SUFFIX): $(BUILD_LAUNCHER_ TARGETS += $(SUPPORT_OUTPUTDIR)/modules_cmds/java.base/java$(EXE_SUFFIX) -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupBuildLauncher, javaw, \ CFLAGS := -DJAVAW -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES, \ EXTRA_RC_FLAGS := $(JAVA_RC_FLAGS), \ @@ -65,7 +65,7 @@ $(eval $(call SetupBuildLauncher, keytool, \ ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), linux) +ifeq ($(call isTargetOs, linux), true) $(eval $(call SetupJdkExecutable, BUILD_JEXEC, \ NAME := jexec, \ SRC := $(TOPDIR)/src/$(MODULE)/unix/native/launcher, \ @@ -84,7 +84,7 @@ endif ################################################################################ -ifneq ($(findstring $(OPENJDK_TARGET_OS), macosx solaris aix linux), ) +ifeq ($(call isTargetOs, macosx solaris aix linux), true) $(eval $(call SetupJdkExecutable, BUILD_JSPAWNHELPER, \ NAME := jspawnhelper, \ SRC := $(TOPDIR)/src/$(MODULE)/unix/native/jspawnhelper, \ diff --git a/make/launcher/Launcher-java.security.jgss.gmk b/make/launcher/Launcher-java.security.jgss.gmk index 7411e1a21c4..b57800e5c9f 100644 --- a/make/launcher/Launcher-java.security.jgss.gmk +++ b/make/launcher/Launcher-java.security.jgss.gmk @@ -25,7 +25,7 @@ include LauncherCommon.gmk -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupBuildLauncher, kinit, \ MAIN_CLASS := sun.security.krb5.internal.tools.Kinit, \ )) diff --git a/make/launcher/Launcher-jdk.accessibility.gmk b/make/launcher/Launcher-jdk.accessibility.gmk index f31d039aab4..fbf3d9493ae 100644 --- a/make/launcher/Launcher-jdk.accessibility.gmk +++ b/make/launcher/Launcher-jdk.accessibility.gmk @@ -28,7 +28,7 @@ include LauncherCommon.gmk ################################################################################ # jabswitch -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) JABSWITCH_SRC := $(TOPDIR)/src/jdk.accessibility/windows/native/jabswitch ACCESSBRIDGE_SRC := $(TOPDIR)/src/jdk.accessibility/windows/native/common @@ -98,7 +98,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) endef - ifeq ($(OPENJDK_TARGET_CPU_BITS), 32) + ifeq ($(call isTargetCpuBits, 32), true) $(eval $(call SetupInspector,-32,32)) $(eval $(call SetupWalker,-32,32)) $(eval $(call SetupInspector,,LEGACY)) diff --git a/make/launcher/Launcher-jdk.pack.gmk b/make/launcher/Launcher-jdk.pack.gmk index ef27779a3bc..04160166928 100644 --- a/make/launcher/Launcher-jdk.pack.gmk +++ b/make/launcher/Launcher-jdk.pack.gmk @@ -45,7 +45,7 @@ ifeq ($(TOOLCHAIN_TYPE), gcc) CXXFLAGS_JDKEXE += -fvisibility=hidden LDFLAGS_JDKEXE += -Wl,--exclude-libs,ALL else ifeq ($(TOOLCHAIN_TYPE), clang) - ifneq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), false) CXXFLAGS_JDKEXE += -fvisibility=hidden endif else ifeq ($(TOOLCHAIN_TYPE), solstudio) diff --git a/make/launcher/LauncherCommon.gmk b/make/launcher/LauncherCommon.gmk index 520f6feaa0e..a1068c3f82c 100644 --- a/make/launcher/LauncherCommon.gmk +++ b/make/launcher/LauncherCommon.gmk @@ -105,7 +105,7 @@ define SetupBuildLauncherBody $$(addprefix -J, $$($1_JAVA_ARGS)) $$($1_LAUNCHER_CLASS), "$$a"$(COMMA) )) }' $1_CFLAGS += -DJAVA_ARGS=$$($1_JAVA_ARGS_STR) - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) ifeq ($$($1_MACOSX_SIGNED), true) $1_PLIST_FILE := Info-privileged.plist $1_CODESIGN := true @@ -179,11 +179,11 @@ define SetupBuildLauncherBody $1 += $$(BUILD_LAUNCHER_$1) TARGETS += $$($1) - ifeq ($(OPENJDK_TARGET_OS), aix) + ifeq ($(call isTargetOs, aix), true) $$(BUILD_LAUNCHER_$1): $(call FindStaticLib, java.base, jli_static) endif - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) $$(BUILD_LAUNCHER_$1): $(call FindStaticLib, java.base, java, /libjava) \ $$($1_WINDOWS_JLI_LIB) endif @@ -194,7 +194,7 @@ endef # relationship between executables and man pages (even if this is not always # the case), so piggyback man page generation on the launcher compilation. -ifeq ($(OPENJDK_TARGET_OS_TYPE), unix) +ifeq ($(call isTargetOsType, unix), true) # Only build manpages on unix systems. # We assume all our man pages should reside in section 1. diff --git a/make/lib/Awt2dLibraries.gmk b/make/lib/Awt2dLibraries.gmk index 2bc8cac1552..debd1499a6f 100644 --- a/make/lib/Awt2dLibraries.gmk +++ b/make/lib/Awt2dLibraries.gmk @@ -43,7 +43,7 @@ BUILD_LIBMLIB_EXCLUDE_SRC_PATTERNS := unix BUILD_LIBMLIB_CFLAGS := -D__USE_J2D_NAMES -D__MEDIALIB_OLD_NAMES -DMLIB_NO_LIBSUNMATH -ifeq ($(OPENJDK_TARGET_CPU_BITS), 64) +ifeq ($(call isTargetCpuBits, 64), true) BUILD_LIBMLIB_CFLAGS += -DMLIB_OS64BIT endif @@ -68,7 +68,7 @@ TARGETS += $(BUILD_LIBMLIB_IMAGE) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc) +ifeq ($(call And, $(call isTargetOs, solaris) $(call isTargetCpuArch, sparc)), true) # libmlib_image_v is basically built from mlib_image sources, with some additions # and some exclusions. @@ -80,7 +80,7 @@ ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc) LIBMLIB_IMAGE_V_CFLAGS := -xarch=sparcvis -D__USE_J2D_NAMES -D__MEDIALIB_OLD_NAMES \ $(TOPDIR)/src/$(MODULE)/unix/native/libmlib_image/vis_$(OPENJDK_TARGET_CPU_BITS).il - ifeq ($(OPENJDK_TARGET_CPU_BITS), 64) + ifeq ($(call isTargetCpuBits, 64), true) LIBMLIB_IMAGE_V_CFLAGS += -DMLIB_OS64BIT endif @@ -127,11 +127,11 @@ LIBAWT_EXTRA_SRC := \ $(TOPDIR)/src/$(MODULE)/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \ # -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc) +ifeq ($(call And, $(call isTargetOs, solaris) $(call isTargetCpuArch, sparc)), true) LIBAWT_EXTRA_SRC += $(TOPDIR)/src/$(MODULE)/share/native/common/awt/medialib endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) LIBAWT_EXTRA_SRC += \ $(TOPDIR)/src/$(MODULE)/share/native/common/awt/utility \ $(TOPDIR)/src/$(MODULE)/share/native/common/font \ @@ -140,22 +140,22 @@ ifeq ($(OPENJDK_TARGET_OS), windows) # endif -ifneq ($(filter $(OPENJDK_TARGET_OS), solaris linux macosx aix), ) +ifeq ($(call isTargetOs, solaris linux macosx aix), true) LIBAWT_EXFILES += awt_Font.c CUPSfuncs.c fontpath.c X11Color.c endif -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) LIBAWT_EXFILES += initIDs.c awt/image/cvutils/img_colors.c endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) LIBAWT_EXFILES += \ java2d/d3d/D3DShaderGen.c \ awt/image/cvutils/img_colors.c \ # endif -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-sparcv9) +ifeq ($(call And, $(call isTargetOs, solaris) $(call isTargetCpu, sparcv9)), true) LIBAWT_EXFILES += java2d/loops/MapAccelFunc.c else LIBAWT_EXCLUDES += \ @@ -182,20 +182,20 @@ LIBAWT_EXTRA_HEADER_DIRS := \ LIBAWT_CFLAGS += -D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES $(X_CFLAGS) -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-sparcv9) +ifeq ($(call And, $(call isTargetOs, solaris) $(call isTargetCpu, sparcv9)), true) LIBAWT_CFLAGS += -xarch=sparcvis -DMLIB_ADD_SUFF \ $(TOPDIR)/src/$(MODULE)/unix/native/libmlib_image/vis_$(OPENJDK_TARGET_CPU_BITS).il LIBAWT_ASFLAGS = -P -xarch=v9a endif -ifneq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), false) LIBAWT_CFLAGS += -DMLIB_NO_LIBSUNMATH endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) LIBAWT_CFLAGS += -EHsc -DUNICODE -D_UNICODE - ifeq ($(OPENJDK_TARGET_CPU_BITS), 64) + ifeq ($(call isTargetCpuBits, 64), true) LIBAWT_CFLAGS += -DMLIB_OS64BIT endif @@ -203,7 +203,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) LIBAWT_VERSIONINFO_RESOURCE := $(TOPDIR)/src/$(MODULE)/windows/native/libawt/windows/awt.rc endif -ifeq ($(OPENJDK_TARGET_OS), linux) +ifeq ($(call isTargetOs, linux), true) # FIXME: This is probably not what we want to do, but keep it now for compatibility. LIBAWT_CFLAGS += $(EXPORT_ALL_SYMBOLS) endif @@ -263,7 +263,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \ $(BUILD_LIBAWT): $(call FindLib, java.base, java) -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) $(BUILD_LIBAWT): $(BUILD_LIBMLIB_IMAGE) endif @@ -271,7 +271,7 @@ TARGETS += $(BUILD_LIBAWT) ################################################################################ -ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx), ) +ifeq ($(call isTargetOs, windows macosx), false) ifeq ($(ENABLE_HEADLESS_ONLY), false) LIBAWT_XAWT_EXTRA_SRC := \ @@ -297,11 +297,11 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx), ) $(FONTCONFIG_CFLAGS) \ $(CUPS_CFLAGS) - ifeq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), true) LIBAWT_XAWT_CFLAGS += -DFUNCPROTO=15 endif - ifeq ($(OPENJDK_TARGET_OS), linux) + ifeq ($(call isTargetOs, linux), true) ifeq ($(DISABLE_XRENDER), true) LIBAWT_XAWT_CFLAGS += -DDISABLE_XRENDER_BY_DEFAULT=true endif @@ -309,7 +309,7 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx), ) LIBAWT_XAWT_LIBS := $(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi -ljava -ljvm - ifeq ($(OPENJDK_TARGET_OS), linux) + ifeq ($(call isTargetOs, linux), true) LIBAWT_XAWT_LIBS += -lpthread endif @@ -443,7 +443,7 @@ TARGETS += $(BUILD_LIBJAVAJPEG) ################################################################################ # Mac and Windows only use the native AWT lib, do not build libawt_headless -ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),) +ifeq ($(call isTargetOs, windows macosx), false) LIBAWT_HEADLESS_EXTRA_SRC := \ common/font \ @@ -504,7 +504,7 @@ else # For use by libfontmanager: LIBFREETYPE_CFLAGS := -I$(BUILD_LIBFREETYPE_HEADER_DIRS) - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) LIBFREETYPE_LIBS := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfreetype/freetype.lib else LIBFREETYPE_LIBS := -lfreetype @@ -534,20 +534,20 @@ endif HARFBUZZ_CFLAGS := -DHAVE_OT -DHAVE_FALLBACK -DHAVE_UCDN -DHAVE_ROUND -ifneq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), false) HARFBUZZ_CFLAGS += -DGETPAGESIZE -DHAVE_MPROTECT -DHAVE_PTHREAD \ -DHAVE_SYSCONF -DHAVE_SYS_MMAN_H -DHAVE_UNISTD_H endif -ifneq (, $(findstring $(OPENJDK_TARGET_OS), linux macosx)) +ifeq ($(call isTargetOs, linux macosx), true) HARFBUZZ_CFLAGS += -DHAVE_INTEL_ATOMIC_PRIMITIVES endif -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) HARFBUZZ_CFLAGS += -DHAVE_SOLARIS_ATOMIC_OPS endif -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) HARFBUZZ_CFLAGS += -DHAVE_CORETEXT endif -ifneq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), false) LIBFONTMANAGER_EXCLUDE_FILES += harfbuzz/hb-coretext.cc endif # hb-ft.cc is not presently needed, and requires freetype 2.4.2 or later. @@ -572,11 +572,11 @@ BUILD_LIBFONTMANAGER_FONTLIB += $(LIBFREETYPE_LIBS) LIBFONTMANAGER_OPTIMIZATION := HIGH -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \ X11TextRenderer.c LIBFONTMANAGER_OPTIMIZATION := HIGHEST -else ifeq ($(OPENJDK_TARGET_OS), macosx) +else ifeq ($(call isTargetOs, macosx), true) LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \ X11TextRenderer.c \ fontpath.c \ @@ -640,7 +640,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBFONTMANAGER, \ $(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT) -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) $(BUILD_LIBFONTMANAGER): $(call FindLib, $(MODULE), awt_lwawt) endif @@ -652,7 +652,7 @@ TARGETS += $(BUILD_LIBFONTMANAGER) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) LIBJAWT_CFLAGS := -EHsc -DUNICODE -D_UNICODE @@ -667,7 +667,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) java.base:libjava \ # - ifeq ($(OPENJDK_TARGET_CPU), x86) + ifeq ($(call isTargetCpu, x86), true) KERNEL32_LIB := kernel32.lib endif @@ -692,25 +692,25 @@ ifeq ($(OPENJDK_TARGET_OS), windows) TARGETS += $(COPY_JAWT_LIB) -else # OPENJDK_TARGET_OS not windows +else # not windows - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) # libjawt on macosx do not use the unix code LIBJAWT_EXCLUDE_SRC_PATTERNS := unix endif - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) JAWT_LIBS := -lawt_lwawt else JAWT_LIBS := - ifneq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), false) JAWT_LIBS += -lawt endif ifeq ($(ENABLE_HEADLESS_ONLY), false) JAWT_LIBS += -lawt_xawt else JAWT_LIBS += -lawt_headless - ifeq ($(OPENJDK_TARGET_OS), linux) + ifeq ($(call isTargetOs, linux), true) JAWT_CFLAGS += -DHEADLESS endif endif @@ -742,11 +742,11 @@ else # OPENJDK_TARGET_OS not windows $(BUILD_LIBJAWT): $(call FindLib, $(MODULE), awt_headless) endif - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) $(BUILD_LIBJAWT): $(call FindLib, $(MODULE), awt_lwawt) endif -endif # OPENJDK_TARGET_OS +endif TARGETS += $(BUILD_LIBJAWT) @@ -784,20 +784,20 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) LIBSPLASHSCREEN_EXTRA_SRC += java.base:libzip/zlib endif - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) # libsplashscreen on macosx do not use the unix code LIBSPLASHSCREEN_EXCLUDE_SRC_PATTERNS := unix endif LIBSPLASHSCREEN_CFLAGS += -DSPLASHSCREEN -DPNG_NO_MMX_CODE -DPNG_ARM_NEON_OPT=0 - ifeq ($(OPENJDK_TARGET_OS), linux) - ifeq ($(OPENJDK_TARGET_CPU_ARCH), ppc) + ifeq ($(call isTargetOs, linux), true) + ifeq ($(call isTargetCpuArch, ppc), true) LIBSPLASHSCREEN_CFLAGS += -DPNG_POWERPC_VSX_OPT=0 endif endif - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) LIBSPLASHSCREEN_CFLAGS += -DWITH_MACOSX BUILD_LIBSPLASHSCREEN_java_awt_SplashScreen.c_CFLAGS := -x objective-c -O0 @@ -808,7 +808,7 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) BUILD_LIBSPLASHSCREEN_splashscreen_png.c_CFLAGS := -x objective-c -O0 BUILD_LIBSPLASHSCREEN_splashscreen_sys.m_CFLAGS := -O0 - else ifeq ($(OPENJDK_TARGET_OS), windows) + else ifeq ($(call isTargetOs, windows), true) LIBSPLASHSCREEN_CFLAGS += -DWITH_WIN32 else LIBSPLASHSCREEN_CFLAGS += -DWITH_X11 $(X_CFLAGS) @@ -816,14 +816,14 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) LIBSPLASHSCREEN_LIBS := - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) LIBSPLASHSCREEN_LIBS += \ $(LIBM) -lpthread -liconv -losxapp \ -framework ApplicationServices \ -framework Foundation \ -framework Cocoa \ -framework JavaNativeFoundation - else ifeq ($(OPENJDK_TARGET_OS), windows) + else ifeq ($(call isTargetOs, windows), true) LIBSPLASHSCREEN_LIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib $(WIN_JAVA_LIB) jvm.lib else LIBSPLASHSCREEN_LIBS += $(X_LIBS) -lX11 -lXext $(LIBM) -lpthread -ldl @@ -863,7 +863,7 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) TARGETS += $(BUILD_LIBSPLASHSCREEN) - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) $(BUILD_LIBSPLASHSCREEN): $(call FindLib, $(MODULE), osxapp) endif @@ -871,7 +871,7 @@ endif ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) LIBAWT_LWAWT_EXTRA_SRC := \ $(TOPDIR)/src/$(MODULE)/unix/native/common/awt \ @@ -941,7 +941,7 @@ endif ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) $(eval $(call SetupJdkLibrary, BUILD_LIBOSXUI, \ NAME := osxui, \ diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk index ec1a2107d41..745c8a946c0 100644 --- a/make/lib/CoreLibraries.gmk +++ b/make/lib/CoreLibraries.gmk @@ -35,7 +35,7 @@ $(eval $(call IncludeCustomExtension, lib/CoreLibraries.gmk)) BUILD_LIBFDLIBM_OPTIMIZATION := NONE -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) BUILD_LIBFDLIBM_OPTIMIZATION := HIGH endif @@ -68,7 +68,7 @@ $(eval $(call SetupNativeCompilation, BUILD_LIBFDLIBM, \ ########################################################################################## LIBVERIFY_OPTIMIZATION := HIGH -ifneq ($(findstring $(OPENJDK_TARGET_OS), solaris linux), ) +ifeq ($(call isTargetOs, solaris linux), true) ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true) LIBVERIFY_OPTIMIZATION := LOW endif @@ -92,7 +92,7 @@ TARGETS += $(BUILD_LIBVERIFY) LIBJAVA_CFLAGS := -DARCHPROPNAME='"$(OPENJDK_TARGET_CPU_OSARCH)"' -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) BUILD_LIBJAVA_java_props_md.c_CFLAGS := -x objective-c BUILD_LIBJAVA_java_props_macosx.c_CFLAGS := -x objective-c endif @@ -181,11 +181,11 @@ TARGETS += $(BUILD_LIBJIMAGE) ########################################################################################## -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) LIBJLI_EXCLUDE_FILES += java_md_solinux.c endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) # Supply the name of the C runtime lib. LIBJLI_CFLAGS += -DMSVCR_DLL_NAME='"$(notdir $(MSVCR_DLL))"' ifneq ($(MSVCP_DLL), ) @@ -233,7 +233,7 @@ TARGETS += $(BUILD_LIBJLI) LIBJLI_SRC_DIRS := $(call FindSrcDirsForComponent, java.base, libjli) -ifeq ($(OPENJDK_TARGET_OS), aix) +ifeq ($(call isTargetOs, aix), true) # AIX also requires a static libjli because the compiler doesn't support '-rpath' $(eval $(call SetupNativeCompilation, BUILD_LIBJLI_STATIC, \ NAME := jli_static, \ diff --git a/make/lib/Lib-java.base.gmk b/make/lib/Lib-java.base.gmk index ac1cb8d7ada..68b4aa53819 100644 --- a/make/lib/Lib-java.base.gmk +++ b/make/lib/Lib-java.base.gmk @@ -99,7 +99,7 @@ $(BUILD_LIBNIO): $(BUILD_LIBNET) ################################################################################ # Create the macosx security library -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) # JavaNativeFoundation framework not supported in static builds ifneq ($(STATIC_BUILD), true) @@ -130,7 +130,7 @@ endif ################################################################################ # Create the jsig library -ifeq ($(OPENJDK_TARGET_OS_TYPE), unix) +ifeq ($(call isTargetOsType, unix), true) ifeq ($(STATIC_BUILD), false) $(eval $(call SetupJdkLibrary, BUILD_LIBJSIG, \ NAME := jsig, \ @@ -205,7 +205,7 @@ endif ################################################################################ # Copy tzmappings file for Windows -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupCopyFiles, COPY_TZMAPPINGS, \ FILES := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/windows/conf/tzmappings, \ DEST := $(call FindLibDirForModule, $(MODULE)), \ diff --git a/make/lib/Lib-java.desktop.gmk b/make/lib/Lib-java.desktop.gmk index c26294cd557..2c660cedd1c 100644 --- a/make/lib/Lib-java.desktop.gmk +++ b/make/lib/Lib-java.desktop.gmk @@ -39,7 +39,7 @@ include Awt2dLibraries.gmk ################################################################################ # Create the libjsound library -ifneq ($(OPENJDK_TARGET_OS), aix) +ifeq ($(call isTargetOs, aix), false) LIBJSOUND_CFLAGS := \ $(ALSA_CFLAGS) \ @@ -48,14 +48,14 @@ ifneq ($(OPENJDK_TARGET_OS), aix) -DUSE_DAUDIO=TRUE \ # - ifneq ($(OPENJDK_TARGET_OS), solaris) + ifeq ($(call isTargetOs, solaris), false) LIBJSOUND_CFLAGS += \ -DUSE_PLATFORM_MIDI_OUT=TRUE \ -DUSE_PLATFORM_MIDI_IN=TRUE \ # endif - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) LIBJSOUND_TOOLCHAIN := TOOLCHAIN_LINK_CXX endif @@ -87,7 +87,7 @@ endif ################################################################################ # Create the macosx specific osxapp and osx libraries -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) $(eval $(call SetupJdkLibrary, BUILD_LIBOSXAPP, \ NAME := osxapp, \ @@ -142,4 +142,3 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) $(BUILD_LIBOSX): $(call FindLib, java.base, java) endif - diff --git a/make/lib/Lib-java.instrument.gmk b/make/lib/Lib-java.instrument.gmk index cf57be6e53b..73a26f830f5 100644 --- a/make/lib/Lib-java.instrument.gmk +++ b/make/lib/Lib-java.instrument.gmk @@ -30,7 +30,7 @@ $(eval $(call IncludeCustomExtension, lib/Lib-java.instrument.gmk)) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) # equivalent of strcasecmp is stricmp on Windows LIBINSTRUMENT_CFLAGS := -Dstrcasecmp=stricmp WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/libjli/jli.lib @@ -62,7 +62,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBINSTRUMENT, \ $(WINDOWS_JLI_LIB), \ )) -ifeq ($(OPENJDK_TARGET_OS), aix) +ifeq ($(call isTargetOs, aix), true) $(BUILD_LIBINSTRUMENT): $(call FindStaticLib, java.base, jli_static) else $(BUILD_LIBINSTRUMENT): $(call FindLib, java.base, jli) diff --git a/make/lib/Lib-java.management.gmk b/make/lib/Lib-java.management.gmk index a70a3ccf45a..90a61882342 100644 --- a/make/lib/Lib-java.management.gmk +++ b/make/lib/Lib-java.management.gmk @@ -31,7 +31,7 @@ $(eval $(call IncludeCustomExtension, lib/Lib-java.management.gmk)) ################################################################################ LIBMANAGEMENT_OPTIMIZATION := HIGH -ifneq ($(findstring $(OPENJDK_TARGET_OS), solaris linux), ) +ifeq ($(call isTargetOs, solaris linux), true) ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true) LIBMANAGEMENT_OPTIMIZATION := LOW endif @@ -57,4 +57,3 @@ TARGETS += $(BUILD_LIBMANAGEMENT) # Include custom extension post hook $(eval $(call IncludeCustomExtension, lib/Lib-java.management-post.gmk)) - diff --git a/make/lib/Lib-java.prefs.gmk b/make/lib/Lib-java.prefs.gmk index cac3b17e26a..f43897245b2 100644 --- a/make/lib/Lib-java.prefs.gmk +++ b/make/lib/Lib-java.prefs.gmk @@ -28,7 +28,7 @@ include LibCommon.gmk ################################################################################ # libprefs on macosx do not use the unix code -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) LIBPREFS_EXCLUDE_SRC_PATTERNS := unix endif diff --git a/make/lib/Lib-java.security.jgss.gmk b/make/lib/Lib-java.security.jgss.gmk index 19f52d7088a..d4789b6fe5d 100644 --- a/make/lib/Lib-java.security.jgss.gmk +++ b/make/lib/Lib-java.security.jgss.gmk @@ -44,7 +44,7 @@ TARGETS += $(BUILD_LIBJ2GSS) ifneq ($(BUILD_CRYPTO), false) - ifeq ($(OPENJDK_TARGET_OS), windows) + ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupJdkLibrary, BUILD_LIBW2K_LSA_AUTH, \ NAME := w2k_lsa_auth, \ OPTIMIZATION := LOW, \ @@ -59,7 +59,7 @@ ifneq ($(BUILD_CRYPTO), false) TARGETS += $(BUILD_LIBW2K_LSA_AUTH) endif - ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(call isTargetOs, macosx), true) # libosxkrb5 needs to call deprecated krb5 APIs so that java # can use the native credentials cache. $(eval $(call SetupJdkLibrary, BUILD_LIBOSXKRB5, \ diff --git a/make/lib/Lib-jdk.accessibility.gmk b/make/lib/Lib-jdk.accessibility.gmk index aacb7b3d2a3..a1cfca06c46 100644 --- a/make/lib/Lib-jdk.accessibility.gmk +++ b/make/lib/Lib-jdk.accessibility.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) ROOT_SRCDIR := $(TOPDIR)/src/jdk.accessibility/windows/native @@ -100,7 +100,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) endef - ifeq ($(OPENJDK_TARGET_CPU_BITS), 32) + ifeq ($(call isTargetCpuBits, 32), true) $(eval $(call SetupAccessBridgeSysInfo)) $(eval $(call SetupJavaDLL,-32,32)) $(eval $(call SetupJavaDLL,,LEGACY)) diff --git a/make/lib/Lib-jdk.attach.gmk b/make/lib/Lib-jdk.attach.gmk index 1c24e554037..2a3a3b162e7 100644 --- a/make/lib/Lib-jdk.attach.gmk +++ b/make/lib/Lib-jdk.attach.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) # In (at least) VS2013 and later, -DPSAPI_VERSION=1 is needed to generate # a binary that is compatible with windows versions older than 7/2008R2. # See MSDN documentation for GetProcessMemoryInfo for more information. diff --git a/make/lib/Lib-jdk.crypto.mscapi.gmk b/make/lib/Lib-jdk.crypto.mscapi.gmk index 88a3270cfbb..e8e92dca3bc 100644 --- a/make/lib/Lib-jdk.crypto.mscapi.gmk +++ b/make/lib/Lib-jdk.crypto.mscapi.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupJdkLibrary, BUILD_LIBSUNMSCAPI, \ NAME := sunmscapi, \ diff --git a/make/lib/Lib-jdk.crypto.ucrypto.gmk b/make/lib/Lib-jdk.crypto.ucrypto.gmk index c00e543737b..1be9af45583 100644 --- a/make/lib/Lib-jdk.crypto.ucrypto.gmk +++ b/make/lib/Lib-jdk.crypto.ucrypto.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) $(eval $(call SetupJdkLibrary, BUILD_LIBJ2UCRYPTO, \ NAME := j2ucrypto, \ diff --git a/make/lib/Lib-jdk.hotspot.agent.gmk b/make/lib/Lib-jdk.hotspot.agent.gmk index add447cf708..f6dbbc95fe7 100644 --- a/make/lib/Lib-jdk.hotspot.agent.gmk +++ b/make/lib/Lib-jdk.hotspot.agent.gmk @@ -29,19 +29,19 @@ $(eval $(call IncludeCustomExtension, hotspot/lib/Lib-jdk.hotspot.agent.gmk)) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), linux) +ifeq ($(call isTargetOs, linux), true) SA_CFLAGS := -D_FILE_OFFSET_BITS=64 -else ifeq ($(OPENJDK_TARGET_OS), solaris) +else ifeq ($(call isTargetOs, solaris), true) SA_LDFLAGS := -mt -else ifeq ($(OPENJDK_TARGET_OS), macosx) +else ifeq ($(call isTargetOs, macosx), true) SA_CFLAGS := -Damd64 -D_GNU_SOURCE -mno-omit-leaf-frame-pointer \ -mstack-alignment=16 -fPIC LIBSA_EXTRA_SRC := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent -else ifeq ($(OPENJDK_TARGET_OS), windows) +else ifeq ($(call isTargetOs, windows), true) SA_CFLAGS := -D_WINDOWS -D_DEBUG -D_CONSOLE -D_MBCS -EHsc - ifeq ($(OPENJDK_TARGET_CPU), x86_64) + ifeq ($(call isTargetCpu, x86_64), true) SA_CXXFLAGS := -DWIN64 else # Only add /RTC1 flag for debug builds as it's diff --git a/make/lib/Lib-jdk.internal.le.gmk b/make/lib/Lib-jdk.internal.le.gmk index 0aa7bb273f5..785542f6247 100644 --- a/make/lib/Lib-jdk.internal.le.gmk +++ b/make/lib/Lib-jdk.internal.le.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupJdkLibrary, BUILD_LIBLE, \ NAME := le, \ @@ -39,6 +39,6 @@ ifeq ($(OPENJDK_TARGET_OS), windows) TARGETS += $(BUILD_LIBLE) -endif # OPENJDK_TARGET_OS +endif ################################################################################ diff --git a/make/lib/Lib-jdk.jdi.gmk b/make/lib/Lib-jdk.jdi.gmk index f1b3a5ab3b5..7a6418bed4b 100644 --- a/make/lib/Lib-jdk.jdi.gmk +++ b/make/lib/Lib-jdk.jdi.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupJdkLibrary, BUILD_LIBDT_SHMEM, \ NAME := dt_shmem, \ @@ -42,6 +42,6 @@ ifeq ($(OPENJDK_TARGET_OS), windows) TARGETS += $(BUILD_LIBDT_SHMEM) -endif # OPENJDK_TARGET_OS +endif ################################################################################ diff --git a/make/lib/Lib-jdk.management.gmk b/make/lib/Lib-jdk.management.gmk index ea0982d5965..3f58a6e9f21 100644 --- a/make/lib/Lib-jdk.management.gmk +++ b/make/lib/Lib-jdk.management.gmk @@ -30,7 +30,7 @@ $(eval $(call IncludeCustomExtension, lib/Lib-jdk.management.gmk)) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) # In (at least) VS2013 and later, -DPSAPI_VERSION=1 is needed to generate # a binary that is compatible with windows versions older than 7/2008R2. # See MSDN documentation for GetProcessMemoryInfo for more information. @@ -38,7 +38,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) endif LIBMANAGEMENT_EXT_OPTIMIZATION := HIGH -ifneq ($(findstring $(OPENJDK_TARGET_OS), solaris linux), ) +ifeq ($(call isTargetOs, solaris linux), true) ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true) LIBMANAGEMENT_EXT_OPTIMIZATION := LOW endif @@ -65,4 +65,3 @@ TARGETS += $(BUILD_LIBMANAGEMENT_EXT) # Include custom extension post hook $(eval $(call IncludeCustomExtension, lib/Lib-jdk.management-post.gmk)) - diff --git a/make/lib/Lib-jdk.net.gmk b/make/lib/Lib-jdk.net.gmk index b202c6373f7..7e828018950 100644 --- a/make/lib/Lib-jdk.net.gmk +++ b/make/lib/Lib-jdk.net.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifneq ($(filter $(OPENJDK_TARGET_OS), solaris linux macosx), ) +ifeq ($(call isTargetOs, solaris linux macosx), true) $(eval $(call SetupJdkLibrary, BUILD_LIBEXTNET, \ NAME := extnet, \ diff --git a/make/lib/Lib-jdk.sctp.gmk b/make/lib/Lib-jdk.sctp.gmk index d8ec372fa2e..af3630f73c6 100644 --- a/make/lib/Lib-jdk.sctp.gmk +++ b/make/lib/Lib-jdk.sctp.gmk @@ -27,9 +27,9 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS_TYPE), unix) +ifeq ($(call isTargetOsType, unix), true) - ifeq ($(filter $(OPENJDK_TARGET_OS), macosx aix), ) + ifeq ($(call isTargetOs, macosx aix), false) $(eval $(call SetupJdkLibrary, BUILD_LIBSCTP, \ NAME := sctp, \ OPTIMIZATION := LOW, \ diff --git a/make/test/BuildFailureHandler.gmk b/make/test/BuildFailureHandler.gmk index 0dca6f3663d..8433a5cc866 100644 --- a/make/test/BuildFailureHandler.gmk +++ b/make/test/BuildFailureHandler.gmk @@ -61,7 +61,7 @@ TARGETS += $(BUILD_FAILURE_HANDLER) ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) $(eval $(call SetupNativeCompilation, BUILD_LIBTIMEOUT_HANDLER, \ NAME := timeoutHandler, \ @@ -99,7 +99,7 @@ IMAGES_TARGETS += $(COPY_FH) # RUN_DIR := $(FH_SUPPORT)/test # Add the dir of the dll to the path on windows -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) export PATH := $(PATH);$(FH_SUPPORT) endif diff --git a/make/test/JtregNativeHotspot.gmk b/make/test/JtregNativeHotspot.gmk index c9682f4c15c..ee287f212ae 100644 --- a/make/test/JtregNativeHotspot.gmk +++ b/make/test/JtregNativeHotspot.gmk @@ -140,7 +140,7 @@ NSK_AOD_INCLUDES := \ -I$(VM_TESTBASE_DIR)/nsk/share/jni NO_FRAMEPOINTER_CFLAGS := -ifeq ($(OPENJDK_TARGET_OS),linux) +ifeq ($(call isTargetOs, linux), true) NO_FRAMEPOINTER_CFLAGS := -fomit-frame-pointer endif @@ -849,11 +849,11 @@ BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libVirtualMachine09agent00 := $(NSK_AOD_INC ################################################################################ # Platform specific setup -ifneq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc) +ifeq ($(call And, $(call isTargetOs, solaris) $(call isTargetCpuArch, sparc)), false) BUILD_HOTSPOT_JTREG_EXCLUDE += liboverflow.c exeThreadSignalMask.c endif -ifeq ($(OPENJDK_TARGET_OS), linux) +ifeq ($(call isTargetOs, linux), true) BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libtest-rw := -z noexecstack BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libtest-rwx := -z execstack BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libstepBreakPopReturn := -lpthread @@ -870,11 +870,11 @@ endif BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exesigtest := -ljvm -ifeq ($(OPENJDK_TARGET_OS), solaris) +ifeq ($(call isTargetOs, solaris), true) BUILD_HOTSPOT_JTREG_EXCLUDE += libterminatedThread.c endif -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) BUILD_HOTSPOT_JTREG_EXECUTABLES_CFLAGS_exeFPRegs := -MT BUILD_HOTSPOT_JTREG_EXCLUDE += exesigtest.c libterminatedThread.c diff --git a/make/test/JtregNativeJdk.gmk b/make/test/JtregNativeJdk.gmk index 40abb4c0de1..aea390e71a9 100644 --- a/make/test/JtregNativeJdk.gmk +++ b/make/test/JtregNativeJdk.gmk @@ -54,7 +54,7 @@ BUILD_JDK_JTREG_EXECUTABLES_CFLAGS_exeJliLaunchTest := \ -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjli # Platform specific setup -ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(call isTargetOs, windows), true) BUILD_JDK_JTREG_EXCLUDE += libDirectIO.c libInheritedChannel.c WIN_LIB_JAVA := $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib @@ -64,15 +64,15 @@ ifeq ($(OPENJDK_TARGET_OS), windows) else BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := -ljava BUILD_JDK_JTREG_LIBRARIES_LIBS_libDirectIO := -ljava - ifeq ($(OPENJDK_TARGET_OS), linux) + ifeq ($(call isTargetOs, linux), true) BUILD_JDK_JTREG_LIBRARIES_LIBS_libInheritedChannel := -ljava - else ifeq ($(OPENJDK_TARGET_OS), solaris) + else ifeq ($(call isTargetOs, solaris), true) BUILD_JDK_JTREG_LIBRARIES_LIBS_libInheritedChannel := -ljava -lsocket -lnsl endif BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeJliLaunchTest := -ljli endif -ifeq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(call isTargetOs, macosx), true) BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libTestMainKeyWindow := -ObjC BUILD_JDK_JTREG_LIBRARIES_LIBS_libTestMainKeyWindow := -framework JavaVM \ -framework Cocoa -framework JavaNativeFoundation diff --git a/test/make/TestMakeBase.gmk b/test/make/TestMakeBase.gmk index 1b6d1344b20..9ea0913b5d1 100644 --- a/test/make/TestMakeBase.gmk +++ b/test/make/TestMakeBase.gmk @@ -115,6 +115,28 @@ ifneq ($(call equals, $(EQUALS_VALUE2), $(EQUALS_EMPTY)), ) $(error The strings >$(EQUALS_VALUE2)< and >$(EQUALS_EMPTY)< are equal) endif +################################################################################ +# Test boolean operators + +$(eval $(call assert-equals, $(call And, true true true ), true)) +$(eval $(call assert-equals, $(call And, true false true ), false)) +$(eval $(call assert-equals, $(call And, false false false ), false)) +$(eval $(call assert-equals, $(call And, true), true)) +$(eval $(call assert-equals, $(call And, false), false)) +$(eval $(call assert-equals, $(call And, ), true)) + +$(eval $(call assert-equals, $(call Or, true true true ), true)) +$(eval $(call assert-equals, $(call Or, true false true ), true)) +$(eval $(call assert-equals, $(call Or, false false false ), false)) +$(eval $(call assert-equals, $(call Or, true), true)) +$(eval $(call assert-equals, $(call Or, false), false)) +$(eval $(call assert-equals, $(call Or, ), false)) + +# We cannot catch $(error) while testing, but you can enable this manually +# by uncommenting and watch make fails. +#$(eval $(call assert-equals, $(call And, non-boolean ), $(error ...))) +#$(eval $(call assert-equals, $(call Or, non-boolean ), $(error ...))) + ################################################################################ # Test remove-prefixes diff --git a/test/make/UtilsForTests.gmk b/test/make/UtilsForTests.gmk index a59bb693f76..e2c62007332 100644 --- a/test/make/UtilsForTests.gmk +++ b/test/make/UtilsForTests.gmk @@ -37,6 +37,6 @@ endef # On macosx, file system timestamps only have 1 second resultion so must add # sleeps to properly test dependencies. -ifeq ($(OPENJDK_BUILD_OS), macosx) +ifeq ($(call isBuildOs, macosx), true) SLEEP_ON_MAC := sleep 1 endif From 63663b64d1520b72221e5d5a452fa36c4a0f86cc Mon Sep 17 00:00:00 2001 From: Sean Coffey Date: Thu, 7 Feb 2019 12:09:17 +0000 Subject: [PATCH 006/101] 8218553: Enhance keystore load debug output Reviewed-by: weijun --- .../classes/apple/security/KeychainStore.java | 8 ++++++- .../com/sun/crypto/provider/JceKeyStore.java | 22 ++++++++++++++----- .../sun/security/pkcs12/PKCS12KeyStore.java | 15 +++---------- .../sun/security/provider/JavaKeyStore.java | 17 ++++++++++---- .../sun/security/pkcs11/P11KeyStore.java | 4 +++- .../sun/security/mscapi/CKeyStore.java | 10 ++++++++- 6 files changed, 52 insertions(+), 24 deletions(-) diff --git a/src/java.base/macosx/classes/apple/security/KeychainStore.java b/src/java.base/macosx/classes/apple/security/KeychainStore.java index 7ed9956b80c..9f17704508b 100644 --- a/src/java.base/macosx/classes/apple/security/KeychainStore.java +++ b/src/java.base/macosx/classes/apple/security/KeychainStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, 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 @@ -102,6 +102,8 @@ public final class KeychainStore extends KeyStoreSpi { private static final int iterationCount = 1024; private static final int SALT_LEN = 20; + private static final Debug debug = Debug.getInstance("keystore"); + static { AccessController.doPrivileged( new PrivilegedAction() { @@ -773,6 +775,10 @@ public final class KeychainStore extends KeyStoreSpi { entries.clear(); _scanKeychain(); + if (debug != null) { + debug.println("KeychainStore load entry count: " + + entries.size()); + } } } diff --git a/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java b/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java index bceb60da76d..e1ee770fa10 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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 @@ -25,6 +25,8 @@ package com.sun.crypto.provider; +import sun.security.util.Debug; + import java.io.*; import java.util.*; import java.security.AccessController; @@ -59,6 +61,7 @@ import javax.crypto.SealedObject; public final class JceKeyStore extends KeyStoreSpi { + private static final Debug debug = Debug.getInstance("keystore"); private static final int JCEKS_MAGIC = 0xcececece; private static final int JKS_MAGIC = 0xfeedfeed; private static final int VERSION_1 = 0x01; @@ -680,6 +683,7 @@ public final class JceKeyStore extends KeyStoreSpi { Hashtable cfs = null; ByteArrayInputStream bais = null; byte[] encoded = null; + int trustedKeyCount = 0, privateKeyCount = 0, secretKeyCount = 0; if (stream == null) return; @@ -726,7 +730,7 @@ public final class JceKeyStore extends KeyStoreSpi { tag = dis.readInt(); if (tag == 1) { // private-key entry - + privateKeyCount++; PrivateKeyEntry entry = new PrivateKeyEntry(); // read the alias @@ -786,7 +790,7 @@ public final class JceKeyStore extends KeyStoreSpi { entries.put(alias, entry); } else if (tag == 2) { // trusted certificate entry - + trustedKeyCount++; TrustedCertEntry entry = new TrustedCertEntry(); // read the alias @@ -825,7 +829,7 @@ public final class JceKeyStore extends KeyStoreSpi { entries.put(alias, entry); } else if (tag == 3) { // secret-key entry - + secretKeyCount++; SecretKeyEntry entry = new SecretKeyEntry(); // read the alias @@ -858,10 +862,18 @@ public final class JceKeyStore extends KeyStoreSpi { entries.put(alias, entry); } else { - throw new IOException("Unrecognized keystore entry"); + throw new IOException("Unrecognized keystore entry: " + + tag); } } + if (debug != null) { + debug.println("JceKeyStore load: private key count: " + + privateKeyCount + ". trusted key count: " + + trustedKeyCount + ". secret key count: " + + secretKeyCount); + } + /* * If a password has been provided, we check the keyed digest * at the end. If this check fails, the store has been tampered diff --git a/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java b/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java index 9c6623888c9..e40cffa51be 100644 --- a/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java +++ b/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java @@ -2231,18 +2231,9 @@ public final class PKCS12KeyStore extends KeyStoreSpi { } if (debug != null) { - if (privateKeyCount > 0) { - debug.println("Loaded " + privateKeyCount + - " protected private key(s)"); - } - if (secretKeyCount > 0) { - debug.println("Loaded " + secretKeyCount + - " protected secret key(s)"); - } - if (certificateCount > 0) { - debug.println("Loaded " + certificateCount + - " certificate(s)"); - } + debug.println("PKCS12KeyStore load: private key count: " + + privateKeyCount + ". secret key count: " + secretKeyCount + + ". certificate count: " + certificateCount); } certEntries.clear(); diff --git a/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java b/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java index c0a1455cf5b..49b3550ef3d 100644 --- a/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java +++ b/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -34,6 +34,7 @@ import java.util.*; import sun.security.pkcs.EncryptedPrivateKeyInfo; import sun.security.pkcs12.PKCS12KeyStore; +import sun.security.util.Debug; import sun.security.util.IOUtils; import sun.security.util.KeyStoreDelegator; @@ -74,6 +75,7 @@ public abstract class JavaKeyStore extends KeyStoreSpi { } } + private static final Debug debug = Debug.getInstance("keystore"); private static final int MAGIC = 0xfeedfeed; private static final int VERSION_1 = 0x01; private static final int VERSION_2 = 0x02; @@ -643,6 +645,7 @@ public abstract class JavaKeyStore extends KeyStoreSpi { Hashtable cfs = null; ByteArrayInputStream bais = null; byte[] encoded = null; + int trustedKeyCount = 0, privateKeyCount = 0; if (stream == null) return; @@ -681,7 +684,7 @@ public abstract class JavaKeyStore extends KeyStoreSpi { tag = dis.readInt(); if (tag == 1) { // private key entry - + privateKeyCount++; KeyEntry entry = new KeyEntry(); // Read the alias @@ -730,7 +733,7 @@ public abstract class JavaKeyStore extends KeyStoreSpi { entries.put(alias, entry); } else if (tag == 2) { // trusted certificate entry - + trustedKeyCount++; TrustedCertEntry entry = new TrustedCertEntry(); // Read the alias @@ -765,10 +768,16 @@ public abstract class JavaKeyStore extends KeyStoreSpi { entries.put(alias, entry); } else { - throw new IOException("Unrecognized keystore entry"); + throw new IOException("Unrecognized keystore entry: " + + tag); } } + if (debug != null) { + debug.println("JavaKeyStore load: private key count: " + + privateKeyCount + ". trusted key count: " + trustedKeyCount); + } + /* * If a password has been provided, we check the keyed digest * at the end. If this check fails, the store has been tampered diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java index d66262ae1b4..c9c2362bcc1 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -772,6 +772,8 @@ final class P11KeyStore extends KeyStoreSpi { } if (debug != null) { dumpTokenMap(); + debug.println("P11KeyStore load. Entry count: " + + aliasMap.size()); } } catch (KeyStoreException | PKCS11Exception e) { throw new IOException("load failed", e); diff --git a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CKeyStore.java b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CKeyStore.java index 2a79bd79542..c90fa4f4d23 100644 --- a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CKeyStore.java +++ b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CKeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -45,6 +45,8 @@ import java.security.cert.CertificateFactory; import java.security.interfaces.RSAPrivateCrtKey; import java.util.*; +import sun.security.util.Debug; + /** * Implementation of key store for Windows using the Microsoft Crypto API. * @@ -180,6 +182,7 @@ abstract class CKeyStore extends KeyStoreSpi { private static final String KEYSTORE_COMPATIBILITY_MODE_PROP = "sun.security.mscapi.keyStoreCompatibilityMode"; private final boolean keyStoreCompatibilityMode; + private static final Debug debug = Debug.getInstance("keystore"); /* * The keystore entries. @@ -710,6 +713,11 @@ abstract class CKeyStore extends KeyStoreSpi { } catch (KeyStoreException e) { throw new IOException(e); } + + if (debug != null) { + debug.println("MSCAPI keystore load: entry count: " + + entries.size()); + } } /** From d5e0b71435811a82b36ff8a7aaa8a6c3b377f22e Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Thu, 7 Feb 2019 14:29:17 -0500 Subject: [PATCH 007/101] 8218558: NMT stack traces in output should show mt component for virtual memory allocations Reviewed-by: shade, stuefe, coleenp --- src/hotspot/share/services/allocationSite.hpp | 6 +++- .../share/services/mallocSiteTable.cpp | 4 +-- .../share/services/mallocSiteTable.hpp | 8 ++--- src/hotspot/share/services/memBaseline.cpp | 6 ++-- src/hotspot/share/services/memReporter.cpp | 29 ++++++++++++------- src/hotspot/share/services/memReporter.hpp | 2 +- .../share/services/virtualMemoryTracker.hpp | 4 +-- 7 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/hotspot/share/services/allocationSite.hpp b/src/hotspot/share/services/allocationSite.hpp index e09773a3e4d..95ee196dd45 100644 --- a/src/hotspot/share/services/allocationSite.hpp +++ b/src/hotspot/share/services/allocationSite.hpp @@ -25,6 +25,7 @@ #ifndef SHARE_SERVICES_ALLOCATIONSITE_HPP #define SHARE_SERVICES_ALLOCATIONSITE_HPP +#include "memory/allocation.hpp" #include "utilities/nativeCallStack.hpp" // Allocation site represents a code path that makes a memory @@ -33,8 +34,9 @@ template class AllocationSite { private: NativeCallStack _call_stack; E e; + MEMFLAGS _flag; public: - AllocationSite(const NativeCallStack& stack) : _call_stack(stack) { } + AllocationSite(const NativeCallStack& stack, MEMFLAGS flag) : _call_stack(stack), _flag(flag) { } int hash() const { return _call_stack.hash(); } bool equals(const NativeCallStack& stack) const { return _call_stack.equals(stack); @@ -51,6 +53,8 @@ template class AllocationSite { // Information regarding this allocation E* data() { return &e; } const E* peek() const { return &e; } + + MEMFLAGS flag() const { return _flag; } }; #endif // SHARE_SERVICES_ALLOCATIONSITE_HPP diff --git a/src/hotspot/share/services/mallocSiteTable.cpp b/src/hotspot/share/services/mallocSiteTable.cpp index 4ce80421e27..d557aa438b6 100644 --- a/src/hotspot/share/services/mallocSiteTable.cpp +++ b/src/hotspot/share/services/mallocSiteTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -138,7 +138,7 @@ MallocSite* MallocSiteTable::lookup_or_add(const NativeCallStack& key, size_t* b MallocSiteHashtableEntry* head = _table[index]; while (head != NULL && (*pos_idx) <= MAX_BUCKET_LENGTH) { MallocSite* site = head->data(); - if (site->flags() == flags && site->equals(key)) { + if (site->flag() == flags && site->equals(key)) { return head->data(); } diff --git a/src/hotspot/share/services/mallocSiteTable.hpp b/src/hotspot/share/services/mallocSiteTable.hpp index 3dec32f7f4f..ee34d97c2e8 100644 --- a/src/hotspot/share/services/mallocSiteTable.hpp +++ b/src/hotspot/share/services/mallocSiteTable.hpp @@ -37,15 +37,12 @@ // MallocSite represents a code path that eventually calls // os::malloc() to allocate memory class MallocSite : public AllocationSite { - private: - MEMFLAGS _flags; - public: MallocSite() : - AllocationSite(NativeCallStack::empty_stack()), _flags(mtNone) {} + AllocationSite(NativeCallStack::empty_stack(), mtNone) {} MallocSite(const NativeCallStack& stack, MEMFLAGS flags) : - AllocationSite(stack), _flags(flags) {} + AllocationSite(stack, flags) {} void allocate(size_t size) { data()->allocate(size); } @@ -55,7 +52,6 @@ class MallocSite : public AllocationSite { size_t size() const { return peek()->size(); } // The number of calls were made size_t count() const { return peek()->count(); } - MEMFLAGS flags() const { return (MEMFLAGS)_flags; } }; // Malloc site hashtable entry diff --git a/src/hotspot/share/services/memBaseline.cpp b/src/hotspot/share/services/memBaseline.cpp index b348e7542e3..b0a8b20ea0b 100644 --- a/src/hotspot/share/services/memBaseline.cpp +++ b/src/hotspot/share/services/memBaseline.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -64,7 +64,7 @@ int compare_malloc_site(const MallocSite& s1, const MallocSite& s2) { int compare_malloc_site_and_type(const MallocSite& s1, const MallocSite& s2) { int res = compare_malloc_site(s1, s2); if (res == 0) { - res = (int)(s1.flags() - s2.flags()); + res = (int)(s1.flag() - s2.flag()); } return res; @@ -212,7 +212,7 @@ bool MemBaseline::aggregate_virtual_memory_allocation_sites() { const ReservedMemoryRegion* rgn; VirtualMemoryAllocationSite* site; while ((rgn = itr.next()) != NULL) { - VirtualMemoryAllocationSite tmp(*rgn->call_stack()); + VirtualMemoryAllocationSite tmp(*rgn->call_stack(), rgn->flag()); site = allocation_sites.find(tmp); if (site == NULL) { LinkedListNode* node = diff --git a/src/hotspot/share/services/memReporter.cpp b/src/hotspot/share/services/memReporter.cpp index d83c915d3f6..b51783b3123 100644 --- a/src/hotspot/share/services/memReporter.cpp +++ b/src/hotspot/share/services/memReporter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -240,7 +240,7 @@ void MemDetailReporter::report_malloc_sites() { const NativeCallStack* stack = malloc_site->call_stack(); stack->print_on(out); out->print("%29s", " "); - MEMFLAGS flag = malloc_site->flags(); + MEMFLAGS flag = malloc_site->flag(); assert((flag >= 0 && flag < (int)mt_number_of_types) && flag != mtNone, "Must have a valid memory type"); print_malloc(malloc_site->size(), malloc_site->count(),flag); @@ -266,6 +266,10 @@ void MemDetailReporter::report_virtual_memory_allocation_sites() { stack->print_on(out); out->print("%28s (", " "); print_total(virtual_memory_site->reserved(), virtual_memory_site->committed()); + MEMFLAGS flag = virtual_memory_site->flag(); + if (flag != mtNone) { + out->print(" Type=%s", NMTUtil::flag_to_name(flag)); + } out->print_cr(")\n"); } } @@ -690,19 +694,19 @@ void MemDetailDiffReporter::diff_virtual_memory_sites() const { void MemDetailDiffReporter::new_malloc_site(const MallocSite* malloc_site) const { diff_malloc_site(malloc_site->call_stack(), malloc_site->size(), malloc_site->count(), - 0, 0, malloc_site->flags()); + 0, 0, malloc_site->flag()); } void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const { diff_malloc_site(malloc_site->call_stack(), 0, 0, malloc_site->size(), - malloc_site->count(), malloc_site->flags()); + malloc_site->count(), malloc_site->flag()); } void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early, const MallocSite* current) const { - assert(early->flags() == current->flags(), "Must be the same memory type"); + assert(early->flag() == current->flag(), "Must be the same memory type"); diff_malloc_site(current->call_stack(), current->size(), current->count(), - early->size(), early->count(), early->flags()); + early->size(), early->count(), early->flag()); } void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_t current_size, @@ -725,21 +729,22 @@ void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_ void MemDetailDiffReporter::new_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { - diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0); + diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0, site->flag()); } void MemDetailDiffReporter::old_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { - diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed()); + diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed(), site->flag()); } void MemDetailDiffReporter::diff_virtual_memory_site(const VirtualMemoryAllocationSite* early, const VirtualMemoryAllocationSite* current) const { + assert(early->flag() == current->flag(), "Should be the same"); diff_virtual_memory_site(current->call_stack(), current->reserved(), current->committed(), - early->reserved(), early->committed()); + early->reserved(), early->committed(), current->flag()); } void MemDetailDiffReporter::diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, - size_t current_committed, size_t early_reserved, size_t early_committed) const { + size_t current_committed, size_t early_reserved, size_t early_committed, MEMFLAGS flag) const { outputStream* out = output(); // no change @@ -753,5 +758,9 @@ void MemDetailDiffReporter::diff_virtual_memory_site(const NativeCallStack* stac print_virtual_memory_diff(current_reserved, current_committed, early_reserved, early_committed); + if (flag != mtNone) { + out->print(" Type=%s", NMTUtil::flag_to_name(flag)); + } + out->print_cr(")\n"); } diff --git a/src/hotspot/share/services/memReporter.hpp b/src/hotspot/share/services/memReporter.hpp index 4f4bab375d5..6685c102efc 100644 --- a/src/hotspot/share/services/memReporter.hpp +++ b/src/hotspot/share/services/memReporter.hpp @@ -230,7 +230,7 @@ class MemDetailDiffReporter : public MemSummaryDiffReporter { void diff_malloc_site(const NativeCallStack* stack, size_t current_size, size_t currrent_count, size_t early_size, size_t early_count, MEMFLAGS flags) const; void diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, - size_t current_committed, size_t early_reserved, size_t early_committed) const; + size_t current_committed, size_t early_reserved, size_t early_committed, MEMFLAGS flag) const; }; #endif // INCLUDE_NMT diff --git a/src/hotspot/share/services/virtualMemoryTracker.hpp b/src/hotspot/share/services/virtualMemoryTracker.hpp index d0ac98151c3..aaea4d3fb4e 100644 --- a/src/hotspot/share/services/virtualMemoryTracker.hpp +++ b/src/hotspot/share/services/virtualMemoryTracker.hpp @@ -70,8 +70,8 @@ class VirtualMemory { // Virtual memory allocation site, keeps track where the virtual memory is reserved. class VirtualMemoryAllocationSite : public AllocationSite { public: - VirtualMemoryAllocationSite(const NativeCallStack& stack) : - AllocationSite(stack) { } + VirtualMemoryAllocationSite(const NativeCallStack& stack, MEMFLAGS flag) : + AllocationSite(stack, flag) { } inline void reserve_memory(size_t sz) { data()->reserve_memory(sz); } inline void commit_memory (size_t sz) { data()->commit_memory(sz); } From 7049e4c4434b248abb0cd270dc0be892ff355d8e Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Thu, 7 Feb 2019 22:20:46 +0100 Subject: [PATCH 008/101] 8218625: Remove dead code in relocInfo Reviewed-by: kvn, thartmann --- src/hotspot/cpu/arm/arm.ad | 2 +- src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp | 6 +- .../arm/gc/g1/g1BarrierSetAssembler_arm.cpp | 2 +- .../arm/gc/shared/barrierSetAssembler_arm.cpp | 2 +- .../cardTableBarrierSetAssembler_arm.cpp | 4 +- src/hotspot/cpu/arm/macroAssembler_arm.hpp | 9 +- src/hotspot/cpu/arm/stubGenerator_arm.cpp | 4 +- src/hotspot/share/code/relocInfo.cpp | 41 +-------- src/hotspot/share/code/relocInfo.hpp | 11 --- src/hotspot/share/code/relocInfo_ext.cpp | 88 ------------------- src/hotspot/share/code/relocInfo_ext.hpp | 61 ------------- 11 files changed, 14 insertions(+), 216 deletions(-) delete mode 100644 src/hotspot/share/code/relocInfo_ext.cpp delete mode 100644 src/hotspot/share/code/relocInfo_ext.hpp diff --git a/src/hotspot/cpu/arm/arm.ad b/src/hotspot/cpu/arm/arm.ad index 49394291888..354749c0d04 100644 --- a/src/hotspot/cpu/arm/arm.ad +++ b/src/hotspot/cpu/arm/arm.ad @@ -352,7 +352,7 @@ void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { // If this does safepoint polling, then do it here if (do_polling() && ra_->C->is_method_compilation()) { // mov_slow here is usually one or two instruction - __ mov_address(Rtemp, (address)os::get_polling_page(), symbolic_Relocation::polling_page_reference); + __ mov_address(Rtemp, (address)os::get_polling_page()); __ relocate(relocInfo::poll_return_type); __ ldr(Rtemp, Address(Rtemp)); } diff --git a/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp index 43573d69531..ffd43403217 100644 --- a/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2019, 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 @@ -309,7 +309,7 @@ void LIR_Assembler::return_op(LIR_Opr result) { __ remove_frame(initial_frame_size_in_bytes()); // mov_slow here is usually one or two instruction - __ mov_address(Rtemp, os::get_polling_page(), symbolic_Relocation::polling_page_reference); + __ mov_address(Rtemp, os::get_polling_page()); __ relocate(relocInfo::poll_return_type); __ ldr(Rtemp, Address(Rtemp)); __ ret(); @@ -317,7 +317,7 @@ void LIR_Assembler::return_op(LIR_Opr result) { int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) { - __ mov_address(Rtemp, os::get_polling_page(), symbolic_Relocation::polling_page_reference); + __ mov_address(Rtemp, os::get_polling_page()); if (info != NULL) { add_debug_info_for_branch(info); } diff --git a/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp b/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp index d695107ea93..7c6452cb3cf 100644 --- a/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp @@ -218,7 +218,7 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, const Register card_addr = tmp1; assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code"); - __ mov_address(tmp2, (address)ct->byte_map_base(), symbolic_Relocation::card_table_reference); + __ mov_address(tmp2, (address)ct->byte_map_base()); __ add(card_addr, tmp2, AsmOperand(store_addr, lsr, CardTable::card_shift)); __ ldrb(tmp2, Address(card_addr)); diff --git a/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp b/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp index d73364f1310..586b479594a 100644 --- a/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp @@ -167,7 +167,7 @@ void BarrierSetAssembler::eden_allocate(MacroAssembler* masm, Register obj, Regi bool load_const = VM_Version::supports_movw(); if (load_const) { - __ mov_address(top_addr, (address)Universe::heap()->top_addr(), symbolic_Relocation::eden_top_reference); + __ mov_address(top_addr, (address)Universe::heap()->top_addr()); } else { __ ldr(top_addr, Address(Rthread, JavaThread::heap_top_addr_offset())); } diff --git a/src/hotspot/cpu/arm/gc/shared/cardTableBarrierSetAssembler_arm.cpp b/src/hotspot/cpu/arm/gc/shared/cardTableBarrierSetAssembler_arm.cpp index 50f5b9a4aec..e58992bb354 100644 --- a/src/hotspot/cpu/arm/gc/shared/cardTableBarrierSetAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/gc/shared/cardTableBarrierSetAssembler_arm.cpp @@ -61,7 +61,7 @@ void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembl __ sub(count, count, addr); // nb of cards // warning: Rthread has not been preserved - __ mov_address(tmp, (address) ct->byte_map_base(), symbolic_Relocation::card_table_reference); + __ mov_address(tmp, (address) ct->byte_map_base()); __ add(addr,tmp, addr); Register zero = __ zero_register(tmp); @@ -119,7 +119,7 @@ void CardTableBarrierSetAssembler::store_check_part1(MacroAssembler* masm, Regis Possible cause is a cache miss (card table base address resides in a rarely accessed area of thread descriptor). */ - __ mov_address(card_table_base, (address)ct->byte_map_base(), symbolic_Relocation::card_table_reference); + __ mov_address(card_table_base, (address)ct->byte_map_base()); } // The 2nd part of the store check. diff --git a/src/hotspot/cpu/arm/macroAssembler_arm.hpp b/src/hotspot/cpu/arm/macroAssembler_arm.hpp index 91ed05a5a08..2e2cd62f23f 100644 --- a/src/hotspot/cpu/arm/macroAssembler_arm.hpp +++ b/src/hotspot/cpu/arm/macroAssembler_arm.hpp @@ -26,7 +26,6 @@ #define CPU_ARM_MACROASSEMBLER_ARM_HPP #include "code/relocInfo.hpp" -#include "code/relocInfo_ext.hpp" class BiasedLockingCounters; @@ -513,15 +512,13 @@ public: } } - // Runtime address that may vary from one execution to another. The - // symbolic_reference describes what the address is, allowing - // the address to be resolved in a different execution context. + // Runtime address that may vary from one execution to another. // Warning: do not implement as a PC relative address. - void mov_address(Register rd, address addr, symbolic_Relocation::symbolic_reference t) { + void mov_address(Register rd, address addr) { mov_address(rd, addr, RelocationHolder::none); } - // rspec can be RelocationHolder::none (for ignored symbolic_Relocation). + // rspec can be RelocationHolder::none (for ignored symbolic Relocation). // In that case, the address is absolute and the generated code need // not be relocable. void mov_address(Register rd, address addr, RelocationHolder const& rspec) { diff --git a/src/hotspot/cpu/arm/stubGenerator_arm.cpp b/src/hotspot/cpu/arm/stubGenerator_arm.cpp index a06677b5707..0c9d0bbe5c4 100644 --- a/src/hotspot/cpu/arm/stubGenerator_arm.cpp +++ b/src/hotspot/cpu/arm/stubGenerator_arm.cpp @@ -820,9 +820,9 @@ class StubGenerator: public StubCodeGenerator { // Note: oop_mask and oop_bits must be updated if the code is saved/reused const address oop_mask = (address) Universe::verify_oop_mask(); const address oop_bits = (address) Universe::verify_oop_bits(); - __ mov_address(tmp1, oop_mask, symbolic_Relocation::oop_mask_reference); + __ mov_address(tmp1, oop_mask); __ andr(tmp2, oop, tmp1); - __ mov_address(tmp1, oop_bits, symbolic_Relocation::oop_bits_reference); + __ mov_address(tmp1, oop_bits); __ cmp(tmp2, tmp1); __ b(error, ne); diff --git a/src/hotspot/share/code/relocInfo.cpp b/src/hotspot/share/code/relocInfo.cpp index 875ef907185..f5ac0cef30e 100644 --- a/src/hotspot/share/code/relocInfo.cpp +++ b/src/hotspot/share/code/relocInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -92,18 +92,6 @@ void relocInfo::set_type(relocType t) { assert(format()==old_format, "sanity check"); } -nmethod* RelocIterator::code_as_nmethod() const { - return _code->as_nmethod(); -} - -void relocInfo::set_format(int f) { - int old_offset = addr_offset(); - assert((f & format_mask) == f, "wrong format"); - _value = (_value & ~(format_mask << offset_width)) | (f << offset_width); - assert(addr_offset()==old_offset, "sanity check"); -} - - void relocInfo::change_reloc_info_for_address(RelocIterator *itr, address pc, relocType old_type, relocType new_type) { bool found = false; while (itr->next() && !found) { @@ -117,11 +105,6 @@ void relocInfo::change_reloc_info_for_address(RelocIterator *itr, address pc, re } -void relocInfo::remove_reloc_info_for_address(RelocIterator *itr, address pc, relocType old_type) { - change_reloc_info_for_address(itr, pc, old_type, none); -} - - // ---------------------------------------------------------------------------------------------------- // Implementation of RelocIterator @@ -179,14 +162,6 @@ RelocIterator::RelocIterator(CodeSection* cs, address begin, address limit) { set_limits(begin, limit); } - -enum { indexCardSize = 128 }; -struct RelocIndexEntry { - jint addr_offset; // offset from header_end of an addr() - jint reloc_offset; // offset from header_end of a relocInfo (prefix) -}; - - bool RelocIterator::addr_in_const() const { const int n = CodeBuffer::SECT_CONSTS; return section_start(n) <= addr() && addr() < section_end(n); @@ -215,12 +190,6 @@ void RelocIterator::set_limits(address begin, address limit) { } -void RelocIterator::set_limit(address limit) { - address code_end = (address)code() + code()->size(); - assert(limit == NULL || limit <= code_end, "in bounds"); - _limit = limit; -} - // All the strange bit-encodings are in here. // The idea is to encode relocation data which are small integers // very efficiently (a single extra halfword). Larger chunks of @@ -622,14 +591,6 @@ void metadata_Relocation::fix_metadata_relocation() { } } - -void metadata_Relocation::verify_metadata_relocation() { - if (!metadata_is_immediate()) { - // get the metadata from the pool, and re-insert it into the instruction: - verify_value(value()); - } -} - address virtual_call_Relocation::cached_value() { assert(_cached_value != NULL && _cached_value < addr(), "must precede ic_call"); return _cached_value; diff --git a/src/hotspot/share/code/relocInfo.hpp b/src/hotspot/share/code/relocInfo.hpp index 4e073c19081..26d1c5141c9 100644 --- a/src/hotspot/share/code/relocInfo.hpp +++ b/src/hotspot/share/code/relocInfo.hpp @@ -345,7 +345,6 @@ class relocInfo { static int offset_limit() { return (1 << offset_width) * offset_unit; } void set_type(relocType type); - void set_format(int format); void remove() { set_type(none); } @@ -422,7 +421,6 @@ class relocInfo { // (since code is dynamically patched, we also need to dynamically update the relocation info) // Both methods takes old_type, so it is able to performe sanity checks on the information removed. static void change_reloc_info_for_address(RelocIterator *itr, address pc, relocType old_type, relocType new_type); - static void remove_reloc_info_for_address(RelocIterator *itr, address pc, relocType old_type); // Machine dependent stuff #include CPU_HEADER(relocInfo) @@ -531,7 +529,6 @@ class RelocIterator : public StackObj { short _databuf; // spare buffer for compressed data short* _data; // pointer to the relocation's data short _datalen; // number of halfwords in _data - char _format; // position within the instruction // Base addresses needed to compute targets of section_word_type relocs. address _section_start[SECT_LIMIT]; @@ -588,23 +585,18 @@ class RelocIterator : public StackObj { return false; } - if (relocInfo::have_format) _format = current()->format(); return true; } // accessors address limit() const { return _limit; } - void set_limit(address x); relocType type() const { return current()->type(); } int format() const { return (relocInfo::have_format) ? current()->format() : 0; } address addr() const { return _addr; } CompiledMethod* code() const { return _code; } - nmethod* code_as_nmethod() const; short* data() const { return _data; } int datalen() const { return _datalen; } bool has_current() const { return _datalen >= 0; } - - void set_addr(address addr) { _addr = addr; } bool addr_in_const() const; address section_start(int n) const { @@ -793,7 +785,6 @@ class Relocation { // accessors which only make sense for a bound Relocation address addr() const { return binding()->addr(); } CompiledMethod* code() const { return binding()->code(); } - nmethod* code_as_nmethod() const { return binding()->code_as_nmethod(); } bool addr_in_const() const { return binding()->addr_in_const(); } protected: short* data() const { return binding()->data(); } @@ -1002,8 +993,6 @@ class metadata_Relocation : public DataRelocation { void fix_metadata_relocation(); // reasserts metadata value - void verify_metadata_relocation(); - address value() { return (address) *metadata_addr(); } bool metadata_is_immediate() { return metadata_index() == 0; } diff --git a/src/hotspot/share/code/relocInfo_ext.cpp b/src/hotspot/share/code/relocInfo_ext.cpp deleted file mode 100644 index 510e90d0476..00000000000 --- a/src/hotspot/share/code/relocInfo_ext.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2015, 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 "code/codeCache.hpp" -#include "code/relocInfo.hpp" -#include "code/relocInfo_ext.hpp" -#include "gc/shared/cardTable.hpp" -#include "gc/shared/cardTableBarrierSet.hpp" -#include "gc/shared/collectedHeap.hpp" -#include "memory/universe.hpp" -#include "runtime/os.hpp" -#include "utilities/debug.hpp" -#ifdef COMPILER1 -#include "c1/c1_globals.hpp" -#endif - -address symbolic_Relocation::symbolic_value(symbolic_Relocation::symbolic_reference t) { - if (Universe::heap() == NULL) { - // the symbolic values are not needed so early - // (and most of them lead to errors if asked too early) - return NULL; - } - switch(t) { - case symbolic_Relocation::polling_page_reference: { - return os::get_polling_page(); - } - case symbolic_Relocation::eden_top_reference: { - if (!Universe::heap()->supports_inline_contig_alloc()) { - return NULL; - } - return (address)Universe::heap()->top_addr(); - } - case symbolic_Relocation::heap_end_reference: { - if (!Universe::heap()->supports_inline_contig_alloc()) { - return NULL; - } - return (address)Universe::heap()->end_addr(); - } - case symbolic_Relocation::card_table_reference: { - BarrierSet* bs = BarrierSet::barrier_set(); - CardTableBarrierSet* ctbs = barrier_set_cast(bs); - CardTable* ct = ctbs->card_table(); - return (address)ct->byte_map_base(); - } - case symbolic_Relocation::mark_bits_reference: { - return (address)Universe::verify_mark_bits(); - } - case symbolic_Relocation::mark_mask_reference: { - return (address)Universe::verify_mark_mask(); - } - case symbolic_Relocation::oop_bits_reference: { - return (address)Universe::verify_oop_bits(); - } - case symbolic_Relocation::oop_mask_reference: { - return (address)Universe::verify_oop_mask(); - } - case symbolic_Relocation::debug_string_reference: { - return (address)""; - } - default: { - // missing declaration - ShouldNotReachHere(); - return NULL; - } - } -} diff --git a/src/hotspot/share/code/relocInfo_ext.hpp b/src/hotspot/share/code/relocInfo_ext.hpp deleted file mode 100644 index 49093b8422a..00000000000 --- a/src/hotspot/share/code/relocInfo_ext.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 2019, 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_CODE_RELOCINFO_EXT_HPP -#define SHARE_CODE_RELOCINFO_EXT_HPP - -// symbolic_Relocation allows to anotate some addresses in the generated code. -// -// This class was initially defined using the last unused relocType. The -// new version tries to limit the impact on open source code changes. -// -// Without compiled code support, symbolic_Relocation need not be a real -// relocation. To avoid using the last unused relocType, the -// symbolic_Relocation::spec() has been replaced -// by additional methods using directly the symbolic type. -// -// Note: the order of the arguments in some methods had to reversed -// to avoid confusion between the relocType enum and the -// symbolic_reference enum. -class symbolic_Relocation : AllStatic { - - public: - enum symbolic_reference { - card_table_reference, - eden_top_reference, - heap_end_reference, - polling_page_reference, - mark_bits_reference, - mark_mask_reference, - oop_bits_reference, - oop_mask_reference, - debug_string_reference, - last_symbolic_reference - }; - - // get the new value for a given symbolic type - static address symbolic_value(symbolic_reference t); -}; - -#endif // SHARE_CODE_RELOCINFO_EXT_HPP From e148e49c587f22897467b5a69209009200eac227 Mon Sep 17 00:00:00 2001 From: Bob Vandette Date: Thu, 7 Feb 2019 17:23:24 -0500 Subject: [PATCH 009/101] 8218169: [AOT] Segmentation fault when running java with AOTed Graal in -Xcomp mode on windows Reviewed-by: kvn --- src/hotspot/os/windows/os_windows.cpp | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 4e2c1d49631..abe2b2be714 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -125,6 +125,11 @@ static FILETIME process_kernel_time; #define __CPU__ i486 #endif +#if INCLUDE_AOT +PVOID topLevelVectoredExceptionHandler = NULL; +LONG WINAPI topLevelVectoredExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo); +#endif + // save DLL module handle, used by GetModuleFileName HINSTANCE vm_lib_handle; @@ -143,6 +148,12 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { if (ForceTimeHighResolution) { timeEndPeriod(1L); } +#if INCLUDE_AOT + if (topLevelVectoredExceptionHandler != NULL) { + RemoveVectoredExceptionHandler(topLevelVectoredExceptionHandler); + topLevelVectoredExceptionHandler = NULL; + } +#endif break; default: break; @@ -2325,6 +2336,25 @@ bool os::win32::get_frame_at_stack_banging_point(JavaThread* thread, return true; } +#if INCLUDE_AOT +LONG WINAPI topLevelVectoredExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) { + PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; + address addr = (address) exceptionRecord->ExceptionInformation[1]; + address pc = (address) exceptionInfo->ContextRecord->Rip; + + // Handle the case where we get an implicit exception in AOT generated + // code. AOT DLL's loaded are not registered for structured exceptions. + // If the exception occurred in the codeCache or AOT code, pass control + // to our normal exception handler. + CodeBlob* cb = CodeCache::find_blob(pc); + if (cb != NULL) { + return topLevelExceptionFilter(exceptionInfo); + } + + return EXCEPTION_CONTINUE_SEARCH; +} +#endif + //----------------------------------------------------------------------------- LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) { if (InterceptOSException) return EXCEPTION_CONTINUE_SEARCH; @@ -4080,6 +4110,16 @@ jint os::init_2(void) { // Setup Windows Exceptions +#if INCLUDE_AOT + // If AOT is enabled we need to install a vectored exception handler + // in order to forward implicit exceptions from code in AOT + // generated DLLs. This is necessary since these DLLs are not + // registered for structured exceptions like codecache methods are. + if (UseAOT) { + topLevelVectoredExceptionHandler = AddVectoredExceptionHandler( 1, topLevelVectoredExceptionFilter); + } +#endif + // for debugging float code generation bugs if (ForceFloatExceptions) { #ifndef _WIN64 From 175b462a778c139ae5500ae670a4d8fdb3df30e7 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Thu, 7 Feb 2019 17:26:44 -0500 Subject: [PATCH 010/101] 8218601: [AOT] Crash in AOTCodeHeap::mark_evol_dependent_methods Null check nmethod in aot dependencies Reviewed-by: kvn --- src/hotspot/share/aot/aotCodeHeap.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/aot/aotCodeHeap.cpp b/src/hotspot/share/aot/aotCodeHeap.cpp index 02ab377f367..af4013ef5bd 100644 --- a/src/hotspot/share/aot/aotCodeHeap.cpp +++ b/src/hotspot/share/aot/aotCodeHeap.cpp @@ -707,7 +707,9 @@ void AOTCodeHeap::mark_evol_dependent_methods(InstanceKlass* dependee) { for (int i = 0; i < methods_cnt; ++i) { int code_id = indexes[i]; AOTCompiledMethod* aot = _code_to_aot[code_id]._aot; - aot->mark_for_deoptimization(false); + if (aot != NULL) { + aot->mark_for_deoptimization(false); + } } } } From 2aa7590846aa6a8cba5fc4e67300bbb676961ade Mon Sep 17 00:00:00 2001 From: Leo Korinth Date: Fri, 8 Feb 2019 11:52:33 +0100 Subject: [PATCH 011/101] 8217329: JTREG: Clean up, remove unused imports in gc folder Reviewed-by: lmesnik, tschatzl --- test/hotspot/jtreg/gc/TestAgeOutput.java | 3 --- test/hotspot/jtreg/gc/TestCardTablePageCommits.java | 1 - test/hotspot/jtreg/gc/TestGenerationPerfCounter.java | 1 - test/hotspot/jtreg/gc/TestMemoryMXBeansAndPoolsPresence.java | 1 - test/hotspot/jtreg/gc/TestNumWorkerOutput.java | 3 --- test/hotspot/jtreg/gc/TestObjectAlignment.java | 3 --- test/hotspot/jtreg/gc/TestPolicyNamePerfCounter.java | 1 - test/hotspot/jtreg/gc/arguments/AllocationHelper.java | 1 - test/hotspot/jtreg/gc/arguments/TestSelectDefaultGC.java | 3 --- test/hotspot/jtreg/gc/arguments/TestShrinkHeapInSteps.java | 1 - .../gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java | 2 -- .../jtreg/gc/class_unloading/TestG1ClassUnloadingHWM.java | 2 -- .../jtreg/gc/concurrent_phase_control/CheckControl.java | 1 - test/hotspot/jtreg/gc/epsilon/TestArraycopyCheckcast.java | 2 -- test/hotspot/jtreg/gc/epsilon/TestEpsilonEnabled.java | 1 - test/hotspot/jtreg/gc/epsilon/TestMemoryMXBeans.java | 1 - .../jtreg/gc/g1/TestEagerReclaimHumongousRegionsLog.java | 4 ---- test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java | 3 --- test/hotspot/jtreg/gc/g1/TestPLABOutput.java | 1 - test/hotspot/jtreg/gc/g1/TestPeriodicLogMessages.java | 1 - test/hotspot/jtreg/gc/g1/TestRemsetLoggingTools.java | 3 --- test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java | 2 -- test/hotspot/jtreg/gc/g1/TestStringDeduplicationTools.java | 2 -- test/hotspot/jtreg/gc/g1/TestVerifyGCType.java | 1 - .../jtreg/gc/g1/mixedgc/TestOldGenCollectionUsage.java | 2 -- test/hotspot/jtreg/gc/logging/TestDeprecatedPrintFlags.java | 2 -- test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java | 1 - test/hotspot/jtreg/gc/logging/TestPrintReferences.java | 2 -- test/hotspot/jtreg/gc/metaspace/TestMetaspaceMemoryPool.java | 2 -- .../jtreg/gc/metaspace/TestPerfCountersAndMemoryPools.java | 1 - .../hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java | 1 - test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java | 1 - test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java | 1 - test/hotspot/jtreg/gc/stress/gclocker/TestGCLocker.java | 1 - test/hotspot/jtreg/gc/stress/systemgc/TestSystemGC.java | 1 - test/hotspot/jtreg/gc/whitebox/TestConcMarkCycleWB.java | 1 - 36 files changed, 60 deletions(-) diff --git a/test/hotspot/jtreg/gc/TestAgeOutput.java b/test/hotspot/jtreg/gc/TestAgeOutput.java index c963d422598..c399e914478 100644 --- a/test/hotspot/jtreg/gc/TestAgeOutput.java +++ b/test/hotspot/jtreg/gc/TestAgeOutput.java @@ -55,12 +55,9 @@ import sun.hotspot.WhiteBox; import java.util.regex.Matcher; import java.util.regex.Pattern; -import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; -import static jdk.test.lib.Asserts.*; - public class TestAgeOutput { public static void checkPattern(String pattern, String what) throws Exception { diff --git a/test/hotspot/jtreg/gc/TestCardTablePageCommits.java b/test/hotspot/jtreg/gc/TestCardTablePageCommits.java index 808c395d55a..1e9c39067df 100644 --- a/test/hotspot/jtreg/gc/TestCardTablePageCommits.java +++ b/test/hotspot/jtreg/gc/TestCardTablePageCommits.java @@ -23,7 +23,6 @@ package gc; -import jdk.test.lib.JDKToolFinder; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.Platform; diff --git a/test/hotspot/jtreg/gc/TestGenerationPerfCounter.java b/test/hotspot/jtreg/gc/TestGenerationPerfCounter.java index 8e12ef4d337..9e333f76424 100644 --- a/test/hotspot/jtreg/gc/TestGenerationPerfCounter.java +++ b/test/hotspot/jtreg/gc/TestGenerationPerfCounter.java @@ -24,7 +24,6 @@ package gc; import static jdk.test.lib.Asserts.*; -import gc.testlibrary.PerfCounter; import gc.testlibrary.PerfCounters; diff --git a/test/hotspot/jtreg/gc/TestMemoryMXBeansAndPoolsPresence.java b/test/hotspot/jtreg/gc/TestMemoryMXBeansAndPoolsPresence.java index 809eaf07240..d67aaa7fb3b 100644 --- a/test/hotspot/jtreg/gc/TestMemoryMXBeansAndPoolsPresence.java +++ b/test/hotspot/jtreg/gc/TestMemoryMXBeansAndPoolsPresence.java @@ -24,7 +24,6 @@ package gc; import java.util.List; -import java.util.ArrayList; import java.lang.management.*; import static jdk.test.lib.Asserts.*; import java.util.stream.*; diff --git a/test/hotspot/jtreg/gc/TestNumWorkerOutput.java b/test/hotspot/jtreg/gc/TestNumWorkerOutput.java index 4f004cf033b..049198627b7 100644 --- a/test/hotspot/jtreg/gc/TestNumWorkerOutput.java +++ b/test/hotspot/jtreg/gc/TestNumWorkerOutput.java @@ -54,12 +54,9 @@ import sun.hotspot.WhiteBox; import java.util.regex.Matcher; import java.util.regex.Pattern; -import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; -import static jdk.test.lib.Asserts.*; - public class TestNumWorkerOutput { public static void checkPatternOnce(String pattern, String what) throws Exception { diff --git a/test/hotspot/jtreg/gc/TestObjectAlignment.java b/test/hotspot/jtreg/gc/TestObjectAlignment.java index f795236ef97..4760d0c9afa 100644 --- a/test/hotspot/jtreg/gc/TestObjectAlignment.java +++ b/test/hotspot/jtreg/gc/TestObjectAlignment.java @@ -44,9 +44,6 @@ package gc; * @run main/othervm gc.TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=256 */ -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; - public class TestObjectAlignment { public static byte[] garbage; diff --git a/test/hotspot/jtreg/gc/TestPolicyNamePerfCounter.java b/test/hotspot/jtreg/gc/TestPolicyNamePerfCounter.java index d31f68d3f93..c413f52e430 100644 --- a/test/hotspot/jtreg/gc/TestPolicyNamePerfCounter.java +++ b/test/hotspot/jtreg/gc/TestPolicyNamePerfCounter.java @@ -24,7 +24,6 @@ package gc; import static jdk.test.lib.Asserts.*; -import gc.testlibrary.PerfCounter; import gc.testlibrary.PerfCounters; diff --git a/test/hotspot/jtreg/gc/arguments/AllocationHelper.java b/test/hotspot/jtreg/gc/arguments/AllocationHelper.java index 3a8f2360d5d..2ba79d017de 100644 --- a/test/hotspot/jtreg/gc/arguments/AllocationHelper.java +++ b/test/hotspot/jtreg/gc/arguments/AllocationHelper.java @@ -23,7 +23,6 @@ package gc.arguments; -import java.util.LinkedList; import java.util.concurrent.Callable; /** diff --git a/test/hotspot/jtreg/gc/arguments/TestSelectDefaultGC.java b/test/hotspot/jtreg/gc/arguments/TestSelectDefaultGC.java index c5fb848c7b2..861b7d0c9dd 100644 --- a/test/hotspot/jtreg/gc/arguments/TestSelectDefaultGC.java +++ b/test/hotspot/jtreg/gc/arguments/TestSelectDefaultGC.java @@ -35,12 +35,9 @@ package gc.arguments; * @run driver gc.arguments.TestSelectDefaultGC */ -import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; -import java.util.regex.*; - public class TestSelectDefaultGC { public static void assertVMOption(OutputAnalyzer output, String option, boolean value) { output.shouldMatch(" " + option + " .*=.* " + value + " "); diff --git a/test/hotspot/jtreg/gc/arguments/TestShrinkHeapInSteps.java b/test/hotspot/jtreg/gc/arguments/TestShrinkHeapInSteps.java index ce97139c407..1727bf688ce 100644 --- a/test/hotspot/jtreg/gc/arguments/TestShrinkHeapInSteps.java +++ b/test/hotspot/jtreg/gc/arguments/TestShrinkHeapInSteps.java @@ -37,7 +37,6 @@ package gc.arguments; import java.util.LinkedList; import java.util.Arrays; -import java.util.Collections; import jdk.test.lib.Utils; public class TestShrinkHeapInSteps { diff --git a/test/hotspot/jtreg/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java b/test/hotspot/jtreg/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java index 998c4a12bfd..1fce46efddc 100644 --- a/test/hotspot/jtreg/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java +++ b/test/hotspot/jtreg/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java @@ -42,8 +42,6 @@ import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import java.lang.management.GarbageCollectorMXBean; import java.lang.management.ManagementFactory; -import java.util.ArrayList; -import java.util.Arrays; import sun.hotspot.WhiteBox; public class TestCMSClassUnloadingEnabledHWM { diff --git a/test/hotspot/jtreg/gc/class_unloading/TestG1ClassUnloadingHWM.java b/test/hotspot/jtreg/gc/class_unloading/TestG1ClassUnloadingHWM.java index 3bfba55f980..5e05bada923 100644 --- a/test/hotspot/jtreg/gc/class_unloading/TestG1ClassUnloadingHWM.java +++ b/test/hotspot/jtreg/gc/class_unloading/TestG1ClassUnloadingHWM.java @@ -39,8 +39,6 @@ package gc.class_unloading; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; -import java.util.ArrayList; -import java.util.Arrays; import sun.hotspot.WhiteBox; public class TestG1ClassUnloadingHWM { diff --git a/test/hotspot/jtreg/gc/concurrent_phase_control/CheckControl.java b/test/hotspot/jtreg/gc/concurrent_phase_control/CheckControl.java index 002f42405d7..51cc6ac792e 100644 --- a/test/hotspot/jtreg/gc/concurrent_phase_control/CheckControl.java +++ b/test/hotspot/jtreg/gc/concurrent_phase_control/CheckControl.java @@ -51,7 +51,6 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; diff --git a/test/hotspot/jtreg/gc/epsilon/TestArraycopyCheckcast.java b/test/hotspot/jtreg/gc/epsilon/TestArraycopyCheckcast.java index 490ddbfc6d9..5e2c2011aac 100644 --- a/test/hotspot/jtreg/gc/epsilon/TestArraycopyCheckcast.java +++ b/test/hotspot/jtreg/gc/epsilon/TestArraycopyCheckcast.java @@ -38,8 +38,6 @@ package gc.epsilon; * @run main/othervm -Xmx1g -Xbatch -Xcomp -XX:-TieredCompilation -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC gc.epsilon.TestArraycopyCheckcast */ -import java.util.Random; - public class TestArraycopyCheckcast { static int COUNT = Integer.getInteger("count", 1000); diff --git a/test/hotspot/jtreg/gc/epsilon/TestEpsilonEnabled.java b/test/hotspot/jtreg/gc/epsilon/TestEpsilonEnabled.java index c0726dd1a83..2f841a0a0f8 100644 --- a/test/hotspot/jtreg/gc/epsilon/TestEpsilonEnabled.java +++ b/test/hotspot/jtreg/gc/epsilon/TestEpsilonEnabled.java @@ -32,7 +32,6 @@ package gc.epsilon; * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC gc.epsilon.TestEpsilonEnabled */ -import jdk.test.lib.Platform; import java.lang.management.GarbageCollectorMXBean; import java.lang.management.ManagementFactory; diff --git a/test/hotspot/jtreg/gc/epsilon/TestMemoryMXBeans.java b/test/hotspot/jtreg/gc/epsilon/TestMemoryMXBeans.java index 9290249a274..012a9f6d74d 100644 --- a/test/hotspot/jtreg/gc/epsilon/TestMemoryMXBeans.java +++ b/test/hotspot/jtreg/gc/epsilon/TestMemoryMXBeans.java @@ -36,7 +36,6 @@ package gc.epsilon; */ import java.lang.management.*; -import java.util.*; public class TestMemoryMXBeans { diff --git a/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsLog.java b/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsLog.java index 6881a915144..bb41f4a02ce 100644 --- a/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsLog.java +++ b/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsLog.java @@ -39,12 +39,8 @@ package gc.g1; import sun.hotspot.WhiteBox; import java.util.Arrays; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import jdk.test.lib.Asserts; -import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; diff --git a/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java b/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java index b9dd97715f0..8c56a29175f 100644 --- a/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java +++ b/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java @@ -38,9 +38,6 @@ package gc.g1; */ import java.lang.Math; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.Asserts; diff --git a/test/hotspot/jtreg/gc/g1/TestPLABOutput.java b/test/hotspot/jtreg/gc/g1/TestPLABOutput.java index f6fd29fba96..48858a1865a 100644 --- a/test/hotspot/jtreg/gc/g1/TestPLABOutput.java +++ b/test/hotspot/jtreg/gc/g1/TestPLABOutput.java @@ -41,7 +41,6 @@ import sun.hotspot.WhiteBox; import java.util.regex.Matcher; import java.util.regex.Pattern; -import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; diff --git a/test/hotspot/jtreg/gc/g1/TestPeriodicLogMessages.java b/test/hotspot/jtreg/gc/g1/TestPeriodicLogMessages.java index bd02a6e1c0a..e1539746dbf 100644 --- a/test/hotspot/jtreg/gc/g1/TestPeriodicLogMessages.java +++ b/test/hotspot/jtreg/gc/g1/TestPeriodicLogMessages.java @@ -36,7 +36,6 @@ package gc.g1; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.Platform; public class TestPeriodicLogMessages { diff --git a/test/hotspot/jtreg/gc/g1/TestRemsetLoggingTools.java b/test/hotspot/jtreg/gc/g1/TestRemsetLoggingTools.java index 5ecf4b7c248..f751fcf1b6e 100644 --- a/test/hotspot/jtreg/gc/g1/TestRemsetLoggingTools.java +++ b/test/hotspot/jtreg/gc/g1/TestRemsetLoggingTools.java @@ -27,13 +27,10 @@ package gc.g1; * Common helpers for TestRemsetLogging* tests */ -import com.sun.management.HotSpotDiagnosticMXBean; -import com.sun.management.VMOption; import sun.hotspot.WhiteBox; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; -import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.Arrays; diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java index ffae711e166..4eb41087c49 100644 --- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java +++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java @@ -27,7 +27,6 @@ import jdk.test.lib.Asserts; import jdk.test.lib.Platform; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.Utils; import jtreg.SkippedException; import java.io.IOException; @@ -36,7 +35,6 @@ import java.lang.management.MemoryUsage; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.List; diff --git a/test/hotspot/jtreg/gc/g1/TestStringDeduplicationTools.java b/test/hotspot/jtreg/gc/g1/TestStringDeduplicationTools.java index 8f3a7b5232c..10eb8e2b5fc 100644 --- a/test/hotspot/jtreg/gc/g1/TestStringDeduplicationTools.java +++ b/test/hotspot/jtreg/gc/g1/TestStringDeduplicationTools.java @@ -27,9 +27,7 @@ package gc.g1; * Common code for string deduplication tests */ -import java.lang.management.*; import java.lang.reflect.*; -import java.security.*; import java.util.*; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; diff --git a/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java b/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java index 34032583bf7..1bbf2d8a660 100644 --- a/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java +++ b/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java @@ -38,7 +38,6 @@ import java.util.ArrayList; import java.util.Collections; import jdk.test.lib.Asserts; -import jdk.test.lib.Utils; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import sun.hotspot.WhiteBox; diff --git a/test/hotspot/jtreg/gc/g1/mixedgc/TestOldGenCollectionUsage.java b/test/hotspot/jtreg/gc/g1/mixedgc/TestOldGenCollectionUsage.java index 72298bd6973..ff0ddcead28 100644 --- a/test/hotspot/jtreg/gc/g1/mixedgc/TestOldGenCollectionUsage.java +++ b/test/hotspot/jtreg/gc/g1/mixedgc/TestOldGenCollectionUsage.java @@ -42,8 +42,6 @@ import sun.hotspot.WhiteBox; import java.util.ArrayList; import java.util.List; -import java.util.Collections; - import java.lang.management.*; // 8195115 says that for the "G1 Old Gen" MemoryPool, CollectionUsage.used diff --git a/test/hotspot/jtreg/gc/logging/TestDeprecatedPrintFlags.java b/test/hotspot/jtreg/gc/logging/TestDeprecatedPrintFlags.java index 3237c67635f..0c8588c895a 100644 --- a/test/hotspot/jtreg/gc/logging/TestDeprecatedPrintFlags.java +++ b/test/hotspot/jtreg/gc/logging/TestDeprecatedPrintFlags.java @@ -36,10 +36,8 @@ package gc.logging; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; -import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.List; import java.util.stream.Collectors; public class TestDeprecatedPrintFlags { diff --git a/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java b/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java index d873ffd2421..ddf7df33f97 100644 --- a/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java +++ b/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java @@ -27,7 +27,6 @@ package gc.logging; import java.io.File; import java.net.URL; import java.net.URLClassLoader; -import java.util.List; import java.util.function.Predicate; import java.util.regex.Pattern; import java.util.regex.Matcher; diff --git a/test/hotspot/jtreg/gc/logging/TestPrintReferences.java b/test/hotspot/jtreg/gc/logging/TestPrintReferences.java index 26b92b0fd26..406d28137d9 100644 --- a/test/hotspot/jtreg/gc/logging/TestPrintReferences.java +++ b/test/hotspot/jtreg/gc/logging/TestPrintReferences.java @@ -36,8 +36,6 @@ package gc.logging; import java.lang.ref.SoftReference; import java.math.BigDecimal; -import java.util.ArrayList; - import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import java.util.regex.Pattern; diff --git a/test/hotspot/jtreg/gc/metaspace/TestMetaspaceMemoryPool.java b/test/hotspot/jtreg/gc/metaspace/TestMetaspaceMemoryPool.java index 026f79af52c..2caf4f77a71 100644 --- a/test/hotspot/jtreg/gc/metaspace/TestMetaspaceMemoryPool.java +++ b/test/hotspot/jtreg/gc/metaspace/TestMetaspaceMemoryPool.java @@ -26,8 +26,6 @@ package gc.metaspace; import java.util.List; import java.lang.management.*; import jdk.test.lib.Platform; -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; import static jdk.test.lib.Asserts.*; /* @test TestMetaspaceMemoryPool diff --git a/test/hotspot/jtreg/gc/metaspace/TestPerfCountersAndMemoryPools.java b/test/hotspot/jtreg/gc/metaspace/TestPerfCountersAndMemoryPools.java index d3d17c81701..1dd929afebd 100644 --- a/test/hotspot/jtreg/gc/metaspace/TestPerfCountersAndMemoryPools.java +++ b/test/hotspot/jtreg/gc/metaspace/TestPerfCountersAndMemoryPools.java @@ -28,7 +28,6 @@ import java.lang.management.*; import jdk.test.lib.Platform; import static jdk.test.lib.Asserts.*; -import gc.testlibrary.PerfCounter; import gc.testlibrary.PerfCounters; /* @test TestPerfCountersAndMemoryPools diff --git a/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java b/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java index 72fcbb82495..f0afc5ef301 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java @@ -41,7 +41,6 @@ import jdk.test.lib.Asserts; import sun.hotspot.WhiteBox; import java.util.ArrayList; -import java.util.List; import java.util.Collections; import gc.testlibrary.Helpers; diff --git a/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java b/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java index e5fa87770a0..8679872d1da 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java @@ -41,7 +41,6 @@ import jdk.test.lib.Asserts; import sun.hotspot.WhiteBox; import java.util.ArrayList; -import java.util.List; import java.util.Collections; /* diff --git a/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java b/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java index f6152de8677..deddeb1b91c 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java @@ -41,7 +41,6 @@ import jdk.test.lib.Asserts; import sun.hotspot.WhiteBox; import java.util.ArrayList; -import java.util.List; import java.util.Collections; /** diff --git a/test/hotspot/jtreg/gc/stress/gclocker/TestGCLocker.java b/test/hotspot/jtreg/gc/stress/gclocker/TestGCLocker.java index 9639250e158..358fd3c379b 100644 --- a/test/hotspot/jtreg/gc/stress/gclocker/TestGCLocker.java +++ b/test/hotspot/jtreg/gc/stress/gclocker/TestGCLocker.java @@ -30,7 +30,6 @@ package gc.stress.gclocker; import java.lang.management.MemoryPoolMXBean; import java.lang.management.ManagementFactory; import java.lang.management.MemoryUsage; -import java.nio.ByteBuffer; import java.util.ArrayDeque; import java.util.HashMap; import java.util.List; diff --git a/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGC.java b/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGC.java index 9244b0f2482..8b89efb7940 100644 --- a/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGC.java +++ b/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGC.java @@ -26,7 +26,6 @@ package gc.stress.systemgc; // A test that stresses a full GC by allocating objects of different lifetimes // and concurrently calling System.gc(). -import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.TreeMap; diff --git a/test/hotspot/jtreg/gc/whitebox/TestConcMarkCycleWB.java b/test/hotspot/jtreg/gc/whitebox/TestConcMarkCycleWB.java index d4b44784765..65ce2da9278 100644 --- a/test/hotspot/jtreg/gc/whitebox/TestConcMarkCycleWB.java +++ b/test/hotspot/jtreg/gc/whitebox/TestConcMarkCycleWB.java @@ -38,7 +38,6 @@ package gc.whitebox; * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC gc.whitebox.TestConcMarkCycleWB * @summary Verifies that ConcurrentMarking-related WB works properly */ -import static jdk.test.lib.Asserts.assertFalse; import static jdk.test.lib.Asserts.assertTrue; import sun.hotspot.WhiteBox; From f3cb008ce20f3c96fd5d2f3332baf60435d8ea2b Mon Sep 17 00:00:00 2001 From: Leo Korinth Date: Fri, 8 Feb 2019 12:09:41 +0100 Subject: [PATCH 012/101] 8217332: JTREG: Clean up, use generics instead of raw types Reviewed-by: tschatzl, sangheki --- test/hotspot/jtreg/gc/TestAllocateHeapAt.java | 2 +- test/hotspot/jtreg/gc/TestAllocateHeapAtError.java | 2 +- .../hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java | 2 +- test/hotspot/jtreg/gc/TestFullGCCount.java | 6 +++--- .../jtreg/gc/TestSoftReferencesBehaviorOnOOME.java | 8 ++++---- test/hotspot/jtreg/gc/TestVerifyDuringStartup.java | 2 +- test/hotspot/jtreg/gc/TestVerifySilently.java | 2 +- test/hotspot/jtreg/gc/TestVerifySubSet.java | 2 +- test/hotspot/jtreg/gc/cms/TestMBeanCMS.java | 2 +- .../hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java | 8 ++++---- .../hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java | 12 ++++++------ .../jtreg/gc/g1/TestShrinkDefragmentedHeap.java | 4 ++-- .../gc/g1/humongousObjects/TestObjectCollected.java | 2 +- .../gc/metaspace/TestMetaspacePerfCounters.java | 2 +- .../jtreg/gc/nvdimm/TestAllocateOldGenAt.java | 4 ++-- .../jtreg/gc/nvdimm/TestAllocateOldGenAtError.java | 4 ++-- .../gc/nvdimm/TestAllocateOldGenAtMultiple.java | 2 +- .../gc/nvdimm/TestHumongousObjectsOnNvdimm.java | 2 +- .../jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java | 2 +- .../jtreg/gc/nvdimm/TestYoungObjectsOnDram.java | 2 +- .../gc/stress/TestReclaimStringsLeaksMemory.java | 12 ++++++------ 21 files changed, 42 insertions(+), 42 deletions(-) diff --git a/test/hotspot/jtreg/gc/TestAllocateHeapAt.java b/test/hotspot/jtreg/gc/TestAllocateHeapAt.java index b228dbff3b3..90d380a1990 100644 --- a/test/hotspot/jtreg/gc/TestAllocateHeapAt.java +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAt.java @@ -40,7 +40,7 @@ import java.util.Collections; public class TestAllocateHeapAt { public static void main(String args[]) throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); String testVmOptsStr = System.getProperty("test.java.opts"); if (!testVmOptsStr.isEmpty()) { diff --git a/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java b/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java index d5e5cd57ea4..dd8f724e93f 100644 --- a/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java @@ -42,7 +42,7 @@ import java.util.UUID; public class TestAllocateHeapAtError { public static void main(String args[]) throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); String testVmOptsStr = System.getProperty("test.java.opts"); if (!testVmOptsStr.isEmpty()) { diff --git a/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java b/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java index 137cea5bd08..3955cbaeca4 100644 --- a/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java @@ -40,7 +40,7 @@ import java.util.Collections; public class TestAllocateHeapAtMultiple { public static void main(String args[]) throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); String[] testVmOpts = null; String test_dir = System.getProperty("test.dir", "."); diff --git a/test/hotspot/jtreg/gc/TestFullGCCount.java b/test/hotspot/jtreg/gc/TestFullGCCount.java index 50663509ce3..fb41b3fe6d4 100644 --- a/test/hotspot/jtreg/gc/TestFullGCCount.java +++ b/test/hotspot/jtreg/gc/TestFullGCCount.java @@ -52,7 +52,7 @@ public class TestFullGCCount { int iterations = 20; boolean failed = false; String errorMessage = ""; - HashMap counts = new HashMap<>(); + HashMap> counts = new HashMap<>(); // Prime the collection of count lists for all collectors. for (int i = 0; i < collectors.size(); i++) { @@ -91,10 +91,10 @@ public class TestFullGCCount { System.out.println("Passed."); } - private static void addCollectionCount(HashMap counts, int iteration) { + private static void addCollectionCount(HashMap> counts, int iteration) { for (int i = 0; i < collectors.size(); i++) { GarbageCollectorMXBean collector = collectors.get(i); - List thisList = counts.get(collector.getName()); + List thisList = counts.get(collector.getName()); thisList.add(collector.getCollectionCount()); } } diff --git a/test/hotspot/jtreg/gc/TestSoftReferencesBehaviorOnOOME.java b/test/hotspot/jtreg/gc/TestSoftReferencesBehaviorOnOOME.java index eb5e5d3b020..b16e961ae23 100644 --- a/test/hotspot/jtreg/gc/TestSoftReferencesBehaviorOnOOME.java +++ b/test/hotspot/jtreg/gc/TestSoftReferencesBehaviorOnOOME.java @@ -71,9 +71,9 @@ public class TestSoftReferencesBehaviorOnOOME { void softReferencesOom(long minSize, long maxSize) { System.out.format( "minSize = %d, maxSize = %d%n", minSize, maxSize ); - LinkedList arrSoftRefs = new LinkedList(); + LinkedList> arrSoftRefs = new LinkedList<>(); staticRef = arrSoftRefs; - LinkedList arrObjects = new LinkedList(); + LinkedList arrObjects = new LinkedList<>(); staticRef = arrObjects; long multiplier = maxSize - minSize; @@ -89,7 +89,7 @@ public class TestSoftReferencesBehaviorOnOOME { while (numSofts-- > 0) { int allocationSize = ((int) (RND_GENERATOR.nextDouble() * multiplier)) + (int)minSize; - arrSoftRefs.add(new SoftReference(new byte[allocationSize])); + arrSoftRefs.add(new SoftReference(new byte[allocationSize])); } System.out.println("free: " + Runtime.getRuntime().freeMemory()); @@ -106,7 +106,7 @@ public class TestSoftReferencesBehaviorOnOOME { arrObjects = null; long oomSoftArraySize = arrSoftRefs.size(); - for (SoftReference sr : arrSoftRefs) { + for (SoftReference sr : arrSoftRefs) { Object o = sr.get(); if (o != null) { diff --git a/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java b/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java index e1553d0a5f7..99a74a96b70 100644 --- a/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java +++ b/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java @@ -41,7 +41,7 @@ import java.util.Collections; public class TestVerifyDuringStartup { public static void main(String args[]) throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); String testVmOptsStr = System.getProperty("test.java.opts"); if (!testVmOptsStr.isEmpty()) { diff --git a/test/hotspot/jtreg/gc/TestVerifySilently.java b/test/hotspot/jtreg/gc/TestVerifySilently.java index 24ccc2c08b9..dff4507ccf8 100644 --- a/test/hotspot/jtreg/gc/TestVerifySilently.java +++ b/test/hotspot/jtreg/gc/TestVerifySilently.java @@ -49,7 +49,7 @@ class TestVerifySilentlyRunSystemGC { public class TestVerifySilently { private static OutputAnalyzer runTest(boolean verifySilently) throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); Collections.addAll(vmOpts, Utils.getFilteredTestJavaOpts("-Xlog.*")); Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/gc/TestVerifySubSet.java b/test/hotspot/jtreg/gc/TestVerifySubSet.java index baa955da41e..2f6023b68d1 100644 --- a/test/hotspot/jtreg/gc/TestVerifySubSet.java +++ b/test/hotspot/jtreg/gc/TestVerifySubSet.java @@ -47,7 +47,7 @@ class TestVerifySubSetRunSystemGC { public class TestVerifySubSet { private static OutputAnalyzer runTest(String subset) throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); Collections.addAll(vmOpts, Utils.getFilteredTestJavaOpts("-Xlog.*")); Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/gc/cms/TestMBeanCMS.java b/test/hotspot/jtreg/gc/cms/TestMBeanCMS.java index eb24c336f12..76c9717830e 100644 --- a/test/hotspot/jtreg/gc/cms/TestMBeanCMS.java +++ b/test/hotspot/jtreg/gc/cms/TestMBeanCMS.java @@ -137,7 +137,7 @@ public class TestMBeanCMS { public void allocationWork(long target) { long sizeAllocated = 0; - List list = new LinkedList(); + List list = new LinkedList<>(); long delay = 50; long count = 0; diff --git a/test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java b/test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java index a61f61993fb..caad74718e2 100644 --- a/test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java +++ b/test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java @@ -52,7 +52,7 @@ public class TestHumongousShrinkHeap { public static final String MIN_FREE_RATIO_FLAG_NAME = "MinHeapFreeRatio"; public static final String MAX_FREE_RATIO_FLAG_NAME = "MaxHeapFreeRatio"; - private static final List> garbage = new ArrayList(); + private static final List> garbage = new ArrayList<>(); private static final int REGION_SIZE = 1024 * 1024; // 1M private static final int LISTS_COUNT = 10; private static final int HUMON_SIZE = Math.round(.9f * REGION_SIZE); @@ -108,7 +108,7 @@ public class TestHumongousShrinkHeap { private void allocate() { for (int i = 0; i < LISTS_COUNT; i++) { - List stuff = new ArrayList(); + List stuff = new ArrayList<>(); allocateList(stuff, HUMON_COUNT, HUMON_SIZE); MemoryUsagePrinter.printMemoryUsage("allocate #" + (i+1)); garbage.add(stuff); @@ -120,12 +120,12 @@ public class TestHumongousShrinkHeap { garbage.subList(0, garbage.size() - 1).clear(); // do not free last one element from last list - List stuff = garbage.get(garbage.size() - 1); + List stuff = garbage.get(garbage.size() - 1); stuff.subList(0, stuff.size() - 1).clear(); System.gc(); } - private static void allocateList(List garbage, int count, int size) { + private static void allocateList(List garbage, int count, int size) { for (int i = 0; i < count; i++) { garbage.add(new byte[size]); } diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java index 4eb41087c49..efb102733f2 100644 --- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java +++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java @@ -66,7 +66,7 @@ public class TestShrinkAuxiliaryData { } protected void test() throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); Collections.addAll(vmOpts, initialOpts); int maxCacheSize = Math.max(0, Math.min(31, getMaxCacheSize())); @@ -82,14 +82,14 @@ public class TestShrinkAuxiliaryData { // for 32 bits ObjectAlignmentInBytes is not a option if (Platform.is32bit()) { - ArrayList vmOptsWithoutAlign = new ArrayList(vmOpts); + ArrayList vmOptsWithoutAlign = new ArrayList<>(vmOpts); vmOptsWithoutAlign.add(ShrinkAuxiliaryDataTest.class.getName()); performTest(vmOptsWithoutAlign); return; } for (int alignment = 3; alignment <= 8; alignment++) { - ArrayList vmOptsWithAlign = new ArrayList(vmOpts); + ArrayList vmOptsWithAlign = new ArrayList<>(vmOpts); vmOptsWithAlign.add("-XX:ObjectAlignmentInBytes=" + (int) Math.pow(2, alignment)); vmOptsWithAlign.add(ShrinkAuxiliaryDataTest.class.getName()); @@ -200,8 +200,8 @@ public class TestShrinkAuxiliaryData { class GarbageObject { - private final List payload = new ArrayList(); - private final List ref = new LinkedList(); + private final List payload = new ArrayList<>(); + private final List ref = new LinkedList<>(); public GarbageObject(int size) { payload.add(new byte[size]); @@ -218,7 +218,7 @@ public class TestShrinkAuxiliaryData { } } - private final List garbage = new ArrayList(); + private final List garbage = new ArrayList<>(); public void test() throws IOException { diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java b/test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java index d4167a61aa3..7bdc1ab8a7a 100644 --- a/test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java +++ b/test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java @@ -139,7 +139,7 @@ public class TestShrinkDefragmentedHeap { garbage.subList(0, garbage.size() - 1).clear(); // do not free last one element from last list - ArrayList stuff = garbage.get(garbage.size() - 1); + ArrayList stuff = garbage.get(garbage.size() - 1); if (stuff.size() > 1) { stuff.subList(0, stuff.size() - 1).clear(); } @@ -159,7 +159,7 @@ public class TestShrinkDefragmentedHeap { ); } - private static void allocateList(List garbage, int count, int size) { + private static void allocateList(List garbage, int count, int size) { for (int i = 0; i < count; i++) { garbage.add(new byte[size]); } diff --git a/test/hotspot/jtreg/gc/g1/humongousObjects/TestObjectCollected.java b/test/hotspot/jtreg/gc/g1/humongousObjects/TestObjectCollected.java index cb4408081d5..9f5bf8b4141 100644 --- a/test/hotspot/jtreg/gc/g1/humongousObjects/TestObjectCollected.java +++ b/test/hotspot/jtreg/gc/g1/humongousObjects/TestObjectCollected.java @@ -139,7 +139,7 @@ public class TestObjectCollected { System.out.println(String.format("Testing %s reference behavior after %s", ref.name(), gc.name())); - Reference reference = ref.create(); + Reference reference = ref.create(); Asserts.assertNotNull(reference, "Test Bug: failed to allocate reference"); long adr = WHITE_BOX.getObjectAddress(reference.get()); diff --git a/test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java b/test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java index c35ac67e249..72b36f916cf 100644 --- a/test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java +++ b/test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java @@ -70,7 +70,7 @@ import gc.testlibrary.PerfCounters; * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC gc.metaspace.TestMetaspacePerfCounters */ public class TestMetaspacePerfCounters { - public static Class fooClass = null; + public static Class fooClass = null; private static final String[] counterNames = {"minCapacity", "maxCapacity", "capacity", "used"}; private static final List gcBeans = ManagementFactoryHelper.getGarbageCollectorMXBeans(); diff --git a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java index bcbdecf0327..9c19c2826bf 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java @@ -43,7 +43,7 @@ public class TestAllocateOldGenAt { private static ArrayList commonOpts; public static void main(String args[]) throws Exception { - commonOpts = new ArrayList(); + commonOpts = new ArrayList<>(); String testVmOptsStr = System.getProperty("test.java.opts"); if (!testVmOptsStr.isEmpty()) { @@ -63,7 +63,7 @@ public class TestAllocateOldGenAt { } private static void runTest(String... extraFlags) throws Exception { - ArrayList testOpts = new ArrayList(); + ArrayList testOpts = new ArrayList<>(); Collections.addAll(testOpts, commonOpts.toArray(new String[commonOpts.size()])); Collections.addAll(testOpts, extraFlags); diff --git a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java index c79f71bcdf4..f1eb195ed2d 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java @@ -45,7 +45,7 @@ public class TestAllocateOldGenAtError { private static ArrayList commonOpts; public static void main(String args[]) throws Exception { - commonOpts = new ArrayList(); + commonOpts = new ArrayList<>(); String testVmOptsStr = System.getProperty("test.java.opts"); if (!testVmOptsStr.isEmpty()) { @@ -94,7 +94,7 @@ public class TestAllocateOldGenAtError { } private static OutputAnalyzer runTest(String... extraFlags) throws Exception { - ArrayList testOpts = new ArrayList(); + ArrayList testOpts = new ArrayList<>(); Collections.addAll(testOpts, commonOpts.toArray(new String[commonOpts.size()])); Collections.addAll(testOpts, extraFlags); diff --git a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java index 6373d58c1a7..2aefca3c167 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java @@ -42,7 +42,7 @@ import java.util.Collections; public class TestAllocateOldGenAtMultiple { public static void main(String args[]) throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); String[] testVmOpts = null; String test_dir = System.getProperty("test.dir", "."); diff --git a/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java b/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java index f0afc5ef301..13c586137a0 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java @@ -53,7 +53,7 @@ public class TestHumongousObjectsOnNvdimm { private static ArrayList testOpts; public static void main(String args[]) throws Exception { - testOpts = new ArrayList(); + testOpts = new ArrayList<>(); String[] common_options = new String[] { "-Xbootclasspath/a:.", diff --git a/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java b/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java index 8679872d1da..b3b495ee076 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java @@ -53,7 +53,7 @@ public class TestOldObjectsOnNvdimm { private static ArrayList testOpts; public static void main(String args[]) throws Exception { - testOpts = new ArrayList(); + testOpts = new ArrayList<>(); String[] common_options = new String[] { "-Xbootclasspath/a:.", diff --git a/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java b/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java index deddeb1b91c..25faa23e416 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java @@ -53,7 +53,7 @@ public class TestYoungObjectsOnDram { private static ArrayList testOpts; public static void main(String args[]) throws Exception { - testOpts = new ArrayList(); + testOpts = new ArrayList<>(); String[] common_options = new String[] { "-Xbootclasspath/a:.", diff --git a/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java b/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java index 6ee6a5a5bff..fc8b462c3dc 100644 --- a/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java +++ b/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java @@ -55,12 +55,12 @@ public class TestReclaimStringsLeaksMemory { public static final int ReservedThreshold = 70000; public static void main(String[] args) throws Exception { - ArrayList baseargs = new ArrayList(Arrays.asList( "-Xms256M", - "-Xmx256M", - "-Xlog:gc*", - "-XX:NativeMemoryTracking=summary", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+PrintNMTStatistics" )); + ArrayList baseargs = new ArrayList<>(Arrays.asList("-Xms256M", + "-Xmx256M", + "-Xlog:gc*", + "-XX:NativeMemoryTracking=summary", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+PrintNMTStatistics" )); baseargs.addAll(Arrays.asList(args)); baseargs.add(GCTest.class.getName()); ProcessBuilder pb_default = From 10a281c485975717de696ce1329f23d82187aeef Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Fri, 8 Feb 2019 11:26:21 +0000 Subject: [PATCH 013/101] 8218546: Unable to connect to https://google.com using java.net.HttpClient Reviewed-by: dfuchs --- .../classes/jdk/internal/net/http/Stream.java | 4 - .../net/httpclient/SpecialHeadersTest.java | 89 +++++++++++++------ 2 files changed, 64 insertions(+), 29 deletions(-) diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Stream.java b/src/java.net.http/share/classes/jdk/internal/net/http/Stream.java index 28ab55ebc60..0e4cedfe6a1 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/Stream.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/Stream.java @@ -608,10 +608,6 @@ class Stream extends ExchangeImpl { if (contentLength > 0) { h.setHeader("content-length", Long.toString(contentLength)); } - URI uri = request.uri(); - if (uri != null) { - h.setHeader("host", Utils.hostString(request)); - } HttpHeaders sysh = filterHeaders(h.build()); HttpHeaders userh = filterHeaders(request.getUserHeaders()); // Filter context restricted from userHeaders diff --git a/test/jdk/java/net/httpclient/SpecialHeadersTest.java b/test/jdk/java/net/httpclient/SpecialHeadersTest.java index a99fff4c7a8..0fdd86d9ad2 100644 --- a/test/jdk/java/net/httpclient/SpecialHeadersTest.java +++ b/test/jdk/java/net/httpclient/SpecialHeadersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -25,7 +25,7 @@ * @test * @summary Verify that some special headers - such as User-Agent * can be specified by the caller. - * @bug 8203771 + * @bug 8203771 8218546 * @modules java.base/sun.net.www.http * java.net.http/jdk.internal.net.http.common * java.net.http/jdk.internal.net.http.frame @@ -64,8 +64,6 @@ import java.net.http.HttpHeaders; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; @@ -74,13 +72,13 @@ import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.function.Function; - -import static java.lang.System.err; import static java.lang.System.out; import static java.net.http.HttpClient.Builder.NO_PROXY; +import static java.net.http.HttpClient.Version.HTTP_2; import static java.nio.charset.StandardCharsets.US_ASCII; import org.testng.Assert; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; public class SpecialHeadersTest implements HttpServerAdapters { @@ -151,7 +149,11 @@ public class SpecialHeadersTest implements HttpServerAdapters { "USER-AGENT", u -> userAgent(), "HOST", u -> u.getRawAuthority()); @Test(dataProvider = "variants") - void test(String uriString, String headerNameAndValue, boolean sameClient) throws Exception { + void test(String uriString, + String headerNameAndValue, + boolean sameClient) + throws Exception + { out.println("\n--- Starting "); int index = headerNameAndValue.indexOf(":"); @@ -183,21 +185,41 @@ public class SpecialHeadersTest implements HttpServerAdapters { assertEquals(resp.statusCode(), 200, "Expected 200, got:" + resp.statusCode()); - String receivedHeaderString = value == null ? null - : resp.headers().firstValue("X-"+key).get(); - out.println("Got X-" + key + ": " + resp.headers().allValues("X-"+key)); - if (value != null) { - assertEquals(receivedHeaderString, value); - assertEquals(resp.headers().allValues("X-"+key), List.of(value)); - } else { - assertEquals(resp.headers().allValues("X-"+key).size(), 0); - } + boolean isInitialRequest = i == 0; + boolean isSecure = uri.getScheme().equalsIgnoreCase("https"); + boolean isHTTP2 = resp.version() == HTTP_2; + boolean isNotH2CUpgrade = isSecure || (sameClient == true && !isInitialRequest); + boolean isDefaultHostHeader = name.equalsIgnoreCase("host") && useDefault; + // By default, HTTP/2 sets the `:authority:` pseudo-header, instead + // of the `Host` header. Therefore, there should be no "X-Host" + // header in the response, except the response to the h2c Upgrade + // request which will have been sent through HTTP/1.1. + + if (isDefaultHostHeader && isHTTP2 && isNotH2CUpgrade) { + assertTrue(resp.headers().firstValue("X-" + key).isEmpty()); + assertTrue(resp.headers().allValues("X-" + key).isEmpty()); + out.println("No X-" + key + " header received, as expected"); + } else { + String receivedHeaderString = value == null ? null + : resp.headers().firstValue("X-"+key).get(); + out.println("Got X-" + key + ": " + resp.headers().allValues("X-"+key)); + if (value != null) { + assertEquals(receivedHeaderString, value); + assertEquals(resp.headers().allValues("X-"+key), List.of(value)); + } else { + assertEquals(resp.headers().allValues("X-"+key).size(), 0); + } + } } } @Test(dataProvider = "variants") - void testHomeMadeIllegalHeader(String uriString, String headerNameAndValue, boolean sameClient) throws Exception { + void testHomeMadeIllegalHeader(String uriString, + String headerNameAndValue, + boolean sameClient) + throws Exception + { out.println("\n--- Starting "); final URI uri = URI.create(uriString); @@ -266,6 +288,11 @@ public class SpecialHeadersTest implements HttpServerAdapters { } HttpRequest request = requestBuilder.build(); + boolean isInitialRequest = i == 0; + boolean isSecure = uri.getScheme().equalsIgnoreCase("https"); + boolean isNotH2CUpgrade = isSecure || (sameClient == true && !isInitialRequest); + boolean isDefaultHostHeader = name.equalsIgnoreCase("host") && useDefault; + client.sendAsync(request, BodyHandlers.ofString()) .thenApply(response -> { out.println("Got response: " + response); @@ -273,15 +300,27 @@ public class SpecialHeadersTest implements HttpServerAdapters { assertEquals(response.statusCode(), 200); return response;}) .thenAccept(resp -> { - String receivedHeaderString = value == null ? null - : resp.headers().firstValue("X-"+key).get(); - out.println("Got X-" + key + ": " + resp.headers().allValues("X-"+key)); - if (value != null) { - assertEquals(receivedHeaderString, value); - assertEquals(resp.headers().allValues("X-" + key), List.of(value)); + // By default, HTTP/2 sets the `:authority:` pseudo-header, instead + // of the `Host` header. Therefore, there should be no "X-Host" + // header in the response, except the response to the h2c Upgrade + // request which will have been sent through HTTP/1.1. + + if (isDefaultHostHeader && resp.version() == HTTP_2 && isNotH2CUpgrade) { + assertTrue(resp.headers().firstValue("X-" + key).isEmpty()); + assertTrue(resp.headers().allValues("X-" + key).isEmpty()); + out.println("No X-" + key + " header received, as expected"); } else { - assertEquals(resp.headers().allValues("X-" + key).size(), 1); - } }) + String receivedHeaderString = value == null ? null + : resp.headers().firstValue("X-"+key).get(); + out.println("Got X-" + key + ": " + resp.headers().allValues("X-"+key)); + if (value != null) { + assertEquals(receivedHeaderString, value); + assertEquals(resp.headers().allValues("X-" + key), List.of(value)); + } else { + assertEquals(resp.headers().allValues("X-" + key).size(), 1); + } + } + }) .join(); } } From 973cfaffa3d3e6f53fb3921d275cca0473db3726 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Fri, 8 Feb 2019 12:31:22 +0100 Subject: [PATCH 014/101] 8217335: Add a script to generate --release data Reviewed-by: darcy, ihse --- make/data/symbols/README | 2 +- make/scripts/generate-symbol-data.sh | 77 ++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 make/scripts/generate-symbol-data.sh diff --git a/make/data/symbols/README b/make/data/symbols/README index f99d6b7562e..4c9f38f77b0 100644 --- a/make/data/symbols/README +++ b/make/data/symbols/README @@ -1,3 +1,3 @@ This directory contains history data for -release. -Please see $LANGTOOLS_DIR/make/src/classes/build/tools/symbolgenerator/CreateSymbols.java for main usage. +Please see $JDK_TOP_DIR/make/scripts/generate-symbol-data.sh for main usage. diff --git a/make/scripts/generate-symbol-data.sh b/make/scripts/generate-symbol-data.sh new file mode 100644 index 00000000000..3ce684041dc --- /dev/null +++ b/make/scripts/generate-symbol-data.sh @@ -0,0 +1,77 @@ +#!/bin/sh +# +# Copyright (c) 2019, 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# + +# This script allows to easily generate (add or update) "--release N" data for JDK N + 1. +# N must be 11 or greater. This script works on Linux. To create new data, or update existing +# data, it is necessary to: +# - download a binary build of OpenJDK N for Linux, API of which will be recorded. It is strongly recommended +# to use an official build, not a custom build, to avoid any chance of including unofficial changes. +# The binary build should never be a build newer than the GA for JDK N. Install the build. The installation +# directory will be denoted as "${JDK_N_INSTALL}" in the further text. +# - have a checkout the JDK to which the data should be added (or in which the data should be updated). +# The checkout directory will be denoted as "${JDK_CHECKOUT}" in the further text. +# The checkout must not have any local changes that could interfere with the new data. In particular, +# there must be absolutely no changed, new or removed files under the ${JDK_CHECKOUT}/make/data/symbols +# directory. +# - open a terminal program and run these commands: +# cd "${JDK_CHECKOUT}"/make/data/symbols +# bash ../../scripts/generate-symbol-data.sh "${JDK_N_INSTALL}" +# - this command will generate or update data for "--release N" into the ${JDK_CHECKOUT}/make/data/symbols +# directory, updating all registration necessary. If the goal was to update the data, and there are no +# new or changed files in the ${JDK_CHECKOUT}/make/data/symbols directory after running this script, +# there were no relevant changes and no further action is necessary. Note that version for N > 9 are encoded +# using capital letters, i.e. A represents version 10, B represents 11, and so on. The version numbers are in +# the names of the files in the ${JDK_CHECKOUT}/make/data/symbols directory, as well as in +# the ${JDK_CHECKOUT}/make/data/symbols/symbols file. +# - if there are any changed/new files in the ${JDK_CHECKOUT}/make/data/symbols directory after running this script, +# then all the changes in this directory, including any new files, need to be sent for review and eventually pushed. +# The commit message should specify which binary build was installed in the ${JDK_N_INSTALL} directory and also +# include the SCM state that was used to build it, which can be found in ${JDK_N_INSTALL}/release, +# in property "SOURCE". + +if [ "$1x" = "x" ] ; then + echo "Must provide the target JDK as a parameter:" >&2 + echo "$0 " >&2 + exit 1 +fi; + +if [ ! -f symbols ] ; then + echo "Must run inside the make/data/symbols directory" >&2 + exit 1 +fi; + +if [ "`hg status .`x" != "x" ] ; then + echo "The make/data/symbols directory contains local changes!" >&2 + exit 1 +fi; + +$1/bin/java --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED \ + --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \ + --add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED \ + --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \ + --add-modules jdk.jdeps \ + ../../../make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java \ + build-description-incremental symbols include.list From 42a47d9491b48f6ae2e899681e444523a2fa5c92 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Fri, 8 Feb 2019 12:31:23 +0100 Subject: [PATCH 015/101] 8218630: CreateSymbols includes class and module headers unnecessarily Ensure class and module headers from the current version are properly matched to existing ones to avoid duplication. Reviewed-by: jjg --- .../tools/symbolgenerator/CreateSymbols.java | 75 ++++++++++++++++++- 1 file changed, 71 insertions(+), 4 deletions(-) diff --git a/make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java b/make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java index 3ca12f5195a..9f3c5a3354c 100644 --- a/make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java +++ b/make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java @@ -1786,9 +1786,13 @@ public class CreateSymbols { if (existing.equals(headerDesc)) { headerDesc = existing; existed = true; - } else { - //check if the only difference between the 7 and 8 version is the Profile annotation - //if so, copy it to the pre-8 version, so save space + } + } + + if (!existed) { + //check if the only difference between the 7 and 8 version is the Profile annotation + //if so, copy it to the pre-8 version, so save space + for (ClassHeaderDescription existing : clazzDesc.header) { List annots = existing.classAnnotations; if (annots != null) { @@ -2610,6 +2614,40 @@ public class CreateSymbols { req.requires_flags, ver); } + + @Override + public int hashCode() { + int hash = 7; + hash = 53 * hash + Objects.hashCode(this.moduleName); + hash = 53 * hash + this.flags; + hash = 53 * hash + Objects.hashCode(this.version); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final RequiresDescription other = (RequiresDescription) obj; + if (this.flags != other.flags) { + return false; + } + if (!Objects.equals(this.moduleName, other.moduleName)) { + return false; + } + if (!Objects.equals(this.version, other.version)) { + return false; + } + return true; + } + } static class ProvidesDescription { @@ -2645,6 +2683,35 @@ public class CreateSymbols { .collect(Collectors.toList()); return new ProvidesDescription(api, impls); } + + @Override + public int hashCode() { + int hash = 5; + hash = 53 * hash + Objects.hashCode(this.interfaceName); + hash = 53 * hash + Objects.hashCode(this.implNames); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ProvidesDescription other = (ProvidesDescription) obj; + if (!Objects.equals(this.interfaceName, other.interfaceName)) { + return false; + } + if (!Objects.equals(this.implNames, other.implNames)) { + return false; + } + return true; + } } } @@ -2806,7 +2873,7 @@ public class CreateSymbols { if (!Objects.equals(this.nestHost, other.nestHost)) { return false; } - if (!Objects.equals(this.nestMembers, other.nestMembers)) { + if (!listEquals(this.nestMembers, other.nestMembers)) { return false; } return true; From 677d177204095aecc3771134594cf322cec3e477 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Fri, 8 Feb 2019 12:31:24 +0100 Subject: [PATCH 016/101] 8216263: Add historical data for JDK 12 Including --release 12 data, based on 12-ea+30, built from changeset 6c377af36a5c. Reviewed-by: darcy, jjg --- make/data/symbols/java.base-C.sym.txt | 636 ++++++++++++++++++++ make/data/symbols/java.compiler-C.sym.txt | 106 ++++ make/data/symbols/java.desktop-C.sym.txt | 47 ++ make/data/symbols/java.naming-C.sym.txt | 50 ++ make/data/symbols/java.rmi-C.sym.txt | 36 ++ make/data/symbols/java.xml-C.sym.txt | 32 + make/data/symbols/jdk.compiler-C.sym.txt | 84 +++ make/data/symbols/jdk.jfr-C.sym.txt | 31 + make/data/symbols/jdk.jsobject-C.sym.txt | 32 + make/data/symbols/jdk.unsupported-C.sym.txt | 32 + make/data/symbols/symbols | 5 +- 11 files changed, 1089 insertions(+), 2 deletions(-) create mode 100644 make/data/symbols/java.base-C.sym.txt create mode 100644 make/data/symbols/java.compiler-C.sym.txt create mode 100644 make/data/symbols/java.desktop-C.sym.txt create mode 100644 make/data/symbols/java.naming-C.sym.txt create mode 100644 make/data/symbols/java.rmi-C.sym.txt create mode 100644 make/data/symbols/java.xml-C.sym.txt create mode 100644 make/data/symbols/jdk.compiler-C.sym.txt create mode 100644 make/data/symbols/jdk.jfr-C.sym.txt create mode 100644 make/data/symbols/jdk.jsobject-C.sym.txt create mode 100644 make/data/symbols/jdk.unsupported-C.sym.txt diff --git a/make/data/symbols/java.base-C.sym.txt b/make/data/symbols/java.base-C.sym.txt new file mode 100644 index 00000000000..27896d9902f --- /dev/null +++ b/make/data/symbols/java.base-C.sym.txt @@ -0,0 +1,636 @@ +# +# Copyright (c) 2019, 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# +# ########################################################## +# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### +# ########################################################## +# +module name java.base +header exports java/io,java/lang,java/lang/annotation,java/lang/constant,java/lang/invoke,java/lang/module,java/lang/ref,java/lang/reflect,java/math,java/net,java/net/spi,java/nio,java/nio/channels,java/nio/channels/spi,java/nio/charset,java/nio/charset/spi,java/nio/file,java/nio/file/attribute,java/nio/file/spi,java/security,java/security/acl,java/security/cert,java/security/interfaces,java/security/spec,java/text,java/text/spi,java/time,java/time/chrono,java/time/format,java/time/temporal,java/time/zone,java/util,java/util/concurrent,java/util/concurrent/atomic,java/util/concurrent/locks,java/util/function,java/util/jar,java/util/regex,java/util/spi,java/util/stream,java/util/zip,javax/crypto,javax/crypto/interfaces,javax/crypto/spec,javax/net,javax/net/ssl,javax/security/auth,javax/security/auth/callback,javax/security/auth/login,javax/security/auth/spi,javax/security/auth/x500,javax/security/cert uses java/lang/System$LoggerFinder,java/net/ContentHandlerFactory,java/net/spi/URLStreamHandlerProvider,java/nio/channels/spi/AsynchronousChannelProvider,java/nio/channels/spi/SelectorProvider,java/nio/charset/spi/CharsetProvider,java/nio/file/spi/FileSystemProvider,java/nio/file/spi/FileTypeDetector,java/security/Provider,java/text/spi/BreakIteratorProvider,java/text/spi/CollatorProvider,java/text/spi/DateFormatProvider,java/text/spi/DateFormatSymbolsProvider,java/text/spi/DecimalFormatSymbolsProvider,java/text/spi/NumberFormatProvider,java/time/chrono/AbstractChronology,java/time/chrono/Chronology,java/time/zone/ZoneRulesProvider,java/util/spi/CalendarDataProvider,java/util/spi/CalendarNameProvider,java/util/spi/CurrencyNameProvider,java/util/spi/LocaleNameProvider,java/util/spi/ResourceBundleControlProvider,java/util/spi/ResourceBundleProvider,java/util/spi/TimeZoneNameProvider,java/util/spi/ToolProvider,javax/security/auth/spi/LoginModule,jdk/internal/logger/DefaultLoggerFinder,sun/text/spi/JavaTimeDateTimePatternProvider,sun/util/locale/provider/LocaleDataMetaInfo,sun/util/resources/LocaleData$CommonResourceBundleProvider,sun/util/resources/LocaleData$SupplementaryResourceBundleProvider,sun/util/spi/CalendarProvider provides interface\u0020;java/nio/file/spi/FileSystemProvider\u0020;impls\u0020;jdk/internal/jrtfs/JrtFileSystemProvider target linux-amd64 flags 8000 + +class name java/io/FileInputStream +-method name finalize descriptor ()V + +class name java/io/FileOutputStream +-method name finalize descriptor ()V + +class name java/io/InputStream +method name skipNBytes descriptor (J)V thrownTypes java/io/IOException flags 1 + +class name java/lang/Character$UnicodeBlock +field name GEORGIAN_EXTENDED descriptor Ljava/lang/Character$UnicodeBlock; flags 19 +field name HANIFI_ROHINGYA descriptor Ljava/lang/Character$UnicodeBlock; flags 19 +field name OLD_SOGDIAN descriptor Ljava/lang/Character$UnicodeBlock; flags 19 +field name SOGDIAN descriptor Ljava/lang/Character$UnicodeBlock; flags 19 +field name DOGRA descriptor Ljava/lang/Character$UnicodeBlock; flags 19 +field name GUNJALA_GONDI descriptor Ljava/lang/Character$UnicodeBlock; flags 19 +field name MAKASAR descriptor Ljava/lang/Character$UnicodeBlock; flags 19 +field name MEDEFAIDRIN descriptor Ljava/lang/Character$UnicodeBlock; flags 19 +field name MAYAN_NUMERALS descriptor Ljava/lang/Character$UnicodeBlock; flags 19 +field name INDIC_SIYAQ_NUMBERS descriptor Ljava/lang/Character$UnicodeBlock; flags 19 +field name CHESS_SYMBOLS descriptor Ljava/lang/Character$UnicodeBlock; flags 19 + +class name java/lang/Character$UnicodeScript +field name HANIFI_ROHINGYA descriptor Ljava/lang/Character$UnicodeScript; flags 4019 +field name OLD_SOGDIAN descriptor Ljava/lang/Character$UnicodeScript; flags 4019 +field name SOGDIAN descriptor Ljava/lang/Character$UnicodeScript; flags 4019 +field name DOGRA descriptor Ljava/lang/Character$UnicodeScript; flags 4019 +field name GUNJALA_GONDI descriptor Ljava/lang/Character$UnicodeScript; flags 4019 +field name MAKASAR descriptor Ljava/lang/Character$UnicodeScript; flags 4019 +field name MEDEFAIDRIN descriptor Ljava/lang/Character$UnicodeScript; flags 4019 + +class name java/lang/Class +header extends java/lang/Object implements java/io/Serializable,java/lang/reflect/GenericDeclaration,java/lang/reflect/Type,java/lang/reflect/AnnotatedElement,java/lang/invoke/TypeDescriptor$OfField,java/lang/constant/Constable flags 31 signature Ljava/lang/Object;Ljava/io/Serializable;Ljava/lang/reflect/GenericDeclaration;Ljava/lang/reflect/Type;Ljava/lang/reflect/AnnotatedElement;Ljava/lang/invoke/TypeDescriptor$OfField;>;Ljava/lang/constant/Constable; +innerclass innerClass java/util/Map$Entry outerClass java/util/Map innerClassName Entry flags 609 +innerclass innerClass java/lang/invoke/TypeDescriptor$OfField outerClass java/lang/invoke/TypeDescriptor innerClassName OfField flags 609 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +method name descriptorString descriptor ()Ljava/lang/String; flags 1 +method name componentType descriptor ()Ljava/lang/Class; flags 1 signature ()Ljava/lang/Class<*>; +method name arrayType descriptor ()Ljava/lang/Class; flags 1 signature ()Ljava/lang/Class<*>; +method name describeConstable descriptor ()Ljava/util/Optional; flags 1 signature ()Ljava/util/Optional; +method name arrayType descriptor ()Ljava/lang/invoke/TypeDescriptor$OfField; flags 1041 +method name componentType descriptor ()Ljava/lang/invoke/TypeDescriptor$OfField; flags 1041 + +class name java/lang/ClassNotFoundException +header extends java/lang/ReflectiveOperationException flags 21 +innerclass innerClass java/io/ObjectInputStream$GetField outerClass java/io/ObjectInputStream innerClassName GetField flags 409 +innerclass innerClass java/io/ObjectOutputStream$PutField outerClass java/io/ObjectOutputStream innerClassName PutField flags 409 +-method name getCause descriptor ()Ljava/lang/Throwable; + +class name java/lang/Double +header extends java/lang/Number implements java/lang/Comparable,java/lang/constant/Constable,java/lang/constant/ConstantDesc flags 31 signature Ljava/lang/Number;Ljava/lang/Comparable;Ljava/lang/constant/Constable;Ljava/lang/constant/ConstantDesc; +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +method name describeConstable descriptor ()Ljava/util/Optional; flags 1 signature ()Ljava/util/Optional; +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/Double; flags 1 +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/Object; thrownTypes java/lang/ReflectiveOperationException flags 1041 + +class name java/lang/Enum +header extends java/lang/Object implements java/lang/constant/Constable,java/lang/Comparable,java/io/Serializable nestMembers java/lang/Enum$EnumDesc flags 421 signature ;>Ljava/lang/Object;Ljava/lang/constant/Constable;Ljava/lang/Comparable;Ljava/io/Serializable; +innerclass innerClass java/lang/Enum$EnumDesc outerClass java/lang/Enum innerClassName EnumDesc flags 19 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +method name describeConstable descriptor ()Ljava/util/Optional; flags 11 signature ()Ljava/util/Optional;>; + +class name java/lang/Enum$EnumDesc +header extends java/lang/constant/DynamicConstantDesc nestHost java/lang/Enum flags 31 signature ;>Ljava/lang/constant/DynamicConstantDesc; +innerclass innerClass java/lang/Enum$EnumDesc outerClass java/lang/Enum innerClassName EnumDesc flags 19 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +method name of descriptor (Ljava/lang/constant/ClassDesc;Ljava/lang/String;)Ljava/lang/Enum$EnumDesc; flags 9 signature ;>(Ljava/lang/constant/ClassDesc;Ljava/lang/String;)Ljava/lang/Enum$EnumDesc; +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/Enum; thrownTypes java/lang/ReflectiveOperationException flags 1 signature (Ljava/lang/invoke/MethodHandles$Lookup;)TE; +method name toString descriptor ()Ljava/lang/String; flags 1 +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/Object; thrownTypes java/lang/ReflectiveOperationException flags 1041 + +class name java/lang/ExceptionInInitializerError +header extends java/lang/LinkageError flags 21 +innerclass innerClass java/io/ObjectInputStream$GetField outerClass java/io/ObjectInputStream innerClassName GetField flags 409 +innerclass innerClass java/io/ObjectOutputStream$PutField outerClass java/io/ObjectOutputStream innerClassName PutField flags 409 +-method name getCause descriptor ()Ljava/lang/Throwable; + +class name java/lang/Float +header extends java/lang/Number implements java/lang/Comparable,java/lang/constant/Constable,java/lang/constant/ConstantDesc flags 31 signature Ljava/lang/Number;Ljava/lang/Comparable;Ljava/lang/constant/Constable;Ljava/lang/constant/ConstantDesc; +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +method name describeConstable descriptor ()Ljava/util/Optional; flags 1 signature ()Ljava/util/Optional; +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/Float; flags 1 +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/Object; thrownTypes java/lang/ReflectiveOperationException flags 1041 + +class name java/lang/Integer +header extends java/lang/Number implements java/lang/Comparable,java/lang/constant/Constable,java/lang/constant/ConstantDesc flags 31 signature Ljava/lang/Number;Ljava/lang/Comparable;Ljava/lang/constant/Constable;Ljava/lang/constant/ConstantDesc; +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +method name describeConstable descriptor ()Ljava/util/Optional; flags 1 signature ()Ljava/util/Optional; +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/Integer; flags 1 +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/Object; thrownTypes java/lang/ReflectiveOperationException flags 1041 + +class name java/lang/Long +header extends java/lang/Number implements java/lang/Comparable,java/lang/constant/Constable,java/lang/constant/ConstantDesc flags 31 signature Ljava/lang/Number;Ljava/lang/Comparable;Ljava/lang/constant/Constable;Ljava/lang/constant/ConstantDesc; +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +method name describeConstable descriptor ()Ljava/util/Optional; flags 1 signature ()Ljava/util/Optional; +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/Long; flags 1 +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/Object; thrownTypes java/lang/ReflectiveOperationException flags 1041 + +class name java/lang/String +header extends java/lang/Object implements java/io/Serializable,java/lang/Comparable,java/lang/CharSequence,java/lang/constant/Constable,java/lang/constant/ConstantDesc flags 31 signature Ljava/lang/Object;Ljava/io/Serializable;Ljava/lang/Comparable;Ljava/lang/CharSequence;Ljava/lang/constant/Constable;Ljava/lang/constant/ConstantDesc; +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +innerclass innerClass java/util/Spliterator$OfInt outerClass java/util/Spliterator innerClassName OfInt flags 609 +method name indent descriptor (I)Ljava/lang/String; flags 1 +method name transform descriptor (Ljava/util/function/Function;)Ljava/lang/Object; flags 1 signature (Ljava/util/function/Function<-Ljava/lang/String;+TR;>;)TR; +method name describeConstable descriptor ()Ljava/util/Optional; flags 1 signature ()Ljava/util/Optional; +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/String; flags 1 +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/Object; thrownTypes java/lang/ReflectiveOperationException flags 1041 + +class name java/lang/System +header extends java/lang/Object nestMembers java/lang/System$LoggerFinder,java/lang/System$Logger,java/lang/System$Logger$Level flags 31 +innerclass innerClass java/lang/System$LoggerFinder outerClass java/lang/System innerClassName LoggerFinder flags 409 +innerclass innerClass java/lang/System$Logger outerClass java/lang/System innerClassName Logger flags 609 +innerclass innerClass java/util/Map$Entry outerClass java/util/Map innerClassName Entry flags 609 +innerclass innerClass java/lang/System$Logger$Level outerClass java/lang/System$Logger innerClassName Level flags 4019 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 + +class name java/lang/constant/ClassDesc +header extends java/lang/Object implements java/lang/constant/ConstantDesc,java/lang/invoke/TypeDescriptor$OfField flags 601 signature Ljava/lang/Object;Ljava/lang/constant/ConstantDesc;Ljava/lang/invoke/TypeDescriptor$OfField; +innerclass innerClass java/lang/invoke/TypeDescriptor$OfField outerClass java/lang/invoke/TypeDescriptor innerClassName OfField flags 609 +method name of descriptor (Ljava/lang/String;)Ljava/lang/constant/ClassDesc; flags 9 +method name of descriptor (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/constant/ClassDesc; flags 9 +method name ofDescriptor descriptor (Ljava/lang/String;)Ljava/lang/constant/ClassDesc; flags 9 +method name arrayType descriptor ()Ljava/lang/constant/ClassDesc; flags 1 +method name arrayType descriptor (I)Ljava/lang/constant/ClassDesc; flags 1 +method name nested descriptor (Ljava/lang/String;)Ljava/lang/constant/ClassDesc; flags 1 +method name nested descriptor (Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/constant/ClassDesc; flags 81 +method name isArray descriptor ()Z flags 1 +method name isPrimitive descriptor ()Z flags 1 +method name isClassOrInterface descriptor ()Z flags 1 +method name componentType descriptor ()Ljava/lang/constant/ClassDesc; flags 1 +method name packageName descriptor ()Ljava/lang/String; flags 1 +method name displayName descriptor ()Ljava/lang/String; flags 1 +method name descriptorString descriptor ()Ljava/lang/String; flags 401 +method name equals descriptor (Ljava/lang/Object;)Z flags 401 +method name arrayType descriptor ()Ljava/lang/invoke/TypeDescriptor$OfField; flags 1041 +method name componentType descriptor ()Ljava/lang/invoke/TypeDescriptor$OfField; flags 1041 + +class name java/lang/constant/Constable +header extends java/lang/Object flags 601 +method name describeConstable descriptor ()Ljava/util/Optional; flags 401 signature ()Ljava/util/Optional<+Ljava/lang/constant/ConstantDesc;>; + +class name java/lang/constant/ConstantDesc +header extends java/lang/Object flags 601 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/Object; thrownTypes java/lang/ReflectiveOperationException flags 401 + +class name java/lang/constant/ConstantDescs +header extends java/lang/Object flags 31 +innerclass innerClass java/lang/constant/DirectMethodHandleDesc$Kind outerClass java/lang/constant/DirectMethodHandleDesc innerClassName Kind flags 4019 +field name DEFAULT_NAME descriptor Ljava/lang/String; constantValue _ flags 19 +field name CD_Object descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_String descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Class descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Number descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Integer descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Long descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Float descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Double descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Short descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Byte descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Character descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Boolean descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Void descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Throwable descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Exception descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Enum descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_VarHandle descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_MethodHandles descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_MethodHandles_Lookup descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_MethodHandle descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_MethodType descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_CallSite descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Collection descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_List descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Set descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_Map descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_ConstantDesc descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_ClassDesc descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_EnumDesc descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_MethodTypeDesc descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_MethodHandleDesc descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_DirectMethodHandleDesc descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_VarHandleDesc descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_MethodHandleDesc_Kind descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_DynamicConstantDesc descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_DynamicCallSiteDesc descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_ConstantBootstraps descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name BSM_PRIMITIVE_CLASS descriptor Ljava/lang/constant/DirectMethodHandleDesc; flags 19 +field name BSM_ENUM_CONSTANT descriptor Ljava/lang/constant/DirectMethodHandleDesc; flags 19 +field name BSM_NULL_CONSTANT descriptor Ljava/lang/constant/DirectMethodHandleDesc; flags 19 +field name BSM_VARHANDLE_FIELD descriptor Ljava/lang/constant/DirectMethodHandleDesc; flags 19 +field name BSM_VARHANDLE_STATIC_FIELD descriptor Ljava/lang/constant/DirectMethodHandleDesc; flags 19 +field name BSM_VARHANDLE_ARRAY descriptor Ljava/lang/constant/DirectMethodHandleDesc; flags 19 +field name BSM_INVOKE descriptor Ljava/lang/constant/DirectMethodHandleDesc; flags 19 +field name CD_int descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_long descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_float descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_double descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_short descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_byte descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_char descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_boolean descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name CD_void descriptor Ljava/lang/constant/ClassDesc; flags 19 +field name NULL descriptor Ljava/lang/constant/ConstantDesc; flags 19 +method name ofCallsiteBootstrap descriptor (Ljava/lang/constant/ClassDesc;Ljava/lang/String;Ljava/lang/constant/ClassDesc;[Ljava/lang/constant/ClassDesc;)Ljava/lang/constant/DirectMethodHandleDesc; flags 89 +method name ofConstantBootstrap descriptor (Ljava/lang/constant/ClassDesc;Ljava/lang/String;Ljava/lang/constant/ClassDesc;[Ljava/lang/constant/ClassDesc;)Ljava/lang/constant/DirectMethodHandleDesc; flags 89 + +class name java/lang/constant/DirectMethodHandleDesc +header extends java/lang/Object implements java/lang/constant/MethodHandleDesc nestMembers java/lang/constant/DirectMethodHandleDesc$Kind flags 601 +innerclass innerClass java/lang/constant/DirectMethodHandleDesc$Kind outerClass java/lang/constant/DirectMethodHandleDesc innerClassName Kind flags 4019 +method name kind descriptor ()Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 401 +method name refKind descriptor ()I flags 401 +method name isOwnerInterface descriptor ()Z flags 401 +method name owner descriptor ()Ljava/lang/constant/ClassDesc; flags 401 +method name methodName descriptor ()Ljava/lang/String; flags 401 +method name lookupDescriptor descriptor ()Ljava/lang/String; flags 401 + +class name java/lang/constant/DirectMethodHandleDesc$Kind +header extends java/lang/Enum nestHost java/lang/constant/DirectMethodHandleDesc flags 4031 signature Ljava/lang/Enum; +innerclass innerClass java/lang/constant/DirectMethodHandleDesc$Kind outerClass java/lang/constant/DirectMethodHandleDesc innerClassName Kind flags 4019 +field name STATIC descriptor Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 4019 +field name INTERFACE_STATIC descriptor Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 4019 +field name VIRTUAL descriptor Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 4019 +field name INTERFACE_VIRTUAL descriptor Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 4019 +field name SPECIAL descriptor Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 4019 +field name INTERFACE_SPECIAL descriptor Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 4019 +field name CONSTRUCTOR descriptor Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 4019 +field name GETTER descriptor Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 4019 +field name SETTER descriptor Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 4019 +field name STATIC_GETTER descriptor Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 4019 +field name STATIC_SETTER descriptor Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 4019 +field name refKind descriptor I flags 11 +field name isInterface descriptor Z flags 11 +method name values descriptor ()[Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 9 +method name valueOf descriptor (Ljava/lang/String;)Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 9 +method name valueOf descriptor (I)Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 9 +method name valueOf descriptor (IZ)Ljava/lang/constant/DirectMethodHandleDesc$Kind; flags 9 + +class name java/lang/constant/DynamicCallSiteDesc +header extends java/lang/Object flags 21 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +method name of descriptor (Ljava/lang/constant/DirectMethodHandleDesc;Ljava/lang/String;Ljava/lang/constant/MethodTypeDesc;[Ljava/lang/constant/ConstantDesc;)Ljava/lang/constant/DynamicCallSiteDesc; flags 89 +method name of descriptor (Ljava/lang/constant/DirectMethodHandleDesc;Ljava/lang/String;Ljava/lang/constant/MethodTypeDesc;)Ljava/lang/constant/DynamicCallSiteDesc; flags 9 +method name of descriptor (Ljava/lang/constant/DirectMethodHandleDesc;Ljava/lang/constant/MethodTypeDesc;)Ljava/lang/constant/DynamicCallSiteDesc; flags 9 +method name withArgs descriptor ([Ljava/lang/constant/ConstantDesc;)Ljava/lang/constant/DynamicCallSiteDesc; flags 81 +method name withNameAndType descriptor (Ljava/lang/String;Ljava/lang/constant/MethodTypeDesc;)Ljava/lang/constant/DynamicCallSiteDesc; flags 1 +method name invocationName descriptor ()Ljava/lang/String; flags 1 +method name invocationType descriptor ()Ljava/lang/constant/MethodTypeDesc; flags 1 +method name bootstrapMethod descriptor ()Ljava/lang/constant/MethodHandleDesc; flags 1 +method name bootstrapArgs descriptor ()[Ljava/lang/constant/ConstantDesc; flags 1 +method name resolveCallSiteDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/invoke/CallSite; thrownTypes java/lang/Throwable flags 1 +method name equals descriptor (Ljava/lang/Object;)Z flags 11 +method name hashCode descriptor ()I flags 11 +method name toString descriptor ()Ljava/lang/String; flags 1 + +class name java/lang/constant/DynamicConstantDesc +header extends java/lang/Object implements java/lang/constant/ConstantDesc flags 421 signature Ljava/lang/Object;Ljava/lang/constant/ConstantDesc; +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +innerclass innerClass java/util/Map$Entry outerClass java/util/Map innerClassName Entry flags 609 +innerclass innerClass java/lang/Enum$EnumDesc outerClass java/lang/Enum innerClassName EnumDesc flags 19 +innerclass innerClass java/lang/invoke/VarHandle$VarHandleDesc outerClass java/lang/invoke/VarHandle innerClassName VarHandleDesc flags 19 +method name descriptor (Ljava/lang/constant/DirectMethodHandleDesc;Ljava/lang/String;Ljava/lang/constant/ClassDesc;[Ljava/lang/constant/ConstantDesc;)V flags 84 +method name ofCanonical descriptor (Ljava/lang/constant/DirectMethodHandleDesc;Ljava/lang/String;Ljava/lang/constant/ClassDesc;[Ljava/lang/constant/ConstantDesc;)Ljava/lang/constant/ConstantDesc; flags 9 signature (Ljava/lang/constant/DirectMethodHandleDesc;Ljava/lang/String;Ljava/lang/constant/ClassDesc;[Ljava/lang/constant/ConstantDesc;)Ljava/lang/constant/ConstantDesc; +method name ofNamed descriptor (Ljava/lang/constant/DirectMethodHandleDesc;Ljava/lang/String;Ljava/lang/constant/ClassDesc;[Ljava/lang/constant/ConstantDesc;)Ljava/lang/constant/DynamicConstantDesc; flags 89 signature (Ljava/lang/constant/DirectMethodHandleDesc;Ljava/lang/String;Ljava/lang/constant/ClassDesc;[Ljava/lang/constant/ConstantDesc;)Ljava/lang/constant/DynamicConstantDesc; +method name of descriptor (Ljava/lang/constant/DirectMethodHandleDesc;[Ljava/lang/constant/ConstantDesc;)Ljava/lang/constant/DynamicConstantDesc; flags 89 signature (Ljava/lang/constant/DirectMethodHandleDesc;[Ljava/lang/constant/ConstantDesc;)Ljava/lang/constant/DynamicConstantDesc; +method name of descriptor (Ljava/lang/constant/DirectMethodHandleDesc;)Ljava/lang/constant/DynamicConstantDesc; flags 9 signature (Ljava/lang/constant/DirectMethodHandleDesc;)Ljava/lang/constant/DynamicConstantDesc; +method name constantName descriptor ()Ljava/lang/String; flags 1 +method name constantType descriptor ()Ljava/lang/constant/ClassDesc; flags 1 +method name bootstrapMethod descriptor ()Ljava/lang/constant/DirectMethodHandleDesc; flags 1 +method name bootstrapArgs descriptor ()[Ljava/lang/constant/ConstantDesc; flags 1 +method name bootstrapArgsList descriptor ()Ljava/util/List; flags 1 signature ()Ljava/util/List; +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/Object; thrownTypes java/lang/ReflectiveOperationException flags 1 signature (Ljava/lang/invoke/MethodHandles$Lookup;)TT; +method name equals descriptor (Ljava/lang/Object;)Z flags 11 +method name hashCode descriptor ()I flags 11 +method name toString descriptor ()Ljava/lang/String; flags 1 + +class name java/lang/constant/MethodHandleDesc +header extends java/lang/Object implements java/lang/constant/ConstantDesc flags 601 +innerclass innerClass java/lang/constant/DirectMethodHandleDesc$Kind outerClass java/lang/constant/DirectMethodHandleDesc innerClassName Kind flags 4019 +method name of descriptor (Ljava/lang/constant/DirectMethodHandleDesc$Kind;Ljava/lang/constant/ClassDesc;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/constant/DirectMethodHandleDesc; flags 9 +method name ofMethod descriptor (Ljava/lang/constant/DirectMethodHandleDesc$Kind;Ljava/lang/constant/ClassDesc;Ljava/lang/String;Ljava/lang/constant/MethodTypeDesc;)Ljava/lang/constant/DirectMethodHandleDesc; flags 9 +method name ofField descriptor (Ljava/lang/constant/DirectMethodHandleDesc$Kind;Ljava/lang/constant/ClassDesc;Ljava/lang/String;Ljava/lang/constant/ClassDesc;)Ljava/lang/constant/DirectMethodHandleDesc; flags 9 +method name ofConstructor descriptor (Ljava/lang/constant/ClassDesc;[Ljava/lang/constant/ClassDesc;)Ljava/lang/constant/DirectMethodHandleDesc; flags 89 +method name asType descriptor (Ljava/lang/constant/MethodTypeDesc;)Ljava/lang/constant/MethodHandleDesc; flags 1 +method name invocationType descriptor ()Ljava/lang/constant/MethodTypeDesc; flags 401 +method name equals descriptor (Ljava/lang/Object;)Z flags 401 + +class name java/lang/constant/MethodTypeDesc +header extends java/lang/Object implements java/lang/constant/ConstantDesc,java/lang/invoke/TypeDescriptor$OfMethod flags 601 signature Ljava/lang/Object;Ljava/lang/constant/ConstantDesc;Ljava/lang/invoke/TypeDescriptor$OfMethod; +innerclass innerClass java/lang/invoke/TypeDescriptor$OfField outerClass java/lang/invoke/TypeDescriptor innerClassName OfField flags 609 +innerclass innerClass java/lang/invoke/TypeDescriptor$OfMethod outerClass java/lang/invoke/TypeDescriptor innerClassName OfMethod flags 609 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +method name ofDescriptor descriptor (Ljava/lang/String;)Ljava/lang/constant/MethodTypeDesc; flags 9 +method name of descriptor (Ljava/lang/constant/ClassDesc;[Ljava/lang/constant/ClassDesc;)Ljava/lang/constant/MethodTypeDesc; flags 89 +method name returnType descriptor ()Ljava/lang/constant/ClassDesc; flags 401 +method name parameterCount descriptor ()I flags 401 +method name parameterType descriptor (I)Ljava/lang/constant/ClassDesc; flags 401 +method name parameterList descriptor ()Ljava/util/List; flags 401 signature ()Ljava/util/List; +method name parameterArray descriptor ()[Ljava/lang/constant/ClassDesc; flags 401 +method name changeReturnType descriptor (Ljava/lang/constant/ClassDesc;)Ljava/lang/constant/MethodTypeDesc; flags 401 +method name changeParameterType descriptor (ILjava/lang/constant/ClassDesc;)Ljava/lang/constant/MethodTypeDesc; flags 401 +method name dropParameterTypes descriptor (II)Ljava/lang/constant/MethodTypeDesc; flags 401 +method name insertParameterTypes descriptor (I[Ljava/lang/constant/ClassDesc;)Ljava/lang/constant/MethodTypeDesc; flags 481 +method name descriptorString descriptor ()Ljava/lang/String; flags 1 +method name displayDescriptor descriptor ()Ljava/lang/String; flags 1 +method name equals descriptor (Ljava/lang/Object;)Z flags 401 +method name insertParameterTypes descriptor (I[Ljava/lang/invoke/TypeDescriptor$OfField;)Ljava/lang/invoke/TypeDescriptor$OfMethod; flags 1041 +method name dropParameterTypes descriptor (II)Ljava/lang/invoke/TypeDescriptor$OfMethod; flags 1041 +method name changeParameterType descriptor (ILjava/lang/invoke/TypeDescriptor$OfField;)Ljava/lang/invoke/TypeDescriptor$OfMethod; flags 1041 +method name changeReturnType descriptor (Ljava/lang/invoke/TypeDescriptor$OfField;)Ljava/lang/invoke/TypeDescriptor$OfMethod; flags 1041 +method name parameterArray descriptor ()[Ljava/lang/invoke/TypeDescriptor$OfField; flags 1041 +method name returnType descriptor ()Ljava/lang/invoke/TypeDescriptor$OfField; flags 1041 +method name parameterType descriptor (I)Ljava/lang/invoke/TypeDescriptor$OfField; flags 1041 + +class name java/lang/invoke/MethodHandle +header extends java/lang/Object implements java/lang/constant/Constable flags 421 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +innerclass innerClass java/lang/constant/DirectMethodHandleDesc$Kind outerClass java/lang/constant/DirectMethodHandleDesc innerClassName Kind flags 4019 +method name describeConstable descriptor ()Ljava/util/Optional; flags 1 signature ()Ljava/util/Optional; + +class name java/lang/invoke/MethodHandleProxies +header extends java/lang/Object flags 21 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 + +class name java/lang/invoke/MethodType +header extends java/lang/Object implements java/lang/constant/Constable,java/lang/invoke/TypeDescriptor$OfMethod,java/io/Serializable flags 31 signature Ljava/lang/Object;Ljava/lang/constant/Constable;Ljava/lang/invoke/TypeDescriptor$OfMethod;Ljava/lang/invoke/MethodType;>;Ljava/io/Serializable; +innerclass innerClass java/lang/invoke/TypeDescriptor$OfField outerClass java/lang/invoke/TypeDescriptor innerClassName OfField flags 609 +innerclass innerClass java/lang/invoke/TypeDescriptor$OfMethod outerClass java/lang/invoke/TypeDescriptor innerClassName OfMethod flags 609 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +method name descriptorString descriptor ()Ljava/lang/String; flags 1 +method name describeConstable descriptor ()Ljava/util/Optional; flags 1 signature ()Ljava/util/Optional; +method name insertParameterTypes descriptor (I[Ljava/lang/invoke/TypeDescriptor$OfField;)Ljava/lang/invoke/TypeDescriptor$OfMethod; flags 1041 +method name dropParameterTypes descriptor (II)Ljava/lang/invoke/TypeDescriptor$OfMethod; flags 1041 +method name changeParameterType descriptor (ILjava/lang/invoke/TypeDescriptor$OfField;)Ljava/lang/invoke/TypeDescriptor$OfMethod; flags 1041 +method name changeReturnType descriptor (Ljava/lang/invoke/TypeDescriptor$OfField;)Ljava/lang/invoke/TypeDescriptor$OfMethod; flags 1041 +method name parameterArray descriptor ()[Ljava/lang/invoke/TypeDescriptor$OfField; flags 1041 +method name returnType descriptor ()Ljava/lang/invoke/TypeDescriptor$OfField; flags 1041 +method name parameterType descriptor (I)Ljava/lang/invoke/TypeDescriptor$OfField; flags 1041 + +class name java/lang/invoke/TypeDescriptor +header extends java/lang/Object nestMembers java/lang/invoke/TypeDescriptor$OfMethod,java/lang/invoke/TypeDescriptor$OfField flags 601 +innerclass innerClass java/lang/invoke/TypeDescriptor$OfMethod outerClass java/lang/invoke/TypeDescriptor innerClassName OfMethod flags 609 +innerclass innerClass java/lang/invoke/TypeDescriptor$OfField outerClass java/lang/invoke/TypeDescriptor innerClassName OfField flags 609 +method name descriptorString descriptor ()Ljava/lang/String; flags 401 + +class name java/lang/invoke/TypeDescriptor$OfField +header extends java/lang/Object implements java/lang/invoke/TypeDescriptor nestHost java/lang/invoke/TypeDescriptor flags 601 signature ;>Ljava/lang/Object;Ljava/lang/invoke/TypeDescriptor; +innerclass innerClass java/lang/invoke/TypeDescriptor$OfField outerClass java/lang/invoke/TypeDescriptor innerClassName OfField flags 609 +method name isArray descriptor ()Z flags 401 +method name isPrimitive descriptor ()Z flags 401 +method name componentType descriptor ()Ljava/lang/invoke/TypeDescriptor$OfField; flags 401 signature ()TF; +method name arrayType descriptor ()Ljava/lang/invoke/TypeDescriptor$OfField; flags 401 signature ()TF; + +class name java/lang/invoke/TypeDescriptor$OfMethod +header extends java/lang/Object implements java/lang/invoke/TypeDescriptor nestHost java/lang/invoke/TypeDescriptor flags 601 signature ;M::Ljava/lang/invoke/TypeDescriptor$OfMethod;>Ljava/lang/Object;Ljava/lang/invoke/TypeDescriptor; +innerclass innerClass java/lang/invoke/TypeDescriptor$OfField outerClass java/lang/invoke/TypeDescriptor innerClassName OfField flags 609 +innerclass innerClass java/lang/invoke/TypeDescriptor$OfMethod outerClass java/lang/invoke/TypeDescriptor innerClassName OfMethod flags 609 +method name parameterCount descriptor ()I flags 401 +method name parameterType descriptor (I)Ljava/lang/invoke/TypeDescriptor$OfField; flags 401 signature (I)TF; +method name returnType descriptor ()Ljava/lang/invoke/TypeDescriptor$OfField; flags 401 signature ()TF; +method name parameterArray descriptor ()[Ljava/lang/invoke/TypeDescriptor$OfField; flags 401 signature ()[TF; +method name parameterList descriptor ()Ljava/util/List; flags 401 signature ()Ljava/util/List; +method name changeReturnType descriptor (Ljava/lang/invoke/TypeDescriptor$OfField;)Ljava/lang/invoke/TypeDescriptor$OfMethod; flags 401 signature (TF;)TM; +method name changeParameterType descriptor (ILjava/lang/invoke/TypeDescriptor$OfField;)Ljava/lang/invoke/TypeDescriptor$OfMethod; flags 401 signature (ITF;)TM; +method name dropParameterTypes descriptor (II)Ljava/lang/invoke/TypeDescriptor$OfMethod; flags 401 signature (II)TM; +method name insertParameterTypes descriptor (I[Ljava/lang/invoke/TypeDescriptor$OfField;)Ljava/lang/invoke/TypeDescriptor$OfMethod; flags 481 signature (I[TF;)TM; + +class name java/lang/invoke/VarHandle +header extends java/lang/Object implements java/lang/constant/Constable nestMembers java/lang/invoke/VarHandle$VarHandleDesc,java/lang/invoke/VarHandle$AccessMode flags 421 +innerclass innerClass java/lang/invoke/VarHandle$VarHandleDesc outerClass java/lang/invoke/VarHandle innerClassName VarHandleDesc flags 19 +innerclass innerClass java/lang/invoke/VarHandle$AccessMode outerClass java/lang/invoke/VarHandle innerClassName AccessMode flags 4019 +method name toString descriptor ()Ljava/lang/String; flags 11 +method name describeConstable descriptor ()Ljava/util/Optional; flags 1 signature ()Ljava/util/Optional; + +class name java/lang/invoke/VarHandle$VarHandleDesc +header extends java/lang/constant/DynamicConstantDesc nestHost java/lang/invoke/VarHandle flags 31 signature Ljava/lang/constant/DynamicConstantDesc; +innerclass innerClass java/lang/invoke/VarHandle$VarHandleDesc outerClass java/lang/invoke/VarHandle innerClassName VarHandleDesc flags 19 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +method name ofField descriptor (Ljava/lang/constant/ClassDesc;Ljava/lang/String;Ljava/lang/constant/ClassDesc;)Ljava/lang/invoke/VarHandle$VarHandleDesc; flags 9 +method name ofStaticField descriptor (Ljava/lang/constant/ClassDesc;Ljava/lang/String;Ljava/lang/constant/ClassDesc;)Ljava/lang/invoke/VarHandle$VarHandleDesc; flags 9 +method name ofArray descriptor (Ljava/lang/constant/ClassDesc;)Ljava/lang/invoke/VarHandle$VarHandleDesc; flags 9 +method name varType descriptor ()Ljava/lang/constant/ClassDesc; flags 1 +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/invoke/VarHandle; thrownTypes java/lang/ReflectiveOperationException flags 1 +method name toString descriptor ()Ljava/lang/String; flags 1 +method name resolveConstantDesc descriptor (Ljava/lang/invoke/MethodHandles$Lookup;)Ljava/lang/Object; thrownTypes java/lang/ReflectiveOperationException flags 1041 + +class name java/lang/module/ModuleDescriptor +header extends java/lang/Object implements java/lang/Comparable nestMembers java/lang/module/ModuleDescriptor$Builder,java/lang/module/ModuleDescriptor$Version,java/lang/module/ModuleDescriptor$Provides,java/lang/module/ModuleDescriptor$Opens,java/lang/module/ModuleDescriptor$Opens$Modifier,java/lang/module/ModuleDescriptor$Exports,java/lang/module/ModuleDescriptor$Exports$Modifier,java/lang/module/ModuleDescriptor$Requires,java/lang/module/ModuleDescriptor$Requires$Modifier,java/lang/module/ModuleDescriptor$Modifier flags 21 signature Ljava/lang/Object;Ljava/lang/Comparable; +innerclass innerClass java/lang/module/ModuleDescriptor$Builder outerClass java/lang/module/ModuleDescriptor innerClassName Builder flags 19 +innerclass innerClass java/lang/module/ModuleDescriptor$Version outerClass java/lang/module/ModuleDescriptor innerClassName Version flags 19 +innerclass innerClass java/lang/module/ModuleDescriptor$Provides outerClass java/lang/module/ModuleDescriptor innerClassName Provides flags 19 +innerclass innerClass java/lang/module/ModuleDescriptor$Opens outerClass java/lang/module/ModuleDescriptor innerClassName Opens flags 19 +innerclass innerClass java/lang/module/ModuleDescriptor$Exports outerClass java/lang/module/ModuleDescriptor innerClassName Exports flags 19 +innerclass innerClass java/lang/module/ModuleDescriptor$Requires outerClass java/lang/module/ModuleDescriptor innerClassName Requires flags 19 +innerclass innerClass java/lang/module/ModuleDescriptor$Modifier outerClass java/lang/module/ModuleDescriptor innerClassName Modifier flags 4019 +innerclass innerClass java/lang/module/ModuleDescriptor$Opens$Modifier outerClass java/lang/module/ModuleDescriptor$Opens innerClassName Modifier flags 4019 +innerclass innerClass java/lang/module/ModuleDescriptor$Exports$Modifier outerClass java/lang/module/ModuleDescriptor$Exports innerClassName Modifier flags 4019 +innerclass innerClass java/lang/module/ModuleDescriptor$Requires$Modifier outerClass java/lang/module/ModuleDescriptor$Requires innerClassName Modifier flags 4019 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 + +class name java/lang/reflect/Executable +header extends java/lang/reflect/AccessibleObject implements java/lang/reflect/Member,java/lang/reflect/GenericDeclaration flags 421 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 + +class name java/lang/reflect/UndeclaredThrowableException +header extends java/lang/RuntimeException flags 21 +innerclass innerClass java/io/ObjectInputStream$GetField outerClass java/io/ObjectInputStream innerClassName GetField flags 409 +innerclass innerClass java/io/ObjectOutputStream$PutField outerClass java/io/ObjectOutputStream innerClassName PutField flags 409 +-method name getCause descriptor ()Ljava/lang/Throwable; + +class name java/net/SecureCacheResponse +method name getSSLSession descriptor ()Ljava/util/Optional; flags 1 signature ()Ljava/util/Optional; + +class name java/net/ServerSocket +method name descriptor (Ljava/net/SocketImpl;)V flags 4 + +class name java/nio/file/Files +method name mismatch descriptor (Ljava/nio/file/Path;Ljava/nio/file/Path;)J thrownTypes java/io/IOException flags 9 + +class name java/security/AccessController +-method name doPrivileged descriptor (Ljava/security/PrivilegedAction;)Ljava/lang/Object; +-method name doPrivileged descriptor (Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object; +-method name doPrivileged descriptor (Ljava/security/PrivilegedExceptionAction;)Ljava/lang/Object; +-method name doPrivileged descriptor (Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)Ljava/lang/Object; +method name doPrivileged descriptor (Ljava/security/PrivilegedAction;)Ljava/lang/Object; flags 9 signature (Ljava/security/PrivilegedAction;)TT; runtimeAnnotations @Ljdk/internal/reflect/CallerSensitive; +method name doPrivileged descriptor (Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object; flags 9 signature (Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)TT; runtimeAnnotations @Ljdk/internal/reflect/CallerSensitive; +method name doPrivileged descriptor (Ljava/security/PrivilegedExceptionAction;)Ljava/lang/Object; thrownTypes java/security/PrivilegedActionException flags 9 signature (Ljava/security/PrivilegedExceptionAction;)TT; runtimeAnnotations @Ljdk/internal/reflect/CallerSensitive; +method name doPrivileged descriptor (Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)Ljava/lang/Object; thrownTypes java/security/PrivilegedActionException flags 9 signature (Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)TT; runtimeAnnotations @Ljdk/internal/reflect/CallerSensitive; + +class name java/security/Key +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue 6603384152749567654 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name java/security/PrivateKey +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue 6034044314589513430 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name java/security/PrivilegedActionException +header extends java/lang/Exception flags 21 +innerclass innerClass java/io/ObjectInputStream$GetField outerClass java/io/ObjectInputStream innerClassName GetField flags 409 +innerclass innerClass java/io/ObjectOutputStream$PutField outerClass java/io/ObjectOutputStream innerClassName PutField flags 409 +-method name getCause descriptor ()Ljava/lang/Throwable; + +class name java/security/Provider +-method name getService descriptor (Ljava/lang/String;Ljava/lang/String;)Ljava/security/Provider$Service; +-method name putService descriptor (Ljava/security/Provider$Service;)V +-method name removeService descriptor (Ljava/security/Provider$Service;)V +method name getService descriptor (Ljava/lang/String;Ljava/lang/String;)Ljava/security/Provider$Service; flags 1 +method name putService descriptor (Ljava/security/Provider$Service;)V flags 4 +method name removeService descriptor (Ljava/security/Provider$Service;)V flags 4 + +class name java/security/PublicKey +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue 7187392471159151072 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name java/security/interfaces/DSAPrivateKey +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue 7776497482533790279 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name java/security/interfaces/DSAPublicKey +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue 1234526332779022332 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name java/security/interfaces/ECPrivateKey +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue -7896394956925609184 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name java/security/interfaces/ECPublicKey +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue -3314988629879632826 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name java/security/interfaces/RSAMultiPrimePrivateCrtKey +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue 618058533534628008 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name java/security/interfaces/RSAPrivateCrtKey +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue -5682214253527700368 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name java/security/interfaces/RSAPrivateKey +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue 5187144804936595022 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name java/security/interfaces/RSAPublicKey +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue -8727434096241101194 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name java/security/spec/PSSParameterSpec +method name toString descriptor ()Ljava/lang/String; flags 1 + +class name java/text/CompactNumberFormat +header extends java/text/NumberFormat flags 31 +innerclass innerClass java/text/Format$Field outerClass java/text/Format innerClassName Field flags 9 +innerclass innerClass java/text/NumberFormat$Field outerClass java/text/NumberFormat innerClassName Field flags 9 +method name descriptor (Ljava/lang/String;Ljava/text/DecimalFormatSymbols;[Ljava/lang/String;)V flags 1 +method name format descriptor (Ljava/lang/Object;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer; flags 11 +method name format descriptor (DLjava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer; flags 1 +method name format descriptor (JLjava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer; flags 1 +method name formatToCharacterIterator descriptor (Ljava/lang/Object;)Ljava/text/AttributedCharacterIterator; flags 1 +method name parse descriptor (Ljava/lang/String;Ljava/text/ParsePosition;)Ljava/lang/Number; flags 1 +method name setMaximumIntegerDigits descriptor (I)V flags 1 +method name setMinimumIntegerDigits descriptor (I)V flags 1 +method name setMinimumFractionDigits descriptor (I)V flags 1 +method name setMaximumFractionDigits descriptor (I)V flags 1 +method name getRoundingMode descriptor ()Ljava/math/RoundingMode; flags 1 +method name setRoundingMode descriptor (Ljava/math/RoundingMode;)V flags 1 +method name getGroupingSize descriptor ()I flags 1 +method name setGroupingSize descriptor (I)V flags 1 +method name isGroupingUsed descriptor ()Z flags 1 +method name setGroupingUsed descriptor (Z)V flags 1 +method name isParseIntegerOnly descriptor ()Z flags 1 +method name setParseIntegerOnly descriptor (Z)V flags 1 +method name isParseBigDecimal descriptor ()Z flags 1 +method name setParseBigDecimal descriptor (Z)V flags 1 +method name equals descriptor (Ljava/lang/Object;)Z flags 1 +method name hashCode descriptor ()I flags 1 +method name clone descriptor ()Ljava/text/CompactNumberFormat; flags 1 +method name clone descriptor ()Ljava/lang/Object; flags 1041 + +class name java/text/NumberFormat +header extends java/text/Format nestMembers java/text/NumberFormat$Style,java/text/NumberFormat$Field flags 421 +innerclass innerClass java/text/NumberFormat$Style outerClass java/text/NumberFormat innerClassName Style flags 4019 +innerclass innerClass java/text/NumberFormat$Field outerClass java/text/NumberFormat innerClassName Field flags 9 +innerclass innerClass java/util/Locale$Category outerClass java/util/Locale innerClassName Category flags 4019 +method name getCompactNumberInstance descriptor ()Ljava/text/NumberFormat; flags 9 +method name getCompactNumberInstance descriptor (Ljava/util/Locale;Ljava/text/NumberFormat$Style;)Ljava/text/NumberFormat; flags 9 + +class name java/text/NumberFormat$Field +field name PREFIX descriptor Ljava/text/NumberFormat$Field; flags 19 +field name SUFFIX descriptor Ljava/text/NumberFormat$Field; flags 19 + +class name java/text/NumberFormat$Style +header extends java/lang/Enum nestHost java/text/NumberFormat flags 4031 signature Ljava/lang/Enum; +innerclass innerClass java/text/NumberFormat$Style outerClass java/text/NumberFormat innerClassName Style flags 4019 +field name SHORT descriptor Ljava/text/NumberFormat$Style; flags 4019 +field name LONG descriptor Ljava/text/NumberFormat$Style; flags 4019 +method name values descriptor ()[Ljava/text/NumberFormat$Style; flags 9 +method name valueOf descriptor (Ljava/lang/String;)Ljava/text/NumberFormat$Style; flags 9 + +class name java/text/spi/NumberFormatProvider +header extends java/util/spi/LocaleServiceProvider flags 421 +innerclass innerClass java/text/NumberFormat$Style outerClass java/text/NumberFormat innerClassName Style flags 4019 +method name getCompactNumberInstance descriptor (Ljava/util/Locale;Ljava/text/NumberFormat$Style;)Ljava/text/NumberFormat; flags 1 + +class name java/util/concurrent/CompletableFuture +method name exceptionallyAsync descriptor (Ljava/util/function/Function;)Ljava/util/concurrent/CompletableFuture; flags 1 signature (Ljava/util/function/Function;)Ljava/util/concurrent/CompletableFuture; +method name exceptionallyAsync descriptor (Ljava/util/function/Function;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture; flags 1 signature (Ljava/util/function/Function;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture; +method name exceptionallyCompose descriptor (Ljava/util/function/Function;)Ljava/util/concurrent/CompletableFuture; flags 1 signature (Ljava/util/function/Function;>;)Ljava/util/concurrent/CompletableFuture; +method name exceptionallyComposeAsync descriptor (Ljava/util/function/Function;)Ljava/util/concurrent/CompletableFuture; flags 1 signature (Ljava/util/function/Function;>;)Ljava/util/concurrent/CompletableFuture; +method name exceptionallyComposeAsync descriptor (Ljava/util/function/Function;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture; flags 1 signature (Ljava/util/function/Function;>;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture; +method name exceptionallyComposeAsync descriptor (Ljava/util/function/Function;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletionStage; flags 1041 +method name exceptionallyComposeAsync descriptor (Ljava/util/function/Function;)Ljava/util/concurrent/CompletionStage; flags 1041 +method name exceptionallyCompose descriptor (Ljava/util/function/Function;)Ljava/util/concurrent/CompletionStage; flags 1041 +method name exceptionallyAsync descriptor (Ljava/util/function/Function;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletionStage; flags 1041 +method name exceptionallyAsync descriptor (Ljava/util/function/Function;)Ljava/util/concurrent/CompletionStage; flags 1041 + +class name java/util/concurrent/CompletionStage +header extends java/lang/Object flags 601 signature Ljava/lang/Object; +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 +method name exceptionallyAsync descriptor (Ljava/util/function/Function;)Ljava/util/concurrent/CompletionStage; flags 1 signature (Ljava/util/function/Function;)Ljava/util/concurrent/CompletionStage; +method name exceptionallyAsync descriptor (Ljava/util/function/Function;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletionStage; flags 1 signature (Ljava/util/function/Function;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletionStage; +method name exceptionallyCompose descriptor (Ljava/util/function/Function;)Ljava/util/concurrent/CompletionStage; flags 1 signature (Ljava/util/function/Function;>;)Ljava/util/concurrent/CompletionStage; +method name exceptionallyComposeAsync descriptor (Ljava/util/function/Function;)Ljava/util/concurrent/CompletionStage; flags 1 signature (Ljava/util/function/Function;>;)Ljava/util/concurrent/CompletionStage; +method name exceptionallyComposeAsync descriptor (Ljava/util/function/Function;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletionStage; flags 1 signature (Ljava/util/function/Function;>;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletionStage; + +class name java/util/jar/JarFile +header extends java/util/zip/ZipFile flags 21 +innerclass innerClass java/lang/Runtime$Version outerClass java/lang/Runtime innerClassName Version flags 19 +innerclass innerClass java/util/jar/Attributes$Name outerClass java/util/jar/Attributes innerClassName Name flags 9 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 + +class name java/util/stream/Collectors +method name teeing descriptor (Ljava/util/stream/Collector;Ljava/util/stream/Collector;Ljava/util/function/BiFunction;)Ljava/util/stream/Collector; flags 9 signature (Ljava/util/stream/Collector<-TT;*TR1;>;Ljava/util/stream/Collector<-TT;*TR2;>;Ljava/util/function/BiFunction<-TR1;-TR2;TR;>;)Ljava/util/stream/Collector; + +class name java/util/zip/Deflater +-method name finalize descriptor ()V + +class name java/util/zip/Inflater +-method name finalize descriptor ()V + +class name java/util/zip/ZipFile +-method name finalize descriptor ()V + +class name javax/crypto/Cipher +method name toString descriptor ()Ljava/lang/String; flags 1 + +class name javax/crypto/SecretKey +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue -4795878709595146952 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name javax/crypto/interfaces/DHPrivateKey +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue 2211791113380396553 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name javax/crypto/interfaces/DHPublicKey +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue -6628103563352519193 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name javax/crypto/interfaces/PBEKey +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue -1430015993304333921 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name javax/net/ssl/HttpsURLConnection +method name getSSLSession descriptor ()Ljava/util/Optional; flags 1 signature ()Ljava/util/Optional; + diff --git a/make/data/symbols/java.compiler-C.sym.txt b/make/data/symbols/java.compiler-C.sym.txt new file mode 100644 index 00000000000..d83d175cd84 --- /dev/null +++ b/make/data/symbols/java.compiler-C.sym.txt @@ -0,0 +1,106 @@ +# +# Copyright (c) 2019, 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# +# ########################################################## +# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### +# ########################################################## +# +class name javax/lang/model/SourceVersion +field name RELEASE_12 descriptor Ljavax/lang/model/SourceVersion; flags 4019 + +class name javax/lang/model/util/AbstractAnnotationValueVisitor7 +-method name descriptor ()V +method name descriptor ()V flags 4 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(since="12") + +class name javax/lang/model/util/AbstractAnnotationValueVisitor9 +header extends javax/lang/model/util/AbstractAnnotationValueVisitor8 flags 421 signature Ljavax/lang/model/util/AbstractAnnotationValueVisitor8; runtimeAnnotations @Ljavax/annotation/processing/SupportedSourceVersion;(value=eLjavax/lang/model/SourceVersion;RELEASE_12;) + +class name javax/lang/model/util/AbstractElementVisitor7 +-method name descriptor ()V +method name descriptor ()V flags 4 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(since="12") + +class name javax/lang/model/util/AbstractElementVisitor9 +header extends javax/lang/model/util/AbstractElementVisitor8 flags 421 signature Ljavax/lang/model/util/AbstractElementVisitor8; runtimeAnnotations @Ljavax/annotation/processing/SupportedSourceVersion;(value=eLjavax/lang/model/SourceVersion;RELEASE_12;) + +class name javax/lang/model/util/AbstractTypeVisitor7 +-method name descriptor ()V +method name descriptor ()V flags 4 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(since="12") + +class name javax/lang/model/util/AbstractTypeVisitor9 +header extends javax/lang/model/util/AbstractTypeVisitor8 flags 421 signature Ljavax/lang/model/util/AbstractTypeVisitor8; runtimeAnnotations @Ljavax/annotation/processing/SupportedSourceVersion;(value=eLjavax/lang/model/SourceVersion;RELEASE_12;) + +class name javax/lang/model/util/ElementKindVisitor7 +-method name descriptor ()V +-method name descriptor (Ljava/lang/Object;)V +method name descriptor ()V flags 4 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(since="12") +method name descriptor (Ljava/lang/Object;)V flags 4 deprecated true signature (TR;)V runtimeAnnotations @Ljava/lang/Deprecated;(since="12") + +class name javax/lang/model/util/ElementKindVisitor9 +header extends javax/lang/model/util/ElementKindVisitor8 flags 21 signature Ljavax/lang/model/util/ElementKindVisitor8; runtimeAnnotations @Ljavax/annotation/processing/SupportedSourceVersion;(value=eLjavax/lang/model/SourceVersion;RELEASE_12;) + +class name javax/lang/model/util/ElementScanner7 +-method name descriptor ()V +-method name descriptor (Ljava/lang/Object;)V +method name descriptor ()V flags 4 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(since="12") +method name descriptor (Ljava/lang/Object;)V flags 4 deprecated true signature (TR;)V runtimeAnnotations @Ljava/lang/Deprecated;(since="12") + +class name javax/lang/model/util/ElementScanner9 +header extends javax/lang/model/util/ElementScanner8 flags 21 signature Ljavax/lang/model/util/ElementScanner8; runtimeAnnotations @Ljavax/annotation/processing/SupportedSourceVersion;(value=eLjavax/lang/model/SourceVersion;RELEASE_12;) + +class name javax/lang/model/util/SimpleAnnotationValueVisitor7 +-method name descriptor ()V +-method name descriptor (Ljava/lang/Object;)V +method name descriptor ()V flags 4 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(since="12") +method name descriptor (Ljava/lang/Object;)V flags 4 deprecated true signature (TR;)V runtimeAnnotations @Ljava/lang/Deprecated;(since="12") + +class name javax/lang/model/util/SimpleAnnotationValueVisitor9 +header extends javax/lang/model/util/SimpleAnnotationValueVisitor8 flags 21 signature Ljavax/lang/model/util/SimpleAnnotationValueVisitor8; runtimeAnnotations @Ljavax/annotation/processing/SupportedSourceVersion;(value=eLjavax/lang/model/SourceVersion;RELEASE_12;) + +class name javax/lang/model/util/SimpleElementVisitor7 +-method name descriptor ()V +-method name descriptor (Ljava/lang/Object;)V +method name descriptor ()V flags 4 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(since="12") +method name descriptor (Ljava/lang/Object;)V flags 4 deprecated true signature (TR;)V runtimeAnnotations @Ljava/lang/Deprecated;(since="12") + +class name javax/lang/model/util/SimpleElementVisitor9 +header extends javax/lang/model/util/SimpleElementVisitor8 flags 21 signature Ljavax/lang/model/util/SimpleElementVisitor8; runtimeAnnotations @Ljavax/annotation/processing/SupportedSourceVersion;(value=eLjavax/lang/model/SourceVersion;RELEASE_12;) + +class name javax/lang/model/util/SimpleTypeVisitor7 +-method name descriptor ()V +-method name descriptor (Ljava/lang/Object;)V +method name descriptor ()V flags 4 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(since="12") +method name descriptor (Ljava/lang/Object;)V flags 4 deprecated true signature (TR;)V runtimeAnnotations @Ljava/lang/Deprecated;(since="12") + +class name javax/lang/model/util/SimpleTypeVisitor9 +header extends javax/lang/model/util/SimpleTypeVisitor8 flags 21 signature Ljavax/lang/model/util/SimpleTypeVisitor8; runtimeAnnotations @Ljavax/annotation/processing/SupportedSourceVersion;(value=eLjavax/lang/model/SourceVersion;RELEASE_12;) + +class name javax/lang/model/util/TypeKindVisitor7 +-method name descriptor ()V +-method name descriptor (Ljava/lang/Object;)V +method name descriptor ()V flags 4 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(since="12") +method name descriptor (Ljava/lang/Object;)V flags 4 deprecated true signature (TR;)V runtimeAnnotations @Ljava/lang/Deprecated;(since="12") + +class name javax/lang/model/util/TypeKindVisitor9 +header extends javax/lang/model/util/TypeKindVisitor8 flags 21 signature Ljavax/lang/model/util/TypeKindVisitor8; runtimeAnnotations @Ljavax/annotation/processing/SupportedSourceVersion;(value=eLjavax/lang/model/SourceVersion;RELEASE_12;) + diff --git a/make/data/symbols/java.desktop-C.sym.txt b/make/data/symbols/java.desktop-C.sym.txt new file mode 100644 index 00000000000..5f4e0186ffc --- /dev/null +++ b/make/data/symbols/java.desktop-C.sym.txt @@ -0,0 +1,47 @@ +# +# Copyright (c) 2019, 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# +# ########################################################## +# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### +# ########################################################## +# +class name javax/swing/border/TitledBorder +header extends javax/swing/border/AbstractBorder flags 21 +innerclass innerClass java/awt/Component$BaselineResizeBehavior outerClass java/awt/Component innerClassName BaselineResizeBehavior flags 4019 +innerclass innerClass java/awt/geom/Path2D$Float outerClass java/awt/geom/Path2D innerClassName Float flags 9 +innerclass innerClass java/lang/ref/Cleaner$Cleanable outerClass java/lang/ref/Cleaner innerClassName Cleanable flags 609 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 + +class name javax/swing/filechooser/FileSystemView +method name getChooserShortcutPanelFiles descriptor ()[Ljava/io/File; flags 11 + +class name javax/swing/text/html/StyleSheet$ListPainter +header extends java/lang/Object implements java/io/Serializable nestHost javax/swing/text/html/StyleSheet flags 21 +innerclass innerClass javax/swing/text/html/StyleSheet$ListPainter outerClass javax/swing/text/html/StyleSheet innerClassName ListPainter flags 9 +innerclass innerClass javax/swing/text/html/HTML$Tag outerClass javax/swing/text/html/HTML innerClassName Tag flags 9 +innerclass innerClass javax/swing/text/html/CSS$Attribute outerClass javax/swing/text/html/CSS innerClassName Attribute flags 19 +innerclass innerClass javax/swing/text/html/HTML$Attribute outerClass javax/swing/text/html/HTML innerClassName Attribute flags 19 +innerclass innerClass java/awt/RenderingHints$Key outerClass java/awt/RenderingHints innerClassName Key flags 409 +innerclass innerClass java/lang/invoke/MethodHandles$Lookup outerClass java/lang/invoke/MethodHandles innerClassName Lookup flags 19 + diff --git a/make/data/symbols/java.naming-C.sym.txt b/make/data/symbols/java.naming-C.sym.txt new file mode 100644 index 00000000000..defb2bcc9ba --- /dev/null +++ b/make/data/symbols/java.naming-C.sym.txt @@ -0,0 +1,50 @@ +# +# Copyright (c) 2019, 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# +# ########################################################## +# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### +# ########################################################## +# +module name java.naming +header exports javax/naming,javax/naming/directory,javax/naming/event,javax/naming/ldap,javax/naming/spi,javax/naming/ldap/spi requires name\u0020;java.base\u0020;flags\u0020;8000,name\u0020;java.security.sasl\u0020;flags\u0020;0 uses javax/naming/ldap/StartTlsResponse,javax/naming/spi/InitialContextFactory,javax/naming/ldap/spi/LdapDnsProvider provides interface\u0020;java/security/Provider\u0020;impls\u0020;sun/security/provider/certpath/ldap/JdkLDAP target linux-amd64 flags 8000 + +class name javax/naming/Name +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue -3617482732056931635 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name javax/naming/directory/Attribute +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue 8707690322213556804 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name javax/naming/ldap/spi/LdapDnsProvider +header extends java/lang/Object flags 421 +method name descriptor ()V flags 4 +method name lookupEndpoints descriptor (Ljava/lang/String;Ljava/util/Map;)Ljava/util/Optional; thrownTypes javax/naming/NamingException flags 401 signature (Ljava/lang/String;Ljava/util/Map<**>;)Ljava/util/Optional; + +class name javax/naming/ldap/spi/LdapDnsProviderResult +header extends java/lang/Object flags 31 +method name descriptor (Ljava/lang/String;Ljava/util/List;)V flags 1 signature (Ljava/lang/String;Ljava/util/List;)V +method name getDomainName descriptor ()Ljava/lang/String; flags 1 +method name getEndpoints descriptor ()Ljava/util/List; flags 1 signature ()Ljava/util/List; + diff --git a/make/data/symbols/java.rmi-C.sym.txt b/make/data/symbols/java.rmi-C.sym.txt new file mode 100644 index 00000000000..cdb3563b128 --- /dev/null +++ b/make/data/symbols/java.rmi-C.sym.txt @@ -0,0 +1,36 @@ +# +# Copyright (c) 2019, 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# +# ########################################################## +# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### +# ########################################################## +# +class name java/rmi/server/RemoteRef +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue 3632638527362204081 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + +class name java/rmi/server/ServerRef +-field name serialVersionUID descriptor J +field name serialVersionUID descriptor J constantValue -4557750989390278438 flags 19 deprecated true runtimeAnnotations @Ljava/lang/Deprecated; + diff --git a/make/data/symbols/java.xml-C.sym.txt b/make/data/symbols/java.xml-C.sym.txt new file mode 100644 index 00000000000..6023e7f147c --- /dev/null +++ b/make/data/symbols/java.xml-C.sym.txt @@ -0,0 +1,32 @@ +# +# Copyright (c) 2019, 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# +# ########################################################## +# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### +# ########################################################## +# +class name javax/xml/stream/XMLInputFactory +method name newFactory descriptor ()Ljavax/xml/stream/XMLInputFactory; thrownTypes javax/xml/stream/FactoryConfigurationError flags 9 +-method name newFactory descriptor ()Ljavax/xml/stream/XMLInputFactory; + diff --git a/make/data/symbols/jdk.compiler-C.sym.txt b/make/data/symbols/jdk.compiler-C.sym.txt new file mode 100644 index 00000000000..89e10ed93c6 --- /dev/null +++ b/make/data/symbols/jdk.compiler-C.sym.txt @@ -0,0 +1,84 @@ +# +# Copyright (c) 2019, 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# +# ########################################################## +# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### +# ########################################################## +# +class name com/sun/source/doctree/DocTree$Kind +field name SYSTEM_PROPERTY descriptor Lcom/sun/source/doctree/DocTree$Kind; flags 4019 + +class name com/sun/source/doctree/DocTreeVisitor +method name visitSystemProperty descriptor (Lcom/sun/source/doctree/SystemPropertyTree;Ljava/lang/Object;)Ljava/lang/Object; flags 1 signature (Lcom/sun/source/doctree/SystemPropertyTree;TP;)TR; + +class name com/sun/source/doctree/SystemPropertyTree +header extends java/lang/Object implements com/sun/source/doctree/InlineTagTree flags 601 +method name getPropertyName descriptor ()Ljavax/lang/model/element/Name; flags 401 + +class name com/sun/source/tree/BreakTree +method name getValue descriptor ()Lcom/sun/source/tree/ExpressionTree; flags 401 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(forRemoval=Ztrue,since="12") + +class name com/sun/source/tree/CaseTree +header extends java/lang/Object implements com/sun/source/tree/Tree nestMembers com/sun/source/tree/CaseTree$CaseKind flags 601 +innerclass innerClass com/sun/source/tree/CaseTree$CaseKind outerClass com/sun/source/tree/CaseTree innerClassName CaseKind flags 4019 +method name getExpressions descriptor ()Ljava/util/List; flags 401 deprecated true signature ()Ljava/util/List<+Lcom/sun/source/tree/ExpressionTree;>; runtimeAnnotations @Ljava/lang/Deprecated;(forRemoval=Ztrue,since="12") +method name getBody descriptor ()Lcom/sun/source/tree/Tree; flags 1 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(forRemoval=Ztrue,since="12") +method name getCaseKind descriptor ()Lcom/sun/source/tree/CaseTree$CaseKind; flags 1 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(forRemoval=Ztrue,since="12") + +class name com/sun/source/tree/CaseTree$CaseKind +header extends java/lang/Enum nestHost com/sun/source/tree/CaseTree flags 4031 deprecated true signature Ljava/lang/Enum; runtimeAnnotations @Ljava/lang/Deprecated;(forRemoval=Ztrue,since="12") +innerclass innerClass com/sun/source/tree/CaseTree$CaseKind outerClass com/sun/source/tree/CaseTree innerClassName CaseKind flags 4019 +field name STATEMENT descriptor Lcom/sun/source/tree/CaseTree$CaseKind; flags 4019 +field name RULE descriptor Lcom/sun/source/tree/CaseTree$CaseKind; flags 4019 +method name values descriptor ()[Lcom/sun/source/tree/CaseTree$CaseKind; flags 9 +method name valueOf descriptor (Ljava/lang/String;)Lcom/sun/source/tree/CaseTree$CaseKind; flags 9 + +class name com/sun/source/tree/SwitchExpressionTree +header extends java/lang/Object implements com/sun/source/tree/ExpressionTree flags 601 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(forRemoval=Ztrue,since="12") +method name getExpression descriptor ()Lcom/sun/source/tree/ExpressionTree; flags 401 +method name getCases descriptor ()Ljava/util/List; flags 401 signature ()Ljava/util/List<+Lcom/sun/source/tree/CaseTree;>; + +class name com/sun/source/tree/Tree$Kind +field name SWITCH_EXPRESSION descriptor Lcom/sun/source/tree/Tree$Kind; flags 4019 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(forRemoval=Ztrue,since="12") + +class name com/sun/source/tree/TreeVisitor +method name visitSwitchExpression descriptor (Lcom/sun/source/tree/SwitchExpressionTree;Ljava/lang/Object;)Ljava/lang/Object; flags 401 deprecated true signature (Lcom/sun/source/tree/SwitchExpressionTree;TP;)TR; runtimeAnnotations @Ljava/lang/Deprecated;(forRemoval=Ztrue,since="12") + +class name com/sun/source/util/DocTreeFactory +method name newSystemPropertyTree descriptor (Ljavax/lang/model/element/Name;)Lcom/sun/source/doctree/SystemPropertyTree; flags 401 + +class name com/sun/source/util/DocTreeScanner +method name visitSystemProperty descriptor (Lcom/sun/source/doctree/SystemPropertyTree;Ljava/lang/Object;)Ljava/lang/Object; flags 1 signature (Lcom/sun/source/doctree/SystemPropertyTree;TP;)TR; + +class name com/sun/source/util/SimpleDocTreeVisitor +method name visitSystemProperty descriptor (Lcom/sun/source/doctree/SystemPropertyTree;Ljava/lang/Object;)Ljava/lang/Object; flags 1 signature (Lcom/sun/source/doctree/SystemPropertyTree;TP;)TR; + +class name com/sun/source/util/SimpleTreeVisitor +method name visitSwitchExpression descriptor (Lcom/sun/source/tree/SwitchExpressionTree;Ljava/lang/Object;)Ljava/lang/Object; flags 1 deprecated true signature (Lcom/sun/source/tree/SwitchExpressionTree;TP;)TR; runtimeAnnotations @Ljava/lang/Deprecated;(forRemoval=Ztrue,since="12") + +class name com/sun/source/util/TreeScanner +header extends java/lang/Object implements com/sun/source/tree/TreeVisitor flags 21 signature Ljava/lang/Object;Lcom/sun/source/tree/TreeVisitor; +innerclass innerClass com/sun/source/tree/CaseTree$CaseKind outerClass com/sun/source/tree/CaseTree innerClassName CaseKind flags 4019 +method name visitSwitchExpression descriptor (Lcom/sun/source/tree/SwitchExpressionTree;Ljava/lang/Object;)Ljava/lang/Object; flags 1 deprecated true signature (Lcom/sun/source/tree/SwitchExpressionTree;TP;)TR; runtimeAnnotations @Ljava/lang/Deprecated;(forRemoval=Ztrue,since="12") + diff --git a/make/data/symbols/jdk.jfr-C.sym.txt b/make/data/symbols/jdk.jfr-C.sym.txt new file mode 100644 index 00000000000..88622426d5c --- /dev/null +++ b/make/data/symbols/jdk.jfr-C.sym.txt @@ -0,0 +1,31 @@ +# +# Copyright (c) 2019, 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# +# ########################################################## +# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### +# ########################################################## +# +class name jdk/jfr/Event +header extends jdk/internal/event/Event flags 421 runtimeAnnotations @Ljdk/jfr/Enabled;(value=Ztrue)@Ljdk/jfr/StackTrace;(value=Ztrue)@Ljdk/jfr/Registered;(value=Ztrue) + diff --git a/make/data/symbols/jdk.jsobject-C.sym.txt b/make/data/symbols/jdk.jsobject-C.sym.txt new file mode 100644 index 00000000000..35d8bd7d33b --- /dev/null +++ b/make/data/symbols/jdk.jsobject-C.sym.txt @@ -0,0 +1,32 @@ +# +# Copyright (c) 2019, 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# +# ########################################################## +# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### +# ########################################################## +# +class name netscape/javascript/JSObject +-method name getWindow descriptor (Ljava/applet/Applet;)Lnetscape/javascript/JSObject; +method name getWindow descriptor (Ljava/applet/Applet;)Lnetscape/javascript/JSObject; thrownTypes netscape/javascript/JSException flags 9 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(forRemoval=Ztrue,since="9") + diff --git a/make/data/symbols/jdk.unsupported-C.sym.txt b/make/data/symbols/jdk.unsupported-C.sym.txt new file mode 100644 index 00000000000..ea476e1e38a --- /dev/null +++ b/make/data/symbols/jdk.unsupported-C.sym.txt @@ -0,0 +1,32 @@ +# +# Copyright (c) 2019, 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# +# ########################################################## +# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### +# ########################################################## +# +class name sun/reflect/ReflectionFactory +header extends java/lang/Object flags 21 classAnnotations @Lsun/Proprietary+Annotation; +-method name newInstanceForSerialization descriptor (Ljava/lang/reflect/Constructor;[Ljava/security/ProtectionDomain;)Ljava/lang/Object; + diff --git a/make/data/symbols/symbols b/make/data/symbols/symbols index aa65fe9488f..9681a368cd7 100644 --- a/make/data/symbols/symbols +++ b/make/data/symbols/symbols @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2019, 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 @@ -29,9 +29,10 @@ #command used to generate this file: #build.tools.symbolgenerator.CreateSymbols build-description-incremental symbols include.list # -generate platforms 7:8:9:A:B +generate platforms 7:8:9:A:B:C platform version 8 files java.activation-8.sym.txt:java.base-8.sym.txt:java.compiler-8.sym.txt:java.corba-8.sym.txt:java.datatransfer-8.sym.txt:java.desktop-8.sym.txt:java.instrument-8.sym.txt:java.logging-8.sym.txt:java.management-8.sym.txt:java.management.rmi-8.sym.txt:java.naming-8.sym.txt:java.prefs-8.sym.txt:java.rmi-8.sym.txt:java.scripting-8.sym.txt:java.security.jgss-8.sym.txt:java.security.sasl-8.sym.txt:java.sql-8.sym.txt:java.sql.rowset-8.sym.txt:java.transaction-8.sym.txt:java.xml-8.sym.txt:java.xml.bind-8.sym.txt:java.xml.crypto-8.sym.txt:java.xml.ws-8.sym.txt:java.xml.ws.annotation-8.sym.txt:jdk.httpserver-8.sym.txt:jdk.management-8.sym.txt:jdk.scripting.nashorn-8.sym.txt:jdk.sctp-8.sym.txt:jdk.security.auth-8.sym.txt:jdk.security.jgss-8.sym.txt platform version 7 base 8 files java.base-7.sym.txt:java.compiler-7.sym.txt:java.datatransfer-7.sym.txt:java.desktop-7.sym.txt:java.logging-7.sym.txt:java.management-7.sym.txt:java.naming-7.sym.txt:java.prefs-7.sym.txt:java.rmi-7.sym.txt:java.scripting-7.sym.txt:java.security.jgss-7.sym.txt:java.security.sasl-7.sym.txt:java.sql-7.sym.txt:java.sql.rowset-7.sym.txt:java.xml-7.sym.txt:java.xml.bind-7.sym.txt:java.xml.ws.annotation-7.sym.txt:jdk.httpserver-7.sym.txt:jdk.management-7.sym.txt:jdk.scripting.nashorn-7.sym.txt:jdk.sctp-7.sym.txt:jdk.security.auth-7.sym.txt:jdk.security.jgss-7.sym.txt platform version 9 base 8 files java.activation-9.sym.txt:java.base-9.sym.txt:java.compiler-9.sym.txt:java.corba-9.sym.txt:java.datatransfer-9.sym.txt:java.desktop-9.sym.txt:java.instrument-9.sym.txt:java.logging-9.sym.txt:java.management-9.sym.txt:java.management.rmi-9.sym.txt:java.naming-9.sym.txt:java.prefs-9.sym.txt:java.rmi-9.sym.txt:java.scripting-9.sym.txt:java.se-9.sym.txt:java.se.ee-9.sym.txt:java.security.jgss-9.sym.txt:java.security.sasl-9.sym.txt:java.smartcardio-9.sym.txt:java.sql-9.sym.txt:java.sql.rowset-9.sym.txt:java.transaction-9.sym.txt:java.xml-9.sym.txt:java.xml.bind-9.sym.txt:java.xml.crypto-9.sym.txt:java.xml.ws-9.sym.txt:java.xml.ws.annotation-9.sym.txt:jdk.accessibility-9.sym.txt:jdk.attach-9.sym.txt:jdk.charsets-9.sym.txt:jdk.compiler-9.sym.txt:jdk.crypto.cryptoki-9.sym.txt:jdk.crypto.ec-9.sym.txt:jdk.dynalink-9.sym.txt:jdk.editpad-9.sym.txt:jdk.hotspot.agent-9.sym.txt:jdk.httpserver-9.sym.txt:jdk.incubator.httpclient-9.sym.txt:jdk.jartool-9.sym.txt:jdk.javadoc-9.sym.txt:jdk.jcmd-9.sym.txt:jdk.jconsole-9.sym.txt:jdk.jdeps-9.sym.txt:jdk.jdi-9.sym.txt:jdk.jdwp.agent-9.sym.txt:jdk.jlink-9.sym.txt:jdk.jshell-9.sym.txt:jdk.jsobject-9.sym.txt:jdk.jstatd-9.sym.txt:jdk.localedata-9.sym.txt:jdk.management-9.sym.txt:jdk.management.agent-9.sym.txt:jdk.naming.dns-9.sym.txt:jdk.naming.rmi-9.sym.txt:jdk.net-9.sym.txt:jdk.pack-9.sym.txt:jdk.policytool-9.sym.txt:jdk.rmic-9.sym.txt:jdk.scripting.nashorn-9.sym.txt:jdk.sctp-9.sym.txt:jdk.security.auth-9.sym.txt:jdk.security.jgss-9.sym.txt:jdk.unsupported-9.sym.txt:jdk.xml.dom-9.sym.txt:jdk.zipfs-9.sym.txt platform version A base 9 files java.activation-A.sym.txt:java.base-A.sym.txt:java.compiler-A.sym.txt:java.corba-A.sym.txt:java.datatransfer-A.sym.txt:java.desktop-A.sym.txt:java.instrument-A.sym.txt:java.logging-A.sym.txt:java.management-A.sym.txt:java.management.rmi-A.sym.txt:java.naming-A.sym.txt:java.prefs-A.sym.txt:java.rmi-A.sym.txt:java.scripting-A.sym.txt:java.se-A.sym.txt:java.se.ee-A.sym.txt:java.security.jgss-A.sym.txt:java.security.sasl-A.sym.txt:java.smartcardio-A.sym.txt:java.sql-A.sym.txt:java.sql.rowset-A.sym.txt:java.transaction-A.sym.txt:java.xml-A.sym.txt:java.xml.bind-A.sym.txt:java.xml.crypto-A.sym.txt:java.xml.ws-A.sym.txt:java.xml.ws.annotation-A.sym.txt:jdk.accessibility-A.sym.txt:jdk.attach-A.sym.txt:jdk.charsets-A.sym.txt:jdk.compiler-A.sym.txt:jdk.crypto.cryptoki-A.sym.txt:jdk.crypto.ec-A.sym.txt:jdk.dynalink-A.sym.txt:jdk.editpad-A.sym.txt:jdk.hotspot.agent-A.sym.txt:jdk.httpserver-A.sym.txt:jdk.incubator.httpclient-A.sym.txt:jdk.jartool-A.sym.txt:jdk.javadoc-A.sym.txt:jdk.jcmd-A.sym.txt:jdk.jconsole-A.sym.txt:jdk.jdeps-A.sym.txt:jdk.jdi-A.sym.txt:jdk.jdwp.agent-A.sym.txt:jdk.jlink-A.sym.txt:jdk.jshell-A.sym.txt:jdk.jsobject-A.sym.txt:jdk.jstatd-A.sym.txt:jdk.localedata-A.sym.txt:jdk.management-A.sym.txt:jdk.management.agent-A.sym.txt:jdk.naming.dns-A.sym.txt:jdk.naming.rmi-A.sym.txt:jdk.net-A.sym.txt:jdk.pack-A.sym.txt:jdk.policytool-A.sym.txt:jdk.rmic-A.sym.txt:jdk.scripting.nashorn-A.sym.txt:jdk.sctp-A.sym.txt:jdk.security.auth-A.sym.txt:jdk.security.jgss-A.sym.txt:jdk.unsupported-A.sym.txt:jdk.xml.dom-A.sym.txt:jdk.zipfs-A.sym.txt platform version B base A files java.activation-B.sym.txt:java.base-B.sym.txt:java.compiler-B.sym.txt:java.corba-B.sym.txt:java.datatransfer-B.sym.txt:java.desktop-B.sym.txt:java.instrument-B.sym.txt:java.logging-B.sym.txt:java.management-B.sym.txt:java.management.rmi-B.sym.txt:java.naming-B.sym.txt:java.net.http-B.sym.txt:java.prefs-B.sym.txt:java.rmi-B.sym.txt:java.scripting-B.sym.txt:java.se-B.sym.txt:java.se.ee-B.sym.txt:java.security.jgss-B.sym.txt:java.security.sasl-B.sym.txt:java.smartcardio-B.sym.txt:java.sql-B.sym.txt:java.sql.rowset-B.sym.txt:java.transaction-B.sym.txt:java.transaction.xa-B.sym.txt:java.xml-B.sym.txt:java.xml.bind-B.sym.txt:java.xml.crypto-B.sym.txt:java.xml.ws-B.sym.txt:java.xml.ws.annotation-B.sym.txt:jdk.accessibility-B.sym.txt:jdk.attach-B.sym.txt:jdk.charsets-B.sym.txt:jdk.compiler-B.sym.txt:jdk.crypto.cryptoki-B.sym.txt:jdk.crypto.ec-B.sym.txt:jdk.dynalink-B.sym.txt:jdk.editpad-B.sym.txt:jdk.hotspot.agent-B.sym.txt:jdk.httpserver-B.sym.txt:jdk.incubator.httpclient-B.sym.txt:jdk.jartool-B.sym.txt:jdk.javadoc-B.sym.txt:jdk.jcmd-B.sym.txt:jdk.jconsole-B.sym.txt:jdk.jdeps-B.sym.txt:jdk.jdi-B.sym.txt:jdk.jdwp.agent-B.sym.txt:jdk.jfr-B.sym.txt:jdk.jlink-B.sym.txt:jdk.jshell-B.sym.txt:jdk.jsobject-B.sym.txt:jdk.jstatd-B.sym.txt:jdk.localedata-B.sym.txt:jdk.management-B.sym.txt:jdk.management.agent-B.sym.txt:jdk.management.jfr-B.sym.txt:jdk.naming.dns-B.sym.txt:jdk.naming.rmi-B.sym.txt:jdk.net-B.sym.txt:jdk.pack-B.sym.txt:jdk.rmic-B.sym.txt:jdk.scripting.nashorn-B.sym.txt:jdk.sctp-B.sym.txt:jdk.security.auth-B.sym.txt:jdk.security.jgss-B.sym.txt:jdk.unsupported-B.sym.txt:jdk.xml.dom-B.sym.txt:jdk.zipfs-B.sym.txt +platform version C base B files java.base-C.sym.txt:java.compiler-C.sym.txt:java.desktop-C.sym.txt:java.naming-C.sym.txt:java.rmi-C.sym.txt:java.xml-C.sym.txt:jdk.compiler-C.sym.txt:jdk.jfr-C.sym.txt:jdk.jsobject-C.sym.txt:jdk.unsupported-C.sym.txt From fb05ae21bb1dff2c9b9a1a6c2f125f2eba531532 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Fri, 8 Feb 2019 12:23:16 +0000 Subject: [PATCH 017/101] 8218662: Allow 204 responses with Content-Length:0 Reviewed-by: michaelm --- .../jdk/internal/net/http/MultiExchange.java | 2 +- test/jdk/java/net/httpclient/Response204.java | 36 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/MultiExchange.java b/src/java.net.http/share/classes/jdk/internal/net/http/MultiExchange.java index 4dcf3be0c88..7c5b9fa91ed 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/MultiExchange.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/MultiExchange.java @@ -217,7 +217,7 @@ class MultiExchange { private boolean bodyIsPresent(Response r) { HttpHeaders headers = r.headers(); - if (headers.firstValue("Content-length").isPresent()) + if (headers.firstValueAsLong("Content-length").orElse(0L) != 0L) return true; if (headers.firstValue("Transfer-encoding").isPresent()) return true; diff --git a/test/jdk/java/net/httpclient/Response204.java b/test/jdk/java/net/httpclient/Response204.java index 61d54ce7031..a2c5cf7a690 100644 --- a/test/jdk/java/net/httpclient/Response204.java +++ b/test/jdk/java/net/httpclient/Response204.java @@ -23,7 +23,7 @@ /** * @test - * @bug 8211437 + * @bug 8211437 8218662 * @run main/othervm -Djdk.httpclient.HttpClient.log=headers,requests Response204 * @summary */ @@ -33,11 +33,13 @@ import com.sun.net.httpserver.*; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; import java.util.*; import java.util.concurrent.*; import java.util.logging.*; import java.io.*; import java.net.*; +import static java.net.http.HttpClient.Builder.NO_PROXY; /** * Verify that a 204 response code with no content-length is handled correctly @@ -54,6 +56,7 @@ public class Response204 { InetSocketAddress addr = new InetSocketAddress (0); HttpServer server = HttpServer.create (addr, 0); HttpContext ctx = server.createContext ("/test", handler); + server.createContext ("/zero", new ZeroContentLengthHandler()); ExecutorService executor = Executors.newCachedThreadPool(); server.setExecutor (executor); server.start (); @@ -80,12 +83,31 @@ public class Response204 { } catch (IOException ioe) { System.out.println("OK 2"); } + + // Test 3 + testZeroContentLength(uri.resolve("/zero/xxyy")); + System.out.println ("OK 3"); } finally { server.stop(2); executor.shutdown(); } } + static void testZeroContentLength(URI uri) throws Exception { + System.out.println("--- testZeroContentLength ---"); + HttpClient client = HttpClient.newBuilder().proxy(NO_PROXY).build(); + HttpRequest request = HttpRequest.newBuilder(uri).build(); + HttpResponse response = client.send(request, BodyHandlers.ofString()); + System.out.println("Received response:" + response); + System.out.println("Received headers:" + response.headers()); + if (response.statusCode() != 204) + throw new RuntimeException("Expected 204, got:" + response.statusCode()); + if (response.body() != null && !response.body().equals("")) + throw new RuntimeException("Expected empty response, got: " + response.body()); + if (response.headers().firstValueAsLong("Content-Length").orElse(-1L) != 0L) + throw new RuntimeException("Expected Content-Length:0, in: " + response.headers()); + } + public static boolean error = false; static class Handler implements HttpHandler { @@ -106,4 +128,16 @@ public class Response204 { t.close(); } } + + // A handler that returns a 204 with a `Content-Length: 0` header/value + static class ZeroContentLengthHandler implements HttpHandler { + public void handle(HttpExchange t) throws IOException { + try (InputStream is = t.getRequestBody()) { + is.readAllBytes(); + } + t.getResponseHeaders().set("Content-length", "0"); + t.sendResponseHeaders(204, -1); + t.close(); + } + } } From 32016662c930eb3203b9ad00c0bddc070ae62918 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Fri, 8 Feb 2019 12:55:20 +0100 Subject: [PATCH 018/101] 8217778: StringTable cleanup miscalculates amount of dead objects Reviewed-by: kbarrett --- src/hotspot/share/gc/shared/weakProcessor.cpp | 20 +++++---- .../share/gc/shared/weakProcessor.inline.hpp | 44 +++++++++++++++---- 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/hotspot/share/gc/shared/weakProcessor.cpp b/src/hotspot/share/gc/shared/weakProcessor.cpp index 1eed6db0f5b..97cd65b1d71 100644 --- a/src/hotspot/share/gc/shared/weakProcessor.cpp +++ b/src/hotspot/share/gc/shared/weakProcessor.cpp @@ -35,19 +35,23 @@ #include "utilities/macros.hpp" void WeakProcessor::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive) { - StringTable::reset_dead_counter(); - CountingIsAliveClosure cl(is_alive); FOR_EACH_WEAK_PROCESSOR_PHASE(phase) { if (WeakProcessorPhases::is_serial(phase)) { - WeakProcessorPhases::processor(phase)(&cl, keep_alive); + WeakProcessorPhases::processor(phase)(is_alive, keep_alive); } else { - WeakProcessorPhases::oop_storage(phase)->weak_oops_do(&cl, keep_alive); - } - if (WeakProcessorPhases::is_stringtable(phase)) { - StringTable::inc_dead_counter(cl.num_dead()); + if (WeakProcessorPhases::is_stringtable(phase)) { + StringTable::reset_dead_counter(); + + CountingSkippedIsAliveClosure cl(is_alive, keep_alive); + WeakProcessorPhases::oop_storage(phase)->oops_do(&cl); + + StringTable::inc_dead_counter(cl.num_dead() + cl.num_skipped()); + StringTable::finish_dead_counter(); + } else { + WeakProcessorPhases::oop_storage(phase)->weak_oops_do(is_alive, keep_alive); + } } } - StringTable::finish_dead_counter(); } void WeakProcessor::oops_do(OopClosure* closure) { diff --git a/src/hotspot/share/gc/shared/weakProcessor.inline.hpp b/src/hotspot/share/gc/shared/weakProcessor.inline.hpp index 3f5b7ceee79..57766424662 100644 --- a/src/hotspot/share/gc/shared/weakProcessor.inline.hpp +++ b/src/hotspot/share/gc/shared/weakProcessor.inline.hpp @@ -37,15 +37,15 @@ class BoolObjectClosure; class OopClosure; -template +template class CountingIsAliveClosure : public BoolObjectClosure { - T* _inner; + IsAlive* _inner; size_t _num_dead; size_t _num_total; public: - CountingIsAliveClosure(T* cl) : _inner(cl), _num_dead(0), _num_total(0) { } + CountingIsAliveClosure(IsAlive* cl) : _inner(cl), _num_dead(0), _num_total(0) { } virtual bool do_object_b(oop obj) { bool result = _inner->do_object_b(obj); @@ -58,6 +58,33 @@ public: size_t num_total() const { return _num_total; } }; +template +class CountingSkippedIsAliveClosure : public Closure { + CountingIsAliveClosure _counting_is_alive; + KeepAlive* _keep_alive; + + size_t _num_skipped; + +public: + CountingSkippedIsAliveClosure(IsAlive* is_alive, KeepAlive* keep_alive) : + _counting_is_alive(is_alive), _keep_alive(keep_alive), _num_skipped(0) { } + + void do_oop(oop* p) { + oop obj = *p; + if (obj == NULL) { + _num_skipped++; + } else if (_counting_is_alive.do_object_b(obj)) { + _keep_alive->do_oop(p); + } else { + *p = NULL; + } + } + + size_t num_dead() const { return _counting_is_alive.num_dead(); } + size_t num_skipped() const { return _num_skipped; } + size_t num_total() const { return _counting_is_alive.num_total() + num_skipped(); } +}; + template void WeakProcessor::Task::work(uint worker_id, IsAlive* is_alive, @@ -67,8 +94,8 @@ void WeakProcessor::Task::work(uint worker_id, worker_id, _nworkers); FOR_EACH_WEAK_PROCESSOR_PHASE(phase) { - CountingIsAliveClosure cl(is_alive); if (WeakProcessorPhases::is_serial(phase)) { + CountingIsAliveClosure cl(is_alive); uint serial_index = WeakProcessorPhases::serial_index(phase); if (_serial_phases_done.try_claim_task(serial_index)) { WeakProcessorPhaseTimeTracker pt(_phase_times, phase); @@ -78,15 +105,16 @@ void WeakProcessor::Task::work(uint worker_id, } } } else { + CountingSkippedIsAliveClosure cl(is_alive, keep_alive); WeakProcessorPhaseTimeTracker pt(_phase_times, phase, worker_id); uint storage_index = WeakProcessorPhases::oop_storage_index(phase); - _storage_states[storage_index].weak_oops_do(&cl, keep_alive); + _storage_states[storage_index].oops_do(&cl); if (_phase_times != NULL) { _phase_times->record_worker_items(worker_id, phase, cl.num_dead(), cl.num_total()); } - } - if (WeakProcessorPhases::is_stringtable(phase)) { - StringTable::inc_dead_counter(cl.num_dead()); + if (WeakProcessorPhases::is_stringtable(phase)) { + StringTable::inc_dead_counter(cl.num_dead() + cl.num_skipped()); + } } } From 13256c7908e5231228e2d36ad6b1849fd6acbfd9 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Fri, 8 Feb 2019 12:55:20 +0100 Subject: [PATCH 019/101] 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm Reviewed-by: lkorinth, kbarrett --- .../share/gc/g1/collectionSetChooser.cpp | 406 ++++++++---------- .../share/gc/g1/collectionSetChooser.hpp | 174 +------- src/hotspot/share/gc/g1/g1CollectionSet.cpp | 36 +- src/hotspot/share/gc/g1/g1CollectionSet.hpp | 18 +- .../share/gc/g1/g1CollectionSetCandidates.cpp | 89 ++++ .../share/gc/g1/g1CollectionSetCandidates.hpp | 99 +++++ src/hotspot/share/gc/g1/g1Policy.cpp | 35 +- src/hotspot/share/gc/g1/heapRegion.hpp | 4 +- src/hotspot/share/memory/allocation.cpp | 5 +- 9 files changed, 444 insertions(+), 422 deletions(-) create mode 100644 src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp create mode 100644 src/hotspot/share/gc/g1/g1CollectionSetCandidates.hpp diff --git a/src/hotspot/share/gc/g1/collectionSetChooser.cpp b/src/hotspot/share/gc/g1/collectionSetChooser.cpp index 1a85db83d8a..daa44a30d70 100644 --- a/src/hotspot/share/gc/g1/collectionSetChooser.cpp +++ b/src/hotspot/share/gc/g1/collectionSetChooser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -25,20 +25,21 @@ #include "precompiled.hpp" #include "gc/g1/collectionSetChooser.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" +#include "gc/g1/g1CollectionSetCandidates.hpp" #include "gc/g1/heapRegionRemSet.hpp" #include "gc/shared/space.inline.hpp" #include "runtime/atomic.hpp" +#include "utilities/quickSort.hpp" -// Even though we don't use the GC efficiency in our heuristics as -// much as we used to, we still order according to GC efficiency. This -// will cause regions with a lot of live objects and large RSets to -// end up at the end of the array. Given that we might skip collecting -// the last few old regions, if after a few mixed GCs the remaining -// have reclaimable bytes under a certain threshold, the hope is that -// the ones we'll skip are ones with both large RSets and a lot of -// live objects, not the ones with just a lot of live objects if we +// Order regions according to GC efficiency. This will cause regions with a lot +// of live objects and large remembered sets to end up at the end of the array. +// Given that we might skip collecting the last few old regions, if after a few +// mixed GCs the remaining have reclaimable bytes under a certain threshold, the +// hope is that the ones we'll skip are ones with both large remembered sets and +// a lot of live objects, not the ones with just a lot of live objects if we // ordered according to the amount of reclaimable bytes per region. static int order_regions(HeapRegion* hr1, HeapRegion* hr2) { + // Make sure that NULL entries are moved to the end. if (hr1 == NULL) { if (hr2 == NULL) { return 0; @@ -51,6 +52,7 @@ static int order_regions(HeapRegion* hr1, HeapRegion* hr2) { double gc_eff1 = hr1->gc_efficiency(); double gc_eff2 = hr2->gc_efficiency(); + if (gc_eff1 > gc_eff2) { return -1; } if (gc_eff1 < gc_eff2) { @@ -60,243 +62,209 @@ static int order_regions(HeapRegion* hr1, HeapRegion* hr2) { } } -static int order_regions(HeapRegion** hr1p, HeapRegion** hr2p) { - return order_regions(*hr1p, *hr2p); -} +// Determine collection set candidates: For all regions determine whether they +// should be a collection set candidates, calculate their efficiency, sort and +// return them as G1CollectionSetCandidates instance. +// Threads calculate the GC efficiency of the regions they get to process, and +// put them into some work area unsorted. At the end the array is sorted and +// copied into the G1CollectionSetCandidates instance; the caller will be the new +// owner of this object. +class G1BuildCandidateRegionsTask : public AbstractGangTask { -CollectionSetChooser::CollectionSetChooser() : - // The line below is the worst bit of C++ hackery I've ever written - // (Detlefs, 11/23). You should think of it as equivalent to - // "_regions(100, true)": initialize the growable array and inform it - // that it should allocate its elem array(s) on the C heap. - // - // The first argument, however, is actually a comma expression - // (set_allocation_type(this, C_HEAP), 100). The purpose of the - // set_allocation_type() call is to replace the default allocation - // type for embedded objects STACK_OR_EMBEDDED with C_HEAP. It will - // allow to pass the assert in GenericGrowableArray() which checks - // that a growable array object must be on C heap if elements are. - // - // Note: containing object is allocated on C heap since it is CHeapObj. - // - _regions((ResourceObj::set_allocation_type((address) &_regions, - ResourceObj::C_HEAP), - 100), true /* C_Heap */), - _front(0), _end(0), _first_par_unreserved_idx(0), - _region_live_threshold_bytes(0), _remaining_reclaimable_bytes(0) { - _region_live_threshold_bytes = mixed_gc_live_threshold_bytes(); -} + // Work area for building the set of collection set candidates. Contains references + // to heap regions with their GC efficiencies calculated. To reduce contention + // on claiming array elements, worker threads claim parts of this array in chunks; + // Array elements may be NULL as threads might not get enough regions to fill + // up their chunks completely. + // Final sorting will remove them. + class G1BuildCandidateArray : public StackObj { -#ifndef PRODUCT -void CollectionSetChooser::verify() { - guarantee(_end <= regions_length(), "_end: %u regions length: %u", _end, regions_length()); - guarantee(_front <= _end, "_front: %u _end: %u", _front, _end); - uint index = 0; - size_t sum_of_reclaimable_bytes = 0; - while (index < _front) { - guarantee(regions_at(index) == NULL, - "all entries before _front should be NULL"); - index += 1; - } - HeapRegion *prev = NULL; - while (index < _end) { - HeapRegion *curr = regions_at(index++); - guarantee(curr != NULL, "Regions in _regions array cannot be NULL"); - guarantee(!curr->is_young(), "should not be young!"); - guarantee(!curr->is_pinned(), - "Pinned region should not be in collection set (index %u)", curr->hrm_index()); - if (prev != NULL) { - guarantee(order_regions(prev, curr) != 1, - "GC eff prev: %1.4f GC eff curr: %1.4f", - prev->gc_efficiency(), curr->gc_efficiency()); + uint const _max_size; + uint const _chunk_size; + + HeapRegion** _data; + + uint volatile _cur_claim_idx; + + // Calculates the maximum array size that will be used. + static uint required_array_size(uint num_regions, uint num_workers, uint chunk_size) { + uint const max_waste = num_workers * chunk_size; + // The array should be aligned with respect to chunk_size. + uint const aligned_num_regions = ((num_regions + chunk_size - 1) / chunk_size) * chunk_size; + + return aligned_num_regions + max_waste; } - sum_of_reclaimable_bytes += curr->reclaimable_bytes(); - prev = curr; - } - guarantee(sum_of_reclaimable_bytes == _remaining_reclaimable_bytes, - "reclaimable bytes inconsistent, " - "remaining: " SIZE_FORMAT " sum: " SIZE_FORMAT, - _remaining_reclaimable_bytes, sum_of_reclaimable_bytes); -} -#endif // !PRODUCT -void CollectionSetChooser::sort_regions() { - // First trim any unused portion of the top in the parallel case. - if (_first_par_unreserved_idx > 0) { - assert(_first_par_unreserved_idx <= regions_length(), - "Or we didn't reserved enough length"); - regions_trunc_to(_first_par_unreserved_idx); - } - _regions.sort(order_regions); - assert(_end <= regions_length(), "Requirement"); -#ifdef ASSERT - for (uint i = 0; i < _end; i++) { - assert(regions_at(i) != NULL, "Should be true by sorting!"); - } -#endif // ASSERT - if (log_is_enabled(Trace, gc, liveness)) { - G1PrintRegionLivenessInfoClosure cl("Post-Sorting"); - for (uint i = 0; i < _end; ++i) { - HeapRegion* r = regions_at(i); - cl.do_heap_region(r); + public: + G1BuildCandidateArray(uint max_num_regions, uint num_workers, uint chunk_size) : + _max_size(required_array_size(max_num_regions, num_workers, chunk_size)), + _chunk_size(chunk_size), + _data(NEW_C_HEAP_ARRAY(HeapRegion*, _max_size, mtGC)), + _cur_claim_idx(0) { + for (uint i = 0; i < _max_size; i++) { + _data[i] = NULL; + } } - } - verify(); -} -void CollectionSetChooser::add_region(HeapRegion* hr) { - assert(!hr->is_pinned(), - "Pinned region shouldn't be added to the collection set (index %u)", hr->hrm_index()); - assert(hr->is_old(), "should be old but is %s", hr->get_type_str()); - assert(hr->rem_set()->is_complete(), - "Trying to add region %u to the collection set with incomplete remembered set", hr->hrm_index()); - _regions.append(hr); - _end++; - _remaining_reclaimable_bytes += hr->reclaimable_bytes(); - hr->calc_gc_efficiency(); -} - -void CollectionSetChooser::push(HeapRegion* hr) { - assert(hr != NULL, "Can't put back a NULL region"); - assert(_front >= 1, "Too many regions have been put back"); - _front--; - regions_at_put(_front, hr); - _remaining_reclaimable_bytes += hr->reclaimable_bytes(); -} - -void CollectionSetChooser::prepare_for_par_region_addition(uint n_threads, - uint n_regions, - uint chunk_size) { - _first_par_unreserved_idx = 0; - uint max_waste = n_threads * chunk_size; - // it should be aligned with respect to chunk_size - uint aligned_n_regions = (n_regions + chunk_size - 1) / chunk_size * chunk_size; - assert(aligned_n_regions % chunk_size == 0, "should be aligned"); - regions_at_put_grow(aligned_n_regions + max_waste - 1, NULL); -} - -uint CollectionSetChooser::claim_array_chunk(uint chunk_size) { - uint res = (uint) Atomic::add((jint) chunk_size, - (volatile jint*) &_first_par_unreserved_idx); - assert(regions_length() > res + chunk_size - 1, - "Should already have been expanded"); - return res - chunk_size; -} - -void CollectionSetChooser::set_region(uint index, HeapRegion* hr) { - assert(regions_at(index) == NULL, "precondition"); - assert(hr->is_old(), "should be old but is %s", hr->get_type_str()); - regions_at_put(index, hr); - hr->calc_gc_efficiency(); -} - -void CollectionSetChooser::update_totals(uint region_num, - size_t reclaimable_bytes) { - // Only take the lock if we actually need to update the totals. - if (region_num > 0) { - assert(reclaimable_bytes > 0, "invariant"); - // We could have just used atomics instead of taking the - // lock. However, we currently don't have an atomic add for size_t. - MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag); - _end += region_num; - _remaining_reclaimable_bytes += reclaimable_bytes; - } else { - assert(reclaimable_bytes == 0, "invariant"); - } -} - -void CollectionSetChooser::iterate(HeapRegionClosure* cl) { - for (uint i = _front; i < _end; i++) { - HeapRegion* r = regions_at(i); - if (cl->do_heap_region(r)) { - cl->set_incomplete(); - break; + ~G1BuildCandidateArray() { + FREE_C_HEAP_ARRAY(HeapRegion*, _data); } - } -} -void CollectionSetChooser::clear() { - _regions.clear(); - _front = 0; - _end = 0; - _remaining_reclaimable_bytes = 0; -} - -class ParKnownGarbageHRClosure: public HeapRegionClosure { - G1CollectedHeap* _g1h; - CSetChooserParUpdater _cset_updater; - -public: - ParKnownGarbageHRClosure(CollectionSetChooser* hrSorted, - uint chunk_size) : - _g1h(G1CollectedHeap::heap()), - _cset_updater(hrSorted, true /* parallel */, chunk_size) { } - - bool do_heap_region(HeapRegion* r) { - // We will skip any region that's currently used as an old GC - // alloc region (we should not consider those for collection - // before we fill them up). - if (_cset_updater.should_add(r) && !_g1h->is_old_gc_alloc_region(r)) { - _cset_updater.add_region(r); - } else if (r->is_old()) { - // Keep remembered sets for humongous regions, otherwise clean out remembered - // sets for old regions. - r->rem_set()->clear(true /* only_cardset */); - } else { - assert(r->is_archive() || !r->is_old() || !r->rem_set()->is_tracked(), - "Missed to clear unused remembered set of region %u (%s) that is %s", - r->hrm_index(), r->get_type_str(), r->rem_set()->get_state_str()); + // Claim a new chunk, returning its bounds [from, to[. + void claim_chunk(uint& from, uint& to) { + uint result = Atomic::add(_chunk_size, &_cur_claim_idx); + assert(_max_size > result - 1, + "Array too small, is %u should be %u with chunk size %u.", + _max_size, result, _chunk_size); + from = result - _chunk_size; + to = result; } - return false; - } -}; -class ParKnownGarbageTask: public AbstractGangTask { - CollectionSetChooser* _hrSorted; - uint _chunk_size; + // Set element in array. + void set(uint idx, HeapRegion* hr) { + assert(idx < _max_size, "Index %u out of bounds %u", idx, _max_size); + assert(_data[idx] == NULL, "Value must not have been set."); + _data[idx] = hr; + } + + void sort_and_copy_into(HeapRegion** dest, uint num_regions) { + if (_cur_claim_idx == 0) { + return; + } + for (uint i = _cur_claim_idx; i < _max_size; i++) { + assert(_data[i] == NULL, "must be"); + } + QuickSort::sort(_data, _cur_claim_idx, order_regions, true); + for (uint i = num_regions; i < _max_size; i++) { + assert(_data[i] == NULL, "must be"); + } + for (uint i = 0; i < num_regions; i++) { + dest[i] = _data[i]; + } + } + }; + + // Per-region closure. In addition to determining whether a region should be + // added to the candidates, and calculating those regions' gc efficiencies, also + // gather additional statistics. + class G1BuildCandidateRegionsClosure : public HeapRegionClosure { + G1BuildCandidateArray* _array; + + uint _cur_chunk_idx; + uint _cur_chunk_end; + + uint _regions_added; + size_t _reclaimable_bytes_added; + + void add_region(HeapRegion* hr) { + if (_cur_chunk_idx == _cur_chunk_end) { + _array->claim_chunk(_cur_chunk_idx, _cur_chunk_end); + } + assert(_cur_chunk_idx < _cur_chunk_end, "Must be"); + + hr->calc_gc_efficiency(); + _array->set(_cur_chunk_idx, hr); + + _cur_chunk_idx++; + + _regions_added++; + _reclaimable_bytes_added += hr->reclaimable_bytes(); + } + + bool should_add(HeapRegion* hr) { return CollectionSetChooser::should_add(hr); } + + public: + G1BuildCandidateRegionsClosure(G1BuildCandidateArray* array) : + _array(array), + _cur_chunk_idx(0), + _cur_chunk_end(0), + _regions_added(0), + _reclaimable_bytes_added(0) { } + + bool do_heap_region(HeapRegion* r) { + // We will skip any region that's currently used as an old GC + // alloc region (we should not consider those for collection + // before we fill them up). + if (should_add(r) && !G1CollectedHeap::heap()->is_old_gc_alloc_region(r)) { + add_region(r); + } else if (r->is_old()) { + // Keep remembered sets for humongous regions, otherwise clean out remembered + // sets for old regions. + r->rem_set()->clear(true /* only_cardset */); + } else { + assert(r->is_archive() || !r->is_old() || !r->rem_set()->is_tracked(), + "Missed to clear unused remembered set of region %u (%s) that is %s", + r->hrm_index(), r->get_type_str(), r->rem_set()->get_state_str()); + } + return false; + } + + uint regions_added() const { return _regions_added; } + size_t reclaimable_bytes_added() const { return _reclaimable_bytes_added; } + }; + G1CollectedHeap* _g1h; HeapRegionClaimer _hrclaimer; + uint volatile _num_regions_added; + size_t volatile _reclaimable_bytes_added; + + G1BuildCandidateArray _result; + + void update_totals(uint num_regions, size_t reclaimable_bytes) { + if (num_regions > 0) { + assert(reclaimable_bytes > 0, "invariant"); + Atomic::add(num_regions, &_num_regions_added); + Atomic::add(reclaimable_bytes, &_reclaimable_bytes_added); + } else { + assert(reclaimable_bytes == 0, "invariant"); + } + } + public: - ParKnownGarbageTask(CollectionSetChooser* hrSorted, uint chunk_size, uint n_workers) : - AbstractGangTask("ParKnownGarbageTask"), - _hrSorted(hrSorted), _chunk_size(chunk_size), - _g1h(G1CollectedHeap::heap()), _hrclaimer(n_workers) {} + G1BuildCandidateRegionsTask(uint max_num_regions, uint chunk_size, uint num_workers) : + AbstractGangTask("G1 Build Candidate Regions"), + _g1h(G1CollectedHeap::heap()), + _hrclaimer(num_workers), + _num_regions_added(0), + _reclaimable_bytes_added(0), + _result(max_num_regions, chunk_size, num_workers) { } void work(uint worker_id) { - ParKnownGarbageHRClosure par_known_garbage_cl(_hrSorted, _chunk_size); - _g1h->heap_region_par_iterate_from_worker_offset(&par_known_garbage_cl, &_hrclaimer, worker_id); + G1BuildCandidateRegionsClosure cl(&_result); + _g1h->heap_region_par_iterate_from_worker_offset(&cl, &_hrclaimer, worker_id); + update_totals(cl.regions_added(), cl.reclaimable_bytes_added()); + } + + G1CollectionSetCandidates* get_sorted_candidates() { + HeapRegion** regions = NEW_C_HEAP_ARRAY(HeapRegion*, _num_regions_added, mtGC); + _result.sort_and_copy_into(regions, _num_regions_added); + return new G1CollectionSetCandidates(regions, + _num_regions_added, + _reclaimable_bytes_added); } }; -uint CollectionSetChooser::calculate_parallel_work_chunk_size(uint n_workers, uint n_regions) const { - assert(n_workers > 0, "Active gc workers should be greater than 0"); - const uint overpartition_factor = 4; - const uint min_chunk_size = MAX2(n_regions / n_workers, 1U); - return MAX2(n_regions / (n_workers * overpartition_factor), min_chunk_size); +uint CollectionSetChooser::calculate_work_chunk_size(uint num_workers, uint num_regions) { + assert(num_workers > 0, "Active gc workers should be greater than 0"); + return MAX2(num_regions / num_workers, 1U); } -bool CollectionSetChooser::region_occupancy_low_enough_for_evac(size_t live_bytes) { - return live_bytes < mixed_gc_live_threshold_bytes(); -} - -bool CollectionSetChooser::should_add(HeapRegion* hr) const { +bool CollectionSetChooser::should_add(HeapRegion* hr) { return !hr->is_young() && !hr->is_pinned() && region_occupancy_low_enough_for_evac(hr->live_bytes()) && hr->rem_set()->is_complete(); } -void CollectionSetChooser::rebuild(WorkGang* workers, uint n_regions) { - clear(); +G1CollectionSetCandidates* CollectionSetChooser::build(WorkGang* workers, uint max_num_regions) { + uint num_workers = workers->active_workers(); + uint chunk_size = calculate_work_chunk_size(num_workers, max_num_regions); - uint n_workers = workers->active_workers(); + G1BuildCandidateRegionsTask cl(max_num_regions, chunk_size, num_workers); + workers->run_task(&cl, num_workers); - uint chunk_size = calculate_parallel_work_chunk_size(n_workers, n_regions); - prepare_for_par_region_addition(n_workers, n_regions, chunk_size); - - ParKnownGarbageTask par_known_garbage_task(this, chunk_size, n_workers); - workers->run_task(&par_known_garbage_task); - - sort_regions(); + G1CollectionSetCandidates* result = cl.get_sorted_candidates(); + result->verify(); + return result; } diff --git a/src/hotspot/share/gc/g1/collectionSetChooser.hpp b/src/hotspot/share/gc/g1/collectionSetChooser.hpp index 915eb62509c..aea46263578 100644 --- a/src/hotspot/share/gc/g1/collectionSetChooser.hpp +++ b/src/hotspot/share/gc/g1/collectionSetChooser.hpp @@ -26,177 +26,35 @@ #define SHARE_GC_G1_COLLECTIONSETCHOOSER_HPP #include "gc/g1/heapRegion.hpp" -#include "utilities/growableArray.hpp" +#include "memory/allocation.hpp" +#include "runtime/globals.hpp" -class CollectionSetChooser: public CHeapObj { +class G1CollectionSetCandidates; +class WorkGang; - GrowableArray _regions; - - // Unfortunately, GrowableArray uses ints for length and indexes. To - // avoid excessive casting in the rest of the class the following - // wrapper methods are provided that use uints. - - uint regions_length() { return (uint) _regions.length(); } - HeapRegion* regions_at(uint i) { return _regions.at((int) i); } - void regions_at_put(uint i, HeapRegion* hr) { - _regions.at_put((int) i, hr); - } - void regions_at_put_grow(uint i, HeapRegion* hr) { - _regions.at_put_grow((int) i, hr); - } - void regions_trunc_to(uint i) { _regions.trunc_to((uint) i); } - - // The index of the next candidate old region to be considered for - // addition to the CSet. - uint _front; - - // The index of the last candidate old region - uint _end; - - // Keeps track of the start of the next array chunk to be claimed by - // parallel GC workers. - uint _first_par_unreserved_idx; - - // If a region has more live bytes than this threshold, it will not - // be added to the CSet chooser and will not be a candidate for - // collection. - size_t _region_live_threshold_bytes; - - // The sum of reclaimable bytes over all the regions in the CSet chooser. - size_t _remaining_reclaimable_bytes; - - // Calculate and return chunk size (in number of regions) for parallel - // addition of regions - uint calculate_parallel_work_chunk_size(uint n_workers, uint n_regions) const; +// Helper class to calculate collection set candidates, and containing some related +// methods. +class CollectionSetChooser : public AllStatic { + static uint calculate_work_chunk_size(uint num_workers, uint num_regions); public: - // Return the current candidate region to be considered for - // collection without removing it from the CSet chooser. - HeapRegion* peek() { - HeapRegion* res = NULL; - if (_front < _end) { - res = regions_at(_front); - assert(res != NULL, "Unexpected NULL hr in _regions at index %u", _front); - } - return res; - } - - // Remove the given region from the CSet chooser and move to the - // next one. - HeapRegion* pop() { - HeapRegion* hr = regions_at(_front); - assert(hr != NULL, "pre-condition"); - assert(_front < _end, "pre-condition"); - regions_at_put(_front, NULL); - assert(hr->reclaimable_bytes() <= _remaining_reclaimable_bytes, - "remaining reclaimable bytes inconsistent " - "from region: " SIZE_FORMAT " remaining: " SIZE_FORMAT, - hr->reclaimable_bytes(), _remaining_reclaimable_bytes); - _remaining_reclaimable_bytes -= hr->reclaimable_bytes(); - _front += 1; - return hr; - } - - void push(HeapRegion* hr); - - CollectionSetChooser(); - static size_t mixed_gc_live_threshold_bytes() { return HeapRegion::GrainBytes * (size_t) G1MixedGCLiveThresholdPercent / 100; } - static bool region_occupancy_low_enough_for_evac(size_t live_bytes); + static bool region_occupancy_low_enough_for_evac(size_t live_bytes) { + return live_bytes < mixed_gc_live_threshold_bytes(); + } - void sort_regions(); - - // Determine whether to add the given region to the CSet chooser or + // Determine whether to add the given region to the collection set candidates or // not. Currently, we skip pinned regions and regions whose live // bytes are over the threshold. Humongous regions may be reclaimed during cleanup. // Regions also need a complete remembered set to be a candidate. - bool should_add(HeapRegion* hr) const; + static bool should_add(HeapRegion* hr); - // Returns the number candidate old regions added - uint length() { return _end; } - - // Serial version. - void add_region(HeapRegion *hr); - - // Must be called before calls to claim_array_chunk(). - // n_regions is the number of regions, chunk_size the chunk size. - void prepare_for_par_region_addition(uint n_threads, uint n_regions, uint chunk_size); - // Returns the first index in a contiguous chunk of chunk_size indexes - // that the calling thread has reserved. These must be set by the - // calling thread using set_region() (to NULL if necessary). - uint claim_array_chunk(uint chunk_size); - // Set the marked array entry at index to hr. Careful to claim the index - // first if in parallel. - void set_region(uint index, HeapRegion* hr); - // Atomically increment the number of added regions by region_num - // and the amount of reclaimable bytes by reclaimable_bytes. - void update_totals(uint region_num, size_t reclaimable_bytes); - - // Iterate over all collection set candidate regions. - void iterate(HeapRegionClosure* cl); - - void clear(); - - void rebuild(WorkGang* workers, uint n_regions); - - // Return the number of candidate regions that remain to be collected. - uint remaining_regions() { return _end - _front; } - - // Determine whether the CSet chooser has more candidate regions or not. - bool is_empty() { return remaining_regions() == 0; } - - // Return the reclaimable bytes that remain to be collected on - // all the candidate regions in the CSet chooser. - size_t remaining_reclaimable_bytes() { return _remaining_reclaimable_bytes; } - - // Returns true if the used portion of "_regions" is properly - // sorted, otherwise asserts false. - void verify() PRODUCT_RETURN; -}; - -class CSetChooserParUpdater : public StackObj { -private: - CollectionSetChooser* _chooser; - bool _parallel; - uint _chunk_size; - uint _cur_chunk_idx; - uint _cur_chunk_end; - uint _regions_added; - size_t _reclaimable_bytes_added; - -public: - CSetChooserParUpdater(CollectionSetChooser* chooser, - bool parallel, uint chunk_size) : - _chooser(chooser), _parallel(parallel), _chunk_size(chunk_size), - _cur_chunk_idx(0), _cur_chunk_end(0), - _regions_added(0), _reclaimable_bytes_added(0) { } - - ~CSetChooserParUpdater() { - if (_parallel && _regions_added > 0) { - _chooser->update_totals(_regions_added, _reclaimable_bytes_added); - } - } - - void add_region(HeapRegion* hr) { - if (_parallel) { - if (_cur_chunk_idx == _cur_chunk_end) { - _cur_chunk_idx = _chooser->claim_array_chunk(_chunk_size); - _cur_chunk_end = _cur_chunk_idx + _chunk_size; - } - assert(_cur_chunk_idx < _cur_chunk_end, "invariant"); - _chooser->set_region(_cur_chunk_idx, hr); - _cur_chunk_idx += 1; - } else { - _chooser->add_region(hr); - } - _regions_added += 1; - _reclaimable_bytes_added += hr->reclaimable_bytes(); - } - - bool should_add(HeapRegion* hr) { return _chooser->should_add(hr); } + // Build and return set of collection set candidates sorted by decreasing gc + // efficiency. + static G1CollectionSetCandidates* build(WorkGang* workers, uint max_num_regions); }; #endif // SHARE_GC_G1_COLLECTIONSETCHOOSER_HPP diff --git a/src/hotspot/share/gc/g1/g1CollectionSet.cpp b/src/hotspot/share/gc/g1/g1CollectionSet.cpp index 2a2d1af52b4..d67fb10829a 100644 --- a/src/hotspot/share/gc/g1/g1CollectionSet.cpp +++ b/src/hotspot/share/gc/g1/g1CollectionSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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 @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectionSet.hpp" +#include "gc/g1/g1CollectionSetCandidates.hpp" #include "gc/g1/g1CollectorState.hpp" #include "gc/g1/g1ParScanThreadState.hpp" #include "gc/g1/g1Policy.hpp" @@ -44,10 +45,6 @@ G1GCPhaseTimes* G1CollectionSet::phase_times() { return _policy->phase_times(); } -CollectionSetChooser* G1CollectionSet::cset_chooser() { - return _cset_chooser; -} - double G1CollectionSet::predict_region_elapsed_time_ms(HeapRegion* hr) { return _policy->predict_region_elapsed_time_ms(hr, collector_state()->in_young_only_phase()); } @@ -55,7 +52,7 @@ double G1CollectionSet::predict_region_elapsed_time_ms(HeapRegion* hr) { G1CollectionSet::G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy) : _g1h(g1h), _policy(policy), - _cset_chooser(new CollectionSetChooser()), + _candidates(NULL), _eden_region_length(0), _survivor_region_length(0), _old_region_length(0), @@ -80,7 +77,7 @@ G1CollectionSet::~G1CollectionSet() { FREE_C_HEAP_ARRAY(uint, _collection_set_regions); } free_optional_regions(); - delete _cset_chooser; + clear_candidates(); } void G1CollectionSet::init_region_lengths(uint eden_cset_region_length, @@ -120,6 +117,11 @@ void G1CollectionSet::free_optional_regions() { } } +void G1CollectionSet::clear_candidates() { + delete _candidates; + _candidates = NULL; +} + void G1CollectionSet::set_recorded_rs_lengths(size_t rs_lengths) { _recorded_rs_lengths = rs_lengths; } @@ -439,14 +441,14 @@ double G1CollectionSet::finalize_young_part(double target_pause_time_ms, G1Survi } void G1CollectionSet::add_as_old(HeapRegion* hr) { - cset_chooser()->pop(); // already have region via peek() + candidates()->pop_front(); // already have region via peek() _g1h->old_set_remove(hr); add_old_region(hr); } void G1CollectionSet::add_as_optional(HeapRegion* hr) { assert(_optional_regions != NULL, "Must not be called before array is allocated"); - cset_chooser()->pop(); // already have region via peek() + candidates()->pop_front(); // already have region via peek() _g1h->old_set_remove(hr); add_optional_region(hr); } @@ -480,7 +482,7 @@ void G1CollectionSet::finalize_old_part(double time_remaining_ms) { uint expensive_region_num = 0; if (collector_state()->in_mixed_phase()) { - cset_chooser()->verify(); + candidates()->verify(); const uint min_old_cset_length = _policy->calc_min_old_cset_length(); const uint max_old_cset_length = MAX2(min_old_cset_length, _policy->calc_max_old_cset_length()); bool check_time_remaining = _policy->adaptive_young_list_length(); @@ -490,7 +492,7 @@ void G1CollectionSet::finalize_old_part(double time_remaining_ms) { "time remaining %1.2fms, optional threshold %1.2fms", min_old_cset_length, max_old_cset_length, time_remaining_ms, optional_threshold_ms); - HeapRegion* hr = cset_chooser()->peek(); + HeapRegion* hr = candidates()->peek_front(); while (hr != NULL) { if (old_region_length() + optional_region_length() >= max_old_cset_length) { // Added maximum number of old regions to the CSet. @@ -502,7 +504,7 @@ void G1CollectionSet::finalize_old_part(double time_remaining_ms) { // Stop adding regions if the remaining reclaimable space is // not above G1HeapWastePercent. - size_t reclaimable_bytes = cset_chooser()->remaining_reclaimable_bytes(); + size_t reclaimable_bytes = candidates()->remaining_reclaimable_bytes(); double reclaimable_percent = _policy->reclaimable_bytes_percent(reclaimable_bytes); double threshold = (double) G1HeapWastePercent; if (reclaimable_percent <= threshold) { @@ -551,13 +553,13 @@ void G1CollectionSet::finalize_old_part(double time_remaining_ms) { break; } } - hr = cset_chooser()->peek(); + hr = candidates()->peek_front(); } if (hr == NULL) { log_debug(gc, ergo, cset)("Finish adding old regions to CSet (candidate old regions not available)"); } - cset_chooser()->verify(); + candidates()->verify(); } stop_incremental_building(); @@ -630,15 +632,15 @@ bool G1OptionalCSet::evacuation_failed() { G1OptionalCSet::~G1OptionalCSet() { G1CollectedHeap* g1h = G1CollectedHeap::heap(); while (!is_empty()) { - // We want to return regions not evacuated to the - // chooser in reverse order to maintain the old order. + // We want to return regions not evacuated to the collection set candidates + // in reverse order to maintain the old order. HeapRegion* hr = _cset->remove_last_optional_region(); assert(hr != NULL, "Should be valid region left"); _pset->record_unused_optional_region(hr); g1h->old_set_add(hr); g1h->clear_in_cset(hr); hr->set_index_in_opt_cset(InvalidCSetIndex); - _cset->cset_chooser()->push(hr); + _cset->candidates()->push_front(hr); } _cset->free_optional_regions(); } diff --git a/src/hotspot/share/gc/g1/g1CollectionSet.hpp b/src/hotspot/share/gc/g1/g1CollectionSet.hpp index 2b438d5d259..aa800980510 100644 --- a/src/hotspot/share/gc/g1/g1CollectionSet.hpp +++ b/src/hotspot/share/gc/g1/g1CollectionSet.hpp @@ -25,23 +25,25 @@ #ifndef SHARE_GC_G1_G1COLLECTIONSET_HPP #define SHARE_GC_G1_G1COLLECTIONSET_HPP -#include "gc/g1/collectionSetChooser.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" class G1CollectedHeap; +class G1CollectionSetCandidates; class G1CollectorState; class G1GCPhaseTimes; class G1ParScanThreadStateSet; class G1Policy; class G1SurvivorRegions; class HeapRegion; +class HeapRegionClosure; class G1CollectionSet { G1CollectedHeap* _g1h; G1Policy* _policy; - CollectionSetChooser* _cset_chooser; + // All old gen collection set candidate regions for the current mixed gc phase. + G1CollectionSetCandidates* _candidates; uint _eden_region_length; uint _survivor_region_length; @@ -128,7 +130,13 @@ public: void initialize_optional(uint max_length); void free_optional_regions(); - CollectionSetChooser* cset_chooser(); + void clear_candidates(); + + void set_candidates(G1CollectionSetCandidates* candidates) { + assert(_candidates == NULL, "Trying to replace collection set candidates."); + _candidates = candidates; + } + G1CollectionSetCandidates* candidates() { return _candidates; } void init_region_lengths(uint eden_cset_region_length, uint survivor_cset_region_length); @@ -253,8 +261,8 @@ public: _current_limit(0), _prepare_failed(false), _evacuation_failed(false) { } - // The destructor returns regions to the cset-chooser and - // frees the optional structure in the cset. + // The destructor returns regions to the collection set candidates set and + // frees the optional structure in the collection set. ~G1OptionalCSet(); uint current_index() { return _current_index; } diff --git a/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp new file mode 100644 index 00000000000..a9c24f7316b --- /dev/null +++ b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2019, 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/g1/collectionSetChooser.hpp" +#include "gc/g1/g1CollectionSetCandidates.hpp" +#include "gc/g1/heapRegion.inline.hpp" + +HeapRegion* G1CollectionSetCandidates::pop_front() { + assert(_front_idx < _num_regions, "pre-condition"); + HeapRegion* hr = _regions[_front_idx]; + assert(hr != NULL, "pre-condition"); + _regions[_front_idx] = NULL; + assert(hr->reclaimable_bytes() <= _remaining_reclaimable_bytes, + "Remaining reclaimable bytes inconsistent " + "from region: " SIZE_FORMAT " remaining: " SIZE_FORMAT, + hr->reclaimable_bytes(), _remaining_reclaimable_bytes); + _remaining_reclaimable_bytes -= hr->reclaimable_bytes(); + _front_idx++; + return hr; +} + +void G1CollectionSetCandidates::push_front(HeapRegion* hr) { + assert(hr != NULL, "Can't put back a NULL region"); + assert(_front_idx >= 1, "Too many regions have been put back."); + _front_idx--; + _regions[_front_idx] = hr; + _remaining_reclaimable_bytes += hr->reclaimable_bytes(); +} + +void G1CollectionSetCandidates::iterate(HeapRegionClosure* cl) { + for (uint i = _front_idx; i < _num_regions; i++) { + HeapRegion* r = _regions[i]; + if (cl->do_heap_region(r)) { + cl->set_incomplete(); + break; + } + } +} + +#ifndef PRODUCT +void G1CollectionSetCandidates::verify() const { + guarantee(_front_idx <= _num_regions, "Index: %u Num_regions: %u", _front_idx, _num_regions); + uint idx = 0; + size_t sum_of_reclaimable_bytes = 0; + while (idx < _front_idx) { + guarantee(_regions[idx] == NULL, "All entries before _front_idx %u should be NULL, but %u is not", + _front_idx, idx); + idx++; + } + HeapRegion *prev = NULL; + for (; idx < _num_regions; idx++) { + HeapRegion *cur = _regions[idx]; + guarantee(cur != NULL, "Regions after _front_idx %u cannot be NULL but %u is", _front_idx, idx); + guarantee(CollectionSetChooser::should_add(cur), "Region %u should be eligible for addition.", cur->hrm_index()); + if (prev != NULL) { + guarantee(prev->gc_efficiency() >= cur->gc_efficiency(), + "GC efficiency for region %u: %1.4f smaller than for region %u: %1.4f", + prev->hrm_index(), prev->gc_efficiency(), cur->hrm_index(), cur->gc_efficiency()); + } + sum_of_reclaimable_bytes += cur->reclaimable_bytes(); + prev = cur; + } + guarantee(sum_of_reclaimable_bytes == _remaining_reclaimable_bytes, + "Inconsistent remaining_reclaimable bytes, remaining " SIZE_FORMAT " calculated " SIZE_FORMAT, + _remaining_reclaimable_bytes, sum_of_reclaimable_bytes); +} +#endif // !PRODUCT diff --git a/src/hotspot/share/gc/g1/g1CollectionSetCandidates.hpp b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.hpp new file mode 100644 index 00000000000..7eb73a156be --- /dev/null +++ b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.hpp @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2019, 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_GC_G1_G1COLLECTIONSETCANDIDATES_HPP +#define SHARE_GC_G1_G1COLLECTIONSETCANDIDATES_HPP + +#include "gc/g1/g1CollectionSetCandidates.hpp" +#include "gc/shared/workgroup.hpp" +#include "memory/allocation.hpp" +#include "runtime/globals.hpp" + +class HeapRegion; +class HeapRegionClosure; + +// Set of collection set candidates, i.e. all old gen regions we consider worth +// collecting in the remainder of the current mixed phase. Regions are sorted by decreasing +// gc efficiency. +// Maintains a cursor into the list that specifies the next collection set candidate +// to put into the current collection set. +class G1CollectionSetCandidates : public CHeapObj { + HeapRegion** _regions; + uint _num_regions; // Total number of regions in the collection set candidate set. + + // The sum of bytes that can be reclaimed in the remaining set of collection + // set candidates. + size_t _remaining_reclaimable_bytes; + // The index of the next candidate old region to be considered for + // addition to the current collection set. + uint _front_idx; + +public: + G1CollectionSetCandidates(HeapRegion** regions, uint num_regions, size_t remaining_reclaimable_bytes) : + _regions(regions), + _num_regions(num_regions), + _remaining_reclaimable_bytes(remaining_reclaimable_bytes), + _front_idx(0) { } + + ~G1CollectionSetCandidates() { + FREE_C_HEAP_ARRAY(HeapRegion*, _regions); + } + + // Returns the total number of collection set candidate old regions added. + uint num_regions() { return _num_regions; } + + // Return the candidate region at the cursor position to be considered for collection without + // removing it. + HeapRegion* peek_front() { + HeapRegion* res = NULL; + if (_front_idx < _num_regions) { + res = _regions[_front_idx]; + assert(res != NULL, "Unexpected NULL HeapRegion at index %u", _front_idx); + } + return res; + } + + // Remove the given region from the candidates set and move the cursor to the next one. + HeapRegion* pop_front(); + + // Add the given HeapRegion to the front of the collection set candidate set again. + void push_front(HeapRegion* hr); + + // Iterate over all remaining collection set candidate regions. + void iterate(HeapRegionClosure* cl); + + // Return the number of candidate regions remaining. + uint num_remaining() { return _num_regions - _front_idx; } + + bool is_empty() { return num_remaining() == 0; } + + // Return the amount of reclaimable bytes that may be collected by the remaining + // candidate regions. + size_t remaining_reclaimable_bytes() { return _remaining_reclaimable_bytes; } + + void verify() const PRODUCT_RETURN; +}; + +#endif /* SHARE_GC_G1_G1COLLECTIONSETCANDIDATES_HPP */ + diff --git a/src/hotspot/share/gc/g1/g1Policy.cpp b/src/hotspot/share/gc/g1/g1Policy.cpp index 31887f9e4da..8907602ea93 100644 --- a/src/hotspot/share/gc/g1/g1Policy.cpp +++ b/src/hotspot/share/gc/g1/g1Policy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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,9 +23,11 @@ */ #include "precompiled.hpp" +#include "gc/g1/collectionSetChooser.hpp" #include "gc/g1/g1Analytics.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectionSet.hpp" +#include "gc/g1/g1CollectionSetCandidates.hpp" #include "gc/g1/g1ConcurrentMark.hpp" #include "gc/g1/g1ConcurrentMarkThread.inline.hpp" #include "gc/g1/g1ConcurrentRefine.hpp" @@ -438,7 +440,7 @@ void G1Policy::record_full_collection_start() { // Release the future to-space so that it is available for compaction into. collector_state()->set_in_young_only_phase(false); collector_state()->set_in_full_gc(true); - cset_chooser()->clear(); + _collection_set->clear_candidates(); } void G1Policy::record_full_collection_end() { @@ -546,10 +548,6 @@ double G1Policy::constant_other_time_ms(double pause_time_ms) const { return other_time_ms(pause_time_ms) - phase_times()->total_free_cset_time_ms(); } -CollectionSetChooser* G1Policy::cset_chooser() const { - return _collection_set->cset_chooser(); -} - bool G1Policy::about_to_start_mixed_phase() const { return _g1h->concurrent_mark()->cm_thread()->during_cycle() || collector_state()->in_young_gc_before_mixed(); } @@ -773,8 +771,6 @@ void G1Policy::record_collection_pause_end(double pause_time_ms, size_t cards_sc _g1h->concurrent_refine()->adjust(average_time_ms(G1GCPhaseTimes::UpdateRS), phase_times()->sum_thread_work_items(G1GCPhaseTimes::UpdateRS), update_rs_time_goal_ms); - - cset_chooser()->verify(); } G1IHOPControl* G1Policy::create_ihop_control(const G1Predictions* predictor){ @@ -1032,7 +1028,8 @@ void G1Policy::decide_on_conc_mark_initiation() { } void G1Policy::record_concurrent_mark_cleanup_end() { - cset_chooser()->rebuild(_g1h->workers(), _g1h->num_regions()); + G1CollectionSetCandidates* candidates = CollectionSetChooser::build(_g1h->workers(), _g1h->num_regions()); + _collection_set->set_candidates(candidates); bool mixed_gc_pending = next_gc_should_be_mixed("request mixed gcs", "request young-only gcs"); if (!mixed_gc_pending) { @@ -1063,10 +1060,10 @@ class G1ClearCollectionSetCandidateRemSets : public HeapRegionClosure { void G1Policy::clear_collection_set_candidates() { // Clear remembered sets of remaining candidate regions and the actual candidate - // list. + // set. G1ClearCollectionSetCandidateRemSets cl; - cset_chooser()->iterate(&cl); - cset_chooser()->clear(); + _collection_set->candidates()->iterate(&cl); + _collection_set->clear_candidates(); } void G1Policy::maybe_start_marking() { @@ -1132,22 +1129,24 @@ void G1Policy::abort_time_to_mixed_tracking() { bool G1Policy::next_gc_should_be_mixed(const char* true_action_str, const char* false_action_str) const { - if (cset_chooser()->is_empty()) { + G1CollectionSetCandidates* candidates = _collection_set->candidates(); + + if (candidates->is_empty()) { log_debug(gc, ergo)("%s (candidate old regions not available)", false_action_str); return false; } // Is the amount of uncollected reclaimable space above G1HeapWastePercent? - size_t reclaimable_bytes = cset_chooser()->remaining_reclaimable_bytes(); + size_t reclaimable_bytes = candidates->remaining_reclaimable_bytes(); double reclaimable_percent = reclaimable_bytes_percent(reclaimable_bytes); double threshold = (double) G1HeapWastePercent; if (reclaimable_percent <= threshold) { log_debug(gc, ergo)("%s (reclaimable percentage not over threshold). candidate old regions: %u reclaimable: " SIZE_FORMAT " (%1.2f) threshold: " UINTX_FORMAT, - false_action_str, cset_chooser()->remaining_regions(), reclaimable_bytes, reclaimable_percent, G1HeapWastePercent); + false_action_str, candidates->num_remaining(), reclaimable_bytes, reclaimable_percent, G1HeapWastePercent); return false; } log_debug(gc, ergo)("%s (candidate old regions available). candidate old regions: %u reclaimable: " SIZE_FORMAT " (%1.2f) threshold: " UINTX_FORMAT, - true_action_str, cset_chooser()->remaining_regions(), reclaimable_bytes, reclaimable_percent, G1HeapWastePercent); + true_action_str, candidates->num_remaining(), reclaimable_bytes, reclaimable_percent, G1HeapWastePercent); return true; } @@ -1159,10 +1158,10 @@ uint G1Policy::calc_min_old_cset_length() const { // maximum desired number of mixed GCs. // // The calculation is based on the number of marked regions we added - // to the CSet chooser in the first place, not how many remain, so + // to the CSet candidates in the first place, not how many remain, so // that the result is the same during all mixed GCs that follow a cycle. - const size_t region_num = (size_t) cset_chooser()->length(); + const size_t region_num = _collection_set->candidates()->num_regions(); const size_t gc_num = (size_t) MAX2(G1MixedGCCountTarget, (uintx) 1); size_t result = region_num / gc_num; // emulate ceiling diff --git a/src/hotspot/share/gc/g1/heapRegion.hpp b/src/hotspot/share/gc/g1/heapRegion.hpp index d3ab70fd7a0..7c69bc4b54e 100644 --- a/src/hotspot/share/gc/g1/heapRegion.hpp +++ b/src/hotspot/share/gc/g1/heapRegion.hpp @@ -547,7 +547,7 @@ class HeapRegion: public G1ContiguousSpace { } void calc_gc_efficiency(void); - double gc_efficiency() { return _gc_efficiency;} + double gc_efficiency() const { return _gc_efficiency;} uint index_in_opt_cset() const { return _index_in_opt_cset; } void set_index_in_opt_cset(uint index) { _index_in_opt_cset = index; } @@ -705,7 +705,7 @@ class HeapRegion: public G1ContiguousSpace { class HeapRegionClosure : public StackObj { friend class HeapRegionManager; friend class G1CollectionSet; - friend class CollectionSetChooser; + friend class G1CollectionSetCandidates; bool _is_complete; void set_incomplete() { _is_complete = false; } diff --git a/src/hotspot/share/memory/allocation.cpp b/src/hotspot/share/memory/allocation.cpp index 0d7b4084440..5f4b5f94944 100644 --- a/src/hotspot/share/memory/allocation.cpp +++ b/src/hotspot/share/memory/allocation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -169,8 +169,7 @@ void ResourceObj::set_allocation_type(address res, allocation_type type) { ResourceObj* resobj = (ResourceObj *)res; resobj->_allocation_t[0] = ~(allocation + type); if (type != STACK_OR_EMBEDDED) { - // Called from operator new() and CollectionSetChooser(), - // set verification value. + // Called from operator new(), set verification value. resobj->_allocation_t[1] = (uintptr_t)&(resobj->_allocation_t[1]) + type; } } From 999ecc66a43788731da239331782b92c791fbb92 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Fri, 8 Feb 2019 12:55:20 +0100 Subject: [PATCH 020/101] 8217328: Rename CollectionSetChooser to G1CollectionSetChooser Reviewed-by: lkorinth, kbarrett --- src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp | 4 ++-- ...ectionSetChooser.cpp => g1CollectionSetChooser.cpp} | 10 +++++----- ...ectionSetChooser.hpp => g1CollectionSetChooser.hpp} | 8 ++++---- src/hotspot/share/gc/g1/g1Policy.cpp | 4 ++-- src/hotspot/share/gc/g1/g1Policy.hpp | 4 ++-- src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) rename src/hotspot/share/gc/g1/{collectionSetChooser.cpp => g1CollectionSetChooser.cpp} (96%) rename src/hotspot/share/gc/g1/{collectionSetChooser.hpp => g1CollectionSetChooser.hpp} (91%) diff --git a/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp index a9c24f7316b..937bb4f8d3f 100644 --- a/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp +++ b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp @@ -23,8 +23,8 @@ */ #include "precompiled.hpp" -#include "gc/g1/collectionSetChooser.hpp" #include "gc/g1/g1CollectionSetCandidates.hpp" +#include "gc/g1/g1CollectionSetChooser.hpp" #include "gc/g1/heapRegion.inline.hpp" HeapRegion* G1CollectionSetCandidates::pop_front() { @@ -73,7 +73,7 @@ void G1CollectionSetCandidates::verify() const { for (; idx < _num_regions; idx++) { HeapRegion *cur = _regions[idx]; guarantee(cur != NULL, "Regions after _front_idx %u cannot be NULL but %u is", _front_idx, idx); - guarantee(CollectionSetChooser::should_add(cur), "Region %u should be eligible for addition.", cur->hrm_index()); + guarantee(G1CollectionSetChooser::should_add(cur), "Region %u should be eligible for addition.", cur->hrm_index()); if (prev != NULL) { guarantee(prev->gc_efficiency() >= cur->gc_efficiency(), "GC efficiency for region %u: %1.4f smaller than for region %u: %1.4f", diff --git a/src/hotspot/share/gc/g1/collectionSetChooser.cpp b/src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp similarity index 96% rename from src/hotspot/share/gc/g1/collectionSetChooser.cpp rename to src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp index daa44a30d70..06da3a4c443 100644 --- a/src/hotspot/share/gc/g1/collectionSetChooser.cpp +++ b/src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp @@ -23,9 +23,9 @@ */ #include "precompiled.hpp" -#include "gc/g1/collectionSetChooser.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectionSetCandidates.hpp" +#include "gc/g1/g1CollectionSetChooser.hpp" #include "gc/g1/heapRegionRemSet.hpp" #include "gc/shared/space.inline.hpp" #include "runtime/atomic.hpp" @@ -171,7 +171,7 @@ class G1BuildCandidateRegionsTask : public AbstractGangTask { _reclaimable_bytes_added += hr->reclaimable_bytes(); } - bool should_add(HeapRegion* hr) { return CollectionSetChooser::should_add(hr); } + bool should_add(HeapRegion* hr) { return G1CollectionSetChooser::should_add(hr); } public: G1BuildCandidateRegionsClosure(G1BuildCandidateArray* array) : @@ -245,19 +245,19 @@ public: } }; -uint CollectionSetChooser::calculate_work_chunk_size(uint num_workers, uint num_regions) { +uint G1CollectionSetChooser::calculate_work_chunk_size(uint num_workers, uint num_regions) { assert(num_workers > 0, "Active gc workers should be greater than 0"); return MAX2(num_regions / num_workers, 1U); } -bool CollectionSetChooser::should_add(HeapRegion* hr) { +bool G1CollectionSetChooser::should_add(HeapRegion* hr) { return !hr->is_young() && !hr->is_pinned() && region_occupancy_low_enough_for_evac(hr->live_bytes()) && hr->rem_set()->is_complete(); } -G1CollectionSetCandidates* CollectionSetChooser::build(WorkGang* workers, uint max_num_regions) { +G1CollectionSetCandidates* G1CollectionSetChooser::build(WorkGang* workers, uint max_num_regions) { uint num_workers = workers->active_workers(); uint chunk_size = calculate_work_chunk_size(num_workers, max_num_regions); diff --git a/src/hotspot/share/gc/g1/collectionSetChooser.hpp b/src/hotspot/share/gc/g1/g1CollectionSetChooser.hpp similarity index 91% rename from src/hotspot/share/gc/g1/collectionSetChooser.hpp rename to src/hotspot/share/gc/g1/g1CollectionSetChooser.hpp index aea46263578..4d6a77abc19 100644 --- a/src/hotspot/share/gc/g1/collectionSetChooser.hpp +++ b/src/hotspot/share/gc/g1/g1CollectionSetChooser.hpp @@ -22,8 +22,8 @@ * */ -#ifndef SHARE_GC_G1_COLLECTIONSETCHOOSER_HPP -#define SHARE_GC_G1_COLLECTIONSETCHOOSER_HPP +#ifndef SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP +#define SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP #include "gc/g1/heapRegion.hpp" #include "memory/allocation.hpp" @@ -34,7 +34,7 @@ class WorkGang; // Helper class to calculate collection set candidates, and containing some related // methods. -class CollectionSetChooser : public AllStatic { +class G1CollectionSetChooser : public AllStatic { static uint calculate_work_chunk_size(uint num_workers, uint num_regions); public: @@ -57,4 +57,4 @@ public: static G1CollectionSetCandidates* build(WorkGang* workers, uint max_num_regions); }; -#endif // SHARE_GC_G1_COLLECTIONSETCHOOSER_HPP +#endif // SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP diff --git a/src/hotspot/share/gc/g1/g1Policy.cpp b/src/hotspot/share/gc/g1/g1Policy.cpp index 8907602ea93..93e65f5476c 100644 --- a/src/hotspot/share/gc/g1/g1Policy.cpp +++ b/src/hotspot/share/gc/g1/g1Policy.cpp @@ -23,7 +23,6 @@ */ #include "precompiled.hpp" -#include "gc/g1/collectionSetChooser.hpp" #include "gc/g1/g1Analytics.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectionSet.hpp" @@ -31,6 +30,7 @@ #include "gc/g1/g1ConcurrentMark.hpp" #include "gc/g1/g1ConcurrentMarkThread.inline.hpp" #include "gc/g1/g1ConcurrentRefine.hpp" +#include "gc/g1/g1CollectionSetChooser.hpp" #include "gc/g1/g1HeterogeneousHeapPolicy.hpp" #include "gc/g1/g1HotCardCache.hpp" #include "gc/g1/g1IHOPControl.hpp" @@ -1028,7 +1028,7 @@ void G1Policy::decide_on_conc_mark_initiation() { } void G1Policy::record_concurrent_mark_cleanup_end() { - G1CollectionSetCandidates* candidates = CollectionSetChooser::build(_g1h->workers(), _g1h->num_regions()); + G1CollectionSetCandidates* candidates = G1CollectionSetChooser::build(_g1h->workers(), _g1h->num_regions()); _collection_set->set_candidates(candidates); bool mixed_gc_pending = next_gc_should_be_mixed("request mixed gcs", "request young-only gcs"); diff --git a/src/hotspot/share/gc/g1/g1Policy.hpp b/src/hotspot/share/gc/g1/g1Policy.hpp index 1376fafd62f..22b9ea8d8db 100644 --- a/src/hotspot/share/gc/g1/g1Policy.hpp +++ b/src/hotspot/share/gc/g1/g1Policy.hpp @@ -44,7 +44,7 @@ class HeapRegion; class G1CollectionSet; -class CollectionSetChooser; +class G1CollectionSetChooser; class G1IHOPControl; class G1Analytics; class G1SurvivorRegions; @@ -176,7 +176,7 @@ private: double non_young_other_time_ms() const; double constant_other_time_ms(double pause_time_ms) const; - CollectionSetChooser* cset_chooser() const; + G1CollectionSetChooser* cset_chooser() const; // The number of bytes copied during the GC. size_t _bytes_copied_during_gc; diff --git a/src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp b/src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp index 575eae7a5ee..d8962a4ff48 100644 --- a/src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp +++ b/src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ */ #include "precompiled.hpp" -#include "gc/g1/collectionSetChooser.hpp" +#include "gc/g1/g1CollectionSetChooser.hpp" #include "gc/g1/g1RemSetTrackingPolicy.hpp" #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionRemSet.hpp" @@ -126,7 +126,7 @@ bool G1RemSetTrackingPolicy::update_before_rebuild(HeapRegion* r, size_t live_by // - Otherwise only add those old gen regions which occupancy is low enough that there // is a chance that we will ever evacuate them in the mixed gcs. if ((total_live_bytes > 0) && - CollectionSetChooser::region_occupancy_low_enough_for_evac(total_live_bytes) && + G1CollectionSetChooser::region_occupancy_low_enough_for_evac(total_live_bytes) && !r->rem_set()->is_tracked()) { r->rem_set()->set_state_updating(); From e174cd627175fe5a03b60b09e567bd8654b12075 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Fri, 8 Feb 2019 09:33:59 -0500 Subject: [PATCH 021/101] 8218593: Symbol leak in prepend_host_package_name Add appropriate refcounting for Symbols stomped by parsing Reviewed-by: hseigel, zgu --- .../share/classfile/classFileParser.cpp | 25 ++++++++++++++++--- .../share/classfile/classFileParser.hpp | 2 ++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index 70c4f00cc83..49710f73e60 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -5739,6 +5739,19 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loa debug_only(ik->verify();) } +void ClassFileParser::update_class_name(Symbol* new_class_name) { + // Decrement the refcount in the old name, since we're clobbering it. + if (_class_name != NULL) { + _class_name->decrement_refcount(); + } + _class_name = new_class_name; + // Increment the refcount of the new name. + // Now the ClassFileParser owns this name and will decrement in + // the destructor. + _class_name->increment_refcount(); +} + + // For an unsafe anonymous class that is in the unnamed package, move it to its host class's // package by prepending its host class's package name to its class name and setting // its _class_name field. @@ -5762,9 +5775,10 @@ void ClassFileParser::prepend_host_package_name(const InstanceKlass* unsafe_anon strncpy(new_anon_name + host_pkg_len + 1, (char *)_class_name->base(), class_name_len); // Create a symbol and update the anonymous class name. - _class_name = SymbolTable::new_symbol(new_anon_name, + Symbol* new_name = SymbolTable::new_symbol(new_anon_name, (int)host_pkg_len + 1 + class_name_len, CHECK); + update_class_name(new_name); } } @@ -5810,6 +5824,7 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream, TRAPS) : _stream(stream), _requested_name(name), + _class_name(NULL), _loader_data(loader_data), _unsafe_anonymous_host(unsafe_anonymous_host), _cp_patches(cp_patches), @@ -5867,7 +5882,7 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream, _has_vanilla_constructor(false), _max_bootstrap_specifier_index(-1) { - _class_name = name != NULL ? name : vmSymbols::unknown_class_name(); + update_class_name(name != NULL ? name : vmSymbols::unknown_class_name()); assert(THREAD->is_Java_thread(), "invariant"); assert(_loader_data != NULL, "invariant"); @@ -5937,6 +5952,8 @@ void ClassFileParser::clear_class_metadata() { // Destructor to clean up ClassFileParser::~ClassFileParser() { + _class_name->decrement_refcount(); + if (_cp != NULL) { MetadataFactory::free_metadata(_loader_data, _cp); } @@ -6092,7 +6109,7 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, // Update _class_name which could be null previously // to reflect the name in the constant pool - _class_name = class_name_in_cp; + update_class_name(class_name_in_cp); // Don't need to check whether this class name is legal or not. // It has been checked when constant pool is parsed. diff --git a/src/hotspot/share/classfile/classFileParser.hpp b/src/hotspot/share/classfile/classFileParser.hpp index aba8208c57f..24f48bf05be 100644 --- a/src/hotspot/share/classfile/classFileParser.hpp +++ b/src/hotspot/share/classfile/classFileParser.hpp @@ -496,6 +496,8 @@ class ClassFileParser { FieldLayoutInfo* info, TRAPS); + void update_class_name(Symbol* new_name); + public: ClassFileParser(ClassFileStream* stream, Symbol* name, From f88962f2d933438b08cf50315a810a0d691dde83 Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Thu, 7 Feb 2019 09:55:57 +0100 Subject: [PATCH 022/101] 8217990: C2 UseOptoBiasInlining: load of markword optimized to 0 if running with -XX:-EliminateLocks Reviewed-by: thartmann, mdoerr, rrich, kvn --- src/hotspot/share/opto/escape.cpp | 5 + src/hotspot/share/opto/graphKit.cpp | 4 + ...OptoBiasInliningWithoutEliminateLocks.java | 94 +++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 test/hotspot/jtreg/compiler/c2/TestUseOptoBiasInliningWithoutEliminateLocks.java diff --git a/src/hotspot/share/opto/escape.cpp b/src/hotspot/share/opto/escape.cpp index 17ee866f614..4be774f0e4d 100644 --- a/src/hotspot/share/opto/escape.cpp +++ b/src/hotspot/share/opto/escape.cpp @@ -3010,6 +3010,11 @@ void ConnectionGraph::split_unique_types(GrowableArray &alloc_worklist, n->raise_bottom_type(tinst); igvn->hash_insert(n); record_for_optimizer(n); + // Allocate an alias index for the header fields. Accesses to + // the header emitted during macro expansion wouldn't have + // correct memory state otherwise. + _compile->get_alias_index(tinst->add_offset(oopDesc::mark_offset_in_bytes())); + _compile->get_alias_index(tinst->add_offset(oopDesc::klass_offset_in_bytes())); if (alloc->is_Allocate() && (t->isa_instptr() || t->isa_aryptr())) { // First, put on the worklist all Field edges from Connection Graph diff --git a/src/hotspot/share/opto/graphKit.cpp b/src/hotspot/share/opto/graphKit.cpp index b90683b5eaf..241d0ec551a 100644 --- a/src/hotspot/share/opto/graphKit.cpp +++ b/src/hotspot/share/opto/graphKit.cpp @@ -3426,6 +3426,10 @@ Node* GraphKit::set_output_for_allocation(AllocateNode* alloc, record_for_igvn(minit_in); // fold it up later, if possible Node* minit_out = memory(rawidx); assert(minit_out->is_Proj() && minit_out->in(0) == init, ""); + // Add an edge in the MergeMem for the header fields so an access + // to one of those has correct memory state + set_memory(minit_out, C->get_alias_index(oop_type->add_offset(oopDesc::mark_offset_in_bytes()))); + set_memory(minit_out, C->get_alias_index(oop_type->add_offset(oopDesc::klass_offset_in_bytes()))); if (oop_type->isa_aryptr()) { const TypePtr* telemref = oop_type->add_offset(Type::OffsetBot); int elemidx = C->get_alias_index(telemref); diff --git a/test/hotspot/jtreg/compiler/c2/TestUseOptoBiasInliningWithoutEliminateLocks.java b/test/hotspot/jtreg/compiler/c2/TestUseOptoBiasInliningWithoutEliminateLocks.java new file mode 100644 index 00000000000..0c169d4aecd --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/TestUseOptoBiasInliningWithoutEliminateLocks.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019 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 8217990 + * @summary With -XX:+UseOptoBiasInlining loading the markword is replaced by 0L if EliminateLocks is disabled. assert(dmw->is_neutral()) failed: invariant fails. + * @author Richard Reingruber richard DOT reingruber AT sap DOT com + * + * @library /test/lib /test/hotspot/jtreg + * + * @build sun.hotspot.WhiteBox + * @build ClassFileInstaller + * + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions + * -XX:CompileCommand=compileonly,*.TestUseOptoBiasInliningWithoutEliminateLocks::dontinline_testMethod + * -XX:CompileCommand=dontinline,*::dontinline_* + * -XX:-EliminateLocks + * -XX:+WhiteBoxAPI -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -Xbatch + * -XX:-TieredCompilation + * compiler.c2.TestUseOptoBiasInliningWithoutEliminateLocks + */ + +package compiler.c2; + +import sun.hotspot.WhiteBox; + +public class TestUseOptoBiasInliningWithoutEliminateLocks { + + public static final WhiteBox WB = WhiteBox.getWhiteBox(); + + public static void main(String[] args) { + new TestUseOptoBiasInliningWithoutEliminateLocks().run(); + } + + public boolean warmupDone; + + public void run() { + for(int i = 0; i < 30000; i++) { + dontinline_testMethod(); + } + warmupDone = true; + dontinline_testMethod(); + } + + public void dontinline_testMethod() { + PointXY l1 = new PointXY(4.0f, 2.0f); + synchronized (l1) { + dontinline_deopt(); + } + } + + public void dontinline_deopt() { + if (warmupDone) { + WB.deoptimizeFrames(false); + } + } + + static class PointXY { + + public float fritz; + public float felix; + + public PointXY(float fritz_param, float felix_param) { + this.fritz = fritz_param; +// this.felix = felix_param; + } + } +} From 76ffbcde9860cb42d231a02abb23cd36c7235645 Mon Sep 17 00:00:00 2001 From: Daniil Titov Date: Fri, 8 Feb 2019 09:41:45 -0800 Subject: [PATCH 023/101] 8205654: serviceability/dcmd/framework/HelpTest.java timed out Reviewed-by: sspitsyn, dholmes --- .../classes/sun/tools/ProcessHelper.java | 155 +++++++++++ .../tools/common/ProcessArgumentMatcher.java | 49 ++-- .../sun/tools/common/ProcessHelper.java | 64 +++++ .../dcmd/framework/HelpTest.java | 13 +- .../dcmd/framework/InvalidCommandTest.java | 14 +- .../dcmd/framework/TEST.properties | 2 - .../dcmd/framework/TestJavaProcess.java | 61 +++++ .../dcmd/framework/TestProcessLauncher.java | 78 ++++++ .../dcmd/framework/VMVersionTest.java | 15 +- .../nsk/share/jpda/DebugeeBinder.java | 4 +- test/jdk/sun/tools/jcmd/TestProcess.java | 34 +++ .../jdk/sun/tools/jcmd/TestProcessHelper.java | 259 ++++++++++++++++++ 12 files changed, 721 insertions(+), 27 deletions(-) create mode 100644 src/jdk.jcmd/linux/classes/sun/tools/ProcessHelper.java create mode 100644 src/jdk.jcmd/share/classes/sun/tools/common/ProcessHelper.java delete mode 100644 test/hotspot/jtreg/serviceability/dcmd/framework/TEST.properties create mode 100644 test/hotspot/jtreg/serviceability/dcmd/framework/TestJavaProcess.java create mode 100644 test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessLauncher.java create mode 100644 test/jdk/sun/tools/jcmd/TestProcess.java create mode 100644 test/jdk/sun/tools/jcmd/TestProcessHelper.java diff --git a/src/jdk.jcmd/linux/classes/sun/tools/ProcessHelper.java b/src/jdk.jcmd/linux/classes/sun/tools/ProcessHelper.java new file mode 100644 index 00000000000..05000373120 --- /dev/null +++ b/src/jdk.jcmd/linux/classes/sun/tools/ProcessHelper.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2019, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package sun.tools; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import java.util.jar.Manifest; +import java.util.stream.Stream; + +/** + * A helper class that retrieves the main class name for + * a running Java process using the proc filesystem (procfs) + */ +public class ProcessHelper implements sun.tools.common.ProcessHelper { + + + private static final String CMD_PREFIX = "cmd:"; + private static final ProcessHelper INSTANCE = new ProcessHelper(); + + public static ProcessHelper getInstance() { + return INSTANCE; + } + + /** + * Gets the main class name for the given Java process by parsing the + * process command line. + * @param pid - process ID (pid) + * @return main class name or null if the process no longer exists or + * was started with a native launcher (e.g. jcmd etc) + */ + + public String getMainClass(String pid) { + String cmdLine = getCommandLine(pid); + if (cmdLine == null) { + return null; + } + if (cmdLine.startsWith(CMD_PREFIX)) { + cmdLine = cmdLine.substring(CMD_PREFIX.length()); + } + String[] parts = cmdLine.split(" "); + String mainClass = null; + + if(parts.length == 0) { + return null; + } + + // Check the executable + String[] executablePath = parts[0].split("/"); + if (executablePath.length > 0) { + String binaryName = executablePath[executablePath.length - 1]; + if (!"java".equals(binaryName)) { + // Skip the process if it is not started with java launcher + return null; + } + } + + // If -jar option is used then read the main class name from the manifest file. + // Otherwise, the main class name is either specified in -m or --module options or it + // is the first part that is not a Java option (doesn't start with '-' and is not a + // classpath or a module path). + + for (int i = 1; i < parts.length && mainClass == null; i++) { + if (i < parts.length - 1) { + // Check if the module is executed with explicitly specified main class + if ((parts[i].equals("-m") || parts[i].equals("--module"))) { + return getMainClassFromModuleArg(parts[i + 1]); + } + // Check if the main class needs to be read from the manifest.mf in a JAR file + if (parts[i].equals("-jar")) { + return getMainClassFromJar(parts[i + 1], pid); + } + } + // If this is a classpath or a module path option then skip the next part + // (the classpath or the module path itself) + if (parts[i].equals("-cp") || parts[i].equals("-classpath") || parts[i].equals("--class-path") || + parts[i].equals("-p") || parts[i].equals("--module-path")) { + i++; + continue; + } + // Skip all other Java options + if (parts[i].startsWith("-")) { + continue; + } + mainClass = parts[i]; + } + return mainClass; + + } + + private String getMainClassFromModuleArg(String moduleArg) { + int pos = moduleArg.lastIndexOf("/"); + return (pos > 0 && pos < moduleArg.length()-1) ? moduleArg.substring(pos + 1) : null; + } + + private String getMainClassFromJar(String jar, String pid) { + if (!jar.startsWith("/")) { + String cwd = getCurrentWorkingDir(pid); + if (cwd != null) { + jar = cwd + "/" + jar; + } + } + try (JarFile jarFile = new JarFile(jar)) { + Manifest mf = jarFile.getManifest(); + if (mf != null) { + Attributes mainAttributes = mf.getMainAttributes(); + return mainAttributes.getValue("Main-Class"); + } + } catch (IOException e) { + return null; + } + return null; + } + + private static String getCurrentWorkingDir(String pid) { + return ("/proc/" + pid + "/cwd"); + } + + private static String getCommandLine(String pid) { + try (Stream lines = + Files.lines(Paths.get("/proc/" + pid + "/cmdline"))) { + return lines.map(x -> x.replaceAll("\0", " ")).findFirst().orElse(null); + } catch (IOException | UncheckedIOException e) { + return null; + } + } +} + + diff --git a/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java b/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java index d8e44d385ab..8c2cbc548ef 100644 --- a/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java +++ b/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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 @@ -78,25 +78,40 @@ public class ProcessArgumentMatcher { } private static boolean check(VirtualMachineDescriptor vmd, String excludeClass, String partialMatch) { + String mainClass = null; - try { - VmIdentifier vmId = new VmIdentifier(vmd.id()); - MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId); - MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1); - mainClass = MonitoredVmUtil.mainClass(monitoredVm, true); - monitoredHost.detach(monitoredVm); - } catch (NullPointerException npe) { - // There is a potential race, where a running java app is being - // queried, unfortunately the java app has shutdown after this - // method is started but before getMonitoredVM is called. - // If this is the case, then the /tmp/hsperfdata_xxx/pid file - // will have disappeared and we will get a NullPointerException. - // Handle this gracefully.... - return false; - } catch (MonitorException | URISyntaxException e) { - return false; + + // Get the main class name using platform specific helper + ProcessHelper helper = ProcessHelper.platformProcessHelper(); + if (helper != null) { + mainClass = helper.getMainClass(vmd.id()); + if (mainClass == null) { + return false; + } } + // If the main class name is still unset then retrieve it with the attach mechanism + if (mainClass == null) { + try { + VmIdentifier vmId = new VmIdentifier(vmd.id()); + MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId); + MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1); + mainClass = MonitoredVmUtil.mainClass(monitoredVm, true); + monitoredHost.detach(monitoredVm); + } catch (NullPointerException npe) { + // There is a potential race, where a running java app is being + // queried, unfortunately the java app has shutdown after this + // method is started but before getMonitoredVM is called. + // If this is the case, then the /tmp/hsperfdata_xxx/pid file + // will have disappeared and we will get a NullPointerException. + // Handle this gracefully.... + return false; + } catch (MonitorException | URISyntaxException e) { + return false; + } + } + + if (excludeClass != null && mainClass.equals(excludeClass)) { return false; } diff --git a/src/jdk.jcmd/share/classes/sun/tools/common/ProcessHelper.java b/src/jdk.jcmd/share/classes/sun/tools/common/ProcessHelper.java new file mode 100644 index 00000000000..d0f2d69bc16 --- /dev/null +++ b/src/jdk.jcmd/share/classes/sun/tools/common/ProcessHelper.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package sun.tools.common; + +import java.lang.reflect.Method; + +/** + * A helper class to retrieve the main class name for a running + * Java process. + */ + +public interface ProcessHelper { + + /** + * Returns an instance of the ProcessHelper class. + * + * @return ProcessHelper object or null if not supported on this platform. + */ + public static ProcessHelper platformProcessHelper() { + try { + Class c = Class.forName("sun.tools.ProcessHelper"); + @SuppressWarnings("unchecked") + Method m = c.getMethod("getInstance"); + return (ProcessHelper) m.invoke(null); + } catch (ClassNotFoundException e) { + return null; + } catch (ReflectiveOperationException e) { + throw new InternalError(e); + } + } + + + /** + * Returns the main class name for the given Java process + * + * @param pid - process ID (pid) + * @return main class name or null if the main class could not be retrieved + */ + + String getMainClass(String pid); +} diff --git a/test/hotspot/jtreg/serviceability/dcmd/framework/HelpTest.java b/test/hotspot/jtreg/serviceability/dcmd/framework/HelpTest.java index d88ddffce71..1590cbb14ab 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/framework/HelpTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/framework/HelpTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -33,6 +33,7 @@ import org.testng.annotations.Test; * @test * @summary Test of diagnostic command help (tests all DCMD executors) * @library /test/lib + * /vmTestbase * @modules java.base/jdk.internal.misc * java.compiler * java.management @@ -55,7 +56,13 @@ public class HelpTest { @Test public void mainClass() { - run(new MainClassJcmdExecutor()); + TestProcessLauncher t = new TestProcessLauncher(Process.class.getName()); + try { + t.launch(); + run(new MainClassJcmdExecutor(Process.class.getName())); + } finally { + t.quit(); + } } @Test @@ -68,4 +75,6 @@ public class HelpTest { run(new JMXExecutor()); } + private static class Process extends TestJavaProcess { + } } diff --git a/test/hotspot/jtreg/serviceability/dcmd/framework/InvalidCommandTest.java b/test/hotspot/jtreg/serviceability/dcmd/framework/InvalidCommandTest.java index 2536b4125aa..010a9d3d338 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/framework/InvalidCommandTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/framework/InvalidCommandTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -33,6 +33,7 @@ import org.testng.annotations.Test; * @test * @summary Test of invalid diagnostic command (tests all DCMD executors) * @library /test/lib + * /vmTestbase * @modules java.base/jdk.internal.misc * java.compiler * java.management @@ -53,7 +54,13 @@ public class InvalidCommandTest { @Test public void mainClass() { - run(new MainClassJcmdExecutor()); + TestProcessLauncher t = new TestProcessLauncher(Process.class.getName()); + try { + t.launch(); + run(new MainClassJcmdExecutor(Process.class.getName())); + } finally { + t.quit(); + } } @Test @@ -65,4 +72,7 @@ public class InvalidCommandTest { public void jmx() { run(new JMXExecutor()); } + + private static class Process extends TestJavaProcess { + } } diff --git a/test/hotspot/jtreg/serviceability/dcmd/framework/TEST.properties b/test/hotspot/jtreg/serviceability/dcmd/framework/TEST.properties deleted file mode 100644 index 7cb4e8f69bf..00000000000 --- a/test/hotspot/jtreg/serviceability/dcmd/framework/TEST.properties +++ /dev/null @@ -1,2 +0,0 @@ -exclusiveAccess.dirs=. - diff --git a/test/hotspot/jtreg/serviceability/dcmd/framework/TestJavaProcess.java b/test/hotspot/jtreg/serviceability/dcmd/framework/TestJavaProcess.java new file mode 100644 index 00000000000..9992238c67a --- /dev/null +++ b/test/hotspot/jtreg/serviceability/dcmd/framework/TestJavaProcess.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2019, 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. + */ + +import nsk.share.jpda.*; +import nsk.share.jdi.*; + +/** + * A simple process that connects to a pipe and waits for command "quit" to + * be received. + * + * Usage: java TestJavaProcess -pipe.port + */ + +public class TestJavaProcess { + + static final int PASSED = 0; + static final int FAILED = 2; + + public static void main(String argv[]) { + + log("Test Java process started!"); + + ArgumentHandler argHandler = new ArgumentHandler(argv); + IOPipe pipe = argHandler.createDebugeeIOPipe(); + pipe.println("ready"); + log("Waiting for the quit command from the test ..."); + String cmd = pipe.readln(); + int exitCode = PASSED; + if (cmd.equals("quit")) { + log("'quit' received"); + } else { + log("Invalid command received " + cmd); + exitCode = FAILED; + } + System.exit(exitCode); + } + + private static void log(String message) { + System.out.println(message); + } +} diff --git a/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessLauncher.java b/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessLauncher.java new file mode 100644 index 00000000000..c01290a98fe --- /dev/null +++ b/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessLauncher.java @@ -0,0 +1,78 @@ + +/* + * Copyright (c) 2019, 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. + */ + +import nsk.share.*; +import nsk.share.jpda.*; +import nsk.share.jdi.*; + +/** + * Launches a new Java process that uses a communication pipe to interact + * with the test. + */ + +public class TestProcessLauncher { + + private final String className; + private final ArgumentHandler argHandler; + + private IOPipe pipe; + + public TestProcessLauncher(String className, ArgumentHandler argHandler) { + this.className = className; + this.argHandler = argHandler; + } + + public TestProcessLauncher(String className) { + this(className, new ArgumentHandler(new String[0])); + } + + public Process launch() { + + String java = argHandler.getLaunchExecPath(); + + Log log = new Log(System.out, argHandler); + Binder binder = new Binder(argHandler, log); + binder.prepareForPipeConnection(argHandler); + + String cmd = java + " " + className + " -pipe.port=" + argHandler.getPipePort(); + + Debugee debuggee = binder.startLocalDebugee(cmd); + debuggee.redirectOutput(log); + + pipe = new IOPipe(debuggee); + + String line = pipe.readln(); + if (!"ready".equals(line)) { + System.out.println("Wrong reply received:" + line); + } + return debuggee.getProcess(); + } + + public void quit() { + if (pipe != null) { + pipe.println("quit"); + } + } + +} diff --git a/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java b/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java index d39f0de5263..294e68ec78c 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -27,6 +27,7 @@ import jdk.test.lib.dcmd.PidJcmdExecutor; import jdk.test.lib.dcmd.MainClassJcmdExecutor; import jdk.test.lib.dcmd.FileJcmdExecutor; import jdk.test.lib.dcmd.JMXExecutor; +import nsk.share.jdi.ArgumentHandler; import org.testng.annotations.Test; @@ -34,6 +35,8 @@ import org.testng.annotations.Test; * @test * @summary Test of diagnostic command VM.version (tests all DCMD executors) * @library /test/lib + * /vmTestbase + * @build TestJavaProcess * @modules java.base/jdk.internal.misc * java.compiler * java.management @@ -53,7 +56,13 @@ public class VMVersionTest { @Test public void mainClass() { - run(new MainClassJcmdExecutor()); + TestProcessLauncher t = new TestProcessLauncher(Process.class.getName()); + try { + t.launch(); + run(new MainClassJcmdExecutor(Process.class.getName())); + } finally { + t.quit(); + } } @Test @@ -65,4 +74,6 @@ public class VMVersionTest { public void jmx() { run(new JMXExecutor()); } + + private static class Process extends TestJavaProcess{} } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeBinder.java b/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeBinder.java index 01c4df801ea..f5cfd11c56e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeBinder.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeBinder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -175,7 +175,7 @@ public class DebugeeBinder extends Log.Logger implements Finalizable { * Make preperation for IOPipe connection before starting debugee VM process. * May change options in the passed argumentHandler. */ - protected void prepareForPipeConnection(DebugeeArgumentHandler argumentHandler) { + public void prepareForPipeConnection(DebugeeArgumentHandler argumentHandler) { if (argumentHandler.isTransportAddressDynamic()) { try { pipeServerSocket = new ServerSocket(); diff --git a/test/jdk/sun/tools/jcmd/TestProcess.java b/test/jdk/sun/tools/jcmd/TestProcess.java new file mode 100644 index 00000000000..873fdde8ab1 --- /dev/null +++ b/test/jdk/sun/tools/jcmd/TestProcess.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019, 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. + */ + +package test; + +public class TestProcess { + + public static void main(String[] args) throws Exception { + System.out.print("The process started, pid:" + ProcessHandle.current().pid()); + while(true) { + Thread.sleep(100); + } + } +} diff --git a/test/jdk/sun/tools/jcmd/TestProcessHelper.java b/test/jdk/sun/tools/jcmd/TestProcessHelper.java new file mode 100644 index 00000000000..0bf78850953 --- /dev/null +++ b/test/jdk/sun/tools/jcmd/TestProcessHelper.java @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2019, 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. + */ + +import jdk.internal.module.ModuleInfoWriter; +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.util.JarUtils; +import sun.tools.common.ProcessHelper; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.lang.module.ModuleDescriptor; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.jar.Attributes; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/* + * @test + * @bug 8205654 + * @summary Unit test for sun.tools.ProcessHelper class. The test launches Java processes with different Java options + * and checks that sun.tools.ProcessHelper.getMainClass(pid) method returns a correct main class. return a . + * + * @requires os.family == "linux" + * @library /test/lib + * @modules jdk.jcmd/sun.tools.common + * java.base/jdk.internal.module + * @build test.TestProcess + * @run main/othervm TestProcessHelper + */ +public class TestProcessHelper { + + private ProcessHelper PROCESS_HELPER = ProcessHelper.platformProcessHelper(); + + private static final String TEST_PROCESS_MAIN_CLASS_NAME = "TestProcess"; + private static final String TEST_PROCESS_MAIN_CLASS_PACKAGE = "test"; + private static final String TEST_PROCESS_MAIN_CLASS = TEST_PROCESS_MAIN_CLASS_PACKAGE + "." + + TEST_PROCESS_MAIN_CLASS_NAME; + private static final Path TEST_CLASSES = FileSystems.getDefault().getPath(System.getProperty("test.classes")); + private static final Path USER_DIR = FileSystems.getDefault().getPath(System.getProperty("user.dir", ".")); + private static final Path TEST_MODULES = USER_DIR.resolve("testmodules"); + private static final String JAVA_PATH = JDKToolFinder.getJDKTool("java"); + private static final Path TEST_CLASS = TEST_CLASSES.resolve(TEST_PROCESS_MAIN_CLASS_PACKAGE) + .resolve(TEST_PROCESS_MAIN_CLASS_NAME + ".class"); + + private static final String[] CP_OPTIONS = {"-cp", "-classpath", "--class-path"}; + private static final String[][] VM_ARGS = {{}, {"-Dtest1=aaa"}, {"-Dtest1=aaa", "-Dtest2=bbb"}}; + private static final String[][] ARGS = {{}, {"param1"}, {"param1", "param2"}}; + private static final String[] MP_OPTIONS = {"-p", "--module-path"}; + private static final String[] MODULE_OPTIONS = {"-m", "--module"}; + private static final String JAR_OPTION = "-jar"; + private static final String MODULE_NAME = "module1"; + + + public static void main(String[] args) throws Exception { + new TestProcessHelper().runTests(); + } + + public void runTests() throws Exception { + testClassPath(); + testJar(); + testModule(); + } + + // Test Java processes that are started with -classpath, -cp, or --class-path options + // and with different combinations of VM and program args. + private void testClassPath() throws Exception { + for (String cp : CP_OPTIONS) { + for (String[] vma : VM_ARGS) { + for (String[] arg : ARGS) { + List cmd = new LinkedList<>(); + cmd.add(JAVA_PATH); + cmd.add(cp); + cmd.add(TEST_CLASSES.toAbsolutePath().toString()); + for (String v : vma) { + cmd.add(v); + } + cmd.add(TEST_PROCESS_MAIN_CLASS); + for (String a : arg) { + cmd.add(a); + } + testProcessHelper(cmd); + } + } + } + } + + // Test Java processes that are started with -jar option + // and with different combinations of VM and program args. + private void testJar() throws Exception { + File jarFile = prepareJar(); + for (String[] vma : VM_ARGS) { + for (String[] arg : ARGS) { + List cmd = new LinkedList<>(); + cmd.add(JAVA_PATH); + for (String v : vma) { + cmd.add(v); + } + cmd.add(JAR_OPTION); + cmd.add(jarFile.getAbsolutePath()); + for (String a : arg) { + cmd.add(a); + } + testProcessHelper(cmd); + } + } + + } + + // Test Java processes that are started with -m or --module options + // and with different combination of VM and program args. + private void testModule() throws Exception { + prepareModule(); + for (String mp : MP_OPTIONS) { + for (String m : MODULE_OPTIONS) { + for (String[] vma : VM_ARGS) { + for (String[] arg : ARGS) { + List cmd = new LinkedList<>(); + cmd.add(JAVA_PATH); + cmd.add(mp); + cmd.add(TEST_MODULES.toAbsolutePath().toString()); + for (String v : vma) { + cmd.add(v); + } + cmd.add(m); + cmd.add(MODULE_NAME + "/" + TEST_PROCESS_MAIN_CLASS); + for (String a : arg) { + cmd.add(a); + } + testProcessHelper(cmd); + } + } + } + } + } + + private void checkMainClass(Process p, String expectedMainClass) { + String mainClass = PROCESS_HELPER.getMainClass(Long.toString(p.pid())); + p.destroyForcibly(); + if (!expectedMainClass.equals(mainClass)) { + throw new RuntimeException("Main class is wrong: " + mainClass); + } + } + + private void testProcessHelper(List args) throws Exception { + ProcessBuilder pb = new ProcessBuilder(args); + String cmd = pb.command().stream().collect(Collectors.joining(" ")); + System.out.println("Starting the process:" + cmd); + Process p = ProcessTools.startProcess("test", pb); + if (!p.isAlive()) { + throw new RuntimeException("Cannot start the process: " + cmd); + } + checkMainClass(p, TEST_PROCESS_MAIN_CLASS); + } + + private File prepareJar() throws Exception { + Path jarFile = USER_DIR.resolve("testprocess.jar"); + Manifest manifest = createManifest(); + JarUtils.createJarFile(jarFile, manifest, TEST_CLASSES, TEST_CLASS); + return jarFile.toFile(); + } + + private void prepareModule() throws Exception { + TEST_MODULES.toFile().mkdirs(); + Path moduleJar = TEST_MODULES.resolve("mod1.jar"); + ModuleDescriptor md = createModuleDescriptor(); + createModuleJarFile(moduleJar, md, TEST_CLASSES, TEST_CLASS); + } + + private Manifest createManifest() { + Manifest manifest = new Manifest(); + manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); + manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, TEST_PROCESS_MAIN_CLASS); + return manifest; + } + + private ModuleDescriptor createModuleDescriptor() { + ModuleDescriptor.Builder builder + = ModuleDescriptor.newModule(MODULE_NAME).requires("java.base"); + return builder.build(); + } + + private static void createModuleJarFile(Path jarfile, ModuleDescriptor md, Path dir, Path... files) + throws IOException { + + Path parent = jarfile.getParent(); + if (parent != null) { + Files.createDirectories(parent); + } + + List entries = findAllRegularFiles(dir, files); + + try (OutputStream out = Files.newOutputStream(jarfile); + JarOutputStream jos = new JarOutputStream(out)) { + if (md != null) { + JarEntry je = new JarEntry("module-info.class"); + jos.putNextEntry(je); + ModuleInfoWriter.write(md, jos); + jos.closeEntry(); + } + + for (Path entry : entries) { + String name = toJarEntryName(entry); + jos.putNextEntry(new JarEntry(name)); + Files.copy(dir.resolve(entry), jos); + jos.closeEntry(); + } + } + } + + private static String toJarEntryName(Path file) { + Path normalized = file.normalize(); + return normalized.subpath(0, normalized.getNameCount()) + .toString() + .replace(File.separatorChar, '/'); + } + + private static List findAllRegularFiles(Path dir, Path[] files) throws IOException { + List entries = new ArrayList<>(); + for (Path file : files) { + try (Stream stream = Files.find(dir.resolve(file), Integer.MAX_VALUE, + (p, attrs) -> attrs.isRegularFile())) { + stream.map(dir::relativize) + .forEach(entries::add); + } + } + return entries; + } + +} From 9c16dc97a05dc04176a2431119187effc3204b6a Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Fri, 8 Feb 2019 10:03:07 -0800 Subject: [PATCH 024/101] 8218580: endpoint identification algorithm should be case-insensitive Reviewed-by: jnimeh --- .../share/classes/sun/security/ssl/ClientHello.java | 6 +++--- .../classes/sun/security/ssl/PreSharedKeyExtension.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/java.base/share/classes/sun/security/ssl/ClientHello.java b/src/java.base/share/classes/sun/security/ssl/ClientHello.java index 6fbac3103e5..53b74223bfb 100644 --- a/src/java.base/share/classes/sun/security/ssl/ClientHello.java +++ b/src/java.base/share/classes/sun/security/ssl/ClientHello.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -519,7 +519,7 @@ final class ClientHello { if (session != null && identityAlg != null) { String sessionIdentityAlg = session.getIdentificationProtocol(); - if (!Objects.equals(identityAlg, sessionIdentityAlg)) { + if (!identityAlg.equalsIgnoreCase(sessionIdentityAlg)) { if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake,verbose")) { SSLLogger.finest("Can't resume, endpoint id" + @@ -1036,7 +1036,7 @@ final class ClientHello { if (resumingSession && identityAlg != null) { String sessionIdentityAlg = previous.getIdentificationProtocol(); - if (!Objects.equals(identityAlg, sessionIdentityAlg)) { + if (!identityAlg.equalsIgnoreCase(sessionIdentityAlg)) { if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake,verbose")) { SSLLogger.finest("Can't resume, endpoint id" + diff --git a/src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java b/src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java index de485e23d89..1f0a957e2f9 100644 --- a/src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java +++ b/src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -458,7 +458,7 @@ final class PreSharedKeyExtension { String identityAlg = shc.sslConfig.identificationProtocol; if (result && identityAlg != null) { String sessionIdentityAlg = s.getIdentificationProtocol(); - if (!Objects.equals(identityAlg, sessionIdentityAlg)) { + if (!identityAlg.equalsIgnoreCase(sessionIdentityAlg)) { if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake,verbose")) { From 1f230335e27acc57596228ed4387a944fbdc4ab8 Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Fri, 8 Feb 2019 14:03:09 -0500 Subject: [PATCH 025/101] 8200109: NMT: diff_malloc_site assert(early->flags() == current->flags(), "Must be the same memory type") Reviewed-by: shade, coleenp --- src/hotspot/share/prims/whitebox.cpp | 8 +++ src/hotspot/share/services/memReporter.cpp | 12 +++- .../runtime/NMT/MallocSiteTypeChange.java | 70 +++++++++++++++++++ test/lib/sun/hotspot/WhiteBox.java | 1 + 4 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 test/hotspot/jtreg/runtime/NMT/MallocSiteTypeChange.java diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index a3fc2b92948..3c053f99166 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -694,6 +694,13 @@ WB_ENTRY(jlong, WB_NMTMallocWithPseudoStack(JNIEnv* env, jobject o, jlong size, return (jlong)(uintptr_t)os::malloc(size, mtTest, stack); WB_END +// Alloc memory with pseudo call stack and specific memory type. +WB_ENTRY(jlong, WB_NMTMallocWithPseudoStackAndType(JNIEnv* env, jobject o, jlong size, jint pseudo_stack, jint type)) + address pc = (address)(size_t)pseudo_stack; + NativeCallStack stack(&pc, 1); + return (jlong)(uintptr_t)os::malloc(size, (MEMFLAGS)type, stack); +WB_END + // Free the memory allocated by NMTAllocTest WB_ENTRY(void, WB_NMTFree(JNIEnv* env, jobject o, jlong mem)) os::free((void*)(uintptr_t)mem); @@ -2161,6 +2168,7 @@ static JNINativeMethod methods[] = { #if INCLUDE_NMT {CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc }, {CC"NMTMallocWithPseudoStack", CC"(JI)J", (void*)&WB_NMTMallocWithPseudoStack}, + {CC"NMTMallocWithPseudoStackAndType", CC"(JII)J", (void*)&WB_NMTMallocWithPseudoStackAndType}, {CC"NMTFree", CC"(J)V", (void*)&WB_NMTFree }, {CC"NMTReserveMemory", CC"(J)J", (void*)&WB_NMTReserveMemory }, {CC"NMTAttemptReserveMemoryAt", CC"(JJ)J", (void*)&WB_NMTAttemptReserveMemoryAt }, diff --git a/src/hotspot/share/services/memReporter.cpp b/src/hotspot/share/services/memReporter.cpp index b51783b3123..a6e815d4f86 100644 --- a/src/hotspot/share/services/memReporter.cpp +++ b/src/hotspot/share/services/memReporter.cpp @@ -704,9 +704,15 @@ void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early, const MallocSite* current) const { - assert(early->flag() == current->flag(), "Must be the same memory type"); - diff_malloc_site(current->call_stack(), current->size(), current->count(), - early->size(), early->count(), early->flag()); + if (early->flag() != current->flag()) { + // If malloc site type changed, treat it as deallocation of old type and + // allocation of new type. + old_malloc_site(early); + new_malloc_site(current); + } else { + diff_malloc_site(current->call_stack(), current->size(), current->count(), + early->size(), early->count(), early->flag()); + } } void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_t current_size, diff --git a/test/hotspot/jtreg/runtime/NMT/MallocSiteTypeChange.java b/test/hotspot/jtreg/runtime/NMT/MallocSiteTypeChange.java new file mode 100644 index 00000000000..5b1735ad17a --- /dev/null +++ b/test/hotspot/jtreg/runtime/NMT/MallocSiteTypeChange.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2019, 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 MallocSiteTypeChange + * @bug 8200109 + * @key nmt jcmd + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocSiteTypeChange + */ + +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import sun.hotspot.WhiteBox; + +public class MallocSiteTypeChange { + public static void main(String args[]) throws Exception { + OutputAnalyzer output; + WhiteBox wb = WhiteBox.getWhiteBox(); + + // Grab my own PID + String pid = Long.toString(ProcessTools.getProcessId()); + ProcessBuilder pb = new ProcessBuilder(); + + int pc = 1; + long addr = wb.NMTMallocWithPseudoStack(4 * 1024, pc); + + // Verify that current tracking level is "detail" + pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Test (reserved=4KB, committed=4KB)"); + + pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "baseline"}); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Baseline succeeded"); + + wb.NMTFree(addr); + addr = wb.NMTMallocWithPseudoStackAndType(2 * 1024, pc, 7 /* mtInternal */ ); + pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail.diff"}); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("(malloc=0KB type=Test -4KB)"); + output.shouldContain("(malloc=2KB type=Internal +2KB #1 +1)"); + output.shouldHaveExitValue(0); + } +} diff --git a/test/lib/sun/hotspot/WhiteBox.java b/test/lib/sun/hotspot/WhiteBox.java index 16f179c8744..1bf5759d81f 100644 --- a/test/lib/sun/hotspot/WhiteBox.java +++ b/test/lib/sun/hotspot/WhiteBox.java @@ -216,6 +216,7 @@ public class WhiteBox { public native void NMTUncommitMemory(long addr, long size); public native void NMTReleaseMemory(long addr, long size); public native long NMTMallocWithPseudoStack(long size, int index); + public native long NMTMallocWithPseudoStackAndType(long size, int index, int type); public native boolean NMTChangeTrackingLevel(); public native int NMTGetHashSize(); From f0807ebc18b0f5cbca75245490ef209688236eb1 Mon Sep 17 00:00:00 2001 From: Doug Lea Date: Fri, 8 Feb 2019 13:39:22 -0800 Subject: [PATCH 026/101] 8210280: Unnecessary reallocation when invoking HashMap.putAll() Co-authored-by: Michal Vala Co-authored-by: Martin Buchholz Reviewed-by: martin, mvala, igerasim, chegar, rriggs --- .../share/classes/java/util/HashMap.java | 9 +- .../java/util/HashMap/WhiteBoxResizeTest.java | 132 ++++++++++++++++++ .../util/concurrent/tck/JSR166TestCase.java | 7 + .../concurrent/tck/LinkedHashMapTest.java | 60 ++++++++ .../jdk/java/util/concurrent/tck/MapTest.java | 34 +++++ .../openjdk/bench/java/util/HashMapBench.java | 103 ++++++++++++++ 6 files changed, 343 insertions(+), 2 deletions(-) create mode 100644 test/jdk/java/util/HashMap/WhiteBoxResizeTest.java create mode 100644 test/jdk/java/util/concurrent/tck/LinkedHashMapTest.java create mode 100644 test/micro/org/openjdk/bench/java/util/HashMapBench.java diff --git a/src/java.base/share/classes/java/util/HashMap.java b/src/java.base/share/classes/java/util/HashMap.java index 30ed4092051..404cd8162eb 100644 --- a/src/java.base/share/classes/java/util/HashMap.java +++ b/src/java.base/share/classes/java/util/HashMap.java @@ -501,9 +501,14 @@ public class HashMap extends AbstractMap (int)ft : MAXIMUM_CAPACITY); if (t > threshold) threshold = tableSizeFor(t); + } else { + // Because of linked-list bucket constraints, we cannot + // expand all at once, but can reduce total resize + // effort by repeated doubling now vs later + while (s > threshold && table.length < MAXIMUM_CAPACITY) + resize(); } - else if (s > threshold) - resize(); + for (Map.Entry e : m.entrySet()) { K key = e.getKey(); V value = e.getValue(); diff --git a/test/jdk/java/util/HashMap/WhiteBoxResizeTest.java b/test/jdk/java/util/HashMap/WhiteBoxResizeTest.java new file mode 100644 index 00000000000..347e5ae08ca --- /dev/null +++ b/test/jdk/java/util/HashMap/WhiteBoxResizeTest.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2018, Red Hat, Inc. All rights reserved. + * + * 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. + */ + +import org.testng.annotations.Test; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.lang.invoke.VarHandle; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ThreadLocalRandom; +import java.util.function.Supplier; +import java.util.stream.IntStream; + +import static java.util.stream.Collectors.toMap; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; + +/* + * @test + * @bug 8210280 + * @modules java.base/java.util:open + * @summary White box tests for HashMap internals around table resize + * @run testng WhiteBoxResizeTest + * @key randomness + */ +public class WhiteBoxResizeTest { + final ThreadLocalRandom rnd = ThreadLocalRandom.current(); + final MethodHandle TABLE_SIZE_FOR; + final VarHandle THRESHOLD; + final VarHandle TABLE; + + public WhiteBoxResizeTest() throws ReflectiveOperationException { + Class mClass = HashMap.class; + String nodeClassName = mClass.getName() + "$Node"; + Class nodeArrayClass = Class.forName("[L" + nodeClassName + ";"); + MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(mClass, MethodHandles.lookup()); + TABLE = lookup.findVarHandle(mClass, "table", nodeArrayClass); + this.TABLE_SIZE_FOR = lookup.findStatic( + mClass, "tableSizeFor", + MethodType.methodType(int.class, int.class)); + this.THRESHOLD = lookup.findVarHandle(mClass, "threshold", int.class); + } + + int tableSizeFor(int n) { + try { + return (int) TABLE_SIZE_FOR.invoke(n); + } catch (Throwable t) { throw new AssertionError(t); } + } + + Object[] table(HashMap map) { + try { + return (Object[]) TABLE.get(map); + } catch (Throwable t) { throw new AssertionError(t); } + } + + int capacity(HashMap map) { + return table(map).length; + } + + @Test + public void testTableSizeFor() { + assertEquals(tableSizeFor(0), 1); + assertEquals(tableSizeFor(1), 1); + assertEquals(tableSizeFor(2), 2); + assertEquals(tableSizeFor(3), 4); + assertEquals(tableSizeFor(15), 16); + assertEquals(tableSizeFor(16), 16); + assertEquals(tableSizeFor(17), 32); + int maxSize = 1 << 30; + assertEquals(tableSizeFor(maxSize - 1), maxSize); + assertEquals(tableSizeFor(maxSize), maxSize); + assertEquals(tableSizeFor(maxSize + 1), maxSize); + assertEquals(tableSizeFor(Integer.MAX_VALUE), maxSize); + } + + @Test + public void capacityTestDefaultConstructor() { + capacityTestDefaultConstructor(new HashMap<>()); + capacityTestDefaultConstructor(new LinkedHashMap<>()); + } + + void capacityTestDefaultConstructor(HashMap map) { + assertNull(table(map)); + + map.put(1, 1); + assertEquals(capacity(map), 16); // default initial capacity + + map.putAll(IntStream.range(0, 64).boxed().collect(toMap(i -> i, i -> i))); + assertEquals(capacity(map), 128); + } + + @Test + public void capacityTestInitialCapacity() { + int initialCapacity = rnd.nextInt(2, 128); + List>> suppliers = List.of( + () -> new HashMap<>(initialCapacity), + () -> new HashMap<>(initialCapacity, 0.75f), + () -> new LinkedHashMap<>(initialCapacity), + () -> new LinkedHashMap<>(initialCapacity, 0.75f)); + + for (Supplier> supplier : suppliers) { + HashMap map = supplier.get(); + assertNull(table(map)); + + map.put(1, 1); + assertEquals(capacity(map), tableSizeFor(initialCapacity)); + } + } +} diff --git a/test/jdk/java/util/concurrent/tck/JSR166TestCase.java b/test/jdk/java/util/concurrent/tck/JSR166TestCase.java index 835cdcaa40c..2e40193b272 100644 --- a/test/jdk/java/util/concurrent/tck/JSR166TestCase.java +++ b/test/jdk/java/util/concurrent/tck/JSR166TestCase.java @@ -487,6 +487,12 @@ public class JSR166TestCase extends TestCase { public static boolean atLeastJava9() { return JAVA_CLASS_VERSION >= 53.0; } public static boolean atLeastJava10() { return JAVA_CLASS_VERSION >= 54.0; } public static boolean atLeastJava11() { return JAVA_CLASS_VERSION >= 55.0; } + public static boolean atLeastJava12() { return JAVA_CLASS_VERSION >= 56.0; } + public static boolean atLeastJava13() { return JAVA_CLASS_VERSION >= 57.0; } + public static boolean atLeastJava14() { return JAVA_CLASS_VERSION >= 58.0; } + public static boolean atLeastJava15() { return JAVA_CLASS_VERSION >= 59.0; } + public static boolean atLeastJava16() { return JAVA_CLASS_VERSION >= 60.0; } + public static boolean atLeastJava17() { return JAVA_CLASS_VERSION >= 61.0; } /** * Collects all JSR166 unit tests as one suite. @@ -577,6 +583,7 @@ public class JSR166TestCase extends TestCase { "HashMapTest", "LinkedBlockingDeque8Test", "LinkedBlockingQueue8Test", + "LinkedHashMapTest", "LongAccumulatorTest", "LongAdderTest", "SplittableRandomTest", diff --git a/test/jdk/java/util/concurrent/tck/LinkedHashMapTest.java b/test/jdk/java/util/concurrent/tck/LinkedHashMapTest.java new file mode 100644 index 00000000000..c572d403b36 --- /dev/null +++ b/test/jdk/java/util/concurrent/tck/LinkedHashMapTest.java @@ -0,0 +1,60 @@ +/* + * 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Written by Doug Lea and Martin Buchholz with assistance from + * members of JCP JSR-166 Expert Group and released to the public + * domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +import java.util.LinkedHashMap; +import java.util.Map; + +import junit.framework.Test; + +public class LinkedHashMapTest extends JSR166TestCase { + public static void main(String[] args) { + main(suite(), args); + } + + public static Test suite() { + class Implementation implements MapImplementation { + public Class klazz() { return LinkedHashMap.class; } + public Map emptyMap() { return new LinkedHashMap(); } + public Object makeKey(int i) { return i; } + public Object makeValue(int i) { return i; } + public boolean isConcurrent() { return false; } + public boolean permitsNullKeys() { return true; } + public boolean permitsNullValues() { return true; } + public boolean supportsSetValue() { return true; } + } + return newTestSuite( + // LinkedHashMapTest.class, + MapTest.testSuite(new Implementation())); + } +} diff --git a/test/jdk/java/util/concurrent/tck/MapTest.java b/test/jdk/java/util/concurrent/tck/MapTest.java index 5d1264f9d0c..4446e084d35 100644 --- a/test/jdk/java/util/concurrent/tck/MapTest.java +++ b/test/jdk/java/util/concurrent/tck/MapTest.java @@ -166,6 +166,40 @@ public class MapTest extends JSR166TestCase { assertEquals(1, m.size()); } + /** + * "Missing" test found while investigating JDK-8210280. + * ant -Djsr166.tckTestClass=HashMapTest -Djsr166.methodFilter=testBug8210280 -Djsr166.runsPerTest=1000000 tck + */ + public void testBug8210280() { + final ThreadLocalRandom rnd = ThreadLocalRandom.current(); + final int size1 = rnd.nextInt(32); + final int size2 = rnd.nextInt(128); + + final Map m1 = impl.emptyMap(); + for (int i = 0; i < size1; i++) { + int elt = rnd.nextInt(1024 * i, 1024 * (i + 1)); + assertNull(m1.put(impl.makeKey(elt), impl.makeValue(elt))); + } + + final Map m2 = impl.emptyMap(); + for (int i = 0; i < size2; i++) { + int elt = rnd.nextInt(Integer.MIN_VALUE + 1024 * i, + Integer.MIN_VALUE + 1024 * (i + 1)); + assertNull(m2.put(impl.makeKey(elt), impl.makeValue(-elt))); + } + + final Map m1Copy = impl.emptyMap(); + m1Copy.putAll(m1); + + m1.putAll(m2); + + for (Object elt : m2.keySet()) + assertEquals(m2.get(elt), m1.get(elt)); + for (Object elt : m1Copy.keySet()) + assertSame(m1Copy.get(elt), m1.get(elt)); + assertEquals(size1 + size2, m1.size()); + } + // public void testFailsIntentionallyForDebugging() { // fail(impl.klazz().getSimpleName()); // } diff --git a/test/micro/org/openjdk/bench/java/util/HashMapBench.java b/test/micro/org/openjdk/bench/java/util/HashMapBench.java new file mode 100644 index 00000000000..350641968bd --- /dev/null +++ b/test/micro/org/openjdk/bench/java/util/HashMapBench.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2018, Red Hat, Inc. All rights reserved. + * + * 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. + */ + +package org.openjdk.bench.java.util; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; +import java.util.stream.IntStream; + +import static java.util.stream.Collectors.toMap; + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@State(Scope.Thread) +public class HashMapBench { + private Supplier> mapSupplier; + private Map bigMapToAdd; + + @Param("1000000") + private int size; + + @Param + private MapType mapType; + + public enum MapType { + HASH_MAP, + LINKED_HASH_MAP, + } + + @Setup + public void setup() { + switch (mapType) { + case HASH_MAP: + mapSupplier = () -> new HashMap<>(); + break; + case LINKED_HASH_MAP: + mapSupplier = () -> new LinkedHashMap<>(); + break; + default: + throw new AssertionError(); + } + + ThreadLocalRandom rnd = ThreadLocalRandom.current(); + this.bigMapToAdd = IntStream.range(0, size).boxed() + .collect(toMap(i -> 7 + i * 128, i -> rnd.nextInt())); + } + + @Benchmark + public int putAllWithBigMapToNonEmptyMap() { + Map map = mapSupplier.get(); + map.put(-1, -1); + map.putAll(bigMapToAdd); + return map.size(); + } + + @Benchmark + public int putAllWithBigMapToEmptyMap() { + Map map = mapSupplier.get(); + map.putAll(bigMapToAdd); + return map.size(); + } + + @Benchmark + public int put() { + Map map = mapSupplier.get(); + for (int k : bigMapToAdd.keySet()) { + map.put(k, bigMapToAdd.get(k)); + } + return map.size(); + } +} From f14d0ac7b43c8f9cd36ea3df5cb186d460bcef27 Mon Sep 17 00:00:00 2001 From: Alexandre Iline Date: Fri, 8 Feb 2019 05:46:11 -0900 Subject: [PATCH 027/101] 8218692: Switch to JCov build which supports byte code version 57 Reviewed-by: erikj --- make/conf/jib-profiles.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js index 4f9e572c64f..e2103344086 100644 --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -944,11 +944,17 @@ var getJibProfilesDependencies = function (input, common) { }, jcov: { - server: "jpg", - product: "jcov", - version: "3.0", - build_number: "b07", - file: "bundles/jcov-3_0.zip", + // Until an official build of JCov is available, use custom + // build to support classfile version 57. + // See CODETOOLS-7902358 for more info. + // server: "jpg", + // product: "jcov", + // version: "3.0", + // build_number: "b07", + // file: "bundles/jcov-3_0.zip", + organization: common.organization, + revision: "3.0-57-support+1.0", + ext: "zip", environment_name: "JCOV_HOME", }, From 3e904a4801b2bf2e988ba096e5cb64a17fd5fce7 Mon Sep 17 00:00:00 2001 From: David Holmes Date: Fri, 8 Feb 2019 20:51:55 -0500 Subject: [PATCH 028/101] 8193234: When using -Xcheck:jni an internally allocated buffer can leak Reviewed-by: shade, hseigel --- src/hotspot/share/prims/jniCheck.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/hotspot/share/prims/jniCheck.cpp b/src/hotspot/share/prims/jniCheck.cpp index 9a0b5850fae..8de19ea906f 100644 --- a/src/hotspot/share/prims/jniCheck.cpp +++ b/src/hotspot/share/prims/jniCheck.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -418,21 +418,20 @@ static void* check_wrapped_array_release(JavaThread* thr, const char* fn_name, size_t sz; void* orig_result = check_wrapped_array(thr, fn_name, obj, carray, &sz); switch (mode) { + // As we never make copies, mode 0 and JNI_COMMIT are the same. case 0: - memcpy(orig_result, carray, sz); - GuardedMemory::free_copy(carray); - break; case JNI_COMMIT: memcpy(orig_result, carray, sz); break; case JNI_ABORT: - GuardedMemory::free_copy(carray); break; default: tty->print_cr("%s: Unrecognized mode %i releasing array " PTR_FORMAT " elements " PTR_FORMAT, fn_name, mode, p2i(obj), p2i(carray)); NativeReportJNIFatalError(thr, "Unrecognized array release mode"); } + // We always need to release the copy we made with GuardedMemory + GuardedMemory::free_copy(carray); return orig_result; } From df94bd8e0c10dac73e7db50d17fd7d0ecfef70a3 Mon Sep 17 00:00:00 2001 From: Daniil Titov Date: Sat, 9 Feb 2019 10:07:13 -0800 Subject: [PATCH 029/101] 8218705: Test sun/tools/jcmd/TestJcmdDefaults.java fails on Linux Reviewed-by: dholmes --- .../share/classes/sun/tools/common/ProcessArgumentMatcher.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java b/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java index 8c2cbc548ef..496bcf7033b 100644 --- a/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java +++ b/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java @@ -85,9 +85,6 @@ public class ProcessArgumentMatcher { ProcessHelper helper = ProcessHelper.platformProcessHelper(); if (helper != null) { mainClass = helper.getMainClass(vmd.id()); - if (mainClass == null) { - return false; - } } // If the main class name is still unset then retrieve it with the attach mechanism From 7ce7e1b3d7590d736889b285ccbe81ebe0af3702 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Sat, 9 Feb 2019 19:39:28 +0100 Subject: [PATCH 030/101] 8218715: [TESTBUG] TestUseOptoBiasInliningWithoutEliminateLocks needs to unlock WhiteBoxAPI Reviewed-by: kvn --- .../c2/TestUseOptoBiasInliningWithoutEliminateLocks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/compiler/c2/TestUseOptoBiasInliningWithoutEliminateLocks.java b/test/hotspot/jtreg/compiler/c2/TestUseOptoBiasInliningWithoutEliminateLocks.java index 0c169d4aecd..e959f91c5fa 100644 --- a/test/hotspot/jtreg/compiler/c2/TestUseOptoBiasInliningWithoutEliminateLocks.java +++ b/test/hotspot/jtreg/compiler/c2/TestUseOptoBiasInliningWithoutEliminateLocks.java @@ -40,7 +40,7 @@ * -XX:CompileCommand=compileonly,*.TestUseOptoBiasInliningWithoutEliminateLocks::dontinline_testMethod * -XX:CompileCommand=dontinline,*::dontinline_* * -XX:-EliminateLocks - * -XX:+WhiteBoxAPI -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * -Xbatch * -XX:-TieredCompilation * compiler.c2.TestUseOptoBiasInliningWithoutEliminateLocks From 128a644ce44f1caf7f8ff34f7d8dad7ed7c88777 Mon Sep 17 00:00:00 2001 From: Lance Andersen Date: Sat, 9 Feb 2019 17:19:53 -0500 Subject: [PATCH 031/101] 8182117: Document Zip File System Properties Reviewed-by: alanb, mchung, rriggs, clanger --- src/jdk.zipfs/share/classes/module-info.java | 89 ++++++++++++++++++-- 1 file changed, 82 insertions(+), 7 deletions(-) diff --git a/src/jdk.zipfs/share/classes/module-info.java b/src/jdk.zipfs/share/classes/module-info.java index b7d2495aaa7..5566793e33d 100644 --- a/src/jdk.zipfs/share/classes/module-info.java +++ b/src/jdk.zipfs/share/classes/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -24,14 +24,89 @@ */ /** - * Provides the implementation of the zip file system provider. + * Provides the implementation of the Zip file system provider. + * The Zip file system provider treats the contents of a Zip or JAR file as a file system. + *

* - *

The zip file system provider treats a zip or JAR file as a file system - * and provides the ability to manipulate the contents of the file. - * The zip file system provider can be created by - * {@link java.nio.file.FileSystems#newFileSystem - * FileSystems.newFileSystem} if installed. + *

Accessing a Zip File System

* + * The {@linkplain java.nio.file.FileSystems FileSystems} {@code newFileSystem} + * static factory methods can be used to: + *
    + *
  • Create a Zip file system
  • + *
  • Open an existing file as a Zip file system
  • + *
+ * + *

URI Scheme Used to Identify the Zip File System

+ * + * The URI {@link java.net.URI#getScheme scheme} that identifies the ZIP file system is {@code jar}. + * + *

Zip File System Properties

+ * + * The following properties may be specified when creating a Zip + * file system: + *

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
+ * Configurable properties that may be specified when creating + * a new Zip file system + *
Property NameData TypeDefault ValueDescription
createjava.lang.Stringfalse + * If the value is {@code true}, the Zip file system provider + * creates a new Zip or JAR file if it does not exist. + *
encodingjava.lang.StringUTF-8 + * The value indicates the encoding scheme for the + * names of the entries in the Zip or JAR file. + *
+ * + *

Examples:

+ * + * Construct a new Zip file system that is identified by a URI. If the Zip file does not exist, + * it will be created: + *
+ * {@code
+ *
+ *     URI uri = URI.create("jar:file:/home/luckydog/tennisTeam.zip");
+ *     Map env = Map.of("create", "true");
+ *     FileSystem zipfs = FileSystems.newFileSystem(uri, env);
+ * }
+ * 
+ * + * Construct a new Zip file system that is identified by specifying a path + * and using automatic file type detection. Iterate from the root of the JAR displaying each + * found entry: + *
+ * {@code
+ *
+ *     FileSystem zipfs = FileSystems.newFileSystem(Path.of("helloworld.jar"), null);
+ *     Path rootDir = zipfs.getPath("/");
+ *     Files.walk(rootDir)
+ *            .forEach(System.out::println);
+ * }
+ * 
* @provides java.nio.file.spi.FileSystemProvider * @moduleGraph * @since 9 From 8b83b515b1981557ab27703482b4c14ca4cdb11c Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Mon, 11 Feb 2019 11:01:00 +0800 Subject: [PATCH 032/101] 8180569: Refactor sun/security/krb5/ shell tests to plain java tests Reviewed-by: mullan --- .../krb5/auto/ReplayCacheTestProcWithMD5.java | 36 +++++++ .../sun/security/krb5/auto/rcache_usemd5.sh | 34 ------- .../sun/security/krb5/tools/KtabCheck.java | 78 +++++++++++++-- .../jdk/sun/security/krb5/tools/KtabZero.java | 33 +++++-- test/jdk/sun/security/krb5/tools/ktarg.sh | 67 ------------- test/jdk/sun/security/krb5/tools/ktcheck.sh | 99 ------------------- test/jdk/sun/security/krb5/tools/ktmissing.sh | 51 ---------- test/jdk/sun/security/krb5/tools/ktzero.sh | 74 -------------- test/lib/jdk/test/lib/SecurityTools.java | 28 ++++++ 9 files changed, 160 insertions(+), 340 deletions(-) create mode 100644 test/jdk/sun/security/krb5/auto/ReplayCacheTestProcWithMD5.java delete mode 100644 test/jdk/sun/security/krb5/auto/rcache_usemd5.sh delete mode 100644 test/jdk/sun/security/krb5/tools/ktarg.sh delete mode 100644 test/jdk/sun/security/krb5/tools/ktcheck.sh delete mode 100644 test/jdk/sun/security/krb5/tools/ktmissing.sh delete mode 100644 test/jdk/sun/security/krb5/tools/ktzero.sh diff --git a/test/jdk/sun/security/krb5/auto/ReplayCacheTestProcWithMD5.java b/test/jdk/sun/security/krb5/auto/ReplayCacheTestProcWithMD5.java new file mode 100644 index 00000000000..a9e0988252e --- /dev/null +++ b/test/jdk/sun/security/krb5/auto/ReplayCacheTestProcWithMD5.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8168518 8194486 + * @summary testing jdk.krb5.rcache.useMD5. This action is put in a separate + * test so that ReplayCacheTestProc.java can be launched with special + * test.* system properties easily. + * @library ../../../../java/security/testlibrary/ /test/lib + * @build jdk.test.lib.Platform + * @run main jdk.test.lib.FileInstaller TestHosts TestHosts + * @run main/othervm/timeout=300 -Djdk.krb5.rcache.useMD5=true + * -Djdk.net.hosts.file=TestHosts + * -Dtest.service=host ReplayCacheTestProc + */ diff --git a/test/jdk/sun/security/krb5/auto/rcache_usemd5.sh b/test/jdk/sun/security/krb5/auto/rcache_usemd5.sh deleted file mode 100644 index 3cd21671bf0..00000000000 --- a/test/jdk/sun/security/krb5/auto/rcache_usemd5.sh +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright (c) 2016, 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. -# - -# @test -# @bug 8168518 8194486 -# @summary testing jdk.krb5.rcache.useMD5. This action is put in a separate -# test so that ReplayCacheTestProc.java can be launched with special -# test.* system properties easily. -# @library ../../../../java/security/testlibrary/ /test/lib -# @build jdk.test.lib.Platform -# @run main jdk.test.lib.FileInstaller TestHosts TestHosts -# @run main/othervm/timeout=300 -Djdk.krb5.rcache.useMD5=true -# -Djdk.net.hosts.file=TestHosts -# -Dtest.service=host ReplayCacheTestProc diff --git a/test/jdk/sun/security/krb5/tools/KtabCheck.java b/test/jdk/sun/security/krb5/tools/KtabCheck.java index ebd18fd70d8..308d64903a1 100644 --- a/test/jdk/sun/security/krb5/tools/KtabCheck.java +++ b/test/jdk/sun/security/krb5/tools/KtabCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2019, 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 @@ -21,27 +21,87 @@ * questions. */ +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Arrays; import java.util.HashSet; import java.util.Set; + +import jdk.test.lib.SecurityTools; import sun.security.krb5.internal.ktab.KeyTab; import sun.security.krb5.internal.ktab.KeyTabEntry; -/** - * This class is called by the test ktcheck.sh and is not meant to run - * by itself. +/* + * @test + * @bug 6950546 + * @summary "ktab -d name etype" to "ktab -d name [-e etype] [kvno | all | old]" + * @requires os.family == "windows" + * @library /test/lib + * @modules java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 */ public class KtabCheck { + + private static final String KEYTAB = "ktab.tmp"; + + public static void main(String[] args) throws Exception { + + Files.deleteIfExists(Path.of(KEYTAB)); + + ktab("-a me mine"); + check(1,16,1,23,1,17); + ktab("-a me mine -n 0"); + check(0,16,0,23,0,17); + ktab("-a me mine -n 1 -append"); + check(0,16,0,23,0,17,1,16,1,23,1,17); + ktab("-a me mine -append"); + check(0,16,0,23,0,17,1,16,1,23,1,17,2,16,2,23,2,17); + ktab("-a me mine"); + check(3,16,3,23,3,17); + ktab("-a me mine -n 4 -append"); + check(3,16,3,23,3,17,4,16,4,23,4,17); + ktab("-a me mine -n 5 -append"); + check(3,16,3,23,3,17,4,16,4,23,4,17,5,16,5,23,5,17); + ktab("-a me mine -n 6 -append"); + check(3,16,3,23,3,17,4,16,4,23,4,17,5,16,5,23,5,17,6,16,6,23,6,17); + ktab("-d me 3"); + check(4,16,4,23,4,17,5,16,5,23,5,17,6,16,6,23,6,17); + ktab("-d me -e 16 6"); + check(4,16,4,23,4,17,5,16,5,23,5,17,6,23,6,17); + ktab("-d me -e 17 6"); + check(4,16,4,23,4,17,5,16,5,23,5,17,6,23); + ktab("-d me -e 16 5"); + check(4,16,4,23,4,17,5,23,5,17,6,23); + ktab("-d me old"); + check(4,16,5,17,6,23); + try { + ktab("-d me old"); + throw new Exception("Should fail"); + } catch (Exception e) { + // no-op + } + check(4,16,5,17,6,23); + ktab("-d me"); + check(); + } + + static void ktab(String s) throws Exception { + File conf = new File(System.getProperty("test.src"), "onlythree.conf"); + SecurityTools.ktab("-J-Djava.security.krb5.conf=" + conf + + " -k " + KEYTAB + " -f " + s).shouldHaveExitValue(0); + } + /** * Checks if a keytab contains exactly the keys (kvno and etype) - * @param args keytabname kvno etype... + * @param args kvno etype... */ - public static void main(String[] args) throws Exception { + static void check(int... args) throws Exception { System.out.println("Checking " + Arrays.toString(args)); - KeyTab ktab = KeyTab.getInstance(args[0]); + KeyTab ktab = KeyTab.getInstance(KEYTAB); Set expected = new HashSet<>(); - for (int i=1; i /dev/null -KTAB="${TESTJAVA}${FS}bin${FS}ktab -k $KEYTAB" - -$KTAB -a me@LOCAL mine || exit 1 - -$KTAB -hello -if [ $? = 0 ]; then exit 2; fi - -$KTAB -if [ $? = 0 ]; then exit 3; fi - -exit 0 diff --git a/test/jdk/sun/security/krb5/tools/ktcheck.sh b/test/jdk/sun/security/krb5/tools/ktcheck.sh deleted file mode 100644 index a2759b72c2e..00000000000 --- a/test/jdk/sun/security/krb5/tools/ktcheck.sh +++ /dev/null @@ -1,99 +0,0 @@ -# -# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 6950546 -# @summary "ktab -d name etype" to "ktab -d name [-e etype] [kvno | all | old]" -# @modules java.security.jgss/sun.security.krb5.internal.ktab -# java.security.jgss/sun.security.krb5 -# @compile KtabCheck.java -# @run shell ktcheck.sh -# - -if [ "${TESTJAVA}" = "" ] ; then - JAVAC_CMD=`which javac` - TESTJAVA=`dirname $JAVAC_CMD`/.. -fi - -if [ "${TESTSRC}" = "" ] ; then - TESTSRC="." -fi - -OS=`uname -s` -case "$OS" in - CYGWIN* ) - FS="/" - ;; - Windows_* ) - FS="\\" - ;; - * ) - FS="/" - echo "Unsupported system!" - exit 0; - ;; -esac - -KEYTAB=ktab.tmp - -rm $KEYTAB - -EXTRA_OPTIONS="-Djava.security.krb5.conf=${TESTSRC}${FS}onlythree.conf" -KTAB="${TESTJAVA}${FS}bin${FS}ktab -J${EXTRA_OPTIONS} -k $KEYTAB -f" -CHECK="${TESTJAVA}${FS}bin${FS}java -cp ${TESTCLASSES} ${TESTVMOPTS} ${EXTRA_OPTIONS} \ - --add-exports java.security.jgss/sun.security.krb5.internal.ktab=ALL-UNNAMED \ - --add-exports java.security.jgss/sun.security.krb5=ALL-UNNAMED \ - KtabCheck $KEYTAB" - -echo ${EXTRA_OPTIONS} - -$KTAB -a me mine -$CHECK 1 16 1 23 1 17 || exit 1 -$KTAB -a me mine -n 0 -$CHECK 0 16 0 23 0 17 || exit 1 -$KTAB -a me mine -n 1 -append -$CHECK 0 16 0 23 0 17 1 16 1 23 1 17 || exit 1 -$KTAB -a me mine -append -$CHECK 0 16 0 23 0 17 1 16 1 23 1 17 2 16 2 23 2 17 || exit 1 -$KTAB -a me mine -$CHECK 3 16 3 23 3 17 || exit 1 -$KTAB -a me mine -n 4 -append -$CHECK 3 16 3 23 3 17 4 16 4 23 4 17 || exit 1 -$KTAB -a me mine -n 5 -append -$CHECK 3 16 3 23 3 17 4 16 4 23 4 17 5 16 5 23 5 17 || exit 1 -$KTAB -a me mine -n 6 -append -$CHECK 3 16 3 23 3 17 4 16 4 23 4 17 5 16 5 23 5 17 6 16 6 23 6 17 || exit 1 -$KTAB -d me 3 -$CHECK 4 16 4 23 4 17 5 16 5 23 5 17 6 16 6 23 6 17 || exit 1 -$KTAB -d me -e 16 6 -$CHECK 4 16 4 23 4 17 5 16 5 23 5 17 6 23 6 17 || exit 1 -$KTAB -d me -e 17 6 -$CHECK 4 16 4 23 4 17 5 16 5 23 5 17 6 23 || exit 1 -$KTAB -d me -e 16 5 -$CHECK 4 16 4 23 4 17 5 23 5 17 6 23 || exit 1 -$KTAB -d me old -$CHECK 4 16 5 17 6 23 || exit 1 -$KTAB -d me old -$CHECK 4 16 5 17 6 23 || exit 1 -$KTAB -d me -$CHECK || exit 1 diff --git a/test/jdk/sun/security/krb5/tools/ktmissing.sh b/test/jdk/sun/security/krb5/tools/ktmissing.sh deleted file mode 100644 index 6410abab7fa..00000000000 --- a/test/jdk/sun/security/krb5/tools/ktmissing.sh +++ /dev/null @@ -1,51 +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. -# - -# @test -# @bug 7043737 -# @summary klist does not detect non-existing keytab -# @run shell ktmissing.sh -# - -OS=`uname -s` -case "$OS" in - CYGWIN* ) - FS="/" - ;; - Windows_* ) - FS="\\" - ;; - * ) - FS="/" - echo "Unsupported system!" - exit 0; - ;; -esac - -${TESTJAVA}${FS}bin${FS}klist -k this_file_does_not_exist && exit 1 - -echo ABC > this_is_not_a_keytab - -${TESTJAVA}${FS}bin${FS}klist -k this_is_not_a_keytab && exit 2 - -exit 0 diff --git a/test/jdk/sun/security/krb5/tools/ktzero.sh b/test/jdk/sun/security/krb5/tools/ktzero.sh deleted file mode 100644 index fd5c488d4ea..00000000000 --- a/test/jdk/sun/security/krb5/tools/ktzero.sh +++ /dev/null @@ -1,74 +0,0 @@ -# -# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 8014196 -# @summary ktab creates a file with zero kt_vno -# @run shell ktzero.sh -# - -if [ "${TESTJAVA}" = "" ] ; then - JAVAC_CMD=`which javac` - TESTJAVA=`dirname $JAVAC_CMD`/.. -fi - -if [ "${TESTSRC}" = "" ] ; then - TESTSRC="." -fi - -OS=`uname -s` -case "$OS" in - CYGWIN* ) - FS="/" - ;; - Windows_* ) - FS="\\" - ;; - * ) - FS="/" - echo "Unsupported system!" - exit 0; - ;; -esac - -KEYTAB=ktzero.tmp - -rm $KEYTAB 2> /dev/null -KTAB="${TESTJAVA}${FS}bin${FS}ktab -k $KEYTAB" - -# Listing non-existing ktab should fail -$KTAB -l && exit 1 - -# Can add to non-existing ktab -$KTAB -a me@LOCAL mine || exit 2 - -# Now can be listed -$KTAB -l || exit 3 - -echo ABCDEFG > $KEYTAB - -# Invalid keytab should fail for all commands -$KTAB -l && exit 4 -$KTAB -a me@LOCAL mine && exit 2 - -exit 0 diff --git a/test/lib/jdk/test/lib/SecurityTools.java b/test/lib/jdk/test/lib/SecurityTools.java index d6889402349..23e055b77e5 100644 --- a/test/lib/jdk/test/lib/SecurityTools.java +++ b/test/lib/jdk/test/lib/SecurityTools.java @@ -195,5 +195,33 @@ public class SecurityTools { public static OutputAnalyzer jarsigner(String... args) throws Exception { return jarsigner(List.of(args)); } + + /** + * Runs ktab. + * + * @param args arguments to ktab in a single string. Only call this if + * there is no white space inside an argument. This string will + * be split with {@code \s+}. + * @return an {@link OutputAnalyzer} object + * @throws Exception if there is an error + */ + public static OutputAnalyzer ktab(String args) throws Exception { + return execute(getProcessBuilder( + "ktab", List.of(args.trim().split("\\s+")))); + } + + /** + * Runs klist. + * + * @param args arguments to klist in a single string. Only call this if + * there is no white space inside an argument. This string will + * be split with {@code \s+}. + * @return an {@link OutputAnalyzer} object + * @throws Exception if there is an error + */ + public static OutputAnalyzer klist(String args) throws Exception { + return execute(getProcessBuilder( + "klist", List.of(args.trim().split("\\s+")))); + } } From ebaef49ed417c47a1b0b120ec0528500a2bed3f1 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 11 Feb 2019 12:12:41 +0100 Subject: [PATCH 033/101] 8218736: Build warning in lib/JvmFlags.gmk: extraneous text after 'ifeq' directive Reviewed-by: redestad, shade --- make/hotspot/lib/JvmFlags.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/hotspot/lib/JvmFlags.gmk b/make/hotspot/lib/JvmFlags.gmk index 251c731ea71..ced208167e0 100644 --- a/make/hotspot/lib/JvmFlags.gmk +++ b/make/hotspot/lib/JvmFlags.gmk @@ -74,7 +74,7 @@ ifeq ($(DEBUG_LEVEL), release) endif else ifeq ($(DEBUG_LEVEL), fastdebug) JVM_CFLAGS_DEBUGLEVEL := -DASSERT - ifeq ($call isTargetOs, windows aix), false) + ifeq ($(call isTargetOs, windows aix), false) # NOTE: Old build did not define CHECK_UNHANDLED_OOPS on Windows and AIX. JVM_CFLAGS_DEBUGLEVEL += -DCHECK_UNHANDLED_OOPS endif From 9bc10ee9bf5c47d30b81500f38971ab6ebc4ac6d Mon Sep 17 00:00:00 2001 From: Gary Adams Date: Mon, 11 Feb 2019 07:19:32 -0500 Subject: [PATCH 034/101] 8068225: nsk/jdi/EventQueue/remove_l/remove_l005 intermittently times out Reviewed-by: cjplummer, sspitsyn --- test/hotspot/jtreg/ProblemList.txt | 1 - .../jdi/VirtualMachine/canBeModified/canbemodified001.java | 3 ++- test/hotspot/jtreg/vmTestbase/nsk/share/jdi/Debugee.java | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 559b1efb0f5..b020d81f30c 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -164,7 +164,6 @@ vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x001/TestDescription.java 8013728 gene vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003/TestDescription.java 8066993 generic-all vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses021/TestDescription.java 8065773 generic-all vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses023/TestDescription.java 8065773 generic-all -vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l005/TestDescription.java 8068225 generic-all vmTestbase/metaspace/gc/firstGC_10m/TestDescription.java 8208250 generic-all vmTestbase/metaspace/gc/firstGC_50m/TestDescription.java 8208250 generic-all diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canBeModified/canbemodified001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canBeModified/canbemodified001.java index 9c731ebbc3e..5e2386f33eb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canBeModified/canbemodified001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canBeModified/canbemodified001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -78,6 +78,7 @@ public class canbemodified001 { exitStatus = Consts.TEST_FAILED; e.printStackTrace(); } finally { + debugee.resume(); debugee.endDebugee(); } display("Test finished. exitStatus = " + exitStatus); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/Debugee.java b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/Debugee.java index 9d87ef36392..c7f82af2261 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/Debugee.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/Debugee.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -557,6 +557,7 @@ abstract public class Debugee extends DebugeeProcess { * exit status code. */ public int endDebugee() { + int status = waitFor(); if (vm != null) { try { vm.dispose(); @@ -564,7 +565,7 @@ abstract public class Debugee extends DebugeeProcess { } vm = null; } - return waitFor(); + return status; } /* From 7e1347391a624fd849429bf132f0fa5627b8f9f0 Mon Sep 17 00:00:00 2001 From: Roman Kennke Date: Mon, 11 Feb 2019 16:49:08 +0100 Subject: [PATCH 035/101] 8217874: Shenandoah: Clobbered register in ShenandoahBarrierSetAssembler::cmpxchg_oop() Reviewed-by: adinn --- .../shenandoahBarrierSetAssembler_aarch64.cpp | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp index 69b4a700c30..cca1b4d304d 100644 --- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp @@ -425,54 +425,56 @@ void ShenandoahBarrierSetAssembler::resolve(MacroAssembler* masm, DecoratorSet d void ShenandoahBarrierSetAssembler::cmpxchg_oop(MacroAssembler* masm, Register addr, Register expected, Register new_val, bool acquire, bool release, bool weak, bool is_cae, Register result) { - - Register tmp = rscratch2; + Register tmp1 = rscratch1; + Register tmp2 = rscratch2; bool is_narrow = UseCompressedOops; Assembler::operand_size size = is_narrow ? Assembler::word : Assembler::xword; - assert_different_registers(addr, expected, new_val, result, tmp); + assert_different_registers(addr, expected, new_val, tmp1, tmp2); Label retry, done, fail; // CAS, using LL/SC pair. __ bind(retry); - __ load_exclusive(result, addr, size, acquire); + __ load_exclusive(tmp1, addr, size, acquire); if (is_narrow) { - __ cmpw(result, expected); + __ cmpw(tmp1, expected); } else { - __ cmp(result, expected); + __ cmp(tmp1, expected); } __ br(Assembler::NE, fail); - __ store_exclusive(tmp, new_val, addr, size, release); + __ store_exclusive(tmp2, new_val, addr, size, release); if (weak) { - __ cmpw(tmp, 0u); // If the store fails, return NE to our caller + __ cmpw(tmp2, 0u); // If the store fails, return NE to our caller } else { - __ cbnzw(tmp, retry); + __ cbnzw(tmp2, retry); } __ b(done); __ bind(fail); - // Check if rb(expected)==rb(result) + // Check if rb(expected)==rb(tmp1) // Shuffle registers so that we have memory value ready for next expected. - __ mov(tmp, expected); - __ mov(expected, result); + __ mov(tmp2, expected); + __ mov(expected, tmp1); if (is_narrow) { - __ decode_heap_oop(result, result); - __ decode_heap_oop(tmp, tmp); + __ decode_heap_oop(tmp1, tmp1); + __ decode_heap_oop(tmp2, tmp2); } - read_barrier_impl(masm, result); - read_barrier_impl(masm, tmp); - __ cmp(result, tmp); + read_barrier_impl(masm, tmp1); + read_barrier_impl(masm, tmp2); + __ cmp(tmp1, tmp2); // Retry with expected now being the value we just loaded from addr. __ br(Assembler::EQ, retry); if (is_cae && is_narrow) { // For cmp-and-exchange and narrow oops, we need to restore // the compressed old-value. We moved it to 'expected' a few lines up. - __ mov(result, expected); + __ mov(tmp1, expected); } __ bind(done); - if (!is_cae) { + if (is_cae) { + __ mov(result, tmp1); + } else { __ cset(result, Assembler::EQ); } } From 6d98f3c4d724132c07b4141c65feade3dd7c14aa Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Mon, 11 Feb 2019 18:41:24 +0100 Subject: [PATCH 036/101] 8218554: HttpServer: allow custom handlers to request that the connection be closed after the exchange Custom handler code can supply `Connection: close` to response headers in order to force connection close after the exchange terminates. Reviewed-by: chegar --- .../com/sun/net/httpserver/HttpExchange.java | 9 +- .../sun/net/httpserver/ExchangeImpl.java | 19 +- .../bugs/HandlerConnectionClose.java | 437 ++++++++++++++++++ 3 files changed, 463 insertions(+), 2 deletions(-) create mode 100644 test/jdk/com/sun/net/httpserver/bugs/HandlerConnectionClose.java diff --git a/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java b/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java index 0ce0b1220b1..067f8060cd2 100644 --- a/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java +++ b/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -171,6 +171,13 @@ public abstract class HttpExchange { * this is set to the appropriate value depending on the response length parameter. *

* This method must be called prior to calling {@link #getResponseBody()}. + * + * @implNote This implementation allows the caller to instruct the + * server to force a connection close after the exchange terminates, by + * supplying a {@code Connection: close} header to the {@linkplain + * #getResponseHeaders() response headers} before {@code sendResponseHeaders} + * is called. + * * @param rCode the response code to send * @param responseLength if {@literal > 0}, specifies a fixed response * body length and that exact number of bytes must be written diff --git a/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java b/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java index 13b0326a150..61cf85646ec 100644 --- a/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java +++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -32,6 +32,7 @@ import java.util.*; import java.lang.System.Logger; import java.lang.System.Logger.Level; import java.text.*; +import java.util.stream.Stream; import com.sun.net.httpserver.*; class ExchangeImpl { @@ -261,6 +262,22 @@ class ExchangeImpl { o.setWrappedStream (new FixedLengthOutputStream (this, ros, contentLen)); } } + + // A custom handler can request that the connection be + // closed after the exchange by supplying Connection: close + // to the response header. Nothing to do if the exchange is + // already set up to be closed. + if (!close) { + Stream conheader = + Optional.ofNullable(rspHdrs.get("Connection")) + .map(List::stream).orElse(Stream.empty()); + if (conheader.anyMatch("close"::equalsIgnoreCase)) { + Logger logger = server.getLogger(); + logger.log (Level.DEBUG, "Connection: close requested by handler"); + close = true; + } + } + write (rspHdrs, tmpout); this.rspContentLen = contentLen; tmpout.flush() ; diff --git a/test/jdk/com/sun/net/httpserver/bugs/HandlerConnectionClose.java b/test/jdk/com/sun/net/httpserver/bugs/HandlerConnectionClose.java new file mode 100644 index 00000000000..89839e462c5 --- /dev/null +++ b/test/jdk/com/sun/net/httpserver/bugs/HandlerConnectionClose.java @@ -0,0 +1,437 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8218554 + * @summary test that the handler can request a connection close. + * @library /test/lib + * @build jdk.test.lib.net.SimpleSSLContext + * @run main/othervm HandlerConnectionClose + */ + +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; +import com.sun.net.httpserver.HttpsConfigurator; +import com.sun.net.httpserver.HttpsServer; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.URI; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Locale; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; +import java.util.logging.StreamHandler; +import jdk.test.lib.net.SimpleSSLContext; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; + +public class HandlerConnectionClose +{ + static final int ONEK = 1024; + static final long POST_SIZE = ONEK * 1L; + SSLContext sslContext; + Logger logger; + + void test(String[] args) throws Exception { + + HttpServer httpServer = startHttpServer("http"); + try { + testHttpURLConnection(httpServer, "http","/close/legacy/http/chunked"); + testHttpURLConnection(httpServer, "http","/close/legacy/http/fixed"); + testPlainSocket(httpServer, "http","/close/plain/http/chunked"); + testPlainSocket(httpServer, "http","/close/plain/http/fixed"); + } finally { + httpServer.stop(0); + } + sslContext = new SimpleSSLContext().get(); + HttpServer httpsServer = startHttpServer("https"); + try { + testHttpURLConnection(httpsServer, "https","/close/legacy/https/chunked"); + testHttpURLConnection(httpsServer, "https","/close/legacy/https/fixed"); + testPlainSocket(httpsServer, "https","/close/plain/https/chunked"); + testPlainSocket(httpsServer, "https","/close/plain/https/fixed"); + } finally{ + httpsServer.stop(0); + } + } + + void testHttpURLConnection(HttpServer httpServer, String protocol, String path) throws Exception { + int port = httpServer.getAddress().getPort(); + String host = httpServer.getAddress().getHostString(); + URL url = new URI(protocol, null, host, port, path, null, null).toURL(); + HttpURLConnection uc = (HttpURLConnection) url.openConnection(); + if ("https".equalsIgnoreCase(protocol)) { + ((HttpsURLConnection)uc).setSSLSocketFactory(sslContext.getSocketFactory()); + ((HttpsURLConnection)uc).setHostnameVerifier((String hostname, SSLSession session) -> true); + } + uc.setDoOutput(true); + uc.setRequestMethod("POST"); + uc.setFixedLengthStreamingMode(POST_SIZE); + OutputStream os = uc.getOutputStream(); + + /* create a 1K byte array with data to POST */ + byte[] ba = new byte[ONEK]; + for (int i = 0; i < ONEK; i++) + ba[i] = (byte) i; + + System.out.println("\n" + uc.getClass().getSimpleName() +": POST " + url + " HTTP/1.1"); + long times = POST_SIZE / ONEK; + for (int i = 0; i < times; i++) { + os.write(ba); + } + + os.close(); + InputStream is = uc.getInputStream(); + int read; + long count = 0; + while ((read = is.read(ba)) != -1) { + for (int i = 0; i < read; i++) { + byte expected = (byte) count++; + if (ba[i] != expected) { + throw new IOException("byte mismatch at " + + (count - 1) + ": expected " + expected + " got " + ba[i]); + } + } + } + if (count != POST_SIZE) { + throw new IOException("Unexpected length: " + count + " expected " + POST_SIZE); + } + is.close(); + + pass(); + } + + void testPlainSocket(HttpServer httpServer, String protocol, String path) throws Exception { + int port = httpServer.getAddress().getPort(); + String host = httpServer.getAddress().getHostString(); + URL url = new URI(protocol, null, host, port, path, null, null).toURL(); + Socket socket; + if ("https".equalsIgnoreCase(protocol)) { + socket = sslContext.getSocketFactory().createSocket(host, port); + } else { + socket = new Socket(host, port); + } + try (Socket sock = socket) { + OutputStream os = socket.getOutputStream(); + + // send request headers + String request = new StringBuilder() + .append("POST ").append(path).append(" HTTP/1.1").append("\r\n") + .append("host: ").append(host).append(':').append(port).append("\r\n") + .append("Content-Length: ").append(POST_SIZE).append("\r\n") + .append("\r\n") + .toString(); + os.write(request.getBytes(StandardCharsets.US_ASCII)); + + /* create a 1K byte array with data to POST */ + byte[] ba = new byte[ONEK]; + for (int i = 0; i < ONEK; i++) + ba[i] = (byte) i; + + // send request data + long times = POST_SIZE / ONEK; + for (int i = 0; i < times; i++) { + os.write(ba); + } + os.flush(); + + InputStream is = socket.getInputStream(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + + // read all response headers + int c; + int crlf = 0; + while ((c = is.read()) != -1) { + if (c == '\r') continue; + if (c == '\n') crlf++; + else crlf = 0; + bos.write(c); + if (crlf == 2) break; + } + String responseHeadersStr = bos.toString(StandardCharsets.US_ASCII); + List responseHeaders = List.of(responseHeadersStr.split("\n")); + System.out.println("\nPOST " + url + " HTTP/1.1"); + responseHeaders.stream().forEach(s -> System.out.println("[reply]\t" + s)); + String statusLine = responseHeaders.get(0); + if (!statusLine.startsWith("HTTP/1.1 200 ")) + throw new IOException("Unexpected status: " + statusLine); + String cl = responseHeaders.stream() + .map(s -> s.toLowerCase(Locale.ROOT)) + .filter(s -> s.startsWith("content-length: ")) + .findFirst() + .orElse(null); + String te = responseHeaders.stream() + .map(s -> s.toLowerCase(Locale.ROOT)) + .filter(s -> s.startsWith("transfer-encoding: ")) + .findFirst() + .orElse(null); + + // check content-length and transfer-encoding are as expected + int read = 0; + long count = 0; + if (path.endsWith("/fixed")) { + if (!("content-length: " + POST_SIZE).equalsIgnoreCase(cl)) { + throw new IOException("Unexpected Content-Length: [" + cl + "]"); + } + if (te != null) { + throw new IOException("Unexpected Transfer-Encoding: [" + te + "]"); + } + // Got expected Content-Length: 1024 - read response data + while ((read = is.read()) != -1) { + int expected = (int) (count & 0xFF); + if ((read & 0xFF) != expected) { + throw new IOException("byte mismatch at " + + (count - 1) + ": expected " + expected + " got " + read); + } + if (++count == POST_SIZE) break; + } + } else if (cl != null) { + throw new IOException("Unexpected Content-Length: [" + cl + "]"); + } else { + if (!("transfer-encoding: chunked").equalsIgnoreCase(te)) { + throw new IOException("Unexpected Transfer-Encoding: [" + te + "]"); + } + // This is a quick & dirty implementation of + // chunk decoding - no trailers - no extensions + StringBuilder chunks = new StringBuilder(); + int cs = -1; + while (cs != 0) { + cs = 0; + chunks.setLength(0); + + // read next chunk length + while ((read = is.read()) != -1) { + if (read == '\r') continue; + if (read == '\n') break; + chunks.append((char) read); + } + cs = Integer.parseInt(chunks.toString().trim(), 16); + System.out.println("Got chunk length: " + cs); + + // If chunk size is 0, then we have read the last chunk. + if (cs == 0) break; + + // Read the chunk data + while (--cs >= 0) { + read = is.read(); + if (read == -1) break; // EOF + int expected = (int) (count & 0xFF); + if ((read & 0xFF) != expected) { + throw new IOException("byte mismatch at " + + (count - 1) + ": expected " + expected + " got " + read); + } + // This is cheating: we know the size :-) + if (++count == POST_SIZE) break; + } + + if (read == -1) { + throw new IOException("Unexpected EOF after " + count + " data bytes"); + } + + // read CRLF + if ((read = is.read()) != '\r') { + throw new IOException("Expected CR at " + count + "after chunk data - got " + read); + } + if ((read = is.read()) != '\n') { + throw new IOException("Expected LF at " + count + "after chunk data - got " + read); + } + + if (cs == 0 && count == POST_SIZE) { + cs = -1; + } + + if (cs != -1) { + // count == POST_SIZE, but some chunk data still to be read? + throw new IOException("Unexpected chunk size, " + + cs + " bytes still to read after " + count + + " data bytes received."); + } + } + // Last CRLF? + for (int i = 0; i < 2; i++) { + if ((read = is.read()) == -1) break; + } + } + + if (count != POST_SIZE) { + throw new IOException("Unexpected length: " + count + " expected " + POST_SIZE); + } + + if (!sock.isClosed()) { + try { + // We send an end request to the server to verify that the + // connection is closed. If the server has not closed the + // connection, it will reply. If we receive a response, + // we should fail... + String endrequest = new StringBuilder() + .append("GET ").append("/close/end").append(" HTTP/1.1").append("\r\n") + .append("host: ").append(host).append(':').append(port).append("\r\n") + .append("Content-Length: ").append(0).append("\r\n") + .append("\r\n") + .toString(); + os.write(endrequest.getBytes(StandardCharsets.US_ASCII)); + os.flush(); + StringBuilder resp = new StringBuilder(); + crlf = 0; + + // read all headers. + // If the server closed the connection as expected + // we should immediately read EOF + while ((read = is.read()) != -1) { + if (read == '\r') continue; + if (read == '\n') crlf++; + else crlf = 0; + if (crlf == 2) break; + resp.append((char) read); + } + + List lines = List.of(resp.toString().split("\n")); + if (read != -1 || resp.length() != 0) { + System.err.println("Connection not closed!"); + System.err.println("Got: "); + lines.stream().forEach(s -> System.err.println("[end]\t" + s)); + throw new AssertionError("EOF not received after " + count + " data bytes"); + } + if (read != -1) { + throw new AssertionError("EOF was expected after " + count + " bytes, but got: " + read); + } else { + System.out.println("Got expected EOF (" + read + ")"); + } + } catch (IOException x) { + // expected! all is well + System.out.println("Socket closed as expected, got exception writing to it."); + } + } else { + System.out.println("Socket closed as expected"); + } + pass(); + } + } + + /** + * Http Server + */ + HttpServer startHttpServer(String protocol) throws IOException { + if (debug) { + logger = Logger.getLogger("com.sun.net.httpserver"); + Handler outHandler = new StreamHandler(System.out, + new SimpleFormatter()); + outHandler.setLevel(Level.FINEST); + logger.setLevel(Level.FINEST); + logger.addHandler(outHandler); + } + + InetSocketAddress serverAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); + HttpServer httpServer = null; + if ("http".equalsIgnoreCase(protocol)) { + httpServer = HttpServer.create(serverAddress, 0); + } + if ("https".equalsIgnoreCase(protocol)) { + HttpsServer httpsServer = HttpsServer.create(serverAddress, 0); + httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext)); + httpServer = httpsServer; + } + httpServer.createContext("/close/", new MyHandler(POST_SIZE)); + System.out.println("Server created at: " + httpServer.getAddress()); + httpServer.start(); + return httpServer; + } + + class MyHandler implements HttpHandler { + static final int BUFFER_SIZE = 512; + final long expected; + + MyHandler(long expected){ + this.expected = expected; + } + + @Override + public void handle(HttpExchange t) throws IOException { + System.out.println("Server: serving " + t.getRequestURI()); + boolean chunked = t.getRequestURI().getPath().endsWith("/chunked"); + boolean fixed = t.getRequestURI().getPath().endsWith("/fixed"); + boolean end = t.getRequestURI().getPath().endsWith("/end"); + long responseLength = fixed ? POST_SIZE : 0; + responseLength = end ? -1 : responseLength; + responseLength = chunked ? 0 : responseLength; + + if (!end) t.getResponseHeaders().add("connection", "CLose"); + t.sendResponseHeaders(200, responseLength); + + if (!end) { + OutputStream os = t.getResponseBody(); + InputStream is = t.getRequestBody(); + byte[] ba = new byte[BUFFER_SIZE]; + int read; + long count = 0L; + while ((read = is.read(ba)) != -1) { + count += read; + os.write(ba, 0, read); + } + is.close(); + + check(count == expected, "Expected: " + expected + ", received " + + count); + debug("Received " + count + " bytes"); + os.close(); + } + + t.close(); + } + } + + //--------------------- Infrastructure --------------------------- + boolean debug = true; + volatile int passed = 0, failed = 0; + void pass() {passed++;} + void fail() {failed++; Thread.dumpStack();} + void fail(String msg) {System.err.println(msg); fail();} + void unexpected(Throwable t) {failed++; t.printStackTrace();} + void check(boolean cond) {if (cond) pass(); else fail();} + void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);} + void debug(String message) {if(debug) { System.out.println(message); } } + public static void main(String[] args) throws Throwable { + Class k = new Object(){}.getClass().getEnclosingClass(); + try {k.getMethod("instanceMain",String[].class) + .invoke( k.newInstance(), (Object) args);} + catch (Throwable e) {throw e.getCause();}} + public void instanceMain(String[] args) throws Throwable { + try {test(args);} catch (Throwable t) {unexpected(t);} + System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); + if (failed > 0) throw new AssertionError("Some tests failed");} + +} From 9eb1223ac09d2f0a4adb9795b45db7a16098e7a8 Mon Sep 17 00:00:00 2001 From: Anthony Scarpino Date: Mon, 11 Feb 2019 13:23:20 -0800 Subject: [PATCH 037/101] 8201633: Problems with AES-GCM native acceleration Reviewed-by: valeriep --- .../crypto/provider/GaloisCounterMode.java | 63 ++++++++++++++----- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java b/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java index 16d4fd4886f..bdbd449ea28 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2019, 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 @@ -61,6 +61,9 @@ final class GaloisCounterMode extends FeedbackCipher { // can only be returned by the doFinal(...) call. private static final int MAX_BUF_SIZE = Integer.MAX_VALUE; + // data size when buffer is divided up to aid in intrinsics + private static final int TRIGGERLEN = 65536; // 64k + // buffer for AAD data; if null, meaning update has been called private ByteArrayOutputStream aadBuffer = new ByteArrayOutputStream(); private int sizeOfAAD = 0; @@ -380,12 +383,10 @@ final class GaloisCounterMode extends FeedbackCipher { // Utility to process the last block; used by encryptFinal and decryptFinal void doLastBlock(byte[] in, int inOfs, int len, byte[] out, int outOfs, boolean isEncrypt) throws IllegalBlockSizeException { - // process data in 'in' - gctrPAndC.doFinal(in, inOfs, len, out, outOfs); - processed += len; - byte[] ct; int ctOfs; + int ilen = len; // internal length + if (isEncrypt) { ct = out; ctOfs = outOfs; @@ -393,14 +394,38 @@ final class GaloisCounterMode extends FeedbackCipher { ct = in; ctOfs = inOfs; } + + // Divide up larger data sizes to trigger CTR & GHASH intrinsic quicker + if (len > TRIGGERLEN) { + int i = 0; + int tlen; // incremental lengths + // 96bit CTR x86 intrinsic + final int plen = AES_BLOCK_SIZE * 6; + // arbitrary formula to aid intrinsic without reaching buffer end + final int count = len / 1024; + + while (count > i) { + tlen = gctrPAndC.update(in, inOfs, plen, out, outOfs); + ghashAllToS.update(ct, ctOfs, tlen); + inOfs += tlen; + outOfs += tlen; + ctOfs += tlen; + i++; + } + ilen -= count * plen; + processed += count * plen; + } + + gctrPAndC.doFinal(in, inOfs, ilen, out, outOfs); + processed += ilen; + int lastLen = len % AES_BLOCK_SIZE; if (lastLen != 0) { ghashAllToS.update(ct, ctOfs, len - lastLen); - byte[] padded = - expandToOneBlock(ct, (ctOfs + len - lastLen), lastLen); - ghashAllToS.update(padded); + ghashAllToS.update( + expandToOneBlock(ct, (ctOfs + len - lastLen), lastLen)); } else { - ghashAllToS.update(ct, ctOfs, len); + ghashAllToS.update(ct, ctOfs, ilen); } } @@ -562,15 +587,19 @@ final class GaloisCounterMode extends FeedbackCipher { System.arraycopy(in, inOfs + len - tagLenBytes, tag, 0, tagLenBytes); len -= tagLenBytes; - if (len > 0) { - ibuffer.write(in, inOfs, len); - } + // If decryption is in-place or there is buffered "ibuffer" data, copy + // the "in" byte array into the ibuffer before proceeding. + if (in == out || ibuffer.size() > 0) { + if (len > 0) { + ibuffer.write(in, inOfs, len); + } - // refresh 'in' to all buffered-up bytes - in = ibuffer.toByteArray(); - inOfs = 0; - len = in.length; - ibuffer.reset(); + // refresh 'in' to all buffered-up bytes + in = ibuffer.toByteArray(); + inOfs = 0; + len = in.length; + ibuffer.reset(); + } if (len > 0) { doLastBlock(in, inOfs, len, out, outOfs, false); From e21cb12d358c22350cb18f0c656dd375f12665a9 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Fri, 8 Feb 2019 08:49:32 +0100 Subject: [PATCH 038/101] 8212828: (process) Change the Process launch mechanism default on Linux to be posix_spawn Reviewed-by: rriggs, martin --- .../unix/classes/java/lang/ProcessImpl.java | 25 +-- .../unix/native/libjava/ProcessImpl_md.c | 169 +++++++++++++----- 2 files changed, 128 insertions(+), 66 deletions(-) diff --git a/src/java.base/unix/classes/java/lang/ProcessImpl.java b/src/java.base/unix/classes/java/lang/ProcessImpl.java index 9e8decf33c4..65188619c1d 100644 --- a/src/java.base/unix/classes/java/lang/ProcessImpl.java +++ b/src/java.base/unix/classes/java/lang/ProcessImpl.java @@ -89,7 +89,7 @@ final class ProcessImpl extends Process { private static enum Platform { - LINUX(LaunchMechanism.VFORK, LaunchMechanism.POSIX_SPAWN, LaunchMechanism.FORK), + LINUX(LaunchMechanism.POSIX_SPAWN, LaunchMechanism.VFORK, LaunchMechanism.FORK), BSD(LaunchMechanism.POSIX_SPAWN, LaunchMechanism.FORK), @@ -106,27 +106,6 @@ final class ProcessImpl extends Process { EnumSet.copyOf(Arrays.asList(launchMechanisms)); } - @SuppressWarnings("fallthrough") - private String helperPath(String javahome, String osArch) { - switch (this) { - case SOLARIS: - // fall through... - case LINUX: - case AIX: - case BSD: - return javahome + "/lib/jspawnhelper"; - - default: - throw new AssertionError("Unsupported platform: " + this); - } - } - - String helperPath() { - Properties props = GetPropertyAction.privilegedGetProperties(); - return helperPath(StaticProperty.javaHome(), - props.getProperty("os.arch")); - } - LaunchMechanism launchMechanism() { return AccessController.doPrivileged( (PrivilegedAction) () -> { @@ -169,7 +148,7 @@ final class ProcessImpl extends Process { private static final Platform platform = Platform.get(); private static final LaunchMechanism launchMechanism = platform.launchMechanism(); - private static final byte[] helperpath = toCString(platform.helperPath()); + private static final byte[] helperpath = toCString(StaticProperty.javaHome() + "/lib/jspawnhelper"); private static byte[] toCString(String s) { if (s == null) diff --git a/src/java.base/unix/native/libjava/ProcessImpl_md.c b/src/java.base/unix/native/libjava/ProcessImpl_md.c index c9812e2e221..9211289f418 100644 --- a/src/java.base/unix/native/libjava/ProcessImpl_md.c +++ b/src/java.base/unix/native/libjava/ProcessImpl_md.c @@ -49,56 +49,139 @@ #include "childproc.h" /* - * There are 4 possible strategies we might use to "fork": * - * - fork(2). Very portable and reliable but subject to - * failure due to overcommit (see the documentation on - * /proc/sys/vm/overcommit_memory in Linux proc(5)). - * This is the ancient problem of spurious failure whenever a large - * process starts a small subprocess. + * When starting a child on Unix, we need to do three things: + * - fork off + * - in the child process, do some pre-exec work: duping/closing file + * descriptors to set up stdio-redirection, setting environment variables, + * changing paths... + * - then exec(2) the target binary * - * - vfork(). Using this is scary because all relevant man pages - * contain dire warnings, e.g. Linux vfork(2). But at least it's - * documented in the glibc docs and is standardized by XPG4. - * http://www.opengroup.org/onlinepubs/000095399/functions/vfork.html - * On Linux, one might think that vfork() would be implemented using - * the clone system call with flag CLONE_VFORK, but in fact vfork is - * a separate system call (which is a good sign, suggesting that - * vfork will continue to be supported at least on Linux). - * Another good sign is that glibc implements posix_spawn using - * vfork whenever possible. Note that we cannot use posix_spawn - * ourselves because there's no reliable way to close all inherited - * file descriptors. + * There are three ways to fork off: * - * - clone() with flags CLONE_VM but not CLONE_THREAD. clone() is - * Linux-specific, but this ought to work - at least the glibc - * sources contain code to handle different combinations of CLONE_VM - * and CLONE_THREAD. However, when this was implemented, it - * appeared to fail on 32-bit i386 (but not 64-bit x86_64) Linux with - * the simple program - * Runtime.getRuntime().exec("/bin/true").waitFor(); - * with: - * # Internal Error (os_linux_x86.cpp:683), pid=19940, tid=2934639536 - * # Error: pthread_getattr_np failed with errno = 3 (ESRCH) - * We believe this is a glibc bug, reported here: - * http://sources.redhat.com/bugzilla/show_bug.cgi?id=10311 - * but the glibc maintainers closed it as WONTFIX. + * A) fork(2). Portable and safe (no side effects) but may fail with ENOMEM on + * all Unices when invoked from a VM with a high memory footprint. On Unices + * with strict no-overcommit policy this problem is most visible. * - * - posix_spawn(). While posix_spawn() is a fairly elaborate and - * complicated system call, it can't quite do everything that the old - * fork()/exec() combination can do, so the only feasible way to do - * this, is to use posix_spawn to launch a new helper executable - * "jprochelper", which in turn execs the target (after cleaning - * up file-descriptors etc.) The end result is the same as before, - * a child process linked to the parent in the same way, but it - * avoids the problem of duplicating the parent (VM) process - * address space temporarily, before launching the target command. + * This is because forking the VM will first create a child process with + * theoretically the same memory footprint as the parent - even if you plan + * to follow up with exec'ing a tiny binary. In reality techniques like + * copy-on-write etc mitigate the problem somewhat but we still run the risk + * of hitting system limits. * - * Based on the above analysis, we are currently using vfork() on - * Linux and posix_spawn() on other Unix systems. + * For a Linux centric description of this problem, see the documentation on + * /proc/sys/vm/overcommit_memory in Linux proc(5). + * + * B) vfork(2): Portable and fast but very unsafe. It bypasses the memory + * problems related to fork(2) by starting the child in the memory image of + * the parent. Things that can go wrong include: + * - Programming errors in the child process before the exec(2) call may + * trash memory in the parent process, most commonly the stack of the + * thread invoking vfork. + * - Signals received by the child before the exec(2) call may be at best + * misdirected to the parent, at worst immediately kill child and parent. + * + * This is mitigated by very strict rules about what one is allowed to do in + * the child process between vfork(2) and exec(2), which is basically nothing. + * However, we always broke this rule by doing the pre-exec work between + * vfork(2) and exec(2). + * + * Also note that vfork(2) has been deprecated by the OpenGroup, presumably + * because of its many dangers. + * + * C) clone(2): This is a Linux specific call which gives the caller fine + * grained control about how exactly the process fork is executed. It is + * powerful, but Linux-specific. + * + * Aside from these three possibilities there is a forth option: posix_spawn(3). + * Where fork/vfork/clone all fork off the process and leave pre-exec work and + * calling exec(2) to the user, posix_spawn(3) offers the user fork+exec-like + * functionality in one package, similar to CreateProcess() on Windows. + * + * It is not a system call in itself, but usually a wrapper implemented within + * the libc in terms of one of (fork|vfork|clone)+exec - so whether or not it + * has advantages over calling the naked (fork|vfork|clone) functions depends + * on how posix_spawn(3) is implemented. + * + * Note that when using posix_spawn(3), we exec twice: first a tiny binary called + * the jspawnhelper, then in the jspawnhelper we do the pre-exec work and exec a + * second time, this time the target binary (similar to the "exec-twice-technique" + * described in http://mail.openjdk.java.net/pipermail/core-libs-dev/2018-September/055333.html). + * + * This is a JDK-specific implementation detail which just happens to be + * implemented for jdk.lang.Process.launchMechanism=POSIX_SPAWN. + * + * --- Linux-specific --- + * + * How does glibc implement posix_spawn? + * (see: sysdeps/posix/spawni.c for glibc < 2.24, + * sysdeps/unix/sysv/linux/spawni.c for glibc >= 2.24): + * + * 1) Before glibc 2.4 (released 2006), posix_spawn(3) used just fork(2)/exec(2). + * This would be bad for the JDK since we would risk the known memory issues with + * fork(2). But since this only affects glibc variants which have long been + * phased out by modern distributions, this is irrelevant. + * + * 2) Between glibc 2.4 and glibc 2.23, posix_spawn uses either fork(2) or + * vfork(2) depending on how exactly the user called posix_spawn(3): + * + * + * The child process is created using vfork(2) instead of fork(2) when + * either of the following is true: + * + * * the spawn-flags element of the attributes object pointed to by + * attrp contains the GNU-specific flag POSIX_SPAWN_USEVFORK; or + * + * * file_actions is NULL and the spawn-flags element of the attributes + * object pointed to by attrp does not contain + * POSIX_SPAWN_SETSIGMASK, POSIX_SPAWN_SETSIGDEF, + * POSIX_SPAWN_SETSCHEDPARAM, POSIX_SPAWN_SETSCHEDULER, + * POSIX_SPAWN_SETPGROUP, or POSIX_SPAWN_RESETIDS. + * + * + * Due to the way the JDK calls posix_spawn(3), it would therefore call vfork(2). + * So we would avoid the fork(2) memory problems. However, there still remains the + * risk associated with vfork(2). But it is smaller than were we to call vfork(2) + * directly since we use the jspawnhelper, moving all pre-exec work off to after + * the first exec, thereby reducing the vulnerable time window. + * + * 3) Since glibc >= 2.24, glibc uses clone+exec: + * + * new_pid = CLONE (__spawni_child, STACK (stack, stack_size), stack_size, + * CLONE_VM | CLONE_VFORK | SIGCHLD, &args); + * + * This is even better than (2): + * + * CLONE_VM means we run in the parent's memory image, as with (2) + * CLONE_VFORK means parent waits until we exec, as with (2) + * + * However, error possibilities are further reduced since: + * - posix_spawn(3) passes a separate stack for the child to run on, eliminating + * the danger of trashing the forking thread's stack in the parent process. + * - posix_spawn(3) takes care to temporarily block all incoming signals to the + * child process until the first exec(2) has been called, + * + * TL;DR + * Calling posix_spawn(3) for glibc + * (2) < 2.24 is not perfect but still better than using plain vfork(2), since + * the chance of an error happening is greatly reduced + * (3) >= 2.24 is the best option - portable, fast and as safe as possible. + * + * --- + * + * How does muslc implement posix_spawn? + * + * They always did use the clone (.. CLONE_VM | CLONE_VFORK ...) + * technique. So we are safe to use posix_spawn() here regardless of muslc + * version. + * + * + * + * + * Based on the above analysis, we are currently defaulting to posix_spawn() + * on all Unices including Linux. */ - static void setSIGCHLDHandler(JNIEnv *env) { From 0fdcd10b9c19e7aa5f8f4b072806c1be116415d1 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 6 Feb 2019 16:02:27 +0100 Subject: [PATCH 039/101] 8218562: handle HOTSPOT_BUILD_COMPILER for clang/xlclang and cleanup HOTSPOT_BUILD_COMPILER settings Reviewed-by: dholmes, ihse, mdoerr --- src/hotspot/share/runtime/vm_version.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp index e5f38cbfe99..275fd6d5b0b 100644 --- a/src/hotspot/share/runtime/vm_version.cpp +++ b/src/hotspot/share/runtime/vm_version.cpp @@ -230,13 +230,7 @@ const char* Abstract_VM_Version::internal_vm_info_string() { #define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER) #endif #elif defined(__SUNPRO_CC) - #if __SUNPRO_CC == 0x420 - #define HOTSPOT_BUILD_COMPILER "Workshop 4.2" - #elif __SUNPRO_CC == 0x500 - #define HOTSPOT_BUILD_COMPILER "Workshop 5.0 compat=" XSTR(__SUNPRO_CC_COMPAT) - #elif __SUNPRO_CC == 0x520 - #define HOTSPOT_BUILD_COMPILER "Workshop 5.2 compat=" XSTR(__SUNPRO_CC_COMPAT) - #elif __SUNPRO_CC == 0x580 + #if __SUNPRO_CC == 0x580 #define HOTSPOT_BUILD_COMPILER "Workshop 5.8" #elif __SUNPRO_CC == 0x590 #define HOTSPOT_BUILD_COMPILER "Workshop 5.9" @@ -249,6 +243,8 @@ const char* Abstract_VM_Version::internal_vm_info_string() { #else #define HOTSPOT_BUILD_COMPILER "unknown Workshop:" XSTR(__SUNPRO_CC) #endif + #elif defined(__clang_version__) + #define HOTSPOT_BUILD_COMPILER "clang " __VERSION__ #elif defined(__GNUC__) #define HOTSPOT_BUILD_COMPILER "gcc " __VERSION__ #elif defined(__IBMCPP__) From efc62ac6ecec6f9f9679d32e4c6ac8bc9820ccdb Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Tue, 12 Feb 2019 09:00:04 +0100 Subject: [PATCH 040/101] 8217383: Obsolete UseImplicitStableValues Reviewed-by: shade, rkennke, vlivanov --- src/hotspot/share/opto/c2_globals.hpp | 3 --- src/hotspot/share/opto/graphKit.cpp | 13 +------------ src/hotspot/share/opto/graphKit.hpp | 3 --- src/hotspot/share/runtime/arguments.cpp | 1 + 4 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/hotspot/share/opto/c2_globals.hpp b/src/hotspot/share/opto/c2_globals.hpp index 5614158bbf0..957c07647bc 100644 --- a/src/hotspot/share/opto/c2_globals.hpp +++ b/src/hotspot/share/opto/c2_globals.hpp @@ -509,9 +509,6 @@ product(bool, EliminateAutoBox, true, \ "Control optimizations for autobox elimination") \ \ - diagnostic(bool, UseImplicitStableValues, true, \ - "Mark well-known stable fields as such (e.g. String.value)") \ - \ product(intx, AutoBoxCacheMax, 128, \ "Sets max value cached by the java.lang.Integer autobox cache") \ range(0, max_jint) \ diff --git a/src/hotspot/share/opto/graphKit.cpp b/src/hotspot/share/opto/graphKit.cpp index 241d0ec551a..e5ebdb7600a 100644 --- a/src/hotspot/share/opto/graphKit.cpp +++ b/src/hotspot/share/opto/graphKit.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -3886,10 +3886,6 @@ Node* GraphKit::load_String_value(Node* str, bool set_ctrl) { Node* p = basic_plus_adr(str, str, value_offset); Node* load = access_load_at(str, p, value_field_type, value_type, T_OBJECT, IN_HEAP | (set_ctrl ? C2_CONTROL_DEPENDENT_LOAD : 0) | MO_UNORDERED); - // String.value field is known to be @Stable. - if (UseImplicitStableValues) { - load = cast_array_to_stable(load, value_type); - } return load; } @@ -3901,7 +3897,6 @@ Node* GraphKit::load_String_coder(Node* str, bool set_ctrl) { const TypeInstPtr* string_type = TypeInstPtr::make(TypePtr::NotNull, C->env()->String_klass(), false, NULL, 0); const TypePtr* coder_field_type = string_type->add_offset(coder_offset); - int coder_field_idx = C->get_alias_index(coder_field_type); Node* p = basic_plus_adr(str, str, coder_offset); Node* load = access_load_at(str, p, coder_field_type, TypeInt::BYTE, T_BYTE, @@ -4039,9 +4034,3 @@ Node* GraphKit::make_constant_from_field(ciField* field, Node* obj) { } return NULL; } - -Node* GraphKit::cast_array_to_stable(Node* ary, const TypeAryPtr* ary_type) { - // Reify the property as a CastPP node in Ideal graph to comply with monotonicity - // assumption of CCP analysis. - return _gvn.transform(new CastPPNode(ary, ary_type->cast_to_stable(true))); -} diff --git a/src/hotspot/share/opto/graphKit.hpp b/src/hotspot/share/opto/graphKit.hpp index 678c627e609..e9204295d41 100644 --- a/src/hotspot/share/opto/graphKit.hpp +++ b/src/hotspot/share/opto/graphKit.hpp @@ -884,9 +884,6 @@ class GraphKit : public Phase { void add_predicate_impl(Deoptimization::DeoptReason reason, int nargs); Node* make_constant_from_field(ciField* field, Node* obj); - - // Produce new array node of stable type - Node* cast_array_to_stable(Node* ary, const TypeAryPtr* ary_type); }; // Helper class to support building of control flow branches. Upon diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 28ddb53a066..ea3c5efc746 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -541,6 +541,7 @@ static SpecialFlag const special_jvm_flags[] = { { "SharedReadOnlySize", JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() }, { "SharedMiscDataSize", JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() }, { "SharedMiscCodeSize", JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() }, + { "UseImplicitStableValues", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, #ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS { "dep > obs", JDK_Version::jdk(9), JDK_Version::jdk(8), JDK_Version::undefined() }, From 1388a70bac51da9ec1880bbd57ef6a1b84b4a727 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Tue, 12 Feb 2019 09:58:27 +0100 Subject: [PATCH 041/101] 8218680: G1 crashes during calculation of old collection set candidates Parameters were passed in the wrong order to some helper class. Reviewed-by: shade, kbarrett, lkorinth --- src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp b/src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp index 06da3a4c443..78997ae8579 100644 --- a/src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp +++ b/src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp @@ -87,7 +87,7 @@ class G1BuildCandidateRegionsTask : public AbstractGangTask { uint volatile _cur_claim_idx; // Calculates the maximum array size that will be used. - static uint required_array_size(uint num_regions, uint num_workers, uint chunk_size) { + static uint required_array_size(uint num_regions, uint chunk_size, uint num_workers) { uint const max_waste = num_workers * chunk_size; // The array should be aligned with respect to chunk_size. uint const aligned_num_regions = ((num_regions + chunk_size - 1) / chunk_size) * chunk_size; @@ -96,8 +96,8 @@ class G1BuildCandidateRegionsTask : public AbstractGangTask { } public: - G1BuildCandidateArray(uint max_num_regions, uint num_workers, uint chunk_size) : - _max_size(required_array_size(max_num_regions, num_workers, chunk_size)), + G1BuildCandidateArray(uint max_num_regions, uint chunk_size, uint num_workers) : + _max_size(required_array_size(max_num_regions, chunk_size, num_workers)), _chunk_size(chunk_size), _data(NEW_C_HEAP_ARRAY(HeapRegion*, _max_size, mtGC)), _cur_claim_idx(0) { From 6773177000c9e5e3c9803206e495da252e091829 Mon Sep 17 00:00:00 2001 From: Chihiro Ito Date: Tue, 12 Feb 2019 08:56:03 +0900 Subject: [PATCH 042/101] 8214236: sun.gc.collector.2.name should be changed Reviewed-by: pliden, tschatzl --- .../share/gc/cms/concurrentMarkSweepGeneration.cpp | 4 ++-- src/hotspot/share/gc/cms/parNewGeneration.cpp | 2 +- src/hotspot/share/gc/g1/g1MonitoringSupport.cpp | 8 ++++---- src/hotspot/share/gc/parallel/psMarkSweep.cpp | 2 +- src/hotspot/share/gc/parallel/psParallelCompact.cpp | 2 +- src/hotspot/share/gc/parallel/psScavenge.cpp | 2 +- src/hotspot/share/gc/serial/defNewGeneration.hpp | 2 +- src/hotspot/share/gc/serial/tenuredGeneration.cpp | 4 ++-- src/hotspot/share/gc/z/zServiceability.cpp | 6 +++--- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp index 6bc8207f76f..a4ff3f4c479 100644 --- a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp +++ b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp @@ -636,8 +636,8 @@ CMSCollector::CMSCollector(ConcurrentMarkSweepGeneration* cmsGen, } NOT_PRODUCT(_overflow_counter = CMSMarkStackOverflowInterval;) - _gc_counters = new CollectorCounters("CMS", 1); - _cgc_counters = new CollectorCounters("CMS stop-the-world phases", 2); + _gc_counters = new CollectorCounters("CMS full collection pauses", 1); + _cgc_counters = new CollectorCounters("CMS concurrent cycle pauses", 2); _completed_initialization = true; _inter_sweep_timer.start(); // start of time } diff --git a/src/hotspot/share/gc/cms/parNewGeneration.cpp b/src/hotspot/share/gc/cms/parNewGeneration.cpp index 24f756c05b6..53213126abe 100644 --- a/src/hotspot/share/gc/cms/parNewGeneration.cpp +++ b/src/hotspot/share/gc/cms/parNewGeneration.cpp @@ -624,7 +624,7 @@ void ParNewGenTask::work(uint worker_id) { } ParNewGeneration::ParNewGeneration(ReservedSpace rs, size_t initial_byte_size) - : DefNewGeneration(rs, initial_byte_size, "PCopy"), + : DefNewGeneration(rs, initial_byte_size, "CMS young collection pauses"), _plab_stats("Young", YoungPLABSize, PLABWeight), _overflow_list(NULL), _is_alive_closure(this) diff --git a/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp b/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp index 89815f04c19..bab872971d3 100644 --- a/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp +++ b/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, 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 @@ -119,15 +119,15 @@ G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h) : // name "collector.0". In a generational collector this would be the // young generation collection. _incremental_collection_counters = - new CollectorCounters("G1 incremental collections", 0); + new CollectorCounters("G1 young collection pauses", 0); // name "collector.1". In a generational collector this would be the // old generation collection. _full_collection_counters = - new CollectorCounters("G1 stop-the-world full collections", 1); + new CollectorCounters("G1 full collection pauses", 1); // name "collector.2". In a generational collector this would be the // STW phases in concurrent collection. _conc_collection_counters = - new CollectorCounters("G1 stop-the-world phases", 2); + new CollectorCounters("G1 concurrent cycle pauses", 2); // "Generation" and "Space" counters. // diff --git a/src/hotspot/share/gc/parallel/psMarkSweep.cpp b/src/hotspot/share/gc/parallel/psMarkSweep.cpp index 99f26e8917e..8673a4504dc 100644 --- a/src/hotspot/share/gc/parallel/psMarkSweep.cpp +++ b/src/hotspot/share/gc/parallel/psMarkSweep.cpp @@ -72,7 +72,7 @@ SpanSubjectToDiscoveryClosure PSMarkSweep::_span_based_discoverer; void PSMarkSweep::initialize() { _span_based_discoverer.set_span(ParallelScavengeHeap::heap()->reserved_region()); set_ref_processor(new ReferenceProcessor(&_span_based_discoverer)); // a vanilla ref proc - _counters = new CollectorCounters("PSMarkSweep", 1); + _counters = new CollectorCounters("Serial full collection pauses", 1); MarkSweep::initialize(); } diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.cpp b/src/hotspot/share/gc/parallel/psParallelCompact.cpp index 970192788cb..d56ce6b6023 100644 --- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp +++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp @@ -883,7 +883,7 @@ void PSParallelCompact::post_initialize() { new PCReferenceProcessor(&_span_based_discoverer, &_is_alive_closure); // non-header is alive closure - _counters = new CollectorCounters("PSParallelCompact", 1); + _counters = new CollectorCounters("Parallel full collection pauses", 1); // Initialize static fields in ParCompactionManager. ParCompactionManager::initialize(mark_bitmap()); diff --git a/src/hotspot/share/gc/parallel/psScavenge.cpp b/src/hotspot/share/gc/parallel/psScavenge.cpp index 54714cb33da..eb1cb2bbf78 100644 --- a/src/hotspot/share/gc/parallel/psScavenge.cpp +++ b/src/hotspot/share/gc/parallel/psScavenge.cpp @@ -754,5 +754,5 @@ void PSScavenge::initialize() { // Cache the cardtable _card_table = heap->card_table(); - _counters = new CollectorCounters("PSScavenge", 0); + _counters = new CollectorCounters("Parallel young collection pauses", 0); } diff --git a/src/hotspot/share/gc/serial/defNewGeneration.hpp b/src/hotspot/share/gc/serial/defNewGeneration.hpp index 6d88c145e75..34bddc1eec4 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.hpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.hpp @@ -192,7 +192,7 @@ protected: public: DefNewGeneration(ReservedSpace rs, size_t initial_byte_size, - const char* policy="Copy"); + const char* policy="Serial young collection pauses"); virtual void ref_processor_init(); diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.cpp b/src/hotspot/share/gc/serial/tenuredGeneration.cpp index e59a1700580..bc8d5db98d8 100644 --- a/src/hotspot/share/gc/serial/tenuredGeneration.cpp +++ b/src/hotspot/share/gc/serial/tenuredGeneration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -65,7 +65,7 @@ TenuredGeneration::TenuredGeneration(ReservedSpace rs, _gen_counters = new GenerationCounters(gen_name, 1, 1, gcp->min_old_size(), gcp->max_old_size(), &_virtual_space); - _gc_counters = new CollectorCounters("MSC", 1); + _gc_counters = new CollectorCounters("Serial full collection pauses", 1); _space_counters = new CSpaceCounters(gen_name, 0, _virtual_space.reserved_size(), diff --git a/src/hotspot/share/gc/z/zServiceability.cpp b/src/hotspot/share/gc/z/zServiceability.cpp index abaea370968..485bfe9c384 100644 --- a/src/hotspot/share/gc/z/zServiceability.cpp +++ b/src/hotspot/share/gc/z/zServiceability.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, 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 @@ -72,8 +72,8 @@ ZServiceabilityCounters::ZServiceabilityCounters(size_t min_capacity, size_t max max_capacity /* max_capacity */, min_capacity /* init_capacity */), // gc.collector.2 - _collector_counters("stop-the-world" /* name */, - 2 /* ordinal */) {} + _collector_counters("Z concurrent cycle pauses" /* name */, + 2 /* ordinal */) {} CollectorCounters* ZServiceabilityCounters::collector_counters() { return &_collector_counters; From 7da54379948fc7fb0e60ce51c40eae4323671541 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Tue, 12 Feb 2019 09:35:51 +0100 Subject: [PATCH 043/101] 8216608: Obsolete stale compiler flags Reviewed-by: shade, thartmann --- src/hotspot/share/runtime/arguments.cpp | 9 ++++++++ src/hotspot/share/runtime/globals.hpp | 30 ------------------------- 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index ea3c5efc746..c1092e1a1a8 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -541,6 +541,15 @@ static SpecialFlag const special_jvm_flags[] = { { "SharedReadOnlySize", JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() }, { "SharedMiscDataSize", JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() }, { "SharedMiscCodeSize", JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() }, + { "ProfilerPrintByteCodeStatistics", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, + { "ProfilerRecordPC", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, + { "ProfileVM", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, + { "ProfileIntervals", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, + { "ProfileIntervalsTicks", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, + { "ProfilerNumberOfInterpretedMethods", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, + { "ProfilerNumberOfCompiledMethods", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, + { "ProfilerNumberOfStubMethods", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, + { "ProfilerNumberOfRuntimeStubNodes", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, { "UseImplicitStableValues", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, #ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index 701098e90fe..2a6e0e134f7 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -749,19 +749,6 @@ define_pd_global(uint64_t,MaxRAM, 1ULL*G); product(bool, OmitStackTraceInFastThrow, true, \ "Omit backtraces for some 'hot' exceptions in optimized code") \ \ - product(bool, ProfilerPrintByteCodeStatistics, false, \ - "Print bytecode statistics when dumping profiler output") \ - \ - product(bool, ProfilerRecordPC, false, \ - "Collect ticks for each 16 byte interval of compiled code") \ - \ - product(bool, ProfileVM, false, \ - "Profile ticks that fall within VM (either in the VM Thread " \ - "or VM code called through stubs)") \ - \ - product(bool, ProfileIntervals, false, \ - "Print profiles for each interval (see ProfileIntervalsTicks)") \ - \ notproduct(bool, ProfilerCheckIntervals, false, \ "Collect and print information on spacing of profiler ticks") \ \ @@ -1650,23 +1637,6 @@ define_pd_global(uint64_t,MaxRAM, 1ULL*G); develop(intx, MethodHistogramCutoff, 100, \ "The cutoff value for method invocation histogram (+CountCalls)") \ \ - diagnostic(intx, ProfilerNumberOfInterpretedMethods, 25, \ - "Number of interpreted methods to show in profile") \ - \ - diagnostic(intx, ProfilerNumberOfCompiledMethods, 25, \ - "Number of compiled methods to show in profile") \ - \ - diagnostic(intx, ProfilerNumberOfStubMethods, 25, \ - "Number of stub methods to show in profile") \ - \ - diagnostic(intx, ProfilerNumberOfRuntimeStubNodes, 25, \ - "Number of runtime stub nodes to show in profile") \ - \ - product(intx, ProfileIntervalsTicks, 100, \ - "Number of ticks between printing of interval profile " \ - "(+ProfileIntervals)") \ - range(0, max_intx) \ - \ develop(intx, DontYieldALotInterval, 10, \ "Interval between which yields will be dropped (milliseconds)") \ \ From 93bdf79f1baadb518c1d6e10f9e4fe4205837bef Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Tue, 12 Feb 2019 14:23:49 +0100 Subject: [PATCH 044/101] 8218675: Reduce verification overhead in ClassFileParser Reviewed-by: dholmes, hseigel --- .../share/classfile/classFileParser.cpp | 101 +++++++----------- 1 file changed, 40 insertions(+), 61 deletions(-) diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index 49710f73e60..c6ad0bcaca0 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -4991,30 +4991,30 @@ void ClassFileParser::verify_legal_utf8(const unsigned char* buffer, bool ClassFileParser::verify_unqualified_name(const char* name, unsigned int length, int type) { - for (const char* p = name; p != name + length;) { - jchar ch = *p; - if (ch < 128) { - if (ch == '.' || ch == ';' || ch == '[' ) { - return false; // do not permit '.', ';', or '[' - } - if (ch == '/') { + for (const char* p = name; p != name + length; p++) { + switch(*p) { + case '.': + case ';': + case '[': + // do not permit '.', ';', or '[' + return false; + case '/': // check for '//' or leading or trailing '/' which are not legal // unqualified name must not be empty if (type == ClassFileParser::LegalClass) { if (p == name || p+1 >= name+length || *(p+1) == '/') { - return false; + return false; } } else { return false; // do not permit '/' unless it's class name } - } - if (type == ClassFileParser::LegalMethod && (ch == '<' || ch == '>')) { - return false; // do not permit '<' or '>' in method names - } - p++; - } else { - char* tmp_p = UTF8::next(p, &ch); - p = tmp_p; + break; + case '<': + case '>': + // do not permit '<' or '>' in method names + if (type == ClassFileParser::LegalMethod) { + return false; + } } } return true; @@ -5026,7 +5026,7 @@ bool ClassFileParser::verify_unqualified_name(const char* name, // Return NULL if no fieldname at all was found, or in the case of slash_ok // being true, we saw consecutive slashes (meaning we were looking for a // qualified path but found something that was badly-formed). -static const char* skip_over_field_name(const char* name, +static const char* skip_over_field_name(const char* const name, bool slash_ok, unsigned int length) { const char* p; @@ -5062,29 +5062,12 @@ static const char* skip_over_field_name(const char* name, // Check if ch is Java identifier start or is Java identifier part // 4672820: call java.lang.Character methods directly without generating separate tables. EXCEPTION_MARK; - // return value JavaValue result(T_BOOLEAN); - // Set up the arguments to isJavaIdentifierStart and isJavaIdentifierPart + // Set up the arguments to isJavaIdentifierStart or isJavaIdentifierPart JavaCallArguments args; args.push_int(unicode_ch); - // public static boolean isJavaIdentifierStart(char ch); - JavaCalls::call_static(&result, - SystemDictionary::Character_klass(), - vmSymbols::isJavaIdentifierStart_name(), - vmSymbols::int_bool_signature(), - &args, - THREAD); - - if (HAS_PENDING_EXCEPTION) { - CLEAR_PENDING_EXCEPTION; - return 0; - } - if (result.get_jboolean()) { - continue; - } - if (not_first_ch) { // public static boolean isJavaIdentifierPart(char ch); JavaCalls::call_static(&result, @@ -5093,15 +5076,21 @@ static const char* skip_over_field_name(const char* name, vmSymbols::int_bool_signature(), &args, THREAD); - - if (HAS_PENDING_EXCEPTION) { - CLEAR_PENDING_EXCEPTION; - return 0; - } - - if (result.get_jboolean()) { - continue; - } + } else { + // public static boolean isJavaIdentifierStart(char ch); + JavaCalls::call_static(&result, + SystemDictionary::Character_klass(), + vmSymbols::isJavaIdentifierStart_name(), + vmSymbols::int_bool_signature(), + &args, + THREAD); + } + if (HAS_PENDING_EXCEPTION) { + CLEAR_PENDING_EXCEPTION; + return NULL; + } + if(result.get_jboolean()) { + continue; } } return (not_first_ch) ? old_p : NULL; @@ -5142,18 +5131,12 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature, } else { // Skip leading 'L' and ignore first appearance of ';' - length--; signature++; char* c = strchr((char*) signature, ';'); // Format check signature if (c != NULL) { - ResourceMark rm(THREAD); int newlen = c - (char*) signature; - char* sig = NEW_RESOURCE_ARRAY(char, newlen + 1); - strncpy(sig, signature, newlen); - sig[newlen] = '\0'; - - bool legal = verify_unqualified_name(sig, newlen, LegalClass); + bool legal = verify_unqualified_name(signature, newlen, LegalClass); if (!legal) { classfile_parse_error("Class name contains illegal character " "in descriptor in class file %s", @@ -5187,8 +5170,8 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature, void ClassFileParser::verify_legal_class_name(const Symbol* name, TRAPS) const { if (!_need_verify || _relax_verify) { return; } - char buf[fixed_buffer_size]; - char* bytes = name->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size); + assert(name->refcount() > 0, "symbol must be kept alive"); + char* bytes = (char*)name->bytes(); unsigned int length = name->utf8_length(); bool legal = false; @@ -5227,8 +5210,7 @@ void ClassFileParser::verify_legal_class_name(const Symbol* name, TRAPS) const { void ClassFileParser::verify_legal_field_name(const Symbol* name, TRAPS) const { if (!_need_verify || _relax_verify) { return; } - char buf[fixed_buffer_size]; - char* bytes = name->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size); + char* bytes = (char*)name->bytes(); unsigned int length = name->utf8_length(); bool legal = false; @@ -5262,8 +5244,7 @@ void ClassFileParser::verify_legal_method_name(const Symbol* name, TRAPS) const if (!_need_verify || _relax_verify) { return; } assert(name != NULL, "method name is null"); - char buf[fixed_buffer_size]; - char* bytes = name->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size); + char* bytes = (char*)name->bytes(); unsigned int length = name->utf8_length(); bool legal = false; @@ -5302,8 +5283,7 @@ void ClassFileParser::verify_legal_field_signature(const Symbol* name, TRAPS) const { if (!_need_verify) { return; } - char buf[fixed_buffer_size]; - const char* const bytes = signature->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size); + const char* const bytes = (const char* const)signature->bytes(); const unsigned int length = signature->utf8_length(); const char* const p = skip_over_field_signature(bytes, false, length, CHECK); @@ -5332,8 +5312,7 @@ int ClassFileParser::verify_legal_method_signature(const Symbol* name, } unsigned int args_size = 0; - char buf[fixed_buffer_size]; - const char* p = signature->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size); + const char* p = (const char*)signature->bytes(); unsigned int length = signature->utf8_length(); const char* nextp; From 9efdb33a59f7db7b4b39e113265a3b3ba513c5d3 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Tue, 12 Feb 2019 15:31:40 +0100 Subject: [PATCH 045/101] 8218413: make reconfigure ignores configure-time AUTOCONF environment variable Reviewed-by: erikj, martin --- make/Init.gmk | 4 ++-- make/autoconf/basics.m4 | 4 +++- make/autoconf/spec.gmk.in | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/make/Init.gmk b/make/Init.gmk index 4d9e26ff8b4..b8b78fbd5e0 100644 --- a/make/Init.gmk +++ b/make/Init.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, 2019, 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 @@ -277,7 +277,7 @@ else # HAS_SPEC=true else $(ECHO) "Re-running configure using default settings" endif - ( cd $(OUTPUTDIR) && PATH="$(ORIGINAL_PATH)" \ + ( cd $(OUTPUTDIR) && PATH="$(ORIGINAL_PATH)" AUTOCONF="$(AUTOCONF)" \ CUSTOM_ROOT="$(CUSTOM_ROOT)" \ CUSTOM_CONFIG_DIR="$(CUSTOM_CONFIG_DIR)" \ $(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) ) diff --git a/make/autoconf/basics.m4 b/make/autoconf/basics.m4 index b8cbe91342d..f35de8faf3f 100644 --- a/make/autoconf/basics.m4 +++ b/make/autoconf/basics.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2019, 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 @@ -406,6 +406,8 @@ AC_DEFUN_ONCE([BASIC_INIT], [ # Save the original command line. This is passed to us by the wrapper configure script. AC_SUBST(CONFIGURE_COMMAND_LINE) + # AUTOCONF might be set in the environment by the user. Preserve for "make reconfigure". + AC_SUBST(AUTOCONF) # Save the path variable before it gets changed ORIGINAL_PATH="$PATH" AC_SUBST(ORIGINAL_PATH) diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index 1571197503b..1ac80135b50 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -36,6 +36,9 @@ CONFIGURE_COMMAND_LINE:=@CONFIGURE_COMMAND_LINE@ # A self-referential reference to this file. SPEC:=@SPEC@ +# Path to autoconf if overriden by the user, to be used by "make reconfigure" +AUTOCONF := @AUTOCONF@ + # SPACE and COMMA are defined in MakeBase.gmk, but they are also used in # some definitions here, and are needed if MakeBase.gmk is not included before # this file. From 821887202488f52f24a1b75fa8fbde62a9291d5d Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Tue, 5 Feb 2019 17:40:15 +0100 Subject: [PATCH 046/101] 8218136: minor hotspot adjustments for xlclang++ from xlc16 on AIX Reviewed-by: dholmes, goetz, ihse --- src/hotspot/os/aix/porting_aix.cpp | 12 +++- .../aix_ppc/prefetch_aix_ppc.inline.hpp | 2 +- src/hotspot/share/runtime/arguments.cpp | 4 +- src/hotspot/share/runtime/arguments.hpp | 12 ++++ .../share/utilities/globalDefinitions_xlc.hpp | 65 +++++++------------ 5 files changed, 51 insertions(+), 44 deletions(-) diff --git a/src/hotspot/os/aix/porting_aix.cpp b/src/hotspot/os/aix/porting_aix.cpp index f67606bda5e..a6430007235 100644 --- a/src/hotspot/os/aix/porting_aix.cpp +++ b/src/hotspot/os/aix/porting_aix.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013 SAP SE. All rights reserved. + * Copyright (c) 2012, 2019 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 @@ -34,7 +34,15 @@ #include "utilities/align.hpp" #include "utilities/debug.hpp" +// distinguish old xlc and xlclang++, where +// is suggested but not found in GA release (might come with a fix) +#if defined(__clang__) +#define DISABLE_DEMANGLE +// #include +#else #include +#endif + #include #include #include @@ -237,6 +245,7 @@ bool AixSymbols::get_function_name ( p_name[i] = '\0'; // If it is a C++ name, try and demangle it using the Demangle interface (see demangle.h). +#ifndef DISABLE_DEMANGLE if (demangle) { char* rest; Name* const name = Demangle(p_name, rest); @@ -249,6 +258,7 @@ bool AixSymbols::get_function_name ( delete name; } } +#endif } else { strncpy(p_name, "", namelen-1); p_name[namelen-1] = '\0'; diff --git a/src/hotspot/os_cpu/aix_ppc/prefetch_aix_ppc.inline.hpp b/src/hotspot/os_cpu/aix_ppc/prefetch_aix_ppc.inline.hpp index bcc42836bde..73799524140 100644 --- a/src/hotspot/os_cpu/aix_ppc/prefetch_aix_ppc.inline.hpp +++ b/src/hotspot/os_cpu/aix_ppc/prefetch_aix_ppc.inline.hpp @@ -43,7 +43,7 @@ inline void Prefetch::read(void *loc, intx interval) { } inline void Prefetch::write(void *loc, intx interval) { -#if !defined(USE_XLC_PREFETCH_WRITE_BUILTIN) +#if !defined(USE_XLC_BUILTINS) __asm__ __volatile__ ( " dcbtst 0, %0 \n" : diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index c1092e1a1a8..792a0a97dcd 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -3794,8 +3794,8 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) { #endif #if defined(AIX) - UNSUPPORTED_OPTION(AllocateHeapAt); - UNSUPPORTED_OPTION(AllocateOldGenAt); + UNSUPPORTED_OPTION_NULL(AllocateHeapAt); + UNSUPPORTED_OPTION_NULL(AllocateOldGenAt); #endif #ifndef PRODUCT diff --git a/src/hotspot/share/runtime/arguments.hpp b/src/hotspot/share/runtime/arguments.hpp index 4a27ca97f86..e8e10d32ea9 100644 --- a/src/hotspot/share/runtime/arguments.hpp +++ b/src/hotspot/share/runtime/arguments.hpp @@ -663,4 +663,16 @@ do { \ } \ } while(0) +// similar to UNSUPPORTED_OPTION but sets flag to NULL +#define UNSUPPORTED_OPTION_NULL(opt) \ +do { \ + if (opt) { \ + if (FLAG_IS_CMDLINE(opt)) { \ + warning("-XX flag " #opt " not supported in this VM"); \ + } \ + FLAG_SET_DEFAULT(opt, NULL); \ + } \ +} while(0) + + #endif // SHARE_RUNTIME_ARGUMENTS_HPP diff --git a/src/hotspot/share/utilities/globalDefinitions_xlc.hpp b/src/hotspot/share/utilities/globalDefinitions_xlc.hpp index 511f4c4f269..80b0ed1f110 100644 --- a/src/hotspot/share/utilities/globalDefinitions_xlc.hpp +++ b/src/hotspot/share/utilities/globalDefinitions_xlc.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2017 SAP SE. All rights reserved. + * Copyright (c) 2012, 2019 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 @@ -51,51 +51,43 @@ #include +// __IBMCPP__ is not defined any more with xlclang++ +#ifdef __IBMCPP__ +#if __IBMCPP__ < 1200 +#error "xlc < 12 not supported" +#endif +#endif + +#ifndef _AIX +#error "missing AIX-specific definition _AIX" +#endif + // Use XLC compiler builtins instead of inline assembler #define USE_XLC_BUILTINS + #ifdef USE_XLC_BUILTINS #include - #if __IBMCPP__ < 1000 - // the funtion prototype for __dcbtst(void *) is missing in XLC V8.0 - // I could compile a little test, where I provided the prototype. - // The generated code was correct there. This is the prototype: - // extern "builtin" void __dcbtst (void *); - // For now we don't make use of it when compiling with XLC V8.0 - #else - // __IBMCPP__ >= 1000 - // XLC V10 provides the prototype for __dcbtst (void *); - #define USE_XLC_PREFETCH_WRITE_BUILTIN - #endif +// XLC V10 and higher provide the prototype for __dcbtst (void *); #endif // USE_XLC_BUILTINS // NULL vs NULL_WORD: -// On Linux NULL is defined as a special type '__null'. Assigning __null to -// integer variable will cause gcc warning. Use NULL_WORD in places where a -// pointer is stored as integer value. On some platforms, sizeof(intptr_t) > -// sizeof(void*), so here we want something which is integer type, but has the -// same size as a pointer. -#ifdef __GNUC__ - #error XLC and __GNUC__? -#else - #define NULL_WORD NULL -#endif +// Some platform/tool-chain combinations can't assign NULL to an integer +// type so we define NULL_WORD to use in those contexts. For xlc they are the same. +#define NULL_WORD NULL // AIX also needs a 64 bit NULL to work as a null address pointer. // Most system includes on AIX would define it as an int 0 if not already defined with one // exception: /usr/include/dirent.h will unconditionally redefine NULL to int 0 again. // In this case you need to copy the following defines to a position after #include -// (see jmv_aix.h). -#ifdef AIX - #include - #ifdef _LP64 - #undef NULL - #define NULL 0L - #else - #ifndef NULL - #define NULL 0 - #endif +#include +#ifdef _LP64 + #undef NULL + #define NULL 0L +#else + #ifndef NULL + #define NULL 0 #endif -#endif // AIX +#endif // Compiler-specific primitive types // All defs of int (uint16_6 etc) are defined in AIX' /usr/include/stdint.h @@ -108,21 +100,14 @@ typedef uint32_t juint; typedef uint64_t julong; // checking for nanness -#ifdef AIX inline int g_isnan(float f) { return isnan(f); } inline int g_isnan(double f) { return isnan(f); } -#else -#error "missing platform-specific definition here" -#endif // Checking for finiteness - inline int g_isfinite(jfloat f) { return finite(f); } inline int g_isfinite(jdouble f) { return finite(f); } - // Wide characters - inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); } From 61882ce51f0e97a31018d103814b77a0fb65962a Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Tue, 12 Feb 2019 19:22:19 +0100 Subject: [PATCH 047/101] 8218738: Remove dead code in Symbol and friends Reviewed-by: coleenp, lfoltan, dholmes --- src/hotspot/share/oops/symbol.cpp | 13 ------------- src/hotspot/share/oops/symbol.hpp | 10 ---------- src/hotspot/share/utilities/utf8.cpp | 9 +++++---- src/hotspot/share/utilities/utf8.hpp | 2 ++ 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/hotspot/share/oops/symbol.cpp b/src/hotspot/share/oops/symbol.cpp index 94218c05475..c1ee26ac235 100644 --- a/src/hotspot/share/oops/symbol.cpp +++ b/src/hotspot/share/oops/symbol.cpp @@ -131,19 +131,6 @@ char* Symbol::as_C_string() const { return as_C_string(str, len + 1); } -char* Symbol::as_C_string_flexible_buffer(Thread* t, - char* buf, int size) const { - char* str; - int len = utf8_length(); - int buf_len = len + 1; - if (size < buf_len) { - str = NEW_RESOURCE_ARRAY(char, buf_len); - } else { - str = buf; - } - return as_C_string(str, buf_len); -} - void Symbol::print_utf8_on(outputStream* st) const { st->print("%s", as_C_string()); } diff --git a/src/hotspot/share/oops/symbol.hpp b/src/hotspot/share/oops/symbol.hpp index 87b5566b0bc..d7a8a72b536 100644 --- a/src/hotspot/share/oops/symbol.hpp +++ b/src/hotspot/share/oops/symbol.hpp @@ -104,7 +104,6 @@ class ClassLoaderData; class Symbol : public MetaspaceObj { friend class VMStructs; friend class SymbolTable; - friend class MoveSymbols; private: @@ -136,7 +135,6 @@ class Symbol : public MetaspaceObj { Symbol(const u1* name, int length, int refcount); void* operator new(size_t size, int len, TRAPS) throw(); void* operator new(size_t size, int len, Arena* arena, TRAPS) throw(); - void* operator new(size_t size, int len, ClassLoaderData* loader_data, TRAPS) throw(); void operator delete(void* p); @@ -207,9 +205,6 @@ class Symbol : public MetaspaceObj { // Tests if the symbol starts with the given prefix. int index_of_at(int i, const char* str, int len) const; - int index_of_at(int i, const char* str) const { - return index_of_at(i, str, (int) strlen(str)); - } // Three-way compare for sorting; returns -1/0/1 if receiver is than arg // note that the ordering is not alfabetical @@ -219,17 +214,12 @@ class Symbol : public MetaspaceObj { // allocated in resource area, or in the char buffer provided by caller. char* as_C_string() const; char* as_C_string(char* buf, int size) const; - // Use buf if needed buffer length is <= size. - char* as_C_string_flexible_buffer(Thread* t, char* buf, int size) const; // Returns an escaped form of a Java string. char* as_quoted_ascii() const; // Returns a null terminated utf8 string in a resource array char* as_utf8() const { return as_C_string(); } - char* as_utf8_flexible_buffer(Thread* t, char* buf, int size) const { - return as_C_string_flexible_buffer(t, buf, size); - } jchar* as_unicode(int& length) const; diff --git a/src/hotspot/share/utilities/utf8.cpp b/src/hotspot/share/utilities/utf8.cpp index 762c00c0961..4c7ba9a3a6f 100644 --- a/src/hotspot/share/utilities/utf8.cpp +++ b/src/hotspot/share/utilities/utf8.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -228,7 +228,9 @@ void UTF8::as_quoted_ascii(const char* utf8_str, int utf8_length, char* buf, int *p = '\0'; } - +#ifndef PRODUCT +// converts a quoted ascii string back to utf8 +// no longer used, but could be useful to test output of UTF8::as_quoted_ascii const char* UTF8::from_quoted_ascii(const char* quoted_ascii_str) { const char *ptr = quoted_ascii_str; char* result = NULL; @@ -302,7 +304,7 @@ const char* UTF8::from_quoted_ascii(const char* quoted_ascii_str) { } return buffer; } - +#endif // !PRODUCT // Returns NULL if 'c' it not found. This only works as long // as 'c' is an ASCII character @@ -468,7 +470,6 @@ char* UNICODE::as_utf8(const jchar* base, int length, char* buf, int buflen) { char* UNICODE::as_utf8(const jbyte* base, int length, char* buf, int buflen) { u_char* p = (u_char*)buf; - u_char* end = (u_char*)buf + buflen; for (int index = 0; index < length; index++) { jbyte c = base[index]; int sz = utf8_size(c); diff --git a/src/hotspot/share/utilities/utf8.hpp b/src/hotspot/share/utilities/utf8.hpp index 79828e6c310..fb77c036262 100644 --- a/src/hotspot/share/utilities/utf8.hpp +++ b/src/hotspot/share/utilities/utf8.hpp @@ -54,9 +54,11 @@ class UTF8 : AllStatic { // converts a utf8 string to quoted ascii static void as_quoted_ascii(const char* utf8_str, int utf8_length, char* buf, int buflen); +#ifndef PRODUCT // converts a quoted ascii string to utf8 string. returns the original // string unchanged if nothing needs to be done. static const char* from_quoted_ascii(const char* quoted_ascii_string); +#endif // decodes the current utf8 character, stores the result in value, // and returns the end of the current utf8 chararacter. From 328fae78805d9a04d6eab0d68bae5a4202a19982 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 12 Feb 2019 11:23:43 -0800 Subject: [PATCH 048/101] 8145845: [AOT] NullPointerException in compiler/whitebox/GetCodeHeapEntriesTest.java Reviewed-by: kvn, thartmann --- src/hotspot/share/prims/whitebox.cpp | 3 --- .../jtreg/compiler/whitebox/GetCodeHeapEntriesTest.java | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 3c053f99166..1f4fcfc9233 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -1544,9 +1544,6 @@ WB_ENTRY(jobjectArray, WB_GetCodeHeapEntries(JNIEnv* env, jobject o, jint blob_t blobs.append(stub); } } - if (blobs.length() == 0) { - return NULL; - } ThreadToNativeFromVM ttn(thread); jobjectArray result = NULL; jclass clazz = env->FindClass(vmSymbols::java_lang_Object()->as_C_string()); diff --git a/test/hotspot/jtreg/compiler/whitebox/GetCodeHeapEntriesTest.java b/test/hotspot/jtreg/compiler/whitebox/GetCodeHeapEntriesTest.java index 2f8e24e4ae8..383c5248bfa 100644 --- a/test/hotspot/jtreg/compiler/whitebox/GetCodeHeapEntriesTest.java +++ b/test/hotspot/jtreg/compiler/whitebox/GetCodeHeapEntriesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -77,7 +77,7 @@ public class GetCodeHeapEntriesTest { CodeBlob blob = Arrays.stream(blobs) .filter(GetCodeHeapEntriesTest::filter) .findAny() - .get(); + .orElse(null); Asserts.assertNotNull(blob); Asserts.assertEQ(blob.code_blob_type, type); Asserts.assertGTE(blob.size, SIZE); From 5d0ff15a58493f13fde686e2db23fe22b0d25e1a Mon Sep 17 00:00:00 2001 From: Gary Adams Date: Tue, 12 Feb 2019 15:19:25 -0500 Subject: [PATCH 049/101] 8218754: JDK-8068225 regression in JDIBreakpointTest Reviewed-by: cjplummer, sspitsyn --- .../vm/mlvm/share/jdi/JDIBreakpointTest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/jdi/JDIBreakpointTest.java b/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/jdi/JDIBreakpointTest.java index 8a1741afc5a..29980ac2117 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/jdi/JDIBreakpointTest.java +++ b/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/jdi/JDIBreakpointTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, 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 @@ -45,6 +45,7 @@ import com.sun.jdi.StackFrame; import com.sun.jdi.ThreadReference; import com.sun.jdi.Value; import com.sun.jdi.VirtualMachine; +import com.sun.jdi.VMDisconnectedException; import com.sun.jdi.event.BreakpointEvent; import com.sun.jdi.event.ClassPrepareEvent; import com.sun.jdi.event.Event; @@ -358,8 +359,12 @@ public abstract class JDIBreakpointTest extends MlvmTest { } }.go(); - if (!debuggee.terminated()) - debuggee.endDebugee(); + if (!debuggee.terminated()) { + try { + debuggee.dispose(); + } catch (VMDisconnectedException ignore) { + } + } debuggee.waitFor(); return true; From fca0af0487806ab2a5b83edad9214b3dbfddd282 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Tue, 12 Feb 2019 13:36:15 -0800 Subject: [PATCH 050/101] 8217835: Remove the experimental SunJSSE FIPS compliant mode Reviewed-by: mullan --- .../sun/net/ssl/internal/ssl/Provider.java | 17 +- .../sun/security/ssl/Authenticator.java | 4 +- .../sun/security/ssl/CertificateVerify.java | 14 +- .../sun/security/ssl/DHClientKeyExchange.java | 4 +- .../sun/security/ssl/DHKeyExchange.java | 14 +- .../sun/security/ssl/DHServerKeyExchange.java | 6 +- .../security/ssl/ECDHClientKeyExchange.java | 17 +- .../sun/security/ssl/ECDHKeyExchange.java | 26 +- .../security/ssl/ECDHServerKeyExchange.java | 13 +- .../sun/security/ssl/EphemeralKeyManager.java | 4 +- .../classes/sun/security/ssl/Finished.java | 8 +- .../share/classes/sun/security/ssl/HKDF.java | 4 +- .../sun/security/ssl/HandshakeHash.java | 57 +- .../sun/security/ssl/HelloCookieManager.java | 38 +- .../classes/sun/security/ssl/JsseJce.java | 251 +------- .../security/ssl/KeyManagerFactoryImpl.java | 19 +- .../security/ssl/PreSharedKeyExtension.java | 2 +- .../sun/security/ssl/RSAKeyExchange.java | 12 +- .../security/ssl/RSAServerKeyExchange.java | 4 +- .../sun/security/ssl/RSASignature.java | 10 +- .../classes/sun/security/ssl/SSLCipher.java | 30 +- .../sun/security/ssl/SSLConfiguration.java | 5 +- .../sun/security/ssl/SSLContextImpl.java | 226 ++----- .../security/ssl/SSLMasterKeyDerivation.java | 4 +- .../security/ssl/SSLTrafficKeyDerivation.java | 4 +- .../sun/security/ssl/SignatureScheme.java | 8 +- .../classes/sun/security/ssl/SunJSSE.java | 121 +--- .../ssl/SupportedGroupsExtension.java | 208 +++--- .../security/ssl/X509TrustManagerImpl.java | 22 +- .../sun/security/pkcs11/fips/CipherTest.java | 608 ------------------ .../pkcs11/fips/ClientJSSEServerJSSE.java | 92 --- .../security/pkcs11/fips/ImportKeyStore.java | 90 --- .../sun/security/pkcs11/fips/JSSEClient.java | 93 --- .../sun/security/pkcs11/fips/JSSEServer.java | 93 --- .../sun/security/pkcs11/fips/TestTLS12.java | 453 ------------- .../pkcs11/fips/TrustManagerTest.java | 111 ---- .../pkcs11/fips/TrustManagerTest.policy | 3 - test/jdk/sun/security/pkcs11/fips/cert8.db | Bin 65536 -> 0 bytes .../sun/security/pkcs11/fips/certs/anchor.cer | Bin 417 -> 0 bytes .../jdk/sun/security/pkcs11/fips/certs/ca.cer | Bin 454 -> 0 bytes .../sun/security/pkcs11/fips/certs/server.cer | Bin 427 -> 0 bytes test/jdk/sun/security/pkcs11/fips/fips.cfg | 19 - test/jdk/sun/security/pkcs11/fips/key3.db | Bin 32768 -> 0 bytes test/jdk/sun/security/pkcs11/fips/keystore | Bin 4760 -> 0 bytes test/jdk/sun/security/pkcs11/fips/secmod.db | Bin 32768 -> 0 bytes test/jdk/sun/security/pkcs11/fips/truststore | Bin 1565 -> 0 bytes 46 files changed, 364 insertions(+), 2350 deletions(-) delete mode 100644 test/jdk/sun/security/pkcs11/fips/CipherTest.java delete mode 100644 test/jdk/sun/security/pkcs11/fips/ClientJSSEServerJSSE.java delete mode 100644 test/jdk/sun/security/pkcs11/fips/ImportKeyStore.java delete mode 100644 test/jdk/sun/security/pkcs11/fips/JSSEClient.java delete mode 100644 test/jdk/sun/security/pkcs11/fips/JSSEServer.java delete mode 100644 test/jdk/sun/security/pkcs11/fips/TestTLS12.java delete mode 100644 test/jdk/sun/security/pkcs11/fips/TrustManagerTest.java delete mode 100644 test/jdk/sun/security/pkcs11/fips/TrustManagerTest.policy delete mode 100644 test/jdk/sun/security/pkcs11/fips/cert8.db delete mode 100644 test/jdk/sun/security/pkcs11/fips/certs/anchor.cer delete mode 100644 test/jdk/sun/security/pkcs11/fips/certs/ca.cer delete mode 100644 test/jdk/sun/security/pkcs11/fips/certs/server.cer delete mode 100644 test/jdk/sun/security/pkcs11/fips/fips.cfg delete mode 100644 test/jdk/sun/security/pkcs11/fips/key3.db delete mode 100644 test/jdk/sun/security/pkcs11/fips/keystore delete mode 100644 test/jdk/sun/security/pkcs11/fips/secmod.db delete mode 100644 test/jdk/sun/security/pkcs11/fips/truststore diff --git a/src/java.base/share/classes/com/sun/net/ssl/internal/ssl/Provider.java b/src/java.base/share/classes/com/sun/net/ssl/internal/ssl/Provider.java index f158f88bda1..40e3317dd0f 100644 --- a/src/java.base/share/classes/com/sun/net/ssl/internal/ssl/Provider.java +++ b/src/java.base/share/classes/com/sun/net/ssl/internal/ssl/Provider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2019, 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 @@ -42,21 +42,6 @@ public final class Provider extends SunJSSE { super(); } - // preferred constructor to enable FIPS mode at runtime - public Provider(java.security.Provider cryptoProvider) { - super(cryptoProvider); - } - - // constructor to enable FIPS mode from java.security file - public Provider(String cryptoProvider) { - super(cryptoProvider); - } - - // public for now, but we may want to change it or not document it. - public static synchronized boolean isFIPS() { - return SunJSSE.isFIPS(); - } - /** * Installs the JSSE provider. */ diff --git a/src/java.base/share/classes/sun/security/ssl/Authenticator.java b/src/java.base/share/classes/sun/security/ssl/Authenticator.java index 7a21fc5e332..1e6ba7f5c94 100644 --- a/src/java.base/share/classes/sun/security/ssl/Authenticator.java +++ b/src/java.base/share/classes/sun/security/ssl/Authenticator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -484,7 +484,7 @@ abstract class Authenticator { throw new RuntimeException("Unknown MacAlg " + macAlg); } - Mac m = JsseJce.getMac(algorithm); + Mac m = Mac.getInstance(algorithm); m.init(key); this.macAlg = macAlg; this.mac = m; diff --git a/src/java.base/share/classes/sun/security/ssl/CertificateVerify.java b/src/java.base/share/classes/sun/security/ssl/CertificateVerify.java index b5c6c9f2301..c1179787938 100644 --- a/src/java.base/share/classes/sun/security/ssl/CertificateVerify.java +++ b/src/java.base/share/classes/sun/security/ssl/CertificateVerify.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -196,13 +196,13 @@ final class CertificateVerify { Signature signer = null; switch (algorithm) { case "RSA": - signer = JsseJce.getSignature(JsseJce.SIGNATURE_RAWRSA); + signer = Signature.getInstance(JsseJce.SIGNATURE_RAWRSA); break; case "DSA": - signer = JsseJce.getSignature(JsseJce.SIGNATURE_RAWDSA); + signer = Signature.getInstance(JsseJce.SIGNATURE_RAWDSA); break; case "EC": - signer = JsseJce.getSignature(JsseJce.SIGNATURE_RAWECDSA); + signer = Signature.getInstance(JsseJce.SIGNATURE_RAWECDSA); break; default: throw new SignatureException("Unrecognized algorithm: " @@ -439,13 +439,13 @@ final class CertificateVerify { Signature signer = null; switch (algorithm) { case "RSA": - signer = JsseJce.getSignature(JsseJce.SIGNATURE_RAWRSA); + signer = Signature.getInstance(JsseJce.SIGNATURE_RAWRSA); break; case "DSA": - signer = JsseJce.getSignature(JsseJce.SIGNATURE_RAWDSA); + signer = Signature.getInstance(JsseJce.SIGNATURE_RAWDSA); break; case "EC": - signer = JsseJce.getSignature(JsseJce.SIGNATURE_RAWECDSA); + signer = Signature.getInstance(JsseJce.SIGNATURE_RAWECDSA); break; default: throw new SignatureException("Unrecognized algorithm: " diff --git a/src/java.base/share/classes/sun/security/ssl/DHClientKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/DHClientKeyExchange.java index 86e2c618a95..2f421898b35 100644 --- a/src/java.base/share/classes/sun/security/ssl/DHClientKeyExchange.java +++ b/src/java.base/share/classes/sun/security/ssl/DHClientKeyExchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -280,7 +280,7 @@ final class DHClientKeyExchange { DHPublicKeySpec spec = new DHPublicKeySpec( new BigInteger(1, ckem.y), params.getP(), params.getG()); - KeyFactory kf = JsseJce.getKeyFactory("DiffieHellman"); + KeyFactory kf = KeyFactory.getInstance("DiffieHellman"); DHPublicKey peerPublicKey = (DHPublicKey)kf.generatePublic(spec); diff --git a/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java index 49f5a90254b..40fe7afb553 100644 --- a/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java +++ b/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java @@ -87,7 +87,7 @@ final class DHKeyExchange { return null; } - KeyFactory kf = JsseJce.getKeyFactory("DiffieHellman"); + KeyFactory kf = KeyFactory.getInstance("DiffieHellman"); DHPublicKeySpec spec = new DHPublicKeySpec( new BigInteger(1, encodedPublic), params.getP(), params.getG()); @@ -106,7 +106,7 @@ final class DHKeyExchange { DHEPossession(NamedGroup namedGroup, SecureRandom random) { try { KeyPairGenerator kpg = - JsseJce.getKeyPairGenerator("DiffieHellman"); + KeyPairGenerator.getInstance("DiffieHellman"); DHParameterSpec params = (DHParameterSpec)namedGroup.getParameterSpec(); kpg.initialize(params, random); @@ -129,7 +129,7 @@ final class DHKeyExchange { PredefinedDHParameterSpecs.definedParams.get(keyLength); try { KeyPairGenerator kpg = - JsseJce.getKeyPairGenerator("DiffieHellman"); + KeyPairGenerator.getInstance("DiffieHellman"); if (params != null) { kpg.initialize(params, random); } else { @@ -155,7 +155,7 @@ final class DHKeyExchange { DHEPossession(DHECredentials credentials, SecureRandom random) { try { KeyPairGenerator kpg = - JsseJce.getKeyPairGenerator("DiffieHellman"); + KeyPairGenerator.getInstance("DiffieHellman"); kpg.initialize(credentials.popPublicKey.getParams(), random); KeyPair kp = generateDHKeyPair(kpg); if (kp == null) { @@ -208,7 +208,7 @@ final class DHKeyExchange { params.getP(), params.getG()); } try { - KeyFactory factory = JsseJce.getKeyFactory("DiffieHellman"); + KeyFactory factory = KeyFactory.getInstance("DiffieHellman"); return factory.getKeySpec(key, DHPublicKeySpec.class); } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { // unlikely @@ -473,7 +473,7 @@ final class DHKeyExchange { private SecretKey t12DeriveKey(String algorithm, AlgorithmParameterSpec params) throws IOException { try { - KeyAgreement ka = JsseJce.getKeyAgreement("DiffieHellman"); + KeyAgreement ka = KeyAgreement.getInstance("DiffieHellman"); ka.init(localPrivateKey); ka.doPhase(peerPublicKey, true); SecretKey preMasterSecret = @@ -499,7 +499,7 @@ final class DHKeyExchange { private SecretKey t13DeriveKey(String algorithm, AlgorithmParameterSpec params) throws IOException { try { - KeyAgreement ka = JsseJce.getKeyAgreement("DiffieHellman"); + KeyAgreement ka = KeyAgreement.getInstance("DiffieHellman"); ka.init(localPrivateKey); ka.doPhase(peerPublicKey, true); SecretKey sharedSecret = diff --git a/src/java.base/share/classes/sun/security/ssl/DHServerKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/DHServerKeyExchange.java index d09bf5d4a80..19a4a45e174 100644 --- a/src/java.base/share/classes/sun/security/ssl/DHServerKeyExchange.java +++ b/src/java.base/share/classes/sun/security/ssl/DHServerKeyExchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -420,7 +420,7 @@ final class DHServerKeyExchange { Signature signer = null; switch (keyAlgorithm) { case "DSA": - signer = JsseJce.getSignature(JsseJce.SIGNATURE_DSA); + signer = Signature.getInstance(JsseJce.SIGNATURE_DSA); break; case "RSA": signer = RSASignature.getInstance(); @@ -524,7 +524,7 @@ final class DHServerKeyExchange { // check constraints of EC PublicKey DHPublicKey publicKey; try { - KeyFactory kf = JsseJce.getKeyFactory("DiffieHellman"); + KeyFactory kf = KeyFactory.getInstance("DiffieHellman"); DHPublicKeySpec spec = new DHPublicKeySpec( new BigInteger(1, skem.y), new BigInteger(1, skem.p), diff --git a/src/java.base/share/classes/sun/security/ssl/ECDHClientKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/ECDHClientKeyExchange.java index 4ee812f2201..a55fbd64506 100644 --- a/src/java.base/share/classes/sun/security/ssl/ECDHClientKeyExchange.java +++ b/src/java.base/share/classes/sun/security/ssl/ECDHClientKeyExchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -49,6 +49,7 @@ import sun.security.ssl.SSLHandshake.HandshakeMessage; import sun.security.ssl.SupportedGroupsExtension.NamedGroup; import sun.security.ssl.X509Authentication.X509Credentials; import sun.security.ssl.X509Authentication.X509Possession; +import sun.security.util.ECUtil; import sun.security.util.HexDumpEncoder; /** @@ -78,7 +79,7 @@ final class ECDHClientKeyExchange { ECPoint point = publicKey.getW(); ECParameterSpec params = publicKey.getParams(); - encodedPoint = JsseJce.encodePoint(point, params.getCurve()); + encodedPoint = ECUtil.encodePoint(point, params.getCurve()); } ECDHClientKeyExchangeMessage(HandshakeContext handshakeContext, @@ -99,10 +100,10 @@ final class ECDHClientKeyExchange { try { ECParameterSpec params = publicKey.getParams(); ECPoint point = - JsseJce.decodePoint(encodedPoint, params.getCurve()); + ECUtil.decodePoint(encodedPoint, params.getCurve()); ECPublicKeySpec spec = new ECPublicKeySpec(point, params); - KeyFactory kf = JsseJce.getKeyFactory("EC"); + KeyFactory kf = KeyFactory.getInstance("EC"); ECPublicKey peerPublicKey = (ECPublicKey)kf.generatePublic(spec); @@ -319,10 +320,10 @@ final class ECDHClientKeyExchange { // create the credentials try { ECPoint point = - JsseJce.decodePoint(cke.encodedPoint, params.getCurve()); + ECUtil.decodePoint(cke.encodedPoint, params.getCurve()); ECPublicKeySpec spec = new ECPublicKeySpec(point, params); - KeyFactory kf = JsseJce.getKeyFactory("EC"); + KeyFactory kf = KeyFactory.getInstance("EC"); ECPublicKey peerPublicKey = (ECPublicKey)kf.generatePublic(spec); @@ -493,10 +494,10 @@ final class ECDHClientKeyExchange { // create the credentials try { ECPoint point = - JsseJce.decodePoint(cke.encodedPoint, params.getCurve()); + ECUtil.decodePoint(cke.encodedPoint, params.getCurve()); ECPublicKeySpec spec = new ECPublicKeySpec(point, params); - KeyFactory kf = JsseJce.getKeyFactory("EC"); + KeyFactory kf = KeyFactory.getInstance("EC"); ECPublicKey peerPublicKey = (ECPublicKey)kf.generatePublic(spec); diff --git a/src/java.base/share/classes/sun/security/ssl/ECDHKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/ECDHKeyExchange.java index 668247cd99e..eee88b538cd 100644 --- a/src/java.base/share/classes/sun/security/ssl/ECDHKeyExchange.java +++ b/src/java.base/share/classes/sun/security/ssl/ECDHKeyExchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -85,14 +85,14 @@ final class ECDHKeyExchange { } ECParameterSpec parameters = - JsseJce.getECParameterSpec(namedGroup.oid); + ECUtil.getECParameterSpec(null, namedGroup.oid); if (parameters == null) { return null; } - ECPoint point = JsseJce.decodePoint( + ECPoint point = ECUtil.decodePoint( encodedPoint, parameters.getCurve()); - KeyFactory factory = JsseJce.getKeyFactory("EC"); + KeyFactory factory = KeyFactory.getInstance("EC"); ECPublicKey publicKey = (ECPublicKey)factory.generatePublic( new ECPublicKeySpec(point, parameters)); return new ECDHECredentials(publicKey, namedGroup); @@ -106,7 +106,7 @@ final class ECDHKeyExchange { ECDHEPossession(NamedGroup namedGroup, SecureRandom random) { try { - KeyPairGenerator kpg = JsseJce.getKeyPairGenerator("EC"); + KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC"); ECGenParameterSpec params = (ECGenParameterSpec)namedGroup.getParameterSpec(); kpg.initialize(params, random); @@ -124,7 +124,7 @@ final class ECDHKeyExchange { ECDHEPossession(ECDHECredentials credentials, SecureRandom random) { ECParameterSpec params = credentials.popPublicKey.getParams(); try { - KeyPairGenerator kpg = JsseJce.getKeyPairGenerator("EC"); + KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC"); kpg.initialize(params, random); KeyPair kp = kpg.generateKeyPair(); privateKey = kp.getPrivate(); @@ -149,7 +149,7 @@ final class ECDHKeyExchange { PublicKey peerPublicKey) throws SSLHandshakeException { try { - KeyAgreement ka = JsseJce.getKeyAgreement("ECDH"); + KeyAgreement ka = KeyAgreement.getInstance("ECDH"); ka.init(privateKey); ka.doPhase(peerPublicKey, true); return ka.generateSecret("TlsPremasterSecret"); @@ -165,8 +165,8 @@ final class ECDHKeyExchange { try { ECParameterSpec params = publicKey.getParams(); ECPoint point = - JsseJce.decodePoint(encodedPoint, params.getCurve()); - KeyFactory kf = JsseJce.getKeyFactory("EC"); + ECUtil.decodePoint(encodedPoint, params.getCurve()); + KeyFactory kf = KeyFactory.getInstance("EC"); ECPublicKeySpec spec = new ECPublicKeySpec(point, params); PublicKey peerPublicKey = kf.generatePublic(spec); return getAgreedSecret(peerPublicKey); @@ -183,10 +183,10 @@ final class ECDHKeyExchange { ECParameterSpec params = publicKey.getParams(); ECPoint point = - JsseJce.decodePoint(encodedPoint, params.getCurve()); + ECUtil.decodePoint(encodedPoint, params.getCurve()); ECPublicKeySpec spec = new ECPublicKeySpec(point, params); - KeyFactory kf = JsseJce.getKeyFactory("EC"); + KeyFactory kf = KeyFactory.getInstance("EC"); ECPublicKey pubKey = (ECPublicKey)kf.generatePublic(spec); // check constraints of ECPublicKey @@ -424,7 +424,7 @@ final class ECDHKeyExchange { private SecretKey t12DeriveKey(String algorithm, AlgorithmParameterSpec params) throws IOException { try { - KeyAgreement ka = JsseJce.getKeyAgreement("ECDH"); + KeyAgreement ka = KeyAgreement.getInstance("ECDH"); ka.init(localPrivateKey); ka.doPhase(peerPublicKey, true); SecretKey preMasterSecret = @@ -451,7 +451,7 @@ final class ECDHKeyExchange { private SecretKey t13DeriveKey(String algorithm, AlgorithmParameterSpec params) throws IOException { try { - KeyAgreement ka = JsseJce.getKeyAgreement("ECDH"); + KeyAgreement ka = KeyAgreement.getInstance("ECDH"); ka.init(localPrivateKey); ka.doPhase(peerPublicKey, true); SecretKey sharedSecret = diff --git a/src/java.base/share/classes/sun/security/ssl/ECDHServerKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/ECDHServerKeyExchange.java index bbd9a6b3ebb..b2a278f180b 100644 --- a/src/java.base/share/classes/sun/security/ssl/ECDHServerKeyExchange.java +++ b/src/java.base/share/classes/sun/security/ssl/ECDHServerKeyExchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -52,6 +52,7 @@ import sun.security.ssl.SupportedGroupsExtension.NamedGroup; import sun.security.ssl.SupportedGroupsExtension.SupportedGroups; import sun.security.ssl.X509Authentication.X509Credentials; import sun.security.ssl.X509Authentication.X509Possession; +import sun.security.util.ECUtil; import sun.security.util.HexDumpEncoder; /** @@ -120,7 +121,7 @@ final class ECDHServerKeyExchange { publicKey = ecdhePossession.publicKey; ECParameterSpec params = publicKey.getParams(); ECPoint point = publicKey.getW(); - publicPoint = JsseJce.encodePoint(point, params.getCurve()); + publicPoint = ECUtil.encodePoint(point, params.getCurve()); this.namedGroup = NamedGroup.valueOf(params); if ((namedGroup == null) || (namedGroup.oid == null) ) { @@ -221,7 +222,7 @@ final class ECDHServerKeyExchange { } ECParameterSpec parameters = - JsseJce.getECParameterSpec(namedGroup.oid); + ECUtil.getECParameterSpec(null, namedGroup.oid); if (parameters == null) { throw chc.conContext.fatal(Alert.ILLEGAL_PARAMETER, "No supported EC parameter: " + namedGroup); @@ -236,8 +237,8 @@ final class ECDHServerKeyExchange { ECPublicKey ecPublicKey = null; try { ECPoint point = - JsseJce.decodePoint(publicPoint, parameters.getCurve()); - KeyFactory factory = JsseJce.getKeyFactory("EC"); + ECUtil.decodePoint(publicPoint, parameters.getCurve()); + KeyFactory factory = KeyFactory.getInstance("EC"); ecPublicKey = (ECPublicKey)factory.generatePublic( new ECPublicKeySpec(point, parameters)); } catch (NoSuchAlgorithmException | @@ -446,7 +447,7 @@ final class ECDHServerKeyExchange { Signature signer = null; switch (keyAlgorithm) { case "EC": - signer = JsseJce.getSignature(JsseJce.SIGNATURE_ECDSA); + signer = Signature.getInstance(JsseJce.SIGNATURE_ECDSA); break; case "RSA": signer = RSASignature.getInstance(); diff --git a/src/java.base/share/classes/sun/security/ssl/EphemeralKeyManager.java b/src/java.base/share/classes/sun/security/ssl/EphemeralKeyManager.java index baa8920e74f..fe9a9090fb9 100644 --- a/src/java.base/share/classes/sun/security/ssl/EphemeralKeyManager.java +++ b/src/java.base/share/classes/sun/security/ssl/EphemeralKeyManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2019, 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 @@ -69,7 +69,7 @@ final class EphemeralKeyManager { KeyPair kp = keys[index].getKeyPair(); if (kp == null) { try { - KeyPairGenerator kgen = JsseJce.getKeyPairGenerator("RSA"); + KeyPairGenerator kgen = KeyPairGenerator.getInstance("RSA"); kgen.initialize(length, random); keys[index] = new EphemeralKeyPair(kgen.genKeyPair()); kp = keys[index].getKeyPair(); diff --git a/src/java.base/share/classes/sun/security/ssl/Finished.java b/src/java.base/share/classes/sun/security/ssl/Finished.java index aabf09a290f..2e76645dce4 100644 --- a/src/java.base/share/classes/sun/security/ssl/Finished.java +++ b/src/java.base/share/classes/sun/security/ssl/Finished.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -257,7 +257,7 @@ final class Finished { TlsPrfParameterSpec spec = new TlsPrfParameterSpec( masterSecretKey, tlsLabel, seed, 12, hashAlg.name, hashAlg.hashLength, hashAlg.blockSize); - KeyGenerator kg = JsseJce.getKeyGenerator(prfAlg); + KeyGenerator kg = KeyGenerator.getInstance(prfAlg); kg.init(spec); SecretKey prfKey = kg.generateKey(); if (!"RAW".equals(prfKey.getFormat())) { @@ -309,7 +309,7 @@ final class Finished { TlsPrfParameterSpec spec = new TlsPrfParameterSpec( masterSecretKey, tlsLabel, seed, 12, hashAlg.name, hashAlg.hashLength, hashAlg.blockSize); - KeyGenerator kg = JsseJce.getKeyGenerator(prfAlg); + KeyGenerator kg = KeyGenerator.getInstance(prfAlg); kg.init(spec); SecretKey prfKey = kg.generateKey(); if (!"RAW".equals(prfKey.getFormat())) { @@ -350,7 +350,7 @@ final class Finished { String hmacAlg = "Hmac" + hashAlg.name.replace("-", ""); try { - Mac hmac = JsseJce.getMac(hmacAlg); + Mac hmac = Mac.getInstance(hmacAlg); hmac.init(finishedSecret); return hmac.doFinal(context.handshakeHash.digest()); } catch (NoSuchAlgorithmException |InvalidKeyException ex) { diff --git a/src/java.base/share/classes/sun/security/ssl/HKDF.java b/src/java.base/share/classes/sun/security/ssl/HKDF.java index 8c4dd4db876..b9fd29b7c89 100644 --- a/src/java.base/share/classes/sun/security/ssl/HKDF.java +++ b/src/java.base/share/classes/sun/security/ssl/HKDF.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -62,7 +62,7 @@ final class HKDF { Objects.requireNonNull(hashAlg, "Must provide underlying HKDF Digest algorithm."); hmacAlg = "Hmac" + hashAlg.replace("-", ""); - hmacObj = JsseJce.getMac(hmacAlg); + hmacObj = Mac.getInstance(hmacAlg); hmacLen = hmacObj.getMacLength(); } diff --git a/src/java.base/share/classes/sun/security/ssl/HandshakeHash.java b/src/java.base/share/classes/sun/security/ssl/HandshakeHash.java index a9737598eeb..2ab184a3a63 100644 --- a/src/java.base/share/classes/sun/security/ssl/HandshakeHash.java +++ b/src/java.base/share/classes/sun/security/ssl/HandshakeHash.java @@ -29,6 +29,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.util.Arrays; import java.util.LinkedList; import javax.crypto.SecretKey; @@ -269,8 +270,13 @@ final class HandshakeHash { private final ByteArrayOutputStream baos; S30HandshakeHash(CipherSuite cipherSuite) { - this.mdMD5 = JsseJce.getMessageDigest("MD5"); - this.mdSHA = JsseJce.getMessageDigest("SHA"); + try { + this.mdMD5 = MessageDigest.getInstance("MD5"); + this.mdSHA = MessageDigest.getInstance("SHA"); + } catch (NoSuchAlgorithmException nsae) { + throw new RuntimeException( + "Hash algorithm MD5 or SHA is not available", nsae); + } boolean hasArchived = false; if (mdMD5 instanceof Cloneable) { @@ -379,7 +385,12 @@ final class HandshakeHash { "MessageDigest does no support clone operation"); } } else { - md5Clone = JsseJce.getMessageDigest("MD5"); + try { + md5Clone = MessageDigest.getInstance("MD5"); + } catch (NoSuchAlgorithmException nsae) { + throw new RuntimeException( + "Hash algorithm MD5 is not available", nsae); + } md5Clone.update(md5.archived()); } @@ -396,7 +407,12 @@ final class HandshakeHash { "MessageDigest does no support clone operation"); } } else { - shaClone = JsseJce.getMessageDigest("SHA"); + try { + shaClone = MessageDigest.getInstance("SHA"); + } catch (NoSuchAlgorithmException nsae) { + throw new RuntimeException( + "Hash algorithm SHA is not available", nsae); + } shaClone.update(sha.archived()); } @@ -447,8 +463,15 @@ final class HandshakeHash { private final ByteArrayOutputStream baos; T10HandshakeHash(CipherSuite cipherSuite) { - MessageDigest mdMD5 = JsseJce.getMessageDigest("MD5"); - MessageDigest mdSHA = JsseJce.getMessageDigest("SHA"); + MessageDigest mdMD5; + MessageDigest mdSHA; + try { + mdMD5 = MessageDigest.getInstance("MD5"); + mdSHA = MessageDigest.getInstance("SHA"); + } catch (NoSuchAlgorithmException nsae) { + throw new RuntimeException( + "Hash algorithm MD5 or SHA is not available", nsae); + } boolean hasArchived = false; if (mdMD5 instanceof Cloneable) { @@ -514,8 +537,15 @@ final class HandshakeHash { private final ByteArrayOutputStream baos; T12HandshakeHash(CipherSuite cipherSuite) { - MessageDigest md = - JsseJce.getMessageDigest(cipherSuite.hashAlg.name); + MessageDigest md; + try { + md = MessageDigest.getInstance(cipherSuite.hashAlg.name); + } catch (NoSuchAlgorithmException nsae) { + throw new RuntimeException( + "Hash algorithm " + + cipherSuite.hashAlg.name + " is not available", nsae); + } + if (md instanceof Cloneable) { transcriptHash = new CloneableHash(md); this.baos = new ByteArrayOutputStream(); @@ -552,8 +582,15 @@ final class HandshakeHash { private final TranscriptHash transcriptHash; T13HandshakeHash(CipherSuite cipherSuite) { - MessageDigest md = - JsseJce.getMessageDigest(cipherSuite.hashAlg.name); + MessageDigest md; + try { + md = MessageDigest.getInstance(cipherSuite.hashAlg.name); + } catch (NoSuchAlgorithmException nsae) { + throw new RuntimeException( + "Hash algorithm " + + cipherSuite.hashAlg.name + " is not available", nsae); + } + if (md instanceof Cloneable) { transcriptHash = new CloneableHash(md); } else { diff --git a/src/java.base/share/classes/sun/security/ssl/HelloCookieManager.java b/src/java.base/share/classes/sun/security/ssl/HelloCookieManager.java index 45b484d09e2..31c61036acf 100644 --- a/src/java.base/share/classes/sun/security/ssl/HelloCookieManager.java +++ b/src/java.base/share/classes/sun/security/ssl/HelloCookieManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -27,6 +27,7 @@ package sun.security.ssl; import java.io.IOException; import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Arrays; import static sun.security.ssl.ClientHello.ClientHelloMessage; @@ -143,7 +144,13 @@ abstract class HelloCookieManager { cookieVersion++; } - MessageDigest md = JsseJce.getMessageDigest("SHA-256"); + MessageDigest md; + try { + md = MessageDigest.getInstance("SHA-256"); + } catch (NoSuchAlgorithmException nsae) { + throw new RuntimeException( + "MessageDigest algorithm SHA-256 is not available", nsae); + } byte[] helloBytes = clientHello.getHelloCookieBytes(); md.update(helloBytes); byte[] cookie = md.digest(secret); // 32 bytes @@ -169,7 +176,13 @@ abstract class HelloCookieManager { } } - MessageDigest md = JsseJce.getMessageDigest("SHA-256"); + MessageDigest md; + try { + md = MessageDigest.getInstance("SHA-256"); + } catch (NoSuchAlgorithmException nsae) { + throw new RuntimeException( + "MessageDigest algorithm SHA-256 is not available", nsae); + } byte[] helloBytes = clientHello.getHelloCookieBytes(); md.update(helloBytes); byte[] target = md.digest(secret); // 32 bytes @@ -234,8 +247,16 @@ abstract class HelloCookieManager { cookieVersion++; // allow wrapped version number } - MessageDigest md = JsseJce.getMessageDigest( + MessageDigest md; + try { + md = MessageDigest.getInstance( context.negotiatedCipherSuite.hashAlg.name); + } catch (NoSuchAlgorithmException nsae) { + throw new RuntimeException( + "MessageDigest algorithm " + + context.negotiatedCipherSuite.hashAlg.name + + " is not available", nsae); + } byte[] headerBytes = clientHello.getHeaderBytes(); md.update(headerBytes); byte[] headerCookie = md.digest(secret); @@ -300,7 +321,14 @@ abstract class HelloCookieManager { } } - MessageDigest md = JsseJce.getMessageDigest(cs.hashAlg.name); + MessageDigest md; + try { + md = MessageDigest.getInstance(cs.hashAlg.name); + } catch (NoSuchAlgorithmException nsae) { + throw new RuntimeException( + "MessageDigest algorithm " + + cs.hashAlg.name + " is not available", nsae); + } byte[] headerBytes = clientHello.getHeaderBytes(); md.update(headerBytes); byte[] headerCookie = md.digest(secret); diff --git a/src/java.base/share/classes/sun/security/ssl/JsseJce.java b/src/java.base/share/classes/sun/security/ssl/JsseJce.java index be5934acd63..c6ca4977d0a 100644 --- a/src/java.base/share/classes/sun/security/ssl/JsseJce.java +++ b/src/java.base/share/classes/sun/security/ssl/JsseJce.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -29,13 +29,7 @@ import java.math.BigInteger; import java.security.*; import java.security.interfaces.RSAPublicKey; import java.security.spec.*; -import java.util.*; import javax.crypto.*; -import sun.security.jca.ProviderList; -import sun.security.jca.Providers; -import static sun.security.ssl.SunJSSE.cryptoProvider; -import sun.security.util.ECUtil; -import static sun.security.util.SecurityConstants.PROVIDER_VER; /** * This class contains a few static methods for interaction with the JCA/JCE @@ -47,54 +41,6 @@ final class JsseJce { static final boolean ALLOW_ECC = Utilities.getBooleanProperty("com.sun.net.ssl.enableECC", true); - private static final ProviderList fipsProviderList; - - static { - // force FIPS flag initialization - // Because isFIPS() is synchronized and cryptoProvider is not modified - // after it completes, this also eliminates the need for any further - // synchronization when accessing cryptoProvider - if (SunJSSE.isFIPS() == false) { - fipsProviderList = null; - } else { - // Setup a ProviderList that can be used by the trust manager - // during certificate chain validation. All the crypto must be - // from the FIPS provider, but we also allow the required - // certificate related services from the SUN provider. - Provider sun = Security.getProvider("SUN"); - if (sun == null) { - throw new RuntimeException - ("FIPS mode: SUN provider must be installed"); - } - Provider sunCerts = new SunCertificates(sun); - fipsProviderList = ProviderList.newList(cryptoProvider, sunCerts); - } - } - - private static final class SunCertificates extends Provider { - private static final long serialVersionUID = -3284138292032213752L; - - SunCertificates(final Provider p) { - super("SunCertificates", PROVIDER_VER, "SunJSSE internal"); - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Object run() { - // copy certificate related services from the Sun provider - for (Map.Entry entry : p.entrySet()) { - String key = (String)entry.getKey(); - if (key.startsWith("CertPathValidator.") - || key.startsWith("CertPathBuilder.") - || key.startsWith("CertStore.") - || key.startsWith("CertificateFactory.")) { - put(key, entry.getValue()); - } - } - return null; - } - }); - } - } - /** * JCE transformation string for RSA with PKCS#1 v1.5 padding. * Can be used for encryption, decryption, signing, verifying. @@ -180,153 +126,6 @@ final class JsseJce { return EcAvailability.isAvailable; } - /** - * Return an JCE cipher implementation for the specified algorithm. - */ - static Cipher getCipher(String transformation) - throws NoSuchAlgorithmException { - try { - if (cryptoProvider == null) { - return Cipher.getInstance(transformation); - } else { - return Cipher.getInstance(transformation, cryptoProvider); - } - } catch (NoSuchPaddingException e) { - throw new NoSuchAlgorithmException(e); - } - } - - /** - * Return an JCA signature implementation for the specified algorithm. - * The algorithm string should be one of the constants defined - * in this class. - */ - static Signature getSignature(String algorithm) - throws NoSuchAlgorithmException { - if (cryptoProvider == null) { - return Signature.getInstance(algorithm); - } else { - // reference equality - if (algorithm == SIGNATURE_SSLRSA) { - // The SunPKCS11 provider currently does not support this - // special algorithm. We allow a fallback in this case because - // the SunJSSE implementation does the actual crypto using - // a NONEwithRSA signature obtained from the cryptoProvider. - if (cryptoProvider.getService("Signature", algorithm) == null) { - // Calling Signature.getInstance() and catching the - // exception would be cleaner, but exceptions are a little - // expensive. So we check directly via getService(). - try { - return Signature.getInstance(algorithm, "SunJSSE"); - } catch (NoSuchProviderException e) { - throw new NoSuchAlgorithmException(e); - } - } - } - return Signature.getInstance(algorithm, cryptoProvider); - } - } - - static KeyGenerator getKeyGenerator(String algorithm) - throws NoSuchAlgorithmException { - if (cryptoProvider == null) { - return KeyGenerator.getInstance(algorithm); - } else { - return KeyGenerator.getInstance(algorithm, cryptoProvider); - } - } - - static KeyPairGenerator getKeyPairGenerator(String algorithm) - throws NoSuchAlgorithmException { - if (cryptoProvider == null) { - return KeyPairGenerator.getInstance(algorithm); - } else { - return KeyPairGenerator.getInstance(algorithm, cryptoProvider); - } - } - - static KeyAgreement getKeyAgreement(String algorithm) - throws NoSuchAlgorithmException { - if (cryptoProvider == null) { - return KeyAgreement.getInstance(algorithm); - } else { - return KeyAgreement.getInstance(algorithm, cryptoProvider); - } - } - - static Mac getMac(String algorithm) - throws NoSuchAlgorithmException { - if (cryptoProvider == null) { - return Mac.getInstance(algorithm); - } else { - return Mac.getInstance(algorithm, cryptoProvider); - } - } - - static KeyFactory getKeyFactory(String algorithm) - throws NoSuchAlgorithmException { - if (cryptoProvider == null) { - return KeyFactory.getInstance(algorithm); - } else { - return KeyFactory.getInstance(algorithm, cryptoProvider); - } - } - - static AlgorithmParameters getAlgorithmParameters(String algorithm) - throws NoSuchAlgorithmException { - if (cryptoProvider == null) { - return AlgorithmParameters.getInstance(algorithm); - } else { - return AlgorithmParameters.getInstance(algorithm, cryptoProvider); - } - } - - static SecureRandom getSecureRandom() throws KeyManagementException { - if (cryptoProvider == null) { - return new SecureRandom(); - } - // Try "PKCS11" first. If that is not supported, iterate through - // the provider and return the first working implementation. - try { - return SecureRandom.getInstance("PKCS11", cryptoProvider); - } catch (NoSuchAlgorithmException e) { - // ignore - } - for (Provider.Service s : cryptoProvider.getServices()) { - if (s.getType().equals("SecureRandom")) { - try { - return SecureRandom.getInstance( - s.getAlgorithm(), cryptoProvider); - } catch (NoSuchAlgorithmException ee) { - // ignore - } - } - } - throw new KeyManagementException("FIPS mode: no SecureRandom " - + " implementation found in provider " + cryptoProvider.getName()); - } - - static MessageDigest getMD5() { - return getMessageDigest("MD5"); - } - - static MessageDigest getSHA() { - return getMessageDigest("SHA"); - } - - static MessageDigest getMessageDigest(String algorithm) { - try { - if (cryptoProvider == null) { - return MessageDigest.getInstance(algorithm); - } else { - return MessageDigest.getInstance(algorithm, cryptoProvider); - } - } catch (NoSuchAlgorithmException e) { - throw new RuntimeException - ("Algorithm " + algorithm + " not available", e); - } - } - static int getRSAKeyLength(PublicKey key) { BigInteger modulus; if (key instanceof RSAPublicKey) { @@ -345,47 +144,13 @@ final class JsseJce { rsaKey.getPublicExponent()); } try { - KeyFactory factory = JsseJce.getKeyFactory("RSA"); + KeyFactory factory = KeyFactory.getInstance("RSA"); return factory.getKeySpec(key, RSAPublicKeySpec.class); } catch (Exception e) { throw new RuntimeException(e); } } - static ECParameterSpec getECParameterSpec(String namedCurveOid) { - return ECUtil.getECParameterSpec(cryptoProvider, namedCurveOid); - } - - static String getNamedCurveOid(ECParameterSpec params) { - return ECUtil.getCurveName(cryptoProvider, params); - } - - static ECPoint decodePoint(byte[] encoded, EllipticCurve curve) - throws java.io.IOException { - return ECUtil.decodePoint(encoded, curve); - } - - static byte[] encodePoint(ECPoint point, EllipticCurve curve) { - return ECUtil.encodePoint(point, curve); - } - - // In FIPS mode, set thread local providers; otherwise a no-op. - // Must be paired with endFipsProvider. - static Object beginFipsProvider() { - if (fipsProviderList == null) { - return null; - } else { - return Providers.beginThreadProviderList(fipsProviderList); - } - } - - static void endFipsProvider(Object o) { - if (fipsProviderList != null) { - Providers.endThreadProviderList((ProviderList)o); - } - } - - // lazy initialization holder class idiom for static default parameters // // See Effective Java Second Edition: Item 71. @@ -396,12 +161,12 @@ final class JsseJce { static { boolean mediator = true; try { - JsseJce.getSignature(SIGNATURE_ECDSA); - JsseJce.getSignature(SIGNATURE_RAWECDSA); - JsseJce.getKeyAgreement("ECDH"); - JsseJce.getKeyFactory("EC"); - JsseJce.getKeyPairGenerator("EC"); - JsseJce.getAlgorithmParameters("EC"); + Signature.getInstance(SIGNATURE_ECDSA); + Signature.getInstance(SIGNATURE_RAWECDSA); + KeyAgreement.getInstance("ECDH"); + KeyFactory.getInstance("EC"); + KeyPairGenerator.getInstance("EC"); + AlgorithmParameters.getInstance("EC"); } catch (Exception e) { mediator = false; } diff --git a/src/java.base/share/classes/sun/security/ssl/KeyManagerFactoryImpl.java b/src/java.base/share/classes/sun/security/ssl/KeyManagerFactoryImpl.java index ffee2c1603b..7256466033f 100644 --- a/src/java.base/share/classes/sun/security/ssl/KeyManagerFactoryImpl.java +++ b/src/java.base/share/classes/sun/security/ssl/KeyManagerFactoryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2019, 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 @@ -61,12 +61,6 @@ abstract class KeyManagerFactoryImpl extends KeyManagerFactorySpi { protected void engineInit(KeyStore ks, char[] password) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException { - if ((ks != null) && SunJSSE.isFIPS()) { - if (ks.getProvider() != SunJSSE.cryptoProvider) { - throw new KeyStoreException("FIPS mode: KeyStore must be " - + "from provider " + SunJSSE.cryptoProvider.getName()); - } - } keyManager = new SunX509KeyManagerImpl(ks, password); isInitialized = true; } @@ -91,12 +85,6 @@ abstract class KeyManagerFactoryImpl extends KeyManagerFactorySpi { keyManager = new X509KeyManagerImpl( Collections.emptyList()); } else { - if (SunJSSE.isFIPS() && - (ks.getProvider() != SunJSSE.cryptoProvider)) { - throw new KeyStoreException( - "FIPS mode: KeyStore must be " + - "from provider " + SunJSSE.cryptoProvider.getName()); - } try { Builder builder = Builder.newInstance(ks, new PasswordProtection(password)); @@ -115,10 +103,7 @@ abstract class KeyManagerFactoryImpl extends KeyManagerFactorySpi { throw new InvalidAlgorithmParameterException( "Parameters must be instance of KeyStoreBuilderParameters"); } - if (SunJSSE.isFIPS()) { - throw new InvalidAlgorithmParameterException - ("FIPS mode: KeyStoreBuilderParameters not supported"); - } + List builders = ((KeyStoreBuilderParameters)params).getParameters(); keyManager = new X509KeyManagerImpl(builders); diff --git a/src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java b/src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java index 1f0a957e2f9..1a50bea72d7 100644 --- a/src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java +++ b/src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java @@ -765,7 +765,7 @@ final class PreSharedKeyExtension { String hmacAlg = "Hmac" + hashAlg.name.replace("-", ""); try { - Mac hmac = JsseJce.getMac(hmacAlg); + Mac hmac = Mac.getInstance(hmacAlg); hmac.init(finishedKey); return hmac.doFinal(digest); } catch (NoSuchAlgorithmException | InvalidKeyException ex) { diff --git a/src/java.base/share/classes/sun/security/ssl/RSAKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/RSAKeyExchange.java index 555d9aeaf84..f9446999db4 100644 --- a/src/java.base/share/classes/sun/security/ssl/RSAKeyExchange.java +++ b/src/java.base/share/classes/sun/security/ssl/RSAKeyExchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -109,7 +109,7 @@ final class RSAKeyExchange { byte[] getEncoded(PublicKey publicKey, SecureRandom secureRandom) throws GeneralSecurityException { - Cipher cipher = JsseJce.getCipher(JsseJce.CIPHER_RSA_PKCS1); + Cipher cipher = Cipher.getInstance(JsseJce.CIPHER_RSA_PKCS1); cipher.init(Cipher.WRAP_MODE, publicKey, secureRandom); return cipher.wrap(premasterSecret); } @@ -119,7 +119,7 @@ final class RSAKeyExchange { ClientHandshakeContext chc) throws GeneralSecurityException { String algorithm = chc.negotiatedProtocol.useTLS12PlusSpec() ? "SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret"; - KeyGenerator kg = JsseJce.getKeyGenerator(algorithm); + KeyGenerator kg = KeyGenerator.getInstance(algorithm); TlsRsaPremasterSecretParameterSpec spec = new TlsRsaPremasterSecretParameterSpec( chc.clientHelloVersion, @@ -136,7 +136,7 @@ final class RSAKeyExchange { byte[] encoded = null; boolean needFailover = false; - Cipher cipher = JsseJce.getCipher(JsseJce.CIPHER_RSA_PKCS1); + Cipher cipher = Cipher.getInstance(JsseJce.CIPHER_RSA_PKCS1); try { // Try UNWRAP_MODE mode firstly. cipher.init(Cipher.UNWRAP_MODE, privateKey, @@ -163,7 +163,7 @@ final class RSAKeyExchange { if (needFailover) { // The cipher might be spoiled by unsuccessful call to init(), // so request a fresh instance - cipher = JsseJce.getCipher(JsseJce.CIPHER_RSA_PKCS1); + cipher = Cipher.getInstance(JsseJce.CIPHER_RSA_PKCS1); // Use DECRYPT_MODE and dispose the previous initialization. cipher.init(Cipher.DECRYPT_MODE, privateKey); @@ -227,7 +227,7 @@ final class RSAKeyExchange { try { String s = ((clientVersion >= ProtocolVersion.TLS12.id) ? "SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret"); - KeyGenerator kg = JsseJce.getKeyGenerator(s); + KeyGenerator kg = KeyGenerator.getInstance(s); kg.init(new TlsRsaPremasterSecretParameterSpec( clientVersion, serverVersion, encodedSecret), generator); diff --git a/src/java.base/share/classes/sun/security/ssl/RSAServerKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/RSAServerKeyExchange.java index ebe82a5a6e4..2398a12c016 100644 --- a/src/java.base/share/classes/sun/security/ssl/RSAServerKeyExchange.java +++ b/src/java.base/share/classes/sun/security/ssl/RSAServerKeyExchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -306,7 +306,7 @@ final class RSAServerKeyExchange { // check constraints of RSA PublicKey RSAPublicKey publicKey; try { - KeyFactory kf = JsseJce.getKeyFactory("RSA"); + KeyFactory kf = KeyFactory.getInstance("RSA"); RSAPublicKeySpec spec = new RSAPublicKeySpec( new BigInteger(1, skem.modulus), new BigInteger(1, skem.exponent)); diff --git a/src/java.base/share/classes/sun/security/ssl/RSASignature.java b/src/java.base/share/classes/sun/security/ssl/RSASignature.java index 9851c3180b6..74574ee0672 100644 --- a/src/java.base/share/classes/sun/security/ssl/RSASignature.java +++ b/src/java.base/share/classes/sun/security/ssl/RSASignature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, 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 @@ -53,9 +53,9 @@ public final class RSASignature extends SignatureSpi { public RSASignature() throws NoSuchAlgorithmException { super(); - rawRsa = JsseJce.getSignature(JsseJce.SIGNATURE_RAWRSA); - this.mdMD5 = JsseJce.getMessageDigest("MD5"); - this.mdSHA = JsseJce.getMessageDigest("SHA"); + rawRsa = Signature.getInstance(JsseJce.SIGNATURE_RAWRSA); + this.mdMD5 = MessageDigest.getInstance("MD5"); + this.mdSHA = MessageDigest.getInstance("SHA"); } /** @@ -66,7 +66,7 @@ public final class RSASignature extends SignatureSpi { * which may be this class. */ static Signature getInstance() throws NoSuchAlgorithmException { - return JsseJce.getSignature(JsseJce.SIGNATURE_SSLRSA); + return Signature.getInstance(JsseJce.SIGNATURE_SSLRSA); } @Override diff --git a/src/java.base/share/classes/sun/security/ssl/SSLCipher.java b/src/java.base/share/classes/sun/security/ssl/SSLCipher.java index 34883b094b0..720d3d8a7ee 100644 --- a/src/java.base/share/classes/sun/security/ssl/SSLCipher.java +++ b/src/java.base/share/classes/sun/security/ssl/SSLCipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -851,7 +851,7 @@ enum SSLCipher { Key key, AlgorithmParameterSpec params, SecureRandom random) throws GeneralSecurityException { super(authenticator, protocolVersion); - this.cipher = JsseJce.getCipher(algorithm); + this.cipher = Cipher.getInstance(algorithm); cipher.init(Cipher.DECRYPT_MODE, key, params, random); } @@ -933,7 +933,7 @@ enum SSLCipher { Key key, AlgorithmParameterSpec params, SecureRandom random) throws GeneralSecurityException { super(authenticator, protocolVersion); - this.cipher = JsseJce.getCipher(algorithm); + this.cipher = Cipher.getInstance(algorithm); cipher.init(Cipher.ENCRYPT_MODE, key, params, random); } @@ -1023,7 +1023,7 @@ enum SSLCipher { Key key, AlgorithmParameterSpec params, SecureRandom random) throws GeneralSecurityException { super(authenticator, protocolVersion); - this.cipher = JsseJce.getCipher(algorithm); + this.cipher = Cipher.getInstance(algorithm); cipher.init(Cipher.DECRYPT_MODE, key, params, random); } @@ -1175,7 +1175,7 @@ enum SSLCipher { Key key, AlgorithmParameterSpec params, SecureRandom random) throws GeneralSecurityException { super(authenticator, protocolVersion); - this.cipher = JsseJce.getCipher(algorithm); + this.cipher = Cipher.getInstance(algorithm); cipher.init(Cipher.ENCRYPT_MODE, key, params, random); } @@ -1291,7 +1291,7 @@ enum SSLCipher { Key key, AlgorithmParameterSpec params, SecureRandom random) throws GeneralSecurityException { super(authenticator, protocolVersion); - this.cipher = JsseJce.getCipher(algorithm); + this.cipher = Cipher.getInstance(algorithm); if (params == null) { params = new IvParameterSpec(new byte[sslCipher.ivSize]); } @@ -1455,7 +1455,7 @@ enum SSLCipher { Key key, AlgorithmParameterSpec params, SecureRandom random) throws GeneralSecurityException { super(authenticator, protocolVersion); - this.cipher = JsseJce.getCipher(algorithm); + this.cipher = Cipher.getInstance(algorithm); this.random = random; if (params == null) { params = new IvParameterSpec(new byte[sslCipher.ivSize]); @@ -1590,7 +1590,7 @@ enum SSLCipher { Key key, AlgorithmParameterSpec params, SecureRandom random) throws GeneralSecurityException { super(authenticator, protocolVersion); - this.cipher = JsseJce.getCipher(algorithm); + this.cipher = Cipher.getInstance(algorithm); this.tagSize = sslCipher.tagSize; this.key = key; this.fixedIv = ((IvParameterSpec)params).getIV(); @@ -1705,7 +1705,7 @@ enum SSLCipher { Key key, AlgorithmParameterSpec params, SecureRandom random) throws GeneralSecurityException { super(authenticator, protocolVersion); - this.cipher = JsseJce.getCipher(algorithm); + this.cipher = Cipher.getInstance(algorithm); this.tagSize = sslCipher.tagSize; this.key = key; this.fixedIv = ((IvParameterSpec)params).getIV(); @@ -1838,7 +1838,7 @@ enum SSLCipher { Key key, AlgorithmParameterSpec params, SecureRandom random) throws GeneralSecurityException { super(authenticator, protocolVersion); - this.cipher = JsseJce.getCipher(algorithm); + this.cipher = Cipher.getInstance(algorithm); this.tagSize = sslCipher.tagSize; this.key = key; this.iv = ((IvParameterSpec)params).getIV(); @@ -1992,7 +1992,7 @@ enum SSLCipher { Key key, AlgorithmParameterSpec params, SecureRandom random) throws GeneralSecurityException { super(authenticator, protocolVersion); - this.cipher = JsseJce.getCipher(algorithm); + this.cipher = Cipher.getInstance(algorithm); this.tagSize = sslCipher.tagSize; this.key = key; this.iv = ((IvParameterSpec)params).getIV(); @@ -2133,7 +2133,7 @@ enum SSLCipher { Key key, AlgorithmParameterSpec params, SecureRandom random) throws GeneralSecurityException { super(authenticator, protocolVersion); - this.cipher = JsseJce.getCipher(algorithm); + this.cipher = Cipher.getInstance(algorithm); this.tagSize = sslCipher.tagSize; this.key = key; this.iv = ((IvParameterSpec)params).getIV(); @@ -2252,7 +2252,7 @@ enum SSLCipher { Key key, AlgorithmParameterSpec params, SecureRandom random) throws GeneralSecurityException { super(authenticator, protocolVersion); - this.cipher = JsseJce.getCipher(algorithm); + this.cipher = Cipher.getInstance(algorithm); this.tagSize = sslCipher.tagSize; this.key = key; this.iv = ((IvParameterSpec)params).getIV(); @@ -2392,7 +2392,7 @@ enum SSLCipher { Key key, AlgorithmParameterSpec params, SecureRandom random) throws GeneralSecurityException { super(authenticator, protocolVersion); - this.cipher = JsseJce.getCipher(algorithm); + this.cipher = Cipher.getInstance(algorithm); this.tagSize = sslCipher.tagSize; this.key = key; this.iv = ((IvParameterSpec)params).getIV(); @@ -2534,7 +2534,7 @@ enum SSLCipher { Key key, AlgorithmParameterSpec params, SecureRandom random) throws GeneralSecurityException { super(authenticator, protocolVersion); - this.cipher = JsseJce.getCipher(algorithm); + this.cipher = Cipher.getInstance(algorithm); this.tagSize = sslCipher.tagSize; this.key = key; this.iv = ((IvParameterSpec)params).getIV(); diff --git a/src/java.base/share/classes/sun/security/ssl/SSLConfiguration.java b/src/java.base/share/classes/sun/security/ssl/SSLConfiguration.java index bd3dd3cb1b5..ec1ad625913 100644 --- a/src/java.base/share/classes/sun/security/ssl/SSLConfiguration.java +++ b/src/java.base/share/classes/sun/security/ssl/SSLConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -36,6 +36,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.function.BiFunction; +import javax.crypto.KeyGenerator; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.SNIMatcher; import javax.net.ssl.SNIServerName; @@ -104,7 +105,7 @@ final class SSLConfiguration implements Cloneable { "jdk.tls.useExtendedMasterSecret", true); if (supportExtendedMasterSecret) { try { - JsseJce.getKeyGenerator("SunTlsExtendedMasterSecret"); + KeyGenerator.getInstance("SunTlsExtendedMasterSecret"); } catch (NoSuchAlgorithmException nae) { supportExtendedMasterSecret = false; } diff --git a/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java b/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java index 6482c7a323f..f7b1095ace2 100644 --- a/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java +++ b/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2019, 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 @@ -94,14 +94,8 @@ public abstract class SSLContextImpl extends SSLContextSpi { trustManager = chooseTrustManager(tm); if (sr == null) { - secureRandom = JsseJce.getSecureRandom(); + secureRandom = new SecureRandom(); } else { - if (SunJSSE.isFIPS() && - (sr.getProvider() != SunJSSE.cryptoProvider)) { - throw new KeyManagementException - ("FIPS mode: SecureRandom must be from provider " - + SunJSSE.cryptoProvider.getName()); - } secureRandom = sr; } @@ -127,12 +121,6 @@ public abstract class SSLContextImpl extends SSLContextSpi { // We only use the first instance of X509TrustManager passed to us. for (int i = 0; tm != null && i < tm.length; i++) { if (tm[i] instanceof X509TrustManager) { - if (SunJSSE.isFIPS() && - !(tm[i] instanceof X509TrustManagerImpl)) { - throw new KeyManagementException - ("FIPS mode: only SunJSSE TrustManagers may be used"); - } - if (tm[i] instanceof X509ExtendedTrustManager) { return (X509TrustManager)tm[i]; } else { @@ -153,20 +141,7 @@ public abstract class SSLContextImpl extends SSLContextSpi { if (!(km instanceof X509KeyManager)) { continue; } - if (SunJSSE.isFIPS()) { - // In FIPS mode, require that one of SunJSSE's own keymanagers - // is used. Otherwise, we cannot be sure that only keys from - // the FIPS token are used. - if ((km instanceof X509KeyManagerImpl) - || (km instanceof SunX509KeyManagerImpl)) { - return (X509ExtendedKeyManager)km; - } else { - // throw exception, we don't want to silently use the - // dummy keymanager without telling the user. - throw new KeyManagementException - ("FIPS mode: only SunJSSE KeyManagers may be used"); - } - } + if (km instanceof X509ExtendedKeyManager) { return (X509ExtendedKeyManager)km; } @@ -548,41 +523,24 @@ public abstract class SSLContextImpl extends SSLContextSpi { private static final List serverDefaultCipherSuites; static { - if (SunJSSE.isFIPS()) { - supportedProtocols = Arrays.asList( - ProtocolVersion.TLS13, - ProtocolVersion.TLS12, - ProtocolVersion.TLS11, - ProtocolVersion.TLS10 - ); + supportedProtocols = Arrays.asList( + ProtocolVersion.TLS13, + ProtocolVersion.TLS12, + ProtocolVersion.TLS11, + ProtocolVersion.TLS10, + ProtocolVersion.SSL30, + ProtocolVersion.SSL20Hello + ); - serverDefaultProtocols = getAvailableProtocols( - new ProtocolVersion[] { - ProtocolVersion.TLS13, - ProtocolVersion.TLS12, - ProtocolVersion.TLS11, - ProtocolVersion.TLS10 - }); - } else { - supportedProtocols = Arrays.asList( - ProtocolVersion.TLS13, - ProtocolVersion.TLS12, - ProtocolVersion.TLS11, - ProtocolVersion.TLS10, - ProtocolVersion.SSL30, - ProtocolVersion.SSL20Hello - ); - - serverDefaultProtocols = getAvailableProtocols( - new ProtocolVersion[] { - ProtocolVersion.TLS13, - ProtocolVersion.TLS12, - ProtocolVersion.TLS11, - ProtocolVersion.TLS10, - ProtocolVersion.SSL30, - ProtocolVersion.SSL20Hello - }); - } + serverDefaultProtocols = getAvailableProtocols( + new ProtocolVersion[] { + ProtocolVersion.TLS13, + ProtocolVersion.TLS12, + ProtocolVersion.TLS11, + ProtocolVersion.TLS10, + ProtocolVersion.SSL30, + ProtocolVersion.SSL20Hello + }); supportedCipherSuites = getApplicableSupportedCipherSuites( supportedProtocols); @@ -626,23 +584,14 @@ public abstract class SSLContextImpl extends SSLContextSpi { } static ProtocolVersion[] getSupportedProtocols() { - if (SunJSSE.isFIPS()) { - return new ProtocolVersion[] { - ProtocolVersion.TLS13, - ProtocolVersion.TLS12, - ProtocolVersion.TLS11, - ProtocolVersion.TLS10 - }; - } else { - return new ProtocolVersion[]{ - ProtocolVersion.TLS13, - ProtocolVersion.TLS12, - ProtocolVersion.TLS11, - ProtocolVersion.TLS10, - ProtocolVersion.SSL30, - ProtocolVersion.SSL20Hello - }; - } + return new ProtocolVersion[]{ + ProtocolVersion.TLS13, + ProtocolVersion.TLS12, + ProtocolVersion.TLS11, + ProtocolVersion.TLS10, + ProtocolVersion.SSL30, + ProtocolVersion.SSL20Hello + }; } } @@ -656,18 +605,11 @@ public abstract class SSLContextImpl extends SSLContextSpi { private static final List clientDefaultCipherSuites; static { - if (SunJSSE.isFIPS()) { - clientDefaultProtocols = getAvailableProtocols( - new ProtocolVersion[] { - ProtocolVersion.TLS10 - }); - } else { - clientDefaultProtocols = getAvailableProtocols( - new ProtocolVersion[] { - ProtocolVersion.TLS10, - ProtocolVersion.SSL30 - }); - } + clientDefaultProtocols = getAvailableProtocols( + new ProtocolVersion[] { + ProtocolVersion.TLS10, + ProtocolVersion.SSL30 + }); clientDefaultCipherSuites = getApplicableEnabledCipherSuites( clientDefaultProtocols, true); @@ -694,20 +636,12 @@ public abstract class SSLContextImpl extends SSLContextSpi { private static final List clientDefaultCipherSuites; static { - if (SunJSSE.isFIPS()) { - clientDefaultProtocols = getAvailableProtocols( - new ProtocolVersion[] { - ProtocolVersion.TLS11, - ProtocolVersion.TLS10 - }); - } else { - clientDefaultProtocols = getAvailableProtocols( - new ProtocolVersion[] { - ProtocolVersion.TLS11, - ProtocolVersion.TLS10, - ProtocolVersion.SSL30 - }); - } + clientDefaultProtocols = getAvailableProtocols( + new ProtocolVersion[] { + ProtocolVersion.TLS11, + ProtocolVersion.TLS10, + ProtocolVersion.SSL30 + }); clientDefaultCipherSuites = getApplicableEnabledCipherSuites( clientDefaultProtocols, true); @@ -735,22 +669,13 @@ public abstract class SSLContextImpl extends SSLContextSpi { private static final List clientDefaultCipherSuites; static { - if (SunJSSE.isFIPS()) { - clientDefaultProtocols = getAvailableProtocols( - new ProtocolVersion[] { - ProtocolVersion.TLS12, - ProtocolVersion.TLS11, - ProtocolVersion.TLS10 - }); - } else { - clientDefaultProtocols = getAvailableProtocols( - new ProtocolVersion[] { - ProtocolVersion.TLS12, - ProtocolVersion.TLS11, - ProtocolVersion.TLS10, - ProtocolVersion.SSL30 - }); - } + clientDefaultProtocols = getAvailableProtocols( + new ProtocolVersion[] { + ProtocolVersion.TLS12, + ProtocolVersion.TLS11, + ProtocolVersion.TLS10, + ProtocolVersion.SSL30 + }); clientDefaultCipherSuites = getApplicableEnabledCipherSuites( clientDefaultProtocols, true); @@ -777,24 +702,14 @@ public abstract class SSLContextImpl extends SSLContextSpi { private static final List clientDefaultCipherSuites; static { - if (SunJSSE.isFIPS()) { - clientDefaultProtocols = getAvailableProtocols( - new ProtocolVersion[] { - ProtocolVersion.TLS13, - ProtocolVersion.TLS12, - ProtocolVersion.TLS11, - ProtocolVersion.TLS10 - }); - } else { - clientDefaultProtocols = getAvailableProtocols( - new ProtocolVersion[] { - ProtocolVersion.TLS13, - ProtocolVersion.TLS12, - ProtocolVersion.TLS11, - ProtocolVersion.TLS10, - ProtocolVersion.SSL30 - }); - } + clientDefaultProtocols = getAvailableProtocols( + new ProtocolVersion[] { + ProtocolVersion.TLS13, + ProtocolVersion.TLS12, + ProtocolVersion.TLS11, + ProtocolVersion.TLS10, + ProtocolVersion.SSL30 + }); clientDefaultCipherSuites = getApplicableEnabledCipherSuites( clientDefaultProtocols, true); @@ -866,16 +781,6 @@ public abstract class SSLContextImpl extends SSLContextSpi { " is not a supported SSL protocol name"); } - if (SunJSSE.isFIPS() && - ((pv == ProtocolVersion.SSL30) || - (pv == ProtocolVersion.SSL20Hello))) { - reservedException = new IllegalArgumentException( - propname + ": " + pv + - " is not FIPS compliant"); - - break; - } - // ignore duplicated protocols if (!arrayList.contains(pv)) { arrayList.add(pv); @@ -955,22 +860,13 @@ public abstract class SSLContextImpl extends SSLContextSpi { } static ProtocolVersion[] getProtocols() { - if (SunJSSE.isFIPS()) { - return new ProtocolVersion[]{ - ProtocolVersion.TLS13, - ProtocolVersion.TLS12, - ProtocolVersion.TLS11, - ProtocolVersion.TLS10 - }; - } else { - return new ProtocolVersion[]{ - ProtocolVersion.TLS13, - ProtocolVersion.TLS12, - ProtocolVersion.TLS11, - ProtocolVersion.TLS10, - ProtocolVersion.SSL30 - }; - } + return new ProtocolVersion[]{ + ProtocolVersion.TLS13, + ProtocolVersion.TLS12, + ProtocolVersion.TLS11, + ProtocolVersion.TLS10, + ProtocolVersion.SSL30 + }; } protected CustomizedTLSContext() { diff --git a/src/java.base/share/classes/sun/security/ssl/SSLMasterKeyDerivation.java b/src/java.base/share/classes/sun/security/ssl/SSLMasterKeyDerivation.java index fb91ec47d84..4ef4d3e7d63 100644 --- a/src/java.base/share/classes/sun/security/ssl/SSLMasterKeyDerivation.java +++ b/src/java.base/share/classes/sun/security/ssl/SSLMasterKeyDerivation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -145,7 +145,7 @@ enum SSLMasterKeyDerivation implements SSLKeyDerivationGenerator { } try { - KeyGenerator kg = JsseJce.getKeyGenerator(masterAlg); + KeyGenerator kg = KeyGenerator.getInstance(masterAlg); kg.init(spec); return kg.generateKey(); } catch (InvalidAlgorithmParameterException | diff --git a/src/java.base/share/classes/sun/security/ssl/SSLTrafficKeyDerivation.java b/src/java.base/share/classes/sun/security/ssl/SSLTrafficKeyDerivation.java index 4b02a82a701..90b021b878f 100644 --- a/src/java.base/share/classes/sun/security/ssl/SSLTrafficKeyDerivation.java +++ b/src/java.base/share/classes/sun/security/ssl/SSLTrafficKeyDerivation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -280,7 +280,7 @@ enum SSLTrafficKeyDerivation implements SSLKeyDerivationGenerator { hashAlg.name, hashAlg.hashLength, hashAlg.blockSize); try { - KeyGenerator kg = JsseJce.getKeyGenerator(keyMaterialAlg); + KeyGenerator kg = KeyGenerator.getInstance(keyMaterialAlg); kg.init(spec); this.keyMaterialSpec = (TlsKeyMaterialSpec)kg.generateKey(); diff --git a/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java b/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java index 3ca5cb87806..40c52678178 100644 --- a/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java +++ b/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -194,7 +194,7 @@ enum SignatureScheme { boolean mediator = true; try { - Signature signer = JsseJce.getSignature("RSASSA-PSS"); + Signature signer = Signature.getInstance("RSASSA-PSS"); signer.setParameter(pssParamSpec); } catch (InvalidAlgorithmParameterException | NoSuchAlgorithmException exp) { @@ -275,7 +275,7 @@ enum SignatureScheme { mediator = signAlgParamSpec.isAvailable; } else { try { - JsseJce.getSignature(algorithm); + Signature.getInstance(algorithm); } catch (Exception e) { mediator = false; if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { @@ -466,7 +466,7 @@ enum SignatureScheme { return null; } - Signature signer = JsseJce.getSignature(algorithm); + Signature signer = Signature.getInstance(algorithm); if (key instanceof PublicKey) { signer.initVerify((PublicKey)(key)); } else { diff --git a/src/java.base/share/classes/sun/security/ssl/SunJSSE.java b/src/java.base/share/classes/sun/security/ssl/SunJSSE.java index c50ba93ecfc..e1975b2a8f0 100644 --- a/src/java.base/share/classes/sun/security/ssl/SunJSSE.java +++ b/src/java.base/share/classes/sun/security/ssl/SunJSSE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2019, 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 @@ -66,97 +66,16 @@ public abstract class SunJSSE extends java.security.Provider { "(PKCS12, SunX509/PKIX key/trust factories, " + "SSLv3/TLSv1/TLSv1.1/TLSv1.2/TLSv1.3/DTLSv1.0/DTLSv1.2)"; - private static String fipsInfo = - "Sun JSSE provider (FIPS mode, crypto provider "; - - // tri-valued flag: - // null := no final decision made - // false := data structures initialized in non-FIPS mode - // true := data structures initialized in FIPS mode - private static Boolean fips; - - // the FIPS certificate crypto provider that we use to perform all crypto - // operations. null in non-FIPS mode - static java.security.Provider cryptoProvider; - - protected static synchronized boolean isFIPS() { - if (fips == null) { - fips = false; - } - return fips; - } - - // ensure we can use FIPS mode using the specified crypto provider. - // enable FIPS mode if not already enabled. - private static synchronized void ensureFIPS(java.security.Provider p) { - if (fips == null) { - fips = true; - cryptoProvider = p; - } else { - if (fips == false) { - throw new ProviderException - ("SunJSSE already initialized in non-FIPS mode"); - } - if (cryptoProvider != p) { - throw new ProviderException - ("SunJSSE already initialized with FIPS crypto provider " - + cryptoProvider); - } - } - } - - // standard constructor protected SunJSSE() { super("SunJSSE", PROVIDER_VER, info); subclassCheck(); - if (Boolean.TRUE.equals(fips)) { - throw new ProviderException - ("SunJSSE is already initialized in FIPS mode"); - } - registerAlgorithms(false); + registerAlgorithms(); } - // preferred constructor to enable FIPS mode at runtime - protected SunJSSE(java.security.Provider cryptoProvider){ - this(checkNull(cryptoProvider), cryptoProvider.getName()); - } - - // constructor to enable FIPS mode from java.security file - protected SunJSSE(String cryptoProvider){ - this(null, checkNull(cryptoProvider)); - } - - private static T checkNull(T t) { - if (t == null) { - throw new ProviderException("cryptoProvider must not be null"); - } - return t; - } - - private SunJSSE(java.security.Provider cryptoProvider, - String providerName) { - super("SunJSSE", PROVIDER_VER, fipsInfo + providerName + ")"); - subclassCheck(); - if (cryptoProvider == null) { - // Calling Security.getProvider() will cause other providers to be - // loaded. That is not good but unavoidable here. - cryptoProvider = Security.getProvider(providerName); - if (cryptoProvider == null) { - throw new ProviderException - ("Crypto provider not installed: " + providerName); - } - } - ensureFIPS(cryptoProvider); - registerAlgorithms(true); - } - - private void registerAlgorithms(final boolean isfips) { - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Object run() { - doRegister(isfips); - return null; - } + private void registerAlgorithms() { + AccessController.doPrivileged((PrivilegedAction) () -> { + doRegister(); + return null; }); } @@ -165,14 +84,13 @@ public abstract class SunJSSE extends java.security.Provider { putService(new Provider.Service(this, type, algo, cn, aliases, attrs)); } - private void doRegister(boolean isfips) { - if (isfips == false) { - Iterator rsaIter = - new SunRsaSignEntries(this).iterator(); - while (rsaIter.hasNext()) { - putService(rsaIter.next()); - } + private void doRegister() { + Iterator rsaIter = + new SunRsaSignEntries(this).iterator(); + while (rsaIter.hasNext()) { + putService(rsaIter.next()); } + ps("Signature", "MD5andSHA1withRSA", "sun.security.ssl.RSASignature", null, null); @@ -183,14 +101,15 @@ public abstract class SunJSSE extends java.security.Provider { createAliases("PKIX"), null); ps("TrustManagerFactory", "SunX509", - "sun.security.ssl.TrustManagerFactoryImpl$SimpleFactory", null, null); + "sun.security.ssl.TrustManagerFactoryImpl$SimpleFactory", + null, null); ps("TrustManagerFactory", "PKIX", "sun.security.ssl.TrustManagerFactoryImpl$PKIXFactory", createAliases("SunPKIX", "X509", "X.509"), null); ps("SSLContext", "TLSv1", "sun.security.ssl.SSLContextImpl$TLS10Context", - (isfips? null : createAliases("SSLv3")), null); + createAliases("SSLv3"), null); ps("SSLContext", "TLSv1.1", "sun.security.ssl.SSLContextImpl$TLS11Context", null, null); ps("SSLContext", "TLSv1.2", @@ -199,7 +118,7 @@ public abstract class SunJSSE extends java.security.Provider { "sun.security.ssl.SSLContextImpl$TLS13Context", null, null); ps("SSLContext", "TLS", "sun.security.ssl.SSLContextImpl$TLSContext", - (isfips? null : createAliases("SSL")), null); + createAliases("SSL"), null); ps("SSLContext", "DTLSv1.0", "sun.security.ssl.SSLContextImpl$DTLS10Context", null, null); @@ -225,12 +144,4 @@ public abstract class SunJSSE extends java.security.Provider { throw new AssertionError("Illegal subclass: " + getClass()); } } - - @Override - @SuppressWarnings("deprecation") - protected final void finalize() throws Throwable { - // empty - super.finalize(); - } - } diff --git a/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java b/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java index 1044b6d13de..e0125c2d21c 100644 --- a/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java +++ b/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -52,6 +52,7 @@ import static sun.security.ssl.SSLExtension.EE_SUPPORTED_GROUPS; import sun.security.ssl.SSLExtension.ExtensionConsumer; import sun.security.ssl.SSLExtension.SSLExtensionSpec; import sun.security.ssl.SSLHandshake.HandshakeMessage; +import sun.security.util.ECUtil; /** * Pack of the "supported_groups" extensions [RFC 4492/7919]. @@ -158,15 +159,23 @@ final class SupportedGroupsExtension { } static enum NamedGroupType { - NAMED_GROUP_ECDHE, // Elliptic Curve Groups (ECDHE) - NAMED_GROUP_FFDHE, // Finite Field Groups (DHE) - NAMED_GROUP_XDH, // Finite Field Groups (XDH) - NAMED_GROUP_ARBITRARY, // arbitrary prime and curves (ECDHE) - NAMED_GROUP_NONE; // Not predefined named group + NAMED_GROUP_ECDHE ("EC"), + NAMED_GROUP_FFDHE ("DiffieHellman"), + NAMED_GROUP_X25519 ("x25519"), + NAMED_GROUP_X448 ("x448"), + NAMED_GROUP_ARBITRARY ("EC"), + NAMED_GROUP_NONE (""); + + private final String algorithm; + + private NamedGroupType(String algorithm) { + this.algorithm = algorithm; + } boolean isSupported(List cipherSuites) { for (CipherSuite cs : cipherSuites) { - if (cs.keyExchange == null || cs.keyExchange.groupType == this) { + if (cs.keyExchange == null || + cs.keyExchange.groupType == this) { return true; } } @@ -180,108 +189,142 @@ final class SupportedGroupsExtension { // // See sun.security.util.CurveDB for the OIDs // NIST K-163 - SECT163_K1 (0x0001, "sect163k1", "1.3.132.0.1", true, + SECT163_K1 (0x0001, "sect163k1", "1.3.132.0.1", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), - SECT163_R1 (0x0002, "sect163r1", "1.3.132.0.2", false, + SECT163_R1 (0x0002, "sect163r1", "1.3.132.0.2", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), // NIST B-163 - SECT163_R2 (0x0003, "sect163r2", "1.3.132.0.15", true, + SECT163_R2 (0x0003, "sect163r2", "1.3.132.0.15", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), - SECT193_R1 (0x0004, "sect193r1", "1.3.132.0.24", false, + SECT193_R1 (0x0004, "sect193r1", "1.3.132.0.24", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), - SECT193_R2 (0x0005, "sect193r2", "1.3.132.0.25", false, + SECT193_R2 (0x0005, "sect193r2", "1.3.132.0.25", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), // NIST K-233 - SECT233_K1 (0x0006, "sect233k1", "1.3.132.0.26", true, + SECT233_K1 (0x0006, "sect233k1", "1.3.132.0.26", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), // NIST B-233 - SECT233_R1 (0x0007, "sect233r1", "1.3.132.0.27", true, + SECT233_R1 (0x0007, "sect233r1", "1.3.132.0.27", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), - SECT239_K1 (0x0008, "sect239k1", "1.3.132.0.3", false, + SECT239_K1 (0x0008, "sect239k1", "1.3.132.0.3", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), // NIST K-283 - SECT283_K1 (0x0009, "sect283k1", "1.3.132.0.16", true, + SECT283_K1 (0x0009, "sect283k1", "1.3.132.0.16", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), // NIST B-283 - SECT283_R1 (0x000A, "sect283r1", "1.3.132.0.17", true, + SECT283_R1 (0x000A, "sect283r1", "1.3.132.0.17", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), // NIST K-409 - SECT409_K1 (0x000B, "sect409k1", "1.3.132.0.36", true, + SECT409_K1 (0x000B, "sect409k1", "1.3.132.0.36", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), // NIST B-409 - SECT409_R1 (0x000C, "sect409r1", "1.3.132.0.37", true, + SECT409_R1 (0x000C, "sect409r1", "1.3.132.0.37", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), // NIST K-571 - SECT571_K1 (0x000D, "sect571k1", "1.3.132.0.38", true, + SECT571_K1 (0x000D, "sect571k1", "1.3.132.0.38", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), // NIST B-571 - SECT571_R1 (0x000E, "sect571r1", "1.3.132.0.39", true, + SECT571_R1 (0x000E, "sect571r1", "1.3.132.0.39", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), - SECP160_K1 (0x000F, "secp160k1", "1.3.132.0.9", false, + SECP160_K1 (0x000F, "secp160k1", "1.3.132.0.9", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), - SECP160_R1 (0x0010, "secp160r1", "1.3.132.0.8", false, + SECP160_R1 (0x0010, "secp160r1", "1.3.132.0.8", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), - SECP160_R2 (0x0011, "secp160r2", "1.3.132.0.30", false, + SECP160_R2 (0x0011, "secp160r2", "1.3.132.0.30", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), - SECP192_K1 (0x0012, "secp192k1", "1.3.132.0.31", false, + SECP192_K1 (0x0012, "secp192k1", "1.3.132.0.31", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), // NIST P-192 - SECP192_R1 (0x0013, "secp192r1", "1.2.840.10045.3.1.1", true, + SECP192_R1 (0x0013, "secp192r1", "1.2.840.10045.3.1.1", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), - SECP224_K1 (0x0014, "secp224k1", "1.3.132.0.32", false, + SECP224_K1 (0x0014, "secp224k1", "1.3.132.0.32", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), // NIST P-224 - SECP224_R1 (0x0015, "secp224r1", "1.3.132.0.33", true, + SECP224_R1 (0x0015, "secp224r1", "1.3.132.0.33", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), - SECP256_K1 (0x0016, "secp256k1", "1.3.132.0.10", false, + SECP256_K1 (0x0016, "secp256k1", "1.3.132.0.10", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_12), // NIST P-256 - SECP256_R1 (0x0017, "secp256r1", "1.2.840.10045.3.1.7", true, + SECP256_R1 (0x0017, "secp256r1", "1.2.840.10045.3.1.7", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_13), // NIST P-384 - SECP384_R1 (0x0018, "secp384r1", "1.3.132.0.34", true, + SECP384_R1 (0x0018, "secp384r1", "1.3.132.0.34", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_13), // NIST P-521 - SECP521_R1 (0x0019, "secp521r1", "1.3.132.0.35", true, + SECP521_R1 (0x0019, "secp521r1", "1.3.132.0.35", + NamedGroupType.NAMED_GROUP_ECDHE, ProtocolVersion.PROTOCOLS_TO_13), // x25519 and x448 - X25519 (0x001D, "x25519", true, "x25519", + X25519 (0x001D, "x25519", null, + NamedGroupType.NAMED_GROUP_X25519, ProtocolVersion.PROTOCOLS_TO_13), - X448 (0x001E, "x448", true, "x448", + X448 (0x001E, "x448", null, + NamedGroupType.NAMED_GROUP_X448, ProtocolVersion.PROTOCOLS_TO_13), // Finite Field Diffie-Hellman Ephemeral Parameters (RFC 7919) - FFDHE_2048 (0x0100, "ffdhe2048", true, + FFDHE_2048 (0x0100, "ffdhe2048", null, + NamedGroupType.NAMED_GROUP_FFDHE, ProtocolVersion.PROTOCOLS_TO_13), - FFDHE_3072 (0x0101, "ffdhe3072", true, + FFDHE_3072 (0x0101, "ffdhe3072", null, + NamedGroupType.NAMED_GROUP_FFDHE, ProtocolVersion.PROTOCOLS_TO_13), - FFDHE_4096 (0x0102, "ffdhe4096", true, + FFDHE_4096 (0x0102, "ffdhe4096", null, + NamedGroupType.NAMED_GROUP_FFDHE, ProtocolVersion.PROTOCOLS_TO_13), - FFDHE_6144 (0x0103, "ffdhe6144", true, + FFDHE_6144 (0x0103, "ffdhe6144", null, + NamedGroupType.NAMED_GROUP_FFDHE, ProtocolVersion.PROTOCOLS_TO_13), - FFDHE_8192 (0x0104, "ffdhe8192", true, + FFDHE_8192 (0x0104, "ffdhe8192", null, + NamedGroupType.NAMED_GROUP_FFDHE, ProtocolVersion.PROTOCOLS_TO_13), // Elliptic Curves (RFC 4492) // // arbitrary prime and characteristic-2 curves - ARBITRARY_PRIME (0xFF01, "arbitrary_explicit_prime_curves", + ARBITRARY_PRIME (0xFF01, "arbitrary_explicit_prime_curves", null, + NamedGroupType.NAMED_GROUP_ARBITRARY, ProtocolVersion.PROTOCOLS_TO_12), - ARBITRARY_CHAR2 (0xFF02, "arbitrary_explicit_char2_curves", + ARBITRARY_CHAR2 (0xFF02, "arbitrary_explicit_char2_curves", null, + NamedGroupType.NAMED_GROUP_ARBITRARY, ProtocolVersion.PROTOCOLS_TO_12); final int id; // hash + signature @@ -289,55 +332,16 @@ final class SupportedGroupsExtension { final String name; // literal name final String oid; // object identifier of the named group final String algorithm; // signature algorithm - final boolean isFips; // can be used in FIPS mode? final ProtocolVersion[] supportedProtocols; - // Constructor used for Elliptic Curve Groups (ECDHE) - private NamedGroup(int id, String name, String oid, boolean isFips, + private NamedGroup(int id, String name, String oid, + NamedGroupType namedGroupType, ProtocolVersion[] supportedProtocols) { this.id = id; - this.type = NamedGroupType.NAMED_GROUP_ECDHE; + this.type = namedGroupType; this.name = name; this.oid = oid; - this.algorithm = "EC"; - this.isFips = isFips; - this.supportedProtocols = supportedProtocols; - } - - // Constructor used for Elliptic Curve Groups (XDH) - private NamedGroup(int id, String name, - boolean isFips, String algorithm, - ProtocolVersion[] supportedProtocols) { - this.id = id; - this.type = NamedGroupType.NAMED_GROUP_XDH; - this.name = name; - this.oid = null; - this.algorithm = algorithm; - this.isFips = isFips; - this.supportedProtocols = supportedProtocols; - } - - // Constructor used for Finite Field Diffie-Hellman Groups (FFDHE) - private NamedGroup(int id, String name, boolean isFips, - ProtocolVersion[] supportedProtocols) { - this.id = id; - this.type = NamedGroupType.NAMED_GROUP_FFDHE; - this.name = name; - this.oid = null; - this.algorithm = "DiffieHellman"; - this.isFips = isFips; - this.supportedProtocols = supportedProtocols; - } - - // Constructor used for arbitrary prime and curves (ECDHE) - private NamedGroup(int id, String name, - ProtocolVersion[] supportedProtocols) { - this.id = id; - this.type = NamedGroupType.NAMED_GROUP_ARBITRARY; - this.name = name; - this.oid = null; - this.algorithm = "EC"; - this.isFips = false; + this.algorithm = namedGroupType.algorithm; this.supportedProtocols = supportedProtocols; } @@ -352,7 +356,7 @@ final class SupportedGroupsExtension { } static NamedGroup valueOf(ECParameterSpec params) { - String oid = JsseJce.getNamedCurveOid(params); + String oid = ECUtil.getCurveName(null, params); if ((oid != null) && (!oid.isEmpty())) { for (NamedGroup group : NamedGroup.values()) { if ((group.type == NamedGroupType.NAMED_GROUP_ECDHE) && @@ -472,8 +476,6 @@ final class SupportedGroupsExtension { static final NamedGroup[] supportedNamedGroups; static { - boolean requireFips = SunJSSE.isFIPS(); - // The value of the System Property defines a list of enabled named // groups in preference order, separated with comma. For example: // @@ -499,8 +501,7 @@ final class SupportedGroupsExtension { group = group.trim(); if (!group.isEmpty()) { NamedGroup namedGroup = NamedGroup.nameOf(group); - if (namedGroup != null && - (!requireFips || namedGroup.isFips)) { + if (namedGroup != null) { if (isAvailableGroup(namedGroup)) { groupList.add(namedGroup); } @@ -514,29 +515,7 @@ final class SupportedGroupsExtension { property + ") contains no supported named groups"); } } else { // default groups - NamedGroup[] groups; - if (requireFips) { - groups = new NamedGroup[] { - // only NIST curves in FIPS mode - NamedGroup.SECP256_R1, - NamedGroup.SECP384_R1, - NamedGroup.SECP521_R1, - NamedGroup.SECT283_K1, - NamedGroup.SECT283_R1, - NamedGroup.SECT409_K1, - NamedGroup.SECT409_R1, - NamedGroup.SECT571_K1, - NamedGroup.SECT571_R1, - - // FFDHE 2048 - NamedGroup.FFDHE_2048, - NamedGroup.FFDHE_3072, - NamedGroup.FFDHE_4096, - NamedGroup.FFDHE_6144, - NamedGroup.FFDHE_8192, - }; - } else { - groups = new NamedGroup[] { + NamedGroup[] groups = new NamedGroup[] { // NIST curves first NamedGroup.SECP256_R1, NamedGroup.SECP384_R1, @@ -558,7 +537,6 @@ final class SupportedGroupsExtension { NamedGroup.FFDHE_6144, NamedGroup.FFDHE_8192, }; - } groupList = new ArrayList<>(groups.length); for (NamedGroup group : groups) { @@ -587,7 +565,7 @@ final class SupportedGroupsExtension { if (namedGroup.type == NamedGroupType.NAMED_GROUP_ECDHE) { if (namedGroup.oid != null) { try { - params = JsseJce.getAlgorithmParameters("EC"); + params = AlgorithmParameters.getInstance("EC"); spec = new ECGenParameterSpec(namedGroup.oid); } catch (NoSuchAlgorithmException e) { return false; @@ -595,7 +573,7 @@ final class SupportedGroupsExtension { } } else if (namedGroup.type == NamedGroupType.NAMED_GROUP_FFDHE) { try { - params = JsseJce.getAlgorithmParameters("DiffieHellman"); + params = AlgorithmParameters.getInstance("DiffieHellman"); spec = getFFDHEDHParameterSpec(namedGroup); } catch (NoSuchAlgorithmException e) { return false; diff --git a/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java b/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java index a891c53894b..9e5d9665160 100644 --- a/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java +++ b/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -218,7 +218,7 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager responseList = ((ExtendedSSLSession)session).getStatusResponses(); } - trustedChain = validate(v, chain, responseList, + trustedChain = v.validate(chain, null, responseList, constraints, isClient ? null : authType); // check if EE certificate chains to a public root CA (as @@ -234,7 +234,7 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager getRequestedServerNames(socket), chainsToPublicCA); } } else { - trustedChain = validate(v, chain, Collections.emptyList(), + trustedChain = v.validate(chain, null, Collections.emptyList(), null, isClient ? null : authType); } @@ -276,7 +276,7 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager responseList = ((ExtendedSSLSession)session).getStatusResponses(); } - trustedChain = validate(v, chain, responseList, + trustedChain = v.validate(chain, null, responseList, constraints, isClient ? null : authType); // check if EE certificate chains to a public root CA (as @@ -292,7 +292,7 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager getRequestedServerNames(engine), chainsToPublicCA); } } else { - trustedChain = validate(v, chain, Collections.emptyList(), + trustedChain = v.validate(chain, null, Collections.emptyList(), null, isClient ? null : authType); } @@ -312,18 +312,6 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager return v; } - private static X509Certificate[] validate(Validator v, - X509Certificate[] chain, List responseList, - AlgorithmConstraints constraints, String authType) - throws CertificateException { - Object o = JsseJce.beginFipsProvider(); - try { - return v.validate(chain, null, responseList, constraints, authType); - } finally { - JsseJce.endFipsProvider(o); - } - } - // Get string representation of HostName from a list of server names. // // We are only accepting host_name name type in the list. diff --git a/test/jdk/sun/security/pkcs11/fips/CipherTest.java b/test/jdk/sun/security/pkcs11/fips/CipherTest.java deleted file mode 100644 index dd627d356b5..00000000000 --- a/test/jdk/sun/security/pkcs11/fips/CipherTest.java +++ /dev/null @@ -1,608 +0,0 @@ -/* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.io.*; -import java.net.*; -import java.util.*; -import java.util.concurrent.*; - -import java.security.*; -import java.security.cert.*; -import java.security.cert.Certificate; - -import javax.net.ssl.*; - -/** - * Test that all ciphersuites work in all versions and all client - * authentication types. The way this is setup the server is stateless and - * all checking is done on the client side. - * - * The test is multithreaded to speed it up, especially on multiprocessor - * machines. To simplify debugging, run with -DnumThreads=1. - * - * @author Andreas Sterbenz - */ -public class CipherTest { - - // use any available port for the server socket - static int serverPort = 0; - - final int THREADS; - - // assume that if we do not read anything for 20 seconds, something - // has gone wrong - final static int TIMEOUT = 20 * 1000; - - static KeyStore /* trustStore, */ keyStore; - static X509ExtendedKeyManager keyManager; - static X509TrustManager trustManager; - static SecureRandom secureRandom; - - private static PeerFactory peerFactory; - - static abstract class Server implements Runnable { - - final CipherTest cipherTest; - - Server(CipherTest cipherTest) throws Exception { - this.cipherTest = cipherTest; - } - - public abstract void run(); - - void handleRequest(InputStream in, OutputStream out) throws IOException { - boolean newline = false; - StringBuilder sb = new StringBuilder(); - while (true) { - int ch = in.read(); - if (ch < 0) { - throw new EOFException(); - } - sb.append((char)ch); - if (ch == '\r') { - // empty - } else if (ch == '\n') { - if (newline) { - // 2nd newline in a row, end of request - break; - } - newline = true; - } else { - newline = false; - } - } - String request = sb.toString(); - if (request.startsWith("GET / HTTP/1.") == false) { - throw new IOException("Invalid request: " + request); - } - out.write("HTTP/1.0 200 OK\r\n\r\n".getBytes()); - } - - } - - public static class TestParameters { - - String cipherSuite; - String protocol; - String clientAuth; - - TestParameters(String cipherSuite, String protocol, - String clientAuth) { - this.cipherSuite = cipherSuite; - this.protocol = protocol; - this.clientAuth = clientAuth; - } - - boolean isEnabled() { - return TLSCipherStatus.isEnabled(cipherSuite, protocol); - } - - public String toString() { - String s = cipherSuite + " in " + protocol + " mode"; - if (clientAuth != null) { - s += " with " + clientAuth + " client authentication"; - } - return s; - } - - static enum TLSCipherStatus { - // cipher suites supported since TLS 1.2 - CS_01("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF), - CS_02("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF), - CS_03("TLS_RSA_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF), - CS_04("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF), - CS_05("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF), - CS_06("TLS_DHE_RSA_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF), - CS_07("TLS_DHE_DSS_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF), - - CS_08("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF), - CS_09("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF), - CS_10("TLS_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF), - CS_11("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF), - CS_12("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF), - CS_13("TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF), - CS_14("TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF), - - CS_15("TLS_DH_anon_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF), - CS_16("TLS_DH_anon_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF), - CS_17("TLS_RSA_WITH_NULL_SHA256", 0x0303, 0xFFFF), - - CS_20("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", 0x0303, 0xFFFF), - CS_21("TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", 0x0303, 0xFFFF), - CS_22("TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", 0x0303, 0xFFFF), - CS_23("TLS_RSA_WITH_AES_256_GCM_SHA384", 0x0303, 0xFFFF), - CS_24("TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384", 0x0303, 0xFFFF), - CS_25("TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384", 0x0303, 0xFFFF), - CS_26("TLS_DHE_RSA_WITH_AES_256_GCM_SHA384", 0x0303, 0xFFFF), - CS_27("TLS_DHE_DSS_WITH_AES_256_GCM_SHA384", 0x0303, 0xFFFF), - - CS_28("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", 0x0303, 0xFFFF), - CS_29("TLS_RSA_WITH_AES_128_GCM_SHA256", 0x0303, 0xFFFF), - CS_30("TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256", 0x0303, 0xFFFF), - CS_31("TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256", 0x0303, 0xFFFF), - CS_32("TLS_DHE_RSA_WITH_AES_128_GCM_SHA256", 0x0303, 0xFFFF), - CS_33("TLS_DHE_DSS_WITH_AES_128_GCM_SHA256", 0x0303, 0xFFFF), - - CS_34("TLS_DH_anon_WITH_AES_256_GCM_SHA384", 0x0303, 0xFFFF), - CS_35("TLS_DH_anon_WITH_AES_128_GCM_SHA256", 0x0303, 0xFFFF), - - // cipher suites obsoleted since TLS 1.2 - CS_50("SSL_RSA_WITH_DES_CBC_SHA", 0x0000, 0x0303), - CS_51("SSL_DHE_RSA_WITH_DES_CBC_SHA", 0x0000, 0x0303), - CS_52("SSL_DHE_DSS_WITH_DES_CBC_SHA", 0x0000, 0x0303), - CS_53("SSL_DH_anon_WITH_DES_CBC_SHA", 0x0000, 0x0303), - CS_54("TLS_KRB5_WITH_DES_CBC_SHA", 0x0000, 0x0303), - CS_55("TLS_KRB5_WITH_DES_CBC_MD5", 0x0000, 0x0303), - - // cipher suites obsoleted since TLS 1.1 - CS_60("SSL_RSA_EXPORT_WITH_RC4_40_MD5", 0x0000, 0x0302), - CS_61("SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", 0x0000, 0x0302), - CS_62("SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302), - CS_63("SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302), - CS_64("SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302), - CS_65("SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302), - CS_66("TLS_KRB5_EXPORT_WITH_RC4_40_SHA", 0x0000, 0x0302), - CS_67("TLS_KRB5_EXPORT_WITH_RC4_40_MD5", 0x0000, 0x0302), - CS_68("TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA", 0x0000, 0x0302), - CS_69("TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5", 0x0000, 0x0302), - - // ignore TLS_EMPTY_RENEGOTIATION_INFO_SCSV always - CS_99("TLS_EMPTY_RENEGOTIATION_INFO_SCSV", 0xFFFF, 0x0000); - - // the cipher suite name - final String cipherSuite; - - // supported since protocol version - final int supportedSince; - - // obsoleted since protocol version - final int obsoletedSince; - - TLSCipherStatus(String cipherSuite, - int supportedSince, int obsoletedSince) { - this.cipherSuite = cipherSuite; - this.supportedSince = supportedSince; - this.obsoletedSince = obsoletedSince; - } - - static boolean isEnabled(String cipherSuite, String protocol) { - int versionNumber = toVersionNumber(protocol); - - if (versionNumber < 0) { - return true; // unlikely to happen - } - - for (TLSCipherStatus status : TLSCipherStatus.values()) { - if (cipherSuite.equals(status.cipherSuite)) { - if ((versionNumber < status.supportedSince) || - (versionNumber >= status.obsoletedSince)) { - return false; - } - - return true; - } - } - - return true; - } - - private static int toVersionNumber(String protocol) { - int versionNumber = -1; - - switch (protocol) { - case "SSLv2Hello": - versionNumber = 0x0002; - break; - case "SSLv3": - versionNumber = 0x0300; - break; - case "TLSv1": - versionNumber = 0x0301; - break; - case "TLSv1.1": - versionNumber = 0x0302; - break; - case "TLSv1.2": - versionNumber = 0x0303; - break; - default: - // unlikely to happen - } - - return versionNumber; - } - } - } - - private List tests; - private Iterator testIterator; - private SSLSocketFactory factory; - private boolean failed; - - private CipherTest(PeerFactory peerFactory) throws IOException { - THREADS = Integer.parseInt(System.getProperty("numThreads", "4")); - factory = (SSLSocketFactory)SSLSocketFactory.getDefault(); - SSLSocket socket = (SSLSocket)factory.createSocket(); - String[] cipherSuites = socket.getSupportedCipherSuites(); - String[] protocols = socket.getSupportedProtocols(); -// String[] clientAuths = {null, "RSA", "DSA"}; - String[] clientAuths = {null}; - tests = new ArrayList( - cipherSuites.length * protocols.length * clientAuths.length); - for (int i = 0; i < cipherSuites.length; i++) { - String cipherSuite = cipherSuites[i]; - - for (int j = 0; j < protocols.length; j++) { - String protocol = protocols[j]; - - if (!peerFactory.isSupported(cipherSuite, protocol)) { - continue; - } - - for (int k = 0; k < clientAuths.length; k++) { - String clientAuth = clientAuths[k]; - if ((clientAuth != null) && - (cipherSuite.indexOf("DH_anon") != -1)) { - // no client with anonymous ciphersuites - continue; - } - tests.add(new TestParameters(cipherSuite, protocol, - clientAuth)); - } - } - } - testIterator = tests.iterator(); - } - - synchronized void setFailed() { - failed = true; - } - - public void run() throws Exception { - Thread[] threads = new Thread[THREADS]; - for (int i = 0; i < THREADS; i++) { - try { - threads[i] = new Thread(peerFactory.newClient(this), - "Client " + i); - } catch (Exception e) { - e.printStackTrace(); - return; - } - threads[i].start(); - } - try { - for (int i = 0; i < THREADS; i++) { - threads[i].join(); - } - } catch (InterruptedException e) { - setFailed(); - e.printStackTrace(); - } - if (failed) { - throw new Exception("*** Test '" + peerFactory.getName() + - "' failed ***"); - } else { - System.out.println("Test '" + peerFactory.getName() + - "' completed successfully"); - } - } - - synchronized TestParameters getTest() { - if (failed) { - return null; - } - if (testIterator.hasNext()) { - return (TestParameters)testIterator.next(); - } - return null; - } - - SSLSocketFactory getFactory() { - return factory; - } - - static abstract class Client implements Runnable { - - final CipherTest cipherTest; - - Client(CipherTest cipherTest) throws Exception { - this.cipherTest = cipherTest; - } - - public final void run() { - while (true) { - TestParameters params = cipherTest.getTest(); - if (params == null) { - // no more tests - break; - } - if (params.isEnabled() == false) { - System.out.println("Skipping disabled test " + params); - continue; - } - try { - runTest(params); - System.out.println("Passed " + params); - } catch (Exception e) { - cipherTest.setFailed(); - System.out.println("** Failed " + params + "**"); - e.printStackTrace(); - } - } - } - - abstract void runTest(TestParameters params) throws Exception; - - void sendRequest(InputStream in, OutputStream out) throws IOException { - out.write("GET / HTTP/1.0\r\n\r\n".getBytes()); - out.flush(); - StringBuilder sb = new StringBuilder(); - while (true) { - int ch = in.read(); - if (ch < 0) { - break; - } - sb.append((char)ch); - } - String response = sb.toString(); - if (response.startsWith("HTTP/1.0 200 ") == false) { - throw new IOException("Invalid response: " + response); - } - } - - } - - // for some reason, ${test.src} has a different value when the - // test is called from the script and when it is called directly... - static String pathToStores = "."; - static String pathToStoresSH = "."; - static String keyStoreFile = "keystore"; - static String trustStoreFile = "truststore"; - static char[] passwd = "passphrase".toCharArray(); - - static File PATH; - - private static KeyStore readKeyStore(String name) throws Exception { - File file = new File(PATH, name); - InputStream in = new FileInputStream(file); - KeyStore ks = KeyStore.getInstance("JKS"); - ks.load(in, passwd); - in.close(); - return ks; - } - - public static void main(PeerFactory peerFactory, KeyStore keyStore, - String[] args) throws Exception { - long time = System.currentTimeMillis(); - String relPath; - if ((args != null) && (args.length > 0) && args[0].equals("sh")) { - relPath = pathToStoresSH; - } else { - relPath = pathToStores; - } - PATH = new File(System.getProperty("test.src", "."), relPath); - CipherTest.peerFactory = peerFactory; - System.out.print( - "Initializing test '" + peerFactory.getName() + "'..."); -// secureRandom = new SecureRandom(); -// secureRandom.nextInt(); -// trustStore = readKeyStore(trustStoreFile); - CipherTest.keyStore = keyStore; -// keyStore = readKeyStore(keyStoreFile); - KeyManagerFactory keyFactory = - KeyManagerFactory.getInstance( - KeyManagerFactory.getDefaultAlgorithm()); - keyFactory.init(keyStore, "test12".toCharArray()); - keyManager = (X509ExtendedKeyManager)keyFactory.getKeyManagers()[0]; - - TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - tmf.init(keyStore); - trustManager = (X509TrustManager)tmf.getTrustManagers()[0]; - -// trustManager = new AlwaysTrustManager(); - SSLContext context = SSLContext.getInstance("TLS"); - context.init(new KeyManager[] {keyManager}, - new TrustManager[] {trustManager}, null); - SSLContext.setDefault(context); - - CipherTest cipherTest = new CipherTest(peerFactory); - Thread serverThread = new Thread(peerFactory.newServer(cipherTest), - "Server"); - serverThread.setDaemon(true); - serverThread.start(); - System.out.println("Done"); - cipherTest.run(); - time = System.currentTimeMillis() - time; - System.out.println("Done. (" + time + " ms)"); - } - - static abstract class PeerFactory { - - abstract String getName(); - - abstract Client newClient(CipherTest cipherTest) throws Exception; - - abstract Server newServer(CipherTest cipherTest) throws Exception; - - boolean isSupported(String cipherSuite, String protocol) { - // skip kerberos cipher suites - if (cipherSuite.startsWith("TLS_KRB5")) { - System.out.println("Skipping unsupported test for " + - cipherSuite + " of " + protocol); - return false; - } - - // No ECDH-capable certificate in key store. May restructure - // this in the future. - if (cipherSuite.contains("ECDHE_ECDSA") || - cipherSuite.contains("ECDH_ECDSA") || - cipherSuite.contains("ECDH_RSA")) { - System.out.println("Skipping unsupported test for " + - cipherSuite + " of " + protocol); - return false; - } - - // skip SSLv2Hello protocol - // - // skip TLSv1.2 protocol, we have not implement "SunTls12Prf" and - // SunTls12RsaPremasterSecret in SunPKCS11 provider - if (protocol.equals("SSLv2Hello") || protocol.equals("TLSv1.2")) { - System.out.println("Skipping unsupported test for " + - cipherSuite + " of " + protocol); - return false; - } - - // ignore exportable cipher suite for TLSv1.1 - if (protocol.equals("TLSv1.1")) { - if (cipherSuite.indexOf("_EXPORT_WITH") != -1) { - System.out.println("Skipping obsoleted test for " + - cipherSuite + " of " + protocol); - return false; - } - } - - return true; - } - } - -} - -// we currently don't do any chain verification. we assume that works ok -// and we can speed up the test. we could also just add a plain certificate -// chain comparision with our trusted certificates. -class AlwaysTrustManager implements X509TrustManager { - - public AlwaysTrustManager() { - - } - - public void checkClientTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - // empty - } - - public void checkServerTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - // empty - } - - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } -} - -class MyX509KeyManager extends X509ExtendedKeyManager { - - private final X509ExtendedKeyManager keyManager; - private String authType; - - MyX509KeyManager(X509ExtendedKeyManager keyManager) { - this.keyManager = keyManager; - } - - void setAuthType(String authType) { - this.authType = authType; - } - - public String[] getClientAliases(String keyType, Principal[] issuers) { - if (authType == null) { - return null; - } - return keyManager.getClientAliases(authType, issuers); - } - - public String chooseClientAlias(String[] keyType, Principal[] issuers, - Socket socket) { - if (authType == null) { - return null; - } - return keyManager.chooseClientAlias(new String[] {authType}, - issuers, socket); - } - - public String chooseEngineClientAlias(String[] keyType, - Principal[] issuers, SSLEngine engine) { - if (authType == null) { - return null; - } - return keyManager.chooseEngineClientAlias(new String[] {authType}, - issuers, engine); - } - - public String[] getServerAliases(String keyType, Principal[] issuers) { - throw new UnsupportedOperationException("Servers not supported"); - } - - public String chooseServerAlias(String keyType, Principal[] issuers, - Socket socket) { - throw new UnsupportedOperationException("Servers not supported"); - } - - public String chooseEngineServerAlias(String keyType, Principal[] issuers, - SSLEngine engine) { - throw new UnsupportedOperationException("Servers not supported"); - } - - public X509Certificate[] getCertificateChain(String alias) { - return keyManager.getCertificateChain(alias); - } - - public PrivateKey getPrivateKey(String alias) { - return keyManager.getPrivateKey(alias); - } - -} - -class DaemonThreadFactory implements ThreadFactory { - - final static ThreadFactory INSTANCE = new DaemonThreadFactory(); - - private final static ThreadFactory DEFAULT = Executors.defaultThreadFactory(); - - public Thread newThread(Runnable r) { - Thread t = DEFAULT.newThread(r); - t.setDaemon(true); - return t; - } - -} diff --git a/test/jdk/sun/security/pkcs11/fips/ClientJSSEServerJSSE.java b/test/jdk/sun/security/pkcs11/fips/ClientJSSEServerJSSE.java deleted file mode 100644 index eb775b8cd53..00000000000 --- a/test/jdk/sun/security/pkcs11/fips/ClientJSSEServerJSSE.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2002, 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. - */ - -/* - * @test - * @bug 6313675 6323647 8028192 - * @summary Verify that all ciphersuites work in FIPS mode - * @library /test/lib .. - * @author Andreas Sterbenz - * @modules java.base/com.sun.net.ssl.internal.ssl - * @run main/manual ClientJSSEServerJSSE - */ - -/* - * JSSE supported cipher suites are changed with CR 6916074, - * need to update this test case in JDK 7 soon - */ - -import java.security.*; - -// This test belongs more in JSSE than here, but the JSSE workspace does not -// have the NSS test infrastructure. It will live here for the time being. - -public class ClientJSSEServerJSSE extends SecmodTest { - - public static void main(String[] args) throws Exception { - if (initSecmod() == false) { - return; - } - - String arch = System.getProperty("os.arch"); - if (!("sparc".equals(arch) || "sparcv9".equals(arch))) { - // we have not updated other platforms with the proper NSS - // libraries yet - System.out.println( - "Test currently works only on solaris-sparc " + - "and solaris-sparcv9. Skipping on " + arch); - return; - } - - String configName = BASE + SEP + "fips.cfg"; - Provider p = getSunPKCS11(configName); - - System.out.println(p); - Security.addProvider(p); - - Security.removeProvider("SunJSSE"); - Provider jsse = new com.sun.net.ssl.internal.ssl.Provider(p); - Security.addProvider(jsse); - System.out.println(jsse.getInfo()); - - KeyStore ks = KeyStore.getInstance("PKCS11", p); - ks.load(null, "test12".toCharArray()); - - CipherTest.main(new JSSEFactory(), ks, args); - } - - private static class JSSEFactory extends CipherTest.PeerFactory { - - String getName() { - return "Client JSSE - Server JSSE"; - } - - CipherTest.Client newClient(CipherTest cipherTest) throws Exception { - return new JSSEClient(cipherTest); - } - - CipherTest.Server newServer(CipherTest cipherTest) throws Exception { - return new JSSEServer(cipherTest); - } - } -} diff --git a/test/jdk/sun/security/pkcs11/fips/ImportKeyStore.java b/test/jdk/sun/security/pkcs11/fips/ImportKeyStore.java deleted file mode 100644 index 8fecb2b2692..00000000000 --- a/test/jdk/sun/security/pkcs11/fips/ImportKeyStore.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.io.*; -import java.util.*; - -import java.security.*; -import java.security.KeyStore.*; -import java.security.cert.*; - -/** - -This is an approximation of the process used to create the *.db files -in this directory. - -setenv LD_LIBRARY_PATH $WS/test/sun/security/pkcs11/nss/lib/solaris-sparc -modutil -create -dbdir . -modutil -changepw "NSS Internal PKCS #11 Module" -dbdir . - -$JHOME/bin/keytool -list -storetype PKCS11 -addprovider SunPKCS11 -providerarg "--name=NSS\nnssSecmodDirectory=." -v -storepass test12 - -modutil -fips true -dbdir . - -*/ - -public class ImportKeyStore { - - public static void main(String[] args) throws Exception { - String nssCfg = "--name=NSS\nnssSecmodDirectory=.\n "; -// "attributes(*,CKO_PRIVATE_KEY,CKK_DSA) = { CKA_NETSCAPE_DB = 0h00 }"; - Provider p = Security.getProvider("SunPKCS11"); - p.configure(nssCfg); - - KeyStore ks = KeyStore.getInstance("PKCS11", p); - ks.load(null, "test12".toCharArray()); - System.out.println("Aliases: " + Collections.list(ks.aliases())); - System.out.println(); - - char[] srcpw = "passphrase".toCharArray(); -// importKeyStore("truststore", srcpw, ks); - importKeyStore("keystore", srcpw, ks); - - System.out.println("OK."); - } - - private static void importKeyStore(String filename, char[] passwd, KeyStore dstks) throws Exception { - System.out.println("Importing JKS KeyStore " + filename); - InputStream in = new FileInputStream(filename); - KeyStore srcks = KeyStore.getInstance("JKS"); - srcks.load(in, passwd); - in.close(); - List aliases = Collections.list(srcks.aliases()); - for (String alias : aliases) { - System.out.println("Alias: " + alias); - if (srcks.isCertificateEntry(alias)) { - X509Certificate cert = (X509Certificate)srcks.getCertificate(alias); - System.out.println(" Certificate: " + cert.getSubjectX500Principal()); - dstks.setCertificateEntry(alias + "-cert", cert); - } else if (srcks.isKeyEntry(alias)) { - PrivateKeyEntry entry = (PrivateKeyEntry)srcks.getEntry(alias, new PasswordProtection(passwd)); - System.out.println(" Key: " + entry.getPrivateKey().toString().split("\n")[0]); - dstks.setEntry(alias, entry, null); - } else { - System.out.println(" Unknown entry: " + alias); - } - } - System.out.println(); - } - -} diff --git a/test/jdk/sun/security/pkcs11/fips/JSSEClient.java b/test/jdk/sun/security/pkcs11/fips/JSSEClient.java deleted file mode 100644 index c6f8db974c0..00000000000 --- a/test/jdk/sun/security/pkcs11/fips/JSSEClient.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2002, 2005, 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. - */ - -import java.io.*; -import java.net.*; -import java.util.*; - -import java.security.*; -import java.security.cert.*; -import java.security.cert.Certificate; - -import javax.net.ssl.*; - -class JSSEClient extends CipherTest.Client { - - private final SSLContext sslContext; - private final MyX509KeyManager keyManager; - - JSSEClient(CipherTest cipherTest) throws Exception { - super(cipherTest); - this.keyManager = new MyX509KeyManager(CipherTest.keyManager); - sslContext = SSLContext.getInstance("TLS"); - } - - void runTest(CipherTest.TestParameters params) throws Exception { - SSLSocket socket = null; - try { - keyManager.setAuthType(params.clientAuth); - sslContext.init(new KeyManager[] {CipherTest.keyManager}, new TrustManager[] {cipherTest.trustManager}, cipherTest.secureRandom); - SSLSocketFactory factory = (SSLSocketFactory)sslContext.getSocketFactory(); - socket = (SSLSocket)factory.createSocket("127.0.0.1", cipherTest.serverPort); - socket.setSoTimeout(cipherTest.TIMEOUT); - socket.setEnabledCipherSuites(new String[] {params.cipherSuite}); - socket.setEnabledProtocols(new String[] {params.protocol}); - InputStream in = socket.getInputStream(); - OutputStream out = socket.getOutputStream(); - sendRequest(in, out); - socket.close(); - SSLSession session = socket.getSession(); - session.invalidate(); - String cipherSuite = session.getCipherSuite(); - if (params.cipherSuite.equals(cipherSuite) == false) { - throw new Exception("Negotiated ciphersuite mismatch: " + cipherSuite + " != " + params.cipherSuite); - } - String protocol = session.getProtocol(); - if (params.protocol.equals(protocol) == false) { - throw new Exception("Negotiated protocol mismatch: " + protocol + " != " + params.protocol); - } - if (cipherSuite.indexOf("DH_anon") == -1) { - session.getPeerCertificates(); - } - Certificate[] certificates = session.getLocalCertificates(); - if (params.clientAuth == null) { - if (certificates != null) { - throw new Exception("Local certificates should be null"); - } - } else { - if ((certificates == null) || (certificates.length == 0)) { - throw new Exception("Certificates missing"); - } - String keyAlg = certificates[0].getPublicKey().getAlgorithm(); - if (params.clientAuth != keyAlg) { - throw new Exception("Certificate type mismatch: " + keyAlg + " != " + params.clientAuth); - } - } - } finally { - if (socket != null) { - socket.close(); - } - } - } - -} diff --git a/test/jdk/sun/security/pkcs11/fips/JSSEServer.java b/test/jdk/sun/security/pkcs11/fips/JSSEServer.java deleted file mode 100644 index 6db9781506d..00000000000 --- a/test/jdk/sun/security/pkcs11/fips/JSSEServer.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2002, 2005, 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. - */ - -import java.io.*; -import java.net.*; -import java.util.*; -import java.util.concurrent.*; - -import java.security.*; -import java.security.cert.*; -import java.security.cert.Certificate; - -import javax.net.ssl.*; - -class JSSEServer extends CipherTest.Server { - - SSLServerSocket serverSocket; - - JSSEServer(CipherTest cipherTest) throws Exception { - super(cipherTest); - SSLContext serverContext = SSLContext.getInstance("TLS"); - serverContext.init(new KeyManager[] {cipherTest.keyManager}, new TrustManager[] {cipherTest.trustManager}, cipherTest.secureRandom); - - SSLServerSocketFactory factory = (SSLServerSocketFactory)serverContext.getServerSocketFactory(); - serverSocket = (SSLServerSocket)factory.createServerSocket(cipherTest.serverPort); - cipherTest.serverPort = serverSocket.getLocalPort(); - serverSocket.setEnabledCipherSuites(factory.getSupportedCipherSuites()); -// serverSocket.setWantClientAuth(true); - } - - public void run() { - System.out.println("JSSE Server listening on port " + cipherTest.serverPort); - Executor exec = Executors.newFixedThreadPool - (cipherTest.THREADS, DaemonThreadFactory.INSTANCE); - try { - while (true) { - final SSLSocket socket = (SSLSocket)serverSocket.accept(); - socket.setSoTimeout(cipherTest.TIMEOUT); - Runnable r = new Runnable() { - public void run() { - try { - InputStream in = socket.getInputStream(); - OutputStream out = socket.getOutputStream(); - handleRequest(in, out); - out.flush(); - socket.close(); - socket.getSession().invalidate(); - } catch (IOException e) { - cipherTest.setFailed(); - e.printStackTrace(); - } finally { - if (socket != null) { - try { - socket.close(); - } catch (IOException e) { - cipherTest.setFailed(); - System.out.println("Exception closing socket on server side:"); - e.printStackTrace(); - } - } - } - } - }; - exec.execute(r); - } - } catch (IOException e) { - cipherTest.setFailed(); - e.printStackTrace(); - // - } - } - -} diff --git a/test/jdk/sun/security/pkcs11/fips/TestTLS12.java b/test/jdk/sun/security/pkcs11/fips/TestTLS12.java deleted file mode 100644 index 73f9fb10b88..00000000000 --- a/test/jdk/sun/security/pkcs11/fips/TestTLS12.java +++ /dev/null @@ -1,453 +0,0 @@ -/* - * Copyright (c) 2018, Red Hat, Inc. - * 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 8029661 - * @summary Test TLS 1.2 - * @modules java.base/sun.security.internal.spec - * java.base/sun.security.util - * java.base/com.sun.net.ssl.internal.ssl - * java.base/com.sun.crypto.provider - * @library /test/lib .. - * @run main/othervm/timeout=120 TestTLS12 - */ - -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.nio.ByteBuffer; - -import java.security.interfaces.RSAPrivateKey; -import java.security.interfaces.RSAPublicKey; -import java.security.KeyStore; -import java.security.NoSuchAlgorithmException; -import java.security.Provider; -import java.security.SecureRandom; -import java.security.Security; - -import java.util.Arrays; - -import javax.crypto.Cipher; -import javax.crypto.KeyGenerator; -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; - -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; -import javax.net.ssl.SSLEngineResult; -import javax.net.ssl.SSLEngineResult.HandshakeStatus; -import javax.net.ssl.SSLParameters; -import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManagerFactory; - -import sun.security.internal.spec.TlsMasterSecretParameterSpec; -import sun.security.internal.spec.TlsPrfParameterSpec; -import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; - -public final class TestTLS12 extends SecmodTest { - - private static final boolean enableDebug = true; - - private static Provider sunPKCS11NSSProvider; - private static Provider sunJCEProvider; - private static com.sun.net.ssl.internal.ssl.Provider jsseProvider; - private static KeyStore ks; - private static KeyStore ts; - private static char[] passphrase = "JAHshj131@@".toCharArray(); - private static RSAPrivateKey privateKey; - private static RSAPublicKey publicKey; - - public static void main(String[] args) throws Exception { - try { - initialize(); - } catch (Exception e) { - System.out.println("Test skipped: failure during" + - " initialization"); - return; - } - - if (shouldRun()) { - // Test against JCE - testTlsAuthenticationCodeGeneration(); - - // Self-integrity test (complete TLS 1.2 communication) - new testTLS12SunPKCS11Communication().run(); - - System.out.println("Test PASS - OK"); - } else { - System.out.println("Test skipped: TLS 1.2 mechanisms" + - " not supported by current SunPKCS11 back-end"); - } - } - - private static boolean shouldRun() { - if (sunPKCS11NSSProvider == null) { - return false; - } - try { - KeyGenerator.getInstance("SunTls12MasterSecret", - sunPKCS11NSSProvider); - KeyGenerator.getInstance( - "SunTls12RsaPremasterSecret", sunPKCS11NSSProvider); - KeyGenerator.getInstance("SunTls12Prf", sunPKCS11NSSProvider); - } catch (NoSuchAlgorithmException e) { - return false; - } - return true; - } - - private static void testTlsAuthenticationCodeGeneration() - throws Exception { - // Generate RSA Pre-Master Secret in SunPKCS11 provider - SecretKey rsaPreMasterSecret = null; - @SuppressWarnings("deprecation") - TlsRsaPremasterSecretParameterSpec rsaPreMasterSecretSpec = - new TlsRsaPremasterSecretParameterSpec(0x0303, 0x0303); - { - KeyGenerator rsaPreMasterSecretKG = KeyGenerator.getInstance( - "SunTls12RsaPremasterSecret", sunPKCS11NSSProvider); - rsaPreMasterSecretKG.init(rsaPreMasterSecretSpec, null); - rsaPreMasterSecret = rsaPreMasterSecretKG.generateKey(); - } - - // Get RSA Pre-Master Secret in plain (from SunPKCS11 provider) - byte[] rsaPlainPreMasterSecret = null; - { - Cipher rsaPreMasterSecretWrapperCipher = - Cipher.getInstance("RSA/ECB/PKCS1Padding", - sunPKCS11NSSProvider); - rsaPreMasterSecretWrapperCipher.init(Cipher.WRAP_MODE, publicKey, - new SecureRandom()); - byte[] rsaEncryptedPreMasterSecret = - rsaPreMasterSecretWrapperCipher.wrap(rsaPreMasterSecret); - Cipher rsaPreMasterSecretUnwrapperCipher = - Cipher.getInstance("RSA/ECB/PKCS1Padding", sunJCEProvider); - rsaPreMasterSecretUnwrapperCipher.init(Cipher.UNWRAP_MODE, - privateKey, rsaPreMasterSecretSpec); - rsaPlainPreMasterSecret = rsaPreMasterSecretUnwrapperCipher.unwrap( - rsaEncryptedPreMasterSecret, "TlsRsaPremasterSecret", - Cipher.SECRET_KEY).getEncoded(); - - if (enableDebug) { - System.out.println("rsaPlainPreMasterSecret:"); - for (byte b : rsaPlainPreMasterSecret) { - System.out.printf("%02X, ", b); - } - System.out.println(""); - } - } - - // Generate Master Secret - SecretKey sunPKCS11MasterSecret = null; - SecretKey jceMasterSecret = null; - { - KeyGenerator sunPKCS11MasterSecretGenerator = - KeyGenerator.getInstance("SunTls12MasterSecret", - sunPKCS11NSSProvider); - KeyGenerator jceMasterSecretGenerator = KeyGenerator.getInstance( - "SunTls12MasterSecret", sunJCEProvider); - @SuppressWarnings("deprecation") - TlsMasterSecretParameterSpec sunPKCS11MasterSecretSpec = - new TlsMasterSecretParameterSpec(rsaPreMasterSecret, 3, 3, - new byte[32], new byte[32], "SHA-256", 32, 64); - @SuppressWarnings("deprecation") - TlsMasterSecretParameterSpec jceMasterSecretSpec = - new TlsMasterSecretParameterSpec( - new SecretKeySpec(rsaPlainPreMasterSecret, - "Generic"), 3, 3, new byte[32], - new byte[32], "SHA-256", 32, 64); - sunPKCS11MasterSecretGenerator.init(sunPKCS11MasterSecretSpec, - null); - jceMasterSecretGenerator.init(jceMasterSecretSpec, null); - sunPKCS11MasterSecret = - sunPKCS11MasterSecretGenerator.generateKey(); - jceMasterSecret = jceMasterSecretGenerator.generateKey(); - if (enableDebug) { - System.out.println("Master Secret (SunJCE):"); - if (jceMasterSecret != null) { - for (byte b : jceMasterSecret.getEncoded()) { - System.out.printf("%02X, ", b); - } - System.out.println(""); - } - } - } - - // Generate authentication codes - byte[] sunPKCS11AuthenticationCode = null; - byte[] jceAuthenticationCode = null; - { - // Generate SunPKCS11 authentication code - { - @SuppressWarnings("deprecation") - TlsPrfParameterSpec sunPKCS11AuthenticationCodeSpec = - new TlsPrfParameterSpec(sunPKCS11MasterSecret, - "client finished", "a".getBytes(), 12, - "SHA-256", 32, 64); - KeyGenerator sunPKCS11AuthCodeGenerator = - KeyGenerator.getInstance("SunTls12Prf", - sunPKCS11NSSProvider); - sunPKCS11AuthCodeGenerator.init( - sunPKCS11AuthenticationCodeSpec); - sunPKCS11AuthenticationCode = - sunPKCS11AuthCodeGenerator.generateKey().getEncoded(); - } - - // Generate SunJCE authentication code - { - @SuppressWarnings("deprecation") - TlsPrfParameterSpec jceAuthenticationCodeSpec = - new TlsPrfParameterSpec(jceMasterSecret, - "client finished", "a".getBytes(), 12, - "SHA-256", 32, 64); - KeyGenerator jceAuthCodeGenerator = - KeyGenerator.getInstance("SunTls12Prf", - sunJCEProvider); - jceAuthCodeGenerator.init(jceAuthenticationCodeSpec); - jceAuthenticationCode = - jceAuthCodeGenerator.generateKey().getEncoded(); - } - - if (enableDebug) { - System.out.println("SunPKCS11 Authentication Code: "); - for (byte b : sunPKCS11AuthenticationCode) { - System.out.printf("%02X, ", b); - } - System.out.println(""); - System.out.println("SunJCE Authentication Code: "); - for (byte b : jceAuthenticationCode) { - System.out.printf("%02X, ", b); - } - System.out.println(""); - } - } - - if (sunPKCS11AuthenticationCode == null || - jceAuthenticationCode == null || - sunPKCS11AuthenticationCode.length == 0 || - jceAuthenticationCode.length == 0 || - !Arrays.equals(sunPKCS11AuthenticationCode, - jceAuthenticationCode)) { - throw new Exception("Authentication codes from JCE" + - " and SunPKCS11 differ."); - } - } - - private static class testTLS12SunPKCS11Communication { - public static void run() throws Exception { - SSLEngine[][] enginesToTest = getSSLEnginesToTest(); - - for (SSLEngine[] engineToTest : enginesToTest) { - - SSLEngine clientSSLEngine = engineToTest[0]; - SSLEngine serverSSLEngine = engineToTest[1]; - - // SSLEngine code based on RedhandshakeFinished.java - - boolean dataDone = false; - - ByteBuffer clientOut = null; - ByteBuffer clientIn = null; - ByteBuffer serverOut = null; - ByteBuffer serverIn = null; - ByteBuffer cTOs; - ByteBuffer sTOc; - - SSLSession session = clientSSLEngine.getSession(); - int appBufferMax = session.getApplicationBufferSize(); - int netBufferMax = session.getPacketBufferSize(); - - 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()); - - SSLEngineResult clientResult; - SSLEngineResult serverResult; - - while (!dataDone) { - clientResult = clientSSLEngine.wrap(clientOut, cTOs); - runDelegatedTasks(clientResult, clientSSLEngine); - serverResult = serverSSLEngine.wrap(serverOut, sTOc); - runDelegatedTasks(serverResult, serverSSLEngine); - cTOs.flip(); - sTOc.flip(); - - if (enableDebug) { - System.out.println("Client -> Network"); - printTlsNetworkPacket("", cTOs); - System.out.println(""); - System.out.println("Server -> Network"); - printTlsNetworkPacket("", sTOc); - System.out.println(""); - } - - clientResult = clientSSLEngine.unwrap(sTOc, clientIn); - runDelegatedTasks(clientResult, clientSSLEngine); - serverResult = serverSSLEngine.unwrap(cTOs, serverIn); - runDelegatedTasks(serverResult, serverSSLEngine); - - cTOs.compact(); - sTOc.compact(); - - if (!dataDone && - (clientOut.limit() == serverIn.position()) && - (serverOut.limit() == clientIn.position())) { - checkTransfer(serverOut, clientIn); - checkTransfer(clientOut, serverIn); - dataDone = true; - } - } - } - } - - static void printTlsNetworkPacket(String prefix, ByteBuffer bb) { - ByteBuffer slice = bb.slice(); - byte[] buffer = new byte[slice.remaining()]; - slice.get(buffer); - for (int i = 0; i < buffer.length; i++) { - System.out.printf("%02X, ", (byte)(buffer[i] & (byte)0xFF)); - if (i % 8 == 0 && i % 16 != 0) { - System.out.print(" "); - } - if (i % 16 == 0) { - System.out.println(""); - } - } - System.out.flush(); - } - - 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"); - } - a.position(a.limit()); - b.position(b.limit()); - a.limit(a.capacity()); - b.limit(b.capacity()); - } - - private static void runDelegatedTasks(SSLEngineResult result, - SSLEngine engine) throws Exception { - - if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { - Runnable runnable; - while ((runnable = engine.getDelegatedTask()) != null) { - runnable.run(); - } - HandshakeStatus hsStatus = engine.getHandshakeStatus(); - if (hsStatus == HandshakeStatus.NEED_TASK) { - throw new Exception( - "handshake shouldn't need additional tasks"); - } - } - } - - private static SSLEngine[][] getSSLEnginesToTest() throws Exception { - SSLEngine[][] enginesToTest = new SSLEngine[2][2]; - String[][] preferredSuites = new String[][]{ new String[] { - "TLS_RSA_WITH_AES_128_CBC_SHA256" - }, new String[] { - "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256" - }}; - for (int i = 0; i < enginesToTest.length; i++) { - enginesToTest[i][0] = createSSLEngine(true); - enginesToTest[i][1] = createSSLEngine(false); - enginesToTest[i][0].setEnabledCipherSuites(preferredSuites[i]); - enginesToTest[i][1].setEnabledCipherSuites(preferredSuites[i]); - } - return enginesToTest; - } - - static private SSLEngine createSSLEngine(boolean client) - throws Exception { - SSLEngine ssle; - KeyManagerFactory kmf = KeyManagerFactory.getInstance("PKIX", - jsseProvider); - kmf.init(ks, passphrase); - - TrustManagerFactory tmf = TrustManagerFactory.getInstance("PKIX", - jsseProvider); - tmf.init(ts); - - SSLContext sslCtx = SSLContext.getInstance("TLSv1.2", - jsseProvider); - sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); - ssle = sslCtx.createSSLEngine("localhost", 443); - ssle.setUseClientMode(client); - SSLParameters sslParameters = ssle.getSSLParameters(); - ssle.setSSLParameters(sslParameters); - - return ssle; - } - } - - private static void initialize() throws Exception { - if (initSecmod() == false) { - return; - } - String configName = BASE + SEP + "fips.cfg"; - sunPKCS11NSSProvider = getSunPKCS11(configName); - System.out.println("SunPKCS11 provider: " + sunPKCS11NSSProvider); - Security.addProvider(sunPKCS11NSSProvider); - - sunJCEProvider = new com.sun.crypto.provider.SunJCE(); - Security.addProvider(sunJCEProvider); - - Security.removeProvider("SunJSSE"); - jsseProvider =new com.sun.net.ssl.internal.ssl.Provider( - sunPKCS11NSSProvider); - Security.addProvider(jsseProvider); - System.out.println(jsseProvider.getInfo()); - - ks = KeyStore.getInstance("PKCS11", sunPKCS11NSSProvider); - ks.load(null, "test12".toCharArray()); - ts = ks; - - KeyStore ksPlain = readTestKeyStore(); - privateKey = (RSAPrivateKey)ksPlain.getKey("rh_rsa_sha256", - passphrase); - publicKey = (RSAPublicKey)ksPlain.getCertificate( - "rh_rsa_sha256").getPublicKey(); - } - - private static KeyStore readTestKeyStore() throws Exception { - File file = new File(System.getProperty("test.src", "."), "keystore"); - InputStream in = new FileInputStream(file); - KeyStore ks = KeyStore.getInstance("JKS"); - ks.load(in, "passphrase".toCharArray()); - in.close(); - return ks; - } -} \ No newline at end of file diff --git a/test/jdk/sun/security/pkcs11/fips/TrustManagerTest.java b/test/jdk/sun/security/pkcs11/fips/TrustManagerTest.java deleted file mode 100644 index 1c33eb9a555..00000000000 --- a/test/jdk/sun/security/pkcs11/fips/TrustManagerTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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 - * 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 6323647 - * @summary Verify that the SunJSSE trustmanager works correctly in FIPS mode - * @author Andreas Sterbenz - * @library /test/lib .. - * @modules java.base/com.sun.net.ssl.internal.ssl - * @run main/othervm TrustManagerTest - * @run main/othervm TrustManagerTest sm TrustManagerTest.policy - */ - -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.security.KeyStore; -import java.security.Policy; -import java.security.Provider; -import java.security.Security; -import java.security.URIParameter; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import javax.net.ssl.TrustManagerFactory; -import javax.net.ssl.X509TrustManager; - -// This test belongs more in JSSE than here, but the JSSE workspace does not -// have the NSS test infrastructure. It will live here for the time being. - -public class TrustManagerTest extends SecmodTest { - - public static void main(String[] args) throws Exception { - if (initSecmod() == false) { - return; - } - - if ("sparc".equals(System.getProperty("os.arch")) == false) { - // we have not updated other platforms with the proper NSS libraries yet - System.out.println("Test currently works only on solaris-sparc, skipping"); - return; - } - - String configName = BASE + SEP + "fips.cfg"; - Provider p = getSunPKCS11(configName); - - System.out.println(p); - Security.addProvider(p); - - Security.removeProvider("SunJSSE"); - Provider jsse = new com.sun.net.ssl.internal.ssl.Provider(p); - Security.addProvider(jsse); - System.out.println(jsse.getInfo()); - - KeyStore ks = KeyStore.getInstance("PKCS11", p); - ks.load(null, "test12".toCharArray()); - - X509Certificate server = loadCertificate("certs/server.cer"); - X509Certificate ca = loadCertificate("certs/ca.cer"); - X509Certificate anchor = loadCertificate("certs/anchor.cer"); - - if (args.length > 1 && "sm".equals(args[0])) { - Policy.setPolicy(Policy.getInstance("JavaPolicy", - new URIParameter(new File(BASE, args[1]).toURI()))); - System.setSecurityManager(new SecurityManager()); - } - - KeyStore trustStore = KeyStore.getInstance("JKS"); - trustStore.load(null, null); - trustStore.setCertificateEntry("anchor", anchor); - - TrustManagerFactory tmf = TrustManagerFactory.getInstance("PKIX"); - tmf.init(trustStore); - - X509TrustManager tm = (X509TrustManager)tmf.getTrustManagers()[0]; - - X509Certificate[] chain = {server, ca, anchor}; - - tm.checkServerTrusted(chain, "RSA"); - - System.out.println("OK"); - } - - private static X509Certificate loadCertificate(String name) throws Exception { - try (InputStream in = new FileInputStream(BASE + SEP + name)) { - return (X509Certificate) CertificateFactory.getInstance("X.509") - .generateCertificate(in); - } - } - -} diff --git a/test/jdk/sun/security/pkcs11/fips/TrustManagerTest.policy b/test/jdk/sun/security/pkcs11/fips/TrustManagerTest.policy deleted file mode 100644 index 16bb57d4e1b..00000000000 --- a/test/jdk/sun/security/pkcs11/fips/TrustManagerTest.policy +++ /dev/null @@ -1,3 +0,0 @@ -grant { - -}; \ No newline at end of file diff --git a/test/jdk/sun/security/pkcs11/fips/cert8.db b/test/jdk/sun/security/pkcs11/fips/cert8.db deleted file mode 100644 index 9d39639d9b2530ba8e8ab044a816a389d8c7bfe0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 65536 zcmeI*c~}!?9tZH5NeID!;YN*M0Pz5X35Xz|$RQ%4a*E)B1PO=-M>quWAQ7-q1);92 z3l$WK;9BW=p9QV*=6ASzHm=>)5*f4P73>GH>S^5n_9?>kTC_k3pF z`S1GR=814h_8>`)kbldrY5VQyioC z{^=X{Z9RYbd2vDrKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$## zAOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P-lRCct&-aeC<# z?Reess-wF@o&65`4fZ<*u|WU=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_< z0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG|gy#SYa%QQuB z2qIa$LMkSRZ05sk_EJMfTDD2Vqg6Pp05(U93h;Z^;A&B><}(T`{7prQ(_tCy^#b z$Ha=p(fW$M5n8%_Nio9t(aWT<38@K*lGO?3!nrZaEJV7rw&DPumYSzHSuFI6jZ9o4 zmP$lp=uwJ(mX^j)85WY5D2s%o7>i}GtL-E1KOP>Hu!ct&T;{#sS;M0g>g`RVcqjNQ z#fREJaA-NTmX?$EDE82mQ{$+ZW_e`wsF5UFi5MPb(*}BKw1^goY-w6#XF~@w&1pjZB3QC*jNleZCL<1c7A~nFPhXa(EQ{j>3-Ymp=jXHZkFDAm;&EB8y~S(#Khu7$+qvdcb4llvmE-qo*T_@V3w4*zk@@fK z%iBG|)UUj4_xj1!*Odk+r*9i#p6;htE%kkBBbhhy{60y9&>S7OkK%3MTK=0eUenibD_4p$NlMBaxTPMWS^?2Kk(G#PE?{G)YE?fsWioV zYnJ?sB1YvRIsBM&#Kw(W|FSS?5+dpyT`%sD?$c6vq8?eWCjTt}Oy17xtJ zQ|F!I_1iDR<^Akp7VU5)Zd@a~^M3C6E02~`WL#}-5S`lGdHn4SNe-Wf2A6r5E|N$S zqGMwSg6ovzXyow5uFLM8-M4myb|H3i>_Yyq)dlcJ5P$##AOHafKmY;|fB*y_009U< z00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa z0SF8?0Y#9TBt{a1boo+gf_Q1da{K|e)H!_1PG zCzNu;GgCOBTT;r54;&qANvH~2!w_i8o_%V~=0?GM6Jx_K zJD#|nDJclJ+f`L6y|(hCv1-%)^`Q}Zr7KOOB9~F$=+xQTjhZ-~ePd_VGqa&sZ>cpC zj@IC)gk^blmJBON2&Wyp zd~<54s+q7 zh6$+#lLeBZR`$9|xpzo!C0}j2tI3Uv*-LI6DJWOFonKy^`&o$AyoSu1N3T_PdXKtr z-MKv8(zK&NuRZFza_84ib~iuL=Ii+Ex&I=w!c%s-t31-zv8XX4MgO8}t~mLnP*|LP zDC6U~K>iQY@cn#Y%~B-kS&qz{>0^@giq#l+9Azd+f5nc?8g4myD_bT!Z!`5>j^0X< zrB^hENseAlRx=aa{2d?3G{z}1^shJi$@G&nC;Q&@EV5|7-`1^B?d#a#Mw~TpNj_ zys54i^g0B#)mN13@Y(&Fy8m^~;4Ee1uNADDXVsnb;-Hzh#k8Z#h&B4ls~%(nr9%{i zdFSdF^BNE3pOEi;lELd-Joc5Mw4TuX`k$J8RBF z)z|$eDkp!pr)>TrfnK7Fd}gTk14q^*G8nv3zc%ne+*WzZcQ;qH`IBVswM(8OtXfKX zg4gW~?^rjk^{0u~`*!HtU#W?G7+f%U>5V-LD+6yGTk!Csd!A)U(B_o3yJdVz-kiEG zth=Y*kuH%ad(~vFrL;#s<{6zc>1nUX*<<3B%HDLg)2#j7S^&dlDHCSVmDleVUcn9o zAOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;| ofB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV={}+MZ0PXWuGXMYp diff --git a/test/jdk/sun/security/pkcs11/fips/certs/anchor.cer b/test/jdk/sun/security/pkcs11/fips/certs/anchor.cer deleted file mode 100644 index 3d67bda8000c84299d02b03937db37be0efe40a6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 417 zcmXqLVw`Kx#K^|P$Y8+B#;Mij(e|B}k&%^^!9d(l)IgYxIh2K2m?xyDw75heF)ukI zzsNvNoY%m}z|z3X(9Fot$UI7%*9e)5TVvyVWIGsH8JHV;84MabnHn1z4(%3~*NhPt zyt(nq!RfJYrDn~N?3tsWwev<=&->2(R!i=OA3qkx`D*9X%f@*VzwZ7&VV;%+quRP> zK@AF3U&MA~+bbtckuqkQ;lYw+{zZpxTDhLoV}= z;>gO_{e^G2zPYwX(xD_d9=(e*ey3S8F*7nSB0CQl1k6Bpxt&{4Tbgo{f7ga?z9S-f zAxp$~Dxa>ge&Q4Q-|5!m`rId(TE;(Qwtr*1G*Q_n^ZkWce)G;-8&?%`T$R1|vu^dY z^?3<1`_6uEKc&1uYSXVz2Hd3_MPAo$pWQVxXrD{x&HYoS2prtzHg6T*e2Wvj{<|+m U-80|urGY0}z42QMe|nw{0Idq2aR2}S diff --git a/test/jdk/sun/security/pkcs11/fips/certs/ca.cer b/test/jdk/sun/security/pkcs11/fips/certs/ca.cer deleted file mode 100644 index b7b3c3bc8ff5c28ea574d0b959cbbf59e0498a78..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 454 zcmXqLVmxHf#HhW1nTe5!iILHOmyJ`a&7D}#Z!p{Ri{8*?ZNvoKFcQE73B zLSkNWMt+fjoH(z6k%6UwnW34Hp^}dMPfv{q-SS6U^Z%3i`o2tRZ#TbD+P>0q@^?S8y-_;X z%ef4%9((3-tv`B!=lb0;c{6M4#LlM{SL|Wp)T#AX;<$U0@j>in-E+t1-K?G~CiY0w z?atIGD_OQPF*7nSE*3TrG~fsNLROfO@jnZz0W*+7b~7-Dn1POE4zeuno0zE(`EBvK zC0@&~w{3l~X8JiV*#^^ByLPFp+S>6|m)puU*xF{3kK)T)d$fusI%=^=7`(b|mXRq@ zAepUN{^gUr;nr`HUSzsARxBzmbcj8n7iXMz_;c!n*6S;^&z(HDIl@p^X!ELz-%eHs XC{1`~dgu=0!p!M5PtKkF$9@90u$TsxmU97u0D!B{>pRx zm*+RlIY#TR$Xpw$7Ktc6)%2t_-N0+E6Zr2<9EAe6YMRtu~QEcVUqP;!3$@yY+#$9MZC6h%Aq z++|{BWMD*g9xyPNf$l1Oe4$FEb{Biq+otJCYkMDWp5A?awZ2gBUaJdsHx#z^tT;D4 zn`@@asvi}_);~=S`LEaAmz?>z*7v{CjNRNHG+7w`M_9|=P<1(06a3&|kJ*T%teUZ&&_uhV?TY0;Uzj*w#oO~qPa;3(m+Lf=wN=k$oA<$QBty*6=0u*oEwSG9@DWQk0zr zku4#G!eEf>Pxbu%`2D`;_s?_AbDrn<f00e*l5csbV zpyS`=|G~e?Kh00%&*SIku|Z99z2++8dVLHU5C8%|00;m9AOHk_01yBIKmZ5;0U!Vb zfB+Bx0zd!=00AHX1c1PQMu37D3XwjM)c3TmV28Dv?UozqE<`p029p)0rav966}^Li zGEhM&WZ5X0|9TDvg;GX9$H$}msy`m#jTFeDNX z5g$z$!$>_76MtBvQBD0gPfA|#C$kM}mknaahtDS*RD>S&ELy~9^)mT5K6K|?V#BEh z-n*qa8ya>^gTvqF{x|!G0*Pml&Iq1NHKz}Mj^~k(s|wF>S-86yd&8OE2TnbYyRI5dby76GQ)i}v5S^1l{XL+t4c$3=r`uQ%Yzc|`b3Wm2iAHEsu1-Bq@riycH%I*=8t*vV)Wc% z{tBFX@Qpx_F%$cX`!uSTMHvqF8_LAn3X1hjQ5?SEP?8|WFm*Ulj_-J)GtlhI&De;s zwn>jg6DTxcv`>dlek^~-GC0j)Etr39R&;#t0q?oDjb00u>Ed=11y{<T+yWh&i(k+NhfFP}b#FW)l9N%>3)Q-a!Jwb`unN8mf zC6TFbyiZprneNlx#Oq|lCLvEI-6Ox2bX^YKD5q!7UdLWZ!>e>qi^Uw&*wph!!w1Or z+pU#Mc~$5yez=wkQ^-G`oH-2{^XqYzsZP zFS=g+9dDmYh2DZSuD1;}eMDk+XJ6HZ`i?VhqPv4>Y+B?N33m*S8sU|$`l;%tns#9P z*a=NX#qW`b$q z5qo*RV^>QEk4nh{)tazyfkKZWnbb*H>S2}ksqT|@IeMk}QHruBv7rapAg`y84==Uo zcImoP^!XHAD0-+V#*J^>8@xJo;fK@dO9)|nXsBwv;ud&lr_dG$L5@(ud4Ldp~ndseqRxv3HImK?Rb4mzq<`-7%E4L7k}WHXUaK) zm!PF@5fvOD$pZRd%-qN?L(OXzMX2=6;X^$kOa z+=5GTlEo4n^X8IGYp`Yt>D?%Y=x;NhuH4S0mi3&^RM*j=wqd|Yv$pplQ*Kx3WLY&r zUk%`B9dFWGqLOKTT(b>E8FH*>=$WfYT%@%i&)KMZ>nBt2)_R25Xbo_zjOm?y9`xyD znt$tH{<@UAFag;Zaho}d-Q{w)N#R~nF5PM4M~k^3;^=Xz1DHxnm**-$*2C`Vsv=I8 zvAdL&*%VX3vM0!xal99ci@)*n3sQkI++p-v*=v`0fmFVX_8w9`_8z_zrZ~Kh ztCuGP#t-4z=33_3{;#P>02cuQKmZ5;0U!VbfB+Bx0zd!=00AHX1b_e#00KY&2mk>f z00e*l5cp>WC?Je@7dyO;0K(hw<0wcX!v$ z)pTa{v=*;lZoIvTD4^_{p@MjJ?O=F|Imx8Kq(JKlx*Y27Gbf!K6gpC)W+j8Jc+i|3 zIchtVm}5xOfywDx7L0wK%C|01ciU33uG+q1$5-a-$Cxpv)quy2D$SCWv3pTU=FEas zij*Na^J21Fc1}Zsp1jFiBP;H#*LKQy50eebWH)TFmd<4DhStXhT$zlVn-%^srG{iV z=V=Xg%gH()lzd!Eg|&OykG#M!|47}d6GaO(#i*gr%tL!YbPyg&IMo&%*}L~(X~$)Z>Fm7WnYgG+-}Wg&9G`xT zGlIY^6{-|T=4=Ut^u774goe2CQV!Q@Up#Nag{obIP=Hr#BfY4^CvJ57+#^ADDJU%7 zxZ|3qbI3)TeRd0nnZ5%pqZsXrrhns+GvZU;mwPC}_(x|VNAZBd34B{kA|@|tpoA8d zs>*6m@LCLI1Sy<+;T$Bqyt!eV1mA6==(SsLoHkJOYK?4X8Sl5Td?!L%n#C&ep!LG7 zgT&*zun4HBab^UcrfRx%ZWgT(K7{?5oLs5Y3PrS9T{E|{mz>s4==i)+8Ro}ni)%_q zZtE?4_WS261IgC|B|YdTPn|a-4KODg=gvgcy)VxDW@S{SW}$ANzr1vX(|21}obq1V z)h>ZHddF>J>k%T3bMDw`99Jupu01*$9^Eb6d^z~Lz^I_2}ysGLUv+1dj`ay?M;TOs?&z=_`UhN^)tsjg9jF?e;#w>j;=ug&KD7AC@t zM*J2r$(r+-sDixY{Jrz3n9$1&r09!ec|Q9(f3hwK-X`Q4AH@7+x=mf%V)*r@BvU6= zQ!k(=g$4H_{G=1+z}14=E#P*I##>L6lTZa_)LyVIPG^f^2bx`}(WEjX^Zi&vt!B4N zIe)8xD&Af>fZFz6K(Wx%n&UB_3ameq!+_k&BCYo3OzP65k;R@Ue+@|w%_-;Cnn3?^#0|tb^`7>TK8LaCA{mF$Kn3$-u`X+Pi+o zZePLGBtT4ADXq8exZ#!tCvp-#Sf*KbV0-aPCuvP}D}H4YjdkTXcf0X!KT2OjNHAw@ zS-m|!{n`wf00e*l5C8%|;9n*1 EcWe-6WB>pF diff --git a/test/jdk/sun/security/pkcs11/fips/keystore b/test/jdk/sun/security/pkcs11/fips/keystore deleted file mode 100644 index 36125edde2b1483ffab36a2986641e2164641692..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4760 zcmd5pv3xp*EXlTTWZk>Ca-1LY|(N&pIof|&t;0tAf&7mrv8G{>OLCkxl_i=!z@XOmB_ z3&p!9UWtbatjJ5CCjuv?ksRh`kVZ@{unVMzvzBhbm&1+*y zAX;?jBTrK*W6n=M-ah{JcWqBt;3P2zwDn&P_Z8<5hOM^eG%=U$AsbY-Y#2UFyt;C` zf7G5iZ{l+f_WVj&>n+E_C#TM~jJK|6w{SA2oKtExmhYUujEk-8zO8f_?xk*>;y9@O zEeRHt&=OH8?ZJbEI7S(;dQLl+-%1F8VI#J`w5;;aG|a=BeaV%{)${kHt8&a+1*;u0-BuE>W1zVc`4X9bcI$9_eB-6Ofc&@9~IzAWDAl&sH;nxfYPA`ueD?JPO+?E;ma=2h!!d>7YTXSSEQ!dQafM`*)m-^t8 zsCn7qgD?@935o--#)~fe%0r}w-K7;d?0JUnau%k`3f0VeybL+Vdx_X&PcQ@k0e^-^ zE-r)|R{(onZd=73Hdyt|bp_h*`w{WUJwB4RUsiNJUJ;yf@q=GSTbKY85~hi<`j5}G zwMarGvdRLz?RTA@_tP!rxHx&jLx3H$fT2P6LCGt(yiWq4={u@&D+j<;DUJ21#?F); z@6^xQVmOsSZ=QbW`uv^l!LK$I(IdlMsF!i;jlaoAPjIy(_+spQT`|&f^5lk#RfKTM zfIt*rWF++Hf7>kdJC4D_E!R1AhD9)TQEtLjtZKYVn5Lc~OkA>Cv#BZlAw;9`-OytJ zp^nt^@+PEr9DZDRZ;R%-U#_+&2fyHv71gAAoxmhBl+Tg=Y;V`i>3vE9=M%w=bL{dT zJ?}O4d^x35O#})Qk8Iq&I;>aP5*8`Ns|(rV%8>h3Tk8C(@bowh5Bpc-(?!%{J@wZgKyyYZH9o(Gw}Ph~hN1Qa6R#j(Afpr|gz!KuBOy&04SM49A9~8Lf!6ARCdi>_U@QffU>IDbK6CXZqDuu`{mnX{zc!ZqTmFH zntf>bu_C_HK(g?(U2lE+ zo2F|U;pg&)A%*jWlR5IRjL|+>QI&1p%G~U?+xjbM`weL3{h#)7nD=o&GGRCo%-?d(Thw>a1 zvKWCma~sZo1ab=*3extWn-8H{>h?QxBWIQO*B4SA zsaYvL`~?JdU)Y*n&5+RZI`F%R)0t=Eu%oPS?2@5Vp-J;_?Q0oSlr~98XH{<3d>#-{ zzD06cVyn0L_}+(P_laZ+>gS%!Q~dggKbS=5Ur^0aA2S)U;VAdN_?_YPSHB(IZJb87 zWNY9Z9?$Z;C5-O+r<>T3=WLDZB}Xd9PX#`!Nf39DQMB3YXLe zFB(nC;>;XiyxEGk_*O92?^H8m5LwD5$l7U$uO8{C54L!gYHb_Zf~(pQq2ElJir(K^ zP>!y)s4V{$ESc(H0h}FI*Pj!ibToU=uk_&XTJZIzn%N;4;_}CSWTjfRgg(rpRw%L# zES~#gH7%f5qchC5(uz}RhA))yLiSUX+B)QVk+j#o7MqegfMXtH8}OYw@G$ccLNujW zJ{hkg%Yqf(8x3UCLUd%!+bvn7H_O!vVS9uzkc{%;{=yM%Q@7-IYo7Fb_D#3e5;KZK6fiI$=iP)Hf1G)hKBPKm6gveJLR z|NntVfbY+rp6Fa8zz8BobqX8_0HBU7amG%2edC~>bY^TVkK*l-J{fO86hw9gq7~+Xpf_ z44~SI4clAqQI>xlUF?YoR5-JAyE>+{8Z}E03W0wL?|?HN$7P)nw!$bM(9t7Q6}_f& zSk?#n(~4r)UF^*&*PAX;doM)Oon;j2U5~Kam&I8G39HLz_BI?h1?Y0HO;Qb4>Ngx* z*ZR`Ax~BOfd3j659(P(fxH+yLenF6*_x{?FPJ2O?<@9ECF=5QTm7i|tVc2!2)5Y$B z1e7+%Q}#9mMGheW=!eYMRk7bvTP#B!SePkk>|+gq*j;V%Fa?ExL1Rcpa%s3(q0~r9 z05}E%ASCU{2II*oaP((d$+aY>6#yaR>jx%fi|NFeza1z`eR0uc9O}@R{CV@6&h`^i z%&iK}k47!D5-t0~i?>@}dl2c^F84^fz%(dD+rhOZXDy!(oxigyUW=9@FlPnJA%F56 zjI`I~C(=8|%*l|-sx~rew9V(svs-M~x3@m%u(;TX%BE;BZzJ_SrJ5{19uDx;a7d)tOon^i{t zDXpyG&aG>#=euGi>&6<^O*widw90&>MAy1bFS|@otye8Q82-w}$Zl3RzZFw~CcfG% zbH1dS*B>3k-K%p46Yv9p$d9Or{>^{t-y@-u?{5osVPubdD}Xy>!X^CgYybrEic(~= zvKbrMcI0vvxq5sqfj4gI6|WlgS(SD!M1`XYt@_FiKc&!l8jMOMXzVsAZt3?$!**@v z6VFZW+bC7P$Jac6D`7J1)9{!%a~Au4K!iT0Q#~aI8^~?lW9Sy_BpCTu$Gb1@K=M4% zBx7o1j5DvG_mUc))y}HsH_`jX_(1+4gw0rNZ4Oe3M{+fHf8U!?sbIJ{C1XQAAnn%^ zO~nxNDrZ4Ci~GrOH%1Mv=p;Gty-??iSXOK44SFuQKrCvZ)8hU&r{0VZt2!lW=SwK&lq3s~%hNN>dQemUZj8aM`wq-u{XjNa;@OYO}h zRj1yW?7_wUt5HETk&zHpa?QHz#uYvxr=pM(0T`&o6E>H(XL((*<>$)rhD!JBQP| zrpafvZ>^SeWv}hc&t~LyU#_LcI8h~nTh?pS*}lO&$F#I0KmRK{qD`#4zQdB>s45)^tS)j6EV!V=-MV9g!BH0A?wbb{AFcKt40;+VrFfX z+&pT1alwa*i5O991oPqlYAg(6Z5X1FPV6q5RfXM1un0{Oo+*BER_uA1e=5E>oOX{_ z&S7KU;RYa}(qFRivcfDSz9MRR_Ue~>%CrRM>k%QAf=+<3%F&RKD1;ad0uv)H40+@@ zuryjzgy}4>$>CFero4se@6KH*k(pgASf=6{evJq*XN1+>rq(nNqC4DgsucOFu;jvJ z_-Q{Pu*!S-EhTXXb@uo}=MAeb-ieXpe@%KUS^&VEu|D)E>G6V{tD%_=YoR=|GeQ%4 z8QjW)&0Y&vvqbDZ6ke>fBGsEL{1@jTQXr%_m`z{GCn(jREnQ|?X^LQjr7~`gxdCS5 s{7%dFMsR1jBDqk|I2an$u`afJuTBI(#eM~OoI*kvWoaIQqJ)5d0RV~9G5`Po diff --git a/test/jdk/sun/security/pkcs11/fips/secmod.db b/test/jdk/sun/security/pkcs11/fips/secmod.db deleted file mode 100644 index 5418eea41d65e3e7e740b5387f473a31fc55e48c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmeI)%Su8~6adhZK{yGTG}RLgE=>e;d}$B_5{2Lw__&H>8dgw)pmFoQFQV@VyLyG1 zG?Tzs8#d>)Igj-LC+zHZLI|Z0_TEE?c{l8au$4E94CPfPUtdmaFWco(QS>@_`pD-N zv8Y+(pGUd4&!3;`Kmr5^5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAh0%pQuVFcs2)`tm2Tx`ZM)it009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0Rja6yTDF};brURkL|~+Cl_-Em+f|JPVTbV zq%)3Z%~m_M&QII%uwIWB)BgQ9%gaxD)5%~o?2l$?QcGelo87f$*KlUD}3 zY@Awc9&O)w85vnv84Mbm4Y>_C*_cCF*o2uvgJB#FVJ2rsLm>kJkPN#pr*mmRYEemM zUcRBcfhIIn@BfuW(ffq|igsX-KwYX;<+LAis( zm5uX}LywV_fw{347=oQljg1VOykH!eOAPTG!~ zk)IyMIv4s*VwT;OQy=SbR{YI%AIpu^kM>V1-*;ib2is2x4A1kK=_$F=)r{Z0R6N{I{8@4!YtCI2hWq_Crf>f+ zM(NvsxVPijgp&mmA314fTAwSBKg06jN&ks+FQQkpT)c4Ha9{g}9pLoI0gmyMVsP^8 zKD|yHo;;Zy44Rm2fJyWhFnJa!+8A)Nu>+ImISUr%!In6U%z-J=)C86|jX(($#2qAw zvx#v#FqiAVf{zi%kq0HrzxBb5vZX?rLHE7p=)HOJ{F~tRAe;9t42R|H8@2_iWxB>X zC;JYN zlm1~H{`}aAWup8nzni~ZJ}P&Z$uvYbN^GLhx6;q+v=gsuz5k@dEIIe02jg)jQHJRW z0sW%N+-EjT+S#<|bqn{02$`=Sr+t68p!M2p+k2%KF{EtX?(!4EN!- zWp7Fkj12GFbtTgOSs}YXW5X6tu|nk+J{n@e+s|_v^_*Dt&_=APJEW#pQ0Mms18+4Vf3;7civNr zxv_WCYbuho!mM#tl zcXgh>zjvHAU9y+^+m*QPVZ!Z!Yv-8GdJ*-!qgn&#cd2pu;5Mre9bw z(S849<8PMtilS55eRj20F^NdN;#NAU`u)v{zJ;njl`PGNKWM+1^4;m9Mrr%QOOH=Y NIaN~O`kGBF8~`DSC5r$6 From 5a97e73e5ac3b128678d62eeb8f530e5fa04b008 Mon Sep 17 00:00:00 2001 From: Anthony Scarpino Date: Tue, 12 Feb 2019 14:08:07 -0800 Subject: [PATCH 051/101] 8215790: Delegated task created by SSLEngine throws java.nio.BufferUnderflowException Reviewed-by: jnimeh --- .../classes/sun/security/ssl/ClientHello.java | 9 ++- .../ClientHelloBufferUnderflowException.java | 81 +++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 test/jdk/javax/net/ssl/interop/ClientHelloBufferUnderflowException.java diff --git a/src/java.base/share/classes/sun/security/ssl/ClientHello.java b/src/java.base/share/classes/sun/security/ssl/ClientHello.java index 53b74223bfb..de50313e511 100644 --- a/src/java.base/share/classes/sun/security/ssl/ClientHello.java +++ b/src/java.base/share/classes/sun/security/ssl/ClientHello.java @@ -803,8 +803,13 @@ final class ClientHello { shc.sslConfig.getEnabledExtensions( SSLHandshake.CLIENT_HELLO); - ClientHelloMessage chm = - new ClientHelloMessage(shc, message, enabledExtensions); + ClientHelloMessage chm; + try { + chm = new ClientHelloMessage(shc, message, enabledExtensions); + } catch (Exception e) { + throw shc.conContext.fatal(Alert.HANDSHAKE_FAILURE, + "ClientHelloMessage failure", e); + } if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { SSLLogger.fine("Consuming ClientHello handshake message", chm); } diff --git a/test/jdk/javax/net/ssl/interop/ClientHelloBufferUnderflowException.java b/test/jdk/javax/net/ssl/interop/ClientHelloBufferUnderflowException.java new file mode 100644 index 00000000000..70ef8ba57d7 --- /dev/null +++ b/test/jdk/javax/net/ssl/interop/ClientHelloBufferUnderflowException.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2019, 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 8215790 + * @summary Verify exception + * @modules java.base/sun.security.util + * @run main/othervm ClientHelloBufferUnderflowException + */ + +import sun.security.util.HexDumpEncoder; +import javax.net.ssl.SSLHandshakeException; + +public class ClientHelloBufferUnderflowException extends ClientHelloInterOp { + /* + * Main entry point for this test. + */ + public static void main(String args[]) throws Exception { + try { + (new ClientHelloBufferUnderflowException()).run(); + } catch (SSLHandshakeException e) { + System.out.println("Correct exception thrown"); + } catch (Exception e) { + System.out.println("Failed: Exception not SSLHandShakeException"); + System.out.println(e.getMessage()); + throw e; + } + } + + @Override + protected byte[] createClientHelloMessage() { + // The ClientHello message in hex: 16 03 01 00 05 01 00 00 01 03 + // Record Header: + // 16 - type is 0x16 (handshake record) + // 03 01 - protocol version is 3.1 (also known as TLS 1.0) + // 00 05 - 0x05 (5) bytes of handshake message follows + // Handshake Header: + // 01 - handshake message type 0x01 (client hello) + // 00 00 01 - 0x01 (1) bytes of client hello follows + // Client Version: + // 03 - incomplete client version + // + // (Based on https://tls.ulfheim.net) + byte[] bytes = { + 0x16, 0x03, 0x01, 0x00, 0x05, 0x01, 0x00, 0x00, 0x01, 0x03}; + + System.out.println("The ClientHello message used"); + try { + (new HexDumpEncoder()).encodeBuffer(bytes, System.out); + } catch (Exception e) { + // ignore + } + return bytes; + } +} From 23a1cc4b2c067bdb4c29648318499e01188db1c8 Mon Sep 17 00:00:00 2001 From: Robin Westberg Date: Tue, 12 Feb 2019 08:40:43 +0100 Subject: [PATCH 052/101] 8218807: Compilation database (compile_commands.json) may contain obsolete items Reviewed-by: ihse, erikj --- make/Main.gmk | 11 ++++++++--- make/MainSupport.gmk | 7 +++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/make/Main.gmk b/make/Main.gmk index 4cfcec5ef0e..da1b1737f9b 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -766,6 +766,8 @@ else $(foreach m, $(GENSRC_MODULES), $(eval $m-libs-compile-commands: $m-gensrc)) $(foreach m, $(filter $(JAVA_MODULES), $(LIBS_MODULES)), $(eval $m-libs-compile-commands: $m-java)) + $(COMPILE_COMMANDS_TARGETS_HOTSPOT): clean-compile-commands + $(COMPILE_COMMANDS_TARGETS_JDK): clean-compile-commands compile-commands-hotspot: $(COMPILE_COMMANDS_TARGETS_HOTSPOT) compile-commands: $(COMPILE_COMMANDS_TARGETS_HOTSPOT) $(COMPILE_COMMANDS_TARGETS_JDK) @@ -1139,6 +1141,9 @@ clean: $(CLEAN_DIR_TARGETS) clean-docs: $(call CleanDocs) +clean-compile-commands: + $(call CleanMakeSupportDir,compile-commands) + $(CLEAN_DIR_TARGETS): $(call CleanDir,$(patsubst clean-%, %, $@)) @@ -1181,9 +1186,9 @@ dist-clean: clean ) $(ECHO) Cleaned everything, you will have to re-run configure. -ALL_TARGETS += clean clean-docs dist-clean $(CLEAN_DIR_TARGETS) $(CLEAN_SUPPORT_DIR_TARGETS) \ - $(CLEAN_TEST_TARGETS) $(CLEAN_PHASE_TARGETS) $(CLEAN_MODULE_TARGETS) \ - $(CLEAN_MODULE_PHASE_TARGETS) +ALL_TARGETS += clean clean-docs clean-compile-commands dist-clean $(CLEAN_DIR_TARGETS) \ + $(CLEAN_SUPPORT_DIR_TARGETS) $(CLEAN_TEST_TARGETS) $(CLEAN_PHASE_TARGETS) \ + $(CLEAN_MODULE_TARGETS) $(CLEAN_MODULE_PHASE_TARGETS) ################################################################################ # Declare *-only targets for each normal target diff --git a/make/MainSupport.gmk b/make/MainSupport.gmk index d7796c509d5..eda99ddec8a 100644 --- a/make/MainSupport.gmk +++ b/make/MainSupport.gmk @@ -54,6 +54,13 @@ define CleanSupportDir @$(PRINTF) " done\n" endef +define CleanMakeSupportDir + @$(PRINTF) "Cleaning $(strip $1) make support artifacts ..." + @$(PRINTF) "\n" $(LOG_DEBUG) + $(RM) -r $(MAKESUPPORT_OUTPUTDIR)/$(strip $1) + @$(PRINTF) " done\n" +endef + define CleanTest @$(PRINTF) "Cleaning test $(strip $1) ..." @$(PRINTF) "\n" $(LOG_DEBUG) From 052e8733b53df20ee6be8fcb382ebcb341881039 Mon Sep 17 00:00:00 2001 From: Dean Long Date: Wed, 13 Feb 2019 00:30:46 -0800 Subject: [PATCH 053/101] 8218695: problem list tests failing with Graal Reviewed-by: kvn --- test/hotspot/jtreg/ProblemList-graal.txt | 26 +++++++++++++++++++++++- test/jdk/ProblemList-graal.txt | 4 +++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/ProblemList-graal.txt b/test/hotspot/jtreg/ProblemList-graal.txt index 78633a27906..683bcc2ff3b 100644 --- a/test/hotspot/jtreg/ProblemList-graal.txt +++ b/test/hotspot/jtreg/ProblemList-graal.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2019, 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 @@ -195,6 +195,26 @@ compiler/stable/TestStableShort.java 8204347 gener compiler/stable/TestStableUByte.java 8204347 generic-all compiler/stable/TestStableUShort.java 8204347 generic-all +gc/g1/mixedgc/TestOldGenCollectionUsage.java 8196611 generic-all +gc/g1/TestPeriodicCollection.java 8196611 generic-all +gc/parallel/TestPrintGCDetailsVerbose.java 8196611 generic-all +vm/gc/InfiniteList.java 8196611 generic-all +vmTestbase/nsk/stress/except/except007.java 8196611 generic-all +vmTestbase/nsk/stress/except/except008.java 8196611 generic-all +serviceability/tmtools/jstat/GcTest02.java 8196611 generic-all +serviceability/tmtools/jstat/GcCapacityTest.java 8196611 generic-all +serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorMultiArrayTest.java 8196611 generic-all + +runtime/RedefineObject/TestRedefineObject.java 8218399 generic-all + +vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/TestDescription.java 8218167 generic-all + +vmTestbase/gc/lock/jvmti/alloc/jvmtialloclock02/TestDescription.java 8218700 generic-all + +vmTestbase/nsk/jdb/unmonitor/unmonitor001/unmonitor001.java 8218701 generic-all + +vmTestbase/nsk/jdb/clear/clear003/clear003.java 8218701 generic-all + # Graal unit tests org.graalvm.compiler.core.test.CheckGraalInvariants 8205081 org.graalvm.compiler.core.test.OptionsVerifierTest 8205081 @@ -207,3 +227,7 @@ org.graalvm.compiler.core.test.deopt.CompiledMethodTest 8202955 org.graalvm.compiler.hotspot.test.ReservedStackAccessTest 8213567 windows-all org.graalvm.compiler.replacements.test.StringCompressInflateTest 8214947 + +org.graalvm.compiler.hotspot.test.BigIntegerIntrinsicsTest 8217289 + +org.graalvm.compiler.hotspot.test.CheckGraalIntrinsics 8218698 diff --git a/test/jdk/ProblemList-graal.txt b/test/jdk/ProblemList-graal.txt index 4f62982daeb..6cc5214d150 100644 --- a/test/jdk/ProblemList-graal.txt +++ b/test/jdk/ProblemList-graal.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2019, 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 @@ -92,6 +92,8 @@ com/sun/jdi/PopAndStepTest.java 8195635 com/sun/jdi/EarlyReturnTest.java 8195635 generic-all com/sun/jdi/EarlyReturnTest.java 8195635 generic-all +com/sun/jdi/RedefineCrossEvent.java 8218396 generic-all + # Next JFR tests fail with Graal. Assuming 8193210. jdk/jfr/event/compiler/TestCodeSweeper.java 8193210 generic-all jdk/jfr/event/compiler/TestCompilerInlining.java 8193210 generic-all From 2e4ac80e0ca17e7bd5a22607b46a2ab16e9d58d4 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 13 Feb 2019 06:48:34 -0500 Subject: [PATCH 054/101] 8212988: add recent class unloading events to the hs_err log Also moved class unloading logging in expected place. Reviewed-by: never, stuefe --- src/hotspot/share/oops/instanceKlass.cpp | 8 ++++++++ .../share/services/classLoadingService.cpp | 5 ----- src/hotspot/share/utilities/events.cpp | 16 +++++++++++++++ src/hotspot/share/utilities/events.hpp | 20 ++++++++++++++++++- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index fbb68541e4e..b329a257688 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -75,6 +75,7 @@ #include "services/classLoadingService.hpp" #include "services/threadService.hpp" #include "utilities/dtrace.hpp" +#include "utilities/events.hpp" #include "utilities/macros.hpp" #include "utilities/stringUtils.hpp" #ifdef COMPILER1 @@ -2447,6 +2448,13 @@ void InstanceKlass::unload_class(InstanceKlass* ik) { // notify ClassLoadingService of class unload ClassLoadingService::notify_class_unloaded(ik); + if (log_is_enabled(Info, class, unload)) { + ResourceMark rm; + log_info(class, unload)("unloading class %s " INTPTR_FORMAT, ik->external_name(), p2i(ik)); + } + + Events::log_class_unloading(Thread::current(), ik); + #if INCLUDE_JFR assert(ik != NULL, "invariant"); EventClassUnload event; diff --git a/src/hotspot/share/services/classLoadingService.cpp b/src/hotspot/share/services/classLoadingService.cpp index 9691f9fa766..0b16d00c768 100644 --- a/src/hotspot/share/services/classLoadingService.cpp +++ b/src/hotspot/share/services/classLoadingService.cpp @@ -137,11 +137,6 @@ void ClassLoadingService::notify_class_unloaded(InstanceKlass* k) { _class_methods_size->inc(-methods->at(i)->size()); } } - - if (log_is_enabled(Info, class, unload)) { - ResourceMark rm; - log_info(class, unload)("unloading class %s " INTPTR_FORMAT , k->external_name(), p2i(k)); - } } void ClassLoadingService::notify_class_loaded(InstanceKlass* k, bool shared_class) { diff --git a/src/hotspot/share/utilities/events.cpp b/src/hotspot/share/utilities/events.cpp index 278afdc5f6e..15fef2c05e7 100644 --- a/src/hotspot/share/utilities/events.cpp +++ b/src/hotspot/share/utilities/events.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "memory/allocation.inline.hpp" +#include "oops/instanceKlass.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/os.inline.hpp" #include "runtime/osThread.hpp" @@ -37,6 +38,7 @@ EventLog* Events::_logs = NULL; StringEventLog* Events::_messages = NULL; StringEventLog* Events::_exceptions = NULL; StringEventLog* Events::_redefinitions = NULL; +UnloadingEventLog* Events::_class_unloading = NULL; StringEventLog* Events::_deopt_messages = NULL; EventLog::EventLog() { @@ -67,6 +69,7 @@ void Events::init() { _messages = new StringEventLog("Events"); _exceptions = new StringEventLog("Internal exceptions"); _redefinitions = new StringEventLog("Classes redefined"); + _class_unloading = new UnloadingEventLog("Classes unloaded"); _deopt_messages = new StringEventLog("Deoptimization events"); } } @@ -96,3 +99,16 @@ EventMark::~EventMark() { Events::log(NULL, "%s", _buffer.buffer()); } } + +void UnloadingEventLog::log(Thread* thread, InstanceKlass* ik) { + if (!should_log()) return; + + double timestamp = fetch_timestamp(); + // Unloading events are single threaded. + int index = compute_log_index(); + _records[index].thread = thread; + _records[index].timestamp = timestamp; + stringStream st = _records[index].data.stream(); + st.print("Unloading class " INTPTR_FORMAT " ", p2i(ik)); + ik->name()->print_value_on(&st); +} diff --git a/src/hotspot/share/utilities/events.hpp b/src/hotspot/share/utilities/events.hpp index 896c7c853cd..60a66741566 100644 --- a/src/hotspot/share/utilities/events.hpp +++ b/src/hotspot/share/utilities/events.hpp @@ -165,9 +165,17 @@ class StringEventLog : public EventLogBase { logv(thread, format, ap); va_end(ap); } - }; +class InstanceKlass; + +// Event log for class unloading events to materialize the class name in place in the log stream. +class UnloadingEventLog : public EventLogBase { + public: + UnloadingEventLog(const char* name, int count = LogEventsBufferEntries) : EventLogBase(name, count) {} + + void log(Thread* thread, InstanceKlass* ik); +}; class Events : AllStatic { @@ -189,6 +197,8 @@ class Events : AllStatic { // Redefinition related messages static StringEventLog* _redefinitions; + // Class unloading events + static UnloadingEventLog* _class_unloading; public: static void print_all(outputStream* out); @@ -203,6 +213,8 @@ class Events : AllStatic { static void log_redefinition(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + static void log_class_unloading(Thread* thread, InstanceKlass* ik); + static void log_deopt_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); // Register default loggers @@ -236,6 +248,12 @@ inline void Events::log_redefinition(Thread* thread, const char* format, ...) { } } +inline void Events::log_class_unloading(Thread* thread, InstanceKlass* ik) { + if (LogEvents) { + _class_unloading->log(thread, ik); + } +} + inline void Events::log_deopt_message(Thread* thread, const char* format, ...) { if (LogEvents) { va_list ap; From 24b8feeb30b85a17a0c4fd0520f063c47001d7da Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 13 Feb 2019 07:22:09 -0500 Subject: [PATCH 055/101] 8218755: Refix Symbol leak in prepend_host_package_name Fix Symbol refcounting again, add comment and a test. Reviewed-by: kbarrett, dholmes --- .../share/classfile/classFileParser.cpp | 20 +++-- .../defineAnonClass/AnonSymbolLeak.java | 75 ++++++++++++++++++ .../runtime/defineAnonClass/DefineAnon.java | 17 +--- .../defineAnonClass/TestAnonSymbolLeak.java | 77 +++++++++++++++++++ .../defineAnonClass/UnsafeDefMeths.java | 18 +---- 5 files changed, 172 insertions(+), 35 deletions(-) create mode 100644 test/hotspot/jtreg/runtime/defineAnonClass/AnonSymbolLeak.java create mode 100644 test/hotspot/jtreg/runtime/defineAnonClass/TestAnonSymbolLeak.java diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index c6ad0bcaca0..62da6b92b5e 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -5720,9 +5720,8 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loa void ClassFileParser::update_class_name(Symbol* new_class_name) { // Decrement the refcount in the old name, since we're clobbering it. - if (_class_name != NULL) { - _class_name->decrement_refcount(); - } + _class_name->decrement_refcount(); + _class_name = new_class_name; // Increment the refcount of the new name. // Now the ClassFileParser owns this name and will decrement in @@ -5753,11 +5752,16 @@ void ClassFileParser::prepend_host_package_name(const InstanceKlass* unsafe_anon // characters. So, do a strncpy instead of using sprintf("%s..."). strncpy(new_anon_name + host_pkg_len + 1, (char *)_class_name->base(), class_name_len); + // Decrement old _class_name to avoid leaking. + _class_name->decrement_refcount(); + // Create a symbol and update the anonymous class name. - Symbol* new_name = SymbolTable::new_symbol(new_anon_name, + // The new class name is created with a refcount of one. When installed into the InstanceKlass, + // it'll be two and when the ClassFileParser destructor runs, it'll go back to one and get deleted + // when the class is unloaded. + _class_name = SymbolTable::new_symbol(new_anon_name, (int)host_pkg_len + 1 + class_name_len, CHECK); - update_class_name(new_name); } } @@ -5861,7 +5865,8 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream, _has_vanilla_constructor(false), _max_bootstrap_specifier_index(-1) { - update_class_name(name != NULL ? name : vmSymbols::unknown_class_name()); + _class_name = name != NULL ? name : vmSymbols::unknown_class_name(); + _class_name->increment_refcount(); assert(THREAD->is_Java_thread(), "invariant"); assert(_loader_data != NULL, "invariant"); @@ -6086,8 +6091,7 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, Symbol* const class_name_in_cp = cp->klass_name_at(_this_class_index); assert(class_name_in_cp != NULL, "class_name can't be null"); - // Update _class_name which could be null previously - // to reflect the name in the constant pool + // Update _class_name to reflect the name in the constant pool update_class_name(class_name_in_cp); // Don't need to check whether this class name is legal or not. diff --git a/test/hotspot/jtreg/runtime/defineAnonClass/AnonSymbolLeak.java b/test/hotspot/jtreg/runtime/defineAnonClass/AnonSymbolLeak.java new file mode 100644 index 00000000000..eab6bce9bce --- /dev/null +++ b/test/hotspot/jtreg/runtime/defineAnonClass/AnonSymbolLeak.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2019, 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. + */ + +// This is copied from DefineAnon to test Symbol Refcounting for the package prepended name. + +package p1; + +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.misc.Unsafe; + + +class T { + static protected void test0() { System.out.println("test0 (public)"); } + static protected void test1() { System.out.println("test1 (protected)"); } + static /*package-private*/ void test2() { System.out.println("test2 (package)"); } + static private void test3() { System.out.println("test3 (private)"); } +} + +public class AnonSymbolLeak { + + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); + + static Class getAnonClass(Class hostClass, final String className) { + final String superName = "java/lang/Object"; + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES); + cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, className, null, superName, null); + + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC, "test", "()V", null, null); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test0", "()V", false); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test1", "()V", false); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test2", "()V", false); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test3", "()V", false); + mv.visitInsn(Opcodes.RETURN); + mv.visitMaxs(0, 0); + mv.visitEnd(); + + final byte[] classBytes = cw.toByteArray(); + Class invokerClass = UNSAFE.defineAnonymousClass(hostClass, classBytes, new Object[0]); + UNSAFE.ensureClassInitialized(invokerClass); + return invokerClass; + } + + public static void test() throws Throwable { + // AnonClass is injected into package p1. + System.out.println("Injecting from the same package (p1):"); + Class p1cls = getAnonClass(T.class, "AnonClass"); + p1cls.getMethod("test").invoke(null); + } + + public static void main(java.lang.String[] unused) throws Throwable { + test(); + } +} diff --git a/test/hotspot/jtreg/runtime/defineAnonClass/DefineAnon.java b/test/hotspot/jtreg/runtime/defineAnonClass/DefineAnon.java index f73b20dfc5f..656a61a4d86 100644 --- a/test/hotspot/jtreg/runtime/defineAnonClass/DefineAnon.java +++ b/test/hotspot/jtreg/runtime/defineAnonClass/DefineAnon.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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 @@ -27,6 +27,7 @@ * @library /testlibrary * @modules java.base/jdk.internal.org.objectweb.asm * java.management + * java.base/jdk.internal.misc * @compile -XDignore.symbol.file=true DefineAnon.java * @run main/othervm p1.DefineAnon */ @@ -36,7 +37,7 @@ package p1; import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.internal.org.objectweb.asm.MethodVisitor; import jdk.internal.org.objectweb.asm.Opcodes; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; class T { @@ -48,17 +49,7 @@ class T { public class DefineAnon { - private static Unsafe getUnsafe() { - try { - java.lang.reflect.Field singleoneInstanceField = Unsafe.class.getDeclaredField("theUnsafe"); - singleoneInstanceField.setAccessible(true); - return (Unsafe) singleoneInstanceField.get(null); - } catch (Throwable ex) { - throw new RuntimeException("Was unable to get Unsafe instance."); - } - } - - static Unsafe UNSAFE = DefineAnon.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); static Class getAnonClass(Class hostClass, final String className) { final String superName = "java/lang/Object"; diff --git a/test/hotspot/jtreg/runtime/defineAnonClass/TestAnonSymbolLeak.java b/test/hotspot/jtreg/runtime/defineAnonClass/TestAnonSymbolLeak.java new file mode 100644 index 00000000000..6cb90a40751 --- /dev/null +++ b/test/hotspot/jtreg/runtime/defineAnonClass/TestAnonSymbolLeak.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +/* + * @test TestAnonSymbolLeak + * @bug 8218755 + * @requires vm.opt.final.ClassUnloading + * @modules java.base/jdk.internal.misc + * java.base/jdk.internal.org.objectweb.asm + * java.management + * @library /test/lib /runtime/testlibrary + * @build p1.AnonSymbolLeak + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -Xlog:class+unload -XX:+WhiteBoxAPI TestAnonSymbolLeak + */ + +import java.lang.reflect.Method; +import sun.hotspot.WhiteBox; +import jdk.test.lib.Asserts; + +public class TestAnonSymbolLeak { + static String className = "p1.AnonSymbolLeak"; + + private static class ClassUnloadTestMain { + public static void test() throws Exception { + // Load the AnonSymbolLeak class in a new class loader, run it, which loads + // an unsafe anonymous class in the same package p1. Then unload it. + // Then test that the refcount of the symbol created for the prepended name doesn't leak. + ClassLoader cl = ClassUnloadCommon.newClassLoader(); + Class c = cl.loadClass(className); + c.getMethod("test").invoke(null); + cl = null; c = null; + ClassUnloadCommon.triggerUnloading(); + } + } + + public static WhiteBox wb = WhiteBox.getWhiteBox(); + + public static void main(String... args) throws Exception { + String oldName = "AnonClass"; + String prependedName = "p1/AnonClass"; + ClassUnloadCommon.failIf(wb.isClassAlive(className), "should not be loaded"); + int countBeforeOld = wb.getSymbolRefcount(oldName); + int countBefore = wb.getSymbolRefcount(prependedName); + ClassUnloadTestMain.test(); + ClassUnloadCommon.failIf(wb.isClassAlive(className), "should be unloaded"); + int countAfterOld = wb.getSymbolRefcount(oldName); + int countAfter = wb.getSymbolRefcount(prependedName); + Asserts.assertEquals(countBeforeOld, countAfterOld); // no leaks to the old name + System.out.println("count before and after " + countBeforeOld + " " + countAfterOld); + Asserts.assertEquals(countBefore, countAfter); // no leaks to the prepended name + System.out.println("count before and after " + countBefore + " " + countAfter); + } +} diff --git a/test/hotspot/jtreg/runtime/defineAnonClass/UnsafeDefMeths.java b/test/hotspot/jtreg/runtime/defineAnonClass/UnsafeDefMeths.java index eff1477397b..9e8edba0b38 100644 --- a/test/hotspot/jtreg/runtime/defineAnonClass/UnsafeDefMeths.java +++ b/test/hotspot/jtreg/runtime/defineAnonClass/UnsafeDefMeths.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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,6 +28,7 @@ * @library /testlibrary * @modules java.base/jdk.internal.org.objectweb.asm * java.management + * java.base/jdk.internal.misc * @compile -XDignore.symbol.file=true UnsafeDefMeths.java * @run main UnsafeDefMeths */ @@ -35,7 +36,7 @@ import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.internal.org.objectweb.asm.MethodVisitor; import jdk.internal.org.objectweb.asm.Type; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.lang.invoke.MethodType; import java.lang.reflect.Field; @@ -57,18 +58,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.V1_8; public class UnsafeDefMeths { - static final Unsafe UNSAFE; - - static { - try { - Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe"); - unsafeField.setAccessible(true); - UNSAFE = (Unsafe) unsafeField.get(null); - } - catch (Exception e) { - throw new InternalError(e); - } - } + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); interface Resource { Pointer ptr(); From e320983f9f275f8fe5ff61fb56cfd74c1543a1b9 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Wed, 13 Feb 2019 21:24:13 +0800 Subject: [PATCH 056/101] 8218888: keytool -genkeypair should not have the -destalias option Reviewed-by: mullan --- .../share/classes/sun/security/tools/keytool/Main.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/src/java.base/share/classes/sun/security/tools/keytool/Main.java index 2de1fb6dea2..1da690eb698 100644 --- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java +++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java @@ -211,7 +211,7 @@ public final class Main { STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), GENKEYPAIR("Generates.a.key.pair", - ALIAS, KEYALG, KEYSIZE, CURVENAME, SIGALG, DESTALIAS, DNAME, + ALIAS, KEYALG, KEYSIZE, CURVENAME, SIGALG, DNAME, STARTDATE, EXT, VALIDITY, KEYPASS, KEYSTORE, STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), From dce16304c159e3c3872d5f58094aae572c70f572 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Wed, 13 Feb 2019 07:58:04 -0800 Subject: [PATCH 057/101] 8218882: NET_Writev is declared, NET_WriteV is defined Reviewed-by: alanb, chegar --- src/java.base/aix/native/libnet/aix_close.c | 6 +----- src/java.base/linux/native/libnet/linux_close.c | 6 +----- src/java.base/macosx/native/libnet/bsd_close.c | 6 +----- src/java.base/solaris/native/libnet/solaris_close.c | 6 +----- src/java.base/unix/native/libnet/net_util_md.h | 3 +-- 5 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/java.base/aix/native/libnet/aix_close.c b/src/java.base/aix/native/libnet/aix_close.c index 3c2716c135d..8dafe8d5ed2 100644 --- a/src/java.base/aix/native/libnet/aix_close.c +++ b/src/java.base/aix/native/libnet/aix_close.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, SAP SE and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -429,10 +429,6 @@ int NET_Send(int s, void *msg, int len, unsigned int flags) { BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) ); } -int NET_WriteV(int s, const struct iovec * vector, int count) { - BLOCKING_IO_RETURN_INT( s, writev(s, vector, count) ); -} - int NET_SendTo(int s, const void *msg, int len, unsigned int flags, const struct sockaddr *to, int tolen) { BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) ); diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c index 960b71966e9..0f495166d5e 100644 --- a/src/java.base/linux/native/libnet/linux_close.c +++ b/src/java.base/linux/native/libnet/linux_close.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -386,10 +386,6 @@ int NET_Send(int s, void *msg, int len, unsigned int flags) { BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) ); } -int NET_WriteV(int s, const struct iovec * vector, int count) { - BLOCKING_IO_RETURN_INT( s, writev(s, vector, count) ); -} - int NET_SendTo(int s, const void *msg, int len, unsigned int flags, const struct sockaddr *to, int tolen) { BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) ); diff --git a/src/java.base/macosx/native/libnet/bsd_close.c b/src/java.base/macosx/native/libnet/bsd_close.c index 899f6478ec8..50a8ea1e66a 100644 --- a/src/java.base/macosx/native/libnet/bsd_close.c +++ b/src/java.base/macosx/native/libnet/bsd_close.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -390,10 +390,6 @@ int NET_Send(int s, void *msg, int len, unsigned int flags) { BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) ); } -int NET_WriteV(int s, const struct iovec * vector, int count) { - BLOCKING_IO_RETURN_INT( s, writev(s, vector, count) ); -} - int NET_SendTo(int s, const void *msg, int len, unsigned int flags, const struct sockaddr *to, int tolen) { BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) ); diff --git a/src/java.base/solaris/native/libnet/solaris_close.c b/src/java.base/solaris/native/libnet/solaris_close.c index 087c988d26b..066881c678e 100644 --- a/src/java.base/solaris/native/libnet/solaris_close.c +++ b/src/java.base/solaris/native/libnet/solaris_close.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -59,10 +59,6 @@ int NET_ReadV(int s, const struct iovec * vector, int count) { RESTARTABLE_RETURN_INT(readv(s, vector, count)); } -int NET_WriteV(int s, const struct iovec * vector, int count) { - RESTARTABLE_RETURN_INT(writev(s, vector, count)); -} - int NET_Send(int s, void *msg, int len, unsigned int flags) { RESTARTABLE_RETURN_INT(send(s, msg, len, flags)); } diff --git a/src/java.base/unix/native/libnet/net_util_md.h b/src/java.base/unix/native/libnet/net_util_md.h index fbdd3304a85..bbed173f9e0 100644 --- a/src/java.base/unix/native/libnet/net_util_md.h +++ b/src/java.base/unix/native/libnet/net_util_md.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -86,7 +86,6 @@ int NET_ReadV(int s, const struct iovec * vector, int count); int NET_Send(int s, void *msg, int len, unsigned int flags); int NET_SendTo(int s, const void *msg, int len, unsigned int flags, const struct sockaddr *to, int tolen); -int NET_Writev(int s, const struct iovec * vector, int count); int NET_Connect(int s, struct sockaddr *addr, int addrlen); int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen); int NET_SocketClose(int s); From 46d9b91d803872da8c7a190433ceea3ff061541d Mon Sep 17 00:00:00 2001 From: Alex Menkov Date: Wed, 13 Feb 2019 11:04:03 -0800 Subject: [PATCH 058/101] 8218702: [TESTBUG] com/sun/jdi/RepStep.java does not report debuggee errors Reviewed-by: sspitsyn, dtitov --- test/jdk/com/sun/jdi/RepStep.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/jdk/com/sun/jdi/RepStep.java b/test/jdk/com/sun/jdi/RepStep.java index 252cf4d2eea..7d7968b4b6e 100644 --- a/test/jdk/com/sun/jdi/RepStep.java +++ b/test/jdk/com/sun/jdi/RepStep.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, 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 @@ -27,6 +27,7 @@ * @summary RepStep detects missed step events due to lack of * frame pop events (in back-end). * @author Robert Field + * @library /test/lib * * @run compile -g RepStepTarg.java * @run build VMConnection RepStep @@ -37,6 +38,7 @@ import com.sun.jdi.*; import com.sun.jdi.event.*; import com.sun.jdi.request.*; import com.sun.jdi.connect.*; +import jdk.test.lib.process.StreamPumper; import java.util.*; @@ -90,6 +92,7 @@ public class RepStep { EventSet set = queue.remove(); for (EventIterator it = set.eventIterator(); it.hasNext(); ) { Event event = it.nextEvent(); + System.out.println("event: " + String.valueOf(event)); if (event instanceof VMStartEvent) { // get thread for setting step later thread = ((VMStartEvent)event).thread(); @@ -165,6 +168,23 @@ public class RepStep { optionsArg.setValue(VMConnection.getDebuggeeVMOptions()); vm = launcher.launch(connectorArgs); + // redirect stdout/stderr + new StreamPumper(vm.process().getInputStream()) + .addPump(new StreamPumper.LinePump() { + @Override + protected void processLine(String line) { + System.out.println("[debugee_stdout] " + line); + } + }) + .process(); + new StreamPumper(vm.process().getErrorStream()) + .addPump(new StreamPumper.LinePump() { + @Override + protected void processLine(String line) { + System.err.println("[debugee_stderr] " + line); + } + }) + .process(); System.out.println("launched: " + TARGET); } From f03805c4efbc17f62e29a6dc31ad39fa8bea99e1 Mon Sep 17 00:00:00 2001 From: Alex Menkov Date: Wed, 13 Feb 2019 11:08:51 -0800 Subject: [PATCH 059/101] 8214582: BasicJDWPConnectionTest.java: RuntimeException: Could not detect port from '' Reviewed-by: sspitsyn, dtitov --- .../com/sun/jdi/BasicJDWPConnectionTest.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/test/jdk/com/sun/jdi/BasicJDWPConnectionTest.java b/test/jdk/com/sun/jdi/BasicJDWPConnectionTest.java index 8911f5bfbde..a26cfb1ca51 100644 --- a/test/jdk/com/sun/jdi/BasicJDWPConnectionTest.java +++ b/test/jdk/com/sun/jdi/BasicJDWPConnectionTest.java @@ -33,9 +33,11 @@ import java.io.IOException; import java.net.Socket; import java.net.SocketException; +import jdk.test.lib.Utils; import jdk.test.lib.apps.LingeredApp; import java.util.ArrayList; +import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -72,13 +74,27 @@ public class BasicJDWPConnectionTest { } private static Pattern listenRegexp = Pattern.compile("Listening for transport \\b(.+)\\b at address: \\b(\\d+)\\b"); - private static int detectPort(String s) { - Matcher m = listenRegexp.matcher(s); - if (!m.find()) { - throw new RuntimeException("Could not detect port from '" + s + "'"); + private static int detectPort(LingeredApp app) { + long maxWaitTime = System.currentTimeMillis() + + Utils.adjustTimeout(10000); // 10 seconds adjusted for TIMEOUT_FACTOR + while (true) { + String s = app.getProcessStdout(); + Matcher m = listenRegexp.matcher(s); + if (m.find()) { + // m.group(1) is transport, m.group(2) is port + return Integer.parseInt(m.group(2)); + } + if (System.currentTimeMillis() > maxWaitTime) { + throw new RuntimeException("Could not detect port from '" + s + "' (timeout)"); + } + try { + if (app.getProcess().waitFor(500, TimeUnit.MILLISECONDS)) { + throw new RuntimeException("Could not detect port from '" + s + "' (debuggee is terminated)"); + } + } catch (InterruptedException e) { + // ignore + } } - // m.group(1) is transport, m.group(2) is port - return Integer.parseInt(m.group(2)); } public static void positiveTest(String testName, String allowOpt) @@ -89,7 +105,7 @@ public class BasicJDWPConnectionTest { LingeredApp a = LingeredApp.startApp(cmd); int res; try { - res = handshake(detectPort(a.getProcessStdout())); + res = handshake(detectPort(a)); } finally { a.stopApp(); } @@ -107,7 +123,7 @@ public class BasicJDWPConnectionTest { LingeredApp a = LingeredApp.startApp(cmd); int res; try { - res = handshake(detectPort(a.getProcessStdout())); + res = handshake(detectPort(a)); } finally { a.stopApp(); } From 120fdfe6ad4fa8b947c278a9c7c043210c417ef4 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Wed, 13 Feb 2019 11:18:14 -0800 Subject: [PATCH 060/101] 8195060: vm/mlvm/anonloader/stress/byteMutation intermittently times out Reviewed-by: kvn --- .../vm/mlvm/anonloader/share/StressClassLoadingTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/vm/mlvm/anonloader/share/StressClassLoadingTest.java b/test/hotspot/jtreg/vmTestbase/vm/mlvm/anonloader/share/StressClassLoadingTest.java index 5453ac3662d..6459d7c729a 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/mlvm/anonloader/share/StressClassLoadingTest.java +++ b/test/hotspot/jtreg/vmTestbase/vm/mlvm/anonloader/share/StressClassLoadingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2019, 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 @@ -169,7 +169,7 @@ public abstract class StressClassLoadingTest extends MlvmTest { c = CustomClassLoaders.makeClassBytesLoader(classBytes, className) .loadClass(className); } - c.newInstance(); + UnsafeAccess.unsafe.ensureClassInitialized(c); } catch (Throwable e) { Env.traceVerbose(e, "parser caught exception"); } From 29245f8878973d095329d0d6d5eb1f2413ab4b14 Mon Sep 17 00:00:00 2001 From: Lois Foltan Date: Wed, 13 Feb 2019 14:20:40 -0500 Subject: [PATCH 061/101] 8218004: Clean up terminology for shared methods within the JVM for indy and condy support Remove "invoke_dynamic" from the name of several ConstantPool bootstrap helper methods that are shared by both indy and condy. Reviewed-by: coleenp, dholmes, mchung --- .../share/classfile/classFileParser.cpp | 4 +- .../share/interpreter/bytecodeTracer.cpp | 2 +- src/hotspot/share/oops/constantPool.cpp | 72 +++++----- src/hotspot/share/oops/constantPool.hpp | 123 +++++++++--------- .../share/prims/jvmtiRedefineClasses.cpp | 4 +- src/hotspot/share/prims/methodComparator.cpp | 14 +- src/hotspot/share/prims/methodHandles.cpp | 6 +- src/hotspot/share/utilities/constantTag.hpp | 6 + src/hotspot/share/utilities/exceptions.cpp | 4 +- 9 files changed, 119 insertions(+), 116 deletions(-) diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index 62da6b92b5e..996dde685b2 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -564,7 +564,7 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream, } case JVM_CONSTANT_Dynamic: { const int name_and_type_ref_index = - cp->invoke_dynamic_name_and_type_ref_index_at(index); + cp->bootstrap_name_and_type_ref_index_at(index); check_property(valid_cp_range(name_and_type_ref_index, length) && cp->tag_at(name_and_type_ref_index).is_name_and_type(), @@ -579,7 +579,7 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream, } case JVM_CONSTANT_InvokeDynamic: { const int name_and_type_ref_index = - cp->invoke_dynamic_name_and_type_ref_index_at(index); + cp->bootstrap_name_and_type_ref_index_at(index); check_property(valid_cp_range(name_and_type_ref_index, length) && cp->tag_at(name_and_type_ref_index).is_name_and_type(), diff --git a/src/hotspot/share/interpreter/bytecodeTracer.cpp b/src/hotspot/share/interpreter/bytecodeTracer.cpp index 2ffcd30cb80..73b3cd4b8f6 100644 --- a/src/hotspot/share/interpreter/bytecodeTracer.cpp +++ b/src/hotspot/share/interpreter/bytecodeTracer.cpp @@ -382,7 +382,7 @@ void BytecodePrinter::print_field_or_method(int orig_i, int i, outputStream* st) st->print_cr(" %d <%s.%s%s%s> ", i, klass->as_C_string(), name->as_C_string(), sep, signature->as_C_string()); } else { if (tag.is_dynamic_constant() || tag.is_invoke_dynamic()) { - int bsm = constants->invoke_dynamic_bootstrap_method_ref_index_at(i); + int bsm = constants->bootstrap_method_ref_index_at(i); st->print(" bsm=%d", bsm); } st->print_cr(" %d <%s%s%s>", i, name->as_C_string(), sep, signature->as_C_string()); diff --git a/src/hotspot/share/oops/constantPool.cpp b/src/hotspot/share/oops/constantPool.cpp index a3136be1d68..0caef0c07ab 100644 --- a/src/hotspot/share/oops/constantPool.cpp +++ b/src/hotspot/share/oops/constantPool.cpp @@ -625,26 +625,22 @@ int ConstantPool::impl_name_and_type_ref_index_at(int which, bool uncached) { if (!uncached && cache() != NULL) { if (ConstantPool::is_invokedynamic_index(which)) { // Invokedynamic index is index into the constant pool cache - int pool_index = invokedynamic_cp_cache_entry_at(which)->constant_pool_index(); - pool_index = invoke_dynamic_name_and_type_ref_index_at(pool_index); + int pool_index = invokedynamic_bootstrap_ref_index_at(which); + pool_index = bootstrap_name_and_type_ref_index_at(pool_index); assert(tag_at(pool_index).is_name_and_type(), ""); return pool_index; } // change byte-ordering and go via cache i = remap_instruction_operand_from_cache(which); } else { - if (tag_at(which).is_invoke_dynamic() || - tag_at(which).is_dynamic_constant() || - tag_at(which).is_dynamic_constant_in_error()) { - int pool_index = invoke_dynamic_name_and_type_ref_index_at(which); + if (tag_at(which).has_bootstrap()) { + int pool_index = bootstrap_name_and_type_ref_index_at(which); assert(tag_at(pool_index).is_name_and_type(), ""); return pool_index; } } assert(tag_at(i).is_field_or_method(), "Corrupted constant pool"); - assert(!tag_at(i).is_invoke_dynamic() && - !tag_at(i).is_dynamic_constant() && - !tag_at(i).is_dynamic_constant_in_error(), "Must be handled above"); + assert(!tag_at(i).has_bootstrap(), "Must be handled above"); jint ref_index = *int_at_addr(i); return extract_high_short_from_int(ref_index); } @@ -654,7 +650,7 @@ constantTag ConstantPool::impl_tag_ref_at(int which, bool uncached) { if (!uncached && cache() != NULL) { if (ConstantPool::is_invokedynamic_index(which)) { // Invokedynamic index is index into resolved_references - pool_index = invokedynamic_cp_cache_entry_at(which)->constant_pool_index(); + pool_index = invokedynamic_bootstrap_ref_index_at(which); } else { // change byte-ordering and go via cache pool_index = remap_instruction_operand_from_cache(which); @@ -1128,14 +1124,14 @@ oop ConstantPool::resolve_bootstrap_specifier_at_impl(const constantPoolHandle& // JVM_CONSTANT_Dynamic is an ordered pair of [bootm, name&ftype], plus optional arguments // In both cases, the bootm, being a JVM_CONSTANT_MethodHandle, has its own cache entry. // It is accompanied by the optional arguments. - int bsm_index = this_cp->invoke_dynamic_bootstrap_method_ref_index_at(index); + int bsm_index = this_cp->bootstrap_method_ref_index_at(index); oop bsm_oop = this_cp->resolve_possibly_cached_constant_at(bsm_index, CHECK_NULL); if (!java_lang_invoke_MethodHandle::is_instance(bsm_oop)) { THROW_MSG_NULL(vmSymbols::java_lang_LinkageError(), "BSM not an MethodHandle"); } // Extract the optional static arguments. - argc = this_cp->invoke_dynamic_argument_count_at(index); + argc = this_cp->bootstrap_argument_count_at(index); // if there are no static arguments, return the bsm by itself: if (argc == 0 && UseBootstrapCallInfo < 2) return bsm_oop; @@ -1177,7 +1173,7 @@ oop ConstantPool::resolve_bootstrap_specifier_at_impl(const constantPoolHandle& if (!use_BSCI && this_cp->tag_at(index).is_dynamic_constant()) { bool found_unresolved_condy = false; for (int i = 0; i < argc; i++) { - int arg_index = this_cp->invoke_dynamic_argument_index_at(index, i); + int arg_index = this_cp->bootstrap_argument_index_at(index, i); if (this_cp->tag_at(arg_index).is_dynamic_constant()) { // potential recursion point condy -> condy bool found_it = false; @@ -1197,7 +1193,7 @@ oop ConstantPool::resolve_bootstrap_specifier_at_impl(const constantPoolHandle& bool all_resolved = true; for (int i = 0; i < argc; i++) { bool found_it = false; - int arg_index = this_cp->invoke_dynamic_argument_index_at(index, i); + int arg_index = this_cp->bootstrap_argument_index_at(index, i); this_cp->find_cached_constant_at(arg_index, found_it, CHECK_NULL); if (!found_it) { all_resolved = false; break; } } @@ -1244,7 +1240,7 @@ void ConstantPool::copy_bootstrap_arguments_at_impl(const constantPoolHandle& th !(this_cp->tag_at(index).is_invoke_dynamic() || this_cp->tag_at(index).is_dynamic_constant()) || (0 > start_arg || start_arg > end_arg) || - (end_arg > (argc = this_cp->invoke_dynamic_argument_count_at(index))) || + (end_arg > (argc = this_cp->bootstrap_argument_count_at(index))) || (0 > pos || pos > limit) || (info.is_null() || limit > info->length())) { // An index or something else went wrong; throw an error. @@ -1255,7 +1251,7 @@ void ConstantPool::copy_bootstrap_arguments_at_impl(const constantPoolHandle& th // now we can loop safely int info_i = pos; for (int i = start_arg; i < end_arg; i++) { - int arg_index = this_cp->invoke_dynamic_argument_index_at(index, i); + int arg_index = this_cp->bootstrap_argument_index_at(index, i); oop arg_oop; if (must_resolve) { arg_oop = this_cp->resolve_possibly_cached_constant_at(arg_index, CHECK); @@ -1454,10 +1450,10 @@ bool ConstantPool::compare_entry_to(int index1, const constantPoolHandle& cp2, case JVM_CONSTANT_Dynamic: { - int k1 = invoke_dynamic_name_and_type_ref_index_at(index1); - int k2 = cp2->invoke_dynamic_name_and_type_ref_index_at(index2); - int i1 = invoke_dynamic_bootstrap_specifier_index(index1); - int i2 = cp2->invoke_dynamic_bootstrap_specifier_index(index2); + int k1 = bootstrap_name_and_type_ref_index_at(index1); + int k2 = cp2->bootstrap_name_and_type_ref_index_at(index2); + int i1 = bootstrap_methods_attribute_index(index1); + int i2 = cp2->bootstrap_methods_attribute_index(index2); // separate statements and variables because CHECK_false is used bool match_entry = compare_entry_to(k1, cp2, k2, CHECK_false); bool match_operand = compare_operand_to(i1, cp2, i2, CHECK_false); @@ -1466,10 +1462,10 @@ bool ConstantPool::compare_entry_to(int index1, const constantPoolHandle& cp2, case JVM_CONSTANT_InvokeDynamic: { - int k1 = invoke_dynamic_name_and_type_ref_index_at(index1); - int k2 = cp2->invoke_dynamic_name_and_type_ref_index_at(index2); - int i1 = invoke_dynamic_bootstrap_specifier_index(index1); - int i2 = cp2->invoke_dynamic_bootstrap_specifier_index(index2); + int k1 = bootstrap_name_and_type_ref_index_at(index1); + int k2 = cp2->bootstrap_name_and_type_ref_index_at(index2); + int i1 = bootstrap_methods_attribute_index(index1); + int i2 = cp2->bootstrap_methods_attribute_index(index2); // separate statements and variables because CHECK_false is used bool match_entry = compare_entry_to(k1, cp2, k2, CHECK_false); bool match_operand = compare_operand_to(i1, cp2, i2, CHECK_false); @@ -1793,16 +1789,16 @@ void ConstantPool::copy_entry_to(const constantPoolHandle& from_cp, int from_i, case JVM_CONSTANT_Dynamic: case JVM_CONSTANT_DynamicInError: { - int k1 = from_cp->invoke_dynamic_bootstrap_specifier_index(from_i); - int k2 = from_cp->invoke_dynamic_name_and_type_ref_index_at(from_i); + int k1 = from_cp->bootstrap_methods_attribute_index(from_i); + int k2 = from_cp->bootstrap_name_and_type_ref_index_at(from_i); k1 += operand_array_length(to_cp->operands()); // to_cp might already have operands to_cp->dynamic_constant_at_put(to_i, k1, k2); } break; case JVM_CONSTANT_InvokeDynamic: { - int k1 = from_cp->invoke_dynamic_bootstrap_specifier_index(from_i); - int k2 = from_cp->invoke_dynamic_name_and_type_ref_index_at(from_i); + int k1 = from_cp->bootstrap_methods_attribute_index(from_i); + int k2 = from_cp->bootstrap_name_and_type_ref_index_at(from_i); k1 += operand_array_length(to_cp->operands()); // to_cp might already have operands to_cp->invoke_dynamic_at_put(to_i, k1, k2); } break; @@ -2252,7 +2248,7 @@ int ConstantPool::copy_cpool_bytes(int cpool_size, *bytes = tag; idx1 = extract_low_short_from_int(*int_at_addr(idx)); idx2 = extract_high_short_from_int(*int_at_addr(idx)); - assert(idx2 == invoke_dynamic_name_and_type_ref_index_at(idx), "correct half of u4"); + assert(idx2 == bootstrap_name_and_type_ref_index_at(idx), "correct half of u4"); Bytes::put_Java_u2((address) (bytes+1), idx1); Bytes::put_Java_u2((address) (bytes+3), idx2); DBG(printf("JVM_CONSTANT_Dynamic: %hd %hd", idx1, idx2)); @@ -2262,7 +2258,7 @@ int ConstantPool::copy_cpool_bytes(int cpool_size, *bytes = tag; idx1 = extract_low_short_from_int(*int_at_addr(idx)); idx2 = extract_high_short_from_int(*int_at_addr(idx)); - assert(idx2 == invoke_dynamic_name_and_type_ref_index_at(idx), "correct half of u4"); + assert(idx2 == bootstrap_name_and_type_ref_index_at(idx), "correct half of u4"); Bytes::put_Java_u2((address) (bytes+1), idx1); Bytes::put_Java_u2((address) (bytes+3), idx2); DBG(printf("JVM_CONSTANT_InvokeDynamic: %hd %hd", idx1, idx2)); @@ -2443,12 +2439,12 @@ void ConstantPool::print_entry_on(const int index, outputStream* st) { case JVM_CONSTANT_Dynamic : case JVM_CONSTANT_DynamicInError : { - st->print("bootstrap_method_index=%d", invoke_dynamic_bootstrap_method_ref_index_at(index)); - st->print(" type_index=%d", invoke_dynamic_name_and_type_ref_index_at(index)); - int argc = invoke_dynamic_argument_count_at(index); + st->print("bootstrap_method_index=%d", bootstrap_method_ref_index_at(index)); + st->print(" type_index=%d", bootstrap_name_and_type_ref_index_at(index)); + int argc = bootstrap_argument_count_at(index); if (argc > 0) { for (int arg_i = 0; arg_i < argc; arg_i++) { - int arg = invoke_dynamic_argument_index_at(index, arg_i); + int arg = bootstrap_argument_index_at(index, arg_i); st->print((arg_i == 0 ? " arguments={%d" : ", %d"), arg); } st->print("}"); @@ -2457,12 +2453,12 @@ void ConstantPool::print_entry_on(const int index, outputStream* st) { break; case JVM_CONSTANT_InvokeDynamic : { - st->print("bootstrap_method_index=%d", invoke_dynamic_bootstrap_method_ref_index_at(index)); - st->print(" name_and_type_index=%d", invoke_dynamic_name_and_type_ref_index_at(index)); - int argc = invoke_dynamic_argument_count_at(index); + st->print("bootstrap_method_index=%d", bootstrap_method_ref_index_at(index)); + st->print(" name_and_type_index=%d", bootstrap_name_and_type_ref_index_at(index)); + int argc = bootstrap_argument_count_at(index); if (argc > 0) { for (int arg_i = 0; arg_i < argc; arg_i++) { - int arg = invoke_dynamic_argument_index_at(index, arg_i); + int arg = bootstrap_argument_index_at(index, arg_i); st->print((arg_i == 0 ? " arguments={%d" : ", %d"), arg); } st->print("}"); diff --git a/src/hotspot/share/oops/constantPool.hpp b/src/hotspot/share/oops/constantPool.hpp index c1a181a8ba2..db6dd35d8fe 100644 --- a/src/hotspot/share/oops/constantPool.hpp +++ b/src/hotspot/share/oops/constantPool.hpp @@ -246,16 +246,22 @@ class ConstantPool : public Metadata { // The invokedynamic points at a CP cache entry. This entry points back // at the original CP entry (CONSTANT_InvokeDynamic) and also (via f2) at an entry // in the resolved_references array (which provides the appendix argument). - int invokedynamic_cp_cache_index(int index) const { - assert (is_invokedynamic_index(index), "should be a invokedynamic index"); - int cache_index = decode_invokedynamic_index(index); + int invokedynamic_cp_cache_index(int indy_index) const { + assert(is_invokedynamic_index(indy_index), "should be a invokedynamic index"); + int cache_index = decode_invokedynamic_index(indy_index); return cache_index; } - ConstantPoolCacheEntry* invokedynamic_cp_cache_entry_at(int index) const { + ConstantPoolCacheEntry* invokedynamic_cp_cache_entry_at(int indy_index) const { // decode index that invokedynamic points to. - int cp_cache_index = invokedynamic_cp_cache_index(index); + int cp_cache_index = invokedynamic_cp_cache_index(indy_index); return cache()->entry_at(cp_cache_index); } + // Given the per-instruction index of an indy instruction, report the + // main constant pool entry for its bootstrap specifier. + // From there, uncached_name/signature_ref_at will get the name/type. + int invokedynamic_bootstrap_ref_index_at(int indy_index) const { + return invokedynamic_cp_cache_entry_at(indy_index)->constant_pool_index(); + } // Assembly code support static int tags_offset_in_bytes() { return offset_of(ConstantPool, _tags); } @@ -294,14 +300,14 @@ class ConstantPool : public Metadata { *int_at_addr(which) = ref_index; } - void dynamic_constant_at_put(int which, int bootstrap_specifier_index, int name_and_type_index) { + void dynamic_constant_at_put(int which, int bsms_attribute_index, int name_and_type_index) { tag_at_put(which, JVM_CONSTANT_Dynamic); - *int_at_addr(which) = ((jint) name_and_type_index<<16) | bootstrap_specifier_index; + *int_at_addr(which) = ((jint) name_and_type_index<<16) | bsms_attribute_index; } - void invoke_dynamic_at_put(int which, int bootstrap_specifier_index, int name_and_type_index) { + void invoke_dynamic_at_put(int which, int bsms_attribute_index, int name_and_type_index) { tag_at_put(which, JVM_CONSTANT_InvokeDynamic); - *int_at_addr(which) = ((jint) name_and_type_index<<16) | bootstrap_specifier_index; + *int_at_addr(which) = ((jint) name_and_type_index<<16) | bsms_attribute_index; } void unresolved_string_at_put(int which, Symbol* s) { @@ -534,26 +540,22 @@ class ConstantPool : public Metadata { return symbol_at(sym); } - int invoke_dynamic_name_and_type_ref_index_at(int which) { - assert(tag_at(which).is_invoke_dynamic() || - tag_at(which).is_dynamic_constant() || - tag_at(which).is_dynamic_constant_in_error(), "Corrupted constant pool"); + int bootstrap_name_and_type_ref_index_at(int which) { + assert(tag_at(which).has_bootstrap(), "Corrupted constant pool"); return extract_high_short_from_int(*int_at_addr(which)); } - int invoke_dynamic_bootstrap_specifier_index(int which) { - assert(tag_at(which).is_invoke_dynamic() || - tag_at(which).is_dynamic_constant() || - tag_at(which).is_dynamic_constant_in_error(), "Corrupted constant pool"); + int bootstrap_methods_attribute_index(int which) { + assert(tag_at(which).has_bootstrap(), "Corrupted constant pool"); return extract_low_short_from_int(*int_at_addr(which)); } - int invoke_dynamic_operand_base(int which) { - int bootstrap_specifier_index = invoke_dynamic_bootstrap_specifier_index(which); - return operand_offset_at(operands(), bootstrap_specifier_index); + int bootstrap_operand_base(int which) { + int bsms_attribute_index = bootstrap_methods_attribute_index(which); + return operand_offset_at(operands(), bsms_attribute_index); } // The first part of the operands array consists of an index into the second part. // Extract a 32-bit index value from the first part. - static int operand_offset_at(Array* operands, int bootstrap_specifier_index) { - int n = (bootstrap_specifier_index * 2); + static int operand_offset_at(Array* operands, int bsms_attribute_index) { + int n = (bsms_attribute_index * 2); assert(n >= 0 && n+2 <= operands->length(), "oob"); // The first 32-bit index points to the beginning of the second part // of the operands array. Make sure this index is in the first part. @@ -566,8 +568,8 @@ class ConstantPool : public Metadata { assert(offset == 0 || offset >= second_part && offset <= operands->length(), "oob (3)"); return offset; } - static void operand_offset_at_put(Array* operands, int bootstrap_specifier_index, int offset) { - int n = bootstrap_specifier_index * 2; + static void operand_offset_at_put(Array* operands, int bsms_attribute_index, int offset) { + int n = bsms_attribute_index * 2; assert(n >= 0 && n+2 <= operands->length(), "oob"); operands->at_put(n+0, extract_low_short_from_int(offset)); operands->at_put(n+1, extract_high_short_from_int(offset)); @@ -580,20 +582,23 @@ class ConstantPool : public Metadata { #ifdef ASSERT // operand tuples fit together exactly, end to end - static int operand_limit_at(Array* operands, int bootstrap_specifier_index) { - int nextidx = bootstrap_specifier_index + 1; + static int operand_limit_at(Array* operands, int bsms_attribute_index) { + int nextidx = bsms_attribute_index + 1; if (nextidx == operand_array_length(operands)) return operands->length(); else return operand_offset_at(operands, nextidx); } - int invoke_dynamic_operand_limit(int which) { - int bootstrap_specifier_index = invoke_dynamic_bootstrap_specifier_index(which); - return operand_limit_at(operands(), bootstrap_specifier_index); + int bootstrap_operand_limit(int which) { + int bsms_attribute_index = bootstrap_methods_attribute_index(which); + return operand_limit_at(operands(), bsms_attribute_index); } #endif //ASSERT - // layout of InvokeDynamic and Dynamic bootstrap method specifier (in second part of operands array): + // Layout of InvokeDynamic and Dynamic bootstrap method specifier + // data in second part of operands array. This encodes one record in + // the BootstrapMethods attribute. The whole specifier also includes + // the name and type information from the main constant pool entry. enum { _indy_bsm_offset = 0, // CONSTANT_MethodHandle bsm _indy_argc_offset = 1, // u2 argc @@ -602,35 +607,35 @@ class ConstantPool : public Metadata { // These functions are used in RedefineClasses for CP merge - int operand_offset_at(int bootstrap_specifier_index) { - assert(0 <= bootstrap_specifier_index && - bootstrap_specifier_index < operand_array_length(operands()), + int operand_offset_at(int bsms_attribute_index) { + assert(0 <= bsms_attribute_index && + bsms_attribute_index < operand_array_length(operands()), "Corrupted CP operands"); - return operand_offset_at(operands(), bootstrap_specifier_index); + return operand_offset_at(operands(), bsms_attribute_index); } - int operand_bootstrap_method_ref_index_at(int bootstrap_specifier_index) { - int offset = operand_offset_at(bootstrap_specifier_index); + int operand_bootstrap_method_ref_index_at(int bsms_attribute_index) { + int offset = operand_offset_at(bsms_attribute_index); return operands()->at(offset + _indy_bsm_offset); } - int operand_argument_count_at(int bootstrap_specifier_index) { - int offset = operand_offset_at(bootstrap_specifier_index); + int operand_argument_count_at(int bsms_attribute_index) { + int offset = operand_offset_at(bsms_attribute_index); int argc = operands()->at(offset + _indy_argc_offset); return argc; } - int operand_argument_index_at(int bootstrap_specifier_index, int j) { - int offset = operand_offset_at(bootstrap_specifier_index); + int operand_argument_index_at(int bsms_attribute_index, int j) { + int offset = operand_offset_at(bsms_attribute_index); return operands()->at(offset + _indy_argv_offset + j); } - int operand_next_offset_at(int bootstrap_specifier_index) { - int offset = operand_offset_at(bootstrap_specifier_index) + _indy_argv_offset - + operand_argument_count_at(bootstrap_specifier_index); + int operand_next_offset_at(int bsms_attribute_index) { + int offset = operand_offset_at(bsms_attribute_index) + _indy_argv_offset + + operand_argument_count_at(bsms_attribute_index); return offset; } - // Compare a bootsrap specifier in the operands arrays - bool compare_operand_to(int bootstrap_specifier_index1, const constantPoolHandle& cp2, - int bootstrap_specifier_index2, TRAPS); - // Find a bootsrap specifier in the operands array - int find_matching_operand(int bootstrap_specifier_index, const constantPoolHandle& search_cp, + // Compare a bootstrap specifier data in the operands arrays + bool compare_operand_to(int bsms_attribute_index1, const constantPoolHandle& cp2, + int bsms_attribute_index2, TRAPS); + // Find a bootstrap specifier data in the operands array + int find_matching_operand(int bsms_attribute_index, const constantPoolHandle& search_cp, int operands_cur_len, TRAPS); // Resize the operands array with delta_len and delta_size void resize_operands(int delta_len, int delta_size, TRAPS); @@ -639,26 +644,22 @@ class ConstantPool : public Metadata { // Shrink the operands array to a smaller array with new_len length void shrink_operands(int new_len, TRAPS); - int invoke_dynamic_bootstrap_method_ref_index_at(int which) { - assert(tag_at(which).is_invoke_dynamic() || - tag_at(which).is_dynamic_constant() || - tag_at(which).is_dynamic_constant_in_error(), "Corrupted constant pool"); - int op_base = invoke_dynamic_operand_base(which); + int bootstrap_method_ref_index_at(int which) { + assert(tag_at(which).has_bootstrap(), "Corrupted constant pool"); + int op_base = bootstrap_operand_base(which); return operands()->at(op_base + _indy_bsm_offset); } - int invoke_dynamic_argument_count_at(int which) { - assert(tag_at(which).is_invoke_dynamic() || - tag_at(which).is_dynamic_constant() || - tag_at(which).is_dynamic_constant_in_error(), "Corrupted constant pool"); - int op_base = invoke_dynamic_operand_base(which); + int bootstrap_argument_count_at(int which) { + assert(tag_at(which).has_bootstrap(), "Corrupted constant pool"); + int op_base = bootstrap_operand_base(which); int argc = operands()->at(op_base + _indy_argc_offset); DEBUG_ONLY(int end_offset = op_base + _indy_argv_offset + argc; - int next_offset = invoke_dynamic_operand_limit(which)); + int next_offset = bootstrap_operand_limit(which)); assert(end_offset == next_offset, "matched ending"); return argc; } - int invoke_dynamic_argument_index_at(int which, int j) { - int op_base = invoke_dynamic_operand_base(which); + int bootstrap_argument_index_at(int which, int j) { + int op_base = bootstrap_operand_base(which); DEBUG_ONLY(int argc = operands()->at(op_base + _indy_argc_offset)); assert((uint)j < (uint)argc, "oob"); return operands()->at(op_base + _indy_argv_offset + j); diff --git a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp index 79beb1b3426..0dc83c8d61e 100644 --- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp +++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp @@ -512,11 +512,11 @@ void VM_RedefineClasses::append_entry(const constantPoolHandle& scratch_cp, case JVM_CONSTANT_InvokeDynamic: { // Index of the bootstrap specifier in the operands array - int old_bs_i = scratch_cp->invoke_dynamic_bootstrap_specifier_index(scratch_i); + int old_bs_i = scratch_cp->bootstrap_methods_attribute_index(scratch_i); int new_bs_i = find_or_append_operand(scratch_cp, old_bs_i, merge_cp_p, merge_cp_length_p, THREAD); // The bootstrap method NameAndType_info index - int old_ref_i = scratch_cp->invoke_dynamic_name_and_type_ref_index_at(scratch_i); + int old_ref_i = scratch_cp->bootstrap_name_and_type_ref_index_at(scratch_i); int new_ref_i = find_or_append_indirect_entry(scratch_cp, old_ref_i, merge_cp_p, merge_cp_length_p, THREAD); if (new_bs_i != old_bs_i) { diff --git a/src/hotspot/share/prims/methodComparator.cpp b/src/hotspot/share/prims/methodComparator.cpp index b66c295ddb7..c35c855846c 100644 --- a/src/hotspot/share/prims/methodComparator.cpp +++ b/src/hotspot/share/prims/methodComparator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, 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 @@ -123,17 +123,17 @@ bool MethodComparator::args_same(Bytecodes::Code c_old, Bytecodes::Code c_new) { int cpi_old = _old_cp->cache()->entry_at(cpci_old)->constant_pool_index(); int cpi_new = _new_cp->cache()->entry_at(cpci_new)->constant_pool_index(); - int bsm_old = _old_cp->invoke_dynamic_bootstrap_method_ref_index_at(cpi_old); - int bsm_new = _new_cp->invoke_dynamic_bootstrap_method_ref_index_at(cpi_new); + int bsm_old = _old_cp->bootstrap_method_ref_index_at(cpi_old); + int bsm_new = _new_cp->bootstrap_method_ref_index_at(cpi_new); if (!pool_constants_same(bsm_old, bsm_new)) return false; - int cnt_old = _old_cp->invoke_dynamic_argument_count_at(cpi_old); - int cnt_new = _new_cp->invoke_dynamic_argument_count_at(cpi_new); + int cnt_old = _old_cp->bootstrap_argument_count_at(cpi_old); + int cnt_new = _new_cp->bootstrap_argument_count_at(cpi_new); if (cnt_old != cnt_new) return false; for (int arg_i = 0; arg_i < cnt_old; arg_i++) { - int idx_old = _old_cp->invoke_dynamic_argument_index_at(cpi_old, arg_i); - int idx_new = _new_cp->invoke_dynamic_argument_index_at(cpi_new, arg_i); + int idx_old = _old_cp->bootstrap_argument_index_at(cpi_old, arg_i); + int idx_new = _new_cp->bootstrap_argument_index_at(cpi_new, arg_i); if (!pool_constants_same(idx_old, idx_new)) return false; } diff --git a/src/hotspot/share/prims/methodHandles.cpp b/src/hotspot/share/prims/methodHandles.cpp index 54b5559a3d2..78a3ef1012f 100644 --- a/src/hotspot/share/prims/methodHandles.cpp +++ b/src/hotspot/share/prims/methodHandles.cpp @@ -1427,7 +1427,7 @@ JVM_ENTRY(void, MHN_copyOutBootstrapArguments(JNIEnv* env, jobject igcls, if (bss_index_in_pool <= 0 || bss_index_in_pool >= caller->constants()->length() || index_info->int_at(0) - != caller->constants()->invoke_dynamic_argument_count_at(bss_index_in_pool)) { + != caller->constants()->bootstrap_argument_count_at(bss_index_in_pool)) { THROW_MSG(vmSymbols::java_lang_InternalError(), "bad index info (1)"); } objArrayHandle buf(THREAD, (objArrayOop) JNIHandles::resolve(buf_jh)); @@ -1439,7 +1439,7 @@ JVM_ENTRY(void, MHN_copyOutBootstrapArguments(JNIEnv* env, jobject igcls, switch (pseudo_index) { case -4: // bootstrap method { - int bsm_index = caller->constants()->invoke_dynamic_bootstrap_method_ref_index_at(bss_index_in_pool); + int bsm_index = caller->constants()->bootstrap_method_ref_index_at(bss_index_in_pool); pseudo_arg = caller->constants()->resolve_possibly_cached_constant_at(bsm_index, CHECK); break; } @@ -1464,7 +1464,7 @@ JVM_ENTRY(void, MHN_copyOutBootstrapArguments(JNIEnv* env, jobject igcls, } case -1: // argument count { - int argc = caller->constants()->invoke_dynamic_argument_count_at(bss_index_in_pool); + int argc = caller->constants()->bootstrap_argument_count_at(bss_index_in_pool); jvalue argc_value; argc_value.i = (jint)argc; pseudo_arg = java_lang_boxing_object::create(T_INT, &argc_value, CHECK); break; diff --git a/src/hotspot/share/utilities/constantTag.hpp b/src/hotspot/share/utilities/constantTag.hpp index fbc7210e8f9..e085052d4c7 100644 --- a/src/hotspot/share/utilities/constantTag.hpp +++ b/src/hotspot/share/utilities/constantTag.hpp @@ -100,6 +100,12 @@ class constantTag { bool is_dynamic_constant() const { return _tag == JVM_CONSTANT_Dynamic; } bool is_invoke_dynamic() const { return _tag == JVM_CONSTANT_InvokeDynamic; } + bool has_bootstrap() const { + return (_tag == JVM_CONSTANT_Dynamic || + _tag == JVM_CONSTANT_DynamicInError || + _tag == JVM_CONSTANT_InvokeDynamic); + } + bool is_loadable_constant() const { return ((_tag >= JVM_CONSTANT_Integer && _tag <= JVM_CONSTANT_String) || is_method_type() || is_method_handle() || is_dynamic_constant() || diff --git a/src/hotspot/share/utilities/exceptions.cpp b/src/hotspot/share/utilities/exceptions.cpp index 420b49b73f2..95e1cd6a2c0 100644 --- a/src/hotspot/share/utilities/exceptions.cpp +++ b/src/hotspot/share/utilities/exceptions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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 @@ -411,7 +411,7 @@ void Exceptions::wrap_dynamic_exception(Thread* THREAD) { // Pass through an Error, including BootstrapMethodError, any other form // of linkage error, or say ThreadDeath/OutOfMemoryError if (TraceMethodHandles) { - tty->print_cr("[constant/invoke]dynamic passes through an Error for " INTPTR_FORMAT, p2i((void *)exception)); + tty->print_cr("bootstrap method invocation wraps BSME around " INTPTR_FORMAT, p2i((void *)exception)); exception->print(); } return; From 9631b064232c552532cb840283f808e59ef56725 Mon Sep 17 00:00:00 2001 From: Lois Foltan Date: Wed, 13 Feb 2019 15:50:08 -0500 Subject: [PATCH 062/101] 8217998: Remove method_type field associated with the appendix field of an indy or method handle call Removed the unused method_type field associated with the appendix field of an indy or method handle call. Reviewed-by: acorn, coleenp, dlong --- .../cpu/aarch64/templateTable_aarch64.cpp | 3 +- src/hotspot/cpu/arm/templateTable_arm.cpp | 3 +- src/hotspot/cpu/sparc/templateTable_sparc.cpp | 3 +- src/hotspot/cpu/x86/templateTable_x86.cpp | 3 +- src/hotspot/share/ci/ciStreams.cpp | 113 ++++++++++++++---- src/hotspot/share/ci/ciStreams.hpp | 3 +- .../share/classfile/systemDictionary.cpp | 4 - .../share/classfile/systemDictionary.hpp | 2 - .../share/interpreter/interpreterRuntime.cpp | 3 - .../share/interpreter/linkResolver.cpp | 36 ++---- .../share/interpreter/linkResolver.hpp | 9 +- src/hotspot/share/interpreter/rewriter.cpp | 15 +-- src/hotspot/share/interpreter/rewriter.hpp | 17 +-- src/hotspot/share/jvmci/jvmciCompilerToVM.cpp | 1 - src/hotspot/share/oops/constantPool.cpp | 12 +- src/hotspot/share/oops/constantPool.hpp | 3 +- src/hotspot/share/oops/cpCache.cpp | 48 ++------ src/hotspot/share/oops/cpCache.hpp | 21 +--- src/hotspot/share/oops/cpCache.inline.hpp | 4 +- 19 files changed, 141 insertions(+), 162 deletions(-) diff --git a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp index da2508f22aa..451567f654f 100644 --- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -3230,7 +3230,6 @@ void TemplateTable::prepare_invoke(int byte_no, // since the parameter_size includes it. __ push(r19); __ mov(r19, index); - assert(ConstantPoolCacheEntry::_indy_resolved_references_appendix_offset == 0, "appendix expected at index+0"); __ load_resolved_reference_at_index(index, r19); __ pop(r19); __ push(index); // push appendix (MethodType, CallSite, etc.) diff --git a/src/hotspot/cpu/arm/templateTable_arm.cpp b/src/hotspot/cpu/arm/templateTable_arm.cpp index dc1950925e6..48c47ef8234 100644 --- a/src/hotspot/cpu/arm/templateTable_arm.cpp +++ b/src/hotspot/cpu/arm/templateTable_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2019, 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 @@ -3645,7 +3645,6 @@ void TemplateTable::prepare_invoke(int byte_no, Label L_no_push; __ tbz(flags, ConstantPoolCacheEntry::has_appendix_shift, L_no_push); __ mov(temp, index); - assert(ConstantPoolCacheEntry::_indy_resolved_references_appendix_offset == 0, "appendix expected at index+0"); __ load_resolved_reference_at_index(index, temp); __ verify_oop(index); __ push_ptr(index); // push appendix (MethodType, CallSite, etc.) diff --git a/src/hotspot/cpu/sparc/templateTable_sparc.cpp b/src/hotspot/cpu/sparc/templateTable_sparc.cpp index 67792cfa771..ee2889f3d05 100644 --- a/src/hotspot/cpu/sparc/templateTable_sparc.cpp +++ b/src/hotspot/cpu/sparc/templateTable_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -2992,7 +2992,6 @@ void TemplateTable::prepare_invoke(int byte_no, // Push the appendix as a trailing parameter. // This must be done before we get the receiver, // since the parameter_size includes it. - assert(ConstantPoolCacheEntry::_indy_resolved_references_appendix_offset == 0, "appendix expected at index+0"); __ load_resolved_reference_at_index(temp, index, /*tmp*/recv); __ verify_oop(temp); __ push_ptr(temp); // push appendix (MethodType, CallSite, etc.) diff --git a/src/hotspot/cpu/x86/templateTable_x86.cpp b/src/hotspot/cpu/x86/templateTable_x86.cpp index 432ba6624a9..d33dd9b1218 100644 --- a/src/hotspot/cpu/x86/templateTable_x86.cpp +++ b/src/hotspot/cpu/x86/templateTable_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -3643,7 +3643,6 @@ void TemplateTable::prepare_invoke(int byte_no, // since the parameter_size includes it. __ push(rbx); __ mov(rbx, index); - assert(ConstantPoolCacheEntry::_indy_resolved_references_appendix_offset == 0, "appendix expected at index+0"); __ load_resolved_reference_at_index(index, rbx); __ pop(rbx); __ push(index); // push appendix (MethodType, CallSite, etc.) diff --git a/src/hotspot/share/ci/ciStreams.cpp b/src/hotspot/share/ci/ciStreams.cpp index d59afcb9afe..dcb24c446a2 100644 --- a/src/hotspot/share/ci/ciStreams.cpp +++ b/src/hotspot/share/ci/ciStreams.cpp @@ -334,15 +334,91 @@ ciMethod* ciBytecodeStream::get_method(bool& will_link, ciSignature* *declared_s ciMethod* m = env->get_method_by_index(cpool, get_method_index(), cur_bc(), _holder); will_link = m->is_loaded(); - // Use the MethodType stored in the CP cache to create a signature + // Use the signature stored in the CP cache to create a signature // with correct types (in respect to class loaders). - if (has_method_type()) { - ciSymbol* sig_sym = env->get_symbol(cpool->symbol_at(get_method_signature_index(cpool))); - ciKlass* pool_holder = env->get_klass(cpool->pool_holder()); - ciMethodType* method_type = get_method_type(); - ciSignature* declared_signature = new (env->arena()) ciSignature(pool_holder, sig_sym, method_type); - (*declared_signature_result) = declared_signature; + // + // In classic Java (before Java 7) there is never the slightest + // difference between the signature at the call site and that of the + // method. Such a difference would have been a type error in the + // JVM. + // + // Now there are a few circumstances where the signature of a call + // site (which controls the outgoing stacked arguments) can differ + // from the signature of the method (which controls the receipt of + // those arguments at the method entry point). + // + // A. The signatures can differ if the callee is a static method and + // the caller thinks it is calling a non-static method (VH.get). + // This requires the method signature to have an explicit leading + // argument for the implicit 'this', not present at the call site. + // + // B. The call site can have less specific parameter types than the + // method, allowing loosely-typed code to handle strongly-typed + // methods. This happens with linkToStatic and related linker + // commands. Obviously the loosely-typed code has to ensure that + // the strongly typed method's invariants are respected, and this is + // done by issuing dynamic casts. + // + // C. The call site can have more specific parameter types than the + // method, allowing loosely-typed methods to handle strongly-typed + // requests. + // + // D. There are corresponding effects with return values, such as + // boolean method returning an int to an int-receiving call site, + // even though the method thought it returned just a boolean. + // + // E. The calling sequence at a particular call site may add an + // "appendix" argument not mentioned in the call site signature. It + // is expected by the method signature, though, and this adds to the + // method's arity, even after 'this' parameter effects (A) are + // discounted. Appendixes are used by invokehandle and + // invokedynamic instructions. + // + // F. A linker method (linkToStatic, etc.) can also take an extra + // argument, a MemberName which routes the call to a concrete + // strongly-typed method. In this case the linker method may also + // differ in any of the ways A-D. The eventual method will ignore + // the presence of the extra argument. + // + // None of these changes to calling sequences requires an argument + // to be moved or reformatted in any way. This works because all + // references look alike to the JVM, as do all primitives (except + // float/long/double). Another required property of the JVM is + // that, if a trailing argument is added or dropped, the placement + // of other arguments does not change. This allows cases E and F to + // work smoothly, against without any moving or reformatting, + // despite the arity change. + // + if (has_local_signature()) { + Symbol* local_signature = cpool->symbol_at(get_method_signature_index(cpool)); + ciSymbol* sig_sym = env->get_symbol(local_signature); + ciKlass* pool_holder = env->get_klass(cpool->pool_holder()); + ciSignature* call_site_sig = new (env->arena()) ciSignature(pool_holder, cpool, sig_sym); + // Examples of how the call site signature can differ from the method's own signature: + // + // meth = static jboolean java.lang.invoke.VarHandleGuards.guard_LII_Z(jobject, jobject, jint, jint, jobject) + // msig = (Ljava/lang/invoke/VarHandle;Ljava/lang/Object;IILjava/lang/invoke/VarHandle$AccessDescriptor;)Z + // call = (Ljava/util/concurrent/locks/AbstractQueuedSynchronizer;II)Z + // + // meth = static jobject java.lang.invoke.LambdaForm$MH/0x0000000800066840.linkToTargetMethod(jobject, jobject) + // msig = (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + // call = (Ljava/lang/String;)Ljava/util/function/Predicate; + // + (*declared_signature_result) = call_site_sig; + } else { + // We can just use the method's own signature. It may differ from the call site, but not by much. + // + // Examples of how the call site signature can differ from the method's signature: + // + // meth = static final native jint java.lang.invoke.MethodHandle.linkToStatic(jobject, jobject, jint, jint, jobject) + // msig = (Ljava/lang/Object;Ljava/lang/Object;IILjava/lang/invoke/MemberName;)I + // call = (Ljava/lang/invoke/VarHandle;Ljava/lang/Object;IILjava/lang/invoke/MemberName;)Z + // + // meth = final native jint java.lang.invoke.MethodHandle.invokeBasic(jobject, jobject, jint, jint) + // msig = (Ljava/lang/Object;Ljava/lang/Object;II)I + // call = (Ljava/lang/invoke/VarHandle;Ljava/lang/Object;II)Z + // (*declared_signature_result) = m->signature(); } return m; @@ -372,27 +448,14 @@ ciObject* ciBytecodeStream::get_appendix() { } // ------------------------------------------------------------------ -// ciBytecodeStream::has_method_type +// ciBytecodeStream::has_local_signature // -// Returns true if there is a MethodType argument stored in the -// constant pool cache at the current bci. -bool ciBytecodeStream::has_method_type() { +// Returns true if the method stored in the constant +// pool cache at the current bci has a local signature. +bool ciBytecodeStream::has_local_signature() { GUARDED_VM_ENTRY( constantPoolHandle cpool(_method->get_Method()->constants()); - return ConstantPool::has_method_type_at_if_loaded(cpool, get_method_index()); - ) -} - -// ------------------------------------------------------------------ -// ciBytecodeStream::get_method_type -// -// Return the MethodType stored in the constant pool cache at -// the current bci. -ciMethodType* ciBytecodeStream::get_method_type() { - GUARDED_VM_ENTRY( - constantPoolHandle cpool(_method->get_Method()->constants()); - oop method_type_oop = ConstantPool::method_type_at_if_loaded(cpool, get_method_index()); - return CURRENT_ENV->get_object(method_type_oop)->as_method_type(); + return ConstantPool::has_local_signature_at_if_loaded(cpool, get_method_index()); ) } diff --git a/src/hotspot/share/ci/ciStreams.hpp b/src/hotspot/share/ci/ciStreams.hpp index 4ddca37310b..8ad963aa486 100644 --- a/src/hotspot/share/ci/ciStreams.hpp +++ b/src/hotspot/share/ci/ciStreams.hpp @@ -245,8 +245,7 @@ public: ciMethod* get_method(bool& will_link, ciSignature* *declared_signature_result); bool has_appendix(); ciObject* get_appendix(); - bool has_method_type(); - ciMethodType* get_method_type(); + bool has_local_signature(); ciKlass* get_declared_method_holder(); int get_method_holder_index(); int get_method_signature_index(const constantPoolHandle& cpool); diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index 437af69c0f1..f10309c0b68 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -2459,7 +2459,6 @@ methodHandle SystemDictionary::find_method_handle_invoker(Klass* klass, Symbol* signature, Klass* accessing_klass, Handle *appendix_result, - Handle *method_type_result, TRAPS) { methodHandle empty; assert(THREAD->can_call_java() ,""); @@ -2492,7 +2491,6 @@ methodHandle SystemDictionary::find_method_handle_invoker(Klass* klass, vmSymbols::linkMethod_signature(), &args, CHECK_(empty)); Handle mname(THREAD, (oop) result.get_jobject()); - (*method_type_result) = method_type; return unpack_method_and_appendix(mname, accessing_klass, appendix_box, appendix_result, THREAD); } @@ -2811,7 +2809,6 @@ methodHandle SystemDictionary::find_dynamic_call_site_invoker(Klass* caller, Symbol* name, Symbol* type, Handle *appendix_result, - Handle *method_type_result, TRAPS) { methodHandle empty; Handle bsm, info; @@ -2853,7 +2850,6 @@ methodHandle SystemDictionary::find_dynamic_call_site_invoker(Klass* caller, vmSymbols::linkCallSite_signature(), &args, CHECK_(empty)); Handle mname(THREAD, (oop) result.get_jobject()); - (*method_type_result) = method_type; return unpack_method_and_appendix(mname, caller, appendix_box, appendix_result, THREAD); } diff --git a/src/hotspot/share/classfile/systemDictionary.hpp b/src/hotspot/share/classfile/systemDictionary.hpp index 384852dea61..87d1e6c57a9 100644 --- a/src/hotspot/share/classfile/systemDictionary.hpp +++ b/src/hotspot/share/classfile/systemDictionary.hpp @@ -481,7 +481,6 @@ public: Symbol* signature, Klass* accessing_klass, Handle *appendix_result, - Handle *method_type_result, TRAPS); // for a given signature, find the internal MethodHandle method (linkTo* or invokeBasic) // (does not ask Java, since this is a low-level intrinsic defined by the JVM) @@ -544,7 +543,6 @@ public: Symbol* name, Symbol* type, Handle *appendix_result, - Handle *method_type_result, TRAPS); // Record the error when the first attempt to resolve a reference from a constant diff --git a/src/hotspot/share/interpreter/interpreterRuntime.cpp b/src/hotspot/share/interpreter/interpreterRuntime.cpp index e45843d1300..13174f93905 100644 --- a/src/hotspot/share/interpreter/interpreterRuntime.cpp +++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp @@ -977,9 +977,6 @@ void InterpreterRuntime::resolve_invokedynamic(JavaThread* thread) { LastFrameAccessor last_frame(thread); const Bytecodes::Code bytecode = Bytecodes::_invokedynamic; - //TO DO: consider passing BCI to Java. - // int caller_bci = last_frame.method()->bci_from(last_frame.bcp()); - // resolve method CallInfo info; constantPoolHandle pool(thread, last_frame.method()->constants()); diff --git a/src/hotspot/share/interpreter/linkResolver.cpp b/src/hotspot/share/interpreter/linkResolver.cpp index f50c86e395e..5e6395a2cf6 100644 --- a/src/hotspot/share/interpreter/linkResolver.cpp +++ b/src/hotspot/share/interpreter/linkResolver.cpp @@ -94,26 +94,21 @@ void CallInfo::set_virtual(Klass* resolved_klass, } void CallInfo::set_handle(const methodHandle& resolved_method, - Handle resolved_appendix, - Handle resolved_method_type, TRAPS) { - set_handle(SystemDictionary::MethodHandle_klass(), resolved_method, resolved_appendix, resolved_method_type, CHECK); + Handle resolved_appendix, TRAPS) { + set_handle(SystemDictionary::MethodHandle_klass(), resolved_method, resolved_appendix, CHECK); } void CallInfo::set_handle(Klass* resolved_klass, const methodHandle& resolved_method, - Handle resolved_appendix, - Handle resolved_method_type, TRAPS) { - if (resolved_method.is_null()) { - THROW_MSG(vmSymbols::java_lang_InternalError(), "resolved method is null"); - } + Handle resolved_appendix, TRAPS) { + guarantee(resolved_method.not_null(), "resolved method is null"); assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic || resolved_method->is_compiled_lambda_form(), "linkMethod must return one of these"); int vtable_index = Method::nonvirtual_vtable_index; assert(!resolved_method->has_vtable_index(), ""); set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); - _resolved_appendix = resolved_appendix; - _resolved_method_type = resolved_method_type; + _resolved_appendix = resolved_appendix; } void CallInfo::set_common(Klass* resolved_klass, @@ -452,7 +447,6 @@ Method* LinkResolver::lookup_method_in_interfaces(const LinkInfo& cp_info) { methodHandle LinkResolver::lookup_polymorphic_method( const LinkInfo& link_info, Handle *appendix_result_or_null, - Handle *method_type_result, TRAPS) { Klass* klass = link_info.resolved_klass(); Symbol* name = link_info.name(); @@ -520,7 +514,6 @@ methodHandle LinkResolver::lookup_polymorphic_method( full_signature, link_info.current_klass(), &appendix, - &method_type, CHECK_NULL); if (TraceMethodHandles) { ttyLocker ttyl; @@ -552,7 +545,6 @@ methodHandle LinkResolver::lookup_polymorphic_method( assert(appendix_result_or_null != NULL, ""); (*appendix_result_or_null) = appendix; - (*method_type_result) = method_type; } return result; } @@ -760,7 +752,7 @@ methodHandle LinkResolver::resolve_method(const LinkInfo& link_info, if (resolved_method.is_null()) { // JSR 292: see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc - resolved_method = lookup_polymorphic_method(link_info, (Handle*)NULL, (Handle*)NULL, THREAD); + resolved_method = lookup_polymorphic_method(link_info, (Handle*)NULL, THREAD); if (HAS_PENDING_EXCEPTION) { nested_exception = Handle(THREAD, PENDING_EXCEPTION); CLEAR_PENDING_EXCEPTION; @@ -1697,10 +1689,8 @@ void LinkResolver::resolve_handle_call(CallInfo& result, resolved_klass == SystemDictionary::VarHandle_klass(), ""); assert(MethodHandles::is_signature_polymorphic_name(link_info.name()), ""); Handle resolved_appendix; - Handle resolved_method_type; - methodHandle resolved_method = lookup_polymorphic_method(link_info, - &resolved_appendix, &resolved_method_type, CHECK); - result.set_handle(resolved_klass, resolved_method, resolved_appendix, resolved_method_type, CHECK); + methodHandle resolved_method = lookup_polymorphic_method(link_info, &resolved_appendix, CHECK); + result.set_handle(resolved_klass, resolved_method, resolved_appendix, CHECK); } void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { @@ -1737,8 +1727,7 @@ void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHan if (!cpce->is_f1_null()) { methodHandle method( THREAD, cpce->f1_as_method()); Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); - Handle method_type(THREAD, cpce->method_type_if_resolved(pool)); - result.set_handle(method, appendix, method_type, THREAD); + result.set_handle(method, appendix, THREAD); Exceptions::wrap_dynamic_exception(CHECK); return; } @@ -1766,8 +1755,7 @@ void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHan if (!cpce->is_f1_null()) { methodHandle method( THREAD, cpce->f1_as_method()); Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); - Handle method_type(THREAD, cpce->method_type_if_resolved(pool)); - result.set_handle(method, appendix, method_type, THREAD); + result.set_handle(method, appendix, THREAD); Exceptions::wrap_dynamic_exception(CHECK); } else { assert(cpce->indy_resolution_failed(), "Resolution failure flag not set"); @@ -1788,17 +1776,15 @@ void LinkResolver::resolve_dynamic_call(CallInfo& result, // JSR 292: this must resolve to an implicitly generated method MH.linkToCallSite(*...) // The appendix argument is likely to be a freshly-created CallSite. Handle resolved_appendix; - Handle resolved_method_type; methodHandle resolved_method = SystemDictionary::find_dynamic_call_site_invoker(current_klass, pool_index, bootstrap_specifier, method_name, method_signature, &resolved_appendix, - &resolved_method_type, THREAD); Exceptions::wrap_dynamic_exception(CHECK); - result.set_handle(resolved_method, resolved_appendix, resolved_method_type, THREAD); + result.set_handle(resolved_method, resolved_appendix, THREAD); Exceptions::wrap_dynamic_exception(CHECK); } diff --git a/src/hotspot/share/interpreter/linkResolver.hpp b/src/hotspot/share/interpreter/linkResolver.hpp index 50747bf995a..e357320e3f9 100644 --- a/src/hotspot/share/interpreter/linkResolver.hpp +++ b/src/hotspot/share/interpreter/linkResolver.hpp @@ -55,7 +55,6 @@ class CallInfo : public StackObj { // others inferred), vtable, itable) int _call_index; // vtable or itable index of selected class method (if any) Handle _resolved_appendix; // extra argument in constant pool (if CPCE::has_appendix) - Handle _resolved_method_type; // MethodType (for invokedynamic and invokehandle call sites) Handle _resolved_method_name; // Object holding the ResolvedMethodName void set_static(Klass* resolved_klass, const methodHandle& resolved_method, TRAPS); @@ -68,10 +67,10 @@ class CallInfo : public StackObj { const methodHandle& selected_method, int vtable_index, TRAPS); void set_handle(const methodHandle& resolved_method, - Handle resolved_appendix, Handle resolved_method_type, TRAPS); + Handle resolved_appendix, TRAPS); void set_handle(Klass* resolved_klass, const methodHandle& resolved_method, - Handle resolved_appendix, Handle resolved_method_type, TRAPS); + Handle resolved_appendix, TRAPS); void set_common(Klass* resolved_klass, Klass* selected_klass, const methodHandle& resolved_method, const methodHandle& selected_method, @@ -98,7 +97,6 @@ class CallInfo : public StackObj { methodHandle resolved_method() const { return _resolved_method; } methodHandle selected_method() const { return _selected_method; } Handle resolved_appendix() const { return _resolved_appendix; } - Handle resolved_method_type() const { return _resolved_method_type; } Handle resolved_method_name() const { return _resolved_method_name; } // Materialize a java.lang.invoke.ResolvedMethodName for this resolved_method void set_resolved_method_name(TRAPS); @@ -207,8 +205,7 @@ class LinkResolver: AllStatic { static Method* lookup_method_in_interfaces(const LinkInfo& link_info); static methodHandle lookup_polymorphic_method(const LinkInfo& link_info, - Handle *appendix_result_or_null, - Handle *method_type_result, TRAPS); + Handle *appendix_result_or_null, TRAPS); JVMCI_ONLY(public:) // Needed for CompilerToVM.resolveMethod() // Not Linktime so doesn't take LinkInfo static methodHandle lookup_instance_method_in_klasses (Klass* klass, Symbol* name, Symbol* signature, diff --git a/src/hotspot/share/interpreter/rewriter.cpp b/src/hotspot/share/interpreter/rewriter.cpp index 265eb645b19..70cf6f8d2ea 100644 --- a/src/hotspot/share/interpreter/rewriter.cpp +++ b/src/hotspot/share/interpreter/rewriter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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 @@ -221,13 +221,13 @@ void Rewriter::maybe_rewrite_invokehandle(address opc, int cp_index, int cache_i MethodHandles::is_signature_polymorphic_name(SystemDictionary::MethodHandle_klass(), _pool->name_ref_at(cp_index))) { // we may need a resolved_refs entry for the appendix - add_invokedynamic_resolved_references_entries(cp_index, cache_index); + add_invokedynamic_resolved_references_entry(cp_index, cache_index); status = +1; } else if (_pool->klass_ref_at_noresolve(cp_index) == vmSymbols::java_lang_invoke_VarHandle() && MethodHandles::is_signature_polymorphic_name(SystemDictionary::VarHandle_klass(), _pool->name_ref_at(cp_index))) { // we may need a resolved_refs entry for the appendix - add_invokedynamic_resolved_references_entries(cp_index, cache_index); + add_invokedynamic_resolved_references_entry(cp_index, cache_index); status = +1; } else { status = -1; @@ -259,7 +259,7 @@ void Rewriter::rewrite_invokedynamic(address bcp, int offset, bool reverse) { if (!reverse) { int cp_index = Bytes::get_Java_u2(p); int cache_index = add_invokedynamic_cp_cache_entry(cp_index); - int resolved_index = add_invokedynamic_resolved_references_entries(cp_index, cache_index); + int resolved_index = add_invokedynamic_resolved_references_entry(cp_index, cache_index); // Replace the trailing four bytes with a CPC index for the dynamic // call site. Unlike other CPC entries, there is one per bytecode, // not just one per distinct CP entry. In other words, the @@ -307,12 +307,9 @@ void Rewriter::patch_invokedynamic_bytecodes() { // invokedynamic resolved references map also points to cp cache and must // add delta to each. int resolved_index = _patch_invokedynamic_refs->at(i); - for (int entry = 0; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) { - assert(_invokedynamic_references_map.at(resolved_index + entry) == cache_index, + assert(_invokedynamic_references_map.at(resolved_index) == cache_index, "should be the same index"); - _invokedynamic_references_map.at_put(resolved_index+entry, - cache_index + delta); - } + _invokedynamic_references_map.at_put(resolved_index, cache_index + delta); } } } diff --git a/src/hotspot/share/interpreter/rewriter.hpp b/src/hotspot/share/interpreter/rewriter.hpp index 97d922f2f87..637011f3c1d 100644 --- a/src/hotspot/share/interpreter/rewriter.hpp +++ b/src/hotspot/share/interpreter/rewriter.hpp @@ -159,19 +159,12 @@ class Rewriter: public StackObj { return ref_index; } - // add a new entries to the resolved_references map (for invokedynamic and invokehandle only) - int add_invokedynamic_resolved_references_entries(int cp_index, int cache_index) { + // add a new entry to the resolved_references map (for invokedynamic and invokehandle only) + int add_invokedynamic_resolved_references_entry(int cp_index, int cache_index) { assert(_resolved_reference_limit >= 0, "must add indy refs after first iteration"); - int ref_index = -1; - for (int entry = 0; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) { - const int index = _resolved_references_map.append(cp_index); // many-to-one - assert(index >= _resolved_reference_limit, ""); - if (entry == 0) { - ref_index = index; - } - assert((index - entry) == ref_index, "entries must be consecutive"); - _invokedynamic_references_map.at_put_grow(index, cache_index, -1); - } + int ref_index = _resolved_references_map.append(cp_index); // many-to-one + assert(ref_index >= _resolved_reference_limit, ""); + _invokedynamic_references_map.at_put_grow(ref_index, cache_index, -1); return ref_index; } diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp index ca89ae52bca..9a3dc521fbb 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp @@ -1241,7 +1241,6 @@ C2V_VMENTRY(jint, isResolvedInvokeHandleInPool, (JNIEnv*, jobject, jobject jvmci vmassert(MethodHandles::is_signature_polymorphic_method(resolved_method()),"!"); vmassert(!MethodHandles::is_signature_polymorphic_static(resolved_method->intrinsic_id()), "!"); vmassert(cp_cache_entry->appendix_if_resolved(cp) == NULL, "!"); - vmassert(cp_cache_entry->method_type_if_resolved(cp) == NULL, "!"); methodHandle m(LinkResolver::linktime_resolve_virtual_method_or_null(link_info)); vmassert(m == resolved_method, "!!"); diff --git a/src/hotspot/share/oops/constantPool.cpp b/src/hotspot/share/oops/constantPool.cpp index 0caef0c07ab..296e26b7bae 100644 --- a/src/hotspot/share/oops/constantPool.cpp +++ b/src/hotspot/share/oops/constantPool.cpp @@ -594,21 +594,13 @@ oop ConstantPool::appendix_at_if_loaded(const constantPoolHandle& cpool, int whi } -bool ConstantPool::has_method_type_at_if_loaded(const constantPoolHandle& cpool, int which) { +bool ConstantPool::has_local_signature_at_if_loaded(const constantPoolHandle& cpool, int which) { if (cpool->cache() == NULL) return false; // nothing to load yet int cache_index = decode_cpcache_index(which, true); ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index); - return e->has_method_type(); + return e->has_local_signature(); } -oop ConstantPool::method_type_at_if_loaded(const constantPoolHandle& cpool, int which) { - if (cpool->cache() == NULL) return NULL; // nothing to load yet - int cache_index = decode_cpcache_index(which, true); - ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index); - return e->method_type_if_resolved(cpool); -} - - Symbol* ConstantPool::impl_name_ref_at(int which, bool uncached) { int name_index = name_ref_index_at(impl_name_and_type_ref_index_at(which, uncached)); return symbol_at(name_index); diff --git a/src/hotspot/share/oops/constantPool.hpp b/src/hotspot/share/oops/constantPool.hpp index db6dd35d8fe..5f436a89636 100644 --- a/src/hotspot/share/oops/constantPool.hpp +++ b/src/hotspot/share/oops/constantPool.hpp @@ -797,8 +797,7 @@ class ConstantPool : public Metadata { static Method* method_at_if_loaded (const constantPoolHandle& this_cp, int which); static bool has_appendix_at_if_loaded (const constantPoolHandle& this_cp, int which); static oop appendix_at_if_loaded (const constantPoolHandle& this_cp, int which); - static bool has_method_type_at_if_loaded (const constantPoolHandle& this_cp, int which); - static oop method_type_at_if_loaded (const constantPoolHandle& this_cp, int which); + static bool has_local_signature_at_if_loaded (const constantPoolHandle& this_cp, int which); static Klass* klass_at_if_loaded (const constantPoolHandle& this_cp, int which); // Routines currently used for annotations (only called by jvm.cpp) but which might be used in the diff --git a/src/hotspot/share/oops/cpCache.cpp b/src/hotspot/share/oops/cpCache.cpp index c239129dc3b..a7615461c4f 100644 --- a/src/hotspot/share/oops/cpCache.cpp +++ b/src/hotspot/share/oops/cpCache.cpp @@ -392,23 +392,22 @@ void ConstantPoolCacheEntry::set_method_handle_common(const constantPoolHandle& const methodHandle adapter = call_info.resolved_method(); const Handle appendix = call_info.resolved_appendix(); - const Handle method_type = call_info.resolved_method_type(); const bool has_appendix = appendix.not_null(); - const bool has_method_type = method_type.not_null(); // Write the flags. + // MHs and indy are always sig-poly and have a local signature. set_method_flags(as_TosState(adapter->result_type()), - ((has_appendix ? 1 : 0) << has_appendix_shift ) | - ((has_method_type ? 1 : 0) << has_method_type_shift) | - ( 1 << is_final_shift ), + ((has_appendix ? 1 : 0) << has_appendix_shift ) | + ( 1 << has_local_signature_shift ) | + ( 1 << is_final_shift ), adapter->size_of_parameters()); if (TraceInvokeDynamic) { ttyLocker ttyl; - tty->print_cr("set_method_handle bc=%d appendix=" PTR_FORMAT "%s method_type=" PTR_FORMAT "%s method=" PTR_FORMAT " ", + tty->print_cr("set_method_handle bc=%d appendix=" PTR_FORMAT "%s method=" PTR_FORMAT " (local signature) ", invoke_code, - p2i(appendix()), (has_appendix ? "" : " (unused)"), - p2i(method_type()), (has_method_type ? "" : " (unused)"), + p2i(appendix()), + (has_appendix ? "" : " (unused)"), p2i(adapter())); adapter->print(); if (has_appendix) appendix()->print(); @@ -435,20 +434,12 @@ void ConstantPoolCacheEntry::set_method_handle_common(const constantPoolHandle& // Store appendix, if any. if (has_appendix) { - const int appendix_index = f2_as_index() + _indy_resolved_references_appendix_offset; + const int appendix_index = f2_as_index(); assert(appendix_index >= 0 && appendix_index < resolved_references->length(), "oob"); assert(resolved_references->obj_at(appendix_index) == NULL, "init just once"); resolved_references->obj_at_put(appendix_index, appendix()); } - // Store MethodType, if any. - if (has_method_type) { - const int method_type_index = f2_as_index() + _indy_resolved_references_method_type_offset; - assert(method_type_index >= 0 && method_type_index < resolved_references->length(), "oob"); - assert(resolved_references->obj_at(method_type_index) == NULL, "init just once"); - resolved_references->obj_at_put(method_type_index, method_type()); - } - release_set_f1(adapter()); // This must be the last one to set (see NOTE above)! // The interpreter assembly code does not check byte_2, @@ -459,6 +450,9 @@ void ConstantPoolCacheEntry::set_method_handle_common(const constantPoolHandle& ttyLocker ttyl; this->print(tty, 0); } + + assert(has_appendix == this->has_appendix(), "proper storage of appendix flag"); + assert(this->has_local_signature(), "proper storage of signature flag"); } bool ConstantPoolCacheEntry::save_and_throw_indy_exc( @@ -544,16 +538,7 @@ Method* ConstantPoolCacheEntry::method_if_resolved(const constantPoolHandle& cpo oop ConstantPoolCacheEntry::appendix_if_resolved(const constantPoolHandle& cpool) { if (!has_appendix()) return NULL; - const int ref_index = f2_as_index() + _indy_resolved_references_appendix_offset; - objArrayOop resolved_references = cpool->resolved_references(); - return resolved_references->obj_at(ref_index); -} - - -oop ConstantPoolCacheEntry::method_type_if_resolved(const constantPoolHandle& cpool) { - if (!has_method_type()) - return NULL; - const int ref_index = f2_as_index() + _indy_resolved_references_method_type_offset; + const int ref_index = f2_as_index(); objArrayOop resolved_references = cpool->resolved_references(); return resolved_references->obj_at(ref_index); } @@ -701,16 +686,7 @@ void ConstantPoolCache::initialize(const intArray& inverse_index_map, for (int ref = 0; ref < invokedynamic_references_map.length(); ref++) { const int cpci = invokedynamic_references_map.at(ref); if (cpci >= 0) { -#ifdef ASSERT - // invokedynamic and invokehandle have more entries; check if they - // all point to the same constant pool cache entry. - for (int entry = 1; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) { - const int cpci_next = invokedynamic_references_map.at(ref + entry); - assert(cpci == cpci_next, "%d == %d", cpci, cpci_next); - } -#endif entry_at(cpci)->initialize_resolved_reference_index(ref); - ref += ConstantPoolCacheEntry::_indy_resolved_references_entries - 1; // skip extra entries } } } diff --git a/src/hotspot/share/oops/cpCache.hpp b/src/hotspot/share/oops/cpCache.hpp index 51238e5b1fa..e9aca49b1c6 100644 --- a/src/hotspot/share/oops/cpCache.hpp +++ b/src/hotspot/share/oops/cpCache.hpp @@ -51,7 +51,7 @@ class PSPromotionManager; // _f2 [ entry specific ] vtable or res_ref index, or vfinal method ptr // _flags [tos|0|F=1|0|0|0|f|v|0 |0000|field_index] (for field entries) // bit length [ 4 |1| 1 |1|1|1|1|1|1 |1 |-3-|----16-----] -// _flags [tos|0|F=0|M|A|I|f|0|vf|indy_rf|000|00000|psize] (for method entries) +// _flags [tos|0|F=0|S|A|I|f|0|vf|indy_rf|000|00000|psize] (for method entries) // bit length [ 4 |1| 1 |1|1|1|1|1|1 |-4--|--8--|--8--] // -------------------------------- @@ -114,7 +114,7 @@ class PSPromotionManager; // _f2 = vtable/itable index (or final Method*) for virtual calls only, // unused by non-virtual. The is_vfinal flag indicates this is a // method pointer for a final method, not an index. -// _flags = method type info (t section), +// _flags = has local signature (MHs and indy), // virtual final bit (vfinal), // parameter size (psize section) // @@ -180,7 +180,7 @@ class ConstantPoolCacheEntry { tos_state_shift = BitsPerInt - tos_state_bits, // see verify_tos_state_shift below // misc. option bits; can be any bit position in [16..27] is_field_entry_shift = 26, // (F) is it a field or a method? - has_method_type_shift = 25, // (M) does the call site have a MethodType? + has_local_signature_shift = 25, // (S) does the call site have a per-site signature (sig-poly methods)? has_appendix_shift = 24, // (A) does the call site have an appendix argument? is_forced_virtual_shift = 23, // (I) is the interface reference forced to virtual mode? is_final_shift = 22, // (f) is the field or method final? @@ -291,19 +291,10 @@ class ConstantPoolCacheEntry { bool save_and_throw_indy_exc(const constantPoolHandle& cpool, int cpool_index, int index, constantTag tag, TRAPS); - // invokedynamic and invokehandle call sites have two entries in the - // resolved references array: - // appendix (at index+0) - // MethodType (at index+1) - enum { - _indy_resolved_references_appendix_offset = 0, - _indy_resolved_references_method_type_offset = 1, - _indy_resolved_references_entries - }; - + // invokedynamic and invokehandle call sites have an "appendix" item in the + // resolved references array. Method* method_if_resolved(const constantPoolHandle& cpool); oop appendix_if_resolved(const constantPoolHandle& cpool); - oop method_type_if_resolved(const constantPoolHandle& cpool); void set_parameter_size(int value); @@ -356,7 +347,7 @@ class ConstantPoolCacheEntry { bool is_vfinal() const { return (_flags & (1 << is_vfinal_shift)) != 0; } bool indy_resolution_failed() const; bool has_appendix() const; - bool has_method_type() const; + bool has_local_signature() const; bool is_method_entry() const { return (_flags & (1 << is_field_entry_shift)) == 0; } bool is_field_entry() const { return (_flags & (1 << is_field_entry_shift)) != 0; } bool is_long() const { return flag_state() == ltos; } diff --git a/src/hotspot/share/oops/cpCache.inline.hpp b/src/hotspot/share/oops/cpCache.inline.hpp index 6285dd9fa82..e5747b6de61 100644 --- a/src/hotspot/share/oops/cpCache.inline.hpp +++ b/src/hotspot/share/oops/cpCache.inline.hpp @@ -71,8 +71,8 @@ inline bool ConstantPoolCacheEntry::has_appendix() const { return (!is_f1_null()) && (_flags & (1 << has_appendix_shift)) != 0; } -inline bool ConstantPoolCacheEntry::has_method_type() const { - return (!is_f1_null()) && (_flags & (1 << has_method_type_shift)) != 0; +inline bool ConstantPoolCacheEntry::has_local_signature() const { + return (!is_f1_null()) && (_flags & (1 << has_local_signature_shift)) != 0; } inline intx ConstantPoolCacheEntry::flags_ord() const { return (intx)OrderAccess::load_acquire(&_flags); } From d2c690e80ba17f762ed1200d26d73b8f757a9312 Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Wed, 13 Feb 2019 17:38:14 -0500 Subject: [PATCH 063/101] 8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions Move files and rename classes. Reviewed-by: tschatzl, lkorinth --- .../ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp | 7 +-- .../s390/gc/g1/g1BarrierSetAssembler_s390.cpp | 7 +-- .../gc/g1/g1BarrierSetAssembler_sparc.cpp | 11 ++-- src/hotspot/share/gc/g1/g1BarrierSet.hpp | 7 ++- src/hotspot/share/gc/g1/g1CollectedHeap.cpp | 25 ++++----- src/hotspot/share/gc/g1/g1CollectedHeap.hpp | 9 ++-- src/hotspot/share/gc/g1/g1ConcurrentMark.cpp | 3 +- .../share/gc/g1/g1ConcurrentRefine.cpp | 11 ++-- .../share/gc/g1/g1ConcurrentRefine.hpp | 1 - .../share/gc/g1/g1ConcurrentRefineThread.cpp | 9 ++-- .../share/gc/g1/g1ConcurrentRefineThread.hpp | 2 - ...irtyCardQueue.cpp => g1DirtyCardQueue.cpp} | 54 +++++++++---------- ...irtyCardQueue.hpp => g1DirtyCardQueue.hpp} | 40 +++++++------- src/hotspot/share/gc/g1/g1EvacFailure.cpp | 10 ++-- src/hotspot/share/gc/g1/g1HotCardCache.cpp | 6 +-- src/hotspot/share/gc/g1/g1HotCardCache.hpp | 5 +- .../share/gc/g1/g1ParScanThreadState.hpp | 6 +-- src/hotspot/share/gc/g1/g1RemSet.cpp | 12 ++--- src/hotspot/share/gc/g1/g1RemSet.hpp | 1 - src/hotspot/share/gc/g1/g1RemSetSummary.cpp | 5 +- src/hotspot/share/gc/g1/g1ThreadLocalData.hpp | 14 ++--- src/hotspot/share/gc/g1/vmStructs_g1.hpp | 2 +- 22 files changed, 125 insertions(+), 122 deletions(-) rename src/hotspot/share/gc/g1/{dirtyCardQueue.cpp => g1DirtyCardQueue.cpp} (78%) rename src/hotspot/share/gc/g1/{dirtyCardQueue.hpp => g1DirtyCardQueue.hpp} (83%) diff --git a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp index c6f2be54363..52ebd4ca955 100644 --- a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,6 +29,7 @@ #include "gc/g1/g1BarrierSetAssembler.hpp" #include "gc/g1/g1BarrierSetRuntime.hpp" #include "gc/g1/g1CardTable.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1SATBMarkQueueSet.hpp" #include "gc/g1/g1ThreadLocalData.hpp" #include "gc/g1/heapRegion.hpp" @@ -512,7 +513,7 @@ void G1BarrierSetAssembler::generate_c1_post_barrier_runtime_stub(StubAssembler* __ bind(restart); - // Get the index into the update buffer. DirtyCardQueue::_index is + // Get the index into the update buffer. G1DirtyCardQueue::_index is // a size_t so ld_ptr is appropriate here. __ ld(tmp2, dirty_card_q_index_byte_offset, R16_thread); @@ -539,7 +540,7 @@ void G1BarrierSetAssembler::generate_c1_post_barrier_runtime_stub(StubAssembler* __ mflr(R0); __ std(R0, _abi(lr), R1_SP); __ push_frame_reg_args(nbytes_save, R0); // dummy frame for C call - __ call_VM_leaf(CAST_FROM_FN_PTR(address, DirtyCardQueueSet::handle_zero_index_for_thread), R16_thread); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1DirtyCardQueueSet::handle_zero_index_for_thread), R16_thread); __ pop_frame(); __ ld(R0, _abi(lr), R1_SP); __ mtlr(R0); diff --git a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp index 2fc9fff0b0a..f7a1b5c732c 100644 --- a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -30,6 +30,7 @@ #include "gc/g1/g1BarrierSet.hpp" #include "gc/g1/g1BarrierSetAssembler.hpp" #include "gc/g1/g1BarrierSetRuntime.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1SATBMarkQueueSet.hpp" #include "gc/g1/g1ThreadLocalData.hpp" #include "gc/g1/heapRegion.hpp" @@ -587,7 +588,7 @@ void G1BarrierSetAssembler::generate_c1_post_barrier_runtime_stub(StubAssembler* __ bind(restart); - // Get the index into the update buffer. DirtyCardQueue::_index is + // Get the index into the update buffer. G1DirtyCardQueue::_index is // a size_t so z_ltg is appropriate here. __ z_ltg(idx, Address(Z_thread, dirty_card_q_index_byte_offset)); @@ -607,7 +608,7 @@ void G1BarrierSetAssembler::generate_c1_post_barrier_runtime_stub(StubAssembler* __ bind(refill); save_volatile_registers(sasm); __ z_lgr(idx, addr_card); // Save addr_card, tmp3 must be non-volatile. - __ call_VM_leaf(CAST_FROM_FN_PTR(address, DirtyCardQueueSet::handle_zero_index_for_thread), + __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1DirtyCardQueueSet::handle_zero_index_for_thread), Z_thread); __ z_lgr(addr_card, idx); restore_volatile_registers(sasm); // Restore addr_card. diff --git a/src/hotspot/cpu/sparc/gc/g1/g1BarrierSetAssembler_sparc.cpp b/src/hotspot/cpu/sparc/gc/g1/g1BarrierSetAssembler_sparc.cpp index 96ce9b13d50..15cebc5fdc6 100644 --- a/src/hotspot/cpu/sparc/gc/g1/g1BarrierSetAssembler_sparc.cpp +++ b/src/hotspot/cpu/sparc/gc/g1/g1BarrierSetAssembler_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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,6 +28,7 @@ #include "gc/g1/g1BarrierSetAssembler.hpp" #include "gc/g1/g1BarrierSetRuntime.hpp" #include "gc/g1/g1CardTable.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1SATBMarkQueueSet.hpp" #include "gc/g1/g1ThreadLocalData.hpp" #include "gc/g1/heapRegion.hpp" @@ -315,7 +316,7 @@ static void generate_dirty_card_log_enqueue(jbyte* byte_map_base) { int dirty_card_q_buf_byte_offset = in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset()); __ bind(restart); - // Load the index into the update buffer. DirtyCardQueue::_index is + // Load the index into the update buffer. G1DirtyCardQueue::_index is // a size_t so ld_ptr is appropriate here. __ ld_ptr(G2_thread, dirty_card_q_index_byte_offset, L0); @@ -333,7 +334,7 @@ static void generate_dirty_card_log_enqueue(jbyte* byte_map_base) { __ bind(refill); address handle_zero = CAST_FROM_FN_PTR(address, - &DirtyCardQueueSet::handle_zero_index_for_thread); + &G1DirtyCardQueueSet::handle_zero_index_for_thread); // This should be rare enough that we can afford to save all the // scratch registers that the calling context might be using. __ mov(G1_scratch, L3); @@ -673,7 +674,7 @@ void G1BarrierSetAssembler::generate_c1_post_barrier_runtime_stub(StubAssembler* __ bind(restart); - // Get the index into the update buffer. DirtyCardQueue::_index is + // Get the index into the update buffer. G1DirtyCardQueue::_index is // a size_t so ld_ptr is appropriate here. __ ld_ptr(G2_thread, dirty_card_q_index_byte_offset, tmp3); @@ -694,7 +695,7 @@ void G1BarrierSetAssembler::generate_c1_post_barrier_runtime_stub(StubAssembler* __ call_VM_leaf(L7_thread_cache, CAST_FROM_FN_PTR(address, - DirtyCardQueueSet::handle_zero_index_for_thread), + G1DirtyCardQueueSet::handle_zero_index_for_thread), G2_thread); __ restore_live_registers(true); diff --git a/src/hotspot/share/gc/g1/g1BarrierSet.hpp b/src/hotspot/share/gc/g1/g1BarrierSet.hpp index 4b60b4b26e1..072d44c3305 100644 --- a/src/hotspot/share/gc/g1/g1BarrierSet.hpp +++ b/src/hotspot/share/gc/g1/g1BarrierSet.hpp @@ -25,11 +25,10 @@ #ifndef SHARE_GC_G1_G1BARRIERSET_HPP #define SHARE_GC_G1_G1BARRIERSET_HPP -#include "gc/g1/dirtyCardQueue.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1SATBMarkQueueSet.hpp" #include "gc/shared/cardTableBarrierSet.hpp" -class DirtyCardQueueSet; class CardTable; class G1CardTable; @@ -42,7 +41,7 @@ class G1BarrierSet: public CardTableBarrierSet { BufferNode::Allocator _satb_mark_queue_buffer_allocator; BufferNode::Allocator _dirty_card_queue_buffer_allocator; G1SATBMarkQueueSet _satb_mark_queue_set; - DirtyCardQueueSet _dirty_card_queue_set; + G1DirtyCardQueueSet _dirty_card_queue_set; static G1BarrierSet* g1_barrier_set() { return barrier_set_cast(BarrierSet::barrier_set()); @@ -88,7 +87,7 @@ class G1BarrierSet: public CardTableBarrierSet { return g1_barrier_set()->_satb_mark_queue_set; } - static DirtyCardQueueSet& dirty_card_queue_set() { + static G1DirtyCardQueueSet& dirty_card_queue_set() { return g1_barrier_set()->_dirty_card_queue_set; } diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp index 381f89563fa..562c8bc10c4 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp @@ -37,6 +37,7 @@ #include "gc/g1/g1ConcurrentRefine.hpp" #include "gc/g1/g1ConcurrentRefineThread.hpp" #include "gc/g1/g1ConcurrentMarkThread.inline.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1EvacStats.inline.hpp" #include "gc/g1/g1FullCollector.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" @@ -107,7 +108,7 @@ size_t G1CollectedHeap::_humongous_object_threshold_in_words = 0; // apply to TLAB allocation, which is not part of this interface: it // is done by clients of this interface.) -class RedirtyLoggedCardTableEntryClosure : public CardTableEntryClosure { +class RedirtyLoggedCardTableEntryClosure : public G1CardTableEntryClosure { private: size_t _num_dirtied; G1CollectedHeap* _g1h; @@ -124,7 +125,7 @@ class RedirtyLoggedCardTableEntryClosure : public CardTableEntryClosure { } public: - RedirtyLoggedCardTableEntryClosure(G1CollectedHeap* g1h) : CardTableEntryClosure(), + RedirtyLoggedCardTableEntryClosure(G1CollectedHeap* g1h) : G1CardTableEntryClosure(), _num_dirtied(0), _g1h(g1h), _g1_ct(g1h->card_table()) { } bool do_card_ptr(jbyte* card_ptr, uint worker_i) { @@ -1811,7 +1812,7 @@ jint G1CollectedHeap::initialize() { } { - DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); + G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); dcqs.set_process_completed_buffers_threshold(concurrent_refine()->yellow_zone()); dcqs.set_max_completed_buffers(concurrent_refine()->red_zone()); } @@ -1954,12 +1955,12 @@ size_t G1CollectedHeap::unused_committed_regions_in_bytes() const { return _hrm->total_free_bytes(); } -void G1CollectedHeap::iterate_hcc_closure(CardTableEntryClosure* cl, uint worker_i) { +void G1CollectedHeap::iterate_hcc_closure(G1CardTableEntryClosure* cl, uint worker_i) { _hot_card_cache->drain(cl, worker_i); } -void G1CollectedHeap::iterate_dirty_card_closure(CardTableEntryClosure* cl, uint worker_i) { - DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); +void G1CollectedHeap::iterate_dirty_card_closure(G1CardTableEntryClosure* cl, uint worker_i) { + G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); size_t n_completed_buffers = 0; while (dcqs.apply_closure_during_gc(cl, worker_i)) { n_completed_buffers++; @@ -2605,10 +2606,10 @@ void G1CollectedHeap::do_concurrent_mark() { size_t G1CollectedHeap::pending_card_num() { size_t extra_cards = 0; for (JavaThreadIteratorWithHandle jtiwh; JavaThread *curr = jtiwh.next(); ) { - DirtyCardQueue& dcq = G1ThreadLocalData::dirty_card_queue(curr); + G1DirtyCardQueue& dcq = G1ThreadLocalData::dirty_card_queue(curr); extra_cards += dcq.size(); } - DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); + G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); size_t buffer_size = dcqs.buffer_size(); size_t buffer_num = dcqs.completed_buffers_num(); @@ -2630,7 +2631,7 @@ class RegisterHumongousWithInCSetFastTestClosure : public HeapRegionClosure { size_t _total_humongous; size_t _candidate_humongous; - DirtyCardQueue _dcq; + G1DirtyCardQueue _dcq; bool humongous_region_is_candidate(G1CollectedHeap* g1h, HeapRegion* region) const { assert(region->is_starts_humongous(), "Must start a humongous object"); @@ -3410,10 +3411,10 @@ void G1CollectedHeap::string_dedup_cleaning(BoolObjectClosure* is_alive, class G1RedirtyLoggedCardsTask : public AbstractGangTask { private: - DirtyCardQueueSet* _queue; + G1DirtyCardQueueSet* _queue; G1CollectedHeap* _g1h; public: - G1RedirtyLoggedCardsTask(DirtyCardQueueSet* queue, G1CollectedHeap* g1h) : AbstractGangTask("Redirty Cards"), + G1RedirtyLoggedCardsTask(G1DirtyCardQueueSet* queue, G1CollectedHeap* g1h) : AbstractGangTask("Redirty Cards"), _queue(queue), _g1h(g1h) { } virtual void work(uint worker_id) { @@ -3434,7 +3435,7 @@ void G1CollectedHeap::redirty_logged_cards() { dirty_card_queue_set().reset_for_par_iteration(); workers()->run_task(&redirty_task); - DirtyCardQueueSet& dcq = G1BarrierSet::dirty_card_queue_set(); + G1DirtyCardQueueSet& dcq = G1BarrierSet::dirty_card_queue_set(); dcq.merge_bufferlists(&dirty_card_queue_set()); assert(dirty_card_queue_set().completed_buffers_num() == 0, "All should be consumed"); diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp index 6f0594c499d..7e76807fc69 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp @@ -31,6 +31,7 @@ #include "gc/g1/g1CollectionSet.hpp" #include "gc/g1/g1CollectorState.hpp" #include "gc/g1/g1ConcurrentMark.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1EdenRegions.hpp" #include "gc/g1/g1EvacFailure.hpp" #include "gc/g1/g1EvacStats.hpp" @@ -758,7 +759,7 @@ private: // A set of cards that cover the objects for which the Rsets should be updated // concurrently after the collection. - DirtyCardQueueSet _dirty_card_queue_set; + G1DirtyCardQueueSet _dirty_card_queue_set; // After a collection pause, convert the regions in the collection set into free // regions. @@ -918,7 +919,7 @@ public: uint num_task_queues() const; // A set of cards where updates happened during the GC - DirtyCardQueueSet& dirty_card_queue_set() { return _dirty_card_queue_set; } + G1DirtyCardQueueSet& dirty_card_queue_set() { return _dirty_card_queue_set; } // Create a G1CollectedHeap with the specified policy. // Must call the initialize method afterwards. @@ -983,10 +984,10 @@ public: void scrub_rem_set(); // Apply the given closure on all cards in the Hot Card Cache, emptying it. - void iterate_hcc_closure(CardTableEntryClosure* cl, uint worker_i); + void iterate_hcc_closure(G1CardTableEntryClosure* cl, uint worker_i); // Apply the given closure on all cards in the Dirty Card Queue Set, emptying it. - void iterate_dirty_card_closure(CardTableEntryClosure* cl, uint worker_i); + void iterate_dirty_card_closure(G1CardTableEntryClosure* cl, uint worker_i); // The shared block offset table array. G1BlockOffsetTable* bot() const { return _bot; } diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index ede0664b6b2..10f3d3d9c4d 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -30,6 +30,7 @@ #include "gc/g1/g1CollectorState.hpp" #include "gc/g1/g1ConcurrentMark.inline.hpp" #include "gc/g1/g1ConcurrentMarkThread.inline.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1HeapVerifier.hpp" #include "gc/g1/g1OopClosures.inline.hpp" #include "gc/g1/g1Policy.hpp" @@ -372,7 +373,7 @@ G1ConcurrentMark::G1ConcurrentMark(G1CollectedHeap* g1h, // _finger set in set_non_marking_state - _worker_id_offset(DirtyCardQueueSet::num_par_ids() + G1ConcRefinementThreads), + _worker_id_offset(G1DirtyCardQueueSet::num_par_ids() + G1ConcRefinementThreads), _max_num_tasks(ParallelGCThreads), // _num_active_tasks set in set_non_marking_state() // _tasks set inside the constructor diff --git a/src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp b/src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp index ac930c977c4..eda6acd19a6 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ #include "gc/g1/g1BarrierSet.hpp" #include "gc/g1/g1ConcurrentRefine.hpp" #include "gc/g1/g1ConcurrentRefineThread.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "logging/log.hpp" #include "memory/allocation.inline.hpp" #include "runtime/java.hpp" @@ -378,7 +379,7 @@ void G1ConcurrentRefine::update_zones(double update_rs_time, void G1ConcurrentRefine::adjust(double update_rs_time, size_t update_rs_processed_buffers, double goal_ms) { - DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); + G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); if (G1UseAdaptiveConcRefinement) { update_zones(update_rs_time, update_rs_processed_buffers, goal_ms); @@ -386,7 +387,7 @@ void G1ConcurrentRefine::adjust(double update_rs_time, // Change the barrier params if (max_num_threads() == 0) { // Disable dcqs notification when there are no threads to notify. - dcqs.set_process_completed_buffers_threshold(DirtyCardQueueSet::ProcessCompletedBuffersThresholdNever); + dcqs.set_process_completed_buffers_threshold(G1DirtyCardQueueSet::ProcessCompletedBuffersThresholdNever); } else { // Worker 0 is the primary; wakeup is via dcqs notification. STATIC_ASSERT(max_yellow_zone <= INT_MAX); @@ -417,7 +418,7 @@ size_t G1ConcurrentRefine::deactivation_threshold(uint worker_id) const { } uint G1ConcurrentRefine::worker_id_offset() { - return DirtyCardQueueSet::num_par_ids(); + return G1DirtyCardQueueSet::num_par_ids(); } void G1ConcurrentRefine::maybe_activate_more_threads(uint worker_id, size_t num_cur_buffers) { @@ -427,7 +428,7 @@ void G1ConcurrentRefine::maybe_activate_more_threads(uint worker_id, size_t num_ } bool G1ConcurrentRefine::do_refinement_step(uint worker_id) { - DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); + G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); size_t curr_buffer_num = dcqs.completed_buffers_num(); // If the number of the buffers falls down into the yellow zone, diff --git a/src/hotspot/share/gc/g1/g1ConcurrentRefine.hpp b/src/hotspot/share/gc/g1/g1ConcurrentRefine.hpp index ce0fbac1a2e..1562f84c629 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentRefine.hpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentRefine.hpp @@ -29,7 +29,6 @@ #include "utilities/globalDefinitions.hpp" // Forward decl -class CardTableEntryClosure; class G1ConcurrentRefine; class G1ConcurrentRefineThread; class outputStream; diff --git a/src/hotspot/share/gc/g1/g1ConcurrentRefineThread.cpp b/src/hotspot/share/gc/g1/g1ConcurrentRefineThread.cpp index b716e35ffeb..7b79b071f1e 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentRefineThread.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentRefineThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ #include "gc/g1/g1BarrierSet.hpp" #include "gc/g1/g1ConcurrentRefine.hpp" #include "gc/g1/g1ConcurrentRefineThread.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/shared/suspendibleThreadSet.hpp" #include "logging/log.hpp" #include "memory/resourceArea.hpp" @@ -65,7 +66,7 @@ void G1ConcurrentRefineThread::wait_for_completed_buffers() { } bool G1ConcurrentRefineThread::is_active() { - DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); + G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); return is_primary() ? dcqs.process_completed_buffers() : _active; } @@ -74,7 +75,7 @@ void G1ConcurrentRefineThread::activate() { if (!is_primary()) { set_active(true); } else { - DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); + G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); dcqs.set_process_completed_buffers(true); } _monitor->notify(); @@ -85,7 +86,7 @@ void G1ConcurrentRefineThread::deactivate() { if (!is_primary()) { set_active(false); } else { - DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); + G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); dcqs.set_process_completed_buffers(false); } } diff --git a/src/hotspot/share/gc/g1/g1ConcurrentRefineThread.hpp b/src/hotspot/share/gc/g1/g1ConcurrentRefineThread.hpp index 8dee30b8d3e..e3ddd111bf5 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentRefineThread.hpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentRefineThread.hpp @@ -25,11 +25,9 @@ #ifndef SHARE_GC_G1_G1CONCURRENTREFINETHREAD_HPP #define SHARE_GC_G1_G1CONCURRENTREFINETHREAD_HPP -#include "gc/g1/dirtyCardQueue.hpp" #include "gc/shared/concurrentGCThread.hpp" // Forward Decl. -class CardTableEntryClosure; class G1ConcurrentRefine; // One or more G1 Concurrent Refinement Threads may be active if concurrent diff --git a/src/hotspot/share/gc/g1/dirtyCardQueue.cpp b/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp similarity index 78% rename from src/hotspot/share/gc/g1/dirtyCardQueue.cpp rename to src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp index ce5bb918008..00715e05014 100644 --- a/src/hotspot/share/gc/g1/dirtyCardQueue.cpp +++ b/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp @@ -23,8 +23,8 @@ */ #include "precompiled.hpp" -#include "gc/g1/dirtyCardQueue.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1FreeIdSet.hpp" #include "gc/g1/g1RemSet.hpp" #include "gc/g1/g1ThreadLocalData.hpp" @@ -42,7 +42,7 @@ // point into the collection set while the mutator is running. // Assumed to be only executed concurrently with the mutator. Yields via // SuspendibleThreadSet after every card. -class G1RefineCardConcurrentlyClosure: public CardTableEntryClosure { +class G1RefineCardConcurrentlyClosure: public G1CardTableEntryClosure { public: bool do_card_ptr(jbyte* card_ptr, uint worker_i) { G1CollectedHeap::heap()->g1_rem_set()->refine_card_concurrently(card_ptr, worker_i); @@ -56,19 +56,19 @@ public: } }; -DirtyCardQueue::DirtyCardQueue(DirtyCardQueueSet* qset, bool permanent) : +G1DirtyCardQueue::G1DirtyCardQueue(G1DirtyCardQueueSet* qset, bool permanent) : // Dirty card queues are always active, so we create them with their // active field set to true. PtrQueue(qset, permanent, true /* active */) { } -DirtyCardQueue::~DirtyCardQueue() { +G1DirtyCardQueue::~G1DirtyCardQueue() { if (!is_permanent()) { flush(); } } -DirtyCardQueueSet::DirtyCardQueueSet(bool notify_when_complete) : +G1DirtyCardQueueSet::G1DirtyCardQueueSet(bool notify_when_complete) : PtrQueueSet(notify_when_complete), _shared_dirty_card_queue(this, true /* permanent */), _free_ids(NULL), @@ -79,19 +79,19 @@ DirtyCardQueueSet::DirtyCardQueueSet(bool notify_when_complete) : _all_active = true; } -DirtyCardQueueSet::~DirtyCardQueueSet() { +G1DirtyCardQueueSet::~G1DirtyCardQueueSet() { delete _free_ids; } // Determines how many mutator threads can process the buffers in parallel. -uint DirtyCardQueueSet::num_par_ids() { +uint G1DirtyCardQueueSet::num_par_ids() { return (uint)os::initial_active_processor_count(); } -void DirtyCardQueueSet::initialize(Monitor* cbl_mon, - BufferNode::Allocator* allocator, - Mutex* lock, - bool init_free_ids) { +void G1DirtyCardQueueSet::initialize(Monitor* cbl_mon, + BufferNode::Allocator* allocator, + Mutex* lock, + bool init_free_ids) { PtrQueueSet::initialize(cbl_mon, allocator); _shared_dirty_card_queue.set_lock(lock); if (init_free_ids) { @@ -99,14 +99,14 @@ void DirtyCardQueueSet::initialize(Monitor* cbl_mon, } } -void DirtyCardQueueSet::handle_zero_index_for_thread(JavaThread* t) { +void G1DirtyCardQueueSet::handle_zero_index_for_thread(JavaThread* t) { G1ThreadLocalData::dirty_card_queue(t).handle_zero_index(); } -bool DirtyCardQueueSet::apply_closure_to_buffer(CardTableEntryClosure* cl, - BufferNode* node, - bool consume, - uint worker_i) { +bool G1DirtyCardQueueSet::apply_closure_to_buffer(G1CardTableEntryClosure* cl, + BufferNode* node, + bool consume, + uint worker_i) { if (cl == NULL) return true; bool result = true; void** buf = BufferNode::make_buffer_from_node(node); @@ -141,7 +141,7 @@ bool DirtyCardQueueSet::apply_closure_to_buffer(CardTableEntryClosure* cl, } while (0) #endif // ASSERT -bool DirtyCardQueueSet::mut_process_buffer(BufferNode* node) { +bool G1DirtyCardQueueSet::mut_process_buffer(BufferNode* node) { guarantee(_free_ids != NULL, "must be"); uint worker_i = _free_ids->claim_par_id(); // temporarily claim an id @@ -156,20 +156,20 @@ bool DirtyCardQueueSet::mut_process_buffer(BufferNode* node) { return result; } -bool DirtyCardQueueSet::refine_completed_buffer_concurrently(uint worker_i, size_t stop_at) { +bool G1DirtyCardQueueSet::refine_completed_buffer_concurrently(uint worker_i, size_t stop_at) { G1RefineCardConcurrentlyClosure cl; return apply_closure_to_completed_buffer(&cl, worker_i, stop_at, false); } -bool DirtyCardQueueSet::apply_closure_during_gc(CardTableEntryClosure* cl, uint worker_i) { +bool G1DirtyCardQueueSet::apply_closure_during_gc(G1CardTableEntryClosure* cl, uint worker_i) { assert_at_safepoint(); return apply_closure_to_completed_buffer(cl, worker_i, 0, true); } -bool DirtyCardQueueSet::apply_closure_to_completed_buffer(CardTableEntryClosure* cl, - uint worker_i, - size_t stop_at, - bool during_pause) { +bool G1DirtyCardQueueSet::apply_closure_to_completed_buffer(G1CardTableEntryClosure* cl, + uint worker_i, + size_t stop_at, + bool during_pause) { assert(!during_pause || stop_at == 0, "Should not leave any completed buffers during a pause"); BufferNode* nd = get_completed_buffer(stop_at); if (nd == NULL) { @@ -189,7 +189,7 @@ bool DirtyCardQueueSet::apply_closure_to_completed_buffer(CardTableEntryClosure* } } -void DirtyCardQueueSet::par_apply_closure_to_all_completed_buffers(CardTableEntryClosure* cl) { +void G1DirtyCardQueueSet::par_apply_closure_to_all_completed_buffers(G1CardTableEntryClosure* cl) { BufferNode* nd = _cur_par_buffer_node; while (nd != NULL) { BufferNode* next = nd->next(); @@ -204,7 +204,7 @@ void DirtyCardQueueSet::par_apply_closure_to_all_completed_buffers(CardTableEntr } } -void DirtyCardQueueSet::abandon_logs() { +void G1DirtyCardQueueSet::abandon_logs() { assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); abandon_completed_buffers(); // Since abandon is done only at safepoints, we can safely manipulate @@ -215,13 +215,13 @@ void DirtyCardQueueSet::abandon_logs() { shared_dirty_card_queue()->reset(); } -void DirtyCardQueueSet::concatenate_log(DirtyCardQueue& dcq) { +void G1DirtyCardQueueSet::concatenate_log(G1DirtyCardQueue& dcq) { if (!dcq.is_empty()) { dcq.flush(); } } -void DirtyCardQueueSet::concatenate_logs() { +void G1DirtyCardQueueSet::concatenate_logs() { // Iterate over all the threads, if we find a partial log add it to // the global list of logs. Temporarily turn off the limit on the number // of outstanding buffers. diff --git a/src/hotspot/share/gc/g1/dirtyCardQueue.hpp b/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp similarity index 83% rename from src/hotspot/share/gc/g1/dirtyCardQueue.hpp rename to src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp index 7619c3a8f8b..6ee64913d71 100644 --- a/src/hotspot/share/gc/g1/dirtyCardQueue.hpp +++ b/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp @@ -22,20 +22,20 @@ * */ -#ifndef SHARE_GC_G1_DIRTYCARDQUEUE_HPP -#define SHARE_GC_G1_DIRTYCARDQUEUE_HPP +#ifndef SHARE_GC_G1_G1DIRTYCARDQUEUE_HPP +#define SHARE_GC_G1_G1DIRTYCARDQUEUE_HPP #include "gc/shared/ptrQueue.hpp" #include "memory/allocation.hpp" -class DirtyCardQueueSet; +class G1DirtyCardQueueSet; class G1FreeIdSet; class JavaThread; class Monitor; // A closure class for processing card table entries. Note that we don't // require these closure objects to be stack-allocated. -class CardTableEntryClosure: public CHeapObj { +class G1CardTableEntryClosure: public CHeapObj { public: // Process the card whose card table entry is "card_ptr". If returns // "false", terminate the iteration early. @@ -43,25 +43,25 @@ public: }; // A ptrQueue whose elements are "oops", pointers to object heads. -class DirtyCardQueue: public PtrQueue { +class G1DirtyCardQueue: public PtrQueue { public: - DirtyCardQueue(DirtyCardQueueSet* qset, bool permanent = false); + G1DirtyCardQueue(G1DirtyCardQueueSet* qset, bool permanent = false); // Flush before destroying; queue may be used to capture pending work while // doing something else, with auto-flush on completion. - ~DirtyCardQueue(); + ~G1DirtyCardQueue(); // Process queue entries and release resources. void flush() { flush_impl(); } // Compiler support. static ByteSize byte_offset_of_index() { - return PtrQueue::byte_offset_of_index(); + return PtrQueue::byte_offset_of_index(); } using PtrQueue::byte_width_of_index; static ByteSize byte_offset_of_buf() { - return PtrQueue::byte_offset_of_buf(); + return PtrQueue::byte_offset_of_buf(); } using PtrQueue::byte_width_of_buf; @@ -69,8 +69,8 @@ public: -class DirtyCardQueueSet: public PtrQueueSet { - DirtyCardQueue _shared_dirty_card_queue; +class G1DirtyCardQueueSet: public PtrQueueSet { + G1DirtyCardQueue _shared_dirty_card_queue; // Apply the closure to the elements of "node" from it's index to // buffer_size. If all closure applications return true, then @@ -79,7 +79,7 @@ class DirtyCardQueueSet: public PtrQueueSet { // function. If "consume" is true, the node's index is updated to // exclude the processed elements, e.g. up to the element for which // the closure returned false. - bool apply_closure_to_buffer(CardTableEntryClosure* cl, + bool apply_closure_to_buffer(G1CardTableEntryClosure* cl, BufferNode* node, bool consume, uint worker_i = 0); @@ -96,7 +96,7 @@ class DirtyCardQueueSet: public PtrQueueSet { // // If during_pause is true, stop_at must be zero, and the closure // must never return false. - bool apply_closure_to_completed_buffer(CardTableEntryClosure* cl, + bool apply_closure_to_completed_buffer(G1CardTableEntryClosure* cl, uint worker_i, size_t stop_at, bool during_pause); @@ -113,11 +113,11 @@ class DirtyCardQueueSet: public PtrQueueSet { // Current buffer node used for parallel iteration. BufferNode* volatile _cur_par_buffer_node; - void concatenate_log(DirtyCardQueue& dcq); + void concatenate_log(G1DirtyCardQueue& dcq); public: - DirtyCardQueueSet(bool notify_when_complete = true); - ~DirtyCardQueueSet(); + G1DirtyCardQueueSet(bool notify_when_complete = true); + ~G1DirtyCardQueueSet(); void initialize(Monitor* cbl_mon, BufferNode::Allocator* allocator, @@ -136,15 +136,15 @@ public: // Apply the given closure to all completed buffers. The given closure's do_card_ptr // must never return false. Must only be called during GC. - bool apply_closure_during_gc(CardTableEntryClosure* cl, uint worker_i); + bool apply_closure_during_gc(G1CardTableEntryClosure* cl, uint worker_i); void reset_for_par_iteration() { _cur_par_buffer_node = completed_buffers_head(); } // Applies the current closure to all completed buffers, non-consumptively. // Can be used in parallel, all callers using the iteration state initialized // by reset_for_par_iteration. - void par_apply_closure_to_all_completed_buffers(CardTableEntryClosure* cl); + void par_apply_closure_to_all_completed_buffers(G1CardTableEntryClosure* cl); - DirtyCardQueue* shared_dirty_card_queue() { + G1DirtyCardQueue* shared_dirty_card_queue() { return &_shared_dirty_card_queue; } @@ -164,4 +164,4 @@ public: }; -#endif // SHARE_GC_G1_DIRTYCARDQUEUE_HPP +#endif // SHARE_GC_G1_G1DIRTYCARDQUEUE_HPP diff --git a/src/hotspot/share/gc/g1/g1EvacFailure.cpp b/src/hotspot/share/gc/g1/g1EvacFailure.cpp index c7875d30433..62e9fee41f2 100644 --- a/src/hotspot/share/gc/g1/g1EvacFailure.cpp +++ b/src/hotspot/share/gc/g1/g1EvacFailure.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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,10 +23,10 @@ */ #include "precompiled.hpp" -#include "gc/g1/dirtyCardQueue.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectorState.hpp" #include "gc/g1/g1ConcurrentMark.inline.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1EvacFailure.hpp" #include "gc/g1/g1HeapVerifier.hpp" #include "gc/g1/g1OopClosures.inline.hpp" @@ -41,11 +41,11 @@ class UpdateRSetDeferred : public BasicOopIterateClosure { private: G1CollectedHeap* _g1h; - DirtyCardQueue* _dcq; + G1DirtyCardQueue* _dcq; G1CardTable* _ct; public: - UpdateRSetDeferred(DirtyCardQueue* dcq) : + UpdateRSetDeferred(G1DirtyCardQueue* dcq) : _g1h(G1CollectedHeap::heap()), _dcq(dcq), _ct(_g1h->card_table()) {} virtual void do_oop(narrowOop* p) { do_oop_work(p); } @@ -196,7 +196,7 @@ class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure { uint _worker_id; HeapRegionClaimer* _hrclaimer; - DirtyCardQueue _dcq; + G1DirtyCardQueue _dcq; UpdateRSetDeferred _update_rset_cl; public: diff --git a/src/hotspot/share/gc/g1/g1HotCardCache.cpp b/src/hotspot/share/gc/g1/g1HotCardCache.cpp index d932f276fb3..26306f1689a 100644 --- a/src/hotspot/share/gc/g1/g1HotCardCache.cpp +++ b/src/hotspot/share/gc/g1/g1HotCardCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2019, 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,8 +23,8 @@ */ #include "precompiled.hpp" -#include "gc/g1/dirtyCardQueue.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1HotCardCache.hpp" #include "runtime/atomic.hpp" @@ -83,7 +83,7 @@ jbyte* G1HotCardCache::insert(jbyte* card_ptr) { return (previous_ptr == current_ptr) ? previous_ptr : card_ptr; } -void G1HotCardCache::drain(CardTableEntryClosure* cl, uint worker_i) { +void G1HotCardCache::drain(G1CardTableEntryClosure* cl, uint worker_i) { assert(default_use_cache(), "Drain only necessary if we use the hot card cache."); assert(_hot_cache != NULL, "Logic"); diff --git a/src/hotspot/share/gc/g1/g1HotCardCache.hpp b/src/hotspot/share/gc/g1/g1HotCardCache.hpp index 614d6953cc4..60d1130765d 100644 --- a/src/hotspot/share/gc/g1/g1HotCardCache.hpp +++ b/src/hotspot/share/gc/g1/g1HotCardCache.hpp @@ -32,8 +32,7 @@ #include "runtime/thread.hpp" #include "utilities/globalDefinitions.hpp" -class CardTableEntryClosure; -class DirtyCardQueue; +class G1CardTableEntryClosure; class G1CollectedHeap; class HeapRegion; @@ -112,7 +111,7 @@ class G1HotCardCache: public CHeapObj { // Refine the cards that have delayed as a result of // being in the cache. - void drain(CardTableEntryClosure* cl, uint worker_i); + void drain(G1CardTableEntryClosure* cl, uint worker_i); // Set up for parallel processing of the cards in the hot cache void reset_hot_cache_claimed_index() { diff --git a/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp b/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp index 231dbdce714..cc1e2aa9b48 100644 --- a/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp +++ b/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp @@ -25,9 +25,9 @@ #ifndef SHARE_GC_G1_G1PARSCANTHREADSTATE_HPP #define SHARE_GC_G1_G1PARSCANTHREADSTATE_HPP -#include "gc/g1/dirtyCardQueue.hpp" #include "gc/g1/g1CardTable.hpp" #include "gc/g1/g1CollectedHeap.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1OopClosures.hpp" #include "gc/g1/g1Policy.hpp" #include "gc/g1/g1RemSet.hpp" @@ -46,7 +46,7 @@ class outputStream; class G1ParScanThreadState : public CHeapObj { G1CollectedHeap* _g1h; RefToScanQueue* _refs; - DirtyCardQueue _dcq; + G1DirtyCardQueue _dcq; G1CardTable* _ct; G1EvacuationRootClosures* _closures; @@ -77,7 +77,7 @@ class G1ParScanThreadState : public CHeapObj { #define PADDING_ELEM_NUM (DEFAULT_CACHE_LINE_SIZE / sizeof(size_t)) - DirtyCardQueue& dirty_card_queue() { return _dcq; } + G1DirtyCardQueue& dirty_card_queue() { return _dcq; } G1CardTable* ct() { return _ct; } InCSetState dest(InCSetState original) const { diff --git a/src/hotspot/share/gc/g1/g1RemSet.cpp b/src/hotspot/share/gc/g1/g1RemSet.cpp index 98587f88bf4..336b05d4ae3 100644 --- a/src/hotspot/share/gc/g1/g1RemSet.cpp +++ b/src/hotspot/share/gc/g1/g1RemSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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,12 +23,12 @@ */ #include "precompiled.hpp" -#include "gc/g1/dirtyCardQueue.hpp" #include "gc/g1/g1BarrierSet.hpp" #include "gc/g1/g1BlockOffsetTable.inline.hpp" #include "gc/g1/g1CardTable.inline.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1ConcurrentRefine.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1FromCardCache.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1HotCardCache.hpp" @@ -300,7 +300,7 @@ G1RemSet::~G1RemSet() { } uint G1RemSet::num_par_rem_sets() { - return DirtyCardQueueSet::num_par_ids() + G1ConcurrentRefine::max_num_threads() + MAX2(ConcGCThreads, ParallelGCThreads); + return G1DirtyCardQueueSet::num_par_ids() + G1ConcurrentRefine::max_num_threads() + MAX2(ConcGCThreads, ParallelGCThreads); } void G1RemSet::initialize(size_t capacity, uint max_regions) { @@ -456,7 +456,7 @@ void G1RemSet::scan_rem_set(G1ParScanThreadState* pss, uint worker_i) { } // Closure used for updating rem sets. Only called during an evacuation pause. -class G1RefineCardClosure: public CardTableEntryClosure { +class G1RefineCardClosure: public G1CardTableEntryClosure { G1RemSet* _g1rs; G1ScanObjsDuringUpdateRSClosure* _update_rs_cl; @@ -520,7 +520,7 @@ void G1RemSet::oops_into_collection_set_do(G1ParScanThreadState* pss, uint worke } void G1RemSet::prepare_for_oops_into_collection_set_do() { - DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); + G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); dcqs.concatenate_logs(); _scan_state->reset(); @@ -677,7 +677,7 @@ void G1RemSet::refine_card_concurrently(jbyte* card_ptr, *card_ptr = G1CardTable::dirty_card_val(); MutexLockerEx x(Shared_DirtyCardQ_lock, Mutex::_no_safepoint_check_flag); - DirtyCardQueue* sdcq = + G1DirtyCardQueue* sdcq = G1BarrierSet::dirty_card_queue_set().shared_dirty_card_queue(); sdcq->enqueue(card_ptr); } diff --git a/src/hotspot/share/gc/g1/g1RemSet.hpp b/src/hotspot/share/gc/g1/g1RemSet.hpp index a6fa4f45e84..d4bc51b0a41 100644 --- a/src/hotspot/share/gc/g1/g1RemSet.hpp +++ b/src/hotspot/share/gc/g1/g1RemSet.hpp @@ -25,7 +25,6 @@ #ifndef SHARE_GC_G1_G1REMSET_HPP #define SHARE_GC_G1_G1REMSET_HPP -#include "gc/g1/dirtyCardQueue.hpp" #include "gc/g1/g1CardTable.hpp" #include "gc/g1/g1OopClosures.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" diff --git a/src/hotspot/share/gc/g1/g1RemSetSummary.cpp b/src/hotspot/share/gc/g1/g1RemSetSummary.cpp index 8f65f81ac6a..14ae71c9016 100644 --- a/src/hotspot/share/gc/g1/g1RemSetSummary.cpp +++ b/src/hotspot/share/gc/g1/g1RemSetSummary.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2019, 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 @@ #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1ConcurrentRefine.hpp" #include "gc/g1/g1ConcurrentRefineThread.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1RemSet.hpp" #include "gc/g1/g1RemSetSummary.hpp" #include "gc/g1/g1YoungRemSetSamplingThread.hpp" @@ -53,7 +54,7 @@ public: void G1RemSetSummary::update() { _num_conc_refined_cards = _rem_set->num_conc_refined_cards(); - DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); + G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); _num_processed_buf_mutator = dcqs.processed_buffers_mut(); _num_processed_buf_rs_threads = dcqs.processed_buffers_rs_thread(); diff --git a/src/hotspot/share/gc/g1/g1ThreadLocalData.hpp b/src/hotspot/share/gc/g1/g1ThreadLocalData.hpp index 878e71df40e..4a23b0eb720 100644 --- a/src/hotspot/share/gc/g1/g1ThreadLocalData.hpp +++ b/src/hotspot/share/gc/g1/g1ThreadLocalData.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -24,8 +24,8 @@ #ifndef SHARE_GC_G1_G1THREADLOCALDATA_HPP #define SHARE_GC_G1_G1THREADLOCALDATA_HPP -#include "gc/g1/dirtyCardQueue.hpp" #include "gc/g1/g1BarrierSet.hpp" +#include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/shared/satbMarkQueue.hpp" #include "runtime/thread.hpp" #include "utilities/debug.hpp" @@ -33,8 +33,8 @@ class G1ThreadLocalData { private: - SATBMarkQueue _satb_mark_queue; - DirtyCardQueue _dirty_card_queue; + SATBMarkQueue _satb_mark_queue; + G1DirtyCardQueue _dirty_card_queue; G1ThreadLocalData() : _satb_mark_queue(&G1BarrierSet::satb_mark_queue_set()), @@ -66,7 +66,7 @@ public: return data(thread)->_satb_mark_queue; } - static DirtyCardQueue& dirty_card_queue(Thread* thread) { + static G1DirtyCardQueue& dirty_card_queue(Thread* thread) { return data(thread)->_dirty_card_queue; } @@ -83,11 +83,11 @@ public: } static ByteSize dirty_card_queue_index_offset() { - return dirty_card_queue_offset() + DirtyCardQueue::byte_offset_of_index(); + return dirty_card_queue_offset() + G1DirtyCardQueue::byte_offset_of_index(); } static ByteSize dirty_card_queue_buffer_offset() { - return dirty_card_queue_offset() + DirtyCardQueue::byte_offset_of_buf(); + return dirty_card_queue_offset() + G1DirtyCardQueue::byte_offset_of_buf(); } }; diff --git a/src/hotspot/share/gc/g1/vmStructs_g1.hpp b/src/hotspot/share/gc/g1/vmStructs_g1.hpp index 4f43dea3202..03e95109cb8 100644 --- a/src/hotspot/share/gc/g1/vmStructs_g1.hpp +++ b/src/hotspot/share/gc/g1/vmStructs_g1.hpp @@ -102,7 +102,7 @@ declare_toplevel_type(PtrQueue) \ declare_toplevel_type(HeapRegionType) \ declare_toplevel_type(SATBMarkQueue) \ - declare_toplevel_type(DirtyCardQueue) \ + declare_toplevel_type(G1DirtyCardQueue) \ \ declare_toplevel_type(G1CollectedHeap*) \ declare_toplevel_type(HeapRegion*) \ From 831b315ca2b78d61b5275fc7bc2cd1eb613272b5 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 13 Feb 2019 17:18:56 -0800 Subject: [PATCH 064/101] 8218936: Test fails in Internet environment Reviewed-by: mchung --- .../jdk/javadoc/doclet/testLinkOption/TestLinkOption.java | 4 ++-- test/langtools/jdk/javadoc/doclet/testLinkOption/pkg/B.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java b/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java index 58b74a14c44..dbd321b720d 100644 --- a/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java +++ b/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java @@ -88,14 +88,14 @@ public class TestLinkOption extends JavadocTester { checkOutput("pkg/B.html", true, "", "
is equivalent to invoking " + "" + "createTempFile(prefix, suffix, null).
", "Link-Plain to String Class", - "getSystemClassLoader()", + "getSystemClassLoader()", "createTempFile(prefix, suffix, null)", "
RFC 2279: UTF-8, a\n" + " transformation format of ISO 10646,
getSystemClassLoader()} as the parent class loader. + * getSystemClassLoader()} as the parent class loader. */ public void method1() {} From 038a979040254aadcf5e6abb13ef2c63e86cc86e Mon Sep 17 00:00:00 2001 From: Jesper Wilhelmsson Date: Thu, 14 Feb 2019 01:25:04 +0100 Subject: [PATCH 065/101] Added tag jdk-13+8 for changeset a535ba736cab --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 44f167e2036..4b4805bd31c 100644 --- a/.hgtags +++ b/.hgtags @@ -542,3 +542,4 @@ b5f05fe4a6f8b3996a000c20078b356d991ca8ec jdk-13+6 6c377af36a5c4203f16aed8a5e4c2ecc08fcd8bd jdk-12+30 021917019cda1c0c5853255322274f37693a2431 jdk-13+7 b5f7bb57de2f797be34f6c75d45c3245ad37ab97 jdk-12+31 +a535ba736cabc6886acdff36de3a096c46e5ddc5 jdk-13+8 From 560928deee9484798c5013fd3a6476b799db4a1c Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Thu, 14 Feb 2019 11:33:45 +0100 Subject: [PATCH 066/101] 8218753: Obsolete nonproduct flag ProfilerCheckIntervals Reviewed-by: dholmes, coleenp --- src/hotspot/share/runtime/arguments.cpp | 1 + src/hotspot/share/runtime/globals.hpp | 3 -- src/hotspot/share/runtime/java.cpp | 3 -- src/hotspot/share/runtime/task.cpp | 46 +++++-------------------- src/hotspot/share/runtime/task.hpp | 7 ---- 5 files changed, 10 insertions(+), 50 deletions(-) diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 792a0a97dcd..9f36b17bb44 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -546,6 +546,7 @@ static SpecialFlag const special_jvm_flags[] = { { "ProfileVM", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, { "ProfileIntervals", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, { "ProfileIntervalsTicks", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, + { "ProfilerCheckIntervals", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, { "ProfilerNumberOfInterpretedMethods", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, { "ProfilerNumberOfCompiledMethods", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, { "ProfilerNumberOfStubMethods", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) }, diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index 2a6e0e134f7..add49a96494 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -749,9 +749,6 @@ define_pd_global(uint64_t,MaxRAM, 1ULL*G); product(bool, OmitStackTraceInFastThrow, true, \ "Omit backtraces for some 'hot' exceptions in optimized code") \ \ - notproduct(bool, ProfilerCheckIntervals, false, \ - "Collect and print information on spacing of profiler ticks") \ - \ product(bool, PrintWarnings, true, \ "Print JVM warnings to output stream") \ \ diff --git a/src/hotspot/share/runtime/java.cpp b/src/hotspot/share/runtime/java.cpp index 326ee5da638..7ec27d1109b 100644 --- a/src/hotspot/share/runtime/java.cpp +++ b/src/hotspot/share/runtime/java.cpp @@ -291,9 +291,6 @@ void print_statistics() { if (TimeOopMap) { GenerateOopMap::print_time(); } - if (ProfilerCheckIntervals) { - PeriodicTask::print_intervals(); - } if (PrintSymbolTableSizeHistogram) { SymbolTable::print_histogram(); } diff --git a/src/hotspot/share/runtime/task.cpp b/src/hotspot/share/runtime/task.cpp index 89dc0ab9aa8..e32ec7698ce 100644 --- a/src/hotspot/share/runtime/task.cpp +++ b/src/hotspot/share/runtime/task.cpp @@ -31,48 +31,20 @@ int PeriodicTask::_num_tasks = 0; PeriodicTask* PeriodicTask::_tasks[PeriodicTask::max_tasks]; -#ifndef PRODUCT -elapsedTimer PeriodicTask::_timer; -int PeriodicTask::_intervalHistogram[PeriodicTask::max_interval]; -int PeriodicTask::_ticks; - -void PeriodicTask::print_intervals() { - if (ProfilerCheckIntervals) { - for (int i = 0; i < PeriodicTask::max_interval; i++) { - int n = _intervalHistogram[i]; - if (n > 0) tty->print_cr("%3d: %5d (%4.1f%%)", i, n, 100.0 * n / _ticks); - } - } -} -#endif void PeriodicTask::real_time_tick(int delay_time) { assert(Thread::current()->is_Watcher_thread(), "must be WatcherThread"); -#ifndef PRODUCT - if (ProfilerCheckIntervals) { - _ticks++; - _timer.stop(); - int ms = (int)_timer.milliseconds(); - _timer.reset(); - _timer.start(); - if (ms >= PeriodicTask::max_interval) ms = PeriodicTask::max_interval - 1; - _intervalHistogram[ms]++; - } -#endif + // The WatcherThread does not participate in the safepoint protocol + // for the PeriodicTask_lock because it is not a JavaThread. + MutexLockerEx ml(PeriodicTask_lock, Mutex::_no_safepoint_check_flag); + int orig_num_tasks = _num_tasks; - { - // The WatcherThread does not participate in the safepoint protocol - // for the PeriodicTask_lock because it is not a JavaThread. - MutexLockerEx ml(PeriodicTask_lock, Mutex::_no_safepoint_check_flag); - int orig_num_tasks = _num_tasks; - - for(int index = 0; index < _num_tasks; index++) { - _tasks[index]->execute_if_pending(delay_time); - if (_num_tasks < orig_num_tasks) { // task dis-enrolled itself - index--; // re-do current slot as it has changed - orig_num_tasks = _num_tasks; - } + for(int index = 0; index < _num_tasks; index++) { + _tasks[index]->execute_if_pending(delay_time); + if (_num_tasks < orig_num_tasks) { // task dis-enrolled itself + index--; // re-do current slot as it has changed + orig_num_tasks = _num_tasks; } } } diff --git a/src/hotspot/share/runtime/task.hpp b/src/hotspot/share/runtime/task.hpp index 3e2094ce69a..a7a14a8106e 100644 --- a/src/hotspot/share/runtime/task.hpp +++ b/src/hotspot/share/runtime/task.hpp @@ -58,13 +58,6 @@ class PeriodicTask: public CHeapObj { // Can only be called by the WatcherThread static void real_time_tick(int delay_time); -#ifndef PRODUCT - static elapsedTimer _timer; // measures time between ticks - static int _ticks; // total number of ticks - static int _intervalHistogram[max_interval]; // to check spacing of timer interrupts - public: - static void print_intervals(); -#endif // Only the WatcherThread can cause us to execute PeriodicTasks friend class WatcherThread; public: From 29fc9b0f0e45fc898db598598102e89bf3086d3c Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Thu, 14 Feb 2019 12:54:56 +0100 Subject: [PATCH 067/101] 8216360: Deprecate -XX:CompilationPolicyChoice Reviewed-by: thartmann, kvn --- src/hotspot/share/runtime/arguments.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 9f36b17bb44..ec4443619f5 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -528,6 +528,7 @@ static SpecialFlag const special_jvm_flags[] = { { "MinRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() }, { "InitialRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() }, { "UseMembar", JDK_Version::jdk(10), JDK_Version::jdk(12), JDK_Version::undefined() }, + { "CompilationPolicyChoice", JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::undefined() }, // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in: { "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() }, From 0a5047a3269eebad33628a440030404033e568f0 Mon Sep 17 00:00:00 2001 From: Nils Eliasson Date: Thu, 14 Feb 2019 14:31:32 +0100 Subject: [PATCH 068/101] 8087128: C2: Disallow definition split on MachCopySpill nodes Reviewed-by: kvn --- src/hotspot/share/opto/reg_split.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hotspot/share/opto/reg_split.cpp b/src/hotspot/share/opto/reg_split.cpp index 78789150c82..b1fd0c8bcc8 100644 --- a/src/hotspot/share/opto/reg_split.cpp +++ b/src/hotspot/share/opto/reg_split.cpp @@ -1192,9 +1192,8 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { (deflrg._direct_conflict || deflrg._must_spill)) || // Check for LRG being up in a register and we are inside a high // pressure area. Spill it down immediately. - (defup && is_high_pressure(b,&deflrg,insidx))) ) { + (defup && is_high_pressure(b,&deflrg,insidx) && !n->is_SpillCopy())) ) { assert( !n->rematerialize(), "" ); - assert( !n->is_SpillCopy(), "" ); // Do a split at the def site. maxlrg = split_DEF( n, b, insidx, maxlrg, Reachblock, debug_defs, splits, slidx ); // If it wasn't split bail From 48cb2d94e71689db91d9131d62027c2912b19ef9 Mon Sep 17 00:00:00 2001 From: Patric Hedlin Date: Wed, 13 Feb 2019 14:42:20 +0100 Subject: [PATCH 069/101] 8217289: compiler/graalunit/HotspotTest.java failed with InvalidInstalledCodeException Reviewed-by: thartmann, neliasso --- .../test/BigIntegerIntrinsicsTest.java | 41 ++++++++++++++----- test/hotspot/jtreg/ProblemList-graal.txt | 2 - 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/BigIntegerIntrinsicsTest.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/BigIntegerIntrinsicsTest.java index 956bb101855..939d9bdf587 100644 --- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/BigIntegerIntrinsicsTest.java +++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/BigIntegerIntrinsicsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -21,22 +21,23 @@ * questions. */ - package org.graalvm.compiler.hotspot.test; +import java.lang.reflect.InvocationTargetException; import java.math.BigInteger; import java.util.Random; import org.graalvm.compiler.api.test.Graal; +import org.graalvm.compiler.core.test.GraalCompilerTest; import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig; import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider; -import org.graalvm.compiler.replacements.test.MethodSubstitutionTest; import org.graalvm.compiler.runtime.RuntimeProvider; import org.junit.Test; import jdk.vm.ci.amd64.AMD64; import jdk.vm.ci.code.InstalledCode; +import jdk.vm.ci.code.InvalidInstalledCodeException; import jdk.vm.ci.meta.ResolvedJavaMethod; /* @@ -52,7 +53,7 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; * is not tested per se (only execution based on admissible intrinsics). * */ -public final class BigIntegerIntrinsicsTest extends MethodSubstitutionTest { +public final class BigIntegerIntrinsicsTest extends GraalCompilerTest { static final int N = 100; @@ -149,8 +150,8 @@ public final class BigIntegerIntrinsicsTest extends MethodSubstitutionTest { assertDeepEquals(res1, res2); - // Invoke BigInteger testMontgomeryAux(BigInteger, BigExp, BigInteger) through code - // handle. + // Invoke BigInteger testMontgomeryAux(BigInteger, BigExp, BigInteger) + // through code handle. BigInteger res3 = (BigInteger) tin.invokeCode(big1, bigTwo, big2); assertDeepEquals(res1, res3); @@ -168,7 +169,6 @@ public final class BigIntegerIntrinsicsTest extends MethodSubstitutionTest { private class TestIntrinsic { TestIntrinsic(String testmname, Class javaclass, String javamname, Class... params) { - javamethod = getResolvedJavaMethod(javaclass, javamname, params); testmethod = getResolvedJavaMethod(testmname); @@ -179,21 +179,39 @@ public final class BigIntegerIntrinsicsTest extends MethodSubstitutionTest { testcode = getCode(testmethod); assert testcode != null; + assert testcode.isValid(); } Object invokeJava(BigInteger big, Object... args) { - return invokeSafe(javamethod, big, args); } Object invokeTest(Object... args) { - return invokeSafe(testmethod, null, args); } Object invokeCode(Object... args) { + try { + return testcode.executeVarargs(args); + } + catch (InvalidInstalledCodeException e) { + // Ensure the installed code is valid, possibly recompiled. + testcode = getCode(testmethod); - return executeVarargsSafe(testcode, args); + assert testcode != null; + assert testcode.isValid(); + + return invokeCode(args); + } + } + + private Object invokeSafe(ResolvedJavaMethod method, Object receiver, Object... args) { + try { + return invoke(method, receiver, args); + } catch (IllegalAccessException | InvocationTargetException | + IllegalArgumentException | InstantiationException e) { + throw new RuntimeException(e); + } } // Private data section: @@ -202,7 +220,8 @@ public final class BigIntegerIntrinsicsTest extends MethodSubstitutionTest { private InstalledCode testcode; } - private static GraalHotSpotVMConfig config = ((HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class)).getVMConfig(); + private static GraalHotSpotVMConfig config = + ((HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class)).getVMConfig(); private static BigInteger bigTwo = BigInteger.valueOf(2); private static Random rnd = new Random(17); diff --git a/test/hotspot/jtreg/ProblemList-graal.txt b/test/hotspot/jtreg/ProblemList-graal.txt index 683bcc2ff3b..0f65b36b51f 100644 --- a/test/hotspot/jtreg/ProblemList-graal.txt +++ b/test/hotspot/jtreg/ProblemList-graal.txt @@ -228,6 +228,4 @@ org.graalvm.compiler.hotspot.test.ReservedStackAccessTest 8213567 windo org.graalvm.compiler.replacements.test.StringCompressInflateTest 8214947 -org.graalvm.compiler.hotspot.test.BigIntegerIntrinsicsTest 8217289 - org.graalvm.compiler.hotspot.test.CheckGraalIntrinsics 8218698 From 904bb0919f01bb3eca606cf4475601fc425fb0eb Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 14 Feb 2019 07:41:54 -0800 Subject: [PATCH 070/101] 8218944: Fix failed for JDK-8218936 Reviewed-by: jwilhelm --- .../jdk/javadoc/doclet/testLinkOption/TestLinkOption.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java b/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java index dbd321b720d..75f253dcdae 100644 --- a/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java +++ b/test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java @@ -69,9 +69,7 @@ public class TestLinkOption extends JavadocTester { "-linkoffline", url, testSrc + "/jdk", "-package", "pkg", "mylib.lang"); - checkExit(Exit.ERROR); - checkOutput(Output.OUT, true, - "tag not supported in the generated HTML version: tt"); + checkExit(Exit.OK); checkOutput("pkg/C.html", true, " Date: Thu, 14 Feb 2019 21:52:39 +0530 Subject: [PATCH 071/101] 8201544: Improve javac command line parsing and error reporting Modified exception into an error message for invalid filenames on windows Reviewed-by: vromero, jjg --- .../com/sun/tools/javac/main/Option.java | 21 ++++++++++++------- .../tools/javac/resources/compiler.properties | 5 +++++ .../tools/javac/diags/examples.not-yet.txt | 1 + .../tools/javac/options/T6986895.java | 7 ++++++- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java index 1c2714f0821..ed4e85f4feb 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2019, 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 @@ -29,6 +29,7 @@ import java.io.FileWriter; import java.io.PrintWriter; import java.lang.module.ModuleDescriptor; import java.nio.file.Files; +import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.nio.file.Paths; import java.text.Collator; @@ -752,14 +753,18 @@ public enum Option { @Override public void process(OptionHelper helper, String option) throws InvalidValueException { if (option.endsWith(".java") ) { - Path p = Paths.get(option); - if (!Files.exists(p)) { - throw helper.newInvalidValueException(Errors.FileNotFound(p.toString())); + try { + Path p = Paths.get(option); + if (!Files.exists(p)) { + throw helper.newInvalidValueException(Errors.FileNotFound(p.toString())); + } + if (!Files.isRegularFile(p)) { + throw helper.newInvalidValueException(Errors.FileNotFile(p)); + } + helper.addFile(p); + } catch (InvalidPathException ex) { + throw helper.newInvalidValueException(Errors.InvalidPath(option)); } - if (!Files.isRegularFile(p)) { - throw helper.newInvalidValueException(Errors.FileNotFile(p)); - } - helper.addFile(p); } else { helper.addClassName(option); } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties index 8089d81c864..eb6fc8fd278 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -1977,6 +1977,11 @@ compiler.warn.deprecated.annotation.has.no.effect=\ compiler.warn.invalid.path=\ Invalid filename: {0} +# 0: string +compiler.err.invalid.path=\ + Invalid filename: {0} + + # 0: path compiler.warn.invalid.archive.file=\ Unexpected file on path: {0} diff --git a/test/langtools/tools/javac/diags/examples.not-yet.txt b/test/langtools/tools/javac/diags/examples.not-yet.txt index a61cf29a201..443a39531cc 100644 --- a/test/langtools/tools/javac/diags/examples.not-yet.txt +++ b/test/langtools/tools/javac/diags/examples.not-yet.txt @@ -125,6 +125,7 @@ compiler.misc.bad.class.file # class file is malforme compiler.misc.bad.const.pool.entry # constant pool entry has wrong type compiler.warn.access.to.member.from.serializable.lambda # in order to generate it we need to modify a restricted package compiler.warn.invalid.path # this warning is generated only in Windows systems +compiler.err.invalid.path # this error is generated only in Windows systems compiler.note.multiple.elements # needs user code compiler.err.preview.feature.disabled.classfile # preview feature support: needs compilation against classfile compiler.warn.preview.feature.use.classfile # preview feature support: needs compilation against classfile diff --git a/test/langtools/tools/javac/options/T6986895.java b/test/langtools/tools/javac/options/T6986895.java index a83bf8e923b..a44499c7bf7 100644 --- a/test/langtools/tools/javac/options/T6986895.java +++ b/test/langtools/tools/javac/options/T6986895.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, 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 @@ -24,6 +24,7 @@ /* * @test * @bug 6986895 + * @bug 8201544 * @summary compiler gives misleading message for no input files * @modules jdk.compiler */ @@ -38,6 +39,8 @@ public class T6986895 { String noSourceFiles = "no source files"; String noSourceFilesOrClasses = "no source files or class names"; + String invalidFileName = "Invalid filename"; + boolean isWindows = System.getProperty("os.name").startsWith("Windows"); void run() throws Exception { Locale prev = Locale.getDefault(); @@ -45,6 +48,8 @@ public class T6986895 { Locale.setDefault(Locale.ENGLISH); test(noSourceFiles, "-Werror"); test(noSourceFilesOrClasses, "-Werror", "-Xprint"); + if (isWindows) + test(invalidFileName, "-Werror", "someNonExistingFile*.java"); } finally { Locale.setDefault(prev); } From 08a370a8a56b129c9b1a812648261fe3ae8d7ea5 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Thu, 14 Feb 2019 09:38:19 -0800 Subject: [PATCH 072/101] 8187697: Cleanup: irrelevant code in OutputPropertiesFactory Reviewed-by: lancea --- .../serializer/OutputPropertiesFactory.java | 476 ++++++------------ .../serializer/output_html.properties | 45 -- .../serializer/output_text.properties | 39 -- .../serializer/output_unknown.properties | 48 -- .../internal/serializer/output_xml.properties | 48 -- 5 files changed, 162 insertions(+), 494 deletions(-) delete mode 100644 src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_html.properties delete mode 100644 src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_text.properties delete mode 100644 src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_unknown.properties delete mode 100644 src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_xml.properties diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java index b1af4542098..e3c566e91a1 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/OutputPropertiesFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -20,15 +20,6 @@ package com.sun.org.apache.xml.internal.serializer; -import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; -import com.sun.org.apache.xml.internal.serializer.utils.Utils; -import com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException; -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Enumeration; import java.util.Properties; import javax.xml.transform.OutputKeys; import jdk.xml.internal.SecuritySupport; @@ -68,18 +59,18 @@ import jdk.xml.internal.SecuritySupport; * of the corresponding character, like this one:
quot=34
* *
  • S_USE_URL_ESCAPING - - * This non-standard property key is used to set a value of "yes" if the href values for HTML serialization should - * use %xx escaping. + * This non-standard property key is used to set a value of "yes" if the href values + * for HTML serialization should use %xx escaping. * *
  • S_OMIT_META_TAG - - * This non-standard property key is used to set a value of "yes" if the META tag should be omitted where it would - * otherwise be supplied. + * This non-standard property key is used to set a value of "yes" if the META tag + * should be omitted where it would otherwise be supplied. * * * @see SerializerFactory * @see Method * @see Serializer - * @LastModified: Oct 2017 + * @LastModified: Feb 2019 */ public final class OutputPropertiesFactory { @@ -147,14 +138,15 @@ public final class OutputPropertiesFactory S_BUILTIN_EXTENSIONS_UNIVERSAL + "entities"; /** - * This non-standard property key is used to set a value of "yes" if the href values for HTML serialization should - * use %xx escaping. */ + * This non-standard property key is used to set a value of "yes" if the href + * values for HTML serialization should use %xx escaping. + */ public static final String S_USE_URL_ESCAPING = S_BUILTIN_EXTENSIONS_UNIVERSAL + "use-url-escaping"; /** - * This non-standard property key is used to set a value of "yes" if the META tag should be omitted where it would - * otherwise be supplied. + * This non-standard property key is used to set a value of "yes" if the META + * tag should be omitted where it would otherwise be supplied. */ public static final String S_OMIT_META_TAG = S_BUILTIN_EXTENSIONS_UNIVERSAL + "omit-meta-tag"; @@ -174,53 +166,133 @@ public final class OutputPropertiesFactory S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL.length(); /** - * This non-standard, Oracle-impl only property key is used as if OutputKeys.STANDALONE is specified but - * without writing it out in the declaration; It can be used to reverse the change by Xalan patch 1495. - * Since Xalan patch 1495 can cause incompatible behavior, this property is add for application to neutralize - * the effect of Xalan patch 1495 + * This non-standard, Oracle-impl only property key is used as if + * OutputKeys.STANDALONE is specified but without writing it out in the declaration; + * It can be used to reverse the change by Xalan patch 1495. + * Since Xalan patch 1495 can cause incompatible behavior, this property is + * added for application to neutralize the effect of Xalan patch 1495 + */ + /** + *

    Is Standalone

    + * + *
      + *
    • + * yes to indicate the output is intended to be used as standalone + *
    • + *
    • + * no has no effect. + *
    • + *
    */ - /** - *

    Is Standalone

    - * - *
      - *
    • - * yes to indicate the output is intended to be used as standalone - *
    • - *
    • - * no has no effect. - *
    • - *
    - */ public static final String ORACLE_IS_STANDALONE = "http://www.oracle.com/xml/is-standalone"; //************************************************************ //* PRIVATE CONSTANTS //************************************************************ - private static final String S_XSLT_PREFIX = "xslt.output."; - private static final int S_XSLT_PREFIX_LEN = S_XSLT_PREFIX.length(); - private static final String S_XALAN_PREFIX = "org.apache.xslt."; - private static final int S_XALAN_PREFIX_LEN = S_XALAN_PREFIX.length(); + /* + * XSLT properties do not need namespace qualification. + * + * Xalan-specific output properties can be overridden in the stylesheet + * assigning a xalan namespace. For example: + * + * + * ... + */ + private static final String[] PROP_XML = { + "method", + "version", + "encoding", + "indent", + "omit-xml-declaration", + "standalone", + "media-type", + "{http://xml.apache.org/xalan}indent-amount", + "{http://xml.apache.org/xalan}content-handler", + "{http://xml.apache.org/xalan}entities" + }; - /** Synchronization object for lazy initialization of the above tables. */ - private static final Object m_synch_object = new Object(); + private static final String[] PROP_XML_VALUE = { + "xml", + "1.0", + "UTF-8", + "no", + "no", + "no", + "text/xml", + "0", + "com.sun.org.apache.xml.internal.serializer.ToXMLStream", + "com/sun/org/apache/xml/internal/serializer/XMLEntities" + }; - /** the directory in which the various method property files are located */ - private static final String PROP_DIR = "com/sun/org/apache/xml/internal/serializer/"; - /** property file for default XML properties */ - private static final String PROP_FILE_XML = "output_xml.properties"; - /** property file for default TEXT properties */ - private static final String PROP_FILE_TEXT = "output_text.properties"; - /** property file for default HTML properties */ - private static final String PROP_FILE_HTML = "output_html.properties"; - /** property file for default UNKNOWN (Either XML or HTML, to be determined later) properties */ - private static final String PROP_FILE_UNKNOWN = "output_unknown.properties"; + private static final String[] PROP_HTML = { + "method", + "indent", + "media", + "version", + "{http://xml.apache.org/xalan}indent-amount", + "{http://xml.apache.org/xalan}content-handler", + "{http://xml.apache.org/xalan}entities", + "{http://xml.apache.org/xalan}use-url-escaping", + "{http://xml.apache.org/xalan}omit-meta-tag" + }; + + private static final String[] PROP_HTML_VALUE = { + "html", + "yes", + "text/html", + "4.0", + "4", + "com.sun.org.apache.xml.internal.serializer.ToHTMLStream", + "com/sun/org/apache/xml/internal/serializer/HTMLEntities", + "yes", + "no" + }; + + private static final String[] PROP_TEXT = { + "method", + "media-type", + "{http://xml.apache.org/xalan}content-handler" + }; + + private static final String[] PROP_TEXT_VALUE = { + "text", + "text/plain", + "com.sun.org.apache.xml.internal.serializer.ToTextStream" + }; + + private static final String[] PROP_UNKNOWN = { + "method", + "version", + "encoding", + "indent", + "omit-xml-declaration", + "standalone", + "media-type", + "{http://xml.apache.org/xalan}indent-amount", + "{http://xml.apache.org/xalan}content-handler" + }; + + private static final String[] PROP_UNKNOWN_VALUE = { + "xml", + "1.0", + "UTF-8", + "no", + "no", + "no", + "text/xml", + "0", + "com.sun.org.apache.xml.internal.serializer.ToUnknownStream", + }; //************************************************************ //* PRIVATE STATIC FIELDS //************************************************************ - /** The default properties of all output files. */ + /** The default properties for all other than html and text. */ private static Properties m_xml_properties = null; /** The default properties when method="html". */ @@ -232,38 +304,8 @@ public final class OutputPropertiesFactory /** The properties when method="" for the "unknown" wrapper */ private static Properties m_unknown_properties = null; - private static final Class - ACCESS_CONTROLLER_CLASS = findAccessControllerClass(); - - private static Class findAccessControllerClass() { - try - { - // This Class was introduced in JDK 1.2. With the re-architecture of - // security mechanism ( starting in JDK 1.2 ), we have option of - // giving privileges to certain part of code using doPrivileged block. - // In JDK1.1.X applications won't be having security manager and if - // there is security manager ( in applets ), code need to be signed - // and trusted for having access to resources. - - return Class.forName("java.security.AccessController"); - } - catch (Exception e) - { - //User may be using older JDK ( JDK <1.2 ). Allow him/her to use it. - // But don't try to use doPrivileged - } - - return null; - } - /** - * Creates an empty OutputProperties with the property key/value defaults specified by - * a property file. The method argument is used to construct a string of - * the form output_[method].properties (for instance, output_html.properties). - * The output_xml.properties file is always used as the base. - * - *

    Anything other than 'text', 'xml', and 'html', will - * use the output_xml.properties file.

    + * Returns a Properties based on the specified method. The default is xml. * * @param method non-null reference to method name. * @@ -271,265 +313,71 @@ public final class OutputPropertiesFactory */ static public final Properties getDefaultMethodProperties(String method) { - String fileName = null; Properties defaultProperties = null; - // According to this article : Double-check locking does not work - // http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-toolbox.html - try - { - synchronized (m_synch_object) - { - if (null == m_xml_properties) // double check - { - fileName = PROP_FILE_XML; - m_xml_properties = loadPropertiesFile(fileName, null); - } - } - if (method.equals(Method.XML)) - { + if (null == m_xml_properties) { + m_xml_properties = initProperties(PROP_XML, PROP_XML_VALUE, null); + } + + + switch (method) { + case Method.XML: defaultProperties = m_xml_properties; - } - else if (method.equals(Method.HTML)) - { - if (null == m_html_properties) // double check - { - fileName = PROP_FILE_HTML; - m_html_properties = - loadPropertiesFile(fileName, m_xml_properties); + break; + case Method.HTML: + if (null == m_html_properties) { + m_html_properties = initProperties( + PROP_HTML, PROP_HTML_VALUE, m_xml_properties); } - defaultProperties = m_html_properties; - } - else if (method.equals(Method.TEXT)) - { - if (null == m_text_properties) // double check - { - fileName = PROP_FILE_TEXT; - m_text_properties = - loadPropertiesFile(fileName, m_xml_properties); - if (null - == m_text_properties.getProperty(OutputKeys.ENCODING)) + break; + case Method.TEXT: + if (null == m_text_properties) { + m_text_properties = initProperties( + PROP_TEXT, PROP_TEXT_VALUE, m_xml_properties); + + if (null == m_text_properties.getProperty(OutputKeys.ENCODING)) { String mimeEncoding = Encodings.getMimeEncoding(null); - m_text_properties.put( - OutputKeys.ENCODING, - mimeEncoding); + m_text_properties.put(OutputKeys.ENCODING, mimeEncoding); } } - defaultProperties = m_text_properties; - } - else if (method.equals(com.sun.org.apache.xml.internal.serializer.Method.UNKNOWN)) - { - if (null == m_unknown_properties) // double check - { - fileName = PROP_FILE_UNKNOWN; - m_unknown_properties = - loadPropertiesFile(fileName, m_xml_properties); + break; + case com.sun.org.apache.xml.internal.serializer.Method.UNKNOWN: + if (null == m_unknown_properties) { + m_unknown_properties = initProperties( + PROP_UNKNOWN, PROP_UNKNOWN_VALUE, m_xml_properties); } - defaultProperties = m_unknown_properties; - } - else - { - // TODO: Calculate res file from name. + break; + default: defaultProperties = m_xml_properties; - } - } - catch (IOException ioe) - { - throw new WrappedRuntimeException( - Utils.messages.createMessage( - MsgKey.ER_COULD_NOT_LOAD_METHOD_PROPERTY, - new Object[] { fileName, method }), - ioe); + break; } + // wrap these cached defaultProperties in a new Property object just so // that the caller of this method can't modify the default values return new Properties(defaultProperties); } /** - * Load the properties file from a resource stream. If a - * key name such as "org.apache.xslt.xxx", fix up the start of - * string to be a curly namespace. If a key name starts with - * "xslt.output.xxx", clip off "xslt.output.". If a key name *or* a - * key value is discovered, check for \u003a in the text, and - * fix it up to be ":", since earlier versions of the JDK do not - * handle the escape sequence (at least in key names). + * Initiates the properties * - * @param resourceName non-null reference to resource name. + * @param keys an array of keys + * @param values values corresponding to the keys * @param defaults Default properties, which may be null. */ - static private Properties loadPropertiesFile( - final String resourceName, - Properties defaults) - throws IOException + static private Properties initProperties(String[] keys, String[] values, Properties defaults) { - - // This static method should eventually be moved to a thread-specific class - // so that we can cache the ContextClassLoader and bottleneck all properties file - // loading throughout Xalan. - Properties props = new Properties(defaults); - InputStream is = null; - BufferedInputStream bis = null; - - try - { - if (ACCESS_CONTROLLER_CLASS != null) - { - is = AccessController.doPrivileged(new PrivilegedAction() { - public InputStream run() - { - return OutputPropertiesFactory.class - .getResourceAsStream(resourceName); - } - }); - } - else - { - // User may be using older JDK ( JDK < 1.2 ) - is = OutputPropertiesFactory.class - .getResourceAsStream(resourceName); - } - - bis = new BufferedInputStream(is); - props.load(bis); - } - catch (IOException ioe) - { - if (defaults == null) - { - throw ioe; - } - else - { - throw new WrappedRuntimeException( - Utils.messages.createMessage( - MsgKey.ER_COULD_NOT_LOAD_RESOURCE, - new Object[] { resourceName }), - ioe); - //"Could not load '"+resourceName+"' (check CLASSPATH), now using just the defaults ", ioe); - } - } - catch (SecurityException se) - { - // Repeat IOException handling for sandbox/applet case -sc - if (defaults == null) - { - throw se; - } - else - { - throw new WrappedRuntimeException( - Utils.messages.createMessage( - MsgKey.ER_COULD_NOT_LOAD_RESOURCE, - new Object[] { resourceName }), - se); - //"Could not load '"+resourceName+"' (check CLASSPATH, applet security), now using just the defaults ", se); - } - } - finally - { - if (bis != null) - { - bis.close(); - } - if (is != null) - { - is.close(); - } - } - - // Note that we're working at the HashTable level here, - // and not at the Properties level! This is important - // because we don't want to modify the default properties. - // NB: If fixupPropertyString ends up changing the property - // name or value, we need to remove the old key and re-add - // with the new key and value. However, then our Enumeration - // could lose its place in the HashTable. So, we first - // clone the HashTable and enumerate over that since the - // clone will not change. When we migrate to Collections, - // this code should be revisited and cleaned up to use - // an Iterator which may (or may not) alleviate the need for - // the clone. Many thanks to Padraig O'hIceadha - // for finding this problem. Bugzilla 2000. - - Enumeration keys = ((Properties) props.clone()).keys(); - while (keys.hasMoreElements()) - { - String key = (String) keys.nextElement(); - // Now check if the given key was specified as a - // System property. If so, the system property - // overides the default value in the propery file. - String value = null; - try - { - value = SecuritySupport.getSystemProperty(key); - } - catch (SecurityException se) - { - // No-op for sandbox/applet case, leave null -sc - } - if (value == null) - value = (String) props.get(key); - - String newKey = fixupPropertyString(key, true); - String newValue = null; - try - { - newValue = SecuritySupport.getSystemProperty(newKey); - } - catch (SecurityException se) - { - // No-op for sandbox/applet case, leave null -sc - } - if (newValue == null) - newValue = fixupPropertyString(value, false); - else - newValue = fixupPropertyString(newValue, false); - - if (key != newKey || value != newValue) - { - props.remove(key); - props.put(newKey, newValue); - } - + for (int i = 0; i < keys.length; i++) { + // check System Property. This is kept as is for binary compatibility + String sys = SecuritySupport.getSystemProperty(keys[i]); + props.put(keys[i], (sys == null) ? values[i] : sys); } return props; } - - /** - * Fix up a string in an output properties file according to - * the rules of {@link #loadPropertiesFile}. - * - * @param s non-null reference to string that may need to be fixed up. - * @return A new string if fixup occured, otherwise the s argument. - */ - static private String fixupPropertyString(String s, boolean doClipping) - { - int index; - if (doClipping && s.startsWith(S_XSLT_PREFIX)) - { - s = s.substring(S_XSLT_PREFIX_LEN); - } - if (s.startsWith(S_XALAN_PREFIX)) - { - s = - S_BUILTIN_EXTENSIONS_UNIVERSAL - + s.substring(S_XALAN_PREFIX_LEN); - } - if ((index = s.indexOf("\\u003a")) > 0) - { - String temp = s.substring(index + 6); - s = s.substring(0, index) + ":" + temp; - - } - return s; - } - } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_html.properties b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_html.properties deleted file mode 100644 index 5230e5e99e3..00000000000 --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_html.properties +++ /dev/null @@ -1,45 +0,0 @@ -########################################################################### -# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. -########################################################################### -## -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -## -# -# Specify defaults when method="html". These defaults use output_xml.properties -# as a base. -# - -# XSLT properties do not need namespace qualification. -method=html -indent=yes -media-type=text/html -version=4.0 - -# Xalan-specific output properties. These can be overridden in the stylesheet -# assigning a xalan namespace. For example: -# -# -# ... -# Note that the colon after the protocol needs to be escaped. -{http\u003a//xml.apache.org/xalan}indent-amount=4 -{http\u003a//xml.apache.org/xalan}content-handler=com.sun.org.apache.xml.internal.serializer.ToHTMLStream -{http\u003a//xml.apache.org/xalan}entities=com/sun/org/apache/xml/internal/serializer/HTMLEntities -{http\u003a//xml.apache.org/xalan}use-url-escaping=yes -{http\u003a//xml.apache.org/xalan}omit-meta-tag=no diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_text.properties b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_text.properties deleted file mode 100644 index d3d2baf9310..00000000000 --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_text.properties +++ /dev/null @@ -1,39 +0,0 @@ -########################################################################### -# reserved comment block -# DO NOT REMOVE OR ALTER! -########################################################################### -########################################################################## -# Copyright 2003-2004 The Apache Software Foundation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -########################################################################## -# -# $Id: output_text.properties,v 1.3 2005/09/28 13:49:10 pvedula Exp $ -# -# Specify defaults when method="text". -# - -# XSLT properties do not need namespace qualification. -method=text -media-type=text/plain - -# Xalan-specific output properties. These can be overridden in the stylesheet -# assigning a xalan namespace. For example: -# -# -# ... -# Note that the colon after the protocol needs to be escaped. -{http\u003a//xml.apache.org/xalan}content-handler=com.sun.org.apache.xml.internal.serializer.ToTextStream diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_unknown.properties b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_unknown.properties deleted file mode 100644 index 118d46969ec..00000000000 --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_unknown.properties +++ /dev/null @@ -1,48 +0,0 @@ -########################################################################### -# reserved comment block -# DO NOT REMOVE OR ALTER! -########################################################################### -########################################################################### -# Copyright 2003-2004 The Apache Software Foundation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -########################################################################## -# -# $Id: output_unknown.properties,v 1.2.4.1 2005/09/15 08:15:33 suresh_emailid Exp $ -# -# Specify defaults when no method="..." is specified. -# This type of output will quickly switch to "xml" or "html" -# depending on the first element name. -# - -# XSLT properties do not need namespace qualification. -method=xml -version=1.0 -encoding=UTF-8 -indent=no -omit-xml-declaration=no -standalone=no -media-type=text/xml - -# Xalan-specific output properties. These can be overridden in the stylesheet -# assigning a xalan namespace. For example: -# -# -# ... -# Note that the colon after the protocol needs to be escaped. -{http\u003a//xml.apache.org/xalan}indent-amount=0 -{http\u003a//xml.apache.org/xalan}content-handler=com.sun.org.apache.xml.internal.serializer.ToUnknownStream - diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_xml.properties b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_xml.properties deleted file mode 100644 index fd016f7c842..00000000000 --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/output_xml.properties +++ /dev/null @@ -1,48 +0,0 @@ -########################################################################### -# reserved comment block -# DO NOT REMOVE OR ALTER! -########################################################################### -########################################################################### -# Copyright 2003-2004 The Apache Software Foundation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -########################################################################## -# -# $Id: output_xml.properties,v 1.2.4.1 2005/09/15 08:15:33 suresh_emailid Exp $ -# -# Specify defaults when method="xml". These defaults serve as a base for -# other defaults, such as output_html and output_text. -# - -# XSLT properties do not need namespace qualification. -method=xml -version=1.0 -encoding=UTF-8 -indent=no -omit-xml-declaration=no -standalone=no -media-type=text/xml - -# Xalan-specific output properties. These can be overridden in the stylesheet -# assigning a xalan namespace. For example: -# -# -# ... -# Note that the colon after the protocol needs to be escaped. -{http\u003a//xml.apache.org/xalan}indent-amount=0 -{http\u003a//xml.apache.org/xalan}content-handler=com.sun.org.apache.xml.internal.serializer.ToXMLStream -{http\u003a//xml.apache.org/xalan}entities=com/sun/org/apache/xml/internal/serializer/XMLEntities - From 39ba0f09a9799926b8b0bb836f7d2cf62dfec7aa Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Thu, 14 Feb 2019 19:48:57 +0100 Subject: [PATCH 073/101] 8183004: Remove code related to gtest death tests from assert macro Reviewed-by: shade, kbarrett, iignatyev --- src/hotspot/share/utilities/debug.cpp | 32 ++++++++++++++------------- src/hotspot/share/utilities/debug.hpp | 14 ------------ test/hotspot/gtest/unittest.hpp | 2 +- 3 files changed, 18 insertions(+), 30 deletions(-) diff --git a/src/hotspot/share/utilities/debug.cpp b/src/hotspot/share/utilities/debug.cpp index e7486bbb88e..46836d7ef09 100644 --- a/src/hotspot/share/utilities/debug.cpp +++ b/src/hotspot/share/utilities/debug.cpp @@ -61,6 +61,7 @@ #include "utilities/vmError.hpp" #include +#include // Support for showing register content on asserts/guarantees. #ifdef CAN_SHOW_REGISTERS_ON_ASSERT @@ -244,6 +245,22 @@ void report_vm_error(const char* file, int line, const char* error_msg, const ch context = g_assertion_context; } #endif // CAN_SHOW_REGISTERS_ON_ASSERT + +#ifdef ASSERT + if (detail_fmt != NULL && ExecutingUnitTests) { + // Special handling for the sake of gtest death tests which expect the assert + // message to be printed in one short line to stderr (see TEST_VM_ASSERT_MSG) and + // cannot be tweaked to accept our normal assert message. + va_list detail_args_copy; + va_copy(detail_args_copy, detail_args); + ::fputs("assert failed: ", stderr); + ::vfprintf(stderr, detail_fmt, detail_args_copy); + ::fputs("\n", stderr); + ::fflush(stderr); + va_end(detail_args_copy); + } +#endif + VMError::report_and_die(Thread::current_or_null(), context, file, line, error_msg, detail_fmt, detail_args); va_end(detail_args); } @@ -293,21 +310,6 @@ void report_unimplemented(const char* file, int line) { report_vm_error(file, line, "Unimplemented()"); } -#ifdef ASSERT -bool is_executing_unit_tests() { - return ExecutingUnitTests; -} - -void report_assert_msg(const char* msg, ...) { - va_list ap; - va_start(ap, msg); - - fprintf(stderr, "assert failed: %s\n", err_msg(FormatBufferDummy(), msg, ap).buffer()); - - va_end(ap); -} -#endif // ASSERT - void report_untested(const char* file, int line, const char* message) { #ifndef PRODUCT warning("Untested: %s in %s: %d\n", message, file, line); diff --git a/src/hotspot/share/utilities/debug.hpp b/src/hotspot/share/utilities/debug.hpp index eb98d09a87b..d1962e8cd14 100644 --- a/src/hotspot/share/utilities/debug.hpp +++ b/src/hotspot/share/utilities/debug.hpp @@ -54,9 +54,6 @@ bool handle_assert_poison_fault(const void* ucVoid, const void* faulting_address do { \ if (!(p)) { \ TOUCH_ASSERT_POISON; \ - if (is_executing_unit_tests()) { \ - report_assert_msg(__VA_ARGS__); \ - } \ report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", __VA_ARGS__); \ BREAKPOINT; \ } \ @@ -157,16 +154,10 @@ void report_vm_error(const char* file, int line, const char* error_msg); // ATTRIBUTE_PRINTF works with gcc >= 4.8 and any other compiler. void report_vm_error(const char* file, int line, const char* error_msg, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(4, 5); -#ifdef ASSERT -void report_assert_msg(const char* msg, ...) ATTRIBUTE_PRINTF(1, 2); -#endif // ASSERT #else // GCC < 4.8 warns because of empty format string. Warning can not be switched off selectively. void report_vm_error(const char* file, int line, const char* error_msg, const char* detail_fmt, ...); -#ifdef ASSERT -void report_assert_msg(const char* msg, ...); -#endif // ASSERT #endif void report_vm_status_error(const char* file, int line, const char* error_msg, int status, const char* detail); @@ -178,11 +169,6 @@ void report_should_not_reach_here(const char* file, int line); void report_unimplemented(const char* file, int line); void report_untested(const char* file, int line, const char* message); -#ifdef ASSERT -// unit test support -bool is_executing_unit_tests(); -#endif // ASSERT - void warning(const char* format, ...) ATTRIBUTE_PRINTF(1, 2); // Compile-time asserts. Cond must be a compile-time constant expression that diff --git a/test/hotspot/gtest/unittest.hpp b/test/hotspot/gtest/unittest.hpp index 0494a0e2408..fda9d79a9f5 100644 --- a/test/hotspot/gtest/unittest.hpp +++ b/test/hotspot/gtest/unittest.hpp @@ -105,7 +105,7 @@ TEST(category, CONCAT(name, _vm_assert)) { \ ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \ ::testing::ExitedWithCode(1), \ - "assert failed: " msg); \ + "^assert failed: " msg); \ } \ \ void test_ ## category ## _ ## name ## _() From a75f826ea800fa4aaded5cde93d70da5fd5a9da4 Mon Sep 17 00:00:00 2001 From: Man Cao Date: Tue, 5 Feb 2019 08:20:09 -0800 Subject: [PATCH 074/101] 8218192: Remove copy constructor for MemRegion Remove copy constructor in memRegion.hpp Reviewed-by: tschatzl, kbarrett --- src/hotspot/share/memory/memRegion.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/memory/memRegion.hpp b/src/hotspot/share/memory/memRegion.hpp index f2e8f6b40f2..da6921601b1 100644 --- a/src/hotspot/share/memory/memRegion.hpp +++ b/src/hotspot/share/memory/memRegion.hpp @@ -34,7 +34,9 @@ // Note that MemRegions are passed by value, not by reference. // The intent is that they remain very small and contain no -// objects. These should never be allocated in heap but we do +// objects. The copy constructor and destructor must be trivial, +// to support optimization for pass-by-value. +// These should never be allocated in heap but we do // create MemRegions (in CardTableBarrierSet) in heap so operator // new and operator new [] added for this special case. @@ -59,8 +61,6 @@ public: assert(end >= start, "incorrect constructor arguments"); } - MemRegion(const MemRegion& mr): _start(mr._start), _word_size(mr._word_size) {} - MemRegion intersection(const MemRegion mr2) const; // regions must overlap or be adjacent MemRegion _union(const MemRegion mr2) const; From 2ca0a6689e4fd57b355486e9a7e138433d18280a Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Thu, 14 Feb 2019 14:19:29 -0800 Subject: [PATCH 075/101] 4919790: Errors in alert ssl message does not reflect the actual certificate status Reviewed-by: mullan --- src/java.base/share/classes/sun/security/ssl/Alert.java | 4 ++-- .../classes/sun/security/ssl/CertificateMessage.java | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/java.base/share/classes/sun/security/ssl/Alert.java b/src/java.base/share/classes/sun/security/ssl/Alert.java index 4fc4d20302d..2e6d47f61c6 100644 --- a/src/java.base/share/classes/sun/security/ssl/Alert.java +++ b/src/java.base/share/classes/sun/security/ssl/Alert.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -48,7 +48,7 @@ enum Alert { HANDSHAKE_FAILURE ((byte)40, "handshake_failure", true), NO_CERTIFICATE ((byte)41, "no_certificate", true), BAD_CERTIFICATE ((byte)42, "bad_certificate", true), - UNSUPPORTED_CERTIFCATE ((byte)43, "unsupported_certificate", true), + UNSUPPORTED_CERTIFICATE ((byte)43, "unsupported_certificate", true), CERTIFICATE_REVOKED ((byte)44, "certificate_revoked", true), CERTIFICATE_EXPIRED ((byte)45, "certificate_expired", true), CERTIFICATE_UNKNOWN ((byte)46, "certificate_unknown", true), diff --git a/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java b/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java index a38cfbfe486..c7e25e238da 100644 --- a/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java +++ b/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -717,6 +717,13 @@ final class CertificateMessage { alert = chc.staplingActive ? Alert.BAD_CERT_STATUS_RESPONSE : Alert.CERTIFICATE_UNKNOWN; + } else if (reason == BasicReason.ALGORITHM_CONSTRAINED) { + alert = Alert.UNSUPPORTED_CERTIFICATE; + } else if (reason == BasicReason.EXPIRED) { + alert = Alert.CERTIFICATE_EXPIRED; + } else if (reason == BasicReason.INVALID_SIGNATURE || + reason == BasicReason.NOT_YET_VALID) { + alert = Alert.BAD_CERTIFICATE; } } From b1fe43947abdf6ab1ce5bfb9f83c5609299cc44c Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Thu, 14 Feb 2019 14:40:11 -0800 Subject: [PATCH 076/101] 8209455: [error-prone] JdkObsolete in jdk.management.agent Reviewed-by: alanb, jcbeyler --- .../share/classes/jdk/internal/agent/Agent.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java b/src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java index 8cff6f6dbd0..3284f0b1575 100644 --- a/src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java +++ b/src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -663,11 +663,7 @@ public class Agent { System.err.print(getText("agent.err.error") + ": " + keyText); if (params != null && params.length != 0) { - StringBuffer message = new StringBuffer(params[0]); - for (int i = 1; i < params.length; i++) { - message.append(" " + params[i]); - } - System.err.println(": " + message); + System.err.println(": " + String.join(" ", params)); } e.printStackTrace(); throw new RuntimeException(e); From aeaad9c910e6170c2f973868e0f17bef4e02d814 Mon Sep 17 00:00:00 2001 From: Mikael Vidstedt Date: Thu, 14 Feb 2019 15:12:17 -0800 Subject: [PATCH 077/101] 8218937: Make mlvmJvmtiUtils strncpy uses GCC 8.x friendly Reviewed-by: iignatyev --- .../vm/mlvm/share/mlvmJvmtiUtils.cpp | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.cpp b/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.cpp index 2badd49861b..aa2214001de 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.cpp +++ b/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2019, 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 @@ -47,6 +47,23 @@ void copyFromJString(JNIEnv * pEnv, jstring src, char ** dst) { pEnv->ReleaseStringUTFChars(src, pStr); } + +/** + * Helper class to track JVMTI resources, deallocating the resource in the destructor. + */ +class JvmtiResource { +private: + jvmtiEnv* const _jvmtiEnv; + void* const _ptr; + +public: + JvmtiResource(jvmtiEnv* jvmtiEnv, void* ptr) : _jvmtiEnv(jvmtiEnv), _ptr(ptr) { } + + ~JvmtiResource() { + NSK_JVMTI_VERIFY(_jvmtiEnv->Deallocate((unsigned char*)_ptr)); + } +}; + struct MethodName * getMethodName(jvmtiEnv * pJvmtiEnv, jmethodID method) { char * szName; char * szSignature; @@ -57,22 +74,31 @@ struct MethodName * getMethodName(jvmtiEnv * pJvmtiEnv, jmethodID method) { return NULL; } + JvmtiResource szNameResource(pJvmtiEnv, szName); + if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetMethodDeclaringClass(method, &clazz))) { - NSK_JVMTI_VERIFY(pJvmtiEnv->Deallocate((unsigned char*) szName)); return NULL; } if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetClassSignature(clazz, &szSignature, NULL))) { - NSK_JVMTI_VERIFY(pJvmtiEnv->Deallocate((unsigned char*) szName)); return NULL; } + JvmtiResource szSignatureResource(pJvmtiEnv, szSignature); + + if (strlen(szName) + 1 > sizeof(mn->methodName) || + strlen(szSignature) + 1 > sizeof(mn->classSig)) { + return NULL; + } + mn = (MethodName*) malloc(sizeof(MethodNameStruct)); + if (mn == NULL) { + return NULL; + } + strncpy(mn->methodName, szName, sizeof(mn->methodName)); strncpy(mn->classSig, szSignature, sizeof(mn->classSig)); - NSK_JVMTI_VERIFY(pJvmtiEnv->Deallocate((unsigned char*) szName)); - NSK_JVMTI_VERIFY(pJvmtiEnv->Deallocate((unsigned char*) szSignature)); return mn; } From d55784deb0d262e965aa998ac8ed00047f851ca5 Mon Sep 17 00:00:00 2001 From: Mikael Vidstedt Date: Thu, 14 Feb 2019 15:17:03 -0800 Subject: [PATCH 078/101] 8218935: Make jfr strncpy uses GCC 8.x friendly Reviewed-by: clanger --- .../jfr/recorder/checkpoint/types/jfrThreadGroup.cpp | 7 +++---- .../share/jfr/recorder/repository/jfrChunkState.cpp | 5 ++--- .../share/jfr/recorder/repository/jfrRepository.cpp | 11 ++++------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp index 129319c87c3..b2ae0d7782a 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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 @@ -238,9 +238,8 @@ void JfrThreadGroup::JfrThreadGroupEntry::set_thread_group_name(const char* tgna assert(_thread_group_name == NULL, "invariant"); if (tgname != NULL) { size_t len = strlen(tgname); - _thread_group_name = JfrCHeapObj::new_array(len+1); - strncpy(_thread_group_name, tgname, len); - _thread_group_name[len] = '\0'; + _thread_group_name = JfrCHeapObj::new_array(len + 1); + strncpy(_thread_group_name, tgname, len + 1); } } diff --git a/src/hotspot/share/jfr/recorder/repository/jfrChunkState.cpp b/src/hotspot/share/jfr/recorder/repository/jfrChunkState.cpp index f86122fd37e..9825cd21ed7 100644 --- a/src/hotspot/share/jfr/recorder/repository/jfrChunkState.cpp +++ b/src/hotspot/share/jfr/recorder/repository/jfrChunkState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -100,8 +100,7 @@ static char* copy_path(const char* path) { assert(path != NULL, "invariant"); const size_t path_len = strlen(path); char* new_path = JfrCHeapObj::new_array(path_len + 1); - strncpy(new_path, path, path_len); - new_path[path_len] = '\0'; + strncpy(new_path, path, path_len + 1); return new_path; } diff --git a/src/hotspot/share/jfr/recorder/repository/jfrRepository.cpp b/src/hotspot/share/jfr/recorder/repository/jfrRepository.cpp index 05747ee5ffc..a877732608d 100644 --- a/src/hotspot/share/jfr/recorder/repository/jfrRepository.cpp +++ b/src/hotspot/share/jfr/recorder/repository/jfrRepository.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, 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 @@ -209,8 +209,7 @@ const char* const RepositoryIterator::filter(const char* entry) const { if (entry_name == NULL) { return NULL; } - strncpy(entry_name, entry, entry_len); - entry_name[entry_len] = '\0'; + strncpy(entry_name, entry, entry_len + 1); const char* const fully_qualified_path_entry = fully_qualified(entry_name); if (NULL == fully_qualified_path_entry) { return NULL; @@ -332,8 +331,7 @@ static const char* create_emergency_dump_path() { if (NULL == emergency_dump_path) { return NULL; } - strncpy(emergency_dump_path, buffer, emergency_filename_length); - emergency_dump_path[emergency_filename_length] = '\0'; + strncpy(emergency_dump_path, buffer, emergency_filename_length + 1); } return emergency_dump_path; } @@ -407,8 +405,7 @@ bool JfrRepository::set_path(const char* path) { if (_path == NULL) { return false; } - strncpy(_path, path, path_len); - _path[path_len] = '\0'; + strncpy(_path, path, path_len + 1); return true; } From f53dfaf5ab789f53369b436303a30f8d33525960 Mon Sep 17 00:00:00 2001 From: Vladimir Ivanov Date: Thu, 14 Feb 2019 15:27:12 -0800 Subject: [PATCH 079/101] 8218881: C2: StaticFinalFieldPrinter doesn't handle T_ARRAY values in T_OBJECT fields Reviewed-by: thartmann, kvn, neliasso --- src/hotspot/share/ci/ciInstanceKlass.cpp | 29 ++++++++++-------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/hotspot/share/ci/ciInstanceKlass.cpp b/src/hotspot/share/ci/ciInstanceKlass.cpp index e8ad5e2567d..fb26277a094 100644 --- a/src/hotspot/share/ci/ciInstanceKlass.cpp +++ b/src/hotspot/share/ci/ciInstanceKlass.cpp @@ -669,11 +669,21 @@ class StaticFinalFieldPrinter : public FieldClosure { _out->print_cr(INT64_FORMAT, *(int64_t*)&d); break; } - case T_ARRAY: { + case T_ARRAY: // fall-through + case T_OBJECT: { oop value = mirror->obj_field_acquire(fd->offset()); if (value == NULL) { _out->print_cr("null"); - } else { + } else if (value->is_instance()) { + assert(fd->field_type() == T_OBJECT, ""); + if (value->is_a(SystemDictionary::String_klass())) { + const char* ascii_value = java_lang_String::as_quoted_ascii(value); + _out->print("\"%s\"", (ascii_value != NULL) ? ascii_value : ""); + } else { + const char* klass_name = value->klass()->name()->as_quoted_ascii(); + _out->print_cr("%s", klass_name); + } + } else if (value->is_array()) { typeArrayOop ta = (typeArrayOop)value; _out->print("%d", ta->length()); if (value->is_objArray()) { @@ -682,21 +692,6 @@ class StaticFinalFieldPrinter : public FieldClosure { _out->print(" %s", klass_name); } _out->cr(); - } - break; - } - case T_OBJECT: { - oop value = mirror->obj_field_acquire(fd->offset()); - if (value == NULL) { - _out->print_cr("null"); - } else if (value->is_instance()) { - if (value->is_a(SystemDictionary::String_klass())) { - const char* ascii_value = java_lang_String::as_quoted_ascii(value); - _out->print("\"%s\"", (ascii_value != NULL) ? ascii_value : ""); - } else { - const char* klass_name = value->klass()->name()->as_quoted_ascii(); - _out->print_cr("%s", klass_name); - } } else { ShouldNotReachHere(); } From 992f8f87ad7dacf1f1fc9afd9be3e98fc795e8e8 Mon Sep 17 00:00:00 2001 From: Vladimir Ivanov Date: Thu, 14 Feb 2019 15:27:12 -0800 Subject: [PATCH 080/101] 8218758: [TESTBUG] compiler/cha/StrengthReduceInterfaceCall.java misses recompilation event Reviewed-by: iignatyev --- .../cha/StrengthReduceInterfaceCall.java | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java b/test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java index 0c27cde5285..814f937da1d 100644 --- a/test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java +++ b/test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java @@ -53,6 +53,7 @@ import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.internal.org.objectweb.asm.MethodVisitor; import jdk.internal.vm.annotation.DontInline; import sun.hotspot.WhiteBox; +import sun.hotspot.code.NMethod; import java.io.IOException; import java.lang.annotation.Retention; @@ -695,10 +696,6 @@ public class StrengthReduceInterfaceCall { public static final Unsafe U = Unsafe.getUnsafe(); interface Test { - boolean isCompiled(); - void assertNotCompiled(); - void assertCompiled(); - void call(T o); T receiver(int id); @@ -733,14 +730,6 @@ public class StrengthReduceInterfaceCall { }; } - default void compile(Runnable r) { - assertNotCompiled(); - while(!isCompiled()) { - r.run(); - } - assertCompiled(); - } - default void initialize(Class... cs) { for (Class c : cs) { U.ensureClassInitialized(c); @@ -789,14 +778,31 @@ public class StrengthReduceInterfaceCall { })); } - @Override - public boolean isCompiled() { return WB.isMethodCompiled(TEST); } - @Override - public void assertNotCompiled() { assertFalse(isCompiled()); } + public void compile(Runnable r) { + while (!WB.isMethodCompiled(TEST)) { + for (int i = 0; i < 100; i++) { + r.run(); + } + } + assertCompiled(); // record nmethod info + } - @Override - public void assertCompiled() { assertTrue(isCompiled()); } + private NMethod prevNM = null; + + public void assertNotCompiled() { + NMethod curNM = NMethod.get(TEST, false); + assertTrue(prevNM != null); // was previously compiled + assertTrue(curNM == null || prevNM.compile_id != curNM.compile_id); // either no nmethod present or recompiled + prevNM = curNM; // update nmethod info + } + + public void assertCompiled() { + NMethod curNM = NMethod.get(TEST, false); + assertTrue(curNM != null); // nmethod is present + assertTrue(prevNM == null || prevNM.compile_id == curNM.compile_id); // no recompilations if nmethod present + prevNM = curNM; // update nmethod info + } @Override public void call(T i) { From 521039cc354f334991fa07db161a2675215d8847 Mon Sep 17 00:00:00 2001 From: Vladimir Ivanov Date: Thu, 14 Feb 2019 15:27:12 -0800 Subject: [PATCH 081/101] 8218879: Keep track of memory accesses originated from Unsafe Reviewed-by: thartmann --- src/hotspot/share/c1/c1_Decorators.hpp | 2 ++ src/hotspot/share/c1/c1_LIRGenerator.cpp | 6 +++--- .../share/gc/shared/c2/barrierSetC2.cpp | 6 ++++-- src/hotspot/share/opto/graphKit.cpp | 15 ++++++++++----- src/hotspot/share/opto/graphKit.hpp | 16 +++++++++------- src/hotspot/share/opto/memnode.cpp | 18 +++++++++++++++--- src/hotspot/share/opto/memnode.hpp | 15 +++++++++------ 7 files changed, 52 insertions(+), 26 deletions(-) diff --git a/src/hotspot/share/c1/c1_Decorators.hpp b/src/hotspot/share/c1/c1_Decorators.hpp index a545de11a63..9d22bc41458 100644 --- a/src/hotspot/share/c1/c1_Decorators.hpp +++ b/src/hotspot/share/c1/c1_Decorators.hpp @@ -34,5 +34,7 @@ const DecoratorSet C1_NEEDS_PATCHING = DECORATOR_LAST << 1; // Use the C1_MASK_BOOLEAN decorator for boolean accesses where the value // needs to be masked. const DecoratorSet C1_MASK_BOOLEAN = DECORATOR_LAST << 2; +// Use the C1_UNSAFE_ACCESS decorator to mark unsafe accesses. +const DecoratorSet C1_UNSAFE_ACCESS = DECORATOR_LAST << 3; #endif // SHARE_C1_C1_DECORATORS_HPP diff --git a/src/hotspot/share/c1/c1_LIRGenerator.cpp b/src/hotspot/share/c1/c1_LIRGenerator.cpp index d29be5e22cf..d851d3680e8 100644 --- a/src/hotspot/share/c1/c1_LIRGenerator.cpp +++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp @@ -2161,7 +2161,7 @@ void LIRGenerator::do_UnsafeGetObject(UnsafeGetObject* x) { off.load_item(); src.load_item(); - DecoratorSet decorators = IN_HEAP; + DecoratorSet decorators = IN_HEAP | C1_UNSAFE_ACCESS; if (x->is_volatile()) { decorators |= MO_SEQ_CST; @@ -2195,7 +2195,7 @@ void LIRGenerator::do_UnsafePutObject(UnsafePutObject* x) { set_no_result(x); - DecoratorSet decorators = IN_HEAP; + DecoratorSet decorators = IN_HEAP | C1_UNSAFE_ACCESS; if (type == T_ARRAY || type == T_OBJECT) { decorators |= ON_UNKNOWN_OOP_REF; } @@ -2211,7 +2211,7 @@ void LIRGenerator::do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) { LIRItem off(x->offset(), this); LIRItem value(x->value(), this); - DecoratorSet decorators = IN_HEAP | MO_SEQ_CST; + DecoratorSet decorators = IN_HEAP | C1_UNSAFE_ACCESS | MO_SEQ_CST; if (type == T_ARRAY || type == T_OBJECT) { decorators |= ON_UNKNOWN_OOP_REF; diff --git a/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp b/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp index f2ec836acf1..5f6bef3e3e1 100644 --- a/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp +++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp @@ -75,6 +75,7 @@ Node* BarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue& val) cons bool mismatched = (decorators & C2_MISMATCHED) != 0; bool unaligned = (decorators & C2_UNALIGNED) != 0; + bool unsafe = (decorators & C2_UNSAFE_ACCESS) != 0; bool requires_atomic_access = (decorators & MO_UNORDERED) == 0; bool in_native = (decorators & IN_NATIVE) != 0; @@ -93,7 +94,7 @@ Node* BarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue& val) cons } store = kit->store_to_memory(kit->control(), access.addr().node(), val.node(), access.type(), - access.addr().type(), mo, requires_atomic_access, unaligned, mismatched); + access.addr().type(), mo, requires_atomic_access, unaligned, mismatched, unsafe); access.set_raw_access(store); } else { assert(!requires_atomic_access, "not yet supported"); @@ -132,6 +133,7 @@ Node* BarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) con bool unaligned = (decorators & C2_UNALIGNED) != 0; bool control_dependent = (decorators & C2_CONTROL_DEPENDENT_LOAD) != 0; bool pinned = (decorators & C2_PINNED_LOAD) != 0; + bool unsafe = (decorators & C2_UNSAFE_ACCESS) != 0; bool in_native = (decorators & IN_NATIVE) != 0; @@ -148,7 +150,7 @@ Node* BarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) con load = kit->make_load(control, adr, val_type, access.type(), mo); } else { load = kit->make_load(control, adr, val_type, access.type(), adr_type, mo, - dep, requires_atomic_access, unaligned, mismatched); + dep, requires_atomic_access, unaligned, mismatched, unsafe); } access.set_raw_access(load); } else { diff --git a/src/hotspot/share/opto/graphKit.cpp b/src/hotspot/share/opto/graphKit.cpp index e5ebdb7600a..ac2b91117fe 100644 --- a/src/hotspot/share/opto/graphKit.cpp +++ b/src/hotspot/share/opto/graphKit.cpp @@ -1489,18 +1489,19 @@ Node* GraphKit::make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, LoadNode::ControlDependency control_dependency, bool require_atomic_access, bool unaligned, - bool mismatched) { + bool mismatched, + bool unsafe) { assert(adr_idx != Compile::AliasIdxTop, "use other make_load factory" ); const TypePtr* adr_type = NULL; // debug-mode-only argument debug_only(adr_type = C->get_adr_type(adr_idx)); Node* mem = memory(adr_idx); Node* ld; if (require_atomic_access && bt == T_LONG) { - ld = LoadLNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched); + ld = LoadLNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched, unsafe); } else if (require_atomic_access && bt == T_DOUBLE) { - ld = LoadDNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched); + ld = LoadDNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched, unsafe); } else { - ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt, mo, control_dependency, unaligned, mismatched); + ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt, mo, control_dependency, unaligned, mismatched, unsafe); } ld = _gvn.transform(ld); if (((bt == T_OBJECT) && C->do_escape_analysis()) || C->eliminate_boxing()) { @@ -1515,7 +1516,8 @@ Node* GraphKit::store_to_memory(Node* ctl, Node* adr, Node *val, BasicType bt, MemNode::MemOrd mo, bool require_atomic_access, bool unaligned, - bool mismatched) { + bool mismatched, + bool unsafe) { assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" ); const TypePtr* adr_type = NULL; debug_only(adr_type = C->get_adr_type(adr_idx)); @@ -1534,6 +1536,9 @@ Node* GraphKit::store_to_memory(Node* ctl, Node* adr, Node *val, BasicType bt, if (mismatched) { st->as_Store()->set_mismatched_access(); } + if (unsafe) { + st->as_Store()->set_unsafe_access(); + } st = _gvn.transform(st); set_memory(st, adr_idx); // Back-to-back stores can only remove intermediate store with DU info diff --git a/src/hotspot/share/opto/graphKit.hpp b/src/hotspot/share/opto/graphKit.hpp index e9204295d41..ceb94f4b214 100644 --- a/src/hotspot/share/opto/graphKit.hpp +++ b/src/hotspot/share/opto/graphKit.hpp @@ -518,27 +518,27 @@ class GraphKit : public Phase { Node* make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, MemNode::MemOrd mo, LoadNode::ControlDependency control_dependency = LoadNode::DependsOnlyOnTest, bool require_atomic_access = false, bool unaligned = false, - bool mismatched = false) { + bool mismatched = false, bool unsafe = false) { // This version computes alias_index from bottom_type return make_load(ctl, adr, t, bt, adr->bottom_type()->is_ptr(), mo, control_dependency, require_atomic_access, - unaligned, mismatched); + unaligned, mismatched, unsafe); } Node* make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, const TypePtr* adr_type, MemNode::MemOrd mo, LoadNode::ControlDependency control_dependency = LoadNode::DependsOnlyOnTest, bool require_atomic_access = false, bool unaligned = false, - bool mismatched = false) { + bool mismatched = false, bool unsafe = false) { // This version computes alias_index from an address type assert(adr_type != NULL, "use other make_load factory"); return make_load(ctl, adr, t, bt, C->get_alias_index(adr_type), mo, control_dependency, require_atomic_access, - unaligned, mismatched); + unaligned, mismatched, unsafe); } // This is the base version which is given an alias index. Node* make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, int adr_idx, MemNode::MemOrd mo, LoadNode::ControlDependency control_dependency = LoadNode::DependsOnlyOnTest, bool require_atomic_access = false, bool unaligned = false, - bool mismatched = false); + bool mismatched = false, bool unsafe = false); // Create & transform a StoreNode and store the effect into the // parser's memory state. @@ -553,7 +553,8 @@ class GraphKit : public Phase { MemNode::MemOrd mo, bool require_atomic_access = false, bool unaligned = false, - bool mismatched = false) { + bool mismatched = false, + bool unsafe = false) { // This version computes alias_index from an address type assert(adr_type != NULL, "use other store_to_memory factory"); return store_to_memory(ctl, adr, val, bt, @@ -568,7 +569,8 @@ class GraphKit : public Phase { MemNode::MemOrd, bool require_atomic_access = false, bool unaligned = false, - bool mismatched = false); + bool mismatched = false, + bool unsafe = false); // Perform decorated accesses diff --git a/src/hotspot/share/opto/memnode.cpp b/src/hotspot/share/opto/memnode.cpp index 9d1c38154af..5a4323557bf 100644 --- a/src/hotspot/share/opto/memnode.cpp +++ b/src/hotspot/share/opto/memnode.cpp @@ -99,6 +99,9 @@ void MemNode::dump_spec(outputStream *st) const { if (_mismatched_access) { st->print(" mismatched"); } + if (_unsafe_access) { + st->print(" unsafe"); + } } void MemNode::dump_adr_type(const Node* mem, const TypePtr* adr_type, outputStream *st) { @@ -789,7 +792,7 @@ bool LoadNode::is_immutable_value(Node* adr) { //----------------------------LoadNode::make----------------------------------- // Polymorphic factory method: Node *LoadNode::make(PhaseGVN& gvn, Node *ctl, Node *mem, Node *adr, const TypePtr* adr_type, const Type *rt, BasicType bt, MemOrd mo, - ControlDependency control_dependency, bool unaligned, bool mismatched) { + ControlDependency control_dependency, bool unaligned, bool mismatched, bool unsafe) { Compile* C = gvn.C; // sanity check the alias category against the created node type @@ -837,6 +840,9 @@ Node *LoadNode::make(PhaseGVN& gvn, Node *ctl, Node *mem, Node *adr, const TypeP if (mismatched) { load->set_mismatched_access(); } + if (unsafe) { + load->set_unsafe_access(); + } if (load->Opcode() == Op_LoadN) { Node* ld = gvn.transform(load); return new DecodeNNode(ld, ld->bottom_type()->make_ptr()); @@ -846,7 +852,7 @@ Node *LoadNode::make(PhaseGVN& gvn, Node *ctl, Node *mem, Node *adr, const TypeP } LoadLNode* LoadLNode::make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo, - ControlDependency control_dependency, bool unaligned, bool mismatched) { + ControlDependency control_dependency, bool unaligned, bool mismatched, bool unsafe) { bool require_atomic = true; LoadLNode* load = new LoadLNode(ctl, mem, adr, adr_type, rt->is_long(), mo, control_dependency, require_atomic); if (unaligned) { @@ -855,11 +861,14 @@ LoadLNode* LoadLNode::make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr if (mismatched) { load->set_mismatched_access(); } + if (unsafe) { + load->set_unsafe_access(); + } return load; } LoadDNode* LoadDNode::make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo, - ControlDependency control_dependency, bool unaligned, bool mismatched) { + ControlDependency control_dependency, bool unaligned, bool mismatched, bool unsafe) { bool require_atomic = true; LoadDNode* load = new LoadDNode(ctl, mem, adr, adr_type, rt, mo, control_dependency, require_atomic); if (unaligned) { @@ -868,6 +877,9 @@ LoadDNode* LoadDNode::make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr if (mismatched) { load->set_mismatched_access(); } + if (unsafe) { + load->set_unsafe_access(); + } return load; } diff --git a/src/hotspot/share/opto/memnode.hpp b/src/hotspot/share/opto/memnode.hpp index 0b37b848189..89c0a8c8840 100644 --- a/src/hotspot/share/opto/memnode.hpp +++ b/src/hotspot/share/opto/memnode.hpp @@ -42,6 +42,7 @@ class MemNode : public Node { private: bool _unaligned_access; // Unaligned access from unsafe bool _mismatched_access; // Mismatched access from unsafe: byte read in integer array for instance + bool _unsafe_access; // Access of unsafe origin. protected: #ifdef ASSERT const TypePtr* _adr_type; // What kind of memory is being addressed? @@ -62,17 +63,17 @@ public: } MemOrd; protected: MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at ) - : Node(c0,c1,c2 ), _unaligned_access(false), _mismatched_access(false) { + : Node(c0,c1,c2 ), _unaligned_access(false), _mismatched_access(false), _unsafe_access(false) { init_class_id(Class_Mem); debug_only(_adr_type=at; adr_type();) } MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at, Node *c3 ) - : Node(c0,c1,c2,c3), _unaligned_access(false), _mismatched_access(false) { + : Node(c0,c1,c2,c3), _unaligned_access(false), _mismatched_access(false), _unsafe_access(false) { init_class_id(Class_Mem); debug_only(_adr_type=at; adr_type();) } MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at, Node *c3, Node *c4) - : Node(c0,c1,c2,c3,c4), _unaligned_access(false), _mismatched_access(false) { + : Node(c0,c1,c2,c3,c4), _unaligned_access(false), _mismatched_access(false), _unsafe_access(false) { init_class_id(Class_Mem); debug_only(_adr_type=at; adr_type();) } @@ -137,6 +138,8 @@ public: bool is_unaligned_access() const { return _unaligned_access; } void set_mismatched_access() { _mismatched_access = true; } bool is_mismatched_access() const { return _mismatched_access; } + void set_unsafe_access() { _unsafe_access = true; } + bool is_unsafe_access() const { return _unsafe_access; } #ifndef PRODUCT static void dump_adr_type(const Node* mem, const TypePtr* adr_type, outputStream *st); @@ -207,7 +210,7 @@ public: static Node* make(PhaseGVN& gvn, Node *c, Node *mem, Node *adr, const TypePtr* at, const Type *rt, BasicType bt, MemOrd mo, ControlDependency control_dependency = DependsOnlyOnTest, - bool unaligned = false, bool mismatched = false); + bool unaligned = false, bool mismatched = false, bool unsafe = false); virtual uint hash() const; // Check the type @@ -388,7 +391,7 @@ public: bool require_atomic_access() const { return _require_atomic_access; } static LoadLNode* make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo, ControlDependency control_dependency = DependsOnlyOnTest, - bool unaligned = false, bool mismatched = false); + bool unaligned = false, bool mismatched = false, bool unsafe = false); #ifndef PRODUCT virtual void dump_spec(outputStream *st) const { LoadNode::dump_spec(st); @@ -440,7 +443,7 @@ public: bool require_atomic_access() const { return _require_atomic_access; } static LoadDNode* make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo, ControlDependency control_dependency = DependsOnlyOnTest, - bool unaligned = false, bool mismatched = false); + bool unaligned = false, bool mismatched = false, bool unsafe = false); #ifndef PRODUCT virtual void dump_spec(outputStream *st) const { LoadNode::dump_spec(st); From 40c61cce4ba12132e9c15e2a6266b7fe4c0b9fff Mon Sep 17 00:00:00 2001 From: Vladimir Ivanov Date: Thu, 14 Feb 2019 15:27:12 -0800 Subject: [PATCH 082/101] 8218874: C2: Unsafe to access PhaseIdealLoop outside of constructors Reviewed-by: thartmann, kvn --- src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp | 2 +- src/hotspot/share/opto/compile.cpp | 12 ++-- src/hotspot/share/opto/loopnode.cpp | 2 - src/hotspot/share/opto/loopnode.hpp | 79 ++++++++++++--------- 4 files changed, 51 insertions(+), 44 deletions(-) diff --git a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp index ceb309aae3e..632a9f9dfb6 100644 --- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp +++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp @@ -130,7 +130,7 @@ void ZBarrierSetC2::find_dominating_barriers(PhaseIterGVN& igvn) { ZBarrierSetC2State* s = bs->state(); if (s->load_barrier_count() >= 2) { Compile::TracePhase tp("idealLoop", &C->timers[Phase::_t_idealLoop]); - PhaseIdealLoop ideal_loop(igvn, LoopOptsLastRound); + PhaseIdealLoop::optimize(igvn, LoopOptsLastRound); if (C->major_progress()) C->print_method(PHASE_PHASEIDEALLOOP_ITERATIONS, 2); } } diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp index 944e0e84cba..2a848a24541 100644 --- a/src/hotspot/share/opto/compile.cpp +++ b/src/hotspot/share/opto/compile.cpp @@ -2112,7 +2112,7 @@ void Compile::inline_incrementally(PhaseIterGVN& igvn) { // PhaseIdealLoop is expensive so we only try it once we are // out of live nodes and we only try it again if the previous // helped got the number of nodes down significantly - PhaseIdealLoop ideal_loop(igvn, LoopOptsNone); + PhaseIdealLoop::optimize(igvn, LoopOptsNone); if (failing()) return; low_live_nodes = live_nodes(); _major_progress = true; @@ -2160,7 +2160,7 @@ bool Compile::optimize_loops(PhaseIterGVN& igvn, LoopOptsMode mode) { while(major_progress() && (_loop_opts_cnt > 0)) { TracePhase tp("idealLoop", &timers[_t_idealLoop]); assert( cnt++ < 40, "infinite cycle in loop optimization" ); - PhaseIdealLoop ideal_loop(igvn, mode); + PhaseIdealLoop::optimize(igvn, mode); _loop_opts_cnt--; if (failing()) return false; if (major_progress()) print_method(PHASE_PHASEIDEALLOOP_ITERATIONS, 2); @@ -2282,7 +2282,7 @@ void Compile::Optimize() { if (has_loops()) { // Cleanup graph (remove dead nodes). TracePhase tp("idealLoop", &timers[_t_idealLoop]); - PhaseIdealLoop ideal_loop(igvn, LoopOptsNone); + PhaseIdealLoop::optimize(igvn, LoopOptsNone); if (major_progress()) print_method(PHASE_PHASEIDEAL_BEFORE_EA, 2); if (failing()) return; } @@ -2316,7 +2316,7 @@ void Compile::Optimize() { if((_loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) { { TracePhase tp("idealLoop", &timers[_t_idealLoop]); - PhaseIdealLoop ideal_loop(igvn, LoopOptsDefault); + PhaseIdealLoop::optimize(igvn, LoopOptsDefault); _loop_opts_cnt--; if (major_progress()) print_method(PHASE_PHASEIDEALLOOP1, 2); if (failing()) return; @@ -2324,7 +2324,7 @@ void Compile::Optimize() { // Loop opts pass if partial peeling occurred in previous pass if(PartialPeelLoop && major_progress() && (_loop_opts_cnt > 0)) { TracePhase tp("idealLoop", &timers[_t_idealLoop]); - PhaseIdealLoop ideal_loop(igvn, LoopOptsSkipSplitIf); + PhaseIdealLoop::optimize(igvn, LoopOptsSkipSplitIf); _loop_opts_cnt--; if (major_progress()) print_method(PHASE_PHASEIDEALLOOP2, 2); if (failing()) return; @@ -2332,7 +2332,7 @@ void Compile::Optimize() { // Loop opts pass for loop-unrolling before CCP if(major_progress() && (_loop_opts_cnt > 0)) { TracePhase tp("idealLoop", &timers[_t_idealLoop]); - PhaseIdealLoop ideal_loop(igvn, LoopOptsSkipSplitIf); + PhaseIdealLoop::optimize(igvn, LoopOptsSkipSplitIf); _loop_opts_cnt--; if (major_progress()) print_method(PHASE_PHASEIDEALLOOP3, 2); } diff --git a/src/hotspot/share/opto/loopnode.cpp b/src/hotspot/share/opto/loopnode.cpp index c1d61ca8e4f..2ca51d50020 100644 --- a/src/hotspot/share/opto/loopnode.cpp +++ b/src/hotspot/share/opto/loopnode.cpp @@ -2712,8 +2712,6 @@ void PhaseIdealLoop::build_and_optimize(LoopOptsMode mode) { bool do_split_ifs = (mode == LoopOptsDefault || mode == LoopOptsLastRound); bool skip_loop_opts = (mode == LoopOptsNone); - ResourceMark rm; - int old_progress = C->major_progress(); uint orig_worklist_size = _igvn._worklist.size(); diff --git a/src/hotspot/share/opto/loopnode.hpp b/src/hotspot/share/opto/loopnode.hpp index c34dc2a3527..09f13ab58d7 100644 --- a/src/hotspot/share/opto/loopnode.hpp +++ b/src/hotspot/share/opto/loopnode.hpp @@ -880,6 +880,42 @@ private: uint *_dom_depth; // Used for fast LCA test GrowableArray* _dom_stk; // For recomputation of dom depth + // Perform verification that the graph is valid. + PhaseIdealLoop( PhaseIterGVN &igvn) : + PhaseTransform(Ideal_Loop), + _igvn(igvn), + _verify_me(NULL), + _verify_only(true), + _dom_lca_tags(arena()) { // Thread::resource_area + build_and_optimize(LoopOptsVerify); + } + + // build the loop tree and perform any requested optimizations + void build_and_optimize(LoopOptsMode mode); + + // Dominators for the sea of nodes + void Dominators(); + + // Compute the Ideal Node to Loop mapping + PhaseIdealLoop(PhaseIterGVN &igvn, LoopOptsMode mode) : + PhaseTransform(Ideal_Loop), + _igvn(igvn), + _verify_me(NULL), + _verify_only(false), + _dom_lca_tags(arena()) { // Thread::resource_area + build_and_optimize(mode); + } + + // Verify that verify_me made the same decisions as a fresh run. + PhaseIdealLoop(PhaseIterGVN &igvn, const PhaseIdealLoop *verify_me) : + PhaseTransform(Ideal_Loop), + _igvn(igvn), + _verify_me(verify_me), + _verify_only(false), + _dom_lca_tags(arena()) { // Thread::resource_area + build_and_optimize(LoopOptsVerify); + } + public: Node* idom_no_update(Node* d) const { return idom_no_update(d->_idx); @@ -923,54 +959,27 @@ public: // Replace parallel induction variable (parallel to trip counter) void replace_parallel_iv(IdealLoopTree *loop); - // Perform verification that the graph is valid. - PhaseIdealLoop( PhaseIterGVN &igvn) : - PhaseTransform(Ideal_Loop), - _igvn(igvn), - _verify_me(NULL), - _verify_only(true), - _dom_lca_tags(arena()) { // Thread::resource_area - build_and_optimize(LoopOptsVerify); - } - - // build the loop tree and perform any requested optimizations - void build_and_optimize(LoopOptsMode mode); - - // Dominators for the sea of nodes - void Dominators(); Node *dom_lca( Node *n1, Node *n2 ) const { return find_non_split_ctrl(dom_lca_internal(n1, n2)); } Node *dom_lca_internal( Node *n1, Node *n2 ) const; - // Compute the Ideal Node to Loop mapping - PhaseIdealLoop(PhaseIterGVN &igvn, LoopOptsMode mode) : - PhaseTransform(Ideal_Loop), - _igvn(igvn), - _verify_me(NULL), - _verify_only(false), - _dom_lca_tags(arena()) { // Thread::resource_area - build_and_optimize(mode); - } - - // Verify that verify_me made the same decisions as a fresh run. - PhaseIdealLoop(PhaseIterGVN &igvn, const PhaseIdealLoop *verify_me) : - PhaseTransform(Ideal_Loop), - _igvn(igvn), - _verify_me(verify_me), - _verify_only(false), - _dom_lca_tags(arena()) { // Thread::resource_area - build_and_optimize(LoopOptsVerify); - } - // Build and verify the loop tree without modifying the graph. This // is useful to verify that all inputs properly dominate their uses. static void verify(PhaseIterGVN& igvn) { #ifdef ASSERT + ResourceMark rm; PhaseIdealLoop v(igvn); #endif } + // Recommended way to use PhaseIdealLoop. + // Run PhaseIdealLoop in some mode and allocates a local scope for memory allocations. + static void optimize(PhaseIterGVN &igvn, LoopOptsMode mode) { + ResourceMark rm; + PhaseIdealLoop v(igvn, mode); + } + // True if the method has at least 1 irreducible loop bool _has_irreducible_loops; From d41611ebebbb6c8542d6cb98cdcfc10b9a7a8a40 Mon Sep 17 00:00:00 2001 From: Vladimir Ivanov Date: Thu, 14 Feb 2019 15:27:46 -0800 Subject: [PATCH 083/101] 8161334: C2: Cast nodes hinder memory alias analysis Reviewed-by: kvn, thartmann --- src/hotspot/share/opto/memnode.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/hotspot/share/opto/memnode.cpp b/src/hotspot/share/opto/memnode.cpp index 5a4323557bf..caa9b8afe50 100644 --- a/src/hotspot/share/opto/memnode.cpp +++ b/src/hotspot/share/opto/memnode.cpp @@ -990,7 +990,8 @@ Node* LoadNode::can_see_arraycopy_value(Node* st, PhaseGVN* phase) const { Node* MemNode::can_see_stored_value(Node* st, PhaseTransform* phase) const { Node* ld_adr = in(MemNode::Address); intptr_t ld_off = 0; - AllocateNode* ld_alloc = AllocateNode::Ideal_allocation(ld_adr, phase, ld_off); + Node* ld_base = AddPNode::Ideal_base_and_offset(ld_adr, phase, ld_off); + Node* ld_alloc = AllocateNode::Ideal_allocation(ld_base, phase); const TypeInstPtr* tp = phase->type(ld_adr)->isa_instptr(); Compile::AliasType* atp = (tp != NULL) ? phase->C->alias_type(tp) : NULL; // This is more general than load from boxing objects. @@ -1043,16 +1044,21 @@ Node* MemNode::can_see_stored_value(Node* st, PhaseTransform* phase) const { if (st->is_Store()) { Node* st_adr = st->in(MemNode::Address); if (!phase->eqv(st_adr, ld_adr)) { - // Try harder before giving up... Match raw and non-raw pointers. + // Try harder before giving up. Unify base pointers with casts (e.g., raw/non-raw pointers). intptr_t st_off = 0; - AllocateNode* alloc = AllocateNode::Ideal_allocation(st_adr, phase, st_off); - if (alloc == NULL) return NULL; - if (alloc != ld_alloc) return NULL; - if (ld_off != st_off) return NULL; + Node* st_base = AddPNode::Ideal_base_and_offset(st_adr, phase, st_off); + if (ld_base == NULL) return NULL; + if (st_base == NULL) return NULL; + if (ld_base->uncast() != st_base->uncast()) return NULL; + if (ld_off != st_off) return NULL; + if (ld_off == Type::OffsetBot) return NULL; + // Same base, same offset. + // Possible improvement for arrays: check index value instead of absolute offset. + // At this point we have proven something like this setup: - // A = Allocate(...) - // L = LoadQ(, AddP(CastPP(, A.Parm),, #Off)) - // S = StoreQ(, AddP(, A.Parm , #Off), V) + // B = << base >> + // L = LoadQ(AddP(Check/CastPP(B), #Off)) + // S = StoreQ(AddP( B , #Off), V) // (Actually, we haven't yet proven the Q's are the same.) // In other words, we are loading from a casted version of // the same pointer-and-offset that we stored to. From 34fe424afbb0c38bf4ea0e882ba4d95a7475cdcb Mon Sep 17 00:00:00 2001 From: David Holmes Date: Thu, 14 Feb 2019 22:57:37 -0500 Subject: [PATCH 084/101] 8218939: vm/mlvm/anonloader/stress/byteMutation crashed on windows Reviewed-by: kbarrett, coleenp, mikael, iignatyev --- .../share/classfile/classFileParser.cpp | 14 +++++++------ .../classFileParserBug/TestBadClassName.java | 20 +++++++++++++++---- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index 996dde685b2..8508e45b810 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -5020,7 +5020,8 @@ bool ClassFileParser::verify_unqualified_name(const char* name, return true; } -// Take pointer to a string. Skip over the longest part of the string that could +// Take pointer to a UTF8 byte string (not NUL-terminated). +// Skip over the longest part of the string that could // be taken as a fieldname. Allow '/' if slash_ok is true. // Return a pointer to just past the fieldname. // Return NULL if no fieldname at all was found, or in the case of slash_ok @@ -5098,7 +5099,8 @@ static const char* skip_over_field_name(const char* const name, return (not_first_ch) ? p : NULL; } -// Take pointer to a string. Skip over the longest part of the string that could +// Take pointer to a UTF8 byte string (not NUL-terminated). +// Skip over the longest part of the string that could // be taken as a field signature. Allow "void" if void_ok. // Return a pointer to just past the signature. // Return NULL if no legal signature is found. @@ -5132,7 +5134,7 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature, else { // Skip leading 'L' and ignore first appearance of ';' signature++; - char* c = strchr((char*) signature, ';'); + const char* c = (const char*) memchr(signature, ';', length - 1); // Format check signature if (c != NULL) { int newlen = c - (char*) signature; @@ -5199,7 +5201,7 @@ void ClassFileParser::verify_legal_class_name(const Symbol* name, TRAPS) const { Exceptions::fthrow( THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(), - "Illegal class name \"%s\" in class file %s", bytes, + "Illegal class name \"%.*s\" in class file %s", length, bytes, _class_name->as_C_string() ); return; @@ -5232,7 +5234,7 @@ void ClassFileParser::verify_legal_field_name(const Symbol* name, TRAPS) const { Exceptions::fthrow( THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(), - "Illegal field name \"%s\" in class %s", bytes, + "Illegal field name \"%.*s\" in class %s", length, bytes, _class_name->as_C_string() ); return; @@ -5269,7 +5271,7 @@ void ClassFileParser::verify_legal_method_name(const Symbol* name, TRAPS) const Exceptions::fthrow( THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(), - "Illegal method name \"%s\" in class %s", bytes, + "Illegal method name \"%.*s\" in class %s", length, bytes, _class_name->as_C_string() ); return; diff --git a/test/hotspot/jtreg/runtime/classFileParserBug/TestBadClassName.java b/test/hotspot/jtreg/runtime/classFileParserBug/TestBadClassName.java index 970d4a54eb6..f369f50557a 100644 --- a/test/hotspot/jtreg/runtime/classFileParserBug/TestBadClassName.java +++ b/test/hotspot/jtreg/runtime/classFileParserBug/TestBadClassName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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 8158297 + * @bug 8158297 8218939 * @summary Constant pool utf8 entry for class name cannot have empty qualified name '//' * @compile p1/BadInterface1.jcod * @compile p1/BadInterface2.jcod @@ -37,20 +37,32 @@ public class TestBadClassName { System.out.println("Regression test for bug 8042660"); - // Test class name with p1//BadInterface2 + // Test class name with p1//BadInterface1 + String expected = "Illegal class name \"p1//BadInterface1\" in class file UseBadInterface1"; try { Class newClass = Class.forName("UseBadInterface1"); throw new RuntimeException("Expected ClassFormatError exception not thrown"); } catch (java.lang.ClassFormatError e) { + check(e, expected); System.out.println("Test UseBadInterface1 passed test case with illegal class name"); } // Test class name with p1/BadInterface2/ + expected = "Illegal class name \"p1/BadInterface2/\" in class file UseBadInterface2"; try { Class newClass = Class.forName("UseBadInterface2"); throw new RuntimeException("Expected ClassFormatError exception not thrown"); } catch (java.lang.ClassFormatError e) { - System.out.println("Test UseBadInterface1 passed test case with illegal class name"); + check(e, expected); + System.out.println("Test UseBadInterface2 passed test case with illegal class name"); + } + } + + static void check(ClassFormatError c, String expected) { + if (!c.getMessage().equals(expected)) { + throw new RuntimeException("Wrong ClassFormatError - expected: \"" + + expected + "\", got \"" + + c.getMessage() + "\""); } } } From 8512c3117d4c063742dc50cbe69d68e526a1cbbb Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Thu, 14 Feb 2019 23:45:03 -0800 Subject: [PATCH 085/101] 8218471: generate-unsafe-access-tests.sh does not correctly invoke build.tools.spp.Spp Reviewed-by: kvn, thartmann --- .../unsafe/X-UnsafeAccessTest.java.template | 104 +++++++++--------- .../unsafe/generate-unsafe-access-tests.sh | 14 ++- 2 files changed, 63 insertions(+), 55 deletions(-) diff --git a/test/hotspot/jtreg/compiler/unsafe/X-UnsafeAccessTest.java.template b/test/hotspot/jtreg/compiler/unsafe/X-UnsafeAccessTest.java.template index f28791765a1..773327240c5 100644 --- a/test/hotspot/jtreg/compiler/unsafe/X-UnsafeAccessTest.java.template +++ b/test/hotspot/jtreg/compiler/unsafe/X-UnsafeAccessTest.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -156,15 +156,15 @@ public class $Qualifier$UnsafeAccessTest$Type$ { static void testAccess(Object base, long offset) { // Plain { - UNSAFE.put$Type$(base, offset, $value1$); - $type$ x = UNSAFE.get$Type$(base, offset); + UNSAFE.put$MethodAffix$(base, offset, $value1$); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); assertEquals(x, $value1$, "set $type$ value"); } // Volatile { - UNSAFE.put$Type$Volatile(base, offset, $value2$); - $type$ x = UNSAFE.get$Type$Volatile(base, offset); + UNSAFE.put$MethodAffix$Volatile(base, offset, $value2$); + $type$ x = UNSAFE.get$MethodAffix$Volatile(base, offset); assertEquals(x, $value2$, "putVolatile $type$ value"); } @@ -172,8 +172,8 @@ public class $Qualifier$UnsafeAccessTest$Type$ { #if[Ordered] // Lazy { - UNSAFE.putOrdered$Type$(base, offset, $value1$); - $type$ x = UNSAFE.get$Type$Volatile(base, offset); + UNSAFE.putOrdered$MethodAffix$(base, offset, $value1$); + $type$ x = UNSAFE.get$MethodAffix$Volatile(base, offset); assertEquals(x, $value1$, "putRelease $type$ value"); } #end[Ordered] @@ -182,15 +182,15 @@ public class $Qualifier$UnsafeAccessTest$Type$ { #if[JdkInternalMisc] // Lazy { - UNSAFE.put$Type$Release(base, offset, $value1$); - $type$ x = UNSAFE.get$Type$Acquire(base, offset); + UNSAFE.put$MethodAffix$Release(base, offset, $value1$); + $type$ x = UNSAFE.get$MethodAffix$Acquire(base, offset); assertEquals(x, $value1$, "putRelease $type$ value"); } // Opaque { - UNSAFE.put$Type$Opaque(base, offset, $value2$); - $type$ x = UNSAFE.get$Type$Opaque(base, offset); + UNSAFE.put$MethodAffix$Opaque(base, offset, $value2$); + $type$ x = UNSAFE.get$MethodAffix$Opaque(base, offset); assertEquals(x, $value2$, "putOpaque $type$ value"); } #end[JdkInternalMisc] @@ -199,38 +199,38 @@ public class $Qualifier$UnsafeAccessTest$Type$ { #if[Unaligned] // Unaligned { - UNSAFE.put$Type$Unaligned(base, offset, $value2$); - $type$ x = UNSAFE.get$Type$Unaligned(base, offset); + UNSAFE.put$MethodAffix$Unaligned(base, offset, $value2$); + $type$ x = UNSAFE.get$MethodAffix$Unaligned(base, offset); assertEquals(x, $value2$, "putUnaligned $type$ value"); } { - UNSAFE.put$Type$Unaligned(base, offset, $value1$, true); - $type$ x = UNSAFE.get$Type$Unaligned(base, offset, true); + UNSAFE.put$MethodAffix$Unaligned(base, offset, $value1$, true); + $type$ x = UNSAFE.get$MethodAffix$Unaligned(base, offset, true); assertEquals(x, $value1$, "putUnaligned big endian $type$ value"); } { - UNSAFE.put$Type$Unaligned(base, offset, $value2$, false); - $type$ x = UNSAFE.get$Type$Unaligned(base, offset, false); + UNSAFE.put$MethodAffix$Unaligned(base, offset, $value2$, false); + $type$ x = UNSAFE.get$MethodAffix$Unaligned(base, offset, false); assertEquals(x, $value2$, "putUnaligned little endian $type$ value"); } #end[Unaligned] #end[JdkInternalMisc] #if[CAS] - UNSAFE.put$Type$(base, offset, $value1$); + UNSAFE.put$MethodAffix$(base, offset, $value1$); // Compare { #if[JdkInternalMisc] - boolean r = UNSAFE.compareAndSet$Type$(base, offset, $value1$, $value2$); + boolean r = UNSAFE.compareAndSet$MethodAffix$(base, offset, $value1$, $value2$); assertEquals(r, true, "success compareAndSet $type$"); #else[JdkInternalMisc] - boolean r = UNSAFE.compareAndSwap$Type$(base, offset, $value1$, $value2$); + boolean r = UNSAFE.compareAndSwap$MethodAffix$(base, offset, $value1$, $value2$); assertEquals(r, true, "success compareAndSwap $type$"); #end[JdkInternalMisc] - $type$ x = UNSAFE.get$Type$(base, offset); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); #if[JdkInternalMisc] assertEquals(x, $value2$, "success compareAndSet $type$ value"); #else[JdkInternalMisc] @@ -240,13 +240,13 @@ public class $Qualifier$UnsafeAccessTest$Type$ { { #if[JdkInternalMisc] - boolean r = UNSAFE.compareAndSet$Type$(base, offset, $value1$, $value3$); + boolean r = UNSAFE.compareAndSet$MethodAffix$(base, offset, $value1$, $value3$); assertEquals(r, false, "failing compareAndSet $type$"); #else[JdkInternalMisc] - boolean r = UNSAFE.compareAndSwap$Type$(base, offset, $value1$, $value3$); + boolean r = UNSAFE.compareAndSwap$MethodAffix$(base, offset, $value1$, $value3$); assertEquals(r, false, "failing compareAndSwap $type$"); #end[JdkInternalMisc] - $type$ x = UNSAFE.get$Type$(base, offset); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); #if[JdkInternalMisc] assertEquals(x, $value2$, "failing compareAndSet $type$ value"); #else[JdkInternalMisc] @@ -257,107 +257,107 @@ public class $Qualifier$UnsafeAccessTest$Type$ { #if[JdkInternalMisc] // Advanced compare { - $type$ r = UNSAFE.compareAndExchange$Type$(base, offset, $value2$, $value1$); + $type$ r = UNSAFE.compareAndExchange$MethodAffix$(base, offset, $value2$, $value1$); assertEquals(r, $value2$, "success compareAndExchange $type$"); - $type$ x = UNSAFE.get$Type$(base, offset); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); assertEquals(x, $value1$, "success compareAndExchange $type$ value"); } { - $type$ r = UNSAFE.compareAndExchange$Type$(base, offset, $value2$, $value3$); + $type$ r = UNSAFE.compareAndExchange$MethodAffix$(base, offset, $value2$, $value3$); assertEquals(r, $value1$, "failing compareAndExchange $type$"); - $type$ x = UNSAFE.get$Type$(base, offset); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); assertEquals(x, $value1$, "failing compareAndExchange $type$ value"); } { - $type$ r = UNSAFE.compareAndExchange$Type$Acquire(base, offset, $value1$, $value2$); + $type$ r = UNSAFE.compareAndExchange$MethodAffix$Acquire(base, offset, $value1$, $value2$); assertEquals(r, $value1$, "success compareAndExchangeAcquire $type$"); - $type$ x = UNSAFE.get$Type$(base, offset); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); assertEquals(x, $value2$, "success compareAndExchangeAcquire $type$ value"); } { - $type$ r = UNSAFE.compareAndExchange$Type$Acquire(base, offset, $value1$, $value3$); + $type$ r = UNSAFE.compareAndExchange$MethodAffix$Acquire(base, offset, $value1$, $value3$); assertEquals(r, $value2$, "failing compareAndExchangeAcquire $type$"); - $type$ x = UNSAFE.get$Type$(base, offset); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); assertEquals(x, $value2$, "failing compareAndExchangeAcquire $type$ value"); } { - $type$ r = UNSAFE.compareAndExchange$Type$Release(base, offset, $value2$, $value1$); + $type$ r = UNSAFE.compareAndExchange$MethodAffix$Release(base, offset, $value2$, $value1$); assertEquals(r, $value2$, "success compareAndExchangeRelease $type$"); - $type$ x = UNSAFE.get$Type$(base, offset); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); assertEquals(x, $value1$, "success compareAndExchangeRelease $type$ value"); } { - $type$ r = UNSAFE.compareAndExchange$Type$Release(base, offset, $value2$, $value3$); + $type$ r = UNSAFE.compareAndExchange$MethodAffix$Release(base, offset, $value2$, $value3$); assertEquals(r, $value1$, "failing compareAndExchangeRelease $type$"); - $type$ x = UNSAFE.get$Type$(base, offset); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSet$Type$Plain(base, offset, $value1$, $value2$); + success = UNSAFE.weakCompareAndSet$MethodAffix$Plain(base, offset, $value1$, $value2$); } assertEquals(success, true, "weakCompareAndSetPlain $type$"); - $type$ x = UNSAFE.get$Type$(base, offset); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSet$Type$Acquire(base, offset, $value2$, $value1$); + success = UNSAFE.weakCompareAndSet$MethodAffix$Acquire(base, offset, $value2$, $value1$); } assertEquals(success, true, "weakCompareAndSetAcquire $type$"); - $type$ x = UNSAFE.get$Type$(base, offset); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSet$Type$Release(base, offset, $value1$, $value2$); + success = UNSAFE.weakCompareAndSet$MethodAffix$Release(base, offset, $value1$, $value2$); } assertEquals(success, true, "weakCompareAndSetRelease $type$"); - $type$ x = UNSAFE.get$Type$(base, offset); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSet$Type$(base, offset, $value2$, $value1$); + success = UNSAFE.weakCompareAndSet$MethodAffix$(base, offset, $value2$, $value1$); } assertEquals(success, true, "weakCompareAndSet $type$"); - $type$ x = UNSAFE.get$Type$(base, offset); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); assertEquals(x, $value1$, "weakCompareAndSet $type$"); } #end[JdkInternalMisc] - UNSAFE.put$Type$(base, offset, $value2$); + UNSAFE.put$MethodAffix$(base, offset, $value2$); // Compare set and get { - $type$ o = UNSAFE.getAndSet$Type$(base, offset, $value1$); + $type$ o = UNSAFE.getAndSet$MethodAffix$(base, offset, $value1$); assertEquals(o, $value2$, "getAndSet $type$"); - $type$ x = UNSAFE.get$Type$(base, offset); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); assertEquals(x, $value1$, "getAndSet $type$ value"); } #end[CAS] #if[AtomicAdd] - UNSAFE.put$Type$(base, offset, $value1$); + UNSAFE.put$MethodAffix$(base, offset, $value1$); // get and add, add and get { - $type$ o = UNSAFE.getAndAdd$Type$(base, offset, $value2$); + $type$ o = UNSAFE.getAndAdd$MethodAffix$(base, offset, $value2$); assertEquals(o, $value1$, "getAndAdd $type$"); - $type$ x = UNSAFE.get$Type$(base, offset); + $type$ x = UNSAFE.get$MethodAffix$(base, offset); assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$"); } #end[AtomicAdd] @@ -368,8 +368,8 @@ public class $Qualifier$UnsafeAccessTest$Type$ { static void testAccess(long address) { // Plain { - UNSAFE.put$Type$(address, $value1$); - $type$ x = UNSAFE.get$Type$(address); + UNSAFE.put$MethodAffix$(address, $value1$); + $type$ x = UNSAFE.get$MethodAffix$(address); assertEquals(x, $value1$, "set $type$ value"); } } diff --git a/test/hotspot/jtreg/compiler/unsafe/generate-unsafe-access-tests.sh b/test/hotspot/jtreg/compiler/unsafe/generate-unsafe-access-tests.sh index ef75a79b8f3..32db4148efb 100644 --- a/test/hotspot/jtreg/compiler/unsafe/generate-unsafe-access-tests.sh +++ b/test/hotspot/jtreg/compiler/unsafe/generate-unsafe-access-tests.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2019, 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 @@ # questions. # -javac -d . ../../../../jdk/make/src/classes/build/tools/spp/Spp.java +javac -d . ../../../../../make/jdk/src/classes/build/tools/spp/Spp.java SPP=build.tools.spp.Spp @@ -41,6 +41,12 @@ function generate { Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}" args="-K$type -Dtype=$type -DType=$Type" + if [ "$Type" == "Object" -a "$package" == "jdk.internal.misc" ]; then + args="$args -DMethodAffix=Reference" + else + args="$args -DMethodAffix=$Type" + fi + case $type in Object|int|long) args="$args -KCAS -KOrdered" @@ -123,8 +129,10 @@ function generate { args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3" echo $args + out=${Qualifier}UnsafeAccessTest${Type}.java + rm -rf "$out" java $SPP -nel -K$Qualifier -Dpackage=$package -DQualifier=$Qualifier -Dmodule=$module \ - $args < X-UnsafeAccessTest.java.template > ${Qualifier}UnsafeAccessTest${Type}.java + $args -iX-UnsafeAccessTest.java.template -o$out done } From 7d6d6613287e758a9245a1c0b3de0130e90c292e Mon Sep 17 00:00:00 2001 From: Wang Haomin Date: Fri, 15 Feb 2019 04:12:18 -0500 Subject: [PATCH 086/101] 8219074: [TESTBUG] runtime/containers/docker/TestCPUAwareness.java typo of printing parameters (period should be shares) Reviewed-by: iignatyev, dholmes --- .../jtreg/runtime/containers/docker/TestCPUAwareness.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/runtime/containers/docker/TestCPUAwareness.java b/test/hotspot/jtreg/runtime/containers/docker/TestCPUAwareness.java index 340772f8371..80667128c96 100644 --- a/test/hotspot/jtreg/runtime/containers/docker/TestCPUAwareness.java +++ b/test/hotspot/jtreg/runtime/containers/docker/TestCPUAwareness.java @@ -175,7 +175,7 @@ public class TestCPUAwareness { System.out.println("cpuset = " + cpuset); System.out.println("quota = " + quota); System.out.println("period = " + period); - System.out.println("shares = " + period); + System.out.println("shares = " + shares); System.out.println("usePreferContainerQuotaForCPUCount = " + usePreferContainerQuotaForCPUCount); System.out.println("expectedAPC = " + expectedAPC); From 0e29b78bd1bcb0a29e9ee0ce5cd6c96f1e042b39 Mon Sep 17 00:00:00 2001 From: Patric Hedlin Date: Thu, 14 Feb 2019 14:59:17 +0100 Subject: [PATCH 087/101] 8214947: Assertion error in test: StringCompressInflateTest Reviewed-by: kvn, neliasso --- .../compiler/replacements/test/StringCompressInflateTest.java | 2 +- test/hotspot/jtreg/ProblemList-graal.txt | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.test/src/org/graalvm/compiler/replacements/test/StringCompressInflateTest.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.test/src/org/graalvm/compiler/replacements/test/StringCompressInflateTest.java index 163e3ef26df..4cd9a2fe49c 100644 --- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.test/src/org/graalvm/compiler/replacements/test/StringCompressInflateTest.java +++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.test/src/org/graalvm/compiler/replacements/test/StringCompressInflateTest.java @@ -299,7 +299,7 @@ public final class StringCompressInflateTest extends MethodSubstitutionTest { TestMethods(String testmname, Class javaclass, Class intrinsicClass, String javamname, Class... params) { javamethod = getResolvedJavaMethod(javaclass, javamname, params); testmethod = getResolvedJavaMethod(testmname); - testgraph = testGraph(testmname, javamname); + testgraph = getReplacements().getIntrinsicGraph(javamethod, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext()); assertInGraph(testgraph, intrinsicClass); assert javamethod != null; diff --git a/test/hotspot/jtreg/ProblemList-graal.txt b/test/hotspot/jtreg/ProblemList-graal.txt index 0f65b36b51f..8ac75093329 100644 --- a/test/hotspot/jtreg/ProblemList-graal.txt +++ b/test/hotspot/jtreg/ProblemList-graal.txt @@ -226,6 +226,4 @@ org.graalvm.compiler.core.test.deopt.CompiledMethodTest 8202955 org.graalvm.compiler.hotspot.test.ReservedStackAccessTest 8213567 windows-all -org.graalvm.compiler.replacements.test.StringCompressInflateTest 8214947 - org.graalvm.compiler.hotspot.test.CheckGraalIntrinsics 8218698 From 8c4106ff569afb2cfe9a6b4fe0263a96e3840d97 Mon Sep 17 00:00:00 2001 From: Gary Adams Date: Fri, 15 Feb 2019 05:32:36 -0500 Subject: [PATCH 088/101] 8219002: Some comments and error messages refer to VMDisconnectException Reviewed-by: cjplummer, sspitsyn --- .../nsk/jdi/ClassType/invokeMethod/invokemethod008.java | 6 +++--- .../nsk/jdi/ClassType/newInstance/newinstance008.java | 6 +++--- .../nsk/jdi/ThreadReference/popFrames/popframes004.java | 4 ++-- .../nsk/jdi/ThreadReference/popFrames/popframes005.java | 4 ++-- .../nsk/jdi/VirtualMachine/dispose/dispose005.java | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod008.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod008.java index b1125293910..2178bc2e0e2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod008.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod008.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2019, 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 @@ -192,11 +192,11 @@ public class invokemethod008 { try { retValue = testedClass.invokeMethod(thread, method, params, 0); if ( ((PrimitiveValue )retValue).intValue() == Consts.TEST_FAILED ) { - complain("VMDisconnectException is not thrown"); + complain("VMDisconnectedException is not thrown"); exitStatus = Consts.TEST_FAILED; } } catch(VMDisconnectedException e) { - display("!!!expected VMDisconnectException"); + display("!!!expected VMDisconnectedException"); notifyVMDisconnect(); } catch(Exception e) { complain("Unexpected " + e); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance008.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance008.java index e0a990e7ca4..cf9464af968 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance008.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance008.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2019, 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 @@ -203,11 +203,11 @@ public class newinstance008 { try { retValue = testedClass.newInstance(thread, method, params, 0); if ( ((PrimitiveValue )retValue).intValue() == Consts.TEST_FAILED ) { - complain("VMDisconnectException is not thrown"); + complain("VMDisconnectedException is not thrown"); exitStatus = Consts.TEST_FAILED; } } catch(VMDisconnectedException e) { - display("!!!expected VMDisconnectException"); + display("!!!expected VMDisconnectedException"); notifyVMDisconnect(); } catch(Exception e) { complain("Unexpected " + e); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java index ed3a048d66c..469a5a870aa 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -343,7 +343,7 @@ public class popframes004 { { // to get mainThread suspended; otherwise its end results in // no suspention for breakpointRequest2 (bug or not?), end of test, - // and VMDisconnectException + // and VMDisconnectedException thread2Ref.suspend(); log2("......eventSet.resume();"); eventSet.resume(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java index 5c471e9182b..cfc0e68b1dc 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -346,7 +346,7 @@ public class popframes005 { { // to get mainThread suspended; otherwise its end results in // no suspention for breakpointRequest2 (bug or not?), end of test, - // and VMDisconnectException + // and VMDisconnectedException thread2Ref.suspend(); log2("......eventSet.resume();"); eventSet.resume(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose005.java index 4aec3caa362..1ad0414ca8c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -79,7 +79,7 @@ import com.sun.jdi.request.*; * The debugger : * clears interruption status,
    * invokes vm.dispose() that results in
    - * VMDisconnectException in the thread2
    + * VMDisconnectedException in the thread2
    * which has been suspended after invoking "runt2"
    * but after exception it is resumed and sends interruption
    * to the main thread;
    From 68d32a9a8aaa6ce5b2b83cca167b550b1d5ea524 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Fri, 15 Feb 2019 12:09:53 +0100 Subject: [PATCH 089/101] 8217381: Incovenient errors reported when annotation processor generates source file and errors in the same round When an annotation processor reports and error, defer reporting recoverable errors from the erroneous round to the last round, to avoid reporting errors that were resolved in the erroneous round. Reviewed-by: jjg --- .../com/sun/tools/javac/api/JavacTrees.java | 2 +- .../sun/tools/javac/main/JavaCompiler.java | 6 +- .../tools/javac/processing/JavacMessager.java | 3 +- .../JavacProcessingEnvironment.java | 22 ++++--- .../sun/tools/javac/util/JCDiagnostic.java | 4 +- .../classes/com/sun/tools/javac/util/Log.java | 9 +-- .../tools/javac/6304921/TestLog.java | 2 +- .../6994946/SemanticErrorTest.2.out | 5 +- .../processing/6994946/TestProcessor.java | 10 +++- .../javac/processing/GenerateAndError.java | 57 +++++++++++++++++++ .../javac/processing/GenerateAndError.out | 3 + .../processing/GenerateAndErrorTest.java | 2 + 12 files changed, 104 insertions(+), 21 deletions(-) create mode 100644 test/langtools/tools/javac/processing/GenerateAndError.java create mode 100644 test/langtools/tools/javac/processing/GenerateAndError.out create mode 100644 test/langtools/tools/javac/processing/GenerateAndErrorTest.java diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java index b70d88f70c7..cb69e7f3862 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java @@ -1152,7 +1152,7 @@ public class JavacTrees extends DocTrees { try { switch (kind) { case ERROR: - log.error(DiagnosticFlag.MULTIPLE, pos, Errors.ProcMessager(msg.toString())); + log.error(DiagnosticFlag.API, pos, Errors.ProcMessager(msg.toString())); break; case WARNING: diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java index b6f41a4edc8..64d7ec2ddf6 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -1014,7 +1014,11 @@ public class JavaCompiler { * Parses a list of files. */ public List parseFiles(Iterable fileObjects) { - if (shouldStop(CompileState.PARSE)) + return parseFiles(fileObjects, false); + } + + public List parseFiles(Iterable fileObjects, boolean force) { + if (!force && shouldStop(CompileState.PARSE)) return List.nil(); //parse all files diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacMessager.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacMessager.java index 431df95f1b5..963e4874d86 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacMessager.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacMessager.java @@ -34,6 +34,7 @@ import com.sun.tools.javac.util.DefinedBy.Api; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.*; +import java.util.Set; import javax.lang.model.element.*; import javax.tools.JavaFileObject; import javax.tools.Diagnostic; @@ -117,7 +118,7 @@ public class JavacMessager implements Messager { switch (kind) { case ERROR: errorCount++; - log.error(DiagnosticFlag.MULTIPLE, pos, Errors.ProcMessager(msg.toString())); + log.error(DiagnosticFlag.API, pos, Errors.ProcMessager(msg.toString())); break; case WARNING: diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java index cf500cb5043..09a57b02f51 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java @@ -35,6 +35,7 @@ import java.net.URL; import java.nio.file.Path; import java.util.*; import java.util.Map.Entry; +import java.util.function.Predicate; import java.util.regex.*; import java.util.stream.Collectors; @@ -83,6 +84,7 @@ import com.sun.tools.javac.util.DefinedBy; import com.sun.tools.javac.util.DefinedBy.Api; import com.sun.tools.javac.util.Iterators; import com.sun.tools.javac.util.JCDiagnostic; +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; import com.sun.tools.javac.util.JavacMessages; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.Log; @@ -1066,7 +1068,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea prev.newRound(); this.genClassFiles = prev.genClassFiles; - List parsedFiles = compiler.parseFiles(newSourceFiles); + //parse the generated files even despite errors reported so far, to eliminate + //recoverable errors related to the type declared in the generated files: + List parsedFiles = compiler.parseFiles(newSourceFiles, true); roots = prev.roots.appendList(parsedFiles); // Check for errors after parsing @@ -1233,15 +1237,17 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea } void showDiagnostics(boolean showAll) { - Set kinds = EnumSet.allOf(JCDiagnostic.Kind.class); - if (!showAll) { - // suppress errors, which are all presumed to be transient resolve errors - kinds.remove(JCDiagnostic.Kind.ERROR); - } - deferredDiagnosticHandler.reportDeferredDiagnostics(kinds); + deferredDiagnosticHandler.reportDeferredDiagnostics(showAll ? ACCEPT_ALL + : ACCEPT_NON_RECOVERABLE); log.popDiagnosticHandler(deferredDiagnosticHandler); compiler.setDeferredDiagnosticHandler(null); } + //where: + private final Predicate ACCEPT_NON_RECOVERABLE = + d -> d.getKind() != JCDiagnostic.Kind.ERROR || + !d.isFlagSet(DiagnosticFlag.RECOVERABLE) || + d.isFlagSet(DiagnosticFlag.API); + private final Predicate ACCEPT_ALL = d -> true; /** Print info about this round. */ private void printRoundInfo(boolean lastRound) { @@ -1335,7 +1341,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea errorStatus = round.unrecoverableError(); moreToDo = moreToDo(); - round.showDiagnostics(errorStatus || showResolveErrors); + round.showDiagnostics(showResolveErrors); // Set up next round. // Copy mutable collections returned from filer. diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java index 88a13031242..8e39539e7a4 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java @@ -429,9 +429,9 @@ public class JCDiagnostic implements Diagnostic { RECOVERABLE, NON_DEFERRABLE, COMPRESSED, - /** Print multiple errors for same source locations. + /** Flag for diagnostics that were reported through API methods. */ - MULTIPLE, + API, /** Flag for not-supported-in-source-X errors. */ SOURCE_LEVEL; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java index 87908253857..e9abf65e266 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java @@ -33,6 +33,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Queue; import java.util.Set; +import java.util.function.Predicate; import javax.tools.DiagnosticListener; import javax.tools.JavaFileObject; @@ -158,14 +159,14 @@ public class Log extends AbstractLog { /** Report all deferred diagnostics. */ public void reportDeferredDiagnostics() { - reportDeferredDiagnostics(EnumSet.allOf(JCDiagnostic.Kind.class)); + reportDeferredDiagnostics(d -> true); } /** Report selected deferred diagnostics. */ - public void reportDeferredDiagnostics(Set kinds) { + public void reportDeferredDiagnostics(Predicate accepter) { JCDiagnostic d; while ((d = deferred.poll()) != null) { - if (kinds.contains(d.getKind())) + if (accepter.test(d)) prev.report(d); } deferred = null; // prevent accidental ongoing use @@ -713,7 +714,7 @@ public class Log extends AbstractLog { case ERROR: if (nerrors < MaxErrors && - (diagnostic.isFlagSet(DiagnosticFlag.MULTIPLE) || + (diagnostic.isFlagSet(DiagnosticFlag.API) || shouldReport(diagnostic))) { writeDiagnostic(diagnostic); nerrors++; diff --git a/test/langtools/tools/javac/6304921/TestLog.java b/test/langtools/tools/javac/6304921/TestLog.java index d7745a32c5d..3d88aa6fdfd 100644 --- a/test/langtools/tools/javac/6304921/TestLog.java +++ b/test/langtools/tools/javac/6304921/TestLog.java @@ -76,7 +76,7 @@ public class TestLog Set defaultErrorFlags = (Set) defaultErrorFlagsField.get(diagnosticFactory); - defaultErrorFlags.add(DiagnosticFlag.MULTIPLE); + defaultErrorFlags.add(DiagnosticFlag.API); JavacFileManager.preRegister(context); ParserFactory pfac = ParserFactory.instance(context); diff --git a/test/langtools/tools/javac/processing/6994946/SemanticErrorTest.2.out b/test/langtools/tools/javac/processing/6994946/SemanticErrorTest.2.out index 1a6bbc34707..3fe2577128d 100644 --- a/test/langtools/tools/javac/processing/6994946/SemanticErrorTest.2.out +++ b/test/langtools/tools/javac/processing/6994946/SemanticErrorTest.2.out @@ -1,3 +1,4 @@ -SemanticErrorTest.java:13:46: compiler.err.repeated.interface - compiler.err.proc.messager: Deliberate Error -2 errors +SemanticErrorTest.java:13:1: compiler.err.proc.messager: Deliberate Error on Trees +SemanticErrorTest.java:13:46: compiler.err.repeated.interface +3 errors diff --git a/test/langtools/tools/javac/processing/6994946/TestProcessor.java b/test/langtools/tools/javac/processing/6994946/TestProcessor.java index a6527a416d9..b93112f49a6 100644 --- a/test/langtools/tools/javac/processing/6994946/TestProcessor.java +++ b/test/langtools/tools/javac/processing/6994946/TestProcessor.java @@ -27,13 +27,21 @@ import javax.lang.model.*; import javax.lang.model.element.*; import static javax.tools.Diagnostic.Kind.*; +import com.sun.source.util.TreePath; +import com.sun.source.util.Trees; + public class TestProcessor extends JavacTestingAbstractProcessor { private int round = 0; public boolean process(Set annotations, RoundEnvironment roundEnv) { - if (++round == 1) + if (++round == 1) { messager.printMessage(ERROR, "Deliberate Error"); + Trees trees = Trees.instance(processingEnv); + TreePath elPath = trees.getPath(roundEnv.getRootElements().iterator().next()); + trees.printMessage(ERROR, "Deliberate Error on Trees", + elPath.getLeaf(), elPath.getCompilationUnit()); + } return false; } } diff --git a/test/langtools/tools/javac/processing/GenerateAndError.java b/test/langtools/tools/javac/processing/GenerateAndError.java new file mode 100644 index 00000000000..9b85eb4de7a --- /dev/null +++ b/test/langtools/tools/javac/processing/GenerateAndError.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8217381 + * @summary Check error are convenient when AP generates a source file and + * an error in the same round + * @library /tools/javac/lib + * @modules jdk.compiler + * @build JavacTestingAbstractProcessor GenerateAndError + * @compile/fail/ref=GenerateAndError.out -XDrawDiagnostics -processor GenerateAndError GenerateAndErrorTest.java + */ + +import java.io.IOException; +import java.io.Writer; +import java.util.*; + +import javax.annotation.processing.*; +import javax.lang.model.element.*; +import javax.tools.Diagnostic.Kind; + +public class GenerateAndError extends JavacTestingAbstractProcessor { + int round = 0; + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (round++ == 0) { + try (Writer w = processingEnv.getFiler().createSourceFile("Extra").openWriter()) { + w.write("public class Extra {}"); + } catch (IOException ex) { + throw new IllegalStateException(ex); + } + processingEnv.getMessager().printMessage(Kind.ERROR, "error"); + } + return false; + } +} diff --git a/test/langtools/tools/javac/processing/GenerateAndError.out b/test/langtools/tools/javac/processing/GenerateAndError.out new file mode 100644 index 00000000000..6ba6baebca9 --- /dev/null +++ b/test/langtools/tools/javac/processing/GenerateAndError.out @@ -0,0 +1,3 @@ +- compiler.err.proc.messager: error +GenerateAndErrorTest.java:2:60: compiler.err.cant.resolve: kindname.class, ExtraExtra, , +2 errors diff --git a/test/langtools/tools/javac/processing/GenerateAndErrorTest.java b/test/langtools/tools/javac/processing/GenerateAndErrorTest.java new file mode 100644 index 00000000000..3a0bf7faff8 --- /dev/null +++ b/test/langtools/tools/javac/processing/GenerateAndErrorTest.java @@ -0,0 +1,2 @@ +/* /nodynamiccopyright/ */ +public class GenerateAndErrorTest extends Extra implements ExtraExtra {} From 66aa45649ad36ed41c0241ded767d465248eda3c Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Fri, 15 Feb 2019 07:53:03 -0500 Subject: [PATCH 090/101] 8079353: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java failed on Windows when getting disjoint instead of zero based coops On Windows, don't run sub-tests that can be affected by ASLR. Reviewed-by: coleenp, mseledtsov --- test/hotspot/jtreg/ProblemList.txt | 1 - .../CompressedOops/UseCompressedOops.java | 22 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index b020d81f30c..a93dd097821 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -82,7 +82,6 @@ gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java 8193639 solaris-all runtime/handshake/HandshakeWalkSuspendExitTest.java 8214174 generic-all runtime/SharedArchiveFile/SASymbolTableTest.java 8193639 solaris-all -runtime/CompressedOops/UseCompressedOops.java 8079353 windows-all ############################################################################# diff --git a/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java b/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java index 6033d7352ff..b47674fa13b 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -45,7 +45,9 @@ public class UseCompressedOops { public static void main(String[] args) throws Exception { testCompressedOopsModesGCs(); - testCompressedOopsModesGCs("-XX:+UseLargePages"); + if (!Platform.isOSX() && !Platform.isAix()) { + testCompressedOopsModesGCs("-XX:+UseLargePages"); + } } public static void testCompressedOopsModesGCs(String... flags) throws Exception { @@ -73,7 +75,7 @@ public class UseCompressedOops { Collections.addAll(args, flags2); if (Platform.is64bit()) { - // Explicitly turn of compressed oops + // Explicitly turn off compressed oops testCompressedOops(args, "-XX:-UseCompressedOops", "-Xmx32m") .shouldNotContain("Compressed Oops") .shouldHaveExitValue(0); @@ -88,11 +90,13 @@ public class UseCompressedOops { .shouldContain("Compressed Oops mode") .shouldHaveExitValue(0); - // Skip the following three test cases if we're on OSX or Solaris. + // Skip the following seven test cases if we're on OSX, Windows, or Solaris. // - // OSX doesn't seem to care about HeapBaseMinAddress and Solaris - // puts the heap way up, forcing different behaviour. - if (!Platform.isOSX() && !Platform.isSolaris()) { + // OSX doesn't seem to care about HeapBaseMinAddress. Windows memory + // locations are affected by ASLR. Solaris puts the heap way up, + // forcing different behaviour. + if (!Platform.isOSX() && !Platform.isWindows() && !Platform.isSolaris()) { + // Larger than 4gb heap should result in zero based with shift 3 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx5g") .shouldContain("Zero based") @@ -179,8 +183,8 @@ public class UseCompressedOops { private static OutputAnalyzer testCompressedOops(ArrayList flags1, String... flags2) throws Exception { ArrayList args = new ArrayList<>(); - // Always run with these three: - args.add("-XX:+PrintCompressedOopsMode"); + // Always run with these two: + args.add("-Xlog:gc+heap+coops=trace"); args.add("-Xms32m"); // Add the extra flags From bec8431683a36ad552a15cd7c4d5ca48058249a7 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Fri, 15 Feb 2019 14:15:10 +0100 Subject: [PATCH 091/101] 8203469: Faster safepoints Reviewed-by: dcubed, pchilanomate, dholmes, acorn, coleenp, eosterlund --- src/hotspot/share/code/dependencyContext.hpp | 2 +- .../recorder/repository/jfrEmergencyDump.cpp | 4 - .../stacktrace/jfrStackTraceRepository.cpp | 5 +- src/hotspot/share/runtime/handshake.cpp | 12 +- .../share/runtime/interfaceSupport.inline.hpp | 22 +- src/hotspot/share/runtime/mutex.cpp | 7 +- src/hotspot/share/runtime/mutex.hpp | 5 +- src/hotspot/share/runtime/mutexLocker.cpp | 3 - src/hotspot/share/runtime/mutexLocker.hpp | 1 - src/hotspot/share/runtime/safepoint.cpp | 1027 ++++++++--------- src/hotspot/share/runtime/safepoint.hpp | 168 ++- .../share/runtime/safepointMechanism.cpp | 3 + .../share/runtime/safepointMechanism.hpp | 3 - .../runtime/safepointMechanism.inline.hpp | 16 +- src/hotspot/share/runtime/thread.hpp | 16 +- src/hotspot/share/runtime/vmThread.cpp | 2 + src/hotspot/share/services/runtimeService.cpp | 50 +- src/hotspot/share/services/runtimeService.hpp | 8 +- .../jtreg/runtime/logging/SafepointTest.java | 5 +- 19 files changed, 647 insertions(+), 712 deletions(-) diff --git a/src/hotspot/share/code/dependencyContext.hpp b/src/hotspot/share/code/dependencyContext.hpp index 76fa92dd832..771957e32c2 100644 --- a/src/hotspot/share/code/dependencyContext.hpp +++ b/src/hotspot/share/code/dependencyContext.hpp @@ -107,7 +107,7 @@ class DependencyContext : public StackObj { _safepoint_counter(SafepointSynchronize::safepoint_counter()) {} ~DependencyContext() { - assert(_safepoint_counter == SafepointSynchronize::safepoint_counter(), "safepoint happened"); + assert(SafepointSynchronize::is_same_safepoint(_safepoint_counter), "must be the same safepoint"); } #else DependencyContext(nmethodBucket* volatile* bucket_addr, volatile uint64_t* last_cleanup_addr) diff --git a/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp b/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp index 2b0948a5a23..147437e25e7 100644 --- a/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp +++ b/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp @@ -82,10 +82,6 @@ static void prepare_for_emergency_dump(Thread* thread) { Heap_lock->unlock(); } - if (Safepoint_lock->owned_by_self()) { - Safepoint_lock->unlock(); - } - if (VMOperationQueue_lock->owned_by_self()) { VMOperationQueue_lock->unlock(); } diff --git a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp index 7600e68e604..e9770a2775d 100644 --- a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp +++ b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, 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 @@ -383,8 +383,7 @@ void JfrStackTrace::resolve_linenos() { } bool JfrStackTrace::record_safe(JavaThread* thread, int skip, bool leakp /* false */) { - assert(SafepointSynchronize::safepoint_safe(thread, thread->thread_state()) - || thread == Thread::current(), "Thread stack needs to be walkable"); + assert(thread == Thread::current(), "Thread stack needs to be walkable"); vframeStream vfs(thread); u4 count = 0; _reached_root = true; diff --git a/src/hotspot/share/runtime/handshake.cpp b/src/hotspot/share/runtime/handshake.cpp index d22f169a81a..0d925c8c8b5 100644 --- a/src/hotspot/share/runtime/handshake.cpp +++ b/src/hotspot/share/runtime/handshake.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, 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 @@ -303,13 +303,9 @@ void HandshakeState::process_self_inner(JavaThread* thread) { } bool HandshakeState::vmthread_can_process_handshake(JavaThread* target) { - // SafepointSynchronize::safepoint_safe() does not consider an externally - // suspended thread to be safe. However, this function must be called with - // the Threads_lock held so an externally suspended thread cannot be - // resumed thus it is safe. - assert(Threads_lock->owned_by_self(), "Not holding Threads_lock."); - return SafepointSynchronize::safepoint_safe(target, target->thread_state()) || - target->is_ext_suspended() || target->is_terminated(); + // handshake_safe may only be called with polls armed. + // VM thread controls this by first claiming the handshake via claim_handshake_for_vmthread. + return SafepointSynchronize::handshake_safe(target); } static bool possibly_vmthread_can_process_handshake(JavaThread* target) { diff --git a/src/hotspot/share/runtime/interfaceSupport.inline.hpp b/src/hotspot/share/runtime/interfaceSupport.inline.hpp index ebf0998d595..a0df8244f18 100644 --- a/src/hotspot/share/runtime/interfaceSupport.inline.hpp +++ b/src/hotspot/share/runtime/interfaceSupport.inline.hpp @@ -314,10 +314,10 @@ class ThreadBlockInVMWithDeadlockCheck : public ThreadStateTransition { // Once we are blocked vm expects stack to be walkable thread->frame_anchor()->make_walkable(thread); - thread->set_thread_state((JavaThreadState)(_thread_in_vm + 1)); - InterfaceSupport::serialize_thread_state_with_handler(thread); - - SafepointMechanism::callback_if_safepoint(thread); + // All unsafe states are treated the same by the VMThread + // so we can skip the _thread_in_vm_trans state here. Since + // we don't read poll, it's enough to order the stores. + OrderAccess::storestore(); thread->set_thread_state(_thread_blocked); @@ -325,23 +325,13 @@ class ThreadBlockInVMWithDeadlockCheck : public ThreadStateTransition { } ~ThreadBlockInVMWithDeadlockCheck() { // Change to transition state - _thread->set_thread_state((JavaThreadState)(_thread_blocked + 1)); + _thread->set_thread_state((JavaThreadState)(_thread_blocked_trans)); InterfaceSupport::serialize_thread_state_with_handler(_thread); if (SafepointMechanism::should_block(_thread)) { release_monitor(); - SafepointMechanism::callback_if_safepoint(_thread); - // The VMThread might have read that we were in a _thread_blocked state - // and proceeded to process a handshake for us. If that's the case then - // we need to block. - // By doing this we are also making the current thread process its own - // handshake if there is one pending and the VMThread didn't try to process - // it yet. This is more of a side-effect and not really necessary; the - // handshake could be processed later on. - if (_thread->has_handshake()) { - _thread->handshake_process_by_self(); - } + SafepointMechanism::block_if_requested(_thread); } _thread->set_thread_state(_thread_in_vm); diff --git a/src/hotspot/share/runtime/mutex.cpp b/src/hotspot/share/runtime/mutex.cpp index 447288bf012..f910e65a6f7 100644 --- a/src/hotspot/share/runtime/mutex.cpp +++ b/src/hotspot/share/runtime/mutex.cpp @@ -401,15 +401,10 @@ void Monitor::set_owner_implementation(Thread *new_owner) { // of m2 be less than the rank of m1. // The rank Mutex::native is an exception in that it is not subject // to the verification rules. - // Here are some further notes relating to mutex acquisition anomalies: - // . it is also ok to acquire Safepoint_lock at the very end while we - // already hold Terminator_lock - may happen because of periodic safepoints if (this->rank() != Mutex::native && this->rank() != Mutex::suspend_resume && locks != NULL && locks->rank() <= this->rank() && - !SafepointSynchronize::is_at_safepoint() && - !(this == Safepoint_lock && contains(locks, Terminator_lock) && - SafepointSynchronize::is_synchronizing())) { + !SafepointSynchronize::is_at_safepoint()) { new_owner->print_owned_locks(); fatal("acquiring lock %s/%d out of order with lock %s/%d -- " "possible deadlock", this->name(), this->rank(), diff --git a/src/hotspot/share/runtime/mutex.hpp b/src/hotspot/share/runtime/mutex.hpp index 17f9e01879d..932249ec538 100644 --- a/src/hotspot/share/runtime/mutex.hpp +++ b/src/hotspot/share/runtime/mutex.hpp @@ -56,10 +56,7 @@ class Monitor : public CHeapObj { // (except for "event" and "access") for the deadlock detection to work correctly. // The rank native is only for use in Mutex's created by JVM_RawMonitorCreate, // which being external to the VM are not subject to deadlock detection. - // The rank safepoint is used only for synchronization in reaching a - // safepoint and leaving a safepoint. It is only used for the Safepoint_lock - // currently. While at a safepoint no mutexes of rank safepoint are held - // by any thread. + // While at a safepoint no mutexes of rank safepoint are held by any thread. // The rank named "leaf" is probably historical (and should // be changed) -- mutexes of this rank aren't really leaf mutexes // at all. diff --git a/src/hotspot/share/runtime/mutexLocker.cpp b/src/hotspot/share/runtime/mutexLocker.cpp index b02c331a7b8..f2a4174c71c 100644 --- a/src/hotspot/share/runtime/mutexLocker.cpp +++ b/src/hotspot/share/runtime/mutexLocker.cpp @@ -72,7 +72,6 @@ Mutex* TouchedMethodLog_lock = NULL; Mutex* RetData_lock = NULL; Monitor* VMOperationQueue_lock = NULL; Monitor* VMOperationRequest_lock = NULL; -Monitor* Safepoint_lock = NULL; Monitor* SerializePage_lock = NULL; Monitor* Threads_lock = NULL; Mutex* NonJavaThreadsList_lock = NULL; @@ -275,8 +274,6 @@ void mutex_init() { // CMS_bitMap_lock leaf 1 // CMS_freeList_lock leaf 2 - def(Safepoint_lock , PaddedMonitor, safepoint, true, Monitor::_safepoint_check_sometimes); // locks SnippetCache_lock/Threads_lock - def(Threads_lock , PaddedMonitor, barrier, true, Monitor::_safepoint_check_sometimes); def(NonJavaThreadsList_lock , PaddedMutex, leaf, true, Monitor::_safepoint_check_never); diff --git a/src/hotspot/share/runtime/mutexLocker.hpp b/src/hotspot/share/runtime/mutexLocker.hpp index 21eaa1c7823..4809f2cb1fc 100644 --- a/src/hotspot/share/runtime/mutexLocker.hpp +++ b/src/hotspot/share/runtime/mutexLocker.hpp @@ -68,7 +68,6 @@ extern Mutex* DerivedPointerTableGC_lock; // a lock to protect the derive extern Monitor* CGCPhaseManager_lock; // a lock to protect a concurrent GC's phase management extern Monitor* VMOperationQueue_lock; // a lock on queue of vm_operations waiting to execute extern Monitor* VMOperationRequest_lock; // a lock on Threads waiting for a vm_operation to terminate -extern Monitor* Safepoint_lock; // a lock used by the safepoint abstraction extern Monitor* Threads_lock; // a lock on the Threads table of active Java threads // (also used by Safepoints too to block threads creation/destruction) extern Mutex* NonJavaThreadsList_lock; // a lock on the NonJavaThreads list diff --git a/src/hotspot/share/runtime/safepoint.cpp b/src/hotspot/share/runtime/safepoint.cpp index 4ea31dee8af..de5464a24e3 100644 --- a/src/hotspot/share/runtime/safepoint.cpp +++ b/src/hotspot/share/runtime/safepoint.cpp @@ -70,70 +70,63 @@ #include "c1/c1_globals.hpp" #endif -template -static void set_current_safepoint_id(E* event, int adjustment = 0) { - assert(event != NULL, "invariant"); - event->set_safepointId(SafepointSynchronize::safepoint_counter() + adjustment); -} - -static void post_safepoint_begin_event(EventSafepointBegin* event, +static void post_safepoint_begin_event(EventSafepointBegin& event, + uint64_t safepoint_id, int thread_count, int critical_thread_count) { - assert(event != NULL, "invariant"); - assert(event->should_commit(), "invariant"); - set_current_safepoint_id(event); - event->set_totalThreadCount(thread_count); - event->set_jniCriticalThreadCount(critical_thread_count); - event->commit(); + if (event.should_commit()) { + event.set_safepointId(safepoint_id); + event.set_totalThreadCount(thread_count); + event.set_jniCriticalThreadCount(critical_thread_count); + event.commit(); + } } -static void post_safepoint_cleanup_event(EventSafepointCleanup* event) { - assert(event != NULL, "invariant"); - assert(event->should_commit(), "invariant"); - set_current_safepoint_id(event); - event->commit(); +static void post_safepoint_cleanup_event(EventSafepointCleanup& event, uint64_t safepoint_id) { + if (event.should_commit()) { + event.set_safepointId(safepoint_id); + event.commit(); + } } -static void post_safepoint_synchronize_event(EventSafepointStateSynchronization* event, +static void post_safepoint_synchronize_event(EventSafepointStateSynchronization& event, + uint64_t safepoint_id, int initial_number_of_threads, int threads_waiting_to_block, - unsigned int iterations) { - assert(event != NULL, "invariant"); - if (event->should_commit()) { - // Group this event together with the ones committed after the counter is increased - set_current_safepoint_id(event, 1); - event->set_initialThreadCount(initial_number_of_threads); - event->set_runningThreadCount(threads_waiting_to_block); - event->set_iterations(iterations); - event->commit(); + uint64_t iterations) { + if (event.should_commit()) { + event.set_safepointId(safepoint_id); + event.set_initialThreadCount(initial_number_of_threads); + event.set_runningThreadCount(threads_waiting_to_block); + event.set_iterations(iterations); + event.commit(); } } -static void post_safepoint_wait_blocked_event(EventSafepointWaitBlocked* event, +static void post_safepoint_wait_blocked_event(EventSafepointWaitBlocked& event, + uint64_t safepoint_id, int initial_threads_waiting_to_block) { - assert(event != NULL, "invariant"); - assert(event->should_commit(), "invariant"); - set_current_safepoint_id(event); - event->set_runningThreadCount(initial_threads_waiting_to_block); - event->commit(); -} - -static void post_safepoint_cleanup_task_event(EventSafepointCleanupTask* event, - const char* name) { - assert(event != NULL, "invariant"); - if (event->should_commit()) { - set_current_safepoint_id(event); - event->set_name(name); - event->commit(); + if (event.should_commit()) { + event.set_safepointId(safepoint_id); + event.set_runningThreadCount(initial_threads_waiting_to_block); + event.commit(); } } -static void post_safepoint_end_event(EventSafepointEnd* event) { - assert(event != NULL, "invariant"); - if (event->should_commit()) { - // Group this event together with the ones committed before the counter increased - set_current_safepoint_id(event, -1); - event->commit(); +static void post_safepoint_cleanup_task_event(EventSafepointCleanupTask& event, + uint64_t safepoint_id, + const char* name) { + if (event.should_commit()) { + event.set_safepointId(safepoint_id); + event.set_name(name); + event.commit(); + } +} + +static void post_safepoint_end_event(EventSafepointEnd& event, uint64_t safepoint_id) { + if (event.should_commit()) { + event.set_safepointId(safepoint_id); + event.commit(); } } @@ -141,64 +134,170 @@ static void post_safepoint_end_event(EventSafepointEnd* event) { // Implementation of Safepoint begin/end SafepointSynchronize::SynchronizeState volatile SafepointSynchronize::_state = SafepointSynchronize::_not_synchronized; -volatile int SafepointSynchronize::_waiting_to_block = 0; +int SafepointSynchronize::_waiting_to_block = 0; volatile uint64_t SafepointSynchronize::_safepoint_counter = 0; +const uint64_t SafepointSynchronize::InactiveSafepointCounter = 0; int SafepointSynchronize::_current_jni_active_count = 0; -long SafepointSynchronize::_end_of_last_safepoint = 0; -int SafepointSynchronize::_defer_thr_suspend_loop_count = 4000; -static const int safepoint_spin_before_yield = 2000; -static volatile int PageArmed = 0 ; // safepoint polling page is RO|RW vs PROT_NONE -static volatile int TryingToBlock = 0 ; // proximate value -- for advisory use only +long SafepointSynchronize::_end_of_last_safepoint = 0; + +WaitBarrier* SafepointSynchronize::_wait_barrier; + +// We need a place to save the desc since it is released before we need it. +static char stopped_description[64] = ""; +static bool _vm_is_waiting = false; + +static volatile bool PageArmed = false; // safepoint polling page is RO|RW vs PROT_NONE static bool timeout_error_printed = false; - -// Statistic related statics +// Statistic related julong SafepointSynchronize::_coalesced_vmop_count = 0; static jlong _safepoint_begin_time = 0; static float _ts_of_current_safepoint = 0.0f; static volatile int _nof_threads_hit_polling_page = 0; -// Roll all threads forward to a safepoint and suspend them all -void SafepointSynchronize::begin() { - EventSafepointBegin begin_event; - Thread* myThread = Thread::current(); - assert(myThread->is_VM_thread(), "Only VM thread may execute a safepoint"); +void SafepointSynchronize::init(Thread* vmthread) { + // WaitBarrier should never be destroyed since we will have + // threads waiting on it while exiting. + _wait_barrier = new WaitBarrier(vmthread); +} +void SafepointSynchronize::increment_jni_active_count() { + assert(Thread::current()->is_VM_thread(), "Only VM thread may increment"); + ++_current_jni_active_count; +} + +void SafepointSynchronize::decrement_waiting_to_block() { + assert(_waiting_to_block > 0, "sanity check"); + assert(Thread::current()->is_VM_thread(), "Only VM thread may decrement"); + --_waiting_to_block; +} + +static bool thread_not_running(ThreadSafepointState *cur_state) { + if (!cur_state->is_running()) { + return true; + } + cur_state->examine_state_of_thread(SafepointSynchronize::safepoint_counter()); + if (!cur_state->is_running()) { + return true; + } + LogTarget(Trace, safepoint) lt; + if (lt.is_enabled()) { + ResourceMark rm; + LogStream ls(lt); + cur_state->print_on(&ls); + } + return false; +} + +#ifdef ASSERT +static void assert_list_is_valid(const ThreadSafepointState* tss_head, int still_running) { + int a = 0; + const ThreadSafepointState *tmp_tss = tss_head; + while (tmp_tss != NULL) { + ++a; + assert(tmp_tss->is_running(), "Illegal initial state"); + tmp_tss = tmp_tss->get_next(); + } + assert(a == still_running, "Must be the same"); +} +#endif // ASSERT + +static void back_off(int iteration) { + // iteration will be 1 the first time we enter this spin back-off. + // naked_short_nanosleep takes tenths of micros which means that + // number of nanoseconds is irrelevant if it's below that. We do + // 20 1 ns sleeps with a total cost of ~1 ms, then we do 1 ms sleeps. + jlong sleep_ns = 1; + if (iteration > 20) { + sleep_ns = NANOUNITS / MILLIUNITS; // 1 ms + } + os::naked_short_nanosleep(sleep_ns); +} + +int SafepointSynchronize::synchronize_threads(jlong safepoint_limit_time, int nof_threads, int* initial_running) +{ + JavaThreadIteratorWithHandle jtiwh; + +#ifdef ASSERT + for (; JavaThread *cur = jtiwh.next(); ) { + assert(cur->safepoint_state()->is_running(), "Illegal initial state"); + } + jtiwh.rewind(); +#endif // ASSERT + + // Iterate through all threads until it has been determined how to stop them all at a safepoint. + int still_running = nof_threads; + ThreadSafepointState *tss_head = NULL; + ThreadSafepointState **p_prev = &tss_head; + for (; JavaThread *cur = jtiwh.next(); ) { + ThreadSafepointState *cur_tss = cur->safepoint_state(); + assert(cur_tss->get_next() == NULL, "Must be NULL"); + if (thread_not_running(cur_tss)) { + --still_running; + } else { + *p_prev = cur_tss; + p_prev = cur_tss->next_ptr(); + } + } + *p_prev = NULL; + + DEBUG_ONLY(assert_list_is_valid(tss_head, still_running);) + + *initial_running = still_running; if (log_is_enabled(Debug, safepoint, stats)) { - _safepoint_begin_time = os::javaTimeNanos(); - _ts_of_current_safepoint = tty->time_stamp().seconds(); - _nof_threads_hit_polling_page = 0; + begin_statistics(nof_threads, still_running); } - Universe::heap()->safepoint_synchronize_begin(); + int iterations = 1; // The first iteration is above. - // By getting the Threads_lock, we assure that no threads are about to start or - // exit. It is released again in SafepointSynchronize::end(). - Threads_lock->lock(); + while (still_running > 0) { + // Check if this has taken too long: + if (SafepointTimeout && safepoint_limit_time < os::javaTimeNanos()) { + print_safepoint_timeout(_spinning_timeout); + } + if (int(iterations) == -1) { // overflow - something is wrong. + // We can only overflow here when we are using global + // polling pages. We keep this guarantee in its original + // form so that searches of the bug database for this + // failure mode find the right bugs. + guarantee (!PageArmed, "invariant"); + } - assert( _state == _not_synchronized, "trying to safepoint synchronize with wrong state"); + p_prev = &tss_head; + ThreadSafepointState *cur_tss = tss_head; + while (cur_tss != NULL) { + assert(cur_tss->is_running(), "Illegal initial state"); + if (thread_not_running(cur_tss)) { + --still_running; + *p_prev = NULL; + ThreadSafepointState *tmp = cur_tss; + cur_tss = cur_tss->get_next(); + tmp->set_next(NULL); + } else { + *p_prev = cur_tss; + p_prev = cur_tss->next_ptr(); + cur_tss = cur_tss->get_next(); + } + } - int nof_threads = Threads::number_of_threads(); + DEBUG_ONLY(assert_list_is_valid(tss_head, still_running);) - log_debug(safepoint)("Safepoint synchronization initiated. (%d threads)", nof_threads); + if (still_running > 0) { + back_off(iterations); + } - RuntimeService::record_safepoint_begin(); + iterations++; + } - MutexLocker mu(Safepoint_lock); + assert(tss_head == NULL, "Must be empty"); - // Reset the count of active JNI critical threads - _current_jni_active_count = 0; - - // Set number of threads to wait for, before we initiate the callbacks - _waiting_to_block = nof_threads; - TryingToBlock = 0 ; - int still_running = nof_threads; - - // Save the starting time, so that it can be compared to see if this has taken - // too long to complete. - jlong safepoint_limit_time = 0; - timeout_error_printed = false; + if (log_is_enabled(Debug, safepoint, stats)) { + update_statistics_on_spin_end(); + } + return iterations; +} +void SafepointSynchronize::arm_safepoint() { // Begin the process of bringing the system to a safepoint. // Java threads can be in several different states and are // stopped by different mechanisms: @@ -216,7 +315,7 @@ void SafepointSynchronize::begin() { // memory writes are serialized with respect to each other, // the VM thread issues a memory barrier instruction. // 3. Running compiled Code - // Compiled code reads a global (Safepoint Polling) page that + // Compiled code reads the local polling page that // is set to fault if we are trying to get to a safepoint. // 4. Blocked // A thread which is blocked will not be allowed to return from the @@ -226,275 +325,154 @@ void SafepointSynchronize::begin() { // between states, the safepointing code will wait for the thread to // block itself when it attempts transitions to a new state. // - { - EventSafepointStateSynchronization sync_event; - int initial_running = 0; - _state = _synchronizing; + // We must never miss a thread with correct safepoint id, so we must make sure we arm + // the wait barrier for the next safepoint id/counter. + // Arming must be done after resetting _current_jni_active_count, _waiting_to_block. + _wait_barrier->arm(static_cast(_safepoint_counter + 1)); - if (SafepointMechanism::uses_thread_local_poll()) { - // Arming the per thread poll while having _state != _not_synchronized means safepointing - log_trace(safepoint)("Setting thread local yield flag for threads"); - OrderAccess::storestore(); // storestore, global state -> local state - for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur = jtiwh.next(); ) { - // Make sure the threads start polling, it is time to yield. - SafepointMechanism::arm_local_poll(cur); - } - } - OrderAccess::fence(); // storestore|storeload, global state -> local state + assert((_safepoint_counter & 0x1) == 0, "must be even"); + // The store to _safepoint_counter must happen after any stores in arming. + OrderAccess::release_store(&_safepoint_counter, _safepoint_counter + 1); - if (SafepointMechanism::uses_global_page_poll()) { - // Make interpreter safepoint aware - Interpreter::notice_safepoints(); + // We are synchronizing + OrderAccess::storestore(); // Ordered with _safepoint_counter + _state = _synchronizing; - // Make polling safepoint aware - guarantee (PageArmed == 0, "invariant") ; - PageArmed = 1 ; - os::make_polling_page_unreadable(); - } - - // Consider using active_processor_count() ... but that call is expensive. - int ncpus = os::processor_count() ; - unsigned int iterations = 0; - - { - JavaThreadIteratorWithHandle jtiwh; -#ifdef ASSERT - for (; JavaThread *cur = jtiwh.next(); ) { - assert(cur->safepoint_state()->is_running(), "Illegal initial state"); - // Clear the visited flag to ensure that the critical counts are collected properly. - cur->set_visited_for_critical_count(false); - } -#endif // ASSERT - - if (SafepointTimeout) - safepoint_limit_time = os::javaTimeNanos() + (jlong)SafepointTimeoutDelay * MICROUNITS; - - // Iterate through all threads until it have been determined how to stop them all at a safepoint - int steps = 0 ; - while(still_running > 0) { - jtiwh.rewind(); - for (; JavaThread *cur = jtiwh.next(); ) { - assert(!cur->is_ConcurrentGC_thread(), "A concurrent GC thread is unexpectly being suspended"); - ThreadSafepointState *cur_state = cur->safepoint_state(); - if (cur_state->is_running()) { - cur_state->examine_state_of_thread(); - if (!cur_state->is_running()) { - still_running--; - // consider adjusting steps downward: - // steps = 0 - // steps -= NNN - // steps >>= 1 - // steps = MIN(steps, 2000-100) - // if (iterations != 0) steps -= NNN - } - LogTarget(Trace, safepoint) lt; - if (lt.is_enabled()) { - ResourceMark rm; - LogStream ls(lt); - cur_state->print_on(&ls); - } - } - } - - if (iterations == 0) { - initial_running = still_running; - if (log_is_enabled(Debug, safepoint, stats)) { - begin_statistics(nof_threads, still_running); - } - } - - if (still_running > 0) { - // Check for if it takes to long - if (SafepointTimeout && safepoint_limit_time < os::javaTimeNanos()) { - print_safepoint_timeout(_spinning_timeout); - } - - // Spin to avoid context switching. - // There's a tension between allowing the mutators to run (and rendezvous) - // vs spinning. As the VM thread spins, wasting cycles, it consumes CPU that - // a mutator might otherwise use profitably to reach a safepoint. Excessive - // spinning by the VM thread on a saturated system can increase rendezvous latency. - // Blocking or yielding incur their own penalties in the form of context switching - // and the resultant loss of $ residency. - // - // Further complicating matters is that yield() does not work as naively expected - // on many platforms -- yield() does not guarantee that any other ready threads - // will run. As such we revert to naked_short_sleep() after some number of iterations. - // nakes_short_sleep() is implemented as a short unconditional sleep. - // Typical operating systems round a "short" sleep period up to 10 msecs, so sleeping - // can actually increase the time it takes the VM thread to detect that a system-wide - // stop-the-world safepoint has been reached. In a pathological scenario such as that - // described in CR6415670 the VMthread may sleep just before the mutator(s) become safe. - // In that case the mutators will be stalled waiting for the safepoint to complete and the - // the VMthread will be sleeping, waiting for the mutators to rendezvous. The VMthread - // will eventually wake up and detect that all mutators are safe, at which point - // we'll again make progress. - // - // Beware too that that the VMThread typically runs at elevated priority. - // Its default priority is higher than the default mutator priority. - // Obviously, this complicates spinning. - // - // Note too that on Windows XP SwitchThreadTo() has quite different behavior than Sleep(0). - // Sleep(0) will _not yield to lower priority threads, while SwitchThreadTo() will. - // - // See the comments in synchronizer.cpp for additional remarks on spinning. - // - // In the future we might: - // -- Modify the safepoint scheme to avoid potentially unbounded spinning. - // This is tricky as the path used by a thread exiting the JVM (say on - // on JNI call-out) simply stores into its state field. The burden - // is placed on the VM thread, which must poll (spin). - // -- Find something useful to do while spinning. If the safepoint is GC-related - // we might aggressively scan the stacks of threads that are already safe. - // -- YieldTo() any still-running mutators that are ready but OFFPROC. - // -- Check system saturation. If the system is not fully saturated then - // simply spin and avoid sleep/yield. - // -- As still-running mutators rendezvous they could unpark the sleeping - // VMthread. This works well for still-running mutators that become - // safe. The VMthread must still poll for mutators that call-out. - // -- Drive the policy on time-since-begin instead of iterations. - // -- Consider making the spin duration a function of the # of CPUs: - // Spin = (((ncpus-1) * M) + K) + F(still_running) - // Alternately, instead of counting iterations of the outer loop - // we could count the # of threads visited in the inner loop, above. - // -- On windows consider using the return value from SwitchThreadTo() - // to drive subsequent spin/SwitchThreadTo()/Sleep(N) decisions. - - if (int(iterations) == -1) { // overflow - something is wrong. - // We can only overflow here when we are using global - // polling pages. We keep this guarantee in its original - // form so that searches of the bug database for this - // failure mode find the right bugs. - guarantee (PageArmed == 0, "invariant"); - } - - // Instead of (ncpus > 1) consider either (still_running < (ncpus + EPSILON)) or - // ((still_running + _waiting_to_block - TryingToBlock)) < ncpus) - ++steps ; - if (ncpus > 1 && steps < safepoint_spin_before_yield) { - SpinPause() ; // MP-Polite spin - } else - if (steps < _defer_thr_suspend_loop_count) { - os::naked_yield() ; - } else { - os::naked_short_sleep(1); - } - - iterations ++ ; - } - assert(iterations < (uint)max_jint, "We have been iterating in the safepoint loop too long"); - } - } // ThreadsListHandle destroyed here. - assert(still_running == 0, "sanity check"); - - if (log_is_enabled(Debug, safepoint, stats)) { - update_statistics_on_spin_end(); - } - if (sync_event.should_commit()) { - post_safepoint_synchronize_event(&sync_event, initial_running, _waiting_to_block, iterations); + if (SafepointMechanism::uses_thread_local_poll()) { + // Arming the per thread poll while having _state != _not_synchronized means safepointing + log_trace(safepoint)("Setting thread local yield flag for threads"); + OrderAccess::storestore(); // storestore, global state -> local state + for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur = jtiwh.next(); ) { + // Make sure the threads start polling, it is time to yield. + SafepointMechanism::arm_local_poll(cur); } } + OrderAccess::fence(); // storestore|storeload, global state -> local state - // wait until all threads are stopped - { - EventSafepointWaitBlocked wait_blocked_event; - int initial_waiting_to_block = _waiting_to_block; + if (SafepointMechanism::uses_global_page_poll()) { + // Make interpreter safepoint aware + Interpreter::notice_safepoints(); - while (_waiting_to_block > 0) { - log_debug(safepoint)("Waiting for %d thread(s) to block", _waiting_to_block); - if (!SafepointTimeout || timeout_error_printed) { - Safepoint_lock->wait(true); // true, means with no safepoint checks - } else { - // Compute remaining time - jlong remaining_time = safepoint_limit_time - os::javaTimeNanos(); + // Make polling safepoint aware + guarantee (!PageArmed, "invariant") ; + PageArmed = true; + os::make_polling_page_unreadable(); + } +} - // If there is no remaining time, then there is an error - if (remaining_time < 0 || Safepoint_lock->wait(true, remaining_time / MICROUNITS)) { - print_safepoint_timeout(_blocking_timeout); - } - } - } - assert(_waiting_to_block == 0, "sanity check"); +// Roll all threads forward to a safepoint and suspend them all +void SafepointSynchronize::begin() { + EventSafepointBegin begin_event; + assert(Thread::current()->is_VM_thread(), "Only VM thread may execute a safepoint"); + + strncpy(stopped_description, VMThread::vm_safepoint_description(), sizeof(stopped_description) - 1); + stopped_description[sizeof(stopped_description) - 1] = '\0'; + + if (log_is_enabled(Debug, safepoint, stats)) { + _safepoint_begin_time = os::javaTimeNanos(); + _ts_of_current_safepoint = tty->time_stamp().seconds(); + _nof_threads_hit_polling_page = 0; + } + + Universe::heap()->safepoint_synchronize_begin(); + + // By getting the Threads_lock, we assure that no threads are about to start or + // exit. It is released again in SafepointSynchronize::end(). + Threads_lock->lock(); + + assert( _state == _not_synchronized, "trying to safepoint synchronize with wrong state"); + + int nof_threads = Threads::number_of_threads(); + + log_debug(safepoint)("Safepoint synchronization initiated using %s wait barrier. (%d threads)", _wait_barrier->description(), nof_threads); + + RuntimeService::record_safepoint_begin(); + + // Reset the count of active JNI critical threads + _current_jni_active_count = 0; + + // Set number of threads to wait for + _waiting_to_block = nof_threads; + + jlong safepoint_limit_time = 0; + if (SafepointTimeout) { + // Set the limit time, so that it can be compared to see if this has taken + // too long to complete. + safepoint_limit_time = os::javaTimeNanos() + (jlong)SafepointTimeoutDelay * MICROUNITS; + } + timeout_error_printed = false; + + EventSafepointStateSynchronization sync_event; + int initial_running = 0; + + // Arms the safepoint, _current_jni_active_count and _waiting_to_block must be set before. + arm_safepoint(); + + // Will spin until all threads are safe. + int iterations = synchronize_threads(safepoint_limit_time, nof_threads, &initial_running); + assert(_waiting_to_block == 0, "No thread should be running"); + + post_safepoint_synchronize_event(sync_event, _safepoint_counter, initial_running, + _waiting_to_block, iterations); + + // Keep event from now. + EventSafepointWaitBlocked wait_blocked_event; #ifndef PRODUCT - if (SafepointTimeout) { - jlong current_time = os::javaTimeNanos(); - if (safepoint_limit_time < current_time) { - log_warning(safepoint)("# SafepointSynchronize: Finished after " - INT64_FORMAT_W(6) " ms", - (int64_t)((current_time - safepoint_limit_time) / MICROUNITS + - (jlong)SafepointTimeoutDelay)); - } - } -#endif - - assert((_safepoint_counter & 0x1) == 0, "must be even"); - assert(Threads_lock->owned_by_self(), "must hold Threads_lock"); - _safepoint_counter ++; - - // Record state - _state = _synchronized; - - OrderAccess::fence(); - if (wait_blocked_event.should_commit()) { - post_safepoint_wait_blocked_event(&wait_blocked_event, initial_waiting_to_block); + if (SafepointTimeout) { + jlong current_time = os::javaTimeNanos(); + if (safepoint_limit_time < current_time) { + log_warning(safepoint)("# SafepointSynchronize: Finished after " + INT64_FORMAT_W(6) " ms", + (int64_t)((current_time - safepoint_limit_time) / MICROUNITS + + (jlong)SafepointTimeoutDelay)); } } +#endif + + assert(Threads_lock->owned_by_self(), "must hold Threads_lock"); + + // Record state + _state = _synchronized; + + OrderAccess::fence(); + + post_safepoint_wait_blocked_event(wait_blocked_event, _safepoint_counter, 0); #ifdef ASSERT // Make sure all the threads were visited. for (JavaThreadIteratorWithHandle jtiwh; JavaThread *cur = jtiwh.next(); ) { - assert(cur->was_visited_for_critical_count(), "missed a thread"); + assert(cur->was_visited_for_critical_count(_safepoint_counter), "missed a thread"); } #endif // ASSERT // Update the count of active JNI critical regions GCLocker::set_jni_lock_count(_current_jni_active_count); - log_info(safepoint)("Entering safepoint region: %s", VMThread::vm_safepoint_description()); + log_info(safepoint)("Entering safepoint region: %s", stopped_description); RuntimeService::record_safepoint_synchronized(); if (log_is_enabled(Debug, safepoint, stats)) { update_statistics_on_sync_end(os::javaTimeNanos()); } - // Call stuff that needs to be run when a safepoint is just about to be completed - { - EventSafepointCleanup cleanup_event; - do_cleanup_tasks(); - if (cleanup_event.should_commit()) { - post_safepoint_cleanup_event(&cleanup_event); - } - } + // We do the safepoint cleanup first since a GC related safepoint + // needs cleanup to be completed before running the GC op. + EventSafepointCleanup cleanup_event; + do_cleanup_tasks(); + post_safepoint_cleanup_event(cleanup_event, _safepoint_counter); if (log_is_enabled(Debug, safepoint, stats)) { // Record how much time spend on the above cleanup tasks update_statistics_on_cleanup_end(os::javaTimeNanos()); } - if (begin_event.should_commit()) { - post_safepoint_begin_event(&begin_event, nof_threads, _current_jni_active_count); - } + post_safepoint_begin_event(begin_event, _safepoint_counter, nof_threads, _current_jni_active_count); } -// Wake up all threads, so they are ready to resume execution after the safepoint -// operation has been carried out -void SafepointSynchronize::end() { - assert(Threads_lock->owned_by_self(), "must hold Threads_lock"); - assert((_safepoint_counter & 0x1) == 1, "must be odd"); - EventSafepointEnd event; - _safepoint_counter ++; - // memory fence isn't required here since an odd _safepoint_counter - // value can do no harm and a fence is issued below anyway. - - DEBUG_ONLY(Thread* myThread = Thread::current();) - assert(myThread->is_VM_thread(), "Only VM thread can execute a safepoint"); - - if (log_is_enabled(Debug, safepoint, stats)) { - end_statistics(os::javaTimeNanos()); - } - +void SafepointSynchronize::disarm_safepoint() { + uint64_t safepoint_id = _safepoint_counter; { JavaThreadIteratorWithHandle jtiwh; #ifdef ASSERT @@ -508,66 +486,74 @@ void SafepointSynchronize::end() { } #endif // ASSERT - if (PageArmed) { - assert(SafepointMechanism::uses_global_page_poll(), "sanity"); + if (SafepointMechanism::uses_global_page_poll()) { + guarantee (PageArmed, "invariant"); // Make polling safepoint aware os::make_polling_page_readable(); - PageArmed = 0 ; - } - - if (SafepointMechanism::uses_global_page_poll()) { + PageArmed = false; // Remove safepoint check from interpreter Interpreter::ignore_safepoints(); } - { - MutexLocker mu(Safepoint_lock); + OrderAccess::fence(); // keep read and write of _state from floating up + assert(_state == _synchronized, "must be synchronized before ending safepoint synchronization"); - assert(_state == _synchronized, "must be synchronized before ending safepoint synchronization"); + // Change state first to _not_synchronized. + // No threads should see _synchronized when running. + _state = _not_synchronized; - if (SafepointMechanism::uses_thread_local_poll()) { - _state = _not_synchronized; - OrderAccess::storestore(); // global state -> local state - jtiwh.rewind(); - for (; JavaThread *current = jtiwh.next(); ) { - ThreadSafepointState* cur_state = current->safepoint_state(); - cur_state->restart(); // TSS _running - SafepointMechanism::disarm_local_poll(current); - } - log_info(safepoint)("Leaving safepoint region"); - } else { - // Set to not synchronized, so the threads will not go into the signal_thread_blocked method - // when they get restarted. - _state = _not_synchronized; - OrderAccess::fence(); + // Set the next dormant (even) safepoint id. + assert((_safepoint_counter & 0x1) == 1, "must be odd"); + OrderAccess::release_store(&_safepoint_counter, _safepoint_counter + 1); - log_info(safepoint)("Leaving safepoint region"); + OrderAccess::fence(); // Keep the local state from floating up. - // Start suspended threads - jtiwh.rewind(); - for (; JavaThread *current = jtiwh.next(); ) { - ThreadSafepointState* cur_state = current->safepoint_state(); - assert(cur_state->type() != ThreadSafepointState::_running, "Thread not suspended at safepoint"); - cur_state->restart(); - assert(cur_state->is_running(), "safepoint state has not been reset"); - } - } - - RuntimeService::record_safepoint_end(); - - // Release threads lock, so threads can be created/destroyed again. - // It will also release all threads blocked in signal_thread_blocked. - Threads_lock->unlock(); + jtiwh.rewind(); + for (; JavaThread *current = jtiwh.next(); ) { + // Clear the visited flag to ensure that the critical counts are collected properly. + DEBUG_ONLY(current->reset_visited_for_critical_count(safepoint_id);) + ThreadSafepointState* cur_state = current->safepoint_state(); + assert(!cur_state->is_running(), "Thread not suspended at safepoint"); + cur_state->restart(); // TSS _running + assert(cur_state->is_running(), "safepoint state has not been reset"); + SafepointMechanism::disarm_local_poll(current); } - } // ThreadsListHandle destroyed here. + } // ~JavaThreadIteratorWithHandle + + log_info(safepoint)("Leaving safepoint region"); + + RuntimeService::record_safepoint_end(); + + // Release threads lock, so threads can be created/destroyed again. + Threads_lock->unlock(); + + // Wake threads after local state is correctly set. + _wait_barrier->disarm(); +} + +// Wake up all threads, so they are ready to resume execution after the safepoint +// operation has been carried out +void SafepointSynchronize::end() { + assert(Threads_lock->owned_by_self(), "must hold Threads_lock"); + EventSafepointEnd event; + uint64_t safepoint_id = _safepoint_counter; + assert(Thread::current()->is_VM_thread(), "Only VM thread can execute a safepoint"); + + if (log_is_enabled(Debug, safepoint, stats)) { + end_statistics(os::javaTimeNanos()); + } + + disarm_safepoint(); + + RuntimeService::record_safepoint_epilog(stopped_description); Universe::heap()->safepoint_synchronize_end(); + // record this time so VMThread can keep track how much time has elapsed // since last safepoint. _end_of_last_safepoint = os::javaTimeMillis(); - if (event.should_commit()) { - post_safepoint_end_event(&event); - } + + post_safepoint_end_event(event, safepoint_id); } bool SafepointSynchronize::is_cleanup_needed() { @@ -613,6 +599,7 @@ public: _counters(counters) {} void work(uint worker_id) { + uint64_t safepoint_id = SafepointSynchronize::safepoint_counter(); // All threads deflate monitors and mark nmethods (if necessary). Threads::possibly_parallel_threads_do(true, &_cleanup_threads_cl); @@ -621,9 +608,8 @@ public: EventSafepointCleanupTask event; TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); ObjectSynchronizer::deflate_idle_monitors(_counters); - if (event.should_commit()) { - post_safepoint_cleanup_task_event(&event, name); - } + + post_safepoint_cleanup_task_event(event, safepoint_id, name); } if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_UPDATE_INLINE_CACHES)) { @@ -631,9 +617,8 @@ public: EventSafepointCleanupTask event; TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); InlineCacheBuffer::update_inline_caches(); - if (event.should_commit()) { - post_safepoint_cleanup_task_event(&event, name); - } + + post_safepoint_cleanup_task_event(event, safepoint_id, name); } if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_COMPILATION_POLICY)) { @@ -641,9 +626,8 @@ public: EventSafepointCleanupTask event; TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); CompilationPolicy::policy()->do_safepoint_work(); - if (event.should_commit()) { - post_safepoint_cleanup_task_event(&event, name); - } + + post_safepoint_cleanup_task_event(event, safepoint_id, name); } if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_SYMBOL_TABLE_REHASH)) { @@ -652,9 +636,8 @@ public: EventSafepointCleanupTask event; TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); SymbolTable::rehash_table(); - if (event.should_commit()) { - post_safepoint_cleanup_task_event(&event, name); - } + + post_safepoint_cleanup_task_event(event, safepoint_id, name); } } @@ -664,9 +647,8 @@ public: EventSafepointCleanupTask event; TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); StringTable::rehash_table(); - if (event.should_commit()) { - post_safepoint_cleanup_task_event(&event, name); - } + + post_safepoint_cleanup_task_event(event, safepoint_id, name); } } @@ -677,9 +659,8 @@ public: EventSafepointCleanupTask event; TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); ClassLoaderDataGraph::purge_if_needed(); - if (event.should_commit()) { - post_safepoint_cleanup_task_event(&event, name); - } + + post_safepoint_cleanup_task_event(event, safepoint_id, name); } if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_SYSTEM_DICTIONARY_RESIZE)) { @@ -687,9 +668,8 @@ public: EventSafepointCleanupTask event; TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); ClassLoaderDataGraph::resize_if_needed(); - if (event.should_commit()) { - post_safepoint_cleanup_task_event(&event, name); - } + + post_safepoint_cleanup_task_event(event, safepoint_id, name); } _subtasks.all_tasks_completed(_num_workers); @@ -736,15 +716,48 @@ void SafepointSynchronize::do_cleanup_tasks() { assert(InlineCacheBuffer::is_empty(), "should have cleaned up ICBuffer"); } +// Methods for determining if a JavaThread is safepoint safe. -bool SafepointSynchronize::safepoint_safe(JavaThread *thread, JavaThreadState state) { +// False means unsafe with undetermined state. +// True means a determined state, but it may be an unsafe state. +// If called from a non-safepoint context safepoint_count MUST be InactiveSafepointCounter. +bool SafepointSynchronize::try_stable_load_state(JavaThreadState *state, JavaThread *thread, uint64_t safepoint_count) { + assert((safepoint_count != InactiveSafepointCounter && + Thread::current() == (Thread*)VMThread::vm_thread() && + SafepointSynchronize::_state != _not_synchronized) + || safepoint_count == InactiveSafepointCounter, "Invalid check"); + + // To handle the thread_blocked state on the backedge of the WaitBarrier from + // previous safepoint and reading the reset value (0/InactiveSafepointCounter) we + // re-read state after we read thread safepoint id. The JavaThread changes its + // thread state from thread_blocked before resetting safepoint id to 0. + // This guarantees the second read will be from an updated thread state. It can + // either be different state making this an unsafe state or it can see blocked + // again. When we see blocked twice with a 0 safepoint id, either: + // - It is normally blocked, e.g. on Mutex, TBIVM. + // - It was in SS:block(), looped around to SS:block() and is blocked on the WaitBarrier. + // - It was in SS:block() but now on a Mutex. + // All of these cases are safe. + + *state = thread->thread_state(); + OrderAccess::loadload(); + uint64_t sid = thread->safepoint_state()->get_safepoint_id(); // Load acquire + if (sid != InactiveSafepointCounter && sid != safepoint_count) { + // In an old safepoint, state not relevant. + return false; + } + return *state == thread->thread_state(); +} + +static bool safepoint_safe_with(JavaThread *thread, JavaThreadState state) { switch(state) { case _thread_in_native: // native threads are safe if they have no java stack or have walkable stack return !thread->has_last_Java_frame() || thread->frame_anchor()->walkable(); - // blocked threads should have already have walkable stack case _thread_blocked: + // On wait_barrier or blocked. + // Blocked threads should already have walkable stack. assert(!thread->has_last_Java_frame() || thread->frame_anchor()->walkable(), "blocked and not walkable"); return true; @@ -753,12 +766,28 @@ bool SafepointSynchronize::safepoint_safe(JavaThread *thread, JavaThreadState st } } +bool SafepointSynchronize::handshake_safe(JavaThread *thread) { + // The polls must be armed otherwise the safe state can change to unsafe at any time. + assert(SafepointMechanism::should_block(thread), "Must be armed"); + // This function must be called with the Threads_lock held so an externally + // suspended thread cannot be resumed thus it is safe. + assert(Threads_lock->owned_by_self() && Thread::current()->is_VM_thread(), + "Must hold Threads_lock and be VMThread"); + if (thread->is_ext_suspended() || thread->is_terminated()) { + return true; + } + JavaThreadState stable_state; + if (try_stable_load_state(&stable_state, thread, InactiveSafepointCounter)) { + return safepoint_safe_with(thread, stable_state); + } + return false; +} // See if the thread is running inside a lazy critical native and // update the thread critical count if so. Also set a suspend flag to // cause the native wrapper to return into the JVM to do the unlock // once the native finishes. -void SafepointSynchronize::check_for_lazy_critical_native(JavaThread *thread, JavaThreadState state) { +static void check_for_lazy_critical_native(JavaThread *thread, JavaThreadState state) { if (state == _thread_in_native && thread->has_last_Java_frame() && thread->frame_anchor()->walkable()) { @@ -788,12 +817,10 @@ void SafepointSynchronize::check_for_lazy_critical_native(JavaThread *thread, Ja } } - - // ------------------------------------------------------------------------------------------------------- -// Implementation of Safepoint callback point +// Implementation of Safepoint blocking point -void SafepointSynchronize::block(JavaThread *thread, bool block_in_safepoint_check) { +void SafepointSynchronize::block(JavaThread *thread) { assert(thread != NULL, "thread must be set"); assert(thread->is_Java_thread(), "not a Java thread"); @@ -813,101 +840,45 @@ void SafepointSynchronize::block(JavaThread *thread, bool block_in_safepoint_che JavaThreadState state = thread->thread_state(); thread->frame_anchor()->make_walkable(thread); + uint64_t safepoint_id = SafepointSynchronize::safepoint_counter(); // Check that we have a valid thread_state at this point switch(state) { case _thread_in_vm_trans: case _thread_in_Java: // From compiled code - - // We are highly likely to block on the Safepoint_lock. In order to avoid blocking in this case, - // we pretend we are still in the VM. - thread->set_thread_state(_thread_in_vm); - - if (is_synchronizing()) { - Atomic::inc (&TryingToBlock) ; - } - - // We will always be holding the Safepoint_lock when we are examine the state - // of a thread. Hence, the instructions between the Safepoint_lock->lock() and - // Safepoint_lock->unlock() are happening atomic with regards to the safepoint code - Safepoint_lock->lock_without_safepoint_check(); - if (is_synchronizing()) { - // Decrement the number of threads to wait for and signal vm thread - assert(_waiting_to_block > 0, "sanity check"); - _waiting_to_block--; - thread->safepoint_state()->set_has_called_back(true); - - DEBUG_ONLY(thread->set_visited_for_critical_count(true)); - if (thread->in_critical()) { - // Notice that this thread is in a critical section - increment_jni_active_count(); - } - - // Consider (_waiting_to_block < 2) to pipeline the wakeup of the VM thread - if (_waiting_to_block == 0) { - Safepoint_lock->notify_all(); - } - } - - if (block_in_safepoint_check) { - // We transition the thread to state _thread_blocked here, but - // we can't do our usual check for external suspension and then - // self-suspend after the lock_without_safepoint_check() call - // below because we are often called during transitions while - // we hold different locks. That would leave us suspended while - // holding a resource which results in deadlocks. - thread->set_thread_state(_thread_blocked); - Safepoint_lock->unlock(); - - // We now try to acquire the threads lock. Since this lock is hold by the VM thread during - // the entire safepoint, the threads will all line up here during the safepoint. - Threads_lock->lock_without_safepoint_check(); - // restore original state. This is important if the thread comes from compiled code, so it - // will continue to execute with the _thread_in_Java state. - thread->set_thread_state(state); - Threads_lock->unlock(); - } else { - // We choose not to block in this call since we would be - // caught when transitioning back anyways if the safepoint - // is still going on. - thread->set_thread_state(state); - Safepoint_lock->unlock(); - } - break; - case _thread_in_native_trans: case _thread_blocked_trans: case _thread_new_trans: - if (thread->safepoint_state()->type() == ThreadSafepointState::_call_back && - block_in_safepoint_check) { - thread->print_thread_state(); - fatal("Deadlock in safepoint code. " - "Should have called back to the VM before blocking."); - } - // We transition the thread to state _thread_blocked here, but - // we can't do our usual check for external suspension and then - // self-suspend after the lock_without_safepoint_check() call - // below because we are often called during transitions while - // we hold different locks. That would leave us suspended while - // holding a resource which results in deadlocks. + // We have no idea where the VMThread is, it might even be at next safepoint. + // So we can miss this poll, but stop at next. + + // Load dependent store, it must not pass loading of safepoint_id. + thread->safepoint_state()->set_safepoint_id(safepoint_id); // Release store + + // This part we can skip if we notice we miss or are in a future safepoint. + OrderAccess::storestore(); thread->set_thread_state(_thread_blocked); - // It is not safe to suspend a thread if we discover it is in _thread_in_native_trans. Hence, - // the safepoint code might still be waiting for it to block. We need to change the state here, - // so it can see that it is at a safepoint. + OrderAccess::fence(); // Load in wait barrier should not float up + _wait_barrier->wait(static_cast(safepoint_id)); + assert(_state != _synchronized, "Can't be"); - // Block until the safepoint operation is completed. - Threads_lock->lock_without_safepoint_check(); - - // Restore state + // If barrier is disarmed stop store from floating above loads in barrier. + OrderAccess::loadstore(); thread->set_thread_state(state); - Threads_lock->unlock(); + // Then we reset the safepoint id to inactive. + thread->safepoint_state()->reset_safepoint_id(); // Release store + + OrderAccess::fence(); + break; default: fatal("Illegal threadstate encountered: %d", state); } + guarantee(thread->safepoint_state()->get_safepoint_id() == InactiveSafepointCounter, + "The safepoint id should be set only in block path"); // Check for pending. async. exceptions or suspends - except if the // thread was blocked inside the VM. has_special_runtime_exit_condition() @@ -979,7 +950,7 @@ void SafepointSynchronize::print_safepoint_timeout(SafepointTimeoutReason reason if (cur_thread->thread_state() != _thread_blocked && ((reason == _spinning_timeout && cur_state->is_running()) || - (reason == _blocking_timeout && !cur_state->has_called_back()))) { + (reason == _blocking_timeout))) { ls.print("# "); cur_thread->print_on(&ls); ls.cr(); @@ -1001,11 +972,10 @@ void SafepointSynchronize::print_safepoint_timeout(SafepointTimeoutReason reason // ------------------------------------------------------------------------------------------------------- // Implementation of ThreadSafepointState -ThreadSafepointState::ThreadSafepointState(JavaThread *thread) { - _thread = thread; - _type = _running; - _has_called_back = false; - _at_poll_safepoint = false; +ThreadSafepointState::ThreadSafepointState(JavaThread *thread) + : _at_poll_safepoint(false), _thread(thread), _safepoint_safe(false), + _safepoint_id(SafepointSynchronize::InactiveSafepointCounter), + _orig_thread_state(_thread_uninitialized), _next(NULL) { } void ThreadSafepointState::create(JavaThread *thread) { @@ -1020,13 +990,30 @@ void ThreadSafepointState::destroy(JavaThread *thread) { } } -void ThreadSafepointState::examine_state_of_thread() { +uint64_t ThreadSafepointState::get_safepoint_id() const { + return OrderAccess::load_acquire(&_safepoint_id); +} + +void ThreadSafepointState::reset_safepoint_id() { + OrderAccess::release_store(&_safepoint_id, SafepointSynchronize::InactiveSafepointCounter); +} + +void ThreadSafepointState::set_safepoint_id(uint64_t safepoint_id) { + OrderAccess::release_store(&_safepoint_id, safepoint_id); +} + +void ThreadSafepointState::examine_state_of_thread(uint64_t safepoint_count) { assert(is_running(), "better be running or just have hit safepoint poll"); - JavaThreadState state = _thread->thread_state(); + JavaThreadState stable_state; + if (!SafepointSynchronize::try_stable_load_state(&stable_state, _thread, safepoint_count)) { + // We could not get stable state of the JavaThread. + // Consider it running and just return. + return; + } // Save the state at the start of safepoint processing. - _orig_thread_state = state; + _orig_thread_state = stable_state; // Check for a thread that is suspended. Note that thread resume tries // to grab the Threads_lock which we own here, so a thread cannot be @@ -1050,21 +1037,13 @@ void ThreadSafepointState::examine_state_of_thread() { // bool is_suspended = _thread->is_ext_suspended(); if (is_suspended) { - roll_forward(_at_safepoint); + account_safe_thread(); return; } - // Some JavaThread states have an initial safepoint state of - // running, but are actually at a safepoint. We will happily - // agree and update the safepoint state here. - if (SafepointSynchronize::safepoint_safe(_thread, state)) { - SafepointSynchronize::check_for_lazy_critical_native(_thread, state); - roll_forward(_at_safepoint); - return; - } - - if (state == _thread_in_vm) { - roll_forward(_call_back); + if (safepoint_safe_with(_thread, stable_state)) { + check_for_lazy_critical_native(_thread, stable_state); + account_safe_thread(); return; } @@ -1077,63 +1056,28 @@ void ThreadSafepointState::examine_state_of_thread() { return; } -// Returns true is thread could not be rolled forward at present position. -void ThreadSafepointState::roll_forward(suspend_type type) { - _type = type; - - switch(_type) { - case _at_safepoint: - SafepointSynchronize::signal_thread_at_safepoint(); - DEBUG_ONLY(_thread->set_visited_for_critical_count(true)); - if (_thread->in_critical()) { - // Notice that this thread is in a critical section - SafepointSynchronize::increment_jni_active_count(); - } - break; - - case _call_back: - set_has_called_back(false); - break; - - case _running: - default: - ShouldNotReachHere(); +void ThreadSafepointState::account_safe_thread() { + SafepointSynchronize::decrement_waiting_to_block(); + if (_thread->in_critical()) { + // Notice that this thread is in a critical section + SafepointSynchronize::increment_jni_active_count(); } + DEBUG_ONLY(_thread->set_visited_for_critical_count(SafepointSynchronize::safepoint_counter());) + assert(!_safepoint_safe, "Must be unsafe before safe"); + _safepoint_safe = true; } void ThreadSafepointState::restart() { - switch(type()) { - case _at_safepoint: - case _call_back: - break; - - case _running: - default: - tty->print_cr("restart thread " INTPTR_FORMAT " with state %d", - p2i(_thread), _type); - _thread->print(); - ShouldNotReachHere(); - } - _type = _running; - set_has_called_back(false); + assert(_safepoint_safe, "Must be safe before unsafe"); + _safepoint_safe = false; } - void ThreadSafepointState::print_on(outputStream *st) const { - const char *s = NULL; - - switch(_type) { - case _running : s = "_running"; break; - case _at_safepoint : s = "_at_safepoint"; break; - case _call_back : s = "_call_back"; break; - default: - ShouldNotReachHere(); - } + const char *s = _safepoint_safe ? "_at_safepoint" : "_running"; st->print_cr("Thread: " INTPTR_FORMAT - " [0x%2x] State: %s _has_called_back %d _at_poll_safepoint %d", - p2i(_thread), _thread->osthread()->thread_id(), s, _has_called_back, - _at_poll_safepoint); + " [0x%2x] State: %s _at_poll_safepoint %d", + p2i(_thread), _thread->osthread()->thread_id(), s, _at_poll_safepoint); _thread->print_thread_state_on(st); } @@ -1143,11 +1087,10 @@ void ThreadSafepointState::print_on(outputStream *st) const { // Block the thread at poll or poll return for safepoint/handshake. void ThreadSafepointState::handle_polling_page_exception() { - // Check state. block() will set thread state to thread_in_vm which will - // cause the safepoint state _type to become _call_back. - suspend_type t = type(); - assert(!SafepointMechanism::uses_global_page_poll() || t == ThreadSafepointState::_running, - "polling page exception on thread not running state: %u", uint(t)); + // If we're using a global poll, then the thread should not be + // marked as safepoint safe yet. + assert(!SafepointMechanism::uses_global_page_poll() || !_safepoint_safe, + "polling page exception on thread safepoint safe"); // Step 1: Find the nmethod from the return address address real_return_addr = thread()->saved_exception_pc(); diff --git a/src/hotspot/share/runtime/safepoint.hpp b/src/hotspot/share/runtime/safepoint.hpp index c1715ad190f..4d2bf520c63 100644 --- a/src/hotspot/share/runtime/safepoint.hpp +++ b/src/hotspot/share/runtime/safepoint.hpp @@ -26,15 +26,15 @@ #define SHARE_RUNTIME_SAFEPOINT_HPP #include "memory/allocation.hpp" -#include "runtime/mutexLocker.hpp" #include "runtime/os.hpp" -#include "utilities/globalDefinitions.hpp" +#include "runtime/thread.hpp" #include "utilities/ostream.hpp" +#include "utilities/waitBarrier.hpp" // // Safepoint synchronization //// -// The VMThread or CMS_thread uses the SafepointSynchronize::begin/end +// The VMThread uses the SafepointSynchronize::begin/end // methods to enter/exit a safepoint region. The begin method will roll // all JavaThreads forward to a safepoint. // @@ -45,9 +45,7 @@ // exit safepoint methods, when a thread is blocked/restarted. Hence, all mutex exter/ // exit points *must* be at a safepoint. - class ThreadSafepointState; -class JavaThread; // // Implements roll-forward to safepoint (safepoint synchronization) @@ -55,21 +53,10 @@ class JavaThread; class SafepointSynchronize : AllStatic { public: enum SynchronizeState { - _not_synchronized = 0, // Threads not synchronized at a safepoint - // Keep this value 0. See the comment in do_call_back() + _not_synchronized = 0, // Threads not synchronized at a safepoint. Keep this value 0. _synchronizing = 1, // Synchronizing in progress - _synchronized = 2 // All Java threads are stopped at a safepoint. Only VM thread is running - }; - - enum SafepointingThread { - _null_thread = 0, - _vm_thread = 1, - _other_thread = 2 - }; - - enum SafepointTimeoutReason { - _spinning_timeout = 0, - _blocking_timeout = 1 + _synchronized = 2 // All Java threads are running in native, blocked in OS or stopped at safepoint. + // VM thread and any NonJavaThread may be running. }; // The enums are listed in the order of the tasks when done serially. @@ -86,22 +73,33 @@ class SafepointSynchronize : AllStatic { }; private: - static volatile SynchronizeState _state; // Threads might read this flag directly, without acquiring the Threads_lock - static volatile int _waiting_to_block; // number of threads we are waiting for to block - static int _current_jni_active_count; // Counts the number of active critical natives during the safepoint - static int _defer_thr_suspend_loop_count; // Iterations before blocking VM threads + friend class SafepointMechanism; + friend class ThreadSafepointState; + friend class HandshakeState; + + enum SafepointTimeoutReason { + _spinning_timeout = 0, + _blocking_timeout = 1 + }; + + // Threads might read this flag directly, without acquiring the Threads_lock: + static volatile SynchronizeState _state; + // Number of threads we are waiting for to block: + static int _waiting_to_block; + // Counts the number of active critical natives during the safepoint: + static int _current_jni_active_count; // This counter is used for fast versions of jni_GetField. - // An even value means there is no ongoing safepoint operations. + // An even value means there are no ongoing safepoint operations. // The counter is incremented ONLY at the beginning and end of each - // safepoint. The fact that Threads_lock is held throughout each pair of - // increments (at the beginning and end of each safepoint) guarantees - // race freedom. + // safepoint. static volatile uint64_t _safepoint_counter; -private: - static long _end_of_last_safepoint; // Time of last safepoint in milliseconds - static julong _coalesced_vmop_count; // coalesced vmop count + // JavaThreads that need to block for the safepoint will stop on the + // _wait_barrier, where they can quickly be started again. + static WaitBarrier* _wait_barrier; + static long _end_of_last_safepoint; // Time of last safepoint in milliseconds + static julong _coalesced_vmop_count; // coalesced vmop count // Statistics static void begin_statistics(int nof_threads, int nof_running); @@ -114,42 +112,41 @@ private: // For debug long safepoint static void print_safepoint_timeout(SafepointTimeoutReason timeout_reason); + // Helper methods for safepoint procedure: + static void arm_safepoint(); + static int synchronize_threads(jlong safepoint_limit_time, int nof_threads, int* initial_running); + static void disarm_safepoint(); + static void increment_jni_active_count(); + static void decrement_waiting_to_block(); + + // Used in safepoint_safe to do a stable load of the thread state. + static bool try_stable_load_state(JavaThreadState *state, + JavaThread *thread, + uint64_t safepoint_count); + + // Called when a thread voluntarily blocks + static void block(JavaThread *thread); + + // Called from VMThread during handshakes. + // If true the VMThread may safely process the handshake operation for the JavaThread. + static bool handshake_safe(JavaThread *thread); + public: - // Main entry points + static void init(Thread* vmthread); - // Roll all threads forward to safepoint. Must be called by the - // VMThread or CMS_thread. + // Roll all threads forward to safepoint. Must be called by the VMThread. static void begin(); static void end(); // Start all suspended threads again... - static bool safepoint_safe(JavaThread *thread, JavaThreadState state); - - static void check_for_lazy_critical_native(JavaThread *thread, JavaThreadState state); + // The value for a not set safepoint id. + static const uint64_t InactiveSafepointCounter; // Query - inline static bool is_at_safepoint() { return _state == _synchronized; } - inline static bool is_synchronizing() { return _state == _synchronizing; } - inline static uint64_t safepoint_counter() { return _safepoint_counter; } - - inline static void increment_jni_active_count() { - assert_locked_or_safepoint(Safepoint_lock); - _current_jni_active_count++; - } - -private: - inline static bool do_call_back() { - return (_state != _not_synchronized); - } - - // Called when a thread voluntarily blocks - static void block(JavaThread *thread, bool block_in_safepoint_check = true); - - friend class SafepointMechanism; - -public: - static void signal_thread_at_safepoint() { _waiting_to_block--; } - + static bool is_at_safepoint() { return _state == _synchronized; } + static bool is_synchronizing() { return _state == _synchronizing; } + static uint64_t safepoint_counter() { return _safepoint_counter; } + static bool is_same_safepoint(uint64_t counter) { return (SafepointSynchronize::safepoint_counter() - counter) < 2; } // Exception handling for page polling static void handle_polling_page_exception(JavaThread *thread); @@ -164,13 +161,13 @@ public: static void do_cleanup_tasks(); static void print_stat_on_exit(); - inline static void inc_vmop_coalesced_count() { _coalesced_vmop_count++; } + static void inc_vmop_coalesced_count() { _coalesced_vmop_count++; } - static void set_is_at_safepoint() { _state = _synchronized; } - static void set_is_not_at_safepoint() { _state = _not_synchronized; } + static void set_is_at_safepoint() { _state = _synchronized; } + static void set_is_not_at_safepoint() { _state = _not_synchronized; } // Assembly support - static address address_of_state() { return (address)&_state; } + static address address_of_state() { return (address)&_state; } // Only used for making sure that no safepoint has happened in // JNI_FastGetField. Therefore only the low 32-bits are needed @@ -201,44 +198,43 @@ public: // State class for a thread suspended at a safepoint class ThreadSafepointState: public CHeapObj { - public: - // These states are maintained by VM thread while threads are being brought - // to a safepoint. After SafepointSynchronize::end(), they are reset to - // _running. - enum suspend_type { - _running = 0, // Thread state not yet determined (i.e., not at a safepoint yet) - _at_safepoint = 1, // Thread at a safepoint (f.ex., when blocked on a lock) - _call_back = 2 // Keep executing and wait for callback (if thread is in interpreted or vm) - }; private: - volatile bool _at_poll_safepoint; // At polling page safepoint (NOT a poll return safepoint) - // Thread has called back the safepoint code (for debugging) - bool _has_called_back; + // At polling page safepoint (NOT a poll return safepoint): + volatile bool _at_poll_safepoint; + JavaThread* _thread; + bool _safepoint_safe; + volatile uint64_t _safepoint_id; + JavaThreadState _orig_thread_state; - JavaThread * _thread; - volatile suspend_type _type; - JavaThreadState _orig_thread_state; + ThreadSafepointState* _next; + void account_safe_thread(); public: ThreadSafepointState(JavaThread *thread); - // examine/roll-forward/restart - void examine_state_of_thread(); - void roll_forward(suspend_type type); + // Linked list support: + ThreadSafepointState* get_next() const { return _next; } + void set_next(ThreadSafepointState* value) { _next = value; } + ThreadSafepointState** next_ptr() { return &_next; } + + // examine/restart + void examine_state_of_thread(uint64_t safepoint_count); void restart(); // Query JavaThread* thread() const { return _thread; } - suspend_type type() const { return _type; } - bool is_running() const { return (_type==_running); } + bool is_running() const { return !_safepoint_safe; } + + uint64_t get_safepoint_id() const; + void reset_safepoint_id(); + void set_safepoint_id(uint64_t sid); + JavaThreadState orig_thread_state() const { return _orig_thread_state; } // Support for safepoint timeout (debugging) - bool has_called_back() const { return _has_called_back; } - void set_has_called_back(bool val) { _has_called_back = val; } - bool is_at_poll_safepoint() { return _at_poll_safepoint; } - void set_at_poll_safepoint(bool val) { _at_poll_safepoint = val; } + bool is_at_poll_safepoint() { return _at_poll_safepoint; } + void set_at_poll_safepoint(bool val) { _at_poll_safepoint = val; } void handle_polling_page_exception(); diff --git a/src/hotspot/share/runtime/safepointMechanism.cpp b/src/hotspot/share/runtime/safepointMechanism.cpp index 5a21e514374..4cf957e3717 100644 --- a/src/hotspot/share/runtime/safepointMechanism.cpp +++ b/src/hotspot/share/runtime/safepointMechanism.cpp @@ -86,6 +86,9 @@ void SafepointMechanism::default_initialize() { void SafepointMechanism::block_if_requested_slow(JavaThread *thread) { // local poll already checked, if used. if (global_poll()) { + // Any load in ::block must not pass the global poll load. + // Otherwise we might load an old safepoint counter (for example). + OrderAccess::loadload(); SafepointSynchronize::block(thread); } if (uses_thread_local_poll() && thread->has_handshake()) { diff --git a/src/hotspot/share/runtime/safepointMechanism.hpp b/src/hotspot/share/runtime/safepointMechanism.hpp index 073d96f4049..6f15b9ab196 100644 --- a/src/hotspot/share/runtime/safepointMechanism.hpp +++ b/src/hotspot/share/runtime/safepointMechanism.hpp @@ -78,9 +78,6 @@ public: // Blocks a thread until safepoint/handshake is completed. static inline void block_if_requested(JavaThread* thread); - // Calls back if there is a pending safepoint but does not block for it. - static inline void callback_if_safepoint(JavaThread* thread); - // Caller is responsible for using a memory barrier if needed. static inline void arm_local_poll(JavaThread* thread); static inline void disarm_local_poll(JavaThread* thread); diff --git a/src/hotspot/share/runtime/safepointMechanism.inline.hpp b/src/hotspot/share/runtime/safepointMechanism.inline.hpp index 5ba31fe6ce9..f44fdf8ca49 100644 --- a/src/hotspot/share/runtime/safepointMechanism.inline.hpp +++ b/src/hotspot/share/runtime/safepointMechanism.inline.hpp @@ -35,7 +35,7 @@ bool SafepointMechanism::local_poll_armed(JavaThread* thread) { } bool SafepointMechanism::global_poll() { - return SafepointSynchronize::do_call_back(); + return (SafepointSynchronize::_state != SafepointSynchronize::_not_synchronized); } bool SafepointMechanism::local_poll(Thread* thread) { @@ -62,20 +62,6 @@ void SafepointMechanism::block_if_requested(JavaThread *thread) { block_if_requested_slow(thread); } -void SafepointMechanism::callback_if_safepoint(JavaThread* thread) { - if (!uses_thread_local_poll() || local_poll_armed(thread)) { - // If using thread local polls, we should not check the - // global_poll() and callback via block() if the VMThread - // has not yet armed the local poll. Otherwise, when used in - // combination with should_block(), the latter could miss - // detecting the same safepoint that this method would detect - // if only checking global polls. - if (global_poll()) { - SafepointSynchronize::block(thread, false); - } - } -} - void SafepointMechanism::arm_local_poll(JavaThread* thread) { thread->set_polling_page(poll_armed_value()); } diff --git a/src/hotspot/share/runtime/thread.hpp b/src/hotspot/share/runtime/thread.hpp index 066888a194e..12d42f6be22 100644 --- a/src/hotspot/share/runtime/thread.hpp +++ b/src/hotspot/share/runtime/thread.hpp @@ -421,11 +421,21 @@ class Thread: public ThreadShadow { #ifdef ASSERT private: - bool _visited_for_critical_count; + volatile uint64_t _visited_for_critical_count; public: - void set_visited_for_critical_count(bool z) { _visited_for_critical_count = z; } - bool was_visited_for_critical_count() const { return _visited_for_critical_count; } + void set_visited_for_critical_count(uint64_t safepoint_id) { + assert(_visited_for_critical_count == 0, "Must be reset before set"); + assert((safepoint_id & 0x1) == 1, "Must be odd"); + _visited_for_critical_count = safepoint_id; + } + void reset_visited_for_critical_count(uint64_t safepoint_id) { + assert(_visited_for_critical_count == safepoint_id, "Was not visited"); + _visited_for_critical_count = 0; + } + bool was_visited_for_critical_count(uint64_t safepoint_id) const { + return _visited_for_critical_count == safepoint_id; + } #endif public: diff --git a/src/hotspot/share/runtime/vmThread.cpp b/src/hotspot/share/runtime/vmThread.cpp index 5adc089e9a4..1dfd0a1c2f0 100644 --- a/src/hotspot/share/runtime/vmThread.cpp +++ b/src/hotspot/share/runtime/vmThread.cpp @@ -458,6 +458,8 @@ bool VMThread::no_op_safepoint_needed(bool check_time) { void VMThread::loop() { assert(_cur_vm_operation == NULL, "no current one should be executing"); + SafepointSynchronize::init(_vm_thread); + while(true) { VM_Operation* safepoint_ops = NULL; // diff --git a/src/hotspot/share/services/runtimeService.cpp b/src/hotspot/share/services/runtimeService.cpp index 30dcdf41a19..4386f940a5e 100644 --- a/src/hotspot/share/services/runtimeService.cpp +++ b/src/hotspot/share/services/runtimeService.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "classfile/classLoader.hpp" #include "logging/log.hpp" +#include "runtime/timer.hpp" #include "runtime/vm_version.hpp" #include "services/attachListener.hpp" #include "services/management.hpp" @@ -40,7 +41,9 @@ PerfCounter* RuntimeService::_sync_time_ticks = NULL; PerfCounter* RuntimeService::_total_safepoints = NULL; PerfCounter* RuntimeService::_safepoint_time_ticks = NULL; PerfCounter* RuntimeService::_application_time_ticks = NULL; -double RuntimeService::_last_safepoint_sync_time_sec = 0.0; +jlong RuntimeService::_last_safepoint_sync_time_ns = 0; +jlong RuntimeService::_last_safepoint_end_time_ns = 0; +jlong RuntimeService::_last_app_time_ns = 0; void RuntimeService::init() { @@ -89,12 +92,14 @@ void RuntimeService::record_safepoint_begin() { // Print the time interval in which the app was executing if (_app_timer.is_updated()) { - log_info(safepoint)("Application time: %3.7f seconds", last_application_time_sec()); + _last_app_time_ns = _app_timer.ticks_since_update(); + log_info(safepoint)("Application time: %3.7f seconds", TimeHelper::counter_to_seconds(_last_app_time_ns)); } // update the time stamp to begin recording safepoint time + _last_safepoint_sync_time_ns = 0; + _last_safepoint_end_time_ns = 0; _safepoint_timer.update(); - _last_safepoint_sync_time_sec = 0.0; if (UsePerfData) { _total_safepoints->inc(); if (_app_timer.is_updated()) { @@ -107,18 +112,24 @@ void RuntimeService::record_safepoint_synchronized() { if (UsePerfData) { _sync_time_ticks->inc(_safepoint_timer.ticks_since_update()); } - if (log_is_enabled(Info, safepoint)) { - _last_safepoint_sync_time_sec = last_safepoint_time_sec(); + if (log_is_enabled(Info, safepoint) || log_is_enabled(Info, safepoint, stats)) { + _last_safepoint_sync_time_ns = _safepoint_timer.ticks_since_update(); } } void RuntimeService::record_safepoint_end() { HS_PRIVATE_SAFEPOINT_END(); - // Print the time interval for which the app was stopped - // during the current safepoint operation. - log_info(safepoint)("Total time for which application threads were stopped: %3.7f seconds, Stopping threads took: %3.7f seconds", - last_safepoint_time_sec(), _last_safepoint_sync_time_sec); + // Logging of safepoint+stats=info needs _last_safepoint_end_time_ns to be set. + // Logging of safepoint=info needs _last_safepoint_end_time_ns for following log. + if (log_is_enabled(Info, safepoint) || log_is_enabled(Info, safepoint, stats)) { + _last_safepoint_end_time_ns = _safepoint_timer.ticks_since_update(); + log_info(safepoint)( + "Total time for which application threads were stopped: %3.7f seconds, " + "Stopping threads took: %3.7f seconds", + TimeHelper::counter_to_seconds(_last_safepoint_end_time_ns), + TimeHelper::counter_to_seconds(_last_safepoint_sync_time_ns)); + } // update the time stamp to begin recording app time _app_timer.update(); @@ -127,6 +138,25 @@ void RuntimeService::record_safepoint_end() { } } +void RuntimeService::record_safepoint_epilog(const char* operation_name) { + if (!log_is_enabled(Info, safepoint, stats)) { + return; + } + + log_info(safepoint, stats)( + "Safepoint \"%s\", " + "Time since last: " JLONG_FORMAT " ns; " + "Reaching safepoint: " JLONG_FORMAT " ns; " + "At safepoint: " JLONG_FORMAT " ns; " + "Total: " JLONG_FORMAT " ns", + operation_name, + _last_app_time_ns, + _last_safepoint_sync_time_ns, + _last_safepoint_end_time_ns - _last_safepoint_sync_time_ns, + _last_safepoint_end_time_ns + ); +} + void RuntimeService::record_application_start() { // update the time stamp to begin recording app time _app_timer.update(); diff --git a/src/hotspot/share/services/runtimeService.hpp b/src/hotspot/share/services/runtimeService.hpp index b18f2cc6e5d..0817fd5485d 100644 --- a/src/hotspot/share/services/runtimeService.hpp +++ b/src/hotspot/share/services/runtimeService.hpp @@ -37,7 +37,9 @@ private: static TimeStamp _safepoint_timer; static TimeStamp _app_timer; - static double _last_safepoint_sync_time_sec; + static jlong _last_safepoint_sync_time_ns; + static jlong _last_safepoint_end_time_ns; + static jlong _last_app_time_ns; public: static void init(); @@ -47,13 +49,11 @@ public: static jlong safepoint_time_ms(); static jlong application_time_ms(); - static double last_safepoint_time_sec() { return _safepoint_timer.seconds(); } - static double last_application_time_sec() { return _app_timer.seconds(); } - // callbacks static void record_safepoint_begin() NOT_MANAGEMENT_RETURN; static void record_safepoint_synchronized() NOT_MANAGEMENT_RETURN; static void record_safepoint_end() NOT_MANAGEMENT_RETURN; + static void record_safepoint_epilog(const char* operation_name) NOT_MANAGEMENT_RETURN; static void record_application_start() NOT_MANAGEMENT_RETURN; }; diff --git a/test/hotspot/jtreg/runtime/logging/SafepointTest.java b/test/hotspot/jtreg/runtime/logging/SafepointTest.java index 2509133742b..f4f36f8a256 100644 --- a/test/hotspot/jtreg/runtime/logging/SafepointTest.java +++ b/test/hotspot/jtreg/runtime/logging/SafepointTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -40,10 +40,9 @@ public class SafepointTest { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepoint=trace", InnerClass.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("Safepoint synchronization initiated. ("); + output.shouldContain("Safepoint synchronization initiated"); output.shouldContain("Entering safepoint region: "); output.shouldContain("Leaving safepoint region"); - output.shouldContain("_at_poll_safepoint"); output.shouldHaveExitValue(0); } From d869d9287f110eae4c002f97067e3036a556821c Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Fri, 15 Feb 2019 08:21:08 -0500 Subject: [PATCH 092/101] 8218851: JVM crash in custom classloader stress test, JDK 12 & 13 Handle NULL and unloaded constraint class in loader constraint table, also cope with unloaded but not cleaned out klass in loader constraint entries. Reviewed-by: hseigel, huntch, stuefe --- src/hotspot/share/classfile/loaderConstraints.cpp | 7 +++++-- src/hotspot/share/classfile/systemDictionary.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/classfile/loaderConstraints.cpp b/src/hotspot/share/classfile/loaderConstraints.cpp index fcfe4ee7102..e258f1fd1aa 100644 --- a/src/hotspot/share/classfile/loaderConstraints.cpp +++ b/src/hotspot/share/classfile/loaderConstraints.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -77,7 +77,10 @@ LoaderConstraintEntry** LoaderConstraintTable::find_loader_constraint( if (p->hash() == hash) { if (p->name() == name) { for (int i = p->num_loaders() - 1; i >= 0; i--) { - if (p->loader_data(i) == loader_data) { + if (p->loader_data(i) == loader_data && + // skip unloaded klasses + (p->klass() == NULL || + p->klass()->is_loader_alive())) { return pp; } } diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index f10309c0b68..505f5964b2a 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -2114,7 +2114,7 @@ void SystemDictionary::check_constraints(unsigned int d_hash, ss.print(" wants to load %s %s.", k->external_kind(), k->external_name()); Klass *existing_klass = constraints()->find_constrained_klass(name, class_loader); - if (existing_klass->class_loader() != class_loader()) { + if (existing_klass != NULL && existing_klass->class_loader() != class_loader()) { ss.print(" A different %s with the same name was previously loaded by %s. (%s)", existing_klass->external_kind(), existing_klass->class_loader_data()->loader_name_and_id(), From 4ac927853957fe691692137a6cabbd1b141b95d4 Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Fri, 15 Feb 2019 12:10:12 -0500 Subject: [PATCH 093/101] 8219006: AArch64: Register corruption in slow subtype check Reviewed-by: adinn --- .../cpu/aarch64/stubGenerator_aarch64.cpp | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp index 218db0d295c..14cefaff731 100644 --- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp @@ -1687,7 +1687,7 @@ class StubGenerator: public StubCodeGenerator { // Helper for generating a dynamic type check. - // Smashes rscratch1. + // Smashes rscratch1, rscratch2. void generate_type_check(Register sub_klass, Register super_check_offset, Register super_klass, @@ -1979,6 +1979,10 @@ class StubGenerator: public StubCodeGenerator { const Register dst_pos = c_rarg3; // destination position const Register length = c_rarg4; + + // Registers used as temps + const Register dst_klass = c_rarg5; + __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", name); @@ -2184,8 +2188,7 @@ class StubGenerator: public StubCodeGenerator { arraycopy_range_checks(src, src_pos, dst, dst_pos, scratch_length, r18, L_failed); - const Register rscratch2_dst_klass = rscratch2; - __ load_klass(rscratch2_dst_klass, dst); // reload + __ load_klass(dst_klass, dst); // reload // Marshal the base address arguments now, freeing registers. __ lea(from, Address(src, src_pos, Address::lsl(LogBytesPerHeapOop))); @@ -2195,24 +2198,25 @@ class StubGenerator: public StubCodeGenerator { __ movw(count, length); // length (reloaded) Register sco_temp = c_rarg3; // this register is free now assert_different_registers(from, to, count, sco_temp, - rscratch2_dst_klass, scratch_src_klass); + dst_klass, scratch_src_klass); // assert_clean_int(count, sco_temp); // Generate the type check. const int sco_offset = in_bytes(Klass::super_check_offset_offset()); - __ ldrw(sco_temp, Address(rscratch2_dst_klass, sco_offset)); - // assert_clean_int(sco_temp, r18); - generate_type_check(scratch_src_klass, sco_temp, rscratch2_dst_klass, L_plain_copy); + __ ldrw(sco_temp, Address(dst_klass, sco_offset)); + + // Smashes rscratch1, rscratch2 + generate_type_check(scratch_src_klass, sco_temp, dst_klass, L_plain_copy); // Fetch destination element klass from the ObjArrayKlass header. int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset()); - __ ldr(rscratch2_dst_klass, Address(rscratch2_dst_klass, ek_offset)); - __ ldrw(sco_temp, Address(rscratch2_dst_klass, sco_offset)); + __ ldr(dst_klass, Address(dst_klass, ek_offset)); + __ ldrw(sco_temp, Address(dst_klass, sco_offset)); // the checkcast_copy loop needs two extra arguments: assert(c_rarg3 == sco_temp, "#3 already in place"); // Set up arguments for checkcast_copy_entry. - __ mov(c_rarg4, rscratch2_dst_klass); // dst.klass.element_klass + __ mov(c_rarg4, dst_klass); // dst.klass.element_klass __ b(RuntimeAddress(checkcast_copy_entry)); } From 012c399c26278aaab22c8f779a443f5e05924af9 Mon Sep 17 00:00:00 2001 From: Doug Lea Date: Fri, 15 Feb 2019 11:18:01 -0800 Subject: [PATCH 094/101] 8195057: java/util/concurrent/CountDownLatch/Basic.java failed w/ Xcomp Reviewed-by: martin, chegar, dholmes --- .../util/concurrent/CountDownLatch/Basic.java | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/test/jdk/java/util/concurrent/CountDownLatch/Basic.java b/test/jdk/java/util/concurrent/CountDownLatch/Basic.java index 61fa4776784..bf2d9a6b0ae 100644 --- a/test/jdk/java/util/concurrent/CountDownLatch/Basic.java +++ b/test/jdk/java/util/concurrent/CountDownLatch/Basic.java @@ -25,24 +25,27 @@ * @test * @bug 6332435 * @summary Basic tests for CountDownLatch + * @library /test/lib * @author Seetharam Avadhanam, Martin Buchholz */ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; - -interface AwaiterFactory { - Awaiter getAwaiter(); -} - -abstract class Awaiter extends Thread { - private volatile Throwable result = null; - protected void result(Throwable result) { this.result = result; } - public Throwable result() { return this.result; } -} +import jdk.test.lib.Utils; public class Basic { + static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000); + + interface AwaiterFactory { + Awaiter getAwaiter(); + } + + abstract static class Awaiter extends Thread { + private volatile Throwable result = null; + protected void result(Throwable result) { this.result = result; } + public Throwable result() { return this.result; } + } private void toTheStartingGate(CountDownLatch gate) { try { @@ -78,15 +81,12 @@ public class Basic { catch (Throwable result) { result(result); }}}; } - private AwaiterFactory awaiterFactories(final CountDownLatch latch, - final CountDownLatch gate, - final int i) { - if (i == 1) - return new AwaiterFactory() { public Awaiter getAwaiter() { - return awaiter(latch, gate); }}; + AwaiterFactory awaiterFactory(CountDownLatch latch, CountDownLatch gate) { + return () -> awaiter(latch, gate); + } - return new AwaiterFactory() { public Awaiter getAwaiter() { - return awaiter(latch, gate, 10000); }}; + AwaiterFactory timedAwaiterFactory(CountDownLatch latch, CountDownLatch gate) { + return () -> awaiter(latch, gate, LONG_DELAY_MS); } //---------------------------------------------------------------- @@ -100,8 +100,8 @@ public class Basic { for (int i = 0; i < 3; i++) { CountDownLatch gate = new CountDownLatch(4); - AwaiterFactory factory1 = test.awaiterFactories(latch, gate, 1); - AwaiterFactory factory2 = test.awaiterFactories(latch, gate, 0); + AwaiterFactory factory1 = test.awaiterFactory(latch, gate); + AwaiterFactory factory2 = test.timedAwaiterFactory(latch, gate); a[count] = factory1.getAwaiter(); a[count++].start(); a[count] = factory1.getAwaiter(); a[count++].start(); a[count] = factory2.getAwaiter(); a[count++].start(); @@ -129,8 +129,8 @@ public class Basic { for (int i = 0; i < 3; i++) { CountDownLatch gate = new CountDownLatch(4); - AwaiterFactory factory1 = test.awaiterFactories(latch, gate, 1); - AwaiterFactory factory2 = test.awaiterFactories(latch, gate, 0); + AwaiterFactory factory1 = test.awaiterFactory(latch, gate); + AwaiterFactory factory2 = test.timedAwaiterFactory(latch, gate); a[count] = factory1.getAwaiter(); a[count++].start(); a[count] = factory1.getAwaiter(); a[count++].start(); a[count] = factory2.getAwaiter(); a[count++].start(); @@ -162,8 +162,8 @@ public class Basic { for (int i = 0; i < 3; i++) { CountDownLatch gate = new CountDownLatch(4); - AwaiterFactory factory1 = test.awaiterFactories(latch, gate, 1); - AwaiterFactory factory2 = test.awaiterFactories(latch, gate, 0); + AwaiterFactory factory1 = test.awaiterFactory(latch, gate); + AwaiterFactory factory2 = test.timedAwaiterFactory(latch, gate); a[count] = test.awaiter(latch, gate, timeout[i]); a[count++].start(); a[count] = factory1.getAwaiter(); a[count++].start(); a[count] = factory2.getAwaiter(); a[count++].start(); From a7ab4d7bd3110e6d41bd4c76a66628f1f3a3ad08 Mon Sep 17 00:00:00 2001 From: Doug Lea Date: Fri, 15 Feb 2019 11:18:01 -0800 Subject: [PATCH 095/101] 8215359: InnocuousForkJoinWorkerThread.setContextClassLoader needlessly throws Reviewed-by: martin, chegar, dholmes, reinhapa, alanb --- .../util/concurrent/ForkJoinWorkerThread.java | 3 +- .../concurrent/tck/ForkJoinPool9Test.java | 34 +++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java b/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java index fa47c227665..b39fc7d675a 100644 --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java @@ -236,7 +236,8 @@ public class ForkJoinWorkerThread extends Thread { @Override // paranoically public void setContextClassLoader(ClassLoader cl) { - throw new SecurityException("setContextClassLoader"); + if (cl != null && ClassLoader.getSystemClassLoader() != cl) + throw new SecurityException("setContextClassLoader"); } } } diff --git a/test/jdk/java/util/concurrent/tck/ForkJoinPool9Test.java b/test/jdk/java/util/concurrent/tck/ForkJoinPool9Test.java index b4153481d61..037b523176e 100644 --- a/test/jdk/java/util/concurrent/tck/ForkJoinPool9Test.java +++ b/test/jdk/java/util/concurrent/tck/ForkJoinPool9Test.java @@ -38,6 +38,8 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinTask; import java.util.concurrent.Future; +import java.util.concurrent.ThreadLocalRandom; +import java.util.stream.Stream; import junit.framework.Test; import junit.framework.TestSuite; @@ -67,21 +69,33 @@ public class ForkJoinPool9Test extends JSR166TestCase { .findVarHandle(Thread.class, "contextClassLoader", ClassLoader.class); ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); boolean haveSecurityManager = (System.getSecurityManager() != null); - CountDownLatch taskStarted = new CountDownLatch(1); + CountDownLatch runInCommonPoolStarted = new CountDownLatch(1); + ClassLoader classLoaderDistinctFromSystemClassLoader + = ClassLoader.getPlatformClassLoader(); + assertNotSame(classLoaderDistinctFromSystemClassLoader, + systemClassLoader); Runnable runInCommonPool = () -> { - taskStarted.countDown(); + runInCommonPoolStarted.countDown(); assertTrue(ForkJoinTask.inForkJoinPool()); - assertSame(ForkJoinPool.commonPool(), - ForkJoinTask.getPool()); - assertSame(systemClassLoader, - Thread.currentThread().getContextClassLoader()); - assertSame(systemClassLoader, - CCL.get(Thread.currentThread())); + assertSame(ForkJoinPool.commonPool(), ForkJoinTask.getPool()); + Thread currentThread = Thread.currentThread(); + + Stream.of(systemClassLoader, null).forEach(cl -> { + if (ThreadLocalRandom.current().nextBoolean()) + // should always be permitted, without effect + currentThread.setContextClassLoader(cl); + }); + + Stream.of(currentThread.getContextClassLoader(), + (ClassLoader) CCL.get(currentThread)) + .forEach(cl -> assertTrue(cl == systemClassLoader || cl == null)); + if (haveSecurityManager) assertThrows( SecurityException.class, () -> System.getProperty("foo"), - () -> Thread.currentThread().setContextClassLoader(null)); + () -> currentThread.setContextClassLoader( + classLoaderDistinctFromSystemClassLoader)); // TODO ? // if (haveSecurityManager // && Thread.currentThread().getClass().getSimpleName() @@ -91,7 +105,7 @@ public class ForkJoinPool9Test extends JSR166TestCase { Future f = ForkJoinPool.commonPool().submit(runInCommonPool); // Ensure runInCommonPool is truly running in the common pool, // by giving this thread no opportunity to "help" on get(). - await(taskStarted); + await(runInCommonPoolStarted); assertNull(f.get()); } From bb6d423ab83fbfcad2207cb057d15f7724cd9758 Mon Sep 17 00:00:00 2001 From: Doug Lea Date: Fri, 15 Feb 2019 11:18:01 -0800 Subject: [PATCH 096/101] 8215363: needless signals in ForkJoinPool Reviewed-by: martin, chegar, dholmes --- .../java/util/concurrent/ForkJoinPool.java | 111 ++++++++++-------- 1 file changed, 60 insertions(+), 51 deletions(-) diff --git a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java index 5ff7f26b6aa..ac6d253ae56 100644 --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java @@ -445,8 +445,7 @@ public class ForkJoinPool extends AbstractExecutorService { * if to its current value). This would be extremely costly. So * we relax it in several ways: (1) Producers only signal when * their queue is possibly empty at some point during a push - * operation (which requires conservatively checking size zero or - * one to cover races). (2) Other workers propagate this signal + * operation. (2) Other workers propagate this signal * when they find tasks in a queue with size greater than one. (3) * Workers only enqueue after scanning (see below) and not finding * any tasks. (4) Rather than CASing ctl to its current value in @@ -762,10 +761,8 @@ public class ForkJoinPool extends AbstractExecutorService { /** * The maximum number of top-level polls per worker before - * checking other queues, expressed as a bit shift to, in effect, - * multiply by pool size, and then use as random value mask, so - * average bound is about poolSize*(1< task) { ForkJoinTask[] a; - int s = top, d, cap, m; + int s = top, d = s - base, cap, m; ForkJoinPool p = pool; if ((a = array) != null && (cap = a.length) > 0) { QA.setRelease(a, (m = cap - 1) & s, task); top = s + 1; - if (((d = s - (int)BASE.getAcquire(this)) & ~1) == 0 && - p != null) { // size 0 or 1 - VarHandle.fullFence(); - p.signalWork(); - } - else if (d == m) + if (d == m) growArray(false); + else if (QA.getAcquire(a, m & (s - 1)) == null && p != null) { + VarHandle.fullFence(); // was empty + p.signalWork(null); + } } } @@ -863,16 +859,16 @@ public class ForkJoinPool extends AbstractExecutorService { final boolean lockedPush(ForkJoinTask task) { ForkJoinTask[] a; boolean signal = false; - int s = top, b = base, cap, d; + int s = top, d = s - base, cap, m; if ((a = array) != null && (cap = a.length) > 0) { - a[(cap - 1) & s] = task; + a[(m = (cap - 1)) & s] = task; top = s + 1; - if (b - s + cap - 1 == 0) + if (d == m) growArray(true); else { phase = 0; // full volatile unlock - if (((s - base) & ~1) == 0) // size 0 or 1 - signal = true; + if (a[m & (s - 1)] == null) + signal = true; // was empty } } return signal; @@ -1014,25 +1010,30 @@ public class ForkJoinPool extends AbstractExecutorService { * queue, up to bound n (to avoid infinite unfairness). */ final void topLevelExec(ForkJoinTask t, WorkQueue q, int n) { - if (t != null && q != null) { // hoist checks - int nstolen = 1; - for (;;) { + int nstolen = 1; + for (int j = 0;;) { + if (t != null) t.doExec(); - if (n-- < 0) - break; - else if ((t = nextLocalTask()) == null) { - if ((t = q.poll()) == null) - break; - else - ++nstolen; - } + if (j++ <= n) + t = nextLocalTask(); + else { + j = 0; + t = null; + } + if (t == null) { + if (q != null && (t = q.poll()) != null) { + ++nstolen; + j = 0; + } + else if (j != 0) + break; } - ForkJoinWorkerThread thread = owner; - nsteals += nstolen; - source = 0; - if (thread != null) - thread.afterTopLevelExec(); } + ForkJoinWorkerThread thread = owner; + nsteals += nstolen; + source = 0; + if (thread != null) + thread.afterTopLevelExec(); } /** @@ -1455,7 +1456,7 @@ public class ForkJoinPool extends AbstractExecutorService { if (!tryTerminate(false, false) && // possibly replace worker w != null && w.array != null) // avoid repeated failures - signalWork(); + signalWork(null); if (ex == null) // help clean on way out ForkJoinTask.helpExpungeStaleExceptions(); @@ -1465,8 +1466,9 @@ public class ForkJoinPool extends AbstractExecutorService { /** * Tries to create or release a worker if too few are running. + * @param q if non-null recheck if empty on CAS failure */ - final void signalWork() { + final void signalWork(WorkQueue q) { for (;;) { long c; int sp; WorkQueue[] ws; int i; WorkQueue v; if ((c = ctl) >= 0L) // enough workers @@ -1493,6 +1495,8 @@ public class ForkJoinPool extends AbstractExecutorService { LockSupport.unpark(vt); break; } + else if (q != null && q.isEmpty()) // no need to retry + break; } } } @@ -1613,19 +1617,24 @@ public class ForkJoinPool extends AbstractExecutorService { else if (rc <= 0 && (md & SHUTDOWN) != 0 && tryTerminate(false, false)) break; // quiescent shutdown - else if (rc <= 0 && pred != 0 && phase == (int)c) { - long nc = (UC_MASK & (c - TC_UNIT)) | (SP_MASK & pred); - long d = keepAlive + System.currentTimeMillis(); - LockSupport.parkUntil(this, d); - if (ctl == c && // drop on timeout if all idle - d - System.currentTimeMillis() <= TIMEOUT_SLOP && - CTL.compareAndSet(this, c, nc)) { - w.phase = QUIET; - break; + else if (w.phase < 0) { + if (rc <= 0 && pred != 0 && phase == (int)c) { + long nc = (UC_MASK & (c - TC_UNIT)) | (SP_MASK & pred); + long d = keepAlive + System.currentTimeMillis(); + LockSupport.parkUntil(this, d); + if (ctl == c && // drop on timeout if all idle + d - System.currentTimeMillis() <= TIMEOUT_SLOP && + CTL.compareAndSet(this, c, nc)) { + w.phase = QUIET; + break; + } + } + else { + LockSupport.park(this); + if (w.phase < 0) // one spurious wakeup check + LockSupport.park(this); } } - else if (w.phase < 0) - LockSupport.park(this); // OK if spuriously woken w.source = 0; // disable signal } } @@ -1651,10 +1660,10 @@ public class ForkJoinPool extends AbstractExecutorService { QA.compareAndSet(a, k, t, null)) { q.base = b; w.source = qid; - if (q.top - b > 0) - signalWork(); + if (a[(cap - 1) & b] != null) + signalWork(q); // help signal if more tasks w.topLevelExec(t, q, // random fairness bound - r & ((n << TOP_BOUND_SHIFT) - 1)); + (r | (1 << TOP_BOUND_SHIFT)) & SMASK); } } return true; @@ -1900,7 +1909,7 @@ public class ForkJoinPool extends AbstractExecutorService { r = ThreadLocalRandom.advanceProbe(r); else { if (q.lockedPush(task)) - signalWork(); + signalWork(null); return; } } From ff97b60fde407c51c3dc57f4de074820ab9b66c7 Mon Sep 17 00:00:00 2001 From: Doug Lea Date: Fri, 15 Feb 2019 11:18:01 -0800 Subject: [PATCH 097/101] 8215249: Miscellaneous changes imported from jsr166 CVS 2019-02 Reviewed-by: martin, chegar, dholmes --- .../java/util/concurrent/CyclicBarrier.java | 29 ++-- .../Collection/IteratorMicroBenchmark.java | 147 ++++++++++++------ .../util/Collection/RemoveMicroBenchmark.java | 16 +- .../concurrent/tck/CyclicBarrierTest.java | 33 ++++ 4 files changed, 155 insertions(+), 70 deletions(-) diff --git a/src/java.base/share/classes/java/util/concurrent/CyclicBarrier.java b/src/java.base/share/classes/java/util/concurrent/CyclicBarrier.java index 269bec4caf2..1e8ef5405aa 100644 --- a/src/java.base/share/classes/java/util/concurrent/CyclicBarrier.java +++ b/src/java.base/share/classes/java/util/concurrent/CyclicBarrier.java @@ -98,12 +98,11 @@ import java.util.concurrent.locks.ReentrantLock; * } * }} * - * Here, each worker thread processes a row of the matrix then waits at the - * barrier until all rows have been processed. When all rows are processed - * the supplied {@link Runnable} barrier action is executed and merges the - * rows. If the merger - * determines that a solution has been found then {@code done()} will return - * {@code true} and each worker will terminate. + * Here, each worker thread processes a row of the matrix, then waits at the + * barrier until all rows have been processed. When all rows are processed the + * supplied {@link Runnable} barrier action is executed and merges the rows. + * If the merger determines that a solution has been found then {@code done()} + * will return {@code true} and each worker will terminate. * *

    If the barrier action does not rely on the parties being suspended when * it is executed, then any of the threads in the party could execute that @@ -132,6 +131,7 @@ import java.util.concurrent.locks.ReentrantLock; * corresponding {@code await()} in other threads. * * @see CountDownLatch + * @see Phaser * * @author Doug Lea * @since 1.5 @@ -214,18 +214,17 @@ public class CyclicBarrier { int index = --count; if (index == 0) { // tripped - boolean ranAction = false; - try { - final Runnable command = barrierCommand; - if (command != null) + Runnable command = barrierCommand; + if (command != null) { + try { command.run(); - ranAction = true; - nextGeneration(); - return 0; - } finally { - if (!ranAction) + } catch (Throwable ex) { breakBarrier(); + throw ex; + } } + nextGeneration(); + return 0; } // loop until tripped, broken, interrupted, or timed out diff --git a/test/jdk/java/util/Collection/IteratorMicroBenchmark.java b/test/jdk/java/util/Collection/IteratorMicroBenchmark.java index 9020e2e33c3..72902d33ef6 100644 --- a/test/jdk/java/util/Collection/IteratorMicroBenchmark.java +++ b/test/jdk/java/util/Collection/IteratorMicroBenchmark.java @@ -69,8 +69,6 @@ import java.util.stream.Stream; * Be patient; this program runs for a very long time. * For faster runs, restrict execution using command line args. * - * This is an interface based version of ArrayList/IteratorMicroBenchmark - * * @author Martin Buchholz */ public class IteratorMicroBenchmark { @@ -115,7 +113,9 @@ public class IteratorMicroBenchmark { CountDownLatch finalized = new CountDownLatch(1); ReferenceQueue queue = new ReferenceQueue<>(); WeakReference ref = new WeakReference<>( - new Object() { protected void finalize() { finalized.countDown(); }}, + new Object() { + @SuppressWarnings("deprecation") + protected void finalize() { finalized.countDown(); }}, queue); try { for (int tries = 3; tries--> 0; ) { @@ -267,16 +267,22 @@ public class IteratorMicroBenchmark { }); } - static List makeSubList(List list) { + String goodClassName(Object x) { + return goodClassName(x.getClass()); + } + + static List makeSubList( + List elements, + UnaryOperator> copyConstructor) { + final ArrayList padded = new ArrayList<>(); final ThreadLocalRandom rnd = ThreadLocalRandom.current(); - int size = list.size(); - if (size <= 2) return list.subList(0, size); - List subList = list.subList(rnd.nextInt(0, 2), - size - rnd.nextInt(0, 2)); - List copy = new ArrayList<>(list); - subList.clear(); - subList.addAll(copy); - return subList; + final int frontPorch = rnd.nextInt(3); + final int backPorch = rnd.nextInt(3); + for (int n = frontPorch; n--> 0; ) padded.add(rnd.nextInt()); + padded.addAll(elements); + for (int n = backPorch; n--> 0; ) padded.add(rnd.nextInt()); + return copyConstructor.apply(padded) + .subList(frontPorch, frontPorch + elements.size()); } void run() throws Throwable { @@ -297,22 +303,42 @@ public class IteratorMicroBenchmark { abq.add(abq.remove()); } - ArrayList jobs = Stream.>of( - al, ad, abq, - makeSubList(new ArrayList<>(al)), - new LinkedList<>(al), - makeSubList(new LinkedList<>(al)), - new PriorityQueue<>(al), + final Integer[] array = al.toArray(new Integer[0]); + final List immutableSubList + = makeSubList(al, x -> List.of(x.toArray(new Integer[0]))); + + Stream> collections = concatStreams( + Stream.of( + // Lists and their subLists + al, + makeSubList(al, ArrayList::new), new Vector<>(al), - makeSubList(new Vector<>(al)), + makeSubList(al, Vector::new), + new LinkedList<>(al), + makeSubList(al, LinkedList::new), new CopyOnWriteArrayList<>(al), - makeSubList(new CopyOnWriteArrayList<>(al)), + makeSubList(al, CopyOnWriteArrayList::new), + + ad, + new PriorityQueue<>(al), new ConcurrentLinkedQueue<>(al), new ConcurrentLinkedDeque<>(al), + + // Blocking Queues + abq, new LinkedBlockingQueue<>(al), new LinkedBlockingDeque<>(al), new LinkedTransferQueue<>(al), - new PriorityBlockingQueue<>(al)) + new PriorityBlockingQueue<>(al), + + List.of(al.toArray(new Integer[0]))), + + // avoid UnsupportedOperationException in jdk9 and jdk10 + (goodClassName(immutableSubList).equals("RandomAccessSubList")) + ? Stream.empty() + : Stream.of(immutableSubList)); + + ArrayList jobs = collections .flatMap(x -> jobs(x)) .filter(job -> nameFilter == null || nameFilter.matcher(job.name()).find()) @@ -329,16 +355,29 @@ public class IteratorMicroBenchmark { return Stream.of(streams).flatMap(s -> s); } + boolean isMutable(Collection x) { + return !(x.getClass().getName().contains("ImmutableCollections$")); + } + Stream jobs(Collection x) { + final String klazz = goodClassName(x); return concatStreams( collectionJobs(x), + (isMutable(x)) + ? mutableCollectionJobs(x) + : Stream.empty(), + (x instanceof Deque) ? dequeJobs((Deque)x) : Stream.empty(), (x instanceof List) ? listJobs((List)x) + : Stream.empty(), + + (x instanceof List && isMutable(x)) + ? mutableListJobs((List)x) : Stream.empty()); } @@ -350,7 +389,7 @@ public class IteratorMicroBenchmark { } Stream collectionJobs(Collection x) { - final String klazz = goodClassName(x.getClass()); + final String klazz = goodClassName(x); return Stream.of( new Job(klazz + " iterate for loop") { public void work() throws Throwable { @@ -381,14 +420,6 @@ public class IteratorMicroBenchmark { sum[0] = 0; x.spliterator().forEachRemaining(n -> sum[0] += n); check.sum(sum[0]);}}}, - new Job(klazz + " removeIf") { - public void work() throws Throwable { - int[] sum = new int[1]; - for (int i = 0; i < iterations; i++) { - sum[0] = 0; - if (x.removeIf(n -> { sum[0] += n; return false; })) - throw new AssertionError(); - check.sum(sum[0]);}}}, new Job(klazz + " contains") { public void work() throws Throwable { int[] sum = new int[1]; @@ -407,14 +438,6 @@ public class IteratorMicroBenchmark { if (x.containsAll(sneakyAdderCollection)) throw new AssertionError(); check.sum(sum[0]);}}}, - new Job(klazz + " remove(Object)") { - public void work() throws Throwable { - int[] sum = new int[1]; - Object sneakyAdder = sneakyAdder(sum); - for (int i = 0; i < iterations; i++) { - sum[0] = 0; - if (x.remove(sneakyAdder)) throw new AssertionError(); - check.sum(sum[0]);}}}, new Job(klazz + " forEach") { public void work() throws Throwable { int[] sum = new int[1]; @@ -498,8 +521,29 @@ public class IteratorMicroBenchmark { check.sum(sum[0]);}}}); } + Stream mutableCollectionJobs(Collection x) { + final String klazz = goodClassName(x); + return Stream.of( + new Job(klazz + " removeIf") { + public void work() throws Throwable { + int[] sum = new int[1]; + for (int i = 0; i < iterations; i++) { + sum[0] = 0; + if (x.removeIf(n -> { sum[0] += n; return false; })) + throw new AssertionError(); + check.sum(sum[0]);}}}, + new Job(klazz + " remove(Object)") { + public void work() throws Throwable { + int[] sum = new int[1]; + Object sneakyAdder = sneakyAdder(sum); + for (int i = 0; i < iterations; i++) { + sum[0] = 0; + if (x.remove(sneakyAdder)) throw new AssertionError(); + check.sum(sum[0]);}}}); + } + Stream dequeJobs(Deque x) { - String klazz = goodClassName(x.getClass()); + final String klazz = goodClassName(x); return Stream.of( new Job(klazz + " descendingIterator() loop") { public void work() throws Throwable { @@ -519,7 +563,7 @@ public class IteratorMicroBenchmark { } Stream listJobs(List x) { - final String klazz = goodClassName(x.getClass()); + final String klazz = goodClassName(x); return Stream.of( new Job(klazz + " listIterator forward loop") { public void work() throws Throwable { @@ -555,15 +599,6 @@ public class IteratorMicroBenchmark { if (x.lastIndexOf(sneakyAdder) != -1) throw new AssertionError(); check.sum(sum[0]);}}}, - new Job(klazz + " replaceAll") { - public void work() throws Throwable { - int[] sum = new int[1]; - UnaryOperator sneakyAdder = - x -> { sum[0] += x; return x; }; - for (int i = 0; i < iterations; i++) { - sum[0] = 0; - x.replaceAll(sneakyAdder); - check.sum(sum[0]);}}}, new Job(klazz + " equals") { public void work() throws Throwable { ArrayList copy = new ArrayList<>(x); @@ -577,4 +612,18 @@ public class IteratorMicroBenchmark { if (x.hashCode() != hashCode) throw new AssertionError();}}}); } + + Stream mutableListJobs(List x) { + final String klazz = goodClassName(x); + return Stream.of( + new Job(klazz + " replaceAll") { + public void work() throws Throwable { + int[] sum = new int[1]; + UnaryOperator sneakyAdder = + x -> { sum[0] += x; return x; }; + for (int i = 0; i < iterations; i++) { + sum[0] = 0; + x.replaceAll(sneakyAdder); + check.sum(sum[0]);}}}); + } } diff --git a/test/jdk/java/util/Collection/RemoveMicroBenchmark.java b/test/jdk/java/util/Collection/RemoveMicroBenchmark.java index fedbd6f06fd..1a58022fa4d 100644 --- a/test/jdk/java/util/Collection/RemoveMicroBenchmark.java +++ b/test/jdk/java/util/Collection/RemoveMicroBenchmark.java @@ -270,6 +270,10 @@ public class RemoveMicroBenchmark { }); } + String goodClassName(Object x) { + return goodClassName(x.getClass()); + } + static List makeSubList(List list) { final ThreadLocalRandom rnd = ThreadLocalRandom.current(); int size = rnd.nextInt(4); @@ -369,7 +373,7 @@ public class RemoveMicroBenchmark { } Stream collectionJobs(Collection x) { - final String klazz = goodClassName(x.getClass()); + final String klazz = goodClassName(x); return Stream.of( new Job(klazz + " removeIf") { public void work() throws Throwable { @@ -422,7 +426,7 @@ public class RemoveMicroBenchmark { } Stream iteratorRemoveJobs(Collection x) { - final String klazz = goodClassName(x.getClass()); + final String klazz = goodClassName(x); return Stream.of( new Job(klazz + " Iterator.remove") { public void work() throws Throwable { @@ -460,7 +464,7 @@ public class RemoveMicroBenchmark { } Stream queueJobs(Queue x) { - final String klazz = goodClassName(x.getClass()); + final String klazz = goodClassName(x); return Stream.of( new Job(klazz + " poll()") { public void work() throws Throwable { @@ -474,7 +478,7 @@ public class RemoveMicroBenchmark { } Stream dequeJobs(Deque x) { - final String klazz = goodClassName(x.getClass()); + final String klazz = goodClassName(x); return Stream.of( new Job(klazz + " descendingIterator().remove") { public void work() throws Throwable { @@ -509,7 +513,7 @@ public class RemoveMicroBenchmark { } Stream blockingQueueJobs(BlockingQueue x) { - final String klazz = goodClassName(x.getClass()); + final String klazz = goodClassName(x); return Stream.of( new Job(klazz + " timed poll()") { public void work() throws Throwable { @@ -545,7 +549,7 @@ public class RemoveMicroBenchmark { } Stream blockingDequeJobs(BlockingDeque x) { - final String klazz = goodClassName(x.getClass()); + final String klazz = goodClassName(x); return Stream.of( new Job(klazz + " timed pollFirst()") { public void work() throws Throwable { diff --git a/test/jdk/java/util/concurrent/tck/CyclicBarrierTest.java b/test/jdk/java/util/concurrent/tck/CyclicBarrierTest.java index 825baf2d177..ac96e50a5b4 100644 --- a/test/jdk/java/util/concurrent/tck/CyclicBarrierTest.java +++ b/test/jdk/java/util/concurrent/tck/CyclicBarrierTest.java @@ -38,6 +38,9 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -486,4 +489,34 @@ public class CyclicBarrierTest extends JSR166TestCase { assertEquals(0, barrier.getNumberWaiting()); } } + + /** + * There can be more threads calling await() than parties, as long as each + * task only calls await once and the task count is a multiple of parties. + */ + public void testMoreTasksThanParties() throws Exception { + final ThreadLocalRandom rnd = ThreadLocalRandom.current(); + final int parties = rnd.nextInt(1, 5); + final int nTasks = rnd.nextInt(1, 5) * parties; + final AtomicInteger tripCount = new AtomicInteger(0); + final AtomicInteger awaitCount = new AtomicInteger(0); + final CyclicBarrier barrier = + new CyclicBarrier(parties, () -> tripCount.getAndIncrement()); + final ExecutorService e = Executors.newFixedThreadPool(nTasks); + final Runnable awaiter = () -> { + try { + if (ThreadLocalRandom.current().nextBoolean()) + barrier.await(); + else + barrier.await(LONG_DELAY_MS, MILLISECONDS); + awaitCount.getAndIncrement(); + } catch (Throwable fail) { threadUnexpectedException(fail); }}; + try (PoolCleaner cleaner = cleaner(e)) { + for (int i = nTasks; i--> 0; ) + e.execute(awaiter); + } + assertEquals(nTasks / parties, tripCount.get()); + assertEquals(nTasks, awaitCount.get()); + assertEquals(0, barrier.getNumberWaiting()); + } } From e4dc17c3548aa1277b82f98327742b50b8a4c28e Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Fri, 15 Feb 2019 12:33:11 -0800 Subject: [PATCH 098/101] 8218941: jdb should support a dbgtrace command that acts the same as the dbgtrace command line option Added dbgtrace command. Reviewed-by: sspitsyn, amenkov, gadams --- .../sun/tools/example/debug/tty/Commands.java | 18 +++++++++++++++++- .../com/sun/tools/example/debug/tty/Env.java | 6 +++++- .../com/sun/tools/example/debug/tty/TTY.java | 5 ++++- .../tools/example/debug/tty/TTYResources.java | 4 +++- .../tools/example/debug/tty/VMConnection.java | 15 +++++++++++++-- 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java index 5e6438d887a..d20f61a43af 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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 @@ -1128,6 +1128,22 @@ class Commands { } } + void commandDbgTrace(StringTokenizer t) { + int traceFlags; + if (t.hasMoreTokens()) { + String flagStr = t.nextToken(); + try { + traceFlags = Integer.decode(flagStr).intValue(); + } catch (NumberFormatException nfe) { + MessageOutput.println("dbgtrace command value must be an integer:", flagStr); + return; + } + } else { + traceFlags = VirtualMachine.TRACE_ALL; + } + Env.setTraceFlags(traceFlags); + } + void commandStop(StringTokenizer t) { String atIn; byte suspendPolicy = EventRequest.SUSPEND_ALL; diff --git a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Env.java b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Env.java index 1af357322a9..5df60491983 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Env.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Env.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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 @@ -64,6 +64,10 @@ class Env { } } + static void setTraceFlags(int flags) { + connection.setTraceFlags(flags); + } + static VMConnection connection() { return connection; } diff --git a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java index bfa05a2b388..822d08bab64 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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 @@ -304,6 +304,7 @@ public class TTY implements EventNotifier { {"clear", "y", "n"}, {"connectors", "y", "y"}, {"cont", "n", "n"}, + {"dbgtrace", "y", "y"}, {"disablegc", "n", "n"}, {"down", "n", "y"}, {"dump", "n", "y"}, @@ -587,6 +588,8 @@ public class TTY implements EventNotifier { evaluator.commandExclude(t); } else if (cmd.equals("read")) { readCommand(t); + } else if (cmd.equals("dbgtrace")) { + evaluator.commandDbgTrace(t); } else if (cmd.equals("help") || cmd.equals("?")) { help(); } else if (cmd.equals("version")) { diff --git a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java index 7fc73c953eb..f1be94db510 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -107,6 +107,7 @@ public class TTYResources extends java.util.ListResourceBundle { {"Current thread isnt suspended.", "Current thread isn't suspended."}, {"Current thread not set.", "Current thread not set."}, {"dbgtrace flag value must be an integer:", "dbgtrace flag value must be an integer: {0}"}, + {"dbgtrace command value must be an integer:", "dbgtrace command value must be an integer: {0}"}, {"Deferring.", "Deferring {0}.\nIt will be set after the class is loaded."}, {"End of stack.", "End of stack."}, {"Error popping frame", "Error popping frame - {0}"}, @@ -411,6 +412,7 @@ public class TTYResources extends java.util.ListResourceBundle { " -- repeat command n times\n" + "# -- discard (no-op)\n" + "help (or ?) -- list commands\n" + + "dbgtrace [flag] -- same as dbgtrace command line option" + "version -- print version information\n" + "exit (or quit) -- exit debugger\n" + "\n" + diff --git a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/VMConnection.java b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/VMConnection.java index db48b3f8357..f0f821fe891 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/VMConnection.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/VMConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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 @@ -52,7 +52,7 @@ class VMConnection { private final Connector connector; private final Map connectorArgs; - private final int traceFlags; + private int traceFlags; synchronized void notifyOutputComplete() { outputCompleteCount++; @@ -321,6 +321,17 @@ class VMConnection { this.traceFlags = traceFlags; } + public void setTraceFlags(int flags) { + this.traceFlags = flags; + /* + * If vm is not connected now, then vm.setDebugTraceMode() will + * be called when it is connected. + */ + if (vm != null) { + vm.setDebugTraceMode(flags); + } + } + synchronized VirtualMachine open() { if (connector instanceof LaunchingConnector) { vm = launchTarget(); From d6bec9017ec205fe790aaed2e4721b2f85b674f3 Mon Sep 17 00:00:00 2001 From: Martin Balao Date: Fri, 15 Feb 2019 11:46:15 -0300 Subject: [PATCH 099/101] 8219011: Implement MacroAssembler::warn method on AArch64 Reviewed-by: adinn --- src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index f24f4e46d61..c32394a95b8 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -2167,6 +2167,14 @@ void MacroAssembler::stop(const char* msg) { hlt(0); } +void MacroAssembler::warn(const char* msg) { + pusha(); + mov(c_rarg0, (address)msg); + mov(lr, CAST_FROM_FN_PTR(address, warning)); + blrt(lr, 1, 0, MacroAssembler::ret_type_void); + popa(); +} + void MacroAssembler::unimplemented(const char* what) { const char* buf = NULL; { From fcf50f8419de1b477df7a917df118c1e2823cf56 Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Sat, 16 Feb 2019 11:40:34 +0900 Subject: [PATCH 100/101] 8204551: Event descriptions are truncated in logs Reviewed-by: coleenp, coleenp --- src/hotspot/share/utilities/events.cpp | 6 ++-- src/hotspot/share/utilities/events.hpp | 39 ++++++++++++++-------- src/hotspot/share/utilities/exceptions.hpp | 4 +++ 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/hotspot/share/utilities/events.cpp b/src/hotspot/share/utilities/events.cpp index 15fef2c05e7..bdd0a7ae29d 100644 --- a/src/hotspot/share/utilities/events.cpp +++ b/src/hotspot/share/utilities/events.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -36,7 +36,7 @@ EventLog* Events::_logs = NULL; StringEventLog* Events::_messages = NULL; -StringEventLog* Events::_exceptions = NULL; +ExtendedStringEventLog* Events::_exceptions = NULL; StringEventLog* Events::_redefinitions = NULL; UnloadingEventLog* Events::_class_unloading = NULL; StringEventLog* Events::_deopt_messages = NULL; @@ -67,7 +67,7 @@ void Events::print() { void Events::init() { if (LogEvents) { _messages = new StringEventLog("Events"); - _exceptions = new StringEventLog("Internal exceptions"); + _exceptions = new ExtendedStringEventLog("Internal exceptions"); _redefinitions = new StringEventLog("Classes redefined"); _class_unloading = new UnloadingEventLog("Classes unloaded"); _deopt_messages = new StringEventLog("Deoptimization events"); diff --git a/src/hotspot/share/utilities/events.hpp b/src/hotspot/share/utilities/events.hpp index 60a66741566..e32b410f23e 100644 --- a/src/hotspot/share/utilities/events.hpp +++ b/src/hotspot/share/utilities/events.hpp @@ -135,37 +135,43 @@ template class EventLogBase : public EventLog { }; // A simple wrapper class for fixed size text messages. -class StringLogMessage : public FormatBuffer<256> { +template +class FormatStringLogMessage : public FormatBuffer { public: // Wrap this buffer in a stringStream. stringStream stream() { - return stringStream(_buf, size()); + return stringStream(this->_buf, this->size()); } }; +typedef FormatStringLogMessage<256> StringLogMessage; +typedef FormatStringLogMessage<512> ExtendedStringLogMessage; // A simple ring buffer of fixed size text messages. -class StringEventLog : public EventLogBase { +template +class FormatStringEventLog : public EventLogBase< FormatStringLogMessage > { public: - StringEventLog(const char* name, int count = LogEventsBufferEntries) : EventLogBase(name, count) {} + FormatStringEventLog(const char* name, int count = LogEventsBufferEntries) : EventLogBase< FormatStringLogMessage >(name, count) {} void logv(Thread* thread, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0) { - if (!should_log()) return; + if (!this->should_log()) return; - double timestamp = fetch_timestamp(); - MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag); - int index = compute_log_index(); - _records[index].thread = thread; - _records[index].timestamp = timestamp; - _records[index].data.printv(format, ap); + double timestamp = this->fetch_timestamp(); + MutexLockerEx ml(&this->_mutex, Mutex::_no_safepoint_check_flag); + int index = this->compute_log_index(); + this->_records[index].thread = thread; + this->_records[index].timestamp = timestamp; + this->_records[index].data.printv(format, ap); } void log(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(3, 4) { va_list ap; va_start(ap, format); - logv(thread, format, ap); + this->logv(thread, format, ap); va_end(ap); } }; +typedef FormatStringEventLog<256> StringEventLog; +typedef FormatStringEventLog<512> ExtendedStringEventLog; class InstanceKlass; @@ -189,7 +195,7 @@ class Events : AllStatic { // A log for internal exception related messages, like internal // throws and implicit exceptions. - static StringEventLog* _exceptions; + static ExtendedStringEventLog* _exceptions; // Deoptization related messages static StringEventLog* _deopt_messages; @@ -307,6 +313,13 @@ inline void EventLogBase::print(outputStream* out, StringLogMe out->cr(); } +// Implement a printing routine for the ExtendedStringLogMessage +template <> +inline void EventLogBase::print(outputStream* out, ExtendedStringLogMessage& lm) { + out->print_raw(lm); + out->cr(); +} + // Place markers for the beginning and end up of a set of events. // These end up in the default log. class EventMark : public StackObj { diff --git a/src/hotspot/share/utilities/exceptions.hpp b/src/hotspot/share/utilities/exceptions.hpp index 69484fed079..8780deefdea 100644 --- a/src/hotspot/share/utilities/exceptions.hpp +++ b/src/hotspot/share/utilities/exceptions.hpp @@ -237,7 +237,11 @@ class Exceptions { // visible within the scope containing the THROW. Usually this is achieved by declaring the function // with a TRAPS argument. +#ifdef THIS_FILE +#define THREAD_AND_LOCATION THREAD, THIS_FILE, __LINE__ +#else #define THREAD_AND_LOCATION THREAD, __FILE__, __LINE__ +#endif #define THROW_OOP(e) \ { Exceptions::_throw_oop(THREAD_AND_LOCATION, e); return; } From 7a86bc1c4fcb7a079d10d268ea37045e9611da54 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Sat, 16 Feb 2019 21:15:33 +0100 Subject: [PATCH 101/101] 8216049: stringTable::intern creates redundant String when looking up existing one Reviewed-by: redestad, gziemski, rehn, zgu, jiangli --- src/hotspot/share/classfile/stringTable.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hotspot/share/classfile/stringTable.cpp b/src/hotspot/share/classfile/stringTable.cpp index de730dc6454..c0356b8db59 100644 --- a/src/hotspot/share/classfile/stringTable.cpp +++ b/src/hotspot/share/classfile/stringTable.cpp @@ -334,6 +334,10 @@ oop StringTable::intern(Handle string_or_null_h, const jchar* name, int len, TRA if (StringTable::_alt_hash) { hash = hash_string(name, len, true); } + found_string = StringTable::the_table()->do_lookup(name, len, hash); + if (found_string != NULL) { + return found_string; + } return StringTable::the_table()->do_intern(string_or_null_h, name, len, hash, CHECK_NULL); }