changeset 55592:806d745ab425 lambda-leftovers

Automatic merge with default
author mcimadamore
date Thu, 28 Mar 2019 22:06:05 +0100
parents db61ecbe36dd f0fec71d2fff
children 85bc4b648318
files src/hotspot/os_cpu/linux_x86/gc/z/zLargePages_linux_x86.cpp src/hotspot/os_cpu/linux_x86/gc/z/zNUMA_linux_x86.cpp src/hotspot/os_cpu/linux_x86/gc/z/zVirtualMemory_linux_x86.cpp src/hotspot/share/gc/z/zForwardingTableEntry.hpp src/hotspot/share/gc/z/zNMethodAllocator.cpp src/hotspot/share/gc/z/zNMethodAllocator.hpp src/hotspot/share/gc/z/zPageTableEntry.hpp src/java.base/unix/native/libnio/ch/ServerSocketChannelImpl.c src/java.base/unix/native/libnio/ch/UnixAsynchronousServerSocketChannelImpl.c src/java.base/windows/native/libnio/ch/ServerSocketChannelImpl.c src/java.desktop/share/native/libfontmanager/harfbuzz/hb-atomic-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-blob-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-face-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-map-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-mutex-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-object-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-open-file-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-open-type-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-common-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsubgpos-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-arabic-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-indic-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-khmer-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-myanmar-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-tibetan.cc src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-use-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-fallback-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-normalize-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-tag.h src/java.desktop/share/native/libfontmanager/harfbuzz/hb-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-set-digest-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-set-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shaper-impl-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shaper-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-subset-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-unicode-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-utf-private.hh src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/UnsafeAccess.java src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/UnsafeAccess.java src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/doc-files/CompilationBailoutActionHelp.txt src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/UnsafeAccess.java src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/NodeCostDumpUtil.java src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/UnsafeAccess.java src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.word/src/org/graalvm/compiler/word/UnsafeAccess.java src/jdk.sctp/unix/native/libsctp/SctpServerChannelImpl.c test/hotspot/gtest/gc/z/test_zForwardingTable.cpp test/hotspot/jtreg/runtime/RedefineObject/Agent.java test/hotspot/jtreg/runtime/RedefineObject/TestRedefineObject.java test/hotspot/jtreg/runtime/RedefineObject/WalkThroughInvoke.java test/hotspot/jtreg/runtime/RedefineTests/ModifyAnonymous.java test/hotspot/jtreg/runtime/RedefineTests/RedefineAddLambdaExpression.java test/hotspot/jtreg/runtime/RedefineTests/RedefineAnnotations.java test/hotspot/jtreg/runtime/RedefineTests/RedefineDeleteJmethod.java test/hotspot/jtreg/runtime/RedefineTests/RedefineDoubleDelete.java test/hotspot/jtreg/runtime/RedefineTests/RedefineFinalizer.java test/hotspot/jtreg/runtime/RedefineTests/RedefineInterfaceCall.java test/hotspot/jtreg/runtime/RedefineTests/RedefineInterfaceMethods.java test/hotspot/jtreg/runtime/RedefineTests/RedefineLeak.java test/hotspot/jtreg/runtime/RedefineTests/RedefinePreviousVersions.java test/hotspot/jtreg/runtime/RedefineTests/RedefineRunningMethods.java test/hotspot/jtreg/runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java test/hotspot/jtreg/runtime/RedefineTests/RedefineRunningMethodsWithResolutionErrors.java test/hotspot/jtreg/runtime/RedefineTests/RedefineSubtractLambdaExpression.java test/hotspot/jtreg/runtime/RedefineTests/TestMultipleClasses.java test/hotspot/jtreg/runtime/RedefineTests/libRedefineDeleteJmethod.c test/hotspot/jtreg/runtime/RedefineTests/libRedefineDoubleDelete.c test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest-aarch64 test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest-ppc64le test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest-s390x test/hotspot/jtreg/runtime/handshake/HandshakeWalkSuspendExitTest.java test/hotspot/jtreg/runtime/noClassDefFoundMsg/NoClassDefFoundMsg.java test/hotspot/jtreg/runtime/noClassDefFoundMsg/libNoClassDefFoundMsg.c test/hotspot/jtreg/serviceability/jvmti/RetransformClassesZeroLength.java test/hotspot/jtreg/serviceability/jvmti/TestLambdaFormRetransformation.java test/hotspot/jtreg/serviceability/jvmti/TestRedefineWithUnresolvedClass.java test/hotspot/jtreg/serviceability/jvmti/UnresolvedClassAgent.java test/hotspot/jtreg/serviceability/jvmti/UnresolvedClassAgent.mf test/jdk/java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html test/jdk/java/awt/Choice/PopupPosTest/PopupPosTest.html test/jdk/java/awt/Clipboard/HTMLTransferTest/HTMLTransferTest.html test/jdk/java/awt/Component/F10TopToplevel/F10TopToplevel.html test/jdk/java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.html test/jdk/java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.html test/jdk/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.html test/jdk/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.html test/jdk/java/awt/Focus/ChildWindowFocusTest/ChildWindowFocusTest.html test/jdk/java/awt/Focus/DeiconifiedFrameLoosesFocus/DeiconifiedFrameLoosesFocus.html test/jdk/java/awt/Focus/FocusSubRequestTest/FocusSubRequestTest.html test/jdk/java/awt/Focus/ModalBlockedStealsFocusTest/ModalBlockedStealsFocusTest.html test/jdk/java/awt/Focus/ModalDialogInitialFocusTest/ModalDialogInitialFocusTest.html test/jdk/java/awt/Focus/ModalExcludedWindowClickTest/ModalExcludedWindowClickTest.html test/jdk/java/awt/Focus/NonFocusableBlockedOwnerTest/NonFocusableBlockedOwnerTest.html test/jdk/java/awt/Focus/ToFrontFocusTest/ToFrontFocus.html test/jdk/java/awt/Focus/WindowInitialFocusTest/WindowInitialFocusTest.html test/jdk/java/awt/Focus/WindowUpdateFocusabilityTest/WindowUpdateFocusabilityTest.html test/jdk/java/awt/FontClass/CreateFont/bigfont.html test/jdk/java/awt/Frame/DisposeStressTest/DisposeStressTest.html test/jdk/java/awt/Frame/NonEDT_GUI_DeadlockTest/NonEDT_GUI_Deadlock.html test/jdk/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.html test/jdk/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeForModalDialogTest/ConsumeForModalDialogTest.html test/jdk/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeNextMnemonicKeyTypedTest.html test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/ButtonActionKeyTest/ButtonActionKeyTest.html test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/MenuItemActivatedTest/MenuItemActivatedTest.html test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/TestDialogTypeAhead.html test/jdk/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.html test/jdk/java/awt/List/FocusEmptyListTest/FocusEmptyListTest.html test/jdk/java/awt/List/KeyEventsTest/KeyEventsTest.html test/jdk/java/awt/Mouse/ExtraMouseClick/ExtraMouseClick.html test/jdk/java/awt/Mouse/TitleBarDoubleClick/TitleBarDoubleClick.html test/jdk/java/awt/Multiscreen/WindowGCChangeTest/WindowGCChangeTest.html test/jdk/java/awt/Window/HandleWindowDestroyTest/HandleWindowDestroyTest.html test/jdk/java/awt/datatransfer/DragUnicodeBetweenJVMTest/DragUnicodeBetweenJVMTest.html test/jdk/java/awt/datatransfer/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html test/jdk/java/awt/dnd/DragInterceptorAppletTest/DragInterceptorAppletTest.html test/jdk/java/awt/dnd/FileListBetweenJVMsTest/FileListBetweenJVMsTest.html test/jdk/java/awt/dnd/ImageDecoratedDnDInOut/ImageDecoratedDnDInOut.html test/jdk/java/awt/dnd/ImageDecoratedDnDNegative/ImageDecoratedDnDNegative.html test/jdk/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.html test/jdk/java/awt/dnd/NoFormatsCrashTest/NoFormatsCrashTest.html test/jdk/java/awt/dnd/URIListBetweenJVMsTest/URIListBetweenJVMsTest.html test/jdk/java/awt/dnd/URIListToFileListBetweenJVMsTest/URIListToFileListBetweenJVMsTest.html test/jdk/java/awt/event/ComponentEvent/MovedResizedTardyEventTest/MovedResizedTardyEventTest.html test/jdk/java/awt/event/KeyEvent/KeyTyped/CtrlASCII.html test/jdk/java/awt/event/MouseEvent/FrameMouseEventAbsoluteCoordsTest/FrameMouseEventAbsoluteCoordsTest.html test/jdk/java/awt/event/MouseEvent/MenuDragMouseEventAbsoluteCoordsTest/MenuDragMouseEventAbsoluteCoordsTest.html test/jdk/java/awt/event/MouseEvent/MouseClickTest/MouseClickTest.html test/jdk/java/awt/event/MouseEvent/MouseWheelEventAbsoluteCoordsTest/MouseWheelEventAbsoluteCoordsTest.html test/jdk/java/awt/event/MouseEvent/RobotLWTest/RobotLWTest.html test/jdk/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_2.html test/jdk/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_3.html test/jdk/javax/imageio/AppletResourceTest.html test/jdk/javax/swing/JFrame/4962534/bug4962534.html test/jdk/javax/swing/JPopupMenu/4634626/bug4634626.html test/jdk/javax/swing/MultiUIDefaults/4300666/bug4300666.html test/jdk/javax/swing/text/StyledEditorKit/4506788/bug4506788.html test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest-aarch64 test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest-ppc64le test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest-s390x test/jdk/sanity/client/TEST.ROOT.template test/jdk/sun/java2d/cmm/ColorConvertOp/ConstructorsNullTest/ConstructorsNullTest.html test/jdk/vm/JniInvocationTest.java test/jdk/vm/exeJniInvocationTest.c test/jdk/vm/gc/ArraySize.java test/jdk/vm/gc/InfiniteList.java test/jdk/vm/jit/BadLogicCode.java test/jdk/vm/jit/ExceptionInInit.java test/jdk/vm/jit/JITClassInit.java test/jdk/vm/runtime/ExplicitArithmeticCheck.java test/jdk/vm/runtime/MonitorCacheMaybeExpand_DeadLock.java test/jdk/vm/runtime/ReflectStackOverflow.java test/jdk/vm/runtime/ShiftTest.java test/jdk/vm/runtime/WideStrictInline.java test/jdk/vm/verifier/TestStaticIF.java test/jdk/vm/verifier/VerifyProtectedConstructor.java test/jdk/vm/verifier/VerifyStackForExceptionHandlers.java test/jdk/vm/verifier/defaultMethods/DefaultMethodRegressionTests.java test/jdk/vm/verifier/defaultMethods/DefaultMethodRegressionTestsRun.java
diffstat 1181 files changed, 68492 insertions(+), 37818 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Mar 14 22:05:45 2019 +0100
+++ b/.hgtags	Thu Mar 28 22:06:05 2019 +0100
@@ -549,3 +549,6 @@
 8e069f7b4fabfe05d9f500783e6d56cb0196d25c jdk-13+10
 21ea4076a275a0f498afa517e9ee1b94a9cf0255 jdk-13+11
 1d7aec80147a6d92b101a76aef92f3ddc88bedf4 jdk-13+12
+b67884871b5fff79c5ef3eb8ac74dd48d71ea9b1 jdk-12-ga
+83cace4142c8563b6a921787db02388e1bc48d01 jdk-13+13
+46cf212cdccaf4fb064d913b12004007d3322b67 jdk-13+14
--- a/doc/testing.html	Thu Mar 14 22:05:45 2019 +0100
+++ b/doc/testing.html	Thu Mar 28 22:06:05 2019 +0100
@@ -39,7 +39,7 @@
 <h2 id="using-make-test-the-run-test-framework">Using &quot;make test&quot; (the run-test framework)</h2>
 <p>This new way of running tests is developer-centric. It assumes that you have built a JDK locally and want to test it. Running common test targets is simple, and more complex ad-hoc combination of tests is possible. The user interface is forgiving, and clearly report errors it cannot resolve.</p>
 <p>The main target <code>test</code> uses the jdk-image as the tested product. There is also an alternate target <code>exploded-test</code> that uses the exploded image instead. Not all tests will run successfully on the exploded image, but using this target can greatly improve rebuild times for certain workflows.</p>
-<p>Previously, <code>make test</code> was used invoke an old system for running test, and <code>make run-test</code> was used for the new test framework. For backward compatibility with scripts and muscle memory, <code>run-test</code> (and variants like <code>exploded-run-test</code> or <code>run-test-tier1</code>) are kept as aliases. The old system can still be accessed for some time using <code>cd test &amp;&amp; make</code>.</p>
+<p>Previously, <code>make test</code> was used to invoke an old system for running tests, and <code>make run-test</code> was used for the new test framework. For backward compatibility with scripts and muscle memory, <code>run-test</code> (and variants like <code>exploded-run-test</code> or <code>run-test-tier1</code>) are kept as aliases.</p>
 <p>Some example command-lines:</p>
 <pre><code>$ make test-tier1
 $ make test-jdk_lang JTREG=&quot;JOBS=8&quot;
--- a/doc/testing.md	Thu Mar 14 22:05:45 2019 +0100
+++ b/doc/testing.md	Thu Mar 28 22:06:05 2019 +0100
@@ -12,11 +12,10 @@
 instead. Not all tests will run successfully on the exploded image, but using
 this target can greatly improve rebuild times for certain workflows.
 
-Previously, `make test` was used invoke an old system for running test, and
+Previously, `make test` was used to invoke an old system for running tests, and
 `make run-test` was used for the new test framework. For backward compatibility
 with scripts and muscle memory, `run-test` (and variants like
-`exploded-run-test` or `run-test-tier1`) are kept as aliases. The old system
-can still be accessed for some time using `cd test && make`.
+`exploded-run-test` or `run-test-tier1`) are kept as aliases.
 
 Some example command-lines:
 
--- a/make/CompileJavaModules.gmk	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/CompileJavaModules.gmk	Thu Mar 28 22:06:05 2019 +0100
@@ -70,7 +70,7 @@
 
 ################################################################################
 
-java.compiler_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-accessibility '-Xdoclint/package:java.*,javax.*'
+java.compiler_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*'
 
 ################################################################################
 
--- a/make/autoconf/jdk-version.m4	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/autoconf/jdk-version.m4	Thu Mar 28 22:06:05 2019 +0100
@@ -460,6 +460,7 @@
   # We could define --with flags for these, if really needed
   VERSION_CLASSFILE_MAJOR="$DEFAULT_VERSION_CLASSFILE_MAJOR"
   VERSION_CLASSFILE_MINOR="$DEFAULT_VERSION_CLASSFILE_MINOR"
+  JDK_SOURCE_TARGET_VERSION="$DEFAULT_JDK_SOURCE_TARGET_VERSION"
 
   AC_MSG_CHECKING([for version string])
   AC_MSG_RESULT([$VERSION_STRING])
@@ -483,5 +484,5 @@
   AC_SUBST(VENDOR_VERSION_STRING)
   AC_SUBST(VERSION_CLASSFILE_MAJOR)
   AC_SUBST(VERSION_CLASSFILE_MINOR)
-
+  AC_SUBST(JDK_SOURCE_TARGET_VERSION)
 ])
--- a/make/autoconf/lib-x11.m4	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/autoconf/lib-x11.m4	Thu Mar 28 22:06:05 2019 +0100
@@ -119,7 +119,7 @@
 
     if test "x$X11_HEADERS_OK" = xno; then
       HELP_MSG_MISSING_DEPENDENCY([x11])
-      AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h Xrander.h XTest.h Intrinsic.h). $HELP_MSG])
+      AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h Xrandr.h XTest.h Intrinsic.h). $HELP_MSG])
     fi
 
     # If XLinearGradient isn't available in Xrender.h, signal that it needs to be
--- a/make/autoconf/spec.gmk.in	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/autoconf/spec.gmk.in	Thu Mar 28 22:06:05 2019 +0100
@@ -208,6 +208,8 @@
 VERSION_CLASSFILE_MAJOR := @VERSION_CLASSFILE_MAJOR@
 VERSION_CLASSFILE_MINOR := @VERSION_CLASSFILE_MINOR@
 
+JDK_SOURCE_TARGET_VERSION := @JDK_SOURCE_TARGET_VERSION@
+
 # Convenience CFLAGS settings for passing version information into native programs.
 VERSION_CFLAGS := \
     -DVERSION_FEATURE=$(VERSION_FEATURE) \
--- a/make/autoconf/toolchain.m4	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/autoconf/toolchain.m4	Thu Mar 28 22:06:05 2019 +0100
@@ -643,14 +643,21 @@
     [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
         $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ]
   elif test  "x$TOOLCHAIN_TYPE" = xgcc; then
-    # gcc -Wl,-version output typically looks like
+    # gcc -Wl,-version output typically looks like:
     #   GNU ld (GNU Binutils for Ubuntu) 2.26.1
     #   Copyright (C) 2015 Free Software Foundation, Inc.
     #   This program is free software; [...]
-    LINKER_VERSION_STRING=`$LD -Wl,-version 2>&1 | $HEAD -n 1`
+    # If using gold it will look like:
+    #   GNU gold (GNU Binutils 2.30) 1.15
+    LINKER_VERSION_STRING=`$LD -Wl,--version 2> /dev/null | $HEAD -n 1`
     # Extract version number
-    [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
-        $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ]
+    if [ [[ "$LINKER_VERSION_STRING" == *gold* ]] ]; then
+      [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
+          $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*) .*/\1/'` ]
+    else
+      [ LINKER_VERSION_NUMBER=`$ECHO $LINKER_VERSION_STRING | \
+          $SED -e 's/.* \([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*/\1/'` ]
+    fi
   elif test  "x$TOOLCHAIN_TYPE" = xclang; then
     # clang -Wl,-v output typically looks like
     #   @(#)PROGRAM:ld  PROJECT:ld64-305
--- a/make/autoconf/toolchain_windows.m4	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/autoconf/toolchain_windows.m4	Thu Mar 28 22:06:05 2019 +0100
@@ -87,6 +87,7 @@
 VS_VS_PLATFORM_NAME_2017="v141"
 VS_SDK_PLATFORM_NAME_2017=
 VS_SUPPORTED_2017=true
+VS_TOOLSET_SUPPORTED_2017=true
 
 ################################################################################
 
@@ -177,6 +178,15 @@
 # build environment and assigns it to VS_ENV_CMD
 AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE],
 [
+  # VS2017 provides the option to install previous minor versions of the MSVC
+  # toolsets. It is not possible to directly download earlier minor versions of
+  # VS2017 and in order to build with a previous minor compiler toolset version,
+  # it is now possible to compile with earlier minor versions by passing
+  # -vcvars_ver=<toolset_version> argument to vcvarsall.bat.
+  AC_ARG_WITH(msvc-toolset-version, [AS_HELP_STRING([--with-msvc-toolset-version],
+      [specific MSVC toolset version to use, passed as -vcvars_ver argument to
+       pass to vcvarsall.bat (Windows only)])])
+
   VS_VERSION="$1"
   eval VS_COMNTOOLS_VAR="\${VS_ENVVAR_${VS_VERSION}}"
   eval VS_COMNTOOLS="\$${VS_COMNTOOLS_VAR}"
@@ -184,6 +194,7 @@
   eval VS_EDITIONS="\${VS_EDITIONS_${VS_VERSION}}"
   eval SDK_INSTALL_DIR="\${VS_SDK_INSTALLDIR_${VS_VERSION}}"
   eval VS_ENV_ARGS="\${VS_ENV_ARGS_${VS_VERSION}}"
+  eval VS_TOOLSET_SUPPORTED="\${VS_TOOLSET_SUPPORTED_${VS_VERSION}}"
 
   # When using --with-tools-dir, assume it points to the correct and default
   # version of Visual Studio or that --with-toolchain-version was also set.
@@ -240,6 +251,12 @@
     TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
         [C:/Program Files (x86)/$SDK_INSTALL_DIR], [well-known name])
   fi
+
+  if test "x$VS_TOOLSET_SUPPORTED" != x; then
+    if test "x$with_msvc_toolset_version" != x; then
+      VS_ENV_ARGS="$VS_ENV_ARGS -vcvars_ver=$with_msvc_toolset_version"
+    fi
+  fi
 ])
 
 ################################################################################
@@ -423,6 +440,8 @@
             >> $EXTRACT_VC_ENV_BAT_FILE
         $ECHO 'echo VCINSTALLDIR="%VCINSTALLDIR% " >> set-vs-env.sh' \
             >> $EXTRACT_VC_ENV_BAT_FILE
+        $ECHO 'echo VCToolsRedistDir="%VCToolsRedistDir% " >> set-vs-env.sh' \
+            >> $EXTRACT_VC_ENV_BAT_FILE
         $ECHO 'echo WindowsSdkDir="%WindowsSdkDir% " >> set-vs-env.sh' \
             >> $EXTRACT_VC_ENV_BAT_FILE
         $ECHO 'echo WINDOWSSDKDIR="%WINDOWSSDKDIR% " >> set-vs-env.sh' \
@@ -440,6 +459,8 @@
             >> $EXTRACT_VC_ENV_BAT_FILE
         $ECHO "$WINPATH_BASH -c 'echo VCINSTALLDIR="'\"$VCINSTALLDIR \" >> set-vs-env.sh' \
             >> $EXTRACT_VC_ENV_BAT_FILE
+        $ECHO "$WINPATH_BASH -c 'echo VCToolsRedistDir="'\"$VCToolsRedistDir \" >> set-vs-env.sh' \
+            >> $EXTRACT_VC_ENV_BAT_FILE
         $ECHO "$WINPATH_BASH -c 'echo WindowsSdkDir="'\"$WindowsSdkDir \" >> set-vs-env.sh' \
             >> $EXTRACT_VC_ENV_BAT_FILE
         $ECHO "$WINPATH_BASH -c 'echo WINDOWSSDKDIR="'\"$WINDOWSSDKDIR \" >> set-vs-env.sh' \
@@ -517,6 +538,7 @@
       VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED -e 's/\\\\*;* *$//'`
       VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\*;* *$//'`
       VCINSTALLDIR=`$ECHO "$VCINSTALLDIR" | $SED 's/\\\\* *$//'`
+      VCToolsRedistDir=`$ECHO "$VCToolsRedistDir" | $SED 's/\\\\* *$//'`
       WindowsSdkDir=`$ECHO "$WindowsSdkDir" | $SED 's/\\\\* *$//'`
       WINDOWSSDKDIR=`$ECHO "$WINDOWSSDKDIR" | $SED 's/\\\\* *$//'`
       if test -z "$WINDOWSSDKDIR"; then
@@ -638,11 +660,13 @@
           POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
         fi
       else
+        CYGWIN_VC_TOOLS_REDIST_DIR="$VCToolsRedistDir"
+        BASIC_FIXUP_PATH(CYGWIN_VC_TOOLS_REDIST_DIR)
         # Probe: Using well-known location from VS 2017
         if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-          POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_INSTALL_DIR/Redist/MSVC/*/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`"
+          POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_TOOLS_REDIST_DIR/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`"
         else
-          POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_INSTALL_DIR/Redist/MSVC/*/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`"
+          POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_TOOLS_REDIST_DIR/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`"
         fi
       fi
       # In case any of the above finds more than one file, loop over them.
--- a/make/autoconf/version-numbers	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/autoconf/version-numbers	Thu Mar 28 22:06:05 2019 +0100
@@ -35,7 +35,8 @@
 DEFAULT_VERSION_DATE=2019-09-17
 DEFAULT_VERSION_CLASSFILE_MAJOR=57  # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`"
 DEFAULT_VERSION_CLASSFILE_MINOR=0
-DEFAULT_ACCEPTABLE_BOOT_VERSIONS="11 12 13"
+DEFAULT_ACCEPTABLE_BOOT_VERSIONS="12 13"
+DEFAULT_JDK_SOURCE_TARGET_VERSION=13
 
 LAUNCHER_NAME=openjdk
 PRODUCT_NAME=OpenJDK
--- a/make/common/SetupJavaCompilers.gmk	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/common/SetupJavaCompilers.gmk	Thu Mar 28 22:06:05 2019 +0100
@@ -33,6 +33,9 @@
 
 DISABLE_WARNINGS ?= -Xlint:all,-deprecation,-removal,-unchecked,-rawtypes,-cast,-serial,-dep-ann,-static,-fallthrough,-try,-varargs,-empty,-finally
 
+JDK_SOURCE_TARGET_FLAGS := -source $(JDK_SOURCE_TARGET_VERSION) \
+    -target $(JDK_SOURCE_TARGET_VERSION)
+
 # If warnings needs to be non-fatal for testing purposes use a command like:
 # make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000"
 JAVAC_WARNINGS ?= -Xlint:all -Werror
@@ -72,7 +75,7 @@
 $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \
     JVM := $(JAVA_JAVAC), \
     JAVAC := $(NEW_JAVAC), \
-    FLAGS := -source 13 -target 13 --doclint-format html5 \
+    FLAGS := $(JDK_SOURCE_TARGET_FLAGS) --doclint-format html5 \
         -encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS), \
     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
@@ -82,7 +85,7 @@
 $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \
     JVM := $(JAVA_JAVAC), \
     JAVAC := $(NEW_JAVAC), \
-    FLAGS := -source 13 -target 13 \
+    FLAGS := $(JDK_SOURCE_TARGET_FLAGS) \
         -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS), \
     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
--- a/make/conf/jib-profiles.js	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/conf/jib-profiles.js	Thu Mar 28 22:06:05 2019 +0100
@@ -365,7 +365,8 @@
         };
     };
 
-    common.boot_jdk_version = "11";
+    common.boot_jdk_version = "12";
+    common.boot_jdk_build_number = "33";
     common.boot_jdk_home = input.get("boot_jdk", "install_path") + "/jdk-"
         + common.boot_jdk_version
         + (input.build_os == "macosx" ? ".jdk/Contents/Home" : "");
@@ -754,7 +755,11 @@
             profiles[cmpBaselineName] = clone(profiles[name + suffix]);
             // Only compare the images target. This should pressumably be expanded
             // to include more build targets when possible.
-            profiles[cmpBaselineName].default_make_targets = [ "images" ];
+            profiles[cmpBaselineName].default_make_targets = [ "images", "test-image" ];
+            if (name == "linux-x64") {
+                profiles[cmpBaselineName].default_make_targets
+                    = concat(profiles[cmpBaselineName].default_make_targets, "docs");
+            }
             profiles[cmpBaselineName].make_args = [ "COMPARE_BUILD=CONF=" ];
             // Do not inherit artifact definitions from base profile
             delete profiles[cmpBaselineName].artifacts;
@@ -939,21 +944,27 @@
 var getJibProfilesDependencies = function (input, common) {
 
     var devkit_platform_revisions = {
-        linux_x64: "gcc7.3.0-OEL6.4+1.2",
+        linux_x64: "gcc8.2.0-OL6.4+1.0",
         macosx_x64: "Xcode10.1-MacOSX10.14+1.0",
         solaris_x64: "SS12u4-Solaris11u1+1.0",
         solaris_sparcv9: "SS12u6-Solaris11u3+1.0",
         windows_x64: "VS2017-15.9.6+1.0",
-        linux_aarch64: "gcc7.3.0-Fedora27+1.2",
-        linux_arm: "gcc7.3.0-Fedora27+1.2",
-        linux_ppc64le: "gcc7.3.0-Fedora27+1.0",
-        linux_s390x: "gcc7.3.0-Fedora27+1.0"
+        linux_aarch64: "gcc8.2.0-Fedora27+1.0",
+        linux_arm: "gcc8.2.0-Fedora27+1.0",
+        linux_ppc64le: "gcc8.2.0-Fedora27+1.0",
+        linux_s390x: "gcc8.2.0-Fedora27+1.0"
     };
 
     var devkit_platform = (input.target_cpu == "x86"
         ? input.target_os + "_x64"
         : input.target_platform);
 
+    var devkit_cross_prefix = "";
+    if (input.build_platform != input.target_platform
+       && input.build_platform != devkit_platform) {
+        devkit_cross_prefix = input.build_platform + "-to-";
+    }
+
     var boot_jdk_platform = (input.build_os == "macosx" ? "osx" : input.build_os)
         + "-" + input.build_cpu;
     var boot_jdk_ext = (input.build_os == "windows" ? ".zip" : ".tar.gz")
@@ -974,7 +985,7 @@
             server: "jpg",
             product: "jdk",
             version: common.boot_jdk_version,
-            build_number: "28",
+            build_number: common.boot_jdk_build_number,
             file: "bundles/" + boot_jdk_platform + "/jdk-" + common.boot_jdk_version + "_"
                 + boot_jdk_platform + "_bin" + boot_jdk_ext,
             configure_args: "--with-boot-jdk=" + common.boot_jdk_home,
@@ -984,7 +995,7 @@
         devkit: {
             organization: common.organization,
             ext: "tar.gz",
-            module: "devkit-" + devkit_platform,
+            module: "devkit-" + devkit_cross_prefix + devkit_platform,
             revision: devkit_platform_revisions[devkit_platform],
             environment: {
                 "DEVKIT_HOME": input.get("devkit", "home_path"),
--- a/make/data/publicsuffixlist/VERSION	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/data/publicsuffixlist/VERSION	Thu Mar 28 22:06:05 2019 +0100
@@ -1,2 +1,2 @@
-Github: https://raw.githubusercontent.com/publicsuffix/list/2225db8d9f4a2a27ec697c883360632fa0c16261/public_suffix_list.dat
-Date: 2018-05-24
+Github: https://raw.githubusercontent.com/publicsuffix/list/ce0d1a5fba657e55adea3abde4b7f1e50636ff10/public_suffix_list.dat
+Date: 2019-01-28
--- a/make/data/publicsuffixlist/public_suffix_list.dat	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/data/publicsuffixlist/public_suffix_list.dat	Thu Mar 28 22:06:05 2019 +0100
@@ -381,8 +381,13 @@
 net.bm
 org.bm
 
-// bn : https://en.wikipedia.org/wiki/.bn
-*.bn
+// bn : http://www.bnnic.bn/faqs
+bn
+com.bn
+edu.bn
+gov.bn
+net.bn
+org.bn
 
 // bo : https://nic.bo/delegacion2015.php#h-1.10
 bo
@@ -546,6 +551,7 @@
 not.br
 ntr.br
 odo.br
+ong.br
 org.br
 osasco.br
 palmas.br
@@ -1239,7 +1245,7 @@
 utazas.hu
 video.hu
 
-// id : https://register.pandi.or.id/
+// id : https://pandi.id/en/domain/registration-requirements/
 id
 ac.id
 biz.id
@@ -1250,6 +1256,7 @@
 my.id
 net.id
 or.id
+ponpes.id
 sch.id
 web.id
 
@@ -1407,9 +1414,9 @@
 tos.it
 toscana.it
 trentin-sud-tirol.it
-trentin-süd-tirol.it
+trentin-süd-tirol.it
 trentin-sudtirol.it
-trentin-südtirol.it
+trentin-südtirol.it
 trentin-sued-tirol.it
 trentin-suedtirol.it
 trentino-a-adige.it
@@ -1419,9 +1426,9 @@
 trentino-s-tirol.it
 trentino-stirol.it
 trentino-sud-tirol.it
-trentino-süd-tirol.it
+trentino-süd-tirol.it
 trentino-sudtirol.it
-trentino-südtirol.it
+trentino-südtirol.it
 trentino-sued-tirol.it
 trentino-suedtirol.it
 trentino.it
@@ -1432,15 +1439,15 @@
 trentinos-tirol.it
 trentinostirol.it
 trentinosud-tirol.it
-trentinosüd-tirol.it
+trentinosüd-tirol.it
 trentinosudtirol.it
-trentinosüdtirol.it
+trentinosüdtirol.it
 trentinosued-tirol.it
 trentinosuedtirol.it
 trentinsud-tirol.it
-trentinsüd-tirol.it
+trentinsüd-tirol.it
 trentinsudtirol.it
-trentinsüdtirol.it
+trentinsüdtirol.it
 trentinsued-tirol.it
 trentinsuedtirol.it
 tuscany.it
@@ -1457,13 +1464,13 @@
 valled-aosta.it
 valledaosta.it
 vallee-aoste.it
-vallée-aoste.it
+vallée-aoste.it
 vallee-d-aoste.it
-vallée-d-aoste.it
+vallée-d-aoste.it
 valleeaoste.it
-valléeaoste.it
+valléeaoste.it
 valleedaoste.it
-valléedaoste.it
+valléedaoste.it
 vao.it
 vda.it
 ven.it
@@ -1497,7 +1504,7 @@
 avellino.it
 ba.it
 balsan-sudtirol.it
-balsan-südtirol.it
+balsan-südtirol.it
 balsan-suedtirol.it
 balsan.it
 bari.it
@@ -1516,7 +1523,7 @@
 bolzano-altoadige.it
 bolzano.it
 bozen-sudtirol.it
-bozen-südtirol.it
+bozen-südtirol.it
 bozen-suedtirol.it
 bozen.it
 br.it
@@ -1525,7 +1532,7 @@
 bs.it
 bt.it
 bulsan-sudtirol.it
-bulsan-südtirol.it
+bulsan-südtirol.it
 bulsan-suedtirol.it
 bulsan.it
 bz.it
@@ -1545,9 +1552,9 @@
 cb.it
 ce.it
 cesena-forli.it
-cesena-forlì.it
+cesena-forlì.it
 cesenaforli.it
-cesenaforlì.it
+cesenaforlì.it
 ch.it
 chieti.it
 ci.it
@@ -1578,9 +1585,9 @@
 fm.it
 foggia.it
 forli-cesena.it
-forlì-cesena.it
+forlì-cesena.it
 forlicesena.it
-forlìcesena.it
+forlìcesena.it
 fr.it
 frosinone.it
 ge.it
@@ -1711,7 +1718,7 @@
 sr.it
 ss.it
 suedtirol.it
-südtirol.it
+südtirol.it
 sv.it
 ta.it
 taranto.it
@@ -3692,8 +3699,16 @@
 seoul.kr
 ulsan.kr
 
-// kw : https://en.wikipedia.org/wiki/.kw
-*.kw
+// kw : https://www.nic.kw/policies/
+// Confirmed by registry <nic.tech@citra.gov.kw>
+kw
+com.kw
+edu.kw
+emb.kw
+gov.kw
+ind.kw
+net.kw
+org.kw
 
 // ky : http://www.icta.ky/da_ky_reg_dom.php
 // Confirmed by registry <kysupport@perimeterusa.com> 2008-06-17
@@ -3775,10 +3790,18 @@
 org.lr
 net.lr
 
-// ls : https://en.wikipedia.org/wiki/.ls
+// ls : http://www.nic.ls/
+// Confirmed by registry <lsadmin@nic.ls>
 ls
+ac.ls
+biz.ls
 co.ls
+edu.ls
+gov.ls
+info.ls
+net.ls
 org.ls
+sc.ls
 
 // lt : https://en.wikipedia.org/wiki/.lt
 lt
@@ -4636,9 +4659,6 @@
 //      ccTLD for the Netherlands
 nl
 
-// BV.nl will be a registry for dutch BV's (besloten vennootschap)
-bv.nl
-
 // no : http://www.norid.no/regelverk/index.en.html
 // The Norwegian registry has declined to notify us of updates. The web pages
 // referenced below are the official source of the data. There is also an
@@ -8329,9 +8349,6 @@
 // goo : 2014-12-18 NTT Resonant Inc.
 goo
 
-// goodhands : 2015-07-31 Allstate Fire and Casualty Insurance Company
-goodhands
-
 // goodyear : 2015-07-02 The Goodyear Tire & Rubber Company
 goodyear
 
@@ -8608,9 +8625,6 @@
 // iveco : 2015-09-03 CNH Industrial N.V.
 iveco
 
-// iwc : 2014-06-23 Richemont DNS Inc.
-iwc
-
 // jaguar : 2014-11-13 Jaguar Land Rover Ltd
 jaguar
 
@@ -8635,9 +8649,6 @@
 // jio : 2015-04-02 Reliance Industries Limited
 jio
 
-// jlc : 2014-12-04 Richemont DNS Inc.
-jlc
-
 // jll : 2015-04-02 Jones Lang LaSalle Incorporated
 jll
 
@@ -8989,9 +9000,6 @@
 // menu : 2013-09-11 Wedding TLD2, LLC
 menu
 
-// meo : 2014-11-07 MEO Servicos de Comunicacoes e Multimedia, S.A.
-meo
-
 // merckmsd : 2016-07-14 MSD Registry Holdings, Inc.
 merckmsd
 
@@ -9283,9 +9291,6 @@
 // panasonic : 2015-07-30 Panasonic Corporation
 panasonic
 
-// panerai : 2014-11-07 Richemont DNS Inc.
-panerai
-
 // paris : 2014-01-30 City of Paris
 paris
 
@@ -9634,9 +9639,6 @@
 // sap : 2014-03-27 SAP AG
 sap
 
-// sapo : 2014-11-07 MEO Servicos de Comunicacoes e Multimedia, S.A.
-sapo
-
 // sarl : 2014-07-03 Binky Moon, LLC
 sarl
 
@@ -9877,9 +9879,6 @@
 // statefarm : 2015-07-30 State Farm Mutual Automobile Insurance Company
 statefarm
 
-// statoil : 2014-12-04 Statoil ASA
-statoil
-
 // stc : 2014-10-09 Saudi Telecom Company
 stc
 
@@ -9991,9 +9990,6 @@
 // technology : 2013-09-13 Binky Moon, LLC
 technology
 
-// telecity : 2015-02-19 TelecityGroup International Limited
-telecity
-
 // telefonica : 2014-10-16 Telefónica S.A.
 telefonica
 
@@ -10201,9 +10197,6 @@
 // vision : 2013-12-05 Binky Moon, LLC
 vision
 
-// vista : 2014-09-18 Vistaprint Limited
-vista
-
 // vistaprint : 2014-09-18 Vistaprint Limited
 vistaprint
 
@@ -10642,9 +10635,6 @@
 // xn--zfr164b : 2013-11-08 China Organizational Name Administration Center
 政务
 
-// xperia : 2015-05-14 Sony Mobile Communications AB
-xperia
-
 // xyz : 2013-12-05 XYZ.COM LLC
 xyz
 
@@ -10737,6 +10727,7 @@
 // Amazon Elastic Beanstalk : https://aws.amazon.com/elasticbeanstalk/
 // Submitted by Luke Wells <psl-maintainers@amazon.com>
 cn-north-1.eb.amazonaws.com.cn
+cn-northwest-1.eb.amazonaws.com.cn
 elasticbeanstalk.com
 ap-northeast-1.elasticbeanstalk.com
 ap-northeast-2.elasticbeanstalk.com
@@ -10823,6 +10814,10 @@
 t3l3p0rt.net
 tele.amune.org
 
+// Apigee : https://apigee.com/
+// Submitted by Apigee Security Team <security@apigee.com>
+apigee.io
+
 // Aptible : https://www.aptible.com/
 // Submitted by Thomas Orozco <thomas@aptible.com>
 on-aptible.com
@@ -10842,6 +10837,11 @@
 // Submitted by Vincent Tseng <vincenttseng@asustor.com>
 myasustor.com
 
+// Automattic Inc. : https://automattic.com/
+// Submitted by Alex Concha <alex.concha@automattic.com>
+go-vip.co
+wpcomstaging.com
+
 // AVM : https://avm.de
 // Submitted by Andreas Weise <a.weise@avm.de>
 myfritz.net
@@ -10888,6 +10888,11 @@
 // Submitted by Dave Tharp <browsersafetymark.io@quicinc.com>
 browsersafetymark.io
 
+// Bytemark Hosting : https://www.bytemark.co.uk
+// Submitted by Paul Cammish <paul.cammish@bytemark.co.uk>
+dh.bytemark.co.uk
+vm.bytemark.co.uk
+
 // callidomus : https://www.callidomus.com/
 // Submitted by Marcus Popp <admin@callidomus.com>
 mycd.eu
@@ -11080,6 +11085,11 @@
 reg.dk
 store.dk
 
+// dapps.earth : https://dapps.earth/
+// Submitted by Daniil Burdakov <icqkill@gmail.com>
+*.dapps.earth
+*.bzz.dapps.earth
+
 // Debian : https://www.debian.org/
 // Submitted by Peter Palfrader / Debian Sysadmin Team <dsa-publicsuffixlist@debian.org>
 debian.net
@@ -11092,6 +11102,11 @@
 // Submitted by Norbert Auler <mail@dnshome.de>
 dnshome.de
 
+// DotArai : https://www.dotarai.com/
+// Submitted by Atsadawat Netcharadsang <atsadawat@dotarai.co.th>
+online.th
+shop.th
+
 // DrayTek Corp. : https://www.draytek.com/
 // Submitted by Paul Fang <mis@draytek.com>
 drayddns.com
@@ -11648,6 +11663,10 @@
 app.os.fedoraproject.org
 app.os.stg.fedoraproject.org
 
+// Fermax : https://fermax.com/
+// submitted by Koen Van Isterdael <k.vanisterdael@fermax.be>
+mydobiss.com
+
 // Filegear Inc. : https://www.filegear.com
 // Submitted by Jason Zhu <jason@owtware.com>
 filegear.me
@@ -11713,6 +11732,8 @@
 
 // Google, Inc.
 // Submitted by Eduardo Vela <evn@google.com>
+run.app
+a.run.app
 *.0emm.com
 appspot.com
 blogspot.ae
@@ -11918,6 +11939,12 @@
 lcube-server.de
 svn-repos.de
 
+// Leadpages : https://www.leadpages.net
+// Submitted by Greg Dallavalle <domains@leadpages.net>
+leadpages.co
+lpages.co
+lpusercontent.com
+
 // Lightmaker Property Manager, Inc. : https://app.lmpm.com/
 // Submitted by Greg Holland <greg.holland@lmpm.com>
 app.lmpm.com
@@ -11935,6 +11962,15 @@
 // Submitted by Victor Velchev <admin@liquidnetlimited.com>
 we.bs
 
+// LubMAN UMCS Sp. z o.o : https://lubman.pl/
+// Submitted by Ireneusz Maliszewski <ireneusz.maliszewski@lubman.pl>
+krasnik.pl
+leczna.pl
+lubartow.pl
+lublin.pl
+poniatowa.pl
+swidnik.pl
+
 // Lug.org.uk : https://lug.org.uk
 // Submitted by Jon Spriggs <admin@lug.org.uk>
 uklugs.org
@@ -12322,6 +12358,10 @@
 chirurgiens-dentistes-en-france.fr
 byen.site
 
+// Redstar Consultants : https://www.redstarconsultants.com/
+// Submitted by Jons Slemmer <jons@redstarconsultants.com>
+instantcloud.cn
+
 // Russian Academy of Sciences
 // Submitted by Tech Support <support@rasnet.ru>
 ras.ru
@@ -12350,6 +12390,10 @@
 rackmaze.com
 rackmaze.net
 
+// Read The Docs, Inc : https://www.readthedocs.org
+// Submitted by David Fischer <team@readthedocs.org>
+readthedocs.io
+
 // Red Hat, Inc. OpenShift : https://openshift.redhat.com/
 // Submitted by Tim Kramer <tkramer@rhcloud.com>
 rhcloud.com
@@ -12426,6 +12470,10 @@
 sinaapp.com
 vipsinaapp.com
 
+// Siteleaf : https://www.siteleaf.com/
+// Submitted by Skylar Challand <support@siteleaf.com>
+siteleaf.net
+
 // Skyhat : http://www.skyhat.io
 // Submitted by Shante Adam <shante@skyhat.io>
 bounty-full.com
@@ -12451,10 +12499,6 @@
 // Submitted by Stefan Neufeind <info@speedpartner.de>
 customer.speedpartner.de
 
-// Stackspace : https://www.stackspace.io/
-// Submitted by Lina He <info@stackspace.io>
-stackspace.space
-
 // Storj Labs Inc. : https://storj.io/
 // Submitted by Philip Hutchins <hostmaster@storj.io>
 storj.farm
@@ -12495,6 +12539,12 @@
 med.pl
 sopot.pl
 
+// Telebit : https://telebit.cloud
+// Submitted by AJ ONeal <aj@telebit.cloud>
+telebit.app
+telebit.io
+*.telebit.xyz
+
 // The Gwiddle Foundation : https://gwiddlefoundation.org.uk
 // Submitted by Joshua Bayfield <joshua.bayfield@gwiddlefoundation.org.uk>
 gwiddle.co.uk
@@ -12533,7 +12583,7 @@
 webspace.rocks
 lima.zone
 
-// TransIP : htts://www.transip.nl
+// TransIP : https://www.transip.nl
 // Submitted by Rory Breuk <rbreuk@transip.nl>
 *.transurl.be
 *.transurl.eu
--- a/make/devkit/Makefile	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/devkit/Makefile	Thu Mar 28 22:06:05 2019 +0100
@@ -29,14 +29,10 @@
 # gcc based cross compilation, portable, self contained packages, capable
 # of building OpenJDK.
 #
-# In addition to the makefiles, access to Oracle Linux installation
-# media is required. This has been tested against Oracle Enterprise Linux
-# 6.4.
-#
 # By default this Makefile will build a native toolchain for the current
 # platform if called with something like this:
 #
-# make tars BASE_OS=OEL6
+# make tars BASE_OS=OL
 #
 # To build the full set of crosstools for additional platforms, use a command
 # line looking like this:
@@ -48,9 +44,19 @@
 # to build several devkits for a specific OS version at once.
 # You can find the final results under ../../build/devkit/result/<host>-to-<target>
 #
+# You may want the native toolchain to be used when compiling the cross
+# compilation toolchains. To achieve this, first build the native toolchain,
+# then add the bin directory from this build to the path when invoking this
+# makefile again for cross compilation. Ex:
+#
+# PATH=$PWD/../../build/devkit/result/x86_64-linux-gnu-to-x86_64-linux-gnu/bin:$PATH \
+#    make TARGETS="arm-linux-gnueabihf,ppc64-linux-gnu" BASE_OS=Fedora
+#
 # This is the makefile which iterates over all host and target platforms.
 #
 
+COMMA := ,
+
 os := $(shell uname -o)
 cpu := $(shell uname -p)
 
@@ -66,7 +72,7 @@
   platforms := $(me)
   host_platforms := $(platforms)
 else
-  platforms := $(TARGETS)
+  platforms := $(subst $(COMMA), , $(TARGETS))
   host_platforms := $(me)
 endif
 target_platforms := $(platforms)
@@ -93,7 +99,7 @@
 	  $(MAKE) -f Tools.gmk all $(submakevars) \
               TARGET=$$p PREFIX=$(RESULT)/$@-to-$$p && \
 	  $(MAKE) -f Tools.gmk ccache $(submakevars) \
-              TARGET=$@ PREFIX=$(RESULT)/$@-to-$$p BUILDDIR=$(OUTPUT_ROOT)/$@/$$p || exit 1 ; \
+              TARGET=$@ PREFIX=$(RESULT)/$@-to-$$p || exit 1 ; \
 	done
 	@echo 'All done"'
 
@@ -103,7 +109,6 @@
   $(1)-to-$(2)_tar = $$(RESULT)/sdk-$(1)-to-$(2)-$$(today).tar.gz
   $$($(1)-to-$(2)_tar) : PLATFORM = $(1)-to-$(2)
   TARFILES += $$($(1)-to-$(2)_tar)
-  $$($(1)-to-$(2)_tar) : $$(shell find $$(RESULT)/$(1)-to-$(2) -type f)
 endef
 
 $(foreach p,$(host_platforms),$(foreach t,$(target_platforms),$(eval $(call Mktar,$(p),$(t)))))
@@ -111,9 +116,7 @@
 tars : all $(TARFILES)
 onlytars : $(TARFILES)
 %.tar.gz :
-	@echo 'Creating compiler package $@'
-	cd $(RESULT) && tar -czf $@ $(PLATFORM)/*
-	touch $@
+	$(MAKE) -r -f Tars.gmk SRC_DIR=$(RESULT)/$(PLATFORM) TAR_FILE=$@
 
 clean :
 	rm -rf $(addprefix ../../build/devkit/, result $(host_platforms))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/devkit/Tars.gmk	Thu Mar 28 22:06:05 2019 +0100
@@ -0,0 +1,49 @@
+#
+# 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
+# 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 makefile creates the tar files. It needs to be called with make -r
+# which is why it's separated out into its own file.
+
+# Input parameters
+# SRC_DIR
+# TAR_FILE
+
+ifeq ($(SRC_DIR), )
+  $(error SRC_DIR not set)
+endif
+ifeq ($(TAR_FILE), )
+  $(error TAR_FILE not set)
+endif
+
+default: tars
+
+tars : $(TAR_FILE)
+
+$(TAR_FILE): $(shell find $(SRC_DIR) -type f)
+	@echo 'Creating compiler package $@'
+	cd $(dir $(SRC_DIR)) && tar -czf $@ $(notdir $(SRC_DIR))/*
+	touch $@
+
+.PHONY: default tars
--- a/make/devkit/Tools.gmk	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/devkit/Tools.gmk	Thu Mar 28 22:06:05 2019 +0100
@@ -51,9 +51,9 @@
 
 $(info ARCH=$(ARCH))
 
-ifeq ($(BASE_OS), OEL6)
+ifeq ($(BASE_OS), OL)
   BASE_URL := http://yum.oracle.com/repo/OracleLinux/OL6/4/base/$(ARCH)/
-  LINUX_VERSION := OEL6.4
+  LINUX_VERSION := OL6.4
 else ifeq ($(BASE_OS), Fedora)
   DEFAULT_OS_VERSION := 27
   ifeq ($(BASE_OS_VERSION), )
@@ -79,8 +79,17 @@
 # Define external dependencies
 
 # Latest that could be made to work.
-GCC_VER := 7.3.0
-ifeq ($(GCC_VER), 7.3.0)
+GCC_VER := 8.2.0
+ifeq ($(GCC_VER), 8.2.0)
+  gcc_ver := gcc-8.2.0
+  binutils_ver := binutils-2.30
+  ccache_ver := ccache-3.5.1a
+  CCACHE_DIRNAME := ccache-3.5.1
+  mpfr_ver := mpfr-3.1.5
+  gmp_ver := gmp-6.1.2
+  mpc_ver := mpc-1.0.3
+  gdb_ver := gdb-8.2.1
+else ifeq ($(GCC_VER), 7.3.0)
   gcc_ver := gcc-7.3.0
   binutils_ver := binutils-2.30
   ccache_ver := ccache-3.3.6
@@ -174,14 +183,16 @@
 
 # Generate downloading + unpacking of sources.
 define Download
-  $(1)_DIR = $(abspath $(SRCDIR)/$(basename $(basename $(notdir $($(1))))))
+  # Allow override
+  $(1)_DIRNAME ?= $(basename $(basename $(notdir $($(1)))))
+  $(1)_DIR = $(abspath $(SRCDIR)/$$($(1)_DIRNAME))
   $(1)_CFG = $$($(1)_DIR)/configure
   $(1)_FILE = $(DOWNLOAD)/$(notdir $($(1)))
 
   $$($(1)_CFG) : $$($(1)_FILE)
 	mkdir -p $$(SRCDIR)
 	tar -C $$(SRCDIR) -xf $$<
-	$$(foreach p,$$(abspath $$(wildcard $$(notdir $$($(1)_DIR)).patch)), \
+	$$(foreach p,$$(abspath $$(wildcard patches/$$(notdir $$($(1)_DIR)).patch)), \
 	  echo PATCHING $$(p) ; \
 	  patch -d $$($(1)_DIR) -p1 -i $$(p) ; \
 	)
@@ -370,7 +381,7 @@
 	      --disable-nls \
 	      --program-prefix=$(TARGET)- \
 	      --enable-multilib \
-	      --enable-gold \
+	      --enable-gold=default \
 	      --enable-threads \
 	      --enable-plugins \
 	) > $(@D)/log.config 2>&1
--- a/make/hotspot/lib/JvmFeatures.gmk	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/hotspot/lib/JvmFeatures.gmk	Thu Mar 28 22:06:05 2019 +0100
@@ -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
@@ -47,6 +47,9 @@
 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 ($(ENABLE_LIBFFI_BUNDLING), true)
+    JVM_LDFLAGS_FEATURES += $(call SET_EXECUTABLE_ORIGIN,/..)
+  endif
   ifeq ($(call isTargetCpu, sparcv9), true)
     BUILD_LIBJVM_EXTRA_FILES := $(TOPDIR)/src/hotspot/cpu/sparc/memset_with_concurrent_readers_sparc.cpp
   endif
@@ -123,7 +126,7 @@
   JVM_CFLAGS_FEATURES += -DINCLUDE_NMT=0
   JVM_EXCLUDE_FILES += \
       memBaseline.cpp memReporter.cpp mallocTracker.cpp virtualMemoryTracker.cpp nmtCommon.cpp \
-      memTracker.cpp nmtDCmd.cpp mallocSiteTable.cpp
+      memTracker.cpp nmtDCmd.cpp mallocSiteTable.cpp threadStackTracker.cpp
 endif
 
 ifneq ($(call check-jvm-feature, aot), true)
--- a/make/lib/Awt2dLibraries.gmk	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/lib/Awt2dLibraries.gmk	Thu Mar 28 22:06:05 2019 +0100
@@ -536,7 +536,8 @@
 
 ifeq ($(call isTargetOs, windows), false)
   HARFBUZZ_CFLAGS += -DGETPAGESIZE -DHAVE_MPROTECT -DHAVE_PTHREAD \
-                      -DHAVE_SYSCONF -DHAVE_SYS_MMAN_H -DHAVE_UNISTD_H
+                      -DHAVE_SYSCONF -DHAVE_SYS_MMAN_H -DHAVE_UNISTD_H \
+                      -DHB_NO_PRAGMA_GCC_DIAGNOSTIC
 endif
 ifeq ($(call isTargetOs, linux macosx), true)
   HARFBUZZ_CFLAGS += -DHAVE_INTEL_ATOMIC_PRIMITIVES
@@ -613,8 +614,7 @@
         type-limits missing-field-initializers implicit-fallthrough \
         strict-aliasing undef unused-function, \
     DISABLED_WARNINGS_CXX_gcc := reorder delete-non-virtual-dtor strict-overflow \
-        maybe-uninitialized \
-        missing-attributes class-memaccess, \
+        maybe-uninitialized class-memaccess, \
     DISABLED_WARNINGS_clang := unused-value incompatible-pointer-types \
         tautological-constant-out-of-range-compare int-to-pointer-cast \
         sign-compare undef missing-field-initializers, \
@@ -624,8 +624,8 @@
         E_ENUM_VAL_OVERFLOWS_INT_MAX, \
     DISABLED_WARNINGS_CXX_solstudio := \
         truncwarn wvarhidenmem wvarhidemem wbadlkginit identexpected \
-        hidevf w_novirtualdescr arrowrtn2, \
-    DISABLED_WARNINGS_microsoft := 4267 4244 4018 4090 4996 4146 4334 4819 4101, \
+        hidevf w_novirtualdescr arrowrtn2 refmemnoconstr_aggr unknownpragma, \
+    DISABLED_WARNINGS_microsoft := 4267 4244 4018 4090 4996 4146 4334 4819 4101 4068 4805 4138, \
     LDFLAGS := $(subst -Xlinker -z -Xlinker defs,, \
         $(subst -Wl$(COMMA)-z$(COMMA)defs,,$(LDFLAGS_JDKLIB))) $(LDFLAGS_CXX_JDK) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
--- a/make/scripts/compare.sh	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/scripts/compare.sh	Thu Mar 28 22:06:05 2019 +0100
@@ -202,15 +202,20 @@
             $SED -e '/[<>].*[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}.*/d')
     fi
     if test "x$SUFFIX" = "xhtml"; then
-	# Some javadoc versions do not put quotes around font size
-	HTML_FILTER="$SED \
+        # Some javadoc versions do not put quotes around font size
+        HTML_FILTER="$SED \
             -e 's/<font size=-1>/<font size=\"-1\">/g'"
-	$CAT $THIS_FILE | eval "$HTML_FILTER" > $THIS_FILE.filtered
-	$CAT $OTHER_FILE | eval "$HTML_FILTER" > $OTHER_FILE.filtered
+        $CAT $THIS_FILE | eval "$HTML_FILTER" > $THIS_FILE.filtered
+        $CAT $OTHER_FILE | eval "$HTML_FILTER" > $OTHER_FILE.filtered
         TMP=$(LC_ALL=C $DIFF $OTHER_FILE.filtered $THIS_FILE.filtered | \
             $GREP '^[<>]' | \
             $SED -e '/[<>] <!-- Generated by javadoc .* on .* -->/d' \
-	         -e '/[<>] <meta name="date" content=".*">/d' )
+                 -e '/[<>] <meta name="date" content=".*">/d' )
+    fi
+    if test "$NAME" = "BenchmarkList"; then
+        $SORT $THIS_FILE > $THIS_FILE.sorted
+        $SORT $OTHER_FILE > $OTHER_FILE.sorted
+        TMP=$($DIFF $THIS_FILE.sorted $OTHER_FILE.sorted)
     fi
     if test -n "$TMP"; then
         echo Files $OTHER_FILE and $THIS_FILE differ
@@ -382,17 +387,19 @@
         ! -name "*.zip" ! -name "*.debuginfo" ! -name "*.dylib" ! -name "jexec" \
         ! -name "modules" ! -name "ct.sym" ! -name "*.diz" ! -name "*.dll" \
         ! -name "*.cpl" ! -name "*.pdb" ! -name "*.exp" ! -name "*.ilk" \
-        ! -name "*.lib" ! -name "*.war" ! -name "JavaControlPanel" ! -name "*.jmod" \
-        ! -name "*.obj" ! -name "*.o" ! -name "JavaControlPanelHelper" \
-        ! -name "JavaUpdater" ! -name "JavaWSApplicationStub" \
-        ! -name "jspawnhelper" ! -name "JavawsLauncher" ! -name "*.a" \
-        ! -name "finish_installation" ! -name "Sparkle" ! -name "*.tar.gz" \
-        ! -name "classes.jsa" \
+        ! -name "*.lib" ! -name "*.war" ! -name "*.jmod" ! -name "*.exe" \
+        ! -name "*.obj" ! -name "*.o" ! -name "jspawnhelper" ! -name "*.a" \
+        ! -name "*.tar.gz" ! -name "classes.jsa" ! -name "gtestLauncher" \
+        ! -name "*.map" \
         | $GREP -v "./bin/"  | $SORT | $FILTER)
 
     echo Other files with binary differences...
     for f in $GENERAL_FILES
     do
+        # Skip all files in test/*/native
+        if [[ "$f" == */native/* ]]; then
+            continue
+        fi
         if [ -e $OTHER_DIR/$f ]; then
             SUFFIX="${f##*.}"
             if [ "$(basename $f)" = "release" ]; then
@@ -431,7 +438,7 @@
                 $CAT $OTHER_DIR/$f | eval "$HTML_FILTER" > $OTHER_FILE &
                 $CAT $THIS_DIR/$f  | eval "$HTML_FILTER" > $THIS_FILE &
                 wait
-            elif [[ "$f" = *"/lib/classlist" ]]; then
+            elif [[ "$f" = *"/lib/classlist" ]] || [ "$SUFFIX" = "jar_contents" ]; then
                 # The classlist files may have some lines in random order
                 OTHER_FILE=$WORK_DIR/$f.other
                 THIS_FILE=$WORK_DIR/$f.this
@@ -792,14 +799,14 @@
         export _NT_SYMBOL_PATH="$(echo $PDB_DIRS | tr ' ' ';')"
     fi
 
+    if cmp $OTHER_FILE $THIS_FILE > /dev/null; then
+        # The files were bytewise identical.
+        if [ -n "$VERBOSE" ]; then
+            echo "        :           :         :         :          :          : $BIN_FILE"
+        fi
+        return 0
+    fi
     if [ -z "$SKIP_BIN_DIFF" ]; then
-        if cmp $OTHER_FILE $THIS_FILE > /dev/null; then
-        # The files were bytewise identical.
-            if [ -n "$VERBOSE" ]; then
-                echo "        :           :         :         :          :          : $BIN_FILE"
-            fi
-            return 0
-        fi
         BIN_MSG=" diff "
         if [[ "$ACCEPTED_BIN_DIFF" != *"$BIN_FILE"* ]]; then
             DIFF_BIN=true
@@ -826,7 +833,8 @@
         DIFF_SIZE_NUM=$($EXPR $THIS_SIZE - $OTHER_SIZE)
         DIFF_SIZE_REL=$($EXPR $THIS_SIZE \* 100 / $OTHER_SIZE)
         SIZE_MSG=$($PRINTF "%3d%% %4d" $DIFF_SIZE_REL $DIFF_SIZE_NUM)
-        if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] && [ "$DIFF_SIZE_REL" -gt 98 ] \
+        if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* || "$ACCEPTED_SMALL_SIZE_DIFF" = "true" ]] \
+            && [ "$DIFF_SIZE_REL" -gt 98 ] \
             && [ "$DIFF_SIZE_REL" -lt 102 ]; then
             SIZE_MSG="($SIZE_MSG)"
             DIFF_SIZE=
@@ -1440,13 +1448,8 @@
         echo
     fi
 
-
     # Find the common images to compare, prioritizing later build stages
-    if [ -d "$THIS/install/jdk" ] && [ -d "$OTHER/install/jdk" ]; then
-        THIS_JDK="$THIS/install/jdk"
-        OTHER_JDK="$OTHER/install/jdk"
-        echo "Selecting install images for JDK compare"
-    elif [ -d "$THIS/images/jdk" ] && [ -d "$OTHER/images/jdk" ]; then
+    if [ -d "$THIS/images/jdk" ] && [ -d "$OTHER/images/jdk" ]; then
         THIS_JDK="$THIS/images/jdk"
         OTHER_JDK="$OTHER/images/jdk"
         echo "Selecting normal images for JDK compare"
@@ -1475,63 +1478,22 @@
     echo "  $OTHER_JDK"
 
     if [ -d "$THIS/images/jdk-bundle" -o -d "$THIS/deploy/images/jdk-bundle" ] \
-	     && [ -d "$OTHER/images/jdk-bundle" -o -d "$OTHER/deploy/images/jdk-bundle" ]; then
-	if [ -d "$THIS/deploy/images/jdk-bundle" ]; then
+             && [ -d "$OTHER/images/jdk-bundle" -o -d "$OTHER/deploy/images/jdk-bundle" ]; then
+        if [ -d "$THIS/deploy/images/jdk-bundle" ]; then
             THIS_JDK_BUNDLE="$THIS/deploy/images/jdk-bundle"
-	else
+        else
             THIS_JDK_BUNDLE="$THIS/images/jdk-bundle"
-	fi
-	if [ -d "$OTHER/deploy/images/jdk-bundle" ]; then
+        fi
+        if [ -d "$OTHER/deploy/images/jdk-bundle" ]; then
             OTHER_JDK_BUNDLE="$OTHER/deploy/images/jdk-bundle"
-	else
+        else
             OTHER_JDK_BUNDLE="$OTHER/images/jdk-bundle"
-	fi
+        fi
         echo "Also comparing jdk macosx bundles"
         echo "  $THIS_JDK_BUNDLE"
         echo "  $OTHER_JDK_BUNDLE"
     fi
 
-    if [ -d "$THIS/deploy/bundles" -o -d "$THIS/deploy/images/bundles" ] \
-	     && [ -d "$OTHER/deploy/bundles" -o -d "$OTHER/deploy/images/bundles" ]; then
-	if [ -d "$THIS/deploy/images/bundles" ]; then
-            THIS_DEPLOY_BUNDLE_DIR="$THIS/deploy/images/bundles"
-	else
-            THIS_DEPLOY_BUNDLE_DIR="$THIS/deploy/bundles"
-	fi
-	if [ -d "$OTHER/deploy/images/bundles" ]; then
-            OTHER_DEPLOY_BUNDLE_DIR="$OTHER/deploy/images/bundles"
-	else
-            OTHER_DEPLOY_BUNDLE_DIR="$OTHER/deploy/bundles"
-	fi
-        echo "Also comparing deploy javadoc bundles"
-    fi
-
-    if [ -d "$THIS/images/JavaAppletPlugin.plugin" ] \
-	     && [ -d "$OTHER/images/JavaAppletPlugin.plugin" -o -d "$OTHER/deploy/images/JavaAppletPlugin.plugin" ]; then
-	if [ -d "$THIS/images/JavaAppletPlugin.plugin" ]; then
-            THIS_DEPLOY_APPLET_PLUGIN_DIR="$THIS/images/JavaAppletPlugin.plugin"
-	else
-            THIS_DEPLOY_APPLET_PLUGIN_DIR="$THIS/deploy/images/JavaAppletPlugin.plugin"
-	fi
-	if [ -d "$OTHER/images/JavaAppletPlugin.plugin" ]; then
-            OTHER_DEPLOY_APPLET_PLUGIN_DIR="$OTHER/images/JavaAppletPlugin.plugin"
-	else
-            OTHER_DEPLOY_APPLET_PLUGIN_DIR="$OTHER/deploy/images/JavaAppletPlugin.plugin"
-	fi
-        echo "Also comparing deploy applet image"
-        echo "  $THIS_DEPLOY_APPLET_PLUGIN_DIR"
-        echo "  $OTHER_DEPLOY_APPLET_PLUGIN_DIR"
-    fi
-
-    if [ -d "$THIS/install/sparkle/Sparkle.framework" ] \
-           && [ -d "$OTHER/install/sparkle/Sparkle.framework" ]; then
-        THIS_SPARKLE_DIR="$THIS/install/sparkle/Sparkle.framework"
-        OTHER_SPARKLE_DIR="$OTHER/install/sparkle/Sparkle.framework"
-        echo "Also comparing install sparkle framework"
-        echo "  $THIS_SPARKLE_DIR"
-        echo "  $OTHER_SPARKLE_DIR"
-    fi
-
     THIS_SEC_DIR="$THIS/images"
     OTHER_SEC_DIR="$OTHER/images"
     if [ -f "$THIS_SEC_DIR/sec-bin.zip" ] && [ -f "$OTHER_SEC_DIR/sec-bin.zip" ]; then
@@ -1557,6 +1519,14 @@
     else
         echo "WARNING! Docs haven't been built and won't be compared."
     fi
+
+    if [ -d "$THIS/images/test" ] && [ -d "$OTHER/images/test" ]; then
+        THIS_TEST="$THIS/images/test"
+        OTHER_TEST="$OTHER/images/test"
+        echo "Also comparing test image"
+    else
+        echo "WARNING! Test haven't been built and won't be compared."
+    fi
 fi
 
 ################################################################################
@@ -1582,22 +1552,16 @@
         echo -n "Docs "
         compare_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
     fi
+    if [ -n "$THIS_TEST" ] && [ -n "$OTHER_TEST" ]; then
+        echo -n "Test "
+        compare_dirs $THIS_TEST $OTHER_TEST $COMPARE_ROOT/test
+        echo -n "Test "
+        compare_files $THIS_TEST $OTHER_TEST $COMPARE_ROOT/test
+    fi
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_dirs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
         compare_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        echo -n "JavaAppletPlugin "
-        compare_dirs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-        echo -n "JavaAppletPlugin "
-        compare_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
-    if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
-        echo -n "Sparkle.framework "
-        compare_dirs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
-        echo -n "Sparkle.framework "
-        compare_files $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
-    fi
 fi
 
 if [ "$CMP_LIBS" = "true" ]; then
@@ -1605,34 +1569,38 @@
         echo -n "JDK "
         compare_all_libs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
     fi
+    if [ -n "$THIS_TEST" ] && [ -n "$OTHER_TEST" ]; then
+        echo -n "Test "
+        # Test native libs are never stripped so will not compare well.
+        SKIP_BIN_DIFF="true"
+        ACCEPTED_SMALL_SIZE_DIFF_bak="$ACCEPTED_SMALL_SIZE_DIFF"
+        if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
+            ACCEPTED_SMALL_SIZE_DIFF="true"
+        fi
+        compare_all_libs $THIS_TEST $OTHER_TEST $COMPARE_ROOT/test
+        SKIP_BIN_DIFF="false"
+        ACCEPTED_SMALL_SIZE_DIFF="$ACCEPTED_SMALL_SIZE_DIFF_bak"
+    fi
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_all_libs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        echo -n "JavaAppletPlugin "
-        compare_all_libs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
-    if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
-        echo -n "Sparkle.framework "
-        compare_all_libs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
-    fi
 fi
 
 if [ "$CMP_EXECS" = "true" ]; then
     if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
+        echo -n "JDK "
         compare_all_execs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
     fi
+    if [ -n "$THIS_TEST" ] && [ -n "$OTHER_TEST" ]; then
+        echo -n "Test "
+        # Test native executables are never stripped so will not compare well.
+        SKIP_BIN_DIFF="true"
+        compare_all_execs $THIS_TEST $OTHER_TEST $COMPARE_ROOT/test
+        SKIP_BIN_DIFF="false"
+    fi
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_all_execs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        echo -n "JavaAppletPlugin "
-        compare_all_execs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
-    if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
-        echo -n "Sparkle.framework "
-        compare_all_execs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
-    fi
 fi
 
 if [ "$CMP_GENERAL" = "true" ]; then
@@ -1648,23 +1616,24 @@
         echo -n "Docs "
         compare_general_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
     fi
+    if [ -n "$THIS_TEST" ] && [ -n "$OTHER_TEST" ]; then
+        echo -n "Test "
+        compare_general_files $THIS_TEST $OTHER_TEST $COMPARE_ROOT/test
+    fi
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_general_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        echo -n "JavaAppletPlugin "
-        compare_general_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
-    if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
-        echo -n "Sparkle.framework "
-        compare_general_files $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
-    fi
 fi
 
 if [ "$CMP_ZIPS" = "true" ]; then
     if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
+        echo -n "JDK "
         compare_all_zip_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
     fi
+    if [ -n "$THIS_TEST" ] && [ -n "$OTHER_TEST" ]; then
+        echo -n "Test "
+        compare_all_zip_files $THIS_TEST $OTHER_TEST $COMPARE_ROOT/test
+    fi
     if [ -n "$THIS_SEC_BIN" ] && [ -n "$OTHER_SEC_BIN" ]; then
         if [ -n "$(echo $THIS_SEC_BIN | $FILTER)" ]; then
             echo "sec-bin.zip..."
@@ -1686,24 +1655,20 @@
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_all_zip_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_BUNDLE_DIR" ] && [ -n "$OTHER_DEPLOY_BUNDLE_DIR" ]; then
-        compare_all_zip_files $THIS_DEPLOY_BUNDLE_DIR $OTHER_DEPLOY_BUNDLE_DIR $COMPARE_ROOT/deploy-bundle
-    fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        compare_all_zip_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
 fi
 
 if [ "$CMP_JARS" = "true" ]; then
     if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
+        echo -n "JDK "
         compare_all_jar_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
     fi
+    if [ -n "$THIS_TEST" ] && [ -n "$OTHER_TEST" ]; then
+        echo -n "Test "
+        compare_all_jar_files $THIS_TEST $OTHER_TEST $COMPARE_ROOT/test
+    fi
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_all_jar_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        compare_all_jar_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
 fi
 
 if [ "$CMP_JMODS" = "true" ]; then
@@ -1723,14 +1688,6 @@
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_permissions $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        echo -n "JavaAppletPlugin "
-        compare_permissions $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
-    if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
-        echo -n "Sparkle.framework "
-        compare_permissions $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
-    fi
 fi
 
 if [ "$CMP_TYPES" = "true" ]; then
@@ -1742,17 +1699,13 @@
         echo -n "JDK Bundle "
         compare_file_types $THIS_JDK_BUNDLE $OTHER_JDK_BUNDLE $COMPARE_ROOT/jdk-bundle
     fi
+    if [ -n "$THIS_TEST" ] && [ -n "$OTHER_TEST" ]; then
+        echo -n "Test "
+        compare_file_types $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
+    fi
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_file_types $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        echo -n "JavaAppletPlugin "
-        compare_file_types $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
-    if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
-        echo -n "Sparkle.framework "
-        compare_file_types $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
-    fi
 fi
 
 echo
--- a/make/scripts/compare_exceptions.sh.incl	Thu Mar 14 22:05:45 2019 +0100
+++ b/make/scripts/compare_exceptions.sh.incl	Thu Mar 28 22:06:05 2019 +0100
@@ -38,6 +38,7 @@
 if [ "$OPENJDK_TARGET_OS" = "linux" ]; then
   ACCEPTED_BIN_DIFF="
       ./lib/server/libjvm.so
+      ./hotspot/gtest/server/libjvm.so
       "
 elif [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
   SKIP_BIN_DIFF="true"
@@ -49,6 +50,7 @@
       ./lib/libunpack.so
       ./lib/server/libjvm.so
       ./bin/unpack200
+      ./hotspot/gtest/server/libjvm.so
       "
   KNOWN_DIS_DIFF="
       ./lib/libfontmanager.so
@@ -68,5 +70,6 @@
       ./lib/libosxapp.dylib
       ./lib/libosxui.dylib
       ./lib/server/libjvm.dylib
+      ./hotspot/gtest/server/libjvm.dylib
       "
 fi
--- a/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -72,15 +72,12 @@
 }
 
 void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
-                                                             Register start, Register end, Register scratch, RegSet saved_regs) {
+                                                             Register start, Register count, Register scratch, RegSet saved_regs) {
   __ push(saved_regs, sp);
-  // must compute element count unless barrier set interface is changed (other platforms supply count)
-  assert_different_registers(start, end, scratch);
-  __ lea(scratch, Address(end, BytesPerHeapOop));
-  __ sub(scratch, scratch, start);               // subtract start to get #bytes
-  __ lsr(scratch, scratch, LogBytesPerHeapOop);  // convert to element count
+  assert_different_registers(start, count, scratch);
+  assert_different_registers(c_rarg0, count);
   __ mov(c_rarg0, start);
-  __ mov(c_rarg1, scratch);
+  __ mov(c_rarg1, count);
   __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_post_entry), 2);
   __ pop(saved_regs, sp);
 }
--- a/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -39,7 +39,7 @@
   void gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators,
                                        Register addr, Register count, RegSet saved_regs);
   void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
-                                        Register start, Register end, Register tmp, RegSet saved_regs);
+                                        Register start, Register count, Register tmp, RegSet saved_regs);
 
   void g1_write_barrier_pre(MacroAssembler* masm,
                             Register obj,
--- a/src/hotspot/cpu/aarch64/gc/shared/cardTableBarrierSetAssembler_aarch64.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/cpu/aarch64/gc/shared/cardTableBarrierSetAssembler_aarch64.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -62,18 +62,22 @@
 }
 
 void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
-                                                                    Register start, Register end, Register scratch, RegSet saved_regs) {
+                                                                    Register start, Register count, Register scratch, RegSet saved_regs) {
   BarrierSet* bs = BarrierSet::barrier_set();
   CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
   CardTable* ct = ctbs->card_table();
 
-  Label L_loop;
+  Label L_loop, L_done;
+  const Register end = count;
 
+  __ cbz(count, L_done); // zero count - nothing to do
+
+  __ lea(end, Address(start, count, Address::lsl(LogBytesPerHeapOop))); // end = start + count << LogBytesPerHeapOop
+  __ sub(end, end, BytesPerHeapOop); // last element address to make inclusive
   __ lsr(start, start, CardTable::card_shift);
   __ lsr(end, end, CardTable::card_shift);
-  __ sub(end, end, start); // number of bytes to copy
+  __ sub(count, end, start); // number of bytes to copy
 
-  const Register count = end; // 'end' register contains bytes count now
   __ load_byte_map_base(scratch);
   __ add(start, start, scratch);
   if (ct->scanned_concurrently()) {
@@ -83,6 +87,7 @@
   __ strb(zr, Address(start, count));
   __ subs(count, count, 1);
   __ br(Assembler::GE, L_loop);
+  __ bind(L_done);
 }
 
 void CardTableBarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
--- a/src/hotspot/cpu/aarch64/gc/shared/cardTableBarrierSetAssembler_aarch64.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/cpu/aarch64/gc/shared/cardTableBarrierSetAssembler_aarch64.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -33,7 +33,7 @@
   void store_check(MacroAssembler* masm, Register obj, Address dst);
 
   virtual void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
-                                                Register start, Register end, Register tmp, RegSet saved_regs);
+                                                Register start, Register count, Register tmp, RegSet saved_regs);
   virtual void oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
                             Address dst, Register val, Register tmp1, Register tmp2);
 
--- a/src/hotspot/cpu/aarch64/gc/shared/modRefBarrierSetAssembler_aarch64.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/cpu/aarch64/gc/shared/modRefBarrierSetAssembler_aarch64.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -37,10 +37,10 @@
 }
 
 void ModRefBarrierSetAssembler::arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
-                                                   Register start, Register end, Register tmp,
+                                                   Register start, Register count, Register tmp,
                                                    RegSet saved_regs) {
   if (is_oop) {
-    gen_write_ref_array_post_barrier(masm, decorators, start, end, tmp, saved_regs);
+    gen_write_ref_array_post_barrier(masm, decorators, start, count, tmp, saved_regs);
   }
 }
 
--- a/src/hotspot/cpu/aarch64/gc/shared/modRefBarrierSetAssembler_aarch64.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/cpu/aarch64/gc/shared/modRefBarrierSetAssembler_aarch64.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -37,7 +37,7 @@
   virtual void gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators,
                                                Register addr, Register count, RegSet saved_regs) {}
   virtual void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
-                                                Register start, Register end, Register tmp, RegSet saved_regs) {}
+                                                Register start, Register count, Register tmp, RegSet saved_regs) {}
 
   virtual void oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
                             Address dst, Register val, Register tmp1, Register tmp2) = 0;
@@ -46,7 +46,7 @@
   virtual void arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
                                   Register addr, Register count, RegSet saved_regs);
   virtual void arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
-                                  Register start, Register end, Register tmp, RegSet saved_regs);
+                                  Register start, Register count, Register tmp, RegSet saved_regs);
   virtual void store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
                         Address dst, Register val, Register tmp1, Register tmp2);
 };
--- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -73,16 +73,13 @@
 }
 
 void ShenandoahBarrierSetAssembler::arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
-                                                       Register start, Register end, Register scratch, RegSet saved_regs) {
+                                                       Register start, Register count, Register scratch, RegSet saved_regs) {
   if (is_oop) {
     __ push(saved_regs, sp);
-    // must compute element count unless barrier set interface is changed (other platforms supply count)
-    assert_different_registers(start, end, scratch);
-    __ lea(scratch, Address(end, BytesPerHeapOop));
-    __ sub(scratch, scratch, start);               // subtract start to get #bytes
-    __ lsr(scratch, scratch, LogBytesPerHeapOop);  // convert to element count
+    assert_different_registers(start, count, scratch);
+    assert_different_registers(c_rarg0, count);
     __ mov(c_rarg0, start);
-    __ mov(c_rarg1, scratch);
+    __ mov(c_rarg1, count);
     __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_array_post_entry), 2);
     __ pop(saved_regs, sp);
   }
--- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -78,7 +78,7 @@
   virtual void arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
                                   Register addr, Register count, RegSet saved_regs);
   virtual void arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
-                                  Register start, Register end, Register tmp, RegSet saved_regs);
+                                  Register start, Register count, Register tmp, RegSet saved_regs);
   virtual void load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
                        Register dst, Address src, Register tmp1, Register tmp_thread);
   virtual void store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
--- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -1375,8 +1375,6 @@
       __ pop(RegSet::of(d, count), sp);
       if (VerifyOops)
         verify_oop_array(size, d, count, r16);
-      __ sub(count, count, 1); // make an inclusive end pointer
-      __ lea(count, Address(d, count, Address::lsl(exact_log2(size))));
     }
 
     bs->arraycopy_epilogue(_masm, decorators, is_oop, d, count, rscratch1, RegSet());
@@ -1448,8 +1446,6 @@
       __ pop(RegSet::of(d, count), sp);
       if (VerifyOops)
         verify_oop_array(size, d, count, r16);
-      __ sub(count, count, 1); // make an inclusive end pointer
-      __ lea(count, Address(d, count, Address::lsl(exact_log2(size))));
     }
     bs->arraycopy_epilogue(_masm, decorators, is_oop, d, count, rscratch1, RegSet());
     __ leave();
@@ -1842,8 +1838,7 @@
     __ br(Assembler::EQ, L_done_pop);
 
     __ BIND(L_do_card_marks);
-    __ add(to, to, -heapOopSize);         // make an inclusive end pointer
-    bs->arraycopy_epilogue(_masm, decorators, is_oop, start_to, to, rscratch1, wb_post_saved_regs);
+    bs->arraycopy_epilogue(_masm, decorators, is_oop, start_to, count_save, rscratch1, wb_post_saved_regs);
 
     __ bind(L_done_pop);
     __ pop(RegSet::of(r18, r19, r20, r21), sp);
--- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -2885,7 +2885,7 @@
   {
     Label notVolatile;
     __ tbz(r5, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
-    __ membar(MacroAssembler::StoreLoad);
+    __ membar(MacroAssembler::StoreLoad | MacroAssembler::StoreStore);
     __ bind(notVolatile);
   }
 }
@@ -3029,7 +3029,7 @@
   {
     Label notVolatile;
     __ tbz(r3, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
-    __ membar(MacroAssembler::StoreLoad);
+    __ membar(MacroAssembler::StoreLoad | MacroAssembler::StoreStore);
     __ bind(notVolatile);
   }
 }
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -1455,13 +1455,11 @@
           break;
       }
     } else {
-      if (opr2->is_address()) {
-        DEBUG_ONLY( Unimplemented(); ) // Seems to be unused at the moment.
-        LIR_Address *addr = opr2->as_address_ptr();
-        BasicType type = addr->type();
-        if (type == T_OBJECT) { __ ld(R0, index_or_disp(addr), addr->base()->as_register()); }
-        else                  { __ lwa(R0, index_or_disp(addr), addr->base()->as_register()); }
-        __ cmpd(BOOL_RESULT, opr1->as_register(), R0);
+      assert(opr1->type() != T_ADDRESS && opr2->type() != T_ADDRESS, "currently unsupported");
+      if (opr1->type() == T_OBJECT || opr1->type() == T_ARRAY) {
+        // There are only equal/notequal comparisons on objects.
+        assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "oops");
+        __ cmpd(BOOL_RESULT, opr1->as_register(), opr2->as_register());
       } else {
         if (unsigned_comp) {
           __ cmplw(BOOL_RESULT, opr1->as_register(), opr2->as_register());
@@ -1497,14 +1495,6 @@
     } else {
       ShouldNotReachHere();
     }
-  } else if (opr1->is_address()) {
-    DEBUG_ONLY( Unimplemented(); ) // Seems to be unused at the moment.
-    LIR_Address * addr = opr1->as_address_ptr();
-    BasicType type = addr->type();
-    assert (opr2->is_constant(), "Checking");
-    if (type == T_OBJECT) { __ ld(R0, index_or_disp(addr), addr->base()->as_register()); }
-    else                  { __ lwa(R0, index_or_disp(addr), addr->base()->as_register()); }
-    __ cmpdi(BOOL_RESULT, R0, opr2->as_constant_ptr()->as_jint());
   } else {
     ShouldNotReachHere();
   }
--- a/src/hotspot/cpu/x86/crc32c.h	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/cpu/x86/crc32c.h	Thu Mar 28 22:06:05 2019 +0100
@@ -1,5 +1,5 @@
 /*
-* 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
@@ -22,6 +22,9 @@
 *
 */
 
+#ifndef CPU_X86_CRC32C_H
+#define CPU_X86_CRC32C_H
+
 enum {
   // S. Gueron / Information Processing Letters 112 (2012) 184
   // shows than anything above 6K and below 32K is a good choice
@@ -64,3 +67,5 @@
 // a) constants table generation (hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp)
 // b) constant fetch from that table (macroAssembler_x86.cpp)
 // c) unrolled for loop (macroAssembler_x86.cpp)
+
+#endif /* !CPU_X86_CRC32C_H */
--- a/src/hotspot/cpu/x86/vm_version_x86.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/cpu/x86/vm_version_x86.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -901,11 +901,15 @@
     FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
   }
 
+#ifdef _LP64
+  // These are only supported on 64-bit
   if (UseSHA && supports_avx2() && supports_bmi2()) {
     if (FLAG_IS_DEFAULT(UseSHA512Intrinsics)) {
       FLAG_SET_DEFAULT(UseSHA512Intrinsics, true);
     }
-  } else if (UseSHA512Intrinsics) {
+  } else
+#endif
+  if (UseSHA512Intrinsics) {
     warning("Intrinsics for SHA-384 and SHA-512 crypto hash functions not available on this CPU.");
     FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
   }
--- a/src/hotspot/os/aix/os_aix.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os/aix/os_aix.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -37,6 +37,7 @@
 #include "compiler/compileBroker.hpp"
 #include "interpreter/interpreter.hpp"
 #include "logging/log.hpp"
+#include "logging/logStream.hpp"
 #include "libo4.hpp"
 #include "libperfstat_aix.hpp"
 #include "libodm_aix.hpp"
@@ -923,6 +924,11 @@
     char buf[64];
     log_warning(os, thread)("Failed to start thread - pthread_create failed (%d=%s) for attributes: %s.",
       ret, os::errno_name(ret), os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr));
+    // Log some OS information which might explain why creating the thread failed.
+    log_info(os, thread)("Number of threads approx. running in the VM: %d", Threads::number_of_threads());
+    LogStream st(Log(os, thread)::info());
+    os::Posix::print_rlimit_info(&st);
+    os::print_memory_info(&st);
   }
 
   pthread_attr_destroy(&attr);
--- a/src/hotspot/os/bsd/os_bsd.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os/bsd/os_bsd.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -33,6 +33,7 @@
 #include "compiler/disassembler.hpp"
 #include "interpreter/interpreter.hpp"
 #include "logging/log.hpp"
+#include "logging/logStream.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/filemap.hpp"
 #include "oops/oop.inline.hpp"
@@ -743,6 +744,11 @@
     } else {
       log_warning(os, thread)("Failed to start thread - pthread_create failed (%s) for attributes: %s.",
         os::errno_name(ret), os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr));
+      // Log some OS information which might explain why creating the thread failed.
+      log_info(os, thread)("Number of threads approx. running in the VM: %d", Threads::number_of_threads());
+      LogStream st(Log(os, thread)::info());
+      os::Posix::print_rlimit_info(&st);
+      os::print_memory_info(&st);
     }
 
     pthread_attr_destroy(&attr);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/os/linux/gc/z/zLargePages_linux.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, 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/z/zLargePages.hpp"
+#include "runtime/globals.hpp"
+
+void ZLargePages::initialize_platform() {
+  if (UseLargePages) {
+    if (UseTransparentHugePages) {
+      _state = Transparent;
+    } else {
+      _state = Explicit;
+    }
+  } else {
+    _state = Disabled;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2016, 2017, 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 "gc/z/zErrno.hpp"
+#include "gc/z/zCPU.hpp"
+#include "gc/z/zNUMA.hpp"
+#include "runtime/os.hpp"
+#include "utilities/debug.hpp"
+
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#ifndef MPOL_F_NODE
+#define MPOL_F_NODE     (1<<0)  // Return next IL mode instead of node mask
+#endif
+
+#ifndef MPOL_F_ADDR
+#define MPOL_F_ADDR     (1<<1)  // Look up VMA using address
+#endif
+
+static int z_get_mempolicy(uint32_t* mode, const unsigned long *nmask, unsigned long maxnode, uintptr_t addr, int flags) {
+  return syscall(__NR_get_mempolicy, mode, nmask, maxnode, addr, flags);
+}
+
+void ZNUMA::initialize_platform() {
+  _enabled = UseNUMA;
+}
+
+uint32_t ZNUMA::count() {
+  if (!_enabled) {
+    // NUMA support not enabled
+    return 1;
+  }
+
+  return os::Linux::numa_max_node() + 1;
+}
+
+uint32_t ZNUMA::id() {
+  if (!_enabled) {
+    // NUMA support not enabled
+    return 0;
+  }
+
+  return os::Linux::get_node_by_cpu(ZCPU::id());
+}
+
+uint32_t ZNUMA::memory_id(uintptr_t addr) {
+  if (!_enabled) {
+    // NUMA support not enabled, assume everything belongs to node zero
+    return 0;
+  }
+
+  uint32_t id = (uint32_t)-1;
+
+  if (z_get_mempolicy(&id, NULL, 0, addr, MPOL_F_NODE | MPOL_F_ADDR) == -1) {
+    ZErrno err;
+    fatal("Failed to get NUMA id for memory at " PTR_FORMAT " (%s)", addr, err.to_string());
+  }
+
+  assert(id < count(), "Invalid NUMA id");
+
+  return id;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/os/linux/gc/z/zVirtualMemory_linux.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015, 2017, 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/z/zVirtualMemory.hpp"
+#include "logging/log.hpp"
+
+#include <sys/mman.h>
+#include <sys/types.h>
+
+bool ZVirtualMemoryManager::reserve(uintptr_t start, size_t size) {
+  // Reserve address space
+  const uintptr_t actual_start = (uintptr_t)mmap((void*)start, size, PROT_NONE,
+                                                 MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0);
+  if (actual_start != start) {
+    log_error(gc)("Failed to reserve address space for Java heap");
+    return false;
+  }
+
+  return true;
+}
--- a/src/hotspot/os/linux/osContainer_linux.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os/linux/osContainer_linux.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -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
@@ -99,14 +99,14 @@
             buf[MAXPATHLEN-1] = '\0';
             _path = os::strdup(buf);
           } else {
-            char *p = strstr(_root, cgroup_path);
+            char *p = strstr(cgroup_path, _root);
             if (p != NULL && p == _root) {
               if (strlen(cgroup_path) > strlen(_root)) {
                 int buflen;
                 strncpy(buf, _mount_point, MAXPATHLEN);
                 buf[MAXPATHLEN-1] = '\0';
                 buflen = strlen(buf);
-                if ((buflen + strlen(cgroup_path)) > (MAXPATHLEN-1)) {
+                if ((buflen + strlen(cgroup_path) - strlen(_root)) > (MAXPATHLEN-1)) {
                   return;
                 }
                 strncat(buf, cgroup_path + strlen(_root), MAXPATHLEN-buflen);
@@ -217,16 +217,11 @@
  * we are running under cgroup control.
  */
 void OSContainer::init() {
-  int mountid;
-  int parentid;
-  int major;
-  int minor;
   FILE *mntinfo = NULL;
   FILE *cgroup = NULL;
   char buf[MAXPATHLEN+1];
   char tmproot[MAXPATHLEN+1];
   char tmpmount[MAXPATHLEN+1];
-  char tmpbase[MAXPATHLEN+1];
   char *p;
   jlong mem_limit;
 
@@ -260,85 +255,24 @@
       return;
   }
 
-  while ( (p = fgets(buf, MAXPATHLEN, mntinfo)) != NULL) {
-    // Look for the filesystem type and see if it's cgroup
-    char fstype[MAXPATHLEN+1];
-    fstype[0] = '\0';
-    char *s =  strstr(p, " - ");
-    if (s != NULL &&
-        sscanf(s, " - %s", fstype) == 1 &&
-        strcmp(fstype, "cgroup") == 0) {
+  while ((p = fgets(buf, MAXPATHLEN, mntinfo)) != NULL) {
+    char tmpcgroups[MAXPATHLEN+1];
+    char *cptr = tmpcgroups;
+    char *token;
 
-      if (strstr(p, "memory") != NULL) {
-        int matched = sscanf(p, "%d %d %d:%d %s %s",
-                             &mountid,
-                             &parentid,
-                             &major,
-                             &minor,
-                             tmproot,
-                             tmpmount);
-        if (matched == 6) {
-          memory = new CgroupSubsystem(tmproot, tmpmount);
-        }
-        else
-          log_debug(os, container)("Incompatible str containing cgroup and memory: %s", p);
-      } else if (strstr(p, "cpuset") != NULL) {
-        int matched = sscanf(p, "%d %d %d:%d %s %s",
-                             &mountid,
-                             &parentid,
-                             &major,
-                             &minor,
-                             tmproot,
-                             tmpmount);
-        if (matched == 6) {
-          cpuset = new CgroupSubsystem(tmproot, tmpmount);
-        }
-        else {
-          log_debug(os, container)("Incompatible str containing cgroup and cpuset: %s", p);
-        }
-      } else if (strstr(p, "cpu,cpuacct") != NULL || strstr(p, "cpuacct,cpu") != NULL) {
-        int matched = sscanf(p, "%d %d %d:%d %s %s",
-                             &mountid,
-                             &parentid,
-                             &major,
-                             &minor,
-                             tmproot,
-                             tmpmount);
-        if (matched == 6) {
-          cpu = new CgroupSubsystem(tmproot, tmpmount);
-          cpuacct = new CgroupSubsystem(tmproot, tmpmount);
-        }
-        else {
-          log_debug(os, container)("Incompatible str containing cgroup and cpu,cpuacct: %s", p);
-        }
-      } else if (strstr(p, "cpuacct") != NULL) {
-        int matched = sscanf(p, "%d %d %d:%d %s %s",
-                             &mountid,
-                             &parentid,
-                             &major,
-                             &minor,
-                             tmproot,
-                             tmpmount);
-        if (matched == 6) {
-          cpuacct = new CgroupSubsystem(tmproot, tmpmount);
-        }
-        else {
-          log_debug(os, container)("Incompatible str containing cgroup and cpuacct: %s", p);
-        }
-      } else if (strstr(p, "cpu") != NULL) {
-        int matched = sscanf(p, "%d %d %d:%d %s %s",
-                             &mountid,
-                             &parentid,
-                             &major,
-                             &minor,
-                             tmproot,
-                             tmpmount);
-        if (matched == 6) {
-          cpu = new CgroupSubsystem(tmproot, tmpmount);
-        }
-        else {
-          log_debug(os, container)("Incompatible str containing cgroup and cpu: %s", p);
-        }
+    // mountinfo format is documented at https://www.kernel.org/doc/Documentation/filesystems/proc.txt
+    if (sscanf(p, "%*d %*d %*d:%*d %s %s %*[^-]- cgroup %*s %s", tmproot, tmpmount, tmpcgroups) != 3) {
+      continue;
+    }
+    while ((token = strsep(&cptr, ",")) != NULL) {
+      if (strcmp(token, "memory") == 0) {
+        memory = new CgroupSubsystem(tmproot, tmpmount);
+      } else if (strcmp(token, "cpuset") == 0) {
+        cpuset = new CgroupSubsystem(tmproot, tmpmount);
+      } else if (strcmp(token, "cpu") == 0) {
+        cpu = new CgroupSubsystem(tmproot, tmpmount);
+      } else if (strcmp(token, "cpuacct") == 0) {
+        cpuacct= new CgroupSubsystem(tmproot, tmpmount);
       }
     }
   }
@@ -392,30 +326,30 @@
     return;
   }
 
-  while ( (p = fgets(buf, MAXPATHLEN, cgroup)) != NULL) {
-    int cgno;
-    int matched;
-    char *controller;
+  while ((p = fgets(buf, MAXPATHLEN, cgroup)) != NULL) {
+    char *controllers;
+    char *token;
     char *base;
 
     /* Skip cgroup number */
     strsep(&p, ":");
-    /* Get controller and base */
-    controller = strsep(&p, ":");
+    /* Get controllers and base */
+    controllers = strsep(&p, ":");
     base = strsep(&p, "\n");
 
-    if (controller != NULL) {
-      if (strstr(controller, "memory") != NULL) {
+    if (controllers == NULL) {
+      continue;
+    }
+
+    while ((token = strsep(&controllers, ",")) != NULL) {
+      if (strcmp(token, "memory") == 0) {
         memory->set_subsystem_path(base);
-      } else if (strstr(controller, "cpuset") != NULL) {
+      } else if (strcmp(token, "cpuset") == 0) {
         cpuset->set_subsystem_path(base);
-      } else if (strstr(controller, "cpu,cpuacct") != NULL || strstr(controller, "cpuacct,cpu") != NULL) {
+      } else if (strcmp(token, "cpu") == 0) {
         cpu->set_subsystem_path(base);
+      } else if (strcmp(token, "cpuacct") == 0) {
         cpuacct->set_subsystem_path(base);
-      } else if (strstr(controller, "cpuacct") != NULL) {
-        cpuacct->set_subsystem_path(base);
-      } else if (strstr(controller, "cpu") != NULL) {
-        cpu->set_subsystem_path(base);
       }
     }
   }
--- a/src/hotspot/os/linux/os_linux.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os/linux/os_linux.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -780,6 +780,13 @@
     } else {
       log_warning(os, thread)("Failed to start thread - pthread_create failed (%s) for attributes: %s.",
         os::errno_name(ret), os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr));
+      // Log some OS information which might explain why creating the thread failed.
+      log_info(os, thread)("Number of threads approx. running in the VM: %d", Threads::number_of_threads());
+      LogStream st(Log(os, thread)::info());
+      os::Posix::print_rlimit_info(&st);
+      os::print_memory_info(&st);
+      os::Linux::print_proc_sys_info(&st);
+      os::Linux::print_container_info(&st);
     }
 
     pthread_attr_destroy(&attr);
@@ -2140,46 +2147,87 @@
   st->print("container (cgroup) information:\n");
 
   const char *p_ct = OSContainer::container_type();
-  st->print("container_type: %s\n", p_ct != NULL ? p_ct : "failed");
+  st->print("container_type: %s\n", p_ct != NULL ? p_ct : "not supported");
 
   char *p = OSContainer::cpu_cpuset_cpus();
-  st->print("cpu_cpuset_cpus: %s\n", p != NULL ? p : "failed");
+  st->print("cpu_cpuset_cpus: %s\n", p != NULL ? p : "not supported");
   free(p);
 
   p = OSContainer::cpu_cpuset_memory_nodes();
-  st->print("cpu_memory_nodes: %s\n", p != NULL ? p : "failed");
+  st->print("cpu_memory_nodes: %s\n", p != NULL ? p : "not supported");
   free(p);
 
   int i = OSContainer::active_processor_count();
+  st->print("active_processor_count: ");
   if (i > 0) {
-    st->print("active_processor_count: %d\n", i);
+    st->print("%d\n", i);
   } else {
-    st->print("active_processor_count: failed\n");
+    st->print("not supported\n");
   }
 
   i = OSContainer::cpu_quota();
-  st->print("cpu_quota: %d\n", i);
+  st->print("cpu_quota: ");
+  if (i > 0) {
+    st->print("%d\n", i);
+  } else {
+    st->print("%s\n", i == OSCONTAINER_ERROR ? "not supported" : "no quota");
+  }
 
   i = OSContainer::cpu_period();
-  st->print("cpu_period: %d\n", i);
+  st->print("cpu_period: ");
+  if (i > 0) {
+    st->print("%d\n", i);
+  } else {
+    st->print("%s\n", i == OSCONTAINER_ERROR ? "not supported" : "no period");
+  }
 
   i = OSContainer::cpu_shares();
-  st->print("cpu_shares: %d\n", i);
+  st->print("cpu_shares: ");
+  if (i > 0) {
+    st->print("%d\n", i);
+  } else {
+    st->print("%s\n", i == OSCONTAINER_ERROR ? "not supported" : "no shares");
+  }
 
   jlong j = OSContainer::memory_limit_in_bytes();
-  st->print("memory_limit_in_bytes: " JLONG_FORMAT "\n", j);
+  st->print("memory_limit_in_bytes: ");
+  if (j > 0) {
+    st->print(JLONG_FORMAT "\n", j);
+  } else {
+    st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
+  }
 
   j = OSContainer::memory_and_swap_limit_in_bytes();
-  st->print("memory_and_swap_limit_in_bytes: " JLONG_FORMAT "\n", j);
+  st->print("memory_and_swap_limit_in_bytes: ");
+  if (j > 0) {
+    st->print(JLONG_FORMAT "\n", j);
+  } else {
+    st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
+  }
 
   j = OSContainer::memory_soft_limit_in_bytes();
-  st->print("memory_soft_limit_in_bytes: " JLONG_FORMAT "\n", j);
+  st->print("memory_soft_limit_in_bytes: ");
+  if (j > 0) {
+    st->print(JLONG_FORMAT "\n", j);
+  } else {
+    st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
+  }
 
   j = OSContainer::OSContainer::memory_usage_in_bytes();
-  st->print("memory_usage_in_bytes: " JLONG_FORMAT "\n", j);
+  st->print("memory_usage_in_bytes: ");
+  if (j > 0) {
+    st->print(JLONG_FORMAT "\n", j);
+  } else {
+    st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
+  }
 
   j = OSContainer::OSContainer::memory_max_usage_in_bytes();
-  st->print("memory_max_usage_in_bytes: " JLONG_FORMAT "\n", j);
+  st->print("memory_max_usage_in_bytes: ");
+  if (j > 0) {
+    st->print(JLONG_FORMAT "\n", j);
+  } else {
+    st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
+  }
   st->cr();
 }
 
@@ -2292,7 +2340,7 @@
 #elif defined(PPC64)
 const char* search_string = "cpu";
 #elif defined(S390)
-const char* search_string = "processor";
+const char* search_string = "machine =";
 #elif defined(SPARC)
 const char* search_string = "cpu";
 #else
--- a/src/hotspot/os/posix/os_posix.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os/posix/os_posix.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -1671,6 +1671,8 @@
   if ((status = pthread_mutexattr_settype(_mutexAttr, PTHREAD_MUTEX_NORMAL)) != 0) {
     fatal("pthread_mutexattr_settype: %s", os::strerror(status));
   }
+  // Solaris has it's own PlatformMonitor, distinct from the one for POSIX.
+  NOT_SOLARIS(os::PlatformMonitor::init();)
 }
 
 #ifndef SOLARIS
@@ -2250,20 +2252,64 @@
 
 // Platform Monitor implementation
 
-os::PlatformMonitor::PlatformMonitor() {
+os::PlatformMonitor::Impl::Impl() : _next(NULL) {
   int status = pthread_cond_init(&_cond, _condAttr);
   assert_status(status == 0, status, "cond_init");
   status = pthread_mutex_init(&_mutex, _mutexAttr);
   assert_status(status == 0, status, "mutex_init");
 }
 
-os::PlatformMonitor::~PlatformMonitor() {
+os::PlatformMonitor::Impl::~Impl() {
   int status = pthread_cond_destroy(&_cond);
   assert_status(status == 0, status, "cond_destroy");
   status = pthread_mutex_destroy(&_mutex);
   assert_status(status == 0, status, "mutex_destroy");
 }
 
+#if PLATFORM_MONITOR_IMPL_INDIRECT
+
+pthread_mutex_t os::PlatformMonitor::_freelist_lock;
+os::PlatformMonitor::Impl* os::PlatformMonitor::_freelist = NULL;
+
+void os::PlatformMonitor::init() {
+  int status = pthread_mutex_init(&_freelist_lock, _mutexAttr);
+  assert_status(status == 0, status, "freelist lock init");
+}
+
+struct os::PlatformMonitor::WithFreeListLocked : public StackObj {
+  WithFreeListLocked() {
+    int status = pthread_mutex_lock(&_freelist_lock);
+    assert_status(status == 0, status, "freelist lock");
+  }
+
+  ~WithFreeListLocked() {
+    int status = pthread_mutex_unlock(&_freelist_lock);
+    assert_status(status == 0, status, "freelist unlock");
+  }
+};
+
+os::PlatformMonitor::PlatformMonitor() {
+  {
+    WithFreeListLocked wfl;
+    _impl = _freelist;
+    if (_impl != NULL) {
+      _freelist = _impl->_next;
+      _impl->_next = NULL;
+      return;
+    }
+  }
+  _impl = new Impl();
+}
+
+os::PlatformMonitor::~PlatformMonitor() {
+  WithFreeListLocked wfl;
+  assert(_impl->_next == NULL, "invariant");
+  _impl->_next = _freelist;
+  _freelist = _impl;
+}
+
+#endif // PLATFORM_MONITOR_IMPL_INDIRECT
+
 // Must already be locked
 int os::PlatformMonitor::wait(jlong millis) {
   assert(millis >= 0, "negative timeout");
@@ -2278,7 +2324,7 @@
     to_abstime(&abst, millis * (NANOUNITS / MILLIUNITS), false, false);
 
     int ret = OS_TIMEOUT;
-    int status = pthread_cond_timedwait(&_cond, &_mutex, &abst);
+    int status = pthread_cond_timedwait(cond(), mutex(), &abst);
     assert_status(status == 0 || status == ETIMEDOUT,
                   status, "cond_timedwait");
     if (status == 0) {
@@ -2286,7 +2332,7 @@
     }
     return ret;
   } else {
-    int status = pthread_cond_wait(&_cond, &_mutex);
+    int status = pthread_cond_wait(cond(), mutex());
     assert_status(status == 0, status, "cond_wait");
     return OS_OK;
   }
--- a/src/hotspot/os/posix/os_posix.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os/posix/os_posix.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -232,15 +232,60 @@
   PlatformParker();
 };
 
+// Workaround for a bug in macOSX kernel's pthread support (fixed in Mojave?).
+// Avoid ever allocating a pthread_mutex_t at the same address as one of our
+// former pthread_cond_t, by using a freelist of mutex/condvar pairs.
+// Conditional to avoid extra indirection and padding loss on other platforms.
+#ifdef __APPLE__
+#define PLATFORM_MONITOR_IMPL_INDIRECT 1
+#else
+#define PLATFORM_MONITOR_IMPL_INDIRECT 0
+#endif
+
 // Platform specific implementation that underpins VM Monitor/Mutex class
 class PlatformMonitor : public CHeapObj<mtSynchronizer> {
- private:
-  pthread_mutex_t _mutex; // Native mutex for locking
-  pthread_cond_t  _cond;  // Native condition variable for blocking
+  class Impl : public CHeapObj<mtSynchronizer> {
+  public:
+    pthread_mutex_t _mutex;
+    pthread_cond_t _cond;
+    Impl* _next;
+
+    Impl();
+    ~Impl();
+  };
+
+#if PLATFORM_MONITOR_IMPL_INDIRECT
+
+  Impl* _impl;
+
+  pthread_mutex_t* mutex() { return &(_impl->_mutex); }
+  pthread_cond_t* cond() { return &(_impl->_cond); }
+
+  class WithFreeListLocked;
+  static pthread_mutex_t _freelist_lock;
+  static Impl* _freelist;
 
  public:
-  PlatformMonitor();
+  PlatformMonitor();            // Use freelist allocation of impl.
   ~PlatformMonitor();
+
+  static void init();           // Initialize the freelist.
+
+#else
+
+  Impl _impl;
+
+  pthread_mutex_t* mutex() { return &(_impl._mutex); }
+  pthread_cond_t* cond() { return &(_impl._cond); }
+
+ public:
+  static void init() {}         // Nothing needed for the non-indirect case.
+
+  // Default constructor and destructor.
+
+#endif // PLATFORM_MONITOR_IMPL_INDIRECT
+
+ public:
   void lock();
   void unlock();
   bool try_lock();
--- a/src/hotspot/os/posix/os_posix.inline.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os/posix/os_posix.inline.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -50,28 +50,28 @@
 // Platform Monitor implementation
 
 inline void os::PlatformMonitor::lock() {
-  int status = pthread_mutex_lock(&_mutex);
+  int status = pthread_mutex_lock(mutex());
   assert_status(status == 0, status, "mutex_lock");
 }
 
 inline void os::PlatformMonitor::unlock() {
-  int status = pthread_mutex_unlock(&_mutex);
+  int status = pthread_mutex_unlock(mutex());
   assert_status(status == 0, status, "mutex_unlock");
 }
 
 inline bool os::PlatformMonitor::try_lock() {
-  int status = pthread_mutex_trylock(&_mutex);
+  int status = pthread_mutex_trylock(mutex());
   assert_status(status == 0 || status == EBUSY, status, "mutex_trylock");
   return status == 0;
 }
 
 inline void os::PlatformMonitor::notify() {
-  int status = pthread_cond_signal(&_cond);
+  int status = pthread_cond_signal(cond());
   assert_status(status == 0, status, "cond_signal");
 }
 
 inline void os::PlatformMonitor::notify_all() {
-  int status = pthread_cond_broadcast(&_cond);
+  int status = pthread_cond_broadcast(cond());
   assert_status(status == 0, status, "cond_broadcast");
 }
 
--- a/src/hotspot/os/solaris/os_solaris.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os/solaris/os_solaris.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -33,6 +33,7 @@
 #include "compiler/disassembler.hpp"
 #include "interpreter/interpreter.hpp"
 #include "logging/log.hpp"
+#include "logging/logStream.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/filemap.hpp"
 #include "oops/oop.inline.hpp"
@@ -992,6 +993,11 @@
   } else {
     log_warning(os, thread)("Failed to start thread - thr_create failed (%s) for attributes: %s.",
       os::errno_name(status), describe_thr_create_attributes(buf, sizeof(buf), stack_size, flags));
+    // Log some OS information which might explain why creating the thread failed.
+    log_info(os, thread)("Number of threads approx. running in the VM: %d", Threads::number_of_threads());
+    LogStream st(Log(os, thread)::info());
+    os::Posix::print_rlimit_info(&st);
+    os::print_memory_info(&st);
   }
 
   if (status != 0) {
--- a/src/hotspot/os/windows/os_windows.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os/windows/os_windows.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -36,6 +36,7 @@
 #include "compiler/disassembler.hpp"
 #include "interpreter/interpreter.hpp"
 #include "logging/log.hpp"
+#include "logging/logStream.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/filemap.hpp"
 #include "oops/oop.inline.hpp"
@@ -669,6 +670,10 @@
   } else {
     log_warning(os, thread)("Failed to start thread - _beginthreadex failed (%s) for attributes: %s.",
       os::errno_name(errno), describe_beginthreadex_attributes(buf, sizeof(buf), stack_size, initflag));
+    // Log some OS information which might explain why creating the thread failed.
+    log_info(os, thread)("Number of threads approx. running in the VM: %d", Threads::number_of_threads());
+    LogStream st(Log(os, thread)::info());
+    os::print_memory_info(&st);
   }
 
   if (thread_handle == NULL) {
--- a/src/hotspot/os_cpu/aix_ppc/orderAccess_aix_ppc.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/aix_ppc/orderAccess_aix_ppc.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -77,6 +77,8 @@
 inline void OrderAccess::acquire()    { inlasm_lwsync(); }
 inline void OrderAccess::release()    { inlasm_lwsync(); }
 inline void OrderAccess::fence()      { inlasm_sync();   }
+inline void OrderAccess::cross_modify_fence()
+                                      { inlasm_isync();  }
 
 template<size_t byte_size>
 struct OrderAccess::PlatformOrderedLoad<byte_size, X_ACQUIRE>
--- a/src/hotspot/os_cpu/bsd_x86/orderAccess_bsd_x86.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/bsd_x86/orderAccess_bsd_x86.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -59,6 +59,11 @@
   compiler_barrier();
 }
 
+inline void OrderAccess::cross_modify_fence() {
+  int idx = 0;
+  __asm__ volatile ("cpuid " : "+a" (idx) : : "ebx", "ecx", "edx", "memory");
+}
+
 template<>
 struct OrderAccess::PlatformOrderedStore<1, RELEASE_X_FENCE>
 {
--- a/src/hotspot/os_cpu/bsd_zero/orderAccess_bsd_zero.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/bsd_zero/orderAccess_bsd_zero.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -73,5 +73,6 @@
 inline void OrderAccess::acquire()    { LIGHT_MEM_BARRIER; }
 inline void OrderAccess::release()    { LIGHT_MEM_BARRIER; }
 inline void OrderAccess::fence()      { FULL_MEM_BARRIER;  }
+inline void OrderAccess::cross_modify_fence()            { }
 
 #endif // OS_CPU_BSD_ZERO_ORDERACCESS_BSD_ZERO_HPP
--- a/src/hotspot/os_cpu/linux_aarch64/orderAccess_linux_aarch64.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/linux_aarch64/orderAccess_linux_aarch64.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -49,6 +49,8 @@
   FULL_MEM_BARRIER;
 }
 
+inline void OrderAccess::cross_modify_fence() { }
+
 template<size_t byte_size>
 struct OrderAccess::PlatformOrderedLoad<byte_size, X_ACQUIRE>
 {
--- a/src/hotspot/os_cpu/linux_arm/orderAccess_linux_arm.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/linux_arm/orderAccess_linux_arm.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -101,5 +101,6 @@
 inline void OrderAccess::storeload()  { dmb_sy(); }
 inline void OrderAccess::release()    { dmb_sy(); }
 inline void OrderAccess::fence()      { dmb_sy(); }
+inline void OrderAccess::cross_modify_fence()   { }
 
 #endif // OS_CPU_LINUX_ARM_ORDERACCESS_LINUX_ARM_HPP
--- a/src/hotspot/os_cpu/linux_ppc/orderAccess_linux_ppc.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/linux_ppc/orderAccess_linux_ppc.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -79,7 +79,8 @@
 inline void   OrderAccess::acquire()    { inlasm_lwsync(); }
 inline void   OrderAccess::release()    { inlasm_lwsync(); }
 inline void   OrderAccess::fence()      { inlasm_sync();   }
-
+inline void   OrderAccess::cross_modify_fence()
+                                        { inlasm_isync();  }
 
 template<size_t byte_size>
 struct OrderAccess::PlatformOrderedLoad<byte_size, X_ACQUIRE>
--- a/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -132,6 +132,10 @@
   return NULL;
 }
 
+static unsigned long ucontext_get_trap(const ucontext_t * uc) {
+  return uc->uc_mcontext.regs->trap;
+}
+
 ExtendedPC os::fetch_frame_from_context(const void* ucVoid,
                     intptr_t** ret_sp, intptr_t** ret_fp) {
 
@@ -304,9 +308,22 @@
 
     // Handle ALL stack overflow variations here
     if (sig == SIGSEGV) {
-      // Si_addr may not be valid due to a bug in the linux-ppc64 kernel (see
+      // si_addr may not be valid due to a bug in the linux-ppc64 kernel (see
       // comment below). Use get_stack_bang_address instead of si_addr.
-      address addr = ((NativeInstruction*)pc)->get_stack_bang_address(uc);
+      // If SIGSEGV is caused due to a branch to an invalid address an
+      // "Instruction Storage" interruption is generated and 'pc' (NIP) already
+      // contains the invalid address. Otherwise, the SIGSEGV is caused due to
+      // load/store instruction trying to load/store from/to an invalid address
+      // and causing a "Data Storage" interruption, so we inspect the intruction
+      // in order to extract the faulty data addresss.
+      address addr;
+      if ((ucontext_get_trap(uc) & 0x0F00 /* no IRQ reply bits */) == 0x0400) {
+        // Instruction interruption
+        addr = pc;
+      } else {
+        // Data interruption (0x0300): extract faulty data address
+        addr = ((NativeInstruction*)pc)->get_stack_bang_address(uc);
+      }
 
       // Check if fault address is within thread stack.
       if (thread->on_local_stack(addr)) {
--- a/src/hotspot/os_cpu/linux_s390/orderAccess_linux_s390.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/linux_s390/orderAccess_linux_s390.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -74,6 +74,7 @@
 inline void OrderAccess::acquire()    { inlasm_zarch_acquire(); }
 inline void OrderAccess::release()    { inlasm_zarch_release(); }
 inline void OrderAccess::fence()      { inlasm_zarch_sync(); }
+inline void OrderAccess::cross_modify_fence() { inlasm_zarch_sync(); }
 
 template<size_t byte_size>
 struct OrderAccess::PlatformOrderedLoad<byte_size, X_ACQUIRE>
--- a/src/hotspot/os_cpu/linux_s390/thread_linux_s390.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/linux_s390/thread_linux_s390.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2016 SAP SE. All rights reserved.
+ * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -63,7 +63,7 @@
 
     if (ret_frame.is_interpreted_frame()) {
       frame::z_ijava_state* istate = ret_frame.ijava_state_unchecked();
-       if (!((Method*)(istate->method))->is_metaspace_object()) {
+       if ((stack_base() >= (address)istate && (address)istate > stack_end()) || !((Method*)(istate->method))->is_metaspace_object()) {
          return false;
        }
        uint64_t reg_bcp = uc->uc_mcontext.gregs[13/*Z_BCP*/];
--- a/src/hotspot/os_cpu/linux_sparc/orderAccess_linux_sparc.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/linux_sparc/orderAccess_linux_sparc.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -48,4 +48,6 @@
   __asm__ volatile ("membar  #StoreLoad" : : : "memory");
 }
 
+inline void OrderAccess::cross_modify_fence() { }
+
 #endif // OS_CPU_LINUX_SPARC_ORDERACCESS_LINUX_SPARC_HPP
--- a/src/hotspot/os_cpu/linux_x86/gc/z/zLargePages_linux_x86.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2017, 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/z/zLargePages.hpp"
-#include "runtime/globals.hpp"
-
-void ZLargePages::initialize_platform() {
-  if (UseLargePages) {
-    if (UseTransparentHugePages) {
-      _state = Transparent;
-    } else {
-      _state = Explicit;
-    }
-  } else {
-    _state = Disabled;
-  }
-}
--- a/src/hotspot/os_cpu/linux_x86/gc/z/zNUMA_linux_x86.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2016, 2017, 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 "gc/z/zErrno.hpp"
-#include "gc/z/zCPU.hpp"
-#include "gc/z/zNUMA.hpp"
-#include "runtime/os.hpp"
-#include "utilities/debug.hpp"
-
-#include <unistd.h>
-#include <sys/syscall.h>
-
-#ifndef MPOL_F_NODE
-#define MPOL_F_NODE     (1<<0)  // Return next IL mode instead of node mask
-#endif
-
-#ifndef MPOL_F_ADDR
-#define MPOL_F_ADDR     (1<<1)  // Look up VMA using address
-#endif
-
-static int z_get_mempolicy(uint32_t* mode, const unsigned long *nmask, unsigned long maxnode, uintptr_t addr, int flags) {
-  return syscall(__NR_get_mempolicy, mode, nmask, maxnode, addr, flags);
-}
-
-void ZNUMA::initialize_platform() {
-  _enabled = UseNUMA;
-}
-
-uint32_t ZNUMA::count() {
-  if (!_enabled) {
-    // NUMA support not enabled
-    return 1;
-  }
-
-  return os::Linux::numa_max_node() + 1;
-}
-
-uint32_t ZNUMA::id() {
-  if (!_enabled) {
-    // NUMA support not enabled
-    return 0;
-  }
-
-  return os::Linux::get_node_by_cpu(ZCPU::id());
-}
-
-uint32_t ZNUMA::memory_id(uintptr_t addr) {
-  if (!_enabled) {
-    // NUMA support not enabled, assume everything belongs to node zero
-    return 0;
-  }
-
-  uint32_t id = (uint32_t)-1;
-
-  if (z_get_mempolicy(&id, NULL, 0, addr, MPOL_F_NODE | MPOL_F_ADDR) == -1) {
-    ZErrno err;
-    fatal("Failed to get NUMA id for memory at " PTR_FORMAT " (%s)", addr, err.to_string());
-  }
-
-  assert(id < count(), "Invalid NUMA id");
-
-  return id;
-}
--- a/src/hotspot/os_cpu/linux_x86/gc/z/zPhysicalMemoryBacking_linux_x86.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/linux_x86/gc/z/zPhysicalMemoryBacking_linux_x86.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -237,8 +237,8 @@
 }
 
 void ZPhysicalMemoryBacking::map(ZPhysicalMemory pmem, uintptr_t offset) const {
-  if (ZUnmapBadViews) {
-    // Only map the good view, for debugging only
+  if (ZVerifyViews) {
+    // Map good view
     map_view(pmem, ZAddress::good(offset), AlwaysPreTouch);
   } else {
     // Map all views
@@ -249,8 +249,8 @@
 }
 
 void ZPhysicalMemoryBacking::unmap(ZPhysicalMemory pmem, uintptr_t offset) const {
-  if (ZUnmapBadViews) {
-    // Only map the good view, for debugging only
+  if (ZVerifyViews) {
+    // Unmap good view
     unmap_view(pmem, ZAddress::good(offset));
   } else {
     // Unmap all views
@@ -260,11 +260,14 @@
   }
 }
 
-void ZPhysicalMemoryBacking::flip(ZPhysicalMemory pmem, uintptr_t offset) const {
-  assert(ZUnmapBadViews, "Should be enabled");
-  const uintptr_t addr_good = ZAddress::good(offset);
-  const uintptr_t addr_bad = ZAddress::is_marked(ZAddressGoodMask) ? ZAddress::remapped(offset) : ZAddress::marked(offset);
-  // Map/Unmap views
-  map_view(pmem, addr_good, false /* pretouch */);
-  unmap_view(pmem, addr_bad);
+void ZPhysicalMemoryBacking::debug_map(ZPhysicalMemory pmem, uintptr_t offset) const {
+  // Map good view
+  assert(ZVerifyViews, "Should be enabled");
+  map_view(pmem, ZAddress::good(offset), false /* pretouch */);
 }
+
+void ZPhysicalMemoryBacking::debug_unmap(ZPhysicalMemory pmem, uintptr_t offset) const {
+  // Unmap good view
+  assert(ZVerifyViews, "Should be enabled");
+  unmap_view(pmem, ZAddress::good(offset));
+}
--- a/src/hotspot/os_cpu/linux_x86/gc/z/zPhysicalMemoryBacking_linux_x86.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/linux_x86/gc/z/zPhysicalMemoryBacking_linux_x86.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -58,7 +58,9 @@
 
   void map(ZPhysicalMemory pmem, uintptr_t offset) const;
   void unmap(ZPhysicalMemory pmem, uintptr_t offset) const;
-  void flip(ZPhysicalMemory pmem, uintptr_t offset) const;
+
+  void debug_map(ZPhysicalMemory pmem, uintptr_t offset) const;
+  void debug_unmap(ZPhysicalMemory pmem, uintptr_t offset) const;
 };
 
 #endif // OS_CPU_LINUX_X86_GC_Z_ZPHYSICALMEMORYBACKING_LINUX_X86_HPP
--- a/src/hotspot/os_cpu/linux_x86/gc/z/zVirtualMemory_linux_x86.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2015, 2017, 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/z/zVirtualMemory.hpp"
-#include "logging/log.hpp"
-
-#include <sys/mman.h>
-#include <sys/types.h>
-
-bool ZVirtualMemoryManager::reserve(uintptr_t start, size_t size) {
-  // Reserve address space
-  const uintptr_t actual_start = (uintptr_t)mmap((void*)start, size, PROT_NONE,
-                                                 MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0);
-  if (actual_start != start) {
-    log_error(gc)("Failed to reserve address space for Java heap");
-    return false;
-  }
-
-  return true;
-}
--- a/src/hotspot/os_cpu/linux_x86/orderAccess_linux_x86.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/linux_x86/orderAccess_linux_x86.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -55,6 +55,11 @@
   compiler_barrier();
 }
 
+inline void OrderAccess::cross_modify_fence() {
+  int idx = 0;
+  __asm__ volatile ("cpuid " : "+a" (idx) : : "ebx", "ecx", "edx", "memory");
+}
+
 template<>
 struct OrderAccess::PlatformOrderedStore<1, RELEASE_X_FENCE>
 {
--- a/src/hotspot/os_cpu/linux_zero/orderAccess_linux_zero.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/linux_zero/orderAccess_linux_zero.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -82,5 +82,6 @@
 inline void OrderAccess::release()    { LIGHT_MEM_BARRIER; }
 
 inline void OrderAccess::fence()      { FULL_MEM_BARRIER;  }
+inline void OrderAccess::cross_modify_fence()            { }
 
 #endif // OS_CPU_LINUX_ZERO_ORDERACCESS_LINUX_ZERO_HPP
--- a/src/hotspot/os_cpu/solaris_sparc/orderAccess_solaris_sparc.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/solaris_sparc/orderAccess_solaris_sparc.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -51,4 +51,6 @@
   __asm__ volatile ("membar  #StoreLoad" : : : "memory");
 }
 
+inline void OrderAccess::cross_modify_fence() { }
+
 #endif // OS_CPU_SOLARIS_SPARC_ORDERACCESS_SOLARIS_SPARC_HPP
--- a/src/hotspot/os_cpu/solaris_x86/orderAccess_solaris_x86.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/solaris_x86/orderAccess_solaris_x86.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -54,4 +54,9 @@
   compiler_barrier();
 }
 
+inline void OrderAccess::cross_modify_fence() {
+  int idx = 0;
+  __asm__ volatile ("cpuid " : "+a" (idx) : : "ebx", "ecx", "edx", "memory");
+}
+
 #endif // OS_CPU_SOLARIS_X86_ORDERACCESS_SOLARIS_X86_HPP
--- a/src/hotspot/os_cpu/windows_x86/orderAccess_windows_x86.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/os_cpu/windows_x86/orderAccess_windows_x86.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -69,6 +69,11 @@
   compiler_barrier();
 }
 
+inline void OrderAccess::cross_modify_fence() {
+  int regs[4];
+  __cpuid(regs, 0);
+}
+
 #ifndef AMD64
 template<>
 struct OrderAccess::PlatformOrderedStore<1, RELEASE_X_FENCE>
--- a/src/hotspot/share/aot/aotCodeHeap.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/aot/aotCodeHeap.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -931,13 +931,13 @@
 // Scan only klasses_got cells which should have only Klass*,
 // metadata_got cells are scanned only for alive AOT methods
 // by AOTCompiledMethod::metadata_do().
-void AOTCodeHeap::got_metadata_do(void f(Metadata*)) {
+void AOTCodeHeap::got_metadata_do(MetadataClosure* f) {
   for (int i = 1; i < _klasses_got_size; i++) {
     Metadata** p = &_klasses_got[i];
     Metadata* md = *p;
     if (md == NULL)  continue;  // skip non-oops
     if (Metaspace::contains(md)) {
-      f(md);
+      f->do_metadata(md);
     } else {
       intptr_t meta = (intptr_t)md;
       fatal("Invalid value in _klasses_got[%d] = " INTPTR_FORMAT, i, meta);
@@ -969,7 +969,7 @@
 }
 #endif
 
-void AOTCodeHeap::metadata_do(void f(Metadata*)) {
+void AOTCodeHeap::metadata_do(MetadataClosure* f) {
   for (int index = 0; index < _method_count; index++) {
     if (_code_to_aot[index]._state != in_use) {
       continue; // Skip uninitialized entries.
--- a/src/hotspot/share/aot/aotCodeHeap.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/aot/aotCodeHeap.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -252,8 +252,8 @@
 
 
   void oops_do(OopClosure* f);
-  void metadata_do(void f(Metadata*));
-  void got_metadata_do(void f(Metadata*));
+  void metadata_do(MetadataClosure* f);
+  void got_metadata_do(MetadataClosure* f);
 
 #ifdef ASSERT
   bool got_contains(Metadata **p) {
--- a/src/hotspot/share/aot/aotCompiledMethod.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/aot/aotCompiledMethod.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -246,7 +246,7 @@
 
 // Iterate over metadata calling this function.   Used by RedefineClasses
 // Copied from nmethod::metadata_do
-void AOTCompiledMethod::metadata_do(void f(Metadata*)) {
+void AOTCompiledMethod::metadata_do(MetadataClosure* f) {
   address low_boundary = verified_entry_point();
   {
     // Visit all immediate references that are embedded in the instruction stream.
@@ -262,7 +262,7 @@
                "metadata must be found in exactly one place");
         if (r->metadata_is_immediate() && r->metadata_value() != NULL) {
           Metadata* md = r->metadata_value();
-          if (md != _method) f(md);
+          if (md != _method) f->do_metadata(md);
         }
       } else if (iter.type() == relocInfo::virtual_call_type) {
         ResourceMark rm;
@@ -270,13 +270,13 @@
         CompiledIC *ic = CompiledIC_at(&iter);
         if (ic->is_icholder_call()) {
           CompiledICHolder* cichk = ic->cached_icholder();
-          f(cichk->holder_metadata());
-          f(cichk->holder_klass());
+          f->do_metadata(cichk->holder_metadata());
+          f->do_metadata(cichk->holder_klass());
         } else {
           // Get Klass* or NULL (if value is -1) from GOT cell of virtual call PLT stub.
           Metadata* ic_oop = ic->cached_metadata();
           if (ic_oop != NULL) {
-            f(ic_oop);
+            f->do_metadata(ic_oop);
           }
         }
       } else if (iter.type() == relocInfo::static_call_type ||
@@ -284,7 +284,7 @@
         // Check Method* in AOT c2i stub for other calls.
         Metadata* meta = (Metadata*)nativeLoadGot_at(nativePltCall_at(iter.addr())->plt_c2i_stub())->data();
         if (meta != NULL) {
-          f(meta);
+          f->do_metadata(meta);
         }
       }
     }
@@ -302,11 +302,11 @@
       continue;
     }
     assert(Metaspace::contains(m), "");
-    f(m);
+    f->do_metadata(m);
   }
 
   // Visit metadata not embedded in the other places.
-  if (_method != NULL) f(_method);
+  if (_method != NULL) f->do_metadata(_method);
 }
 
 void AOTCompiledMethod::print() const {
--- a/src/hotspot/share/aot/aotCompiledMethod.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/aot/aotCompiledMethod.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -241,7 +241,7 @@
   address get_original_pc(const frame* fr) { return *orig_pc_addr(fr); }
   void    set_original_pc(const frame* fr, address pc) { *orig_pc_addr(fr) = pc; }
 
-  virtual void metadata_do(void f(Metadata*));
+  virtual void metadata_do(MetadataClosure* f);
 
   bool metadata_got_contains(Metadata **p) {
     return p >= &_metadata_got[0] && p < &_metadata_got[_metadata_size];
--- a/src/hotspot/share/aot/aotLoader.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/aot/aotLoader.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -78,7 +78,7 @@
   }
 }
 
-void AOTLoader::metadata_do(void f(Metadata*)) {
+void AOTLoader::metadata_do(MetadataClosure* f) {
   if (UseAOT) {
     FOR_ALL_AOT_HEAPS(heap) {
       (*heap)->metadata_do(f);
--- a/src/hotspot/share/aot/aotLoader.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/aot/aotLoader.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -62,7 +62,7 @@
   static void load_for_klass(InstanceKlass* ik, Thread* thread) NOT_AOT_RETURN;
   static uint64_t get_saved_fingerprint(InstanceKlass* ik) NOT_AOT({ return 0; });
   static void oops_do(OopClosure* f) NOT_AOT_RETURN;
-  static void metadata_do(void f(Metadata*)) NOT_AOT_RETURN;
+  static void metadata_do(MetadataClosure* f) NOT_AOT_RETURN;
   static void mark_evol_dependent_methods(InstanceKlass* dependee) NOT_AOT_RETURN;
 
   NOT_PRODUCT( static void print_statistics() NOT_AOT_RETURN; )
--- a/src/hotspot/share/c1/c1_LIRGenerator.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -3279,7 +3279,14 @@
 
 void LIRGenerator::increment_backedge_counter_conditionally(LIR_Condition cond, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info, int left_bci, int right_bci, int bci) {
   if (compilation()->count_backedges()) {
+#if defined(X86) && !defined(_LP64)
+    // BEWARE! On 32-bit x86 cmp clobbers its left argument so we need a temp copy.
+    LIR_Opr left_copy = new_register(left->type());
+    __ move(left, left_copy);
+    __ cmp(cond, left_copy, right);
+#else
     __ cmp(cond, left, right);
+#endif
     LIR_Opr step = new_register(T_INT);
     LIR_Opr plus_one = LIR_OprFact::intConst(InvocationCounter::count_increment);
     LIR_Opr zero = LIR_OprFact::intConst(0);
--- a/src/hotspot/share/ci/ciEnv.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/ci/ciEnv.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -465,7 +465,7 @@
   void record_out_of_memory_failure();
 
   // RedefineClasses support
-  void metadata_do(void f(Metadata*)) { _factory->metadata_do(f); }
+  void metadata_do(MetadataClosure* f) { _factory->metadata_do(f); }
 
   // Dump the compilation replay data for the ciEnv to the stream.
   void dump_replay_data(int compile_id);
--- a/src/hotspot/share/ci/ciObjectFactory.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/ci/ciObjectFactory.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -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
@@ -689,11 +689,11 @@
 
 // ------------------------------------------------------------------
 // ciObjectFactory::metadata_do
-void ciObjectFactory::metadata_do(void f(Metadata*)) {
+void ciObjectFactory::metadata_do(MetadataClosure* f) {
   if (_ci_metadata == NULL) return;
   for (int j = 0; j< _ci_metadata->length(); j++) {
     Metadata* o = _ci_metadata->at(j)->constant_encoding();
-    f(o);
+    f->do_metadata(o);
   }
 }
 
--- a/src/hotspot/share/ci/ciObjectFactory.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/ci/ciObjectFactory.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -140,7 +140,7 @@
 
   GrowableArray<ciMetadata*>* get_ci_metadata() const { return _ci_metadata; }
   // RedefineClasses support
-  void metadata_do(void f(Metadata*));
+  void metadata_do(MetadataClosure* f);
 
   void print_contents();
   void print();
--- a/src/hotspot/share/classfile/classFileParser.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/classfile/classFileParser.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -6113,7 +6113,7 @@
           // For the boot and platform class loaders, skip classes that are not found in the
           // java runtime image, such as those found in the --patch-module entries.
           // These classes can't be loaded from the archive during runtime.
-          if (!ClassLoader::is_modules_image(stream->source()) && strncmp(stream->source(), "jrt:", 4) != 0) {
+          if (!stream->from_boot_loader_modules_image() && strncmp(stream->source(), "jrt:", 4) != 0) {
             skip = true;
           }
 
--- a/src/hotspot/share/classfile/classFileStream.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/classfile/classFileStream.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, 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
@@ -38,12 +38,14 @@
 ClassFileStream::ClassFileStream(const u1* buffer,
                                  int length,
                                  const char* source,
-                                 bool verify_stream) :
+                                 bool verify_stream,
+                                 bool from_boot_loader_modules_image) :
   _buffer_start(buffer),
   _buffer_end(buffer + length),
   _current(buffer),
   _source(source),
-  _need_verify(verify_stream) {}
+  _need_verify(verify_stream),
+  _from_boot_loader_modules_image(from_boot_loader_modules_image) {}
 
 const u1* ClassFileStream::clone_buffer() const {
   u1* const new_buffer_start = NEW_RESOURCE_ARRAY(u1, length());
@@ -69,7 +71,8 @@
   return new ClassFileStream(new_buffer_start,
                              length(),
                              clone_source(),
-                             need_verify());
+                             need_verify(),
+                             from_boot_loader_modules_image());
 }
 
 uint64_t ClassFileStream::compute_fingerprint() const {
--- a/src/hotspot/share/classfile/classFileStream.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/classfile/classFileStream.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -44,7 +44,7 @@
   mutable const u1* _current;    // Current buffer position
   const char* const _source;     // Source of stream (directory name, ZIP/JAR archive name)
   bool _need_verify;             // True if verification is on for the class file
-
+  bool _from_boot_loader_modules_image;  // True if this was created by ClassPathImageEntry.
   void truncated_file_error(TRAPS) const ;
 
  protected:
@@ -57,7 +57,8 @@
   ClassFileStream(const u1* buffer,
                   int length,
                   const char* source,
-                  bool verify_stream = verify); // to be verified by default
+                  bool verify_stream = verify,  // to be verified by default
+                  bool from_boot_loader_modules_image = false);
 
   virtual const ClassFileStream* clone() const;
 
@@ -77,6 +78,7 @@
   const char* source() const { return _source; }
   bool need_verify() const { return _need_verify; }
   void set_verify(bool flag) { _need_verify = flag; }
+  bool from_boot_loader_modules_image() const { return _from_boot_loader_modules_image; }
 
   void check_truncated_file(bool b, TRAPS) const {
     if (b) {
--- a/src/hotspot/share/classfile/classLoader.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/classfile/classLoader.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -361,6 +361,8 @@
   }
 }
 
+DEBUG_ONLY(ClassPathImageEntry* ClassPathImageEntry::_singleton = NULL;)
+
 void ClassPathImageEntry::close_jimage() {
   if (_jimage != NULL) {
     (*JImageClose)(_jimage);
@@ -373,12 +375,17 @@
   _jimage(jimage) {
   guarantee(jimage != NULL, "jimage file is null");
   guarantee(name != NULL, "jimage file name is null");
+  assert(_singleton == NULL, "VM supports only one jimage");
+  DEBUG_ONLY(_singleton = this);
   size_t len = strlen(name) + 1;
   _name = NEW_C_HEAP_ARRAY(const char, len, mtClass);
   strncpy((char *)_name, name, len);
 }
 
 ClassPathImageEntry::~ClassPathImageEntry() {
+  assert(_singleton == this, "must be");
+  DEBUG_ONLY(_singleton = NULL);
+
   if (_name != NULL) {
     FREE_C_HEAP_ARRAY(const char, _name);
     _name = NULL;
@@ -442,10 +449,12 @@
     char* data = NEW_RESOURCE_ARRAY(char, size);
     (*JImageGetResource)(_jimage, location, data, size);
     // Resource allocated
+    assert(this == (ClassPathImageEntry*)ClassLoader::get_jrt_entry(), "must be");
     return new ClassFileStream((u1*)data,
                                (int)size,
                                _name,
-                               ClassFileStream::verify);
+                               ClassFileStream::verify,
+                               true); // from_boot_loader_modules_image
   }
 
   return NULL;
@@ -459,7 +468,9 @@
 }
 
 bool ClassPathImageEntry::is_modules_image() const {
-  return ClassLoader::is_modules_image(name());
+  assert(this == _singleton, "VM supports a single jimage");
+  assert(this == (ClassPathImageEntry*)ClassLoader::get_jrt_entry(), "must be used for jrt entry");
+  return true;
 }
 
 #if INCLUDE_CDS
@@ -737,8 +748,8 @@
         // Check for a jimage
         if (Arguments::has_jimage()) {
           assert(_jrt_entry == NULL, "should not setup bootstrap class search path twice");
+          _jrt_entry = new_entry;
           assert(new_entry != NULL && new_entry->is_modules_image(), "No java runtime image present");
-          _jrt_entry = new_entry;
           assert(_jrt_entry->jimage() != NULL, "No java runtime image");
         }
       } else {
@@ -1499,7 +1510,7 @@
       }
       // for index 0 and the stream->source() is the modules image or has the jrt: protocol.
       // The class must be from the runtime modules image.
-      if (i == 0 && (is_modules_image(src) || string_starts_with(src, "jrt:"))) {
+      if (i == 0 && (stream->from_boot_loader_modules_image() || string_starts_with(src, "jrt:"))) {
         classpath_index = i;
         break;
       }
@@ -1515,7 +1526,7 @@
     // The shared path table is set up after module system initialization.
     // The path table contains no entry before that. Any classes loaded prior
     // to the setup of the shared path table must be from the modules image.
-    assert(is_modules_image(src), "stream must be from modules image");
+    assert(stream->from_boot_loader_modules_image(), "stream must be loaded by boot loader from modules image");
     assert(FileMapInfo::get_number_of_shared_paths() == 0, "shared path table must not have been setup");
     classpath_index = 0;
   }
--- a/src/hotspot/share/classfile/classLoader.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/classfile/classLoader.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -114,6 +114,7 @@
 private:
   JImageFile* _jimage;
   const char* _name;
+  DEBUG_ONLY(static ClassPathImageEntry* _singleton;)
 public:
   bool is_modules_image() const;
   bool is_jar_file() const { return false; }
@@ -439,8 +440,6 @@
   // distinguish from a class_name with no package name, as both cases have a NULL return value
   static const char* package_from_name(const char* const class_name, bool* bad_class_name = NULL);
 
-  static bool is_modules_image(const char* name) { return string_ends_with(name, MODULES_IMAGE_NAME); }
-
   // Debugging
   static void verify()              PRODUCT_RETURN;
 };
--- a/src/hotspot/share/classfile/metadataOnStackMark.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/classfile/metadataOnStackMark.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, 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
@@ -42,6 +42,10 @@
 MetadataOnStackBuffer* MetadataOnStackMark::_current_buffer = NULL;
 NOT_PRODUCT(bool MetadataOnStackMark::_is_active = false;)
 
+class MetadataOnStackClosure : public MetadataClosure {
+  void do_metadata(Metadata* m) { Metadata::mark_on_stack(m); }
+};
+
 // Walk metadata on the stack and mark it so that redefinition doesn't delete
 // it.  Class unloading only deletes in-error class files, methods created by
 // the relocator and dummy constant pools.  None of these appear anywhere except
@@ -55,8 +59,9 @@
   Threads::metadata_handles_do(Metadata::mark_on_stack);
 
   if (redefinition_walk) {
-    Threads::metadata_do(Metadata::mark_on_stack);
-    CodeCache::metadata_do(Metadata::mark_on_stack);
+    MetadataOnStackClosure md_on_stack;
+    Threads::metadata_do(&md_on_stack);
+    CodeCache::metadata_do(&md_on_stack);
     CompileBroker::mark_on_stack();
     JvmtiCurrentBreakpoints::metadata_do(Metadata::mark_on_stack);
     ThreadService::metadata_do(Metadata::mark_on_stack);
--- a/src/hotspot/share/classfile/verifier.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/classfile/verifier.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -574,7 +574,7 @@
 ClassVerifier::ClassVerifier(
     InstanceKlass* klass, TRAPS)
     : _thread(THREAD), _previous_symbol(NULL), _symbols(NULL), _exception_type(NULL),
-      _message(NULL), _klass(klass) {
+      _message(NULL), _method_signatures_table(NULL), _klass(klass) {
   _this_type = VerificationType::reference_type(klass->name());
 }
 
@@ -601,6 +601,13 @@
 void ClassVerifier::verify_class(TRAPS) {
   log_info(verification)("Verifying class %s with new format", _klass->external_name());
 
+  // Either verifying both local and remote classes or just remote classes.
+  assert(BytecodeVerificationRemote, "Should not be here");
+
+  // Create hash table containing method signatures.
+  method_signatures_table_type method_signatures_table;
+  set_method_signatures_table(&method_signatures_table);
+
   Array<Method*>* methods = _klass->methods();
   int num_methods = methods->length();
 
@@ -625,6 +632,55 @@
   }
 }
 
+// Translate the signature entries into verification types and save them in
+// the growable array.  Also, save the count of arguments.
+void ClassVerifier::translate_signature(Symbol* const method_sig,
+                                        sig_as_verification_types* sig_verif_types,
+                                        TRAPS) {
+  SignatureStream sig_stream(method_sig);
+  VerificationType sig_type[2];
+  int sig_i = 0;
+  GrowableArray<VerificationType>* verif_types = sig_verif_types->sig_verif_types();
+
+  // Translate the signature arguments into verification types.
+  while (!sig_stream.at_return_type()) {
+    int n = change_sig_to_verificationType(&sig_stream, sig_type, CHECK_VERIFY(this));
+    assert(n <= 2, "Unexpected signature type");
+
+    // Store verification type(s).  Longs and Doubles each have two verificationTypes.
+    for (int x = 0; x < n; x++) {
+      verif_types->push(sig_type[x]);
+    }
+    sig_i += n;
+    sig_stream.next();
+  }
+
+  // Set final arg count, not including the return type.  The final arg count will
+  // be compared with sig_verify_types' length to see if there is a return type.
+  sig_verif_types->set_num_args(sig_i);
+
+  // Store verification type(s) for the return type, if there is one.
+  if (sig_stream.type() != T_VOID) {
+    int n = change_sig_to_verificationType(&sig_stream, sig_type, CHECK_VERIFY(this));
+    assert(n <= 2, "Unexpected signature return type");
+    for (int y = 0; y < n; y++) {
+      verif_types->push(sig_type[y]);
+    }
+  }
+}
+
+void ClassVerifier::create_method_sig_entry(sig_as_verification_types* sig_verif_types,
+                                            int sig_index, TRAPS) {
+  // Translate the signature into verification types.
+  ConstantPool* cp = _klass->constants();
+  Symbol* const method_sig = cp->symbol_at(sig_index);
+  translate_signature(method_sig, sig_verif_types, CHECK_VERIFY(this));
+
+  // Add the list of this signature's verification types to the table.
+  bool is_unique = method_signatures_table()->put(sig_index, sig_verif_types);
+  assert(is_unique, "Duplicate entries in method_signature_table");
+}
+
 void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
   HandleMark hm(THREAD);
   _method = m;   // initialize _method
@@ -2734,44 +2790,28 @@
     ref_class_type = cp_ref_index_to_type(index, cp, CHECK_VERIFY(this));
   }
 
-  // For a small signature length, we just allocate 128 bytes instead
-  // of parsing the signature once to find its size.
-  // -3 is for '(', ')' and return descriptor; multiply by 2 is for
-  // longs/doubles to be consertive.
   assert(sizeof(VerificationType) == sizeof(uintptr_t),
         "buffer type must match VerificationType size");
-  uintptr_t on_stack_sig_types_buffer[128];
-  // If we make a VerificationType[128] array directly, the compiler calls
-  // to the c-runtime library to do the allocation instead of just
-  // stack allocating it.  Plus it would run constructors.  This shows up
-  // in performance profiles.
 
-  VerificationType* sig_types;
-  int size = (method_sig->utf8_length() - 3) * 2;
-  if (size > 128) {
-    // Long and double occupies two slots here.
-    ArgumentSizeComputer size_it(method_sig);
-    size = size_it.size();
-    sig_types = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, VerificationType, size);
-  } else{
-    sig_types = (VerificationType*)on_stack_sig_types_buffer;
+  // Get the UTF8 index for this signature.
+  int sig_index = cp->signature_ref_index_at(cp->name_and_type_ref_index_at(index));
+
+  // Get the signature's verification types.
+  sig_as_verification_types* mth_sig_verif_types;
+  sig_as_verification_types** mth_sig_verif_types_ptr = method_signatures_table()->get(sig_index);
+  if (mth_sig_verif_types_ptr != NULL) {
+    // Found the entry for the signature's verification types in the hash table.
+    mth_sig_verif_types = *mth_sig_verif_types_ptr;
+    assert(mth_sig_verif_types != NULL, "Unexpected NULL sig_as_verification_types value");
+  } else {
+    // Not found, add the entry to the table.
+    GrowableArray<VerificationType>* verif_types = new GrowableArray<VerificationType>(10);
+    mth_sig_verif_types = new sig_as_verification_types(verif_types);
+    create_method_sig_entry(mth_sig_verif_types, sig_index, CHECK_VERIFY(this));
   }
-  SignatureStream sig_stream(method_sig);
-  int sig_i = 0;
-  while (!sig_stream.at_return_type()) {
-    sig_i += change_sig_to_verificationType(
-      &sig_stream, &sig_types[sig_i], CHECK_VERIFY(this));
-    sig_stream.next();
-  }
-  int nargs = sig_i;
 
-#ifdef ASSERT
-  {
-    ArgumentSizeComputer size_it(method_sig);
-    assert(nargs == size_it.size(), "Argument sizes do not match");
-    assert(nargs <= (method_sig->utf8_length() - 3) * 2, "estimate of max size isn't conservative enough");
-  }
-#endif
+  // Get the number of arguments for this signature.
+  int nargs = mth_sig_verif_types->num_args();
 
   // Check instruction operands
   u2 bci = bcs->bci();
@@ -2844,10 +2884,16 @@
     }
 
   }
+
+  // Get the verification types for the method's arguments.
+  GrowableArray<VerificationType>* sig_verif_types = mth_sig_verif_types->sig_verif_types();
+  assert(sig_verif_types != NULL, "Missing signature's array of verification types");
   // Match method descriptor with operand stack
-  for (int i = nargs - 1; i >= 0; i--) {  // Run backwards
-    current_frame->pop_stack(sig_types[i], CHECK_VERIFY(this));
+  // The arguments are on the stack in descending order.
+  for (int i = nargs - 1; i >= 0; i--) { // Run backwards
+    current_frame->pop_stack(sig_verif_types->at(i), CHECK_VERIFY(this));
   }
+
   // Check objectref on operand stack
   if (opcode != Bytecodes::_invokestatic &&
       opcode != Bytecodes::_invokedynamic) {
@@ -2919,7 +2965,8 @@
     }
   }
   // Push the result type.
-  if (sig_stream.type() != T_VOID) {
+  int sig_verif_types_len = sig_verif_types->length();
+  if (sig_verif_types_len > nargs) {  // There's a return type
     if (method_name == vmSymbols::object_initializer_name()) {
       // <init> method must have a void return type
       /* Unreachable?  Class file parser verifies that methods with '<' have
@@ -2928,11 +2975,13 @@
           "Return type must be void in <init> method");
       return;
     }
-    VerificationType return_type[2];
-    int n = change_sig_to_verificationType(
-      &sig_stream, return_type, CHECK_VERIFY(this));
-    for (int i = 0; i < n; i++) {
-      current_frame->push_stack(return_type[i], CHECK_VERIFY(this)); // push types backwards
+
+    assert(sig_verif_types_len <= nargs + 2,
+           "Signature verification types array return type is bogus");
+    for (int i = nargs; i < sig_verif_types_len; i++) {
+      assert(i == nargs || sig_verif_types->at(i).is_long2() ||
+             sig_verif_types->at(i).is_double2(), "Unexpected return verificationType");
+      current_frame->push_stack(sig_verif_types->at(i), CHECK_VERIFY(this));
     }
   }
 }
--- a/src/hotspot/share/classfile/verifier.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/classfile/verifier.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -31,6 +31,7 @@
 #include "runtime/handles.hpp"
 #include "utilities/exceptions.hpp"
 #include "utilities/growableArray.hpp"
+#include "utilities/resourceHash.hpp"
 
 // The verifier class
 class Verifier : AllStatic {
@@ -246,6 +247,33 @@
   void stackmap_details(outputStream* ss, const Method* method) const;
 };
 
+class sig_as_verification_types : public ResourceObj {
+ private:
+  int _num_args;  // Number of arguments, not including return type.
+  GrowableArray<VerificationType>* _sig_verif_types;
+
+ public:
+
+  sig_as_verification_types(GrowableArray<VerificationType>* sig_verif_types) :
+    _num_args(0), _sig_verif_types(sig_verif_types) {
+  }
+
+  int num_args() const { return _num_args; }
+  void set_num_args(int num_args) { _num_args = num_args; }
+
+  GrowableArray<VerificationType>* sig_verif_types() { return _sig_verif_types; }
+  void set_sig_verif_types(GrowableArray<VerificationType>* sig_verif_types) {
+    _sig_verif_types = sig_verif_types;
+  }
+
+};
+
+// This hashtable is indexed by the Utf8 constant pool indexes pointed to
+// by constant pool (Interface)Method_refs' NameAndType signature entries.
+typedef ResourceHashtable<int, sig_as_verification_types*,
+                          primitive_hash<int>, primitive_equals<int>, 1007>
+                          method_signatures_table_type;
+
 // A new instance of this class is created for each class being verified
 class ClassVerifier : public StackObj {
  private:
@@ -257,6 +285,8 @@
   Symbol* _exception_type;
   char* _message;
 
+  method_signatures_table_type* _method_signatures_table;
+
   ErrorContext _error_context;  // contains information about an error
 
   void verify_method(const methodHandle& method, TRAPS);
@@ -383,6 +413,13 @@
   // the message_buffer will be filled in with the exception message.
   void verify_class(TRAPS);
 
+  // Translates method signature entries into verificationTypes and saves them
+  // in the growable array.
+  void translate_signature(Symbol* const method_sig, sig_as_verification_types* sig_verif_types, TRAPS);
+
+  // Initializes a sig_as_verification_types entry and puts it in the hash table.
+  void create_method_sig_entry(sig_as_verification_types* sig_verif_types, int sig_index, TRAPS);
+
   // Return status modes
   Symbol* result() const { return _exception_type; }
   bool has_error() const { return result() != NULL; }
@@ -400,6 +437,14 @@
 
   Klass* load_class(Symbol* name, TRAPS);
 
+  method_signatures_table_type* method_signatures_table() const {
+    return _method_signatures_table;
+  }
+
+  void set_method_signatures_table(method_signatures_table_type* method_signatures_table) {
+    _method_signatures_table = method_signatures_table;
+  }
+
   int change_sig_to_verificationType(
     SignatureStream* sig_type, VerificationType* inference_type, TRAPS);
 
--- a/src/hotspot/share/code/codeCache.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/code/codeCache.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -667,7 +667,7 @@
   }
 }
 
-void CodeCache::metadata_do(void f(Metadata* m)) {
+void CodeCache::metadata_do(MetadataClosure* f) {
   assert_locked_or_safepoint(CodeCache_lock);
   NMethodIterator iter(NMethodIterator::only_alive_and_not_unloading);
   while(iter.next()) {
@@ -1061,13 +1061,14 @@
       // ...Already marked in the previous pass; count it here.
       // Also counts AOT compiled methods, already marked.
       number_of_marked_CodeBlobs++;
-    } else if (nm->is_evol_dependent()) {
+    } else if (nm->has_evol_metadata()) {
       ResourceMark rm;
       nm->mark_for_deoptimization();
       number_of_marked_CodeBlobs++;
-    } else  {
-      // flush caches in case they refer to a redefined Method*
-      nm->clear_inline_caches();
+    } else {
+      // Inline caches that refer to an nmethod are deoptimized already, because
+      // the Method* is walked in the metadata section of the nmethod.
+      assert(!nm->is_evol_dependent(), "should no longer be necessary");
     }
   }
 
--- a/src/hotspot/share/code/codeCache.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/code/codeCache.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -147,7 +147,7 @@
   static void blobs_do(void f(CodeBlob* cb));              // iterates over all CodeBlobs
   static void blobs_do(CodeBlobClosure* f);                // iterates over all CodeBlobs
   static void nmethods_do(void f(nmethod* nm));            // iterates over all nmethods
-  static void metadata_do(void f(Metadata* m));            // iterates over metadata in alive nmethods
+  static void metadata_do(MetadataClosure* f);             // iterates over metadata in alive nmethods
 
   // Lookup
   static CodeBlob* find_blob(void* start);              // Returns the CodeBlob containing the given address
--- a/src/hotspot/share/code/compiledMethod.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/code/compiledMethod.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -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
@@ -415,20 +415,22 @@
 
 #ifdef ASSERT
 // Check class_loader is alive for this bit of metadata.
-static void check_class(Metadata* md) {
-   Klass* klass = NULL;
-   if (md->is_klass()) {
-     klass = ((Klass*)md);
-   } else if (md->is_method()) {
-     klass = ((Method*)md)->method_holder();
-   } else if (md->is_methodData()) {
-     klass = ((MethodData*)md)->method()->method_holder();
-   } else {
-     md->print();
-     ShouldNotReachHere();
-   }
-   assert(klass->is_loader_alive(), "must be alive");
-}
+class CheckClass : public MetadataClosure {
+  void do_metadata(Metadata* md) {
+    Klass* klass = NULL;
+    if (md->is_klass()) {
+      klass = ((Klass*)md);
+    } else if (md->is_method()) {
+      klass = ((Method*)md)->method_holder();
+    } else if (md->is_methodData()) {
+      klass = ((MethodData*)md)->method()->method_holder();
+    } else {
+      md->print();
+      ShouldNotReachHere();
+    }
+    assert(klass->is_loader_alive(), "must be alive");
+  }
+};
 #endif // ASSERT
 
 
@@ -550,8 +552,11 @@
   // All static stubs need to be cleaned.
   clean_ic_stubs();
 
+#ifdef ASSERT
   // Check that the metadata embedded in the nmethod is alive
-  DEBUG_ONLY(metadata_do(check_class));
+  CheckClass check_class;
+  metadata_do(&check_class);
+#endif
   return true;
 }
 
@@ -628,3 +633,35 @@
          os::is_readable_pointer(method->constants()) &&
          os::is_readable_pointer(method->signature());
 }
+
+class HasEvolDependency : public MetadataClosure {
+  bool _has_evol_dependency;
+ public:
+  HasEvolDependency() : _has_evol_dependency(false) {}
+  void do_metadata(Metadata* md) {
+    if (md->is_method()) {
+      Method* method = (Method*)md;
+      if (method->is_old()) {
+        _has_evol_dependency = true;
+      }
+    }
+  }
+  bool has_evol_dependency() const { return _has_evol_dependency; }
+};
+
+bool CompiledMethod::has_evol_metadata() {
+  // Check the metadata in relocIter and CompiledIC and also deoptimize
+  // any nmethod that has reference to old methods.
+  HasEvolDependency check_evol;
+  metadata_do(&check_evol);
+  if (check_evol.has_evol_dependency() && log_is_enabled(Debug, redefine, class, nmethod)) {
+    ResourceMark rm;
+    log_debug(redefine, class, nmethod)
+            ("Found evol dependency of nmethod %s.%s(%s) compile_id=%d on in nmethod metadata",
+             _method->method_holder()->external_name(),
+             _method->name()->as_C_string(),
+             _method->signature()->as_C_string(),
+             compile_id());
+  }
+  return check_evol.has_evol_dependency();
+}
--- a/src/hotspot/share/code/compiledMethod.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/code/compiledMethod.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -38,6 +38,7 @@
 class NativeCallWrapper;
 class ScopeDesc;
 class CompiledIC;
+class MetadataClosure;
 
 // This class is used internally by nmethods, to cache
 // exception/pc/handler information.
@@ -368,6 +369,8 @@
   void verify_oop_relocations();
 
   virtual bool is_evol_dependent() = 0;
+  bool has_evol_metadata();
+
   // Fast breakpoint support. Tells if this compiled method is
   // dependent on the given method. Returns true if this nmethod
   // corresponds to the given method as well.
@@ -384,7 +387,7 @@
   Method* attached_method(address call_pc);
   Method* attached_method_before_pc(address pc);
 
-  virtual void metadata_do(void f(Metadata*)) = 0;
+  virtual void metadata_do(MetadataClosure* f) = 0;
 
   // GC support
  protected:
--- a/src/hotspot/share/code/nmethod.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/code/nmethod.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -1089,7 +1089,6 @@
     if (_method->code() == this) {
       _method->clear_code(); // Break a cycle
     }
-    _method = NULL;            // Clear the method of this dead nmethod
   }
 
   // Make the class unloaded - i.e., change state and notify sweeper
@@ -1109,6 +1108,9 @@
     Universe::heap()->unregister_nmethod(this);
   }
 
+  // Clear the method of this dead nmethod
+  set_method(NULL);
+
   // Log the unloading.
   log_state_change();
 
@@ -1499,7 +1501,7 @@
 }
 
 // Iterate over metadata calling this function.   Used by RedefineClasses
-void nmethod::metadata_do(void f(Metadata*)) {
+void nmethod::metadata_do(MetadataClosure* f) {
   {
     // Visit all immediate references that are embedded in the instruction stream.
     RelocIterator iter(this, oops_reloc_begin());
@@ -1514,7 +1516,7 @@
                "metadata must be found in exactly one place");
         if (r->metadata_is_immediate() && r->metadata_value() != NULL) {
           Metadata* md = r->metadata_value();
-          if (md != _method) f(md);
+          if (md != _method) f->do_metadata(md);
         }
       } else if (iter.type() == relocInfo::virtual_call_type) {
         // Check compiledIC holders associated with this nmethod
@@ -1522,12 +1524,12 @@
         CompiledIC *ic = CompiledIC_at(&iter);
         if (ic->is_icholder_call()) {
           CompiledICHolder* cichk = ic->cached_icholder();
-          f(cichk->holder_metadata());
-          f(cichk->holder_klass());
+          f->do_metadata(cichk->holder_metadata());
+          f->do_metadata(cichk->holder_klass());
         } else {
           Metadata* ic_oop = ic->cached_metadata();
           if (ic_oop != NULL) {
-            f(ic_oop);
+            f->do_metadata(ic_oop);
           }
         }
       }
@@ -1538,11 +1540,11 @@
   for (Metadata** p = metadata_begin(); p < metadata_end(); p++) {
     if (*p == Universe::non_oop_word() || *p == NULL)  continue;  // skip non-oops
     Metadata* md = *p;
-    f(md);
+    f->do_metadata(md);
   }
 
   // Visit metadata not embedded in the other places.
-  if (_method != NULL) f(_method);
+  if (_method != NULL) f->do_metadata(_method);
 }
 
 // The _is_unloading_state encodes a tuple comprising the unloading cycle
--- a/src/hotspot/share/code/nmethod.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/code/nmethod.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -591,7 +591,7 @@
   static int osr_entry_point_offset()             { return offset_of(nmethod, _osr_entry_point); }
   static int state_offset()                       { return offset_of(nmethod, _state); }
 
-  virtual void metadata_do(void f(Metadata*));
+  virtual void metadata_do(MetadataClosure* f);
 
   NativeCallWrapper* call_wrapper_at(address call) const;
   NativeCallWrapper* call_wrapper_before(address return_pc) const;
--- a/src/hotspot/share/compiler/compileTask.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/compiler/compileTask.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -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
@@ -197,13 +197,13 @@
 }
 
 // RedefineClasses support
-void CompileTask::metadata_do(void f(Metadata*)) {
+void CompileTask::metadata_do(MetadataClosure* f) {
   if (is_unloaded()) {
     return;
   }
-  f(method());
+  f->do_metadata(method());
   if (hot_method() != NULL && hot_method() != method()) {
-    f(hot_method());
+    f->do_metadata(hot_method());
   }
 }
 
--- a/src/hotspot/share/compiler/compileTask.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/compiler/compileTask.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -177,7 +177,7 @@
   bool         is_unloaded() const;
 
   // RedefineClasses support
-  void         metadata_do(void f(Metadata*));
+  void         metadata_do(MetadataClosure* f);
   void         mark_on_stack();
 
 private:
--- a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -4248,7 +4248,7 @@
   verify_overflow_empty();
 
   if (should_unload_classes()) {
-    heap->prune_nmethods();
+    heap->prune_scavengable_nmethods();
   }
   JvmtiExport::gc_epilogue();
 
--- a/src/hotspot/share/gc/g1/g1BarrierSet.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1BarrierSet.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -58,7 +58,8 @@
   _satb_mark_queue_buffer_allocator("SATB Buffer Allocator", G1SATBBufferSize),
   _dirty_card_queue_buffer_allocator("DC Buffer Allocator", G1UpdateBufferSize),
   _satb_mark_queue_set(),
-  _dirty_card_queue_set()
+  _dirty_card_queue_set(),
+  _shared_dirty_card_queue(&_dirty_card_queue_set)
 {}
 
 void G1BarrierSet::enqueue(oop pre_val) {
--- a/src/hotspot/share/gc/g1/g1BarrierSet.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1BarrierSet.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -27,6 +27,7 @@
 
 #include "gc/g1/g1DirtyCardQueue.hpp"
 #include "gc/g1/g1SATBMarkQueueSet.hpp"
+#include "gc/g1/g1SharedDirtyCardQueue.hpp"
 #include "gc/shared/cardTable.hpp"
 #include "gc/shared/cardTableBarrierSet.hpp"
 
@@ -42,6 +43,7 @@
   BufferNode::Allocator _dirty_card_queue_buffer_allocator;
   G1SATBMarkQueueSet _satb_mark_queue_set;
   G1DirtyCardQueueSet _dirty_card_queue_set;
+  G1SharedDirtyCardQueue _shared_dirty_card_queue;
 
   static G1BarrierSet* g1_barrier_set() {
     return barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
@@ -91,6 +93,10 @@
     return g1_barrier_set()->_dirty_card_queue_set;
   }
 
+  static G1SharedDirtyCardQueue& shared_dirty_card_queue() {
+    return g1_barrier_set()->_shared_dirty_card_queue;
+  }
+
   // Callbacks for runtime accesses.
   template <DecoratorSet decorators, typename BarrierSetT = G1BarrierSet>
   class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -1682,12 +1682,10 @@
   // later, based on the concurrent refinement object.
   G1BarrierSet::dirty_card_queue_set().initialize(DirtyCardQ_CBL_mon,
                                                   &bs->dirty_card_queue_buffer_allocator(),
-                                                  Shared_DirtyCardQ_lock,
                                                   true); // init_free_ids
 
   dirty_card_queue_set().initialize(DirtyCardQ_CBL_mon,
-                                    &bs->dirty_card_queue_buffer_allocator(),
-                                    Shared_DirtyCardQ_lock);
+                                    &bs->dirty_card_queue_buffer_allocator());
 
   // Create the hot card cache.
   _hot_card_cache = new G1HotCardCache(this);
@@ -2537,7 +2535,7 @@
 
   // Update common counters.
   increment_total_collections(full /* full gc */);
-  if (full) {
+  if (full || collector_state()->in_initial_mark_gc()) {
     increment_old_marking_cycles_started();
   }
 
@@ -2863,16 +2861,92 @@
 };
 
 void G1CollectedHeap::start_new_collection_set() {
+  double start = os::elapsedTime();
+
   collection_set()->start_incremental_building();
 
   clear_cset_fast_test();
 
   guarantee(_eden.length() == 0, "eden should have been cleared");
   policy()->transfer_survivors_to_cset(survivor());
+
+  // We redo the verification but now wrt to the new CSet which
+  // has just got initialized after the previous CSet was freed.
+  _cm->verify_no_collection_set_oops();
+
+  phase_times()->record_start_new_cset_time_ms((os::elapsedTime() - start) * 1000.0);
 }
 
-bool
-G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) {
+void G1CollectedHeap::calculate_collection_set(G1EvacuationInfo& evacuation_info, double target_pause_time_ms){
+  policy()->finalize_collection_set(target_pause_time_ms, &_survivor);
+  evacuation_info.set_collectionset_regions(collection_set()->region_length());
+
+  _cm->verify_no_collection_set_oops();
+
+  if (_hr_printer.is_active()) {
+    G1PrintCollectionSetClosure cl(&_hr_printer);
+    _collection_set.iterate(&cl);
+  }
+}
+
+G1HeapVerifier::G1VerifyType G1CollectedHeap::young_collection_verify_type() const {
+  if (collector_state()->in_initial_mark_gc()) {
+    return G1HeapVerifier::G1VerifyConcurrentStart;
+  } else if (collector_state()->in_young_only_phase()) {
+    return G1HeapVerifier::G1VerifyYoungNormal;
+  } else {
+    return G1HeapVerifier::G1VerifyMixed;
+  }
+}
+
+void G1CollectedHeap::verify_before_young_collection(G1HeapVerifier::G1VerifyType type) {
+  if (VerifyRememberedSets) {
+    log_info(gc, verify)("[Verifying RemSets before GC]");
+    VerifyRegionRemSetClosure v_cl;
+    heap_region_iterate(&v_cl);
+  }
+  _verifier->verify_before_gc(type);
+  _verifier->check_bitmaps("GC Start");
+}
+
+void G1CollectedHeap::verify_after_young_collection(G1HeapVerifier::G1VerifyType type) {
+  if (VerifyRememberedSets) {
+    log_info(gc, verify)("[Verifying RemSets after GC]");
+    VerifyRegionRemSetClosure v_cl;
+    heap_region_iterate(&v_cl);
+  }
+  _verifier->verify_after_gc(type);
+  _verifier->check_bitmaps("GC End");
+}
+
+void G1CollectedHeap::expand_heap_after_young_collection(){
+  size_t expand_bytes = _heap_sizing_policy->expansion_amount();
+  if (expand_bytes > 0) {
+    // No need for an ergo logging here,
+    // expansion_amount() does this when it returns a value > 0.
+    double expand_ms;
+    if (!expand(expand_bytes, _workers, &expand_ms)) {
+      // We failed to expand the heap. Cannot do anything about it.
+    }
+    phase_times()->record_expand_heap_time(expand_ms);
+  }
+}
+
+const char* G1CollectedHeap::young_gc_name() const {
+  if (collector_state()->in_initial_mark_gc()) {
+    return "Pause Young (Concurrent Start)";
+  } else if (collector_state()->in_young_only_phase()) {
+    if (collector_state()->in_young_gc_before_mixed()) {
+      return "Pause Young (Prepare Mixed)";
+    } else {
+      return "Pause Young (Normal)";
+    }
+  } else {
+    return "Pause Young (Mixed)";
+  }
+}
+
+bool G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) {
   assert_at_safepoint_on_vm_thread();
   guarantee(!is_gc_active(), "collection is not reentrant");
 
@@ -2880,16 +2954,16 @@
     return false;
   }
 
-  _gc_timer_stw->register_gc_start();
-
   GCIdMark gc_id_mark;
-  _gc_tracer_stw->report_gc_start(gc_cause(), _gc_timer_stw->gc_start());
 
   SvcGCMarker sgcm(SvcGCMarker::MINOR);
   ResourceMark rm;
 
   policy()->note_gc_start();
 
+  _gc_timer_stw->register_gc_start();
+  _gc_tracer_stw->report_gc_start(gc_cause(), _gc_timer_stw->gc_start());
+
   wait_for_root_region_scanning();
 
   print_heap_before_gc();
@@ -2909,8 +2983,7 @@
 
   // We do not allow initial-mark to be piggy-backed on a mixed GC.
   assert(!collector_state()->in_initial_mark_gc() ||
-          collector_state()->in_young_only_phase(), "sanity");
-
+         collector_state()->in_young_only_phase(), "sanity");
   // We also do not allow mixed GCs during marking.
   assert(!collector_state()->mark_or_rebuild_in_progress() || collector_state()->in_young_only_phase(), "sanity");
 
@@ -2918,39 +2991,19 @@
   // thread has completed its logging output and it's safe to signal
   // the CM thread, the flag's value in the policy has been reset.
   bool should_start_conc_mark = collector_state()->in_initial_mark_gc();
+  if (should_start_conc_mark) {
+    _cm->gc_tracer_cm()->set_gc_cause(gc_cause());
+  }
 
   // Inner scope for scope based logging, timers, and stats collection
   {
     G1EvacuationInfo evacuation_info;
 
-    if (collector_state()->in_initial_mark_gc()) {
-      // We are about to start a marking cycle, so we increment the
-      // full collection counter.
-      increment_old_marking_cycles_started();
-      _cm->gc_tracer_cm()->set_gc_cause(gc_cause());
-    }
-
     _gc_tracer_stw->report_yc_type(collector_state()->yc_type());
 
     GCTraceCPUTime tcpu;
 
-    G1HeapVerifier::G1VerifyType verify_type;
-    FormatBuffer<> gc_string("Pause Young ");
-    if (collector_state()->in_initial_mark_gc()) {
-      gc_string.append("(Concurrent Start)");
-      verify_type = G1HeapVerifier::G1VerifyConcurrentStart;
-    } else if (collector_state()->in_young_only_phase()) {
-      if (collector_state()->in_young_gc_before_mixed()) {
-        gc_string.append("(Prepare Mixed)");
-      } else {
-        gc_string.append("(Normal)");
-      }
-      verify_type = G1HeapVerifier::G1VerifyYoungNormal;
-    } else {
-      gc_string.append("(Mixed)");
-      verify_type = G1HeapVerifier::G1VerifyMixed;
-    }
-    GCTraceTime(Info, gc) tm(gc_string, NULL, gc_cause(), true);
+    GCTraceTime(Info, gc) tm(young_gc_name(), NULL, gc_cause(), true);
 
     uint active_workers = WorkerPolicy::calc_active_workers(workers()->total_workers(),
                                                             workers()->active_workers(),
@@ -2965,88 +3018,43 @@
     G1HeapTransition heap_transition(this);
     size_t heap_used_bytes_before_gc = used();
 
-    // Don't dynamically change the number of GC threads this early.  A value of
-    // 0 is used to indicate serial work.  When parallel work is done,
-    // it will be set.
-
-    { // Call to jvmpi::post_class_unload_events must occur outside of active GC
+    {
       IsGCActiveMark x;
 
       gc_prologue(false);
 
-      if (VerifyRememberedSets) {
-        log_info(gc, verify)("[Verifying RemSets before GC]");
-        VerifyRegionRemSetClosure v_cl;
-        heap_region_iterate(&v_cl);
-      }
-
-      _verifier->verify_before_gc(verify_type);
-
-      _verifier->check_bitmaps("GC Start");
-
-#if COMPILER2_OR_JVMCI
-      DerivedPointerTable::clear();
-#endif
-
-      // Please see comment in g1CollectedHeap.hpp and
-      // G1CollectedHeap::ref_processing_init() to see how
-      // reference processing currently works in G1.
-
-      // Enable discovery in the STW reference processor
-      _ref_processor_stw->enable_discovery();
+      G1HeapVerifier::G1VerifyType verify_type = young_collection_verify_type();
+      verify_before_young_collection(verify_type);
 
       {
+        // The elapsed time induced by the start time below deliberately elides
+        // the possible verification above.
+        double sample_start_time_sec = os::elapsedTime();
+
+        // Please see comment in g1CollectedHeap.hpp and
+        // G1CollectedHeap::ref_processing_init() to see how
+        // reference processing currently works in G1.
+        _ref_processor_stw->enable_discovery();
+
         // We want to temporarily turn off discovery by the
         // CM ref processor, if necessary, and turn it back on
         // on again later if we do. Using a scoped
         // NoRefDiscovery object will do this.
         NoRefDiscovery no_cm_discovery(_ref_processor_cm);
 
-        // Forget the current alloc region (we might even choose it to be part
+        policy()->record_collection_pause_start(sample_start_time_sec);
+
+        // Forget the current allocation region (we might even choose it to be part
         // of the collection set!).
         _allocator->release_mutator_alloc_region();
 
-        // This timing is only used by the ergonomics to handle our pause target.
-        // It is unclear why this should not include the full pause. We will
-        // investigate this in CR 7178365.
-        //
-        // Preserving the old comment here if that helps the investigation:
-        //
-        // The elapsed time induced by the start time below deliberately elides
-        // the possible verification above.
-        double sample_start_time_sec = os::elapsedTime();
-
-        policy()->record_collection_pause_start(sample_start_time_sec);
-
-        if (collector_state()->in_initial_mark_gc()) {
-          concurrent_mark()->pre_initial_mark();
-        }
-
-        policy()->finalize_collection_set(target_pause_time_ms, &_survivor);
-
-        evacuation_info.set_collectionset_regions(collection_set()->region_length());
-
-        register_humongous_regions_with_cset();
-
-        assert(_verifier->check_cset_fast_test(), "Inconsistency in the InCSetState table.");
-
-        // We call this after finalize_cset() to
-        // ensure that the CSet has been finalized.
-        _cm->verify_no_cset_oops();
-
-        if (_hr_printer.is_active()) {
-          G1PrintCollectionSetClosure cl(&_hr_printer);
-          _collection_set.iterate(&cl);
-        }
-
-        // Initialize the GC alloc regions.
-        _allocator->init_gc_alloc_regions(evacuation_info);
+        calculate_collection_set(evacuation_info, target_pause_time_ms);
 
         G1ParScanThreadStateSet per_thread_states(this,
                                                   workers()->active_workers(),
                                                   collection_set()->young_region_length(),
                                                   collection_set()->optional_region_length());
-        pre_evacuate_collection_set();
+        pre_evacuate_collection_set(evacuation_info);
 
         // Actually do the work...
         evacuate_collection_set(&per_thread_states);
@@ -3054,39 +3062,12 @@
 
         post_evacuate_collection_set(evacuation_info, &per_thread_states);
 
-        const size_t* surviving_young_words = per_thread_states.surviving_young_words();
-        free_collection_set(&_collection_set, evacuation_info, surviving_young_words);
-
-        eagerly_reclaim_humongous_regions();
-
-        record_obj_copy_mem_stats();
+        start_new_collection_set();
+
         _survivor_evac_stats.adjust_desired_plab_sz();
         _old_evac_stats.adjust_desired_plab_sz();
 
-        double start = os::elapsedTime();
-        start_new_collection_set();
-        phase_times()->record_start_new_cset_time_ms((os::elapsedTime() - start) * 1000.0);
-
-        if (evacuation_failed()) {
-          double recalculate_used_start = os::elapsedTime();
-          set_used(recalculate_used());
-          phase_times()->record_evac_fail_recalc_used_time((os::elapsedTime() - recalculate_used_start) * 1000.0);
-
-          if (_archive_allocator != NULL) {
-            _archive_allocator->clear_used();
-          }
-          for (uint i = 0; i < ParallelGCThreads; i++) {
-            if (_evacuation_failed_info_array[i].has_failed()) {
-              _gc_tracer_stw->report_evacuation_failed(_evacuation_failed_info_array[i]);
-            }
-          }
-        } else {
-          // The "used" of the the collection set have already been subtracted
-          // when they were freed.  Add in the bytes evacuated.
-          increase_used(policy()->bytes_copied_during_gc());
-        }
-
-        if (collector_state()->in_initial_mark_gc()) {
+        if (should_start_conc_mark) {
           // We have to do this before we notify the CM threads that
           // they can start working to make sure that all the
           // appropriate initialization is done on the CM object.
@@ -3100,50 +3081,16 @@
 
         _allocator->init_mutator_alloc_region();
 
-        {
-          size_t expand_bytes = _heap_sizing_policy->expansion_amount();
-          if (expand_bytes > 0) {
-            size_t bytes_before = capacity();
-            // No need for an ergo logging here,
-            // expansion_amount() does this when it returns a value > 0.
-            double expand_ms;
-            if (!expand(expand_bytes, _workers, &expand_ms)) {
-              // We failed to expand the heap. Cannot do anything about it.
-            }
-            phase_times()->record_expand_heap_time(expand_ms);
-          }
-        }
-
-        // We redo the verification but now wrt to the new CSet which
-        // has just got initialized after the previous CSet was freed.
-        _cm->verify_no_cset_oops();
-
-        // This timing is only used by the ergonomics to handle our pause target.
-        // It is unclear why this should not include the full pause. We will
-        // investigate this in CR 7178365.
+        expand_heap_after_young_collection();
+
         double sample_end_time_sec = os::elapsedTime();
         double pause_time_ms = (sample_end_time_sec - sample_start_time_sec) * MILLIUNITS;
         size_t total_cards_scanned = phase_times()->sum_thread_work_items(G1GCPhaseTimes::ScanRS, G1GCPhaseTimes::ScanRSScannedCards);
         policy()->record_collection_pause_end(pause_time_ms, total_cards_scanned, heap_used_bytes_before_gc);
-
-        evacuation_info.set_collectionset_used_before(collection_set()->bytes_used_before());
-        evacuation_info.set_bytes_copied(policy()->bytes_copied_during_gc());
-
-        if (VerifyRememberedSets) {
-          log_info(gc, verify)("[Verifying RemSets after GC]");
-          VerifyRegionRemSetClosure v_cl;
-          heap_region_iterate(&v_cl);
-        }
-
-        _verifier->verify_after_gc(verify_type);
-        _verifier->check_bitmaps("GC End");
-
-        assert(!_ref_processor_stw->discovery_enabled(), "Postcondition");
-        _ref_processor_stw->verify_no_references_recorded();
-
-        // CM reference discovery will be re-enabled if necessary.
       }
 
+      verify_after_young_collection(verify_type);
+
 #ifdef TRACESPINNING
       ParallelTaskTerminator::print_termination_counts();
 #endif
@@ -3159,11 +3106,6 @@
     policy()->print_phases();
     heap_transition.print();
 
-    // It is not yet to safe to tell the concurrent mark to
-    // start as we have some optional output below. We don't want the
-    // output from the concurrent mark thread interfering with this
-    // logging output either.
-
     _hrm->verify_optional();
     _verifier->verify_region_sets_optional();
 
@@ -3190,13 +3132,11 @@
   // that came from the pause.
 
   if (should_start_conc_mark) {
-    // CAUTION: after the doConcurrentMark() call below,
-    // the concurrent marking thread(s) could be running
-    // concurrently with us. Make sure that anything after
-    // this point does not assume that we are the only GC thread
-    // running. Note: of course, the actual marking work will
-    // not start until the safepoint itself is released in
-    // SuspendibleThreadSet::desynchronize().
+    // CAUTION: after the doConcurrentMark() call below, the concurrent marking
+    // thread(s) could be running concurrently with us. Make sure that anything
+    // after this point does not assume that we are the only GC thread running.
+    // Note: of course, the actual marking work will not start until the safepoint
+    // itself is released in SuspendibleThreadSet::desynchronize().
     do_concurrent_mark();
   }
 
@@ -3677,6 +3617,7 @@
 
   make_pending_list_reachable();
 
+  assert(!rp->discovery_enabled(), "Postcondition");
   rp->verify_no_references_recorded();
 
   double ref_proc_time = os::elapsedTime() - ref_proc_start;
@@ -3699,7 +3640,7 @@
   phase_times()->record_merge_pss_time_ms((os::elapsedTime() - merge_pss_time_start) * 1000.0);
 }
 
-void G1CollectedHeap::pre_evacuate_collection_set() {
+void G1CollectedHeap::pre_evacuate_collection_set(G1EvacuationInfo& evacuation_info) {
   _expand_heap_after_alloc_failure = true;
   _evacuation_failed = false;
 
@@ -3707,11 +3648,23 @@
   _hot_card_cache->reset_hot_cache_claimed_index();
   _hot_card_cache->set_use_cache(false);
 
+  // Initialize the GC alloc regions.
+  _allocator->init_gc_alloc_regions(evacuation_info);
+
+  register_humongous_regions_with_cset();
+  assert(_verifier->check_cset_fast_test(), "Inconsistency in the InCSetState table.");
+
   rem_set()->prepare_for_oops_into_collection_set_do();
   _preserved_marks_set.assert_empty();
 
+#if COMPILER2_OR_JVMCI
+  DerivedPointerTable::clear();
+#endif
+
   // InitialMark needs claim bits to keep track of the marked-through CLDs.
   if (collector_state()->in_initial_mark_gc()) {
+    concurrent_mark()->pre_initial_mark();
+
     double start_clear_claimed_marks = os::elapsedTime();
 
     ClassLoaderDataGraph::clear_claimed_marks();
@@ -3918,19 +3871,34 @@
     phase_times()->record_string_deduplication_time(string_cleanup_time_ms);
   }
 
+  _allocator->release_gc_alloc_regions(evacuation_info);
+
   if (evacuation_failed()) {
     restore_after_evac_failure();
 
     // Reset the G1EvacuationFailureALot counters and flags
-    // Note: the values are reset only when an actual
-    // evacuation failure occurs.
     NOT_PRODUCT(reset_evacuation_should_fail();)
+
+    double recalculate_used_start = os::elapsedTime();
+    set_used(recalculate_used());
+    phase_times()->record_evac_fail_recalc_used_time((os::elapsedTime() - recalculate_used_start) * 1000.0);
+
+    if (_archive_allocator != NULL) {
+      _archive_allocator->clear_used();
+    }
+    for (uint i = 0; i < ParallelGCThreads; i++) {
+      if (_evacuation_failed_info_array[i].has_failed()) {
+        _gc_tracer_stw->report_evacuation_failed(_evacuation_failed_info_array[i]);
+      }
+    }
+  } else {
+    // The "used" of the the collection set have already been subtracted
+    // when they were freed.  Add in the bytes evacuated.
+    increase_used(policy()->bytes_copied_during_gc());
   }
 
   _preserved_marks_set.assert_empty();
 
-  _allocator->release_gc_alloc_regions(evacuation_info);
-
   merge_per_thread_state_info(per_thread_states);
 
   // Reset and re-enable the hot card cache.
@@ -3942,6 +3910,16 @@
   purge_code_root_memory();
 
   redirty_logged_cards();
+
+  free_collection_set(&_collection_set, evacuation_info, per_thread_states->surviving_young_words());
+
+  eagerly_reclaim_humongous_regions();
+
+  record_obj_copy_mem_stats();
+
+  evacuation_info.set_collectionset_used_before(collection_set()->bytes_used_before());
+  evacuation_info.set_bytes_copied(policy()->bytes_copied_during_gc());
+
 #if COMPILER2_OR_JVMCI
   double start = os::elapsedTime();
   DerivedPointerTable::update_pointers();
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -357,6 +357,8 @@
     assert(Thread::current()->is_VM_thread(), "current thread is not VM thread"); \
   } while (0)
 
+  const char* young_gc_name() const;
+
   // The young region list.
   G1EdenRegions _eden;
   G1SurvivorRegions _survivor;
@@ -730,14 +732,21 @@
   // to the GC locker being active, true otherwise
   bool do_collection_pause_at_safepoint(double target_pause_time_ms);
 
+  G1HeapVerifier::G1VerifyType young_collection_verify_type() const;
+  void verify_before_young_collection(G1HeapVerifier::G1VerifyType type);
+  void verify_after_young_collection(G1HeapVerifier::G1VerifyType type);
+
+  void calculate_collection_set(G1EvacuationInfo& evacuation_info, double target_pause_time_ms);
+
   // Actually do the work of evacuating the collection set.
   void evacuate_collection_set(G1ParScanThreadStateSet* per_thread_states);
   void evacuate_optional_collection_set(G1ParScanThreadStateSet* per_thread_states);
   void evacuate_optional_regions(G1ParScanThreadStateSet* per_thread_states, G1OptionalCSet* ocset);
 
-  void pre_evacuate_collection_set();
+  void pre_evacuate_collection_set(G1EvacuationInfo& evacuation_info);
   void post_evacuate_collection_set(G1EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* pss);
 
+  void expand_heap_after_young_collection();
   // Update object copying statistics.
   void record_obj_copy_mem_stats();
 
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -734,7 +734,9 @@
 };
 
 void G1ConcurrentMark::pre_initial_mark() {
-  // Initialize marking structures. This has to be done in a STW phase.
+  assert_at_safepoint_on_vm_thread();
+
+  // Reset marking state.
   reset();
 
   // For each region note start of marking.
@@ -1944,7 +1946,7 @@
   }
 };
 
-void G1ConcurrentMark::verify_no_cset_oops() {
+void G1ConcurrentMark::verify_no_collection_set_oops() {
   assert(SafepointSynchronize::is_at_safepoint(), "should be at a safepoint");
   if (!_g1h->collector_state()->mark_or_rebuild_in_progress()) {
     return;
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -579,7 +579,7 @@
   // Verify that there are no collection set oops on the stacks (taskqueues /
   // global mark stack) and fingers (global / per-task).
   // If marking is not in progress, it's a no-op.
-  void verify_no_cset_oops() PRODUCT_RETURN;
+  void verify_no_collection_set_oops() PRODUCT_RETURN;
 
   inline bool do_yield_check();
 
--- a/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -56,21 +56,18 @@
   }
 };
 
-G1DirtyCardQueue::G1DirtyCardQueue(G1DirtyCardQueueSet* qset, bool permanent) :
+G1DirtyCardQueue::G1DirtyCardQueue(G1DirtyCardQueueSet* qset) :
   // Dirty card queues are always active, so we create them with their
   // active field set to true.
-  PtrQueue(qset, permanent, true /* active */)
+  PtrQueue(qset, true /* active */)
 { }
 
 G1DirtyCardQueue::~G1DirtyCardQueue() {
-  if (!is_permanent()) {
-    flush();
-  }
+  flush();
 }
 
 G1DirtyCardQueueSet::G1DirtyCardQueueSet(bool notify_when_complete) :
   PtrQueueSet(notify_when_complete),
-  _shared_dirty_card_queue(this, true /* permanent */),
   _free_ids(NULL),
   _processed_buffers_mut(0),
   _processed_buffers_rs_thread(0),
@@ -90,10 +87,8 @@
 
 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) {
     _free_ids = new G1FreeIdSet(0, num_par_ids());
   }
@@ -217,13 +212,7 @@
   } closure;
   Threads::threads_do(&closure);
 
-  shared_dirty_card_queue()->reset();
-}
-
-void G1DirtyCardQueueSet::concatenate_log(G1DirtyCardQueue& dcq) {
-  if (!dcq.is_empty()) {
-    dcq.flush();
-  }
+  G1BarrierSet::shared_dirty_card_queue().reset();
 }
 
 void G1DirtyCardQueueSet::concatenate_logs() {
@@ -234,16 +223,16 @@
   size_t old_limit = max_completed_buffers();
   set_max_completed_buffers(MaxCompletedBuffersUnlimited);
 
-  class ConcatenateThreadLogClosure : public ThreadClosure {
-    G1DirtyCardQueueSet* _qset;
-  public:
-    ConcatenateThreadLogClosure(G1DirtyCardQueueSet* qset) : _qset(qset) {}
+  struct ConcatenateThreadLogClosure : public ThreadClosure {
     virtual void do_thread(Thread* t) {
-      _qset->concatenate_log(G1ThreadLocalData::dirty_card_queue(t));
+      G1DirtyCardQueue& dcq = G1ThreadLocalData::dirty_card_queue(t);
+      if (!dcq.is_empty()) {
+        dcq.flush();
+      }
     }
-  } closure(this);
+  } closure;
   Threads::threads_do(&closure);
 
-  concatenate_log(_shared_dirty_card_queue);
+  G1BarrierSet::shared_dirty_card_queue().flush();
   set_max_completed_buffers(old_limit);
 }
--- a/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -48,7 +48,7 @@
 // A ptrQueue whose elements are "oops", pointers to object heads.
 class G1DirtyCardQueue: public PtrQueue {
 public:
-  G1DirtyCardQueue(G1DirtyCardQueueSet* qset, bool permanent = false);
+  G1DirtyCardQueue(G1DirtyCardQueueSet* qset);
 
   // Flush before destroying; queue may be used to capture pending work while
   // doing something else, with auto-flush on completion.
@@ -70,11 +70,7 @@
 
 };
 
-
-
 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
   // returns true.  Stops processing after the first closure
@@ -116,15 +112,12 @@
   // Current buffer node used for parallel iteration.
   BufferNode* volatile _cur_par_buffer_node;
 
-  void concatenate_log(G1DirtyCardQueue& dcq);
-
 public:
   G1DirtyCardQueueSet(bool notify_when_complete = true);
   ~G1DirtyCardQueueSet();
 
   void initialize(Monitor* cbl_mon,
                   BufferNode::Allocator* allocator,
-                  Mutex* lock,
                   bool init_free_ids = false);
 
   // The number of parallel ids that can be claimed to allow collector or
@@ -147,10 +140,6 @@
   // by reset_for_par_iteration.
   void par_apply_closure_to_all_completed_buffers(G1CardTableEntryClosure* cl);
 
-  G1DirtyCardQueue* shared_dirty_card_queue() {
-    return &_shared_dirty_card_queue;
-  }
-
   // If a full collection is happening, reset partial logs, and ignore
   // completed ones: the full collection will make them all irrelevant.
   void abandon_logs();
--- a/src/hotspot/share/gc/g1/g1Policy.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1Policy.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -1188,9 +1188,11 @@
   return (uint) result;
 }
 
-void G1Policy::finalize_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor) {
+uint G1Policy::finalize_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor) {
   double time_remaining_ms = _collection_set->finalize_young_part(target_pause_time_ms, survivor);
   _collection_set->finalize_old_part(time_remaining_ms);
+
+  return _collection_set->region_length();
 }
 
 void G1Policy::transfer_survivors_to_cset(const G1SurvivorRegions* survivors) {
--- a/src/hotspot/share/gc/g1/g1Policy.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1Policy.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -344,7 +344,7 @@
   bool next_gc_should_be_mixed(const char* true_action_str,
                                const char* false_action_str) const;
 
-  void finalize_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor);
+  uint finalize_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor);
 private:
   // Set the state to start a concurrent marking cycle and clear
   // _initiate_conc_mark_if_possible because it has now been
--- a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -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
@@ -205,8 +205,10 @@
                                                          MemoryType type) :
   G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type),
   _rs(rs),
+  _dram_mapper(NULL),
   _num_committed_dram(0),
   _num_committed_nvdimm(0),
+  _start_index_of_dram(0),
   _page_size(page_size),
   _commit_factor(commit_factor),
   _type(type) {
@@ -248,7 +250,6 @@
     _dram_mapper = new G1RegionsSmallerThanCommitSizeMapper(rs_dram, rs_dram.size(), _page_size, _region_granularity, _commit_factor, _type);
   }
 
-  _start_index_of_nvdimm = 0;
   _start_index_of_dram = (uint)(rs_nvdimm.size() / _region_granularity);
   return true;
 }
--- a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -101,12 +101,10 @@
 // part of space is mapped to dram and part to nv-dimm
 class G1RegionToHeteroSpaceMapper : public G1RegionToSpaceMapper {
 private:
-  size_t _pages_per_region;
   ReservedSpace _rs;
   G1RegionToSpaceMapper* _dram_mapper;
   uint _num_committed_dram;
   uint _num_committed_nvdimm;
-  uint _start_index_of_nvdimm;
   uint _start_index_of_dram;
   size_t _page_size;
   size_t _commit_factor;
--- a/src/hotspot/share/gc/g1/g1RemSet.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1RemSet.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -35,6 +35,7 @@
 #include "gc/g1/g1OopClosures.inline.hpp"
 #include "gc/g1/g1RootClosures.hpp"
 #include "gc/g1/g1RemSet.hpp"
+#include "gc/g1/g1SharedDirtyCardQueue.hpp"
 #include "gc/g1/heapRegion.inline.hpp"
 #include "gc/g1/heapRegionManager.inline.hpp"
 #include "gc/g1/heapRegionRemSet.hpp"
@@ -519,9 +520,7 @@
 }
 
 void G1RemSet::prepare_for_oops_into_collection_set_do() {
-  G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set();
-  dcqs.concatenate_logs();
-
+  G1BarrierSet::dirty_card_queue_set().concatenate_logs();
   _scan_state->reset();
 }
 
@@ -660,29 +659,30 @@
   assert(!dirty_region.is_empty(), "sanity");
 
   G1ConcurrentRefineOopClosure conc_refine_cl(_g1h, worker_i);
-
-  bool card_processed =
-    r->oops_on_card_seq_iterate_careful<false>(dirty_region, &conc_refine_cl);
+  if (r->oops_on_card_seq_iterate_careful<false>(dirty_region, &conc_refine_cl)) {
+    _num_conc_refined_cards++; // Unsynchronized update, only used for logging.
+    return;
+  }
 
   // If unable to process the card then we encountered an unparsable
-  // part of the heap (e.g. a partially allocated object) while
-  // processing a stale card.  Despite the card being stale, redirty
-  // and re-enqueue, because we've already cleaned the card.  Without
-  // this we could incorrectly discard a non-stale card.
-  if (!card_processed) {
-    // The card might have gotten re-dirtied and re-enqueued while we
-    // worked.  (In fact, it's pretty likely.)
-    if (*card_ptr != G1CardTable::dirty_card_val()) {
-      *card_ptr = G1CardTable::dirty_card_val();
-      MutexLockerEx x(Shared_DirtyCardQ_lock,
-                      Mutex::_no_safepoint_check_flag);
-      G1DirtyCardQueue* sdcq =
-        G1BarrierSet::dirty_card_queue_set().shared_dirty_card_queue();
-      sdcq->enqueue(card_ptr);
-    }
-  } else {
-    _num_conc_refined_cards++; // Unsynchronized update, only used for logging.
+  // part of the heap (e.g. a partially allocated object, so only
+  // temporarily a problem) while processing a stale card.  Despite
+  // the card being stale, we can't simply ignore it, because we've
+  // already marked the card cleaned, so taken responsibility for
+  // ensuring the card gets scanned.
+  //
+  // However, the card might have gotten re-dirtied and re-enqueued
+  // while we worked.  (In fact, it's pretty likely.)
+  if (*card_ptr == G1CardTable::dirty_card_val()) {
+    return;
   }
+
+  // Re-dirty the card and enqueue in the *shared* queue.  Can't use
+  // the thread-local queue, because that might be the queue that is
+  // being processed by us; we could be a Java thread conscripted to
+  // perform refinement on our queue's current buffer.
+  *card_ptr = G1CardTable::dirty_card_val();
+  G1BarrierSet::shared_dirty_card_queue().enqueue(card_ptr);
 }
 
 bool G1RemSet::refine_card_during_gc(CardValue* card_ptr,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/g1/g1SharedDirtyCardQueue.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -0,0 +1,73 @@
+/*
+ * 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/g1DirtyCardQueue.hpp"
+#include "gc/g1/g1SharedDirtyCardQueue.hpp"
+#include "gc/shared/ptrQueue.hpp"
+#include "runtime/mutex.hpp"
+#include "runtime/mutexLocker.hpp"
+
+G1SharedDirtyCardQueue::G1SharedDirtyCardQueue(G1DirtyCardQueueSet* qset) :
+  _qset(qset),
+  _buffer(NULL),
+  _index(0)
+{}
+
+G1SharedDirtyCardQueue::~G1SharedDirtyCardQueue() {
+  flush();
+}
+
+void G1SharedDirtyCardQueue::enqueue(void* card_ptr) {
+  MutexLockerEx ml(Shared_DirtyCardQ_lock, Mutex::_no_safepoint_check_flag);
+  if (_index == 0) {
+    flush();
+    _buffer = _qset->allocate_buffer();
+    _index = _qset->buffer_size();
+    assert(_index != 0, "invariant");
+  }
+  _buffer[--_index] = card_ptr;
+}
+
+void G1SharedDirtyCardQueue::flush() {
+  if (_buffer != NULL) {
+    BufferNode* node = BufferNode::make_node_from_buffer(_buffer, _index);
+    _buffer = NULL;
+    _index = 0;
+    if (node->index() == _qset->buffer_size()) {
+      _qset->deallocate_buffer(node);
+    } else {
+      _qset->enqueue_completed_buffer(node);
+    }
+  }
+  assert(_index == 0, "invariant");
+}
+
+void G1SharedDirtyCardQueue::reset() {
+  if (_buffer == NULL) {
+    _index = 0;
+  } else {
+    _index = _qset->buffer_size();
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/g1/g1SharedDirtyCardQueue.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -0,0 +1,60 @@
+/*
+ * 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_G1SHAREDDIRTYCARDQUEUE_HPP
+#define SHARE_GC_G1_G1SHAREDDIRTYCARDQUEUE_HPP
+
+#include "utilities/globalDefinitions.hpp"
+
+class G1DirtyCardQueueSet;
+
+// A dirty card queue providing thread-safe enqueue.  A shared global
+// instance can be used for cases where a thread-local dirty card can't
+// be used.
+class G1SharedDirtyCardQueue {
+  G1DirtyCardQueueSet* const _qset;
+  void** _buffer;
+  size_t _index;
+
+  // Noncopyable
+  G1SharedDirtyCardQueue(const G1SharedDirtyCardQueue&);
+  G1SharedDirtyCardQueue& operator=(const G1SharedDirtyCardQueue&);
+
+public:
+  G1SharedDirtyCardQueue(G1DirtyCardQueueSet* qset);
+  ~G1SharedDirtyCardQueue();    // flushes the queue.
+
+  // Thread-safe addition to shared logging buffer.
+  void enqueue(void* card_ptr);
+
+  // Flush any pending entries to the qset and remove the buffer.
+  // Not thread-safe.
+  void flush();
+
+  // Discard any pending entries.
+  // Not thread-safe.
+  void reset();
+};
+
+#endif // SHARE_GC_G1_G1SHAREDDIRTYCARDQUEUE_HPP
--- a/src/hotspot/share/gc/parallel/adjoiningGenerations.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/adjoiningGenerations.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -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
@@ -119,7 +119,7 @@
   }
 }
 
-AdjoiningGenerations::AdjoiningGenerations() { }
+AdjoiningGenerations::AdjoiningGenerations(): _young_gen(NULL), _old_gen(NULL), _virtual_spaces(NULL) { }
 
 size_t AdjoiningGenerations::reserved_byte_size() {
   return virtual_spaces()->reserved_space().size();
--- a/src/hotspot/share/gc/parallel/adjoiningGenerations.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/adjoiningGenerations.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -50,6 +50,7 @@
   bool request_young_gen_expansion(size_t desired_change_in_bytes);
 
  protected:
+   AdjoiningGenerations();
    // The young generation and old generation, respectively
    PSYoungGen* _young_gen;
    PSOldGen* _old_gen;
@@ -59,7 +60,6 @@
 
  public:
   AdjoiningGenerations(ReservedSpace rs, GenerationSizer* policy, size_t alignment);
-  AdjoiningGenerations();
 
   // Accessors
   PSYoungGen* young_gen() { return _young_gen; }
--- a/src/hotspot/share/gc/parallel/gcTaskThread.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/gcTaskThread.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -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
@@ -167,7 +167,6 @@
         // so that a task can complete without waiting for idle tasks.
         // They have to be terminated separately.
         IdleGCTask::destroy((IdleGCTask*)task);
-        set_is_working(true);
       }
 
       // Check if we should release our inner resources.
--- a/src/hotspot/share/gc/parallel/gcTaskThread.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/gcTaskThread.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -47,8 +47,6 @@
   GCTaskTimeStamp* time_stamp_at(uint index);
   void add_task_timestamp(const char* name, jlong t_entry, jlong t_exit);
 
-  bool _is_working;                     // True if participating in GC tasks
-
   // Factory create and destroy methods.
   static GCTaskThread* create(GCTaskManager* manager,
                               uint           which,
@@ -85,7 +83,6 @@
   uint processor_id() const {
     return _processor_id;
   }
-  void set_is_working(bool v) { _is_working = v; }
 };
 
 class GCTaskTimeStamp : public CHeapObj<mtGC>
--- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -717,10 +717,10 @@
 }
 
 void ParallelScavengeHeap::flush_nmethod(nmethod* nm) {
-  ScavengableNMethods::flush_nmethod(nm);
+  // nothing particular
 }
 
-void ParallelScavengeHeap::prune_nmethods() {
+void ParallelScavengeHeap::prune_scavengable_nmethods() {
   ScavengableNMethods::prune_nmethods();
 }
 
--- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -93,7 +93,15 @@
 
  public:
   ParallelScavengeHeap(GenerationSizer* policy) :
-    CollectedHeap(), _collector_policy(policy), _death_march_count(0) { }
+    CollectedHeap(),
+    _collector_policy(policy),
+    _gens(NULL),
+    _death_march_count(0),
+    _young_manager(NULL),
+    _old_manager(NULL),
+    _eden_pool(NULL),
+    _survivor_pool(NULL),
+    _old_pool(NULL) { }
 
   // For use by VM operations
   enum CollectionType {
@@ -162,7 +170,7 @@
   virtual void verify_nmethod(nmethod* nm);
   virtual void flush_nmethod(nmethod* nm);
 
-  void prune_nmethods();
+  void prune_scavengable_nmethods();
 
   size_t max_capacity() const;
 
--- a/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, 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
@@ -49,34 +49,25 @@
                         init_survivor_size,
                         gc_pause_goal_sec,
                         gc_cost_ratio),
+     _avg_major_pause(new AdaptivePaddedAverage(AdaptiveTimeWeight, PausePadding)),
+     _avg_base_footprint(new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight)),
+     _gc_stats(),
      _collection_cost_margin_fraction(AdaptiveSizePolicyCollectionCostMargin / 100.0),
+     _major_pause_old_estimator(new LinearLeastSquareFit(AdaptiveSizePolicyWeight)),
+     _major_pause_young_estimator(new LinearLeastSquareFit(AdaptiveSizePolicyWeight)),
      _latest_major_mutator_interval_seconds(0),
      _space_alignment(space_alignment),
      _gc_minor_pause_goal_sec(gc_minor_pause_goal_sec),
      _live_at_last_full_gc(init_promo_size),
-     _young_gen_change_for_major_pause_count(0)
+     _change_old_gen_for_min_pauses(0),
+     _change_young_gen_for_maj_pauses(0),
+     _old_gen_policy_is_ready(false),
+     _young_gen_size_increment_supplement(YoungGenerationSizeSupplement),
+     _old_gen_size_increment_supplement(TenuredGenerationSizeSupplement),
+     _bytes_absorbed_from_eden(0)
 {
-  // Sizing policy statistics
-  _avg_major_pause    =
-    new AdaptivePaddedAverage(AdaptiveTimeWeight, PausePadding);
-  _avg_minor_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
-  _avg_major_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
-
-  _avg_base_footprint = new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight);
-  _major_pause_old_estimator =
-    new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
-  _major_pause_young_estimator =
-    new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
-  _major_collection_estimator =
-    new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
-
-  _young_gen_size_increment_supplement = YoungGenerationSizeSupplement;
-  _old_gen_size_increment_supplement = TenuredGenerationSizeSupplement;
-
   // Start the timers
   _major_timer.start();
-
-  _old_gen_policy_is_ready = false;
 }
 
 size_t PSAdaptiveSizePolicy::calculate_free_based_on_live(size_t live, uintx ratio_as_percentage) {
--- a/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -75,7 +75,6 @@
   // Statistical data gathered for GC
   GCStats _gc_stats;
 
-  size_t _survivor_size_limit;   // Limit in bytes of survivor size
   const double _collection_cost_margin_fraction;
 
   // Variable for estimating the major and minor pause times.
@@ -111,13 +110,6 @@
   // Flag indicating that the adaptive policy is ready to use
   bool _old_gen_policy_is_ready;
 
-  // Changing the generation sizing depends on the data that is
-  // gathered about the effects of changes on the pause times and
-  // throughput.  These variable count the number of data points
-  // gathered.  The policy may use these counters as a threshold
-  // for reliable data.
-  julong _young_gen_change_for_major_pause_count;
-
   // To facilitate faster growth at start up, supplement the normal
   // growth percentage for the young gen eden and the
   // old gen space for promotion with these value which decay
--- a/src/hotspot/share/gc/parallel/psFileBackedVirtualspace.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/psFileBackedVirtualspace.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -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
@@ -51,10 +51,6 @@
   return true;
 }
 
-PSFileBackedVirtualSpace::PSFileBackedVirtualSpace(ReservedSpace rs, const char* path) {
-  PSFileBackedVirtualSpace(rs, os::vm_page_size(), path);
-}
-
 bool PSFileBackedVirtualSpace::expand_by(size_t bytes) {
   assert(special(), "Since entire space is committed at initialization, _special should always be true for PSFileBackedVirtualSpace");
 
--- a/src/hotspot/share/gc/parallel/psFileBackedVirtualspace.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/psFileBackedVirtualspace.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -34,7 +34,6 @@
   bool _mapping_succeeded;
 public:
   PSFileBackedVirtualSpace(ReservedSpace rs, size_t alignment, const char* file_path);
-  PSFileBackedVirtualSpace(ReservedSpace rs, const char* file_path);
 
   bool   initialize();
   bool   expand_by(size_t bytes);
--- a/src/hotspot/share/gc/parallel/psMarkSweep.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/psMarkSweep.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -254,7 +254,7 @@
     MetaspaceUtils::verify_metrics();
 
     BiasedLocking::restore_marks();
-    heap->prune_nmethods();
+    heap->prune_scavengable_nmethods();
     JvmtiExport::gc_epilogue();
 
 #if COMPILER2_OR_JVMCI
--- a/src/hotspot/share/gc/parallel/psMarkSweepDecorator.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/psMarkSweepDecorator.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -52,7 +52,11 @@
  public:
   PSMarkSweepDecorator(MutableSpace* space, ObjectStartArray* start_array,
                        size_t allowed_dead_ratio) :
-    _space(space), _start_array(start_array),
+    _space(space),
+    _start_array(start_array),
+    _first_dead(NULL),
+    _end_of_live(NULL),
+    _compaction_top(NULL),
     _allowed_dead_ratio(allowed_dead_ratio) { }
 
   // During a compacting collection, we need to collapse objects into
--- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -406,19 +406,16 @@
 size_t mark_bitmap_size;
 #endif  // #ifdef ASSERT
 
-ParallelCompactData::ParallelCompactData()
-{
-  _region_start = 0;
-
-  _region_vspace = 0;
-  _reserved_byte_size = 0;
-  _region_data = 0;
-  _region_count = 0;
-
-  _block_vspace = 0;
-  _block_data = 0;
-  _block_count = 0;
-}
+ParallelCompactData::ParallelCompactData() :
+  _region_start(NULL),
+  DEBUG_ONLY(_region_end(NULL) COMMA)
+  _region_vspace(NULL),
+  _reserved_byte_size(0),
+  _region_data(NULL),
+  _region_count(0),
+  _block_vspace(NULL),
+  _block_data(NULL),
+  _block_count(0) {}
 
 bool ParallelCompactData::initialize(MemRegion covered_region)
 {
@@ -1061,7 +1058,7 @@
   ClassLoaderDataGraph::purge();
   MetaspaceUtils::verify_metrics();
 
-  heap->prune_nmethods();
+  heap->prune_scavengable_nmethods();
   JvmtiExport::gc_epilogue();
 
 #if COMPILER2_OR_JVMCI
--- a/src/hotspot/share/gc/parallel/psTasks.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/psTasks.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -98,8 +98,8 @@
 
     case code_cache:
       {
-        MarkingCodeBlobClosure each_scavengable_code_blob(&roots_to_old_closure, CodeBlobToOopClosure::FixRelocations);
-        ScavengableNMethods::scavengable_nmethods_do(&each_scavengable_code_blob);
+        MarkingCodeBlobClosure code_closure(&roots_to_old_closure, CodeBlobToOopClosure::FixRelocations);
+        ScavengableNMethods::nmethods_do(&code_closure);
         AOTLoader::oops_do(&roots_closure);
       }
       break;
--- a/src/hotspot/share/gc/parallel/psVirtualspace.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/psVirtualspace.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, 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
@@ -46,7 +46,13 @@
 }
 
 // Deprecated.
-PSVirtualSpace::PSVirtualSpace(): _alignment(os::vm_page_size()) {
+PSVirtualSpace::PSVirtualSpace():
+  _alignment(os::vm_page_size()),
+  _reserved_low_addr(NULL),
+  _reserved_high_addr(NULL),
+  _committed_low_addr(NULL),
+  _committed_high_addr(NULL),
+  _special(false) {
 }
 
 // Deprecated.
--- a/src/hotspot/share/gc/parallel/psVirtualspace.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/psVirtualspace.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -64,7 +64,14 @@
   // Eventually all instances should be created with the above 1- or 2-arg
   // constructors.  Then the 1st constructor below should become protected and
   // the 2nd ctor and initialize() removed.
-  PSVirtualSpace(size_t alignment): _alignment(alignment) { }
+  PSVirtualSpace(size_t alignment):
+    _alignment(alignment),
+    _reserved_low_addr(NULL),
+    _reserved_high_addr(NULL),
+    _committed_low_addr(NULL),
+    _committed_high_addr(NULL),
+    _special(false) {
+  }
   PSVirtualSpace();
   bool initialize(ReservedSpace rs, size_t commit_size);
 
--- a/src/hotspot/share/gc/parallel/psYoungGen.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/parallel/psYoungGen.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -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
@@ -35,12 +35,22 @@
 #include "runtime/java.hpp"
 #include "utilities/align.hpp"
 
-PSYoungGen::PSYoungGen(size_t        initial_size,
-                       size_t        min_size,
-                       size_t        max_size) :
+PSYoungGen::PSYoungGen(size_t initial_size, size_t min_size, size_t max_size) :
+  _reserved(),
+  _virtual_space(NULL),
+  _eden_space(NULL),
+  _from_space(NULL),
+  _to_space(NULL),
+  _eden_mark_sweep(NULL),
+  _from_mark_sweep(NULL),
+  _to_mark_sweep(NULL),
   _init_gen_size(initial_size),
   _min_gen_size(min_size),
-  _max_gen_size(max_size)
+  _max_gen_size(max_size),
+  _gen_counters(NULL),
+  _eden_counters(NULL),
+  _from_counters(NULL),
+  _to_counters(NULL)
 {}
 
 void PSYoungGen::initialize_virtual_space(ReservedSpace rs, size_t alignment) {
--- a/src/hotspot/share/gc/serial/genMarkSweep.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/serial/genMarkSweep.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -124,7 +124,7 @@
     rs->invalidate_or_clear(old_gen);
   }
 
-  gch->prune_nmethods();
+  gch->prune_scavengable_nmethods();
   JvmtiExport::gc_epilogue();
 
   // refs processing: clean slate
--- a/src/hotspot/share/gc/shared/adaptiveSizePolicy.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/shared/adaptiveSizePolicy.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -48,40 +48,38 @@
     _eden_size(init_eden_size),
     _promo_size(init_promo_size),
     _survivor_size(init_survivor_size),
+    _avg_minor_pause(new AdaptivePaddedAverage(AdaptiveTimeWeight, PausePadding)),
+    _avg_minor_interval(new AdaptiveWeightedAverage(AdaptiveTimeWeight)),
+    _avg_minor_gc_cost(new AdaptiveWeightedAverage(AdaptiveTimeWeight)),
+    _avg_major_interval(new AdaptiveWeightedAverage(AdaptiveTimeWeight)),
+    _avg_major_gc_cost(new AdaptiveWeightedAverage(AdaptiveTimeWeight)),
+    _avg_young_live(new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight)),
+    _avg_eden_live(new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight)),
+    _avg_old_live(new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight)),
+    _avg_survived(new AdaptivePaddedAverage(AdaptiveSizePolicyWeight, SurvivorPadding)),
+    _avg_pretenured(new AdaptivePaddedNoZeroDevAverage(AdaptiveSizePolicyWeight, SurvivorPadding)),
+    _minor_pause_old_estimator(new LinearLeastSquareFit(AdaptiveSizePolicyWeight)),
+    _minor_pause_young_estimator(new LinearLeastSquareFit(AdaptiveSizePolicyWeight)),
+    _minor_collection_estimator(new LinearLeastSquareFit(AdaptiveSizePolicyWeight)),
+    _major_collection_estimator(new LinearLeastSquareFit(AdaptiveSizePolicyWeight)),
     _latest_minor_mutator_interval_seconds(0),
     _threshold_tolerance_percent(1.0 + ThresholdTolerance/100.0),
     _gc_pause_goal_sec(gc_pause_goal_sec),
+    _young_gen_policy_is_ready(false),
+    _change_young_gen_for_min_pauses(0),
+    _change_old_gen_for_maj_pauses(0),
+    _change_old_gen_for_throughput(0),
+    _change_young_gen_for_throughput(0),
+    _increment_tenuring_threshold_for_gc_cost(false),
+    _decrement_tenuring_threshold_for_gc_cost(false),
+    _decrement_tenuring_threshold_for_survivor_limit(false),
+    _decrease_for_footprint(0),
+    _decide_at_full_gc(0),
     _young_gen_change_for_minor_throughput(0),
     _old_gen_change_for_major_throughput(0) {
-  _avg_minor_pause    =
-    new AdaptivePaddedAverage(AdaptiveTimeWeight, PausePadding);
-  _avg_minor_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
-  _avg_minor_gc_cost  = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
-  _avg_major_gc_cost  = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
-
-  _avg_young_live     = new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight);
-  _avg_old_live       = new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight);
-  _avg_eden_live      = new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight);
-
-  _avg_survived       = new AdaptivePaddedAverage(AdaptiveSizePolicyWeight,
-                                                  SurvivorPadding);
-  _avg_pretenured     = new AdaptivePaddedNoZeroDevAverage(
-                                                  AdaptiveSizePolicyWeight,
-                                                  SurvivorPadding);
-
-  _minor_pause_old_estimator =
-    new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
-  _minor_pause_young_estimator =
-    new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
-  _minor_collection_estimator =
-    new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
-  _major_collection_estimator =
-    new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
 
   // Start the timers
   _minor_timer.start();
-
-  _young_gen_policy_is_ready = false;
 }
 
 bool AdaptiveSizePolicy::tenuring_threshold_change() const {
--- a/src/hotspot/share/gc/shared/concurrentGCThread.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/shared/concurrentGCThread.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -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,79 +23,58 @@
  */
 
 #include "precompiled.hpp"
-#include "classfile/systemDictionary.hpp"
 #include "gc/shared/concurrentGCThread.hpp"
-#include "oops/instanceRefKlass.hpp"
-#include "oops/oop.inline.hpp"
 #include "runtime/init.hpp"
-#include "runtime/java.hpp"
-#include "runtime/javaCalls.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "runtime/orderAccess.hpp"
 #include "runtime/os.hpp"
 
 ConcurrentGCThread::ConcurrentGCThread() :
-  _should_terminate(false), _has_terminated(false) {
-};
+    _should_terminate(false),
+    _has_terminated(false) {}
 
 void ConcurrentGCThread::create_and_start(ThreadPriority prio) {
   if (os::create_thread(this, os::cgc_thread)) {
-    // XXX: need to set this to low priority
-    // unless "aggressive mode" set; priority
-    // should be just less than that of VMThread.
     os::set_priority(this, prio);
-    if (!_should_terminate) {
-      os::start_thread(this);
-    }
-  }
-}
-
-void ConcurrentGCThread::initialize_in_thread() {
-  this->set_active_handles(JNIHandleBlock::allocate_block());
-  // From this time Thread::current() should be working.
-  assert(this == Thread::current(), "just checking");
-}
-
-void ConcurrentGCThread::wait_for_universe_init() {
-  MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
-  while (!is_init_completed() && !_should_terminate) {
-    CGC_lock->wait(Mutex::_no_safepoint_check_flag, 1);
-  }
-}
-
-void ConcurrentGCThread::terminate() {
-  assert(_should_terminate, "Should only be called on terminate request.");
-  // Signal that it is terminated
-  {
-    MutexLockerEx mu(Terminator_lock,
-                     Mutex::_no_safepoint_check_flag);
-    _has_terminated = true;
-    Terminator_lock->notify();
+    os::start_thread(this);
   }
 }
 
 void ConcurrentGCThread::run() {
-  initialize_in_thread();
-  wait_for_universe_init();
+  // Setup handle area
+  set_active_handles(JNIHandleBlock::allocate_block());
+
+  // Wait for initialization to complete
+  wait_init_completed();
 
   run_service();
 
-  terminate();
+  // Signal thread has terminated
+  MonitorLockerEx ml(Terminator_lock);
+  OrderAccess::release_store(&_has_terminated, true);
+  ml.notify_all();
 }
 
 void ConcurrentGCThread::stop() {
-  // it is ok to take late safepoints here, if needed
-  {
-    MutexLockerEx mu(Terminator_lock);
-    assert(!_has_terminated,   "stop should only be called once");
-    assert(!_should_terminate, "stop should only be called once");
-    _should_terminate = true;
-  }
+  assert(!should_terminate(), "Invalid state");
+  assert(!has_terminated(), "Invalid state");
+
+  // Signal thread to terminate
+  OrderAccess::release_store_fence(&_should_terminate, true);
 
   stop_service();
 
-  {
-    MutexLockerEx mu(Terminator_lock);
-    while (!_has_terminated) {
-      Terminator_lock->wait();
-    }
+  // Wait for thread to terminate
+  MonitorLockerEx ml(Terminator_lock);
+  while (!_has_terminated) {
+    ml.wait();
   }
 }
+
+bool ConcurrentGCThread::should_terminate() const {
+  return OrderAccess::load_acquire(&_should_terminate);
+}
+
+bool ConcurrentGCThread::has_terminated() const {
+  return OrderAccess::load_acquire(&_has_terminated);
+}
--- a/src/hotspot/share/gc/shared/concurrentGCThread.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/shared/concurrentGCThread.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -26,48 +26,28 @@
 #define SHARE_GC_SHARED_CONCURRENTGCTHREAD_HPP
 
 #include "runtime/thread.hpp"
-#include "utilities/macros.hpp"
 
 class ConcurrentGCThread: public NamedThread {
-  friend class VMStructs;
-
-  bool volatile _should_terminate;
-  bool _has_terminated;
-
-  // Do initialization steps in the thread: record stack base and size,
-  // init thread local storage, set JNI handle block.
-  void initialize_in_thread();
-
-  // Wait until Universe::is_fully_initialized();
-  void wait_for_universe_init();
-
-  // Record that the current thread is terminating, and will do more
-  // concurrent work.
-  void terminate();
+private:
+  volatile bool _should_terminate;
+  volatile bool _has_terminated;
 
 protected:
-  // Create and start the thread (setting it's priority.)
   void create_and_start(ThreadPriority prio = NearMaxPriority);
 
-  // Do the specific GC work. Called by run() after initialization complete.
   virtual void run_service() = 0;
-
-  // Shut down the specific GC work. Called by stop() as part of termination protocol.
-  virtual void stop_service()  = 0;
+  virtual void stop_service() = 0;
 
 public:
   ConcurrentGCThread();
 
-  // Tester
-  bool is_ConcurrentGC_thread() const { return true; }
+  virtual bool is_ConcurrentGC_thread() const { return true; }
 
   virtual void run();
-
-  // shutdown following termination protocol
   virtual void stop();
 
-  bool should_terminate() { return _should_terminate; }
-  bool has_terminated()   { return _has_terminated; }
+  bool should_terminate() const;
+  bool has_terminated() const;
 };
 
 #endif // SHARE_GC_SHARED_CONCURRENTGCTHREAD_HPP
--- a/src/hotspot/share/gc/shared/gcStats.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/shared/gcStats.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, 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
@@ -26,8 +26,4 @@
 #include "gc/shared/gcStats.hpp"
 #include "gc/shared/gcUtil.inline.hpp"
 
-GCStats::GCStats() {
-    _avg_promoted       = new AdaptivePaddedNoZeroDevAverage(
-                                                  AdaptiveSizePolicyWeight,
-                                                  PromotedPadding);
-}
+GCStats::GCStats() : _avg_promoted(new AdaptivePaddedNoZeroDevAverage(AdaptiveSizePolicyWeight, PromotedPadding)) {}
--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -723,10 +723,10 @@
 }
 
 void GenCollectedHeap::flush_nmethod(nmethod* nm) {
-  ScavengableNMethods::flush_nmethod(nm);
+  // Do nothing.
 }
 
-void GenCollectedHeap::prune_nmethods() {
+void GenCollectedHeap::prune_scavengable_nmethods() {
   ScavengableNMethods::prune_nmethods();
 }
 
@@ -871,7 +871,7 @@
       assert(code_roots != NULL, "must supply closure for code cache");
 
       // We only visit parts of the CodeCache when scavenging.
-      ScavengableNMethods::scavengable_nmethods_do(code_roots);
+      ScavengableNMethods::nmethods_do(code_roots);
     }
     if (so & SO_AllCodeCache) {
       assert(code_roots != NULL, "must supply closure for code cache");
--- a/src/hotspot/share/gc/shared/genCollectedHeap.hpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.hpp	Thu Mar 28 22:06:05 2019 +0100
@@ -255,7 +255,7 @@
   virtual void verify_nmethod(nmethod* nm);
   virtual void flush_nmethod(nmethod* nm);
 
-  void prune_nmethods();
+  void prune_scavengable_nmethods();
 
   // Iteration functions.
   void oop_iterate(OopIterateClosure* cl);
--- a/src/hotspot/share/gc/shared/ptrQueue.cpp	Thu Mar 14 22:05:45 2019 +0100
+++ b/src/hotspot/share/gc/shared/ptrQueue.cpp	Thu Mar 28 22:06:05 2019 +0100
@@ -36,18 +36,16 @@
 
 #include <new>
 
-PtrQueue::PtrQueue(PtrQueueSet* qset, bool permanent, bool active) :
+PtrQueue::PtrQueue(PtrQueueSet* qset, bool active) :
   _qset(qset),
   _active(active),
-  _permanent(permanent),
   _index(0),
<