changeset 48439:ef097d7d5b15

Merge
author prr
date Mon, 18 Dec 2017 10:28:43 -0800
parents 4f9683bf0923 003d6365ec6a
children 3d4e8f5a2a69
files src/java.base/share/classes/java/util/zip/ZStreamRef.java src/java.base/share/native/include/jvm.h src/java.base/unix/native/include/jvm_md.h src/java.base/windows/native/include/jvm_md.h src/java.management/share/native/include/jmm.h src/jdk.compiler/share/classes/com/sun/tools/javah/Gen.java src/jdk.compiler/share/classes/com/sun/tools/javah/InternalError.java src/jdk.compiler/share/classes/com/sun/tools/javah/JNI.java src/jdk.compiler/share/classes/com/sun/tools/javah/JavahFileManager.java src/jdk.compiler/share/classes/com/sun/tools/javah/JavahTask.java src/jdk.compiler/share/classes/com/sun/tools/javah/JavahTool.java src/jdk.compiler/share/classes/com/sun/tools/javah/LLNI.java src/jdk.compiler/share/classes/com/sun/tools/javah/Main.java src/jdk.compiler/share/classes/com/sun/tools/javah/Mangle.java src/jdk.compiler/share/classes/com/sun/tools/javah/NativeHeaderTool.java src/jdk.compiler/share/classes/com/sun/tools/javah/TypeSignature.java src/jdk.compiler/share/classes/com/sun/tools/javah/Util.java src/jdk.compiler/share/classes/com/sun/tools/javah/resources/l10n.properties src/jdk.compiler/share/classes/com/sun/tools/javah/resources/l10n_ja.properties src/jdk.compiler/share/classes/com/sun/tools/javah/resources/l10n_zh_CN.properties src/jdk.compiler/share/classes/com/sun/tools/javah/resources/version.properties-template src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PackageListWriter.java test/jdk/sun/security/tools/keytool/p12importks.sh test/langtools/tools/javac/T8152360/DeprecateJavahTest.java test/langtools/tools/javac/nativeHeaders/javahComparison/CompareTest.java test/langtools/tools/javac/nativeHeaders/javahComparison/TestClass1.java test/langtools/tools/javac/nativeHeaders/javahComparison/TestClass4.java test/langtools/tools/javac/nativeHeaders/javahComparison/TestClass5.java test/langtools/tools/javah/4942232/ParamClassTest.java test/langtools/tools/javah/4942232/Test.java test/langtools/tools/javah/6257087/T6257087.java test/langtools/tools/javah/6572945/T6572945.java test/langtools/tools/javah/6572945/TestClass1.java test/langtools/tools/javah/6572945/TestClass2.java test/langtools/tools/javah/6572945/TestClass3.java test/langtools/tools/javah/6572945/gold/jni.dir.1/TestClass1.h test/langtools/tools/javah/6572945/gold/jni.dir.1/TestClass1_Inner1.h test/langtools/tools/javah/6572945/gold/jni.dir.1/TestClass1_Inner2.h test/langtools/tools/javah/6572945/gold/jni.dir.1/TestClass2.h test/langtools/tools/javah/6572945/gold/jni.file.1 test/langtools/tools/javah/6572945/gold/jni.file.2 test/langtools/tools/javah/6572945/gold/jni.file.3 test/langtools/tools/javah/ModuleClass.java test/langtools/tools/javah/ReadOldClass.sh test/langtools/tools/javah/T4942232/MissingParamClassTest.java test/langtools/tools/javah/T5070898.java test/langtools/tools/javah/T6893943.java test/langtools/tools/javah/T6994608.java test/langtools/tools/javah/T7126832/T7126832.java test/langtools/tools/javah/T7126832/java.java test/langtools/tools/javah/T7185778.java test/langtools/tools/javah/TestHelpOpts.java test/langtools/tools/javah/VersionTest.java test/langtools/tools/javah/constMacroTest/ConstMacroTest.java test/langtools/tools/lib/toolbox/JavahTask.java
diffstat 211 files changed, 6574 insertions(+), 14457 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Dec 13 14:21:12 2017 -0800
+++ b/.hgtags	Mon Dec 18 10:28:43 2017 -0800
@@ -460,3 +460,5 @@
 bbd692ad4fa300ecca7939ffbe3b1d5e52a28cc6 jdk-10+33
 89deac44e51517841491ba86ff44aa82a5ca96b3 jdk-10+34
 d8c634b016c628622c9abbdc6bf50509e5dedbec jdk-10+35
+0ee20aad71c4f33c426372b4c8bcc1235ce2ec08 jdk-11+0
+959f2f7cbaa6d2ee45d50029744efb219721576c jdk-10+36
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADDITIONAL_LICENSE_INFO	Mon Dec 18 10:28:43 2017 -0800
@@ -0,0 +1,37 @@
+                      ADDITIONAL INFORMATION ABOUT LICENSING
+
+Certain files distributed by Oracle America, Inc. and/or its affiliates are 
+subject to the following clarification and special exception to the GPLv2, 
+based on the GNU Project exception for its Classpath libraries, known as the 
+GNU Classpath Exception.
+
+Note that Oracle includes multiple, independent programs in this software 
+package.  Some of those programs are provided under licenses deemed 
+incompatible with the GPLv2 by the Free Software Foundation and others. 
+For example, the package includes programs licensed under the Apache 
+License, Version 2.0 and may include FreeType. Such programs are licensed 
+to you under their original licenses. 
+
+Oracle facilitates your further distribution of this package by adding the 
+Classpath Exception to the necessary parts of its GPLv2 code, which permits 
+you to use that code in combination with other independent modules not 
+licensed under the GPLv2. However, note that this would not permit you to 
+commingle code under an incompatible license with Oracle's GPLv2 licensed 
+code by, for example, cutting and pasting such code into a file also 
+containing Oracle's GPLv2 licensed code and then distributing the result. 
+
+Additionally, if you were to remove the Classpath Exception from any of the 
+files to which it applies and distribute the result, you would likely be 
+required to license some or all of the other code in that distribution under 
+the GPLv2 as well, and since the GPLv2 is incompatible with the license terms 
+of some items included in the distribution by Oracle, removing the Classpath 
+Exception could therefore effectively compromise your ability to further 
+distribute the package. 
+
+Failing to distribute notices associated with some files may also create 
+unexpected legal consequences.
+ 
+Proceed with caution and we recommend that you obtain the advice of a lawyer 
+skilled in open source matters before removing the Classpath Exception or 
+making modifications to this package which may subsequently be redistributed 
+and/or involve the use of third party software.
--- a/make/MacBundles.gmk	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/MacBundles.gmk	Mon Dec 18 10:28:43 2017 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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
@@ -41,7 +41,7 @@
   BUNDLE_ID := $(MACOSX_BUNDLE_ID_BASE).$(VERSION_SHORT)
   BUNDLE_NAME := $(MACOSX_BUNDLE_NAME_BASE) $(VERSION_SHORT)
   BUNDLE_INFO := $(MACOSX_BUNDLE_NAME_BASE) $(VERSION_STRING)
-  BUNDLE_PLATFORM_VERSION := $(VERSION_MAJOR).$(VERSION_MINOR)
+  BUNDLE_PLATFORM_VERSION := $(VERSION_FEATURE).$(VERSION_INTERIM)
   BUNDLE_VERSION := $(VERSION_NUMBER)
   ifeq ($(COMPANY_NAME), N/A)
     BUNDLE_VENDOR := UNDEFINED
--- a/make/ReleaseFile.gmk	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/ReleaseFile.gmk	Mon Dec 18 10:28:43 2017 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# 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
@@ -48,6 +48,9 @@
     $(call info-file-item, "SUN_ARCH_ABI", "$(JDK_ARCH_ABI_PROP_NAME)"))
   $(call info-file-item, "SOURCE", "$(strip $(SOURCE_REVISION))")
   $(call info-file-item, "IMPLEMENTOR", "$(COMPANY_NAME)")
+  $(if $(VENDOR_VERSION_STRING), \
+    $(call info-file-item, "IMPLEMENTOR_VERSION", "$(VENDOR_VERSION_STRING)"))
+  $(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
   $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
   $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
 endef
--- a/make/autoconf/flags.m4	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/autoconf/flags.m4	Mon Dec 18 10:28:43 2017 -0800
@@ -313,7 +313,7 @@
         -D\"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
         -D\"JDK_VER=\$(VERSION_NUMBER)\" \
         -D\"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
-        -D\"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(VERSION_MAJOR)\" \
+        -D\"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(VERSION_FEATURE)\" \
         -D\"JDK_FVER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\""
 
     JVM_RCFLAGS="$JVM_RCFLAGS \
@@ -1166,7 +1166,9 @@
       -I${TOPDIR}/src/java.base/$OPENJDK_$1_OS/native/include \
       -I${TOPDIR}/src/java.base/$OPENJDK_$1_OS_TYPE/native/include \
       -I${TOPDIR}/src/java.base/share/native/libjava \
-      -I${TOPDIR}/src/java.base/$OPENJDK_$1_OS_TYPE/native/libjava"
+      -I${TOPDIR}/src/java.base/$OPENJDK_$1_OS_TYPE/native/libjava \
+      -I${TOPDIR}/src/hotspot/share/include \
+      -I${TOPDIR}/src/hotspot/os/${HOTSPOT_$1_OS_TYPE}/include"
 
   # The shared libraries are compiled using the picflag.
   $2CFLAGS_JDKLIB="[$]$2COMMON_CCXXFLAGS_JDK \
--- a/make/autoconf/generated-configure.sh	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/autoconf/generated-configure.sh	Mon Dec 18 10:28:43 2017 -0800
@@ -887,6 +887,8 @@
 BOOT_JDK
 JAVA_CHECK
 JAVAC_CHECK
+VENDOR_VERSION_STRING
+VERSION_DATE
 VERSION_IS_GA
 VERSION_SHORT
 VERSION_STRING
@@ -896,9 +898,9 @@
 VERSION_BUILD
 VERSION_PRE
 VERSION_PATCH
-VERSION_SECURITY
-VERSION_MINOR
-VERSION_MAJOR
+VERSION_UPDATE
+VERSION_INTERIM
+VERSION_FEATURE
 MACOSX_BUNDLE_ID_BASE
 MACOSX_BUNDLE_NAME_BASE
 HOTSPOT_VM_DISTRO
@@ -972,7 +974,6 @@
 HOTSPOT_BUILD_OS_TYPE
 HOTSPOT_BUILD_OS
 OPENJDK_BUILD_BUNDLE_PLATFORM
-OPENJDK_BUILD_OS_EXPORT_DIR
 OPENJDK_BUILD_CPU_OSARCH
 OPENJDK_BUILD_CPU_ISADIR
 OPENJDK_BUILD_CPU_LEGACY_LIB
@@ -984,7 +985,6 @@
 HOTSPOT_TARGET_OS
 DEFINE_CROSS_COMPILE_ARCH
 OPENJDK_TARGET_BUNDLE_PLATFORM
-OPENJDK_TARGET_OS_EXPORT_DIR
 OPENJDK_TARGET_CPU_OSARCH
 OPENJDK_TARGET_CPU_ISADIR
 OPENJDK_TARGET_CPU_LEGACY_LIB
@@ -1093,6 +1093,7 @@
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -1143,14 +1144,19 @@
 with_update_version
 with_user_release_suffix
 with_build_number
+with_version_major
+with_version_minor
+with_version_security
 with_version_string
 with_version_pre
 with_version_opt
 with_version_build
-with_version_major
-with_version_minor
-with_version_security
+with_version_feature
+with_version_interim
+with_version_update
 with_version_patch
+with_version_date
+with_vendor_version_string
 with_boot_jdk
 with_build_jdk
 with_import_modules
@@ -1377,6 +1383,7 @@
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1629,6 +1636,15 @@
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1766,7 +1782,7 @@
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
+		libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1919,6 +1935,7 @@
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -2060,6 +2077,12 @@
                           compatibility and is ignored
   --with-build-number     Deprecated. Option is kept for backwards
                           compatibility and is ignored
+  --with-version-major    Deprecated. Option is kept for backwards
+                          compatibility and is ignored
+  --with-version-minor    Deprecated. Option is kept for backwards
+                          compatibility and is ignored
+  --with-version-security Deprecated. Option is kept for backwards
+                          compatibility and is ignored
   --with-version-string   Set version string [calculated]
   --with-version-pre      Set the base part of the version 'PRE' field
                           (pre-release identifier) ['internal']
@@ -2067,14 +2090,17 @@
                           [<timestamp>.<user>.<dirname>]
   --with-version-build    Set version 'BUILD' field (build number) [not
                           specified]
-  --with-version-major    Set version 'MAJOR' field (first number) [current
+  --with-version-feature  Set version 'FEATURE' field (first number) [current
                           source value]
-  --with-version-minor    Set version 'MINOR' field (second number) [current
+  --with-version-interim  Set version 'INTERIM' field (second number) [current
                           source value]
-  --with-version-security Set version 'SECURITY' field (third number) [current
+  --with-version-update   Set version 'UPDATE' field (third number) [current
                           source value]
   --with-version-patch    Set version 'PATCH' field (fourth number) [not
                           specified]
+  --with-version-date     Set version date [current source value]
+  --with-vendor-version-string
+                          Set vendor version string [not specified]
   --with-boot-jdk         path to Boot JDK (used to bootstrap build) [probed]
   --with-build-jdk        path to JDK of same version as is being built[the
                           newly built JDK]
@@ -4449,7 +4475,7 @@
 
 
 #
-# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+# 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
@@ -5159,7 +5185,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1512479382
+DATE_WHEN_GENERATED=1513206608
 
 ###############################################################################
 #
@@ -16200,13 +16226,6 @@
     OPENJDK_TARGET_CPU_JLI="amd64"
   fi
 
-  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-      OPENJDK_TARGET_OS_EXPORT_DIR=macosx
-  else
-      OPENJDK_TARGET_OS_EXPORT_DIR=${OPENJDK_TARGET_OS_TYPE}
-  fi
-
-
   # The new version string in JDK 9 also defined new naming of OS and ARCH for bundles
   # Macosx is osx and x86_64 is x64
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
@@ -16358,13 +16377,6 @@
     OPENJDK_BUILD_CPU_JLI="amd64"
   fi
 
-  if test "x$OPENJDK_BUILD_OS" = xmacosx; then
-      OPENJDK_BUILD_OS_EXPORT_DIR=macosx
-  else
-      OPENJDK_BUILD_OS_EXPORT_DIR=${OPENJDK_BUILD_OS_TYPE}
-  fi
-
-
   # The new version string in JDK 9 also defined new naming of OS and ARCH for bundles
   # Macosx is osx and x86_64 is x64
   if test "x$OPENJDK_BUILD_OS" = xmacosx; then
@@ -25004,6 +25016,33 @@
 
 
 
+
+# Check whether --with-version-major was given.
+if test "${with_version_major+set}" = set; then :
+  withval=$with_version_major; { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Option --with-version-major is deprecated and will be ignored." >&5
+$as_echo "$as_me: WARNING: Option --with-version-major is deprecated and will be ignored." >&2;}
+fi
+
+
+
+
+# Check whether --with-version-minor was given.
+if test "${with_version_minor+set}" = set; then :
+  withval=$with_version_minor; { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Option --with-version-minor is deprecated and will be ignored." >&5
+$as_echo "$as_me: WARNING: Option --with-version-minor is deprecated and will be ignored." >&2;}
+fi
+
+
+
+
+# Check whether --with-version-security was given.
+if test "${with_version_security+set}" = set; then :
+  withval=$with_version_security; { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Option --with-version-security is deprecated and will be ignored." >&5
+$as_echo "$as_me: WARNING: Option --with-version-security is deprecated and will be ignored." >&2;}
+fi
+
+
+
   # Source the version numbers file
   . $AUTOCONF_DIR/version-numbers
 
@@ -25032,20 +25071,20 @@
   elif test "x$with_version_string" != x; then
     # Additional [] needed to keep m4 from mangling shell constructs.
     if  [[ $with_version_string =~ ^([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(-([a-zA-Z]+))?((\+)([0-9]+)?(-([-a-zA-Z0-9.]+))?)?$ ]] ; then
-      VERSION_MAJOR=${BASH_REMATCH[1]}
-      VERSION_MINOR=${BASH_REMATCH[3]}
-      VERSION_SECURITY=${BASH_REMATCH[5]}
+      VERSION_FEATURE=${BASH_REMATCH[1]}
+      VERSION_INTERIM=${BASH_REMATCH[3]}
+      VERSION_UPDATE=${BASH_REMATCH[5]}
       VERSION_PATCH=${BASH_REMATCH[7]}
       VERSION_PRE=${BASH_REMATCH[9]}
       version_plus_separator=${BASH_REMATCH[11]}
       VERSION_BUILD=${BASH_REMATCH[12]}
       VERSION_OPT=${BASH_REMATCH[14]}
       # Unspecified numerical fields are interpreted as 0.
-      if test "x$VERSION_MINOR" = x; then
-        VERSION_MINOR=0
-      fi
-      if test "x$VERSION_SECURITY" = x; then
-        VERSION_SECURITY=0
+      if test "x$VERSION_INTERIM" = x; then
+        VERSION_INTERIM=0
+      fi
+      if test "x$VERSION_UPDATE" = x; then
+        VERSION_UPDATE=0
       fi
       if test "x$VERSION_PATCH" = x; then
         VERSION_PATCH=0
@@ -25174,22 +25213,22 @@
   fi
 
 
-# Check whether --with-version-major was given.
-if test "${with_version_major+set}" = set; then :
-  withval=$with_version_major; with_version_major_present=true
-else
-  with_version_major_present=false
-fi
-
-
-  if test "x$with_version_major_present" = xtrue; then
-    if test "x$with_version_major" = xyes; then
-      as_fn_error $? "--with-version-major must have a value" "$LINENO" 5
+# Check whether --with-version-feature was given.
+if test "${with_version_feature+set}" = set; then :
+  withval=$with_version_feature; with_version_feature_present=true
+else
+  with_version_feature_present=false
+fi
+
+
+  if test "x$with_version_feature_present" = xtrue; then
+    if test "x$with_version_feature" = xyes; then
+      as_fn_error $? "--with-version-feature must have a value" "$LINENO" 5
     else
 
   # Additional [] needed to keep m4 from mangling shell constructs.
-  if  ! [[ "$with_version_major" =~ ^0*([1-9][0-9]*)|(0)$ ]]  ; then
-    as_fn_error $? "\"$with_version_major\" is not a valid numerical value for VERSION_MAJOR" "$LINENO" 5
+  if  ! [[ "$with_version_feature" =~ ^0*([1-9][0-9]*)|(0)$ ]]  ; then
+    as_fn_error $? "\"$with_version_feature\" is not a valid numerical value for VERSION_FEATURE" "$LINENO" 5
   fi
   # Extract the version number without leading zeros.
   cleaned_value=${BASH_REMATCH[1]}
@@ -25199,44 +25238,44 @@
   fi
 
   if test $cleaned_value -gt 255; then
-    as_fn_error $? "VERSION_MAJOR is given as $with_version_major. This is greater than 255 which is not allowed." "$LINENO" 5
-  fi
-  if test "x$cleaned_value" != "x$with_version_major"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Value for VERSION_MAJOR has been sanitized from '$with_version_major' to '$cleaned_value'" >&5
-$as_echo "$as_me: WARNING: Value for VERSION_MAJOR has been sanitized from '$with_version_major' to '$cleaned_value'" >&2;}
-  fi
-  VERSION_MAJOR=$cleaned_value
+    as_fn_error $? "VERSION_FEATURE is given as $with_version_feature. This is greater than 255 which is not allowed." "$LINENO" 5
+  fi
+  if test "x$cleaned_value" != "x$with_version_feature"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Value for VERSION_FEATURE has been sanitized from '$with_version_feature' to '$cleaned_value'" >&5
+$as_echo "$as_me: WARNING: Value for VERSION_FEATURE has been sanitized from '$with_version_feature' to '$cleaned_value'" >&2;}
+  fi
+  VERSION_FEATURE=$cleaned_value
 
     fi
   else
     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
       # Default is to get value from version-numbers
-      VERSION_MAJOR="$DEFAULT_VERSION_MAJOR"
-    fi
-  fi
-
-
-# Check whether --with-version-minor was given.
-if test "${with_version_minor+set}" = set; then :
-  withval=$with_version_minor; with_version_minor_present=true
-else
-  with_version_minor_present=false
-fi
-
-
-  if test "x$with_version_minor_present" = xtrue; then
-    if test "x$with_version_minor" = xyes; then
-      as_fn_error $? "--with-version-minor must have a value" "$LINENO" 5
-    elif test "x$with_version_minor" = xno; then
+      VERSION_FEATURE="$DEFAULT_VERSION_FEATURE"
+    fi
+  fi
+
+
+# Check whether --with-version-interim was given.
+if test "${with_version_interim+set}" = set; then :
+  withval=$with_version_interim; with_version_interim_present=true
+else
+  with_version_interim_present=false
+fi
+
+
+  if test "x$with_version_interim_present" = xtrue; then
+    if test "x$with_version_interim" = xyes; then
+      as_fn_error $? "--with-version-interim must have a value" "$LINENO" 5
+    elif test "x$with_version_interim" = xno; then
       # Interpret --without-* as empty string (i.e. 0) instead of the literal "no"
-      VERSION_MINOR=0
-    elif test "x$with_version_minor" = x; then
-      VERSION_MINOR=0
+      VERSION_INTERIM=0
+    elif test "x$with_version_interim" = x; then
+      VERSION_INTERIM=0
     else
 
   # Additional [] needed to keep m4 from mangling shell constructs.
-  if  ! [[ "$with_version_minor" =~ ^0*([1-9][0-9]*)|(0)$ ]]  ; then
-    as_fn_error $? "\"$with_version_minor\" is not a valid numerical value for VERSION_MINOR" "$LINENO" 5
+  if  ! [[ "$with_version_interim" =~ ^0*([1-9][0-9]*)|(0)$ ]]  ; then
+    as_fn_error $? "\"$with_version_interim\" is not a valid numerical value for VERSION_INTERIM" "$LINENO" 5
   fi
   # Extract the version number without leading zeros.
   cleaned_value=${BASH_REMATCH[1]}
@@ -25246,44 +25285,44 @@
   fi
 
   if test $cleaned_value -gt 255; then
-    as_fn_error $? "VERSION_MINOR is given as $with_version_minor. This is greater than 255 which is not allowed." "$LINENO" 5
-  fi
-  if test "x$cleaned_value" != "x$with_version_minor"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Value for VERSION_MINOR has been sanitized from '$with_version_minor' to '$cleaned_value'" >&5
-$as_echo "$as_me: WARNING: Value for VERSION_MINOR has been sanitized from '$with_version_minor' to '$cleaned_value'" >&2;}
-  fi
-  VERSION_MINOR=$cleaned_value
+    as_fn_error $? "VERSION_INTERIM is given as $with_version_interim. This is greater than 255 which is not allowed." "$LINENO" 5
+  fi
+  if test "x$cleaned_value" != "x$with_version_interim"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Value for VERSION_INTERIM has been sanitized from '$with_version_interim' to '$cleaned_value'" >&5
+$as_echo "$as_me: WARNING: Value for VERSION_INTERIM has been sanitized from '$with_version_interim' to '$cleaned_value'" >&2;}
+  fi
+  VERSION_INTERIM=$cleaned_value
 
     fi
   else
     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
       # Default is 0, if unspecified
-      VERSION_MINOR=$DEFAULT_VERSION_MINOR
-    fi
-  fi
-
-
-# Check whether --with-version-security was given.
-if test "${with_version_security+set}" = set; then :
-  withval=$with_version_security; with_version_security_present=true
-else
-  with_version_security_present=false
-fi
-
-
-  if test "x$with_version_security_present" = xtrue; then
-    if test "x$with_version_security" = xyes; then
-      as_fn_error $? "--with-version-security must have a value" "$LINENO" 5
-    elif test "x$with_version_security" = xno; then
+      VERSION_INTERIM=$DEFAULT_VERSION_INTERIM
+    fi
+  fi
+
+
+# Check whether --with-version-update was given.
+if test "${with_version_update+set}" = set; then :
+  withval=$with_version_update; with_version_update_present=true
+else
+  with_version_update_present=false
+fi
+
+
+  if test "x$with_version_update_present" = xtrue; then
+    if test "x$with_version_update" = xyes; then
+      as_fn_error $? "--with-version-update must have a value" "$LINENO" 5
+    elif test "x$with_version_update" = xno; then
       # Interpret --without-* as empty string (i.e. 0) instead of the literal "no"
-      VERSION_SECURITY=0
-    elif test "x$with_version_security" = x; then
-      VERSION_SECURITY=0
+      VERSION_UPDATE=0
+    elif test "x$with_version_update" = x; then
+      VERSION_UPDATE=0
     else
 
   # Additional [] needed to keep m4 from mangling shell constructs.
-  if  ! [[ "$with_version_security" =~ ^0*([1-9][0-9]*)|(0)$ ]]  ; then
-    as_fn_error $? "\"$with_version_security\" is not a valid numerical value for VERSION_SECURITY" "$LINENO" 5
+  if  ! [[ "$with_version_update" =~ ^0*([1-9][0-9]*)|(0)$ ]]  ; then
+    as_fn_error $? "\"$with_version_update\" is not a valid numerical value for VERSION_UPDATE" "$LINENO" 5
   fi
   # Extract the version number without leading zeros.
   cleaned_value=${BASH_REMATCH[1]}
@@ -25293,19 +25332,19 @@
   fi
 
   if test $cleaned_value -gt 255; then
-    as_fn_error $? "VERSION_SECURITY is given as $with_version_security. This is greater than 255 which is not allowed." "$LINENO" 5
-  fi
-  if test "x$cleaned_value" != "x$with_version_security"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Value for VERSION_SECURITY has been sanitized from '$with_version_security' to '$cleaned_value'" >&5
-$as_echo "$as_me: WARNING: Value for VERSION_SECURITY has been sanitized from '$with_version_security' to '$cleaned_value'" >&2;}
-  fi
-  VERSION_SECURITY=$cleaned_value
+    as_fn_error $? "VERSION_UPDATE is given as $with_version_update. This is greater than 255 which is not allowed." "$LINENO" 5
+  fi
+  if test "x$cleaned_value" != "x$with_version_update"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Value for VERSION_UPDATE has been sanitized from '$with_version_update' to '$cleaned_value'" >&5
+$as_echo "$as_me: WARNING: Value for VERSION_UPDATE has been sanitized from '$with_version_update' to '$cleaned_value'" >&2;}
+  fi
+  VERSION_UPDATE=$cleaned_value
 
     fi
   else
     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
       # Default is 0, if unspecified
-      VERSION_SECURITY=$DEFAULT_VERSION_SECURITY
+      VERSION_UPDATE=$DEFAULT_VERSION_UPDATE
     fi
   fi
 
@@ -25366,7 +25405,7 @@
   fi
 
   # VERSION_NUMBER but always with exactly 4 positions, with 0 for empty positions.
-  VERSION_NUMBER_FOUR_POSITIONS=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_SECURITY.$VERSION_PATCH
+  VERSION_NUMBER_FOUR_POSITIONS=$VERSION_FEATURE.$VERSION_INTERIM.$VERSION_UPDATE.$VERSION_PATCH
 
   stripped_version_number=$VERSION_NUMBER_FOUR_POSITIONS
   # Strip trailing zeroes from stripped_version_number
@@ -25384,6 +25423,40 @@
   # The short version string, just VERSION_NUMBER and PRE, if present.
   VERSION_SHORT=$VERSION_NUMBER${VERSION_PRE:+-$VERSION_PRE}
 
+  # The version date
+
+# Check whether --with-version-date was given.
+if test "${with_version_date+set}" = set; then :
+  withval=$with_version_date;
+fi
+
+  if test "x$with_version_date" = xyes; then
+    as_fn_error $? "--with-version-date must have a value" "$LINENO" 5
+  elif test "x$with_version_date" != x; then
+    if  ! [[ $with_version_date =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] ; then
+      as_fn_error $? "\"$with_version_date\" is not a valid version date" "$LINENO" 5
+    else
+      VERSION_DATE="$with_version_date"
+    fi
+  else
+    VERSION_DATE="$DEFAULT_VERSION_DATE"
+  fi
+
+  # The vendor version string, if any
+
+# Check whether --with-vendor-version-string was given.
+if test "${with_vendor_version_string+set}" = set; then :
+  withval=$with_vendor_version_string;
+fi
+
+  if test "x$with_vendor_version_string" = xyes; then
+    as_fn_error $? "--with-vendor-version-string must have a value" "$LINENO" 5
+  elif  ! [[ $with_vendor_version_string =~ ^[[:graph:]]*$ ]] ; then
+    as_fn_error $? "--with--vendor-version-string contains non-graphical characters: $with_vendor_version_string" "$LINENO" 5
+  else
+    VENDOR_VERSION_STRING="$with_vendor_version_string"
+  fi
+
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version string" >&5
 $as_echo_n "checking for version string... " >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $VERSION_STRING" >&5
@@ -25403,6 +25476,8 @@
 
 
 
+
+
 ###############################################################################
 #
 # Setup BootJDK, used to bootstrap the build.
@@ -50669,7 +50744,7 @@
         -D\"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
         -D\"JDK_VER=\$(VERSION_NUMBER)\" \
         -D\"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
-        -D\"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(VERSION_MAJOR)\" \
+        -D\"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(VERSION_FEATURE)\" \
         -D\"JDK_FVER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\""
 
     JVM_RCFLAGS="$JVM_RCFLAGS \
@@ -52817,7 +52892,9 @@
       -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS/native/include \
       -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/include \
       -I${TOPDIR}/src/java.base/share/native/libjava \
-      -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava"
+      -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava \
+      -I${TOPDIR}/src/hotspot/share/include \
+      -I${TOPDIR}/src/hotspot/os/${HOTSPOT_TARGET_OS_TYPE}/include"
 
   # The shared libraries are compiled using the picflag.
   CFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK \
@@ -53698,7 +53775,9 @@
       -I${TOPDIR}/src/java.base/$OPENJDK_BUILD_OS/native/include \
       -I${TOPDIR}/src/java.base/$OPENJDK_BUILD_OS_TYPE/native/include \
       -I${TOPDIR}/src/java.base/share/native/libjava \
-      -I${TOPDIR}/src/java.base/$OPENJDK_BUILD_OS_TYPE/native/libjava"
+      -I${TOPDIR}/src/java.base/$OPENJDK_BUILD_OS_TYPE/native/libjava \
+      -I${TOPDIR}/src/hotspot/share/include \
+      -I${TOPDIR}/src/hotspot/os/${HOTSPOT_BUILD_OS_TYPE}/include"
 
   # The shared libraries are compiled using the picflag.
   OPENJDK_BUILD_CFLAGS_JDKLIB="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK \
--- a/make/autoconf/jdk-version.m4	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/autoconf/jdk-version.m4	Mon Dec 18 10:28:43 2017 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+# 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
@@ -62,6 +62,9 @@
   BASIC_DEPRECATED_ARG_WITH([update-version])
   BASIC_DEPRECATED_ARG_WITH([user-release-suffix])
   BASIC_DEPRECATED_ARG_WITH([build-number])
+  BASIC_DEPRECATED_ARG_WITH([version-major])
+  BASIC_DEPRECATED_ARG_WITH([version-minor])
+  BASIC_DEPRECATED_ARG_WITH([version-security])
 
   # Source the version numbers file
   . $AUTOCONF_DIR/version-numbers
@@ -87,20 +90,20 @@
   elif test "x$with_version_string" != x; then
     # Additional [] needed to keep m4 from mangling shell constructs.
     if [ [[ $with_version_string =~ ^([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(-([a-zA-Z]+))?((\+)([0-9]+)?(-([-a-zA-Z0-9.]+))?)?$ ]] ]; then
-      VERSION_MAJOR=${BASH_REMATCH[[1]]}
-      VERSION_MINOR=${BASH_REMATCH[[3]]}
-      VERSION_SECURITY=${BASH_REMATCH[[5]]}
+      VERSION_FEATURE=${BASH_REMATCH[[1]]}
+      VERSION_INTERIM=${BASH_REMATCH[[3]]}
+      VERSION_UPDATE=${BASH_REMATCH[[5]]}
       VERSION_PATCH=${BASH_REMATCH[[7]]}
       VERSION_PRE=${BASH_REMATCH[[9]]}
       version_plus_separator=${BASH_REMATCH[[11]]}
       VERSION_BUILD=${BASH_REMATCH[[12]]}
       VERSION_OPT=${BASH_REMATCH[[14]]}
       # Unspecified numerical fields are interpreted as 0.
-      if test "x$VERSION_MINOR" = x; then
-        VERSION_MINOR=0
+      if test "x$VERSION_INTERIM" = x; then
+        VERSION_INTERIM=0
       fi
-      if test "x$VERSION_SECURITY" = x; then
-        VERSION_SECURITY=0
+      if test "x$VERSION_UPDATE" = x; then
+        VERSION_UPDATE=0
       fi
       if test "x$VERSION_PATCH" = x; then
         VERSION_PATCH=0
@@ -191,64 +194,64 @@
     fi
   fi
 
-  AC_ARG_WITH(version-major, [AS_HELP_STRING([--with-version-major],
-      [Set version 'MAJOR' field (first number) @<:@current source value@:>@])],
-      [with_version_major_present=true], [with_version_major_present=false])
+  AC_ARG_WITH(version-feature, [AS_HELP_STRING([--with-version-feature],
+      [Set version 'FEATURE' field (first number) @<:@current source value@:>@])],
+      [with_version_feature_present=true], [with_version_feature_present=false])
 
-  if test "x$with_version_major_present" = xtrue; then
-    if test "x$with_version_major" = xyes; then
-      AC_MSG_ERROR([--with-version-major must have a value])
+  if test "x$with_version_feature_present" = xtrue; then
+    if test "x$with_version_feature" = xyes; then
+      AC_MSG_ERROR([--with-version-feature must have a value])
     else
-      JDKVER_CHECK_AND_SET_NUMBER(VERSION_MAJOR, $with_version_major)
+      JDKVER_CHECK_AND_SET_NUMBER(VERSION_FEATURE, $with_version_feature)
     fi
   else
     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
       # Default is to get value from version-numbers
-      VERSION_MAJOR="$DEFAULT_VERSION_MAJOR"
+      VERSION_FEATURE="$DEFAULT_VERSION_FEATURE"
     fi
   fi
 
-  AC_ARG_WITH(version-minor, [AS_HELP_STRING([--with-version-minor],
-      [Set version 'MINOR' field (second number) @<:@current source value@:>@])],
-      [with_version_minor_present=true], [with_version_minor_present=false])
+  AC_ARG_WITH(version-interim, [AS_HELP_STRING([--with-version-interim],
+      [Set version 'INTERIM' field (second number) @<:@current source value@:>@])],
+      [with_version_interim_present=true], [with_version_interim_present=false])
 
-  if test "x$with_version_minor_present" = xtrue; then
-    if test "x$with_version_minor" = xyes; then
-      AC_MSG_ERROR([--with-version-minor must have a value])
-    elif test "x$with_version_minor" = xno; then
+  if test "x$with_version_interim_present" = xtrue; then
+    if test "x$with_version_interim" = xyes; then
+      AC_MSG_ERROR([--with-version-interim must have a value])
+    elif test "x$with_version_interim" = xno; then
       # Interpret --without-* as empty string (i.e. 0) instead of the literal "no"
-      VERSION_MINOR=0
-    elif test "x$with_version_minor" = x; then
-      VERSION_MINOR=0
+      VERSION_INTERIM=0
+    elif test "x$with_version_interim" = x; then
+      VERSION_INTERIM=0
     else
-      JDKVER_CHECK_AND_SET_NUMBER(VERSION_MINOR, $with_version_minor)
+      JDKVER_CHECK_AND_SET_NUMBER(VERSION_INTERIM, $with_version_interim)
     fi
   else
     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
       # Default is 0, if unspecified
-      VERSION_MINOR=$DEFAULT_VERSION_MINOR
+      VERSION_INTERIM=$DEFAULT_VERSION_INTERIM
     fi
   fi
 
-  AC_ARG_WITH(version-security, [AS_HELP_STRING([--with-version-security],
-      [Set version 'SECURITY' field (third number) @<:@current source value@:>@])],
-      [with_version_security_present=true], [with_version_security_present=false])
+  AC_ARG_WITH(version-update, [AS_HELP_STRING([--with-version-update],
+      [Set version 'UPDATE' field (third number) @<:@current source value@:>@])],
+      [with_version_update_present=true], [with_version_update_present=false])
 
-  if test "x$with_version_security_present" = xtrue; then
-    if test "x$with_version_security" = xyes; then
-      AC_MSG_ERROR([--with-version-security must have a value])
-    elif test "x$with_version_security" = xno; then
+  if test "x$with_version_update_present" = xtrue; then
+    if test "x$with_version_update" = xyes; then
+      AC_MSG_ERROR([--with-version-update must have a value])
+    elif test "x$with_version_update" = xno; then
       # Interpret --without-* as empty string (i.e. 0) instead of the literal "no"
-      VERSION_SECURITY=0
-    elif test "x$with_version_security" = x; then
-      VERSION_SECURITY=0
+      VERSION_UPDATE=0
+    elif test "x$with_version_update" = x; then
+      VERSION_UPDATE=0
     else
-      JDKVER_CHECK_AND_SET_NUMBER(VERSION_SECURITY, $with_version_security)
+      JDKVER_CHECK_AND_SET_NUMBER(VERSION_UPDATE, $with_version_update)
     fi
   else
     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
       # Default is 0, if unspecified
-      VERSION_SECURITY=$DEFAULT_VERSION_SECURITY
+      VERSION_UPDATE=$DEFAULT_VERSION_UPDATE
     fi
   fi
 
@@ -284,7 +287,7 @@
   fi
 
   # VERSION_NUMBER but always with exactly 4 positions, with 0 for empty positions.
-  VERSION_NUMBER_FOUR_POSITIONS=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_SECURITY.$VERSION_PATCH
+  VERSION_NUMBER_FOUR_POSITIONS=$VERSION_FEATURE.$VERSION_INTERIM.$VERSION_UPDATE.$VERSION_PATCH
 
   stripped_version_number=$VERSION_NUMBER_FOUR_POSITIONS
   # Strip trailing zeroes from stripped_version_number
@@ -302,12 +305,38 @@
   # The short version string, just VERSION_NUMBER and PRE, if present.
   VERSION_SHORT=$VERSION_NUMBER${VERSION_PRE:+-$VERSION_PRE}
 
+  # The version date
+  AC_ARG_WITH(version-date, [AS_HELP_STRING([--with-version-date],
+      [Set version date @<:@current source value@:>@])])
+  if test "x$with_version_date" = xyes; then
+    AC_MSG_ERROR([--with-version-date must have a value])
+  elif test "x$with_version_date" != x; then
+    if [ ! [[ $with_version_date =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] ]; then
+      AC_MSG_ERROR(["$with_version_date" is not a valid version date]) 
+    else
+      VERSION_DATE="$with_version_date"
+    fi
+  else
+    VERSION_DATE="$DEFAULT_VERSION_DATE"
+  fi
+
+  # The vendor version string, if any
+  AC_ARG_WITH(vendor-version-string, [AS_HELP_STRING([--with-vendor-version-string],
+      [Set vendor version string @<:@not specified@:>@])])
+  if test "x$with_vendor_version_string" = xyes; then
+    AC_MSG_ERROR([--with-vendor-version-string must have a value])
+  elif [ ! [[ $with_vendor_version_string =~ ^[[:graph:]]*$ ]] ]; then
+    AC_MSG_ERROR([--with--vendor-version-string contains non-graphical characters: $with_vendor_version_string])
+  else
+    VENDOR_VERSION_STRING="$with_vendor_version_string"
+  fi
+
   AC_MSG_CHECKING([for version string])
   AC_MSG_RESULT([$VERSION_STRING])
 
-  AC_SUBST(VERSION_MAJOR)
-  AC_SUBST(VERSION_MINOR)
-  AC_SUBST(VERSION_SECURITY)
+  AC_SUBST(VERSION_FEATURE)
+  AC_SUBST(VERSION_INTERIM)
+  AC_SUBST(VERSION_UPDATE)
   AC_SUBST(VERSION_PATCH)
   AC_SUBST(VERSION_PRE)
   AC_SUBST(VERSION_BUILD)
@@ -317,4 +346,6 @@
   AC_SUBST(VERSION_STRING)
   AC_SUBST(VERSION_SHORT)
   AC_SUBST(VERSION_IS_GA)
+  AC_SUBST(VERSION_DATE)
+  AC_SUBST(VENDOR_VERSION_STRING)
 ])
--- a/make/autoconf/platform.m4	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/autoconf/platform.m4	Mon Dec 18 10:28:43 2017 -0800
@@ -388,13 +388,6 @@
     OPENJDK_$1_CPU_JLI="amd64"
   fi
 
-  if test "x$OPENJDK_$1_OS" = xmacosx; then
-      OPENJDK_$1_OS_EXPORT_DIR=macosx
-  else
-      OPENJDK_$1_OS_EXPORT_DIR=${OPENJDK_$1_OS_TYPE}
-  fi
-  AC_SUBST(OPENJDK_$1_OS_EXPORT_DIR)
-
   # The new version string in JDK 9 also defined new naming of OS and ARCH for bundles
   # Macosx is osx and x86_64 is x64
   if test "x$OPENJDK_$1_OS" = xmacosx; then
--- a/make/autoconf/spec.gmk.in	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/autoconf/spec.gmk.in	Mon Dec 18 10:28:43 2017 -0800
@@ -78,7 +78,6 @@
 OPENJDK_TARGET_CPU_LEGACY:=@OPENJDK_TARGET_CPU_LEGACY@
 OPENJDK_TARGET_CPU_LEGACY_LIB:=@OPENJDK_TARGET_CPU_LEGACY_LIB@
 OPENJDK_TARGET_CPU_OSARCH:=@OPENJDK_TARGET_CPU_OSARCH@
-OPENJDK_TARGET_OS_EXPORT_DIR:=@OPENJDK_TARGET_OS_EXPORT_DIR@
 
 HOTSPOT_TARGET_OS := @HOTSPOT_TARGET_OS@
 HOTSPOT_TARGET_OS_TYPE := @HOTSPOT_TARGET_OS_TYPE@
@@ -144,10 +143,9 @@
 
 ## Building blocks of the version string
 # First three version numbers, with well-specified meanings (numerical)
-VERSION_MAJOR := @VERSION_MAJOR@
-VERSION_MINOR := @VERSION_MINOR@
-VERSION_SECURITY := @VERSION_SECURITY@
-# Optional fourth element for use by OpenJDK consumers (numerical)
+VERSION_FEATURE := @VERSION_FEATURE@
+VERSION_INTERIM := @VERSION_INTERIM@
+VERSION_UPDATE := @VERSION_UPDATE@
 VERSION_PATCH := @VERSION_PATCH@
 # The pre-release identifier (string)
 VERSION_PRE := @VERSION_PRE@
@@ -165,17 +163,23 @@
 VERSION_STRING := @VERSION_STRING@
 # The short version string, without trailing zeroes and just PRE, if present.
 VERSION_SHORT := @VERSION_SHORT@
-# The Java specification version. It usually equals the major version number.
-VERSION_SPECIFICATION := @VERSION_MAJOR@
+# The Java specification version. It usually equals the feature version number.
+VERSION_SPECIFICATION := @VERSION_FEATURE@
 # A GA version is defined by the PRE string being empty. Rather than testing for
 # that, this variable defines it with true/false.
 VERSION_IS_GA := @VERSION_IS_GA@
 
+# Version date
+VERSION_DATE := @VERSION_DATE@
+
+# Vendor version string
+VENDOR_VERSION_STRING := @VENDOR_VERSION_STRING@
+
 # Convenience CFLAGS settings for passing version information into native programs.
 VERSION_CFLAGS := \
-    -DVERSION_MAJOR=$(VERSION_MAJOR) \
-    -DVERSION_MINOR=$(VERSION_MINOR) \
-    -DVERSION_SECURITY=$(VERSION_SECURITY) \
+    -DVERSION_FEATURE=$(VERSION_FEATURE) \
+    -DVERSION_INTERIM=$(VERSION_INTERIM) \
+    -DVERSION_UPDATE=$(VERSION_UPDATE) \
     -DVERSION_PATCH=$(VERSION_PATCH) \
     -DVERSION_PRE='"$(VERSION_PRE)"' \
     -DVERSION_BUILD=$(VERSION_BUILD) \
@@ -184,6 +188,8 @@
     -DVERSION_STRING='"$(VERSION_STRING)"' \
     -DVERSION_SHORT='"$(VERSION_SHORT)"' \
     -DVERSION_SPECIFICATION='"$(VERSION_SPECIFICATION)"' \
+    -DVERSION_DATE='"$(VERSION_DATE)"' \
+    -DVENDOR_VERSION_STRING='"$(VENDOR_VERSION_STRING)"' \
     #
 
 # Platform naming variables
--- a/make/autoconf/version-numbers	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/autoconf/version-numbers	Mon Dec 18 10:28:43 2017 -0800
@@ -25,10 +25,11 @@
 
 # Default version numbers to use unless overridden by configure
 
-DEFAULT_VERSION_MAJOR=10
-DEFAULT_VERSION_MINOR=0
-DEFAULT_VERSION_SECURITY=0
+DEFAULT_VERSION_FEATURE=10
+DEFAULT_VERSION_INTERIM=0
+DEFAULT_VERSION_UPDATE=0
 DEFAULT_VERSION_PATCH=0
+DEFAULT_VERSION_DATE=2018-03-20
 
 LAUNCHER_NAME=openjdk
 PRODUCT_NAME=OpenJDK
--- a/make/conf/jib-profiles.js	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/conf/jib-profiles.js	Mon Dec 18 10:28:43 2017 -0800
@@ -1050,17 +1050,17 @@
  * Constructs the numeric version string from reading the
  * make/autoconf/version-numbers file and removing all trailing ".0".
  *
- * @param major Override major version
- * @param minor Override minor version
- * @param security Override security version
+ * @param feature Override feature version
+ * @param interim Override interim version
+ * @param update Override update version
  * @param patch Override patch version
  * @returns {String} The numeric version string
  */
-var getVersion = function (major, minor, security, patch) {
+var getVersion = function (feature, interim, update, patch) {
     var version_numbers = getVersionNumbers();
-    var version = (major != null ? major : version_numbers.get("DEFAULT_VERSION_MAJOR"))
-        + "." + (minor != null ? minor : version_numbers.get("DEFAULT_VERSION_MINOR"))
-        + "." + (security != null ? security :  version_numbers.get("DEFAULT_VERSION_SECURITY"))
+    var version = (feature != null ? feature : version_numbers.get("DEFAULT_VERSION_FEATURE"))
+        + "." + (interim != null ? interim : version_numbers.get("DEFAULT_VERSION_INTERIM"))
+        + "." + (update != null ? update :  version_numbers.get("DEFAULT_VERSION_UPDATE"))
         + "." + (patch != null ? patch : version_numbers.get("DEFAULT_VERSION_PATCH"));
     while (version.match(".*\\.0$")) {
         version = version.substring(0, version.length - 2);
--- a/make/copy/Copy-java.base.gmk	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/copy/Copy-java.base.gmk	Mon Dec 18 10:28:43 2017 -0800
@@ -28,24 +28,6 @@
 $(eval $(call IncludeCustomExtension, copy/Copy-java.base.gmk))
 
 ################################################################################
-#
-# Copy exported header files to outputdir.
-#
-TARGETS += \
-    $(INCLUDE_DST_DIR)/jni.h \
-    $(INCLUDE_DST_DIR)/jvmticmlr.h \
-    $(INCLUDE_DST_DIR)/classfile_constants.h \
-    $(INCLUDE_DST_OS_DIR)/jni_md.h \
-    #
-
-$(INCLUDE_DST_DIR)/%.h: $(TOPDIR)/src/java.base/share/native/include/%.h
-	$(call install-file)
-
-$(INCLUDE_DST_OS_DIR)/%.h: \
-    $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/include/%.h
-	$(call install-file)
-
-################################################################################
 
 ifneq ($(findstring $(OPENJDK_TARGET_OS), windows aix),)
 
@@ -237,9 +219,10 @@
 # different license.
 JDK_LICENSE ?= $(wildcard $(TOPDIR)/LICENSE)
 JDK_NOTICE  ?= $(wildcard $(TOPDIR)/ASSEMBLY_EXCEPTION)
+JDK_ADDITIONAL_LICENSE_INFO  ?= $(wildcard $(TOPDIR)/ADDITIONAL_LICENSE_INFO)
 
 $(eval $(call SetupCopyFiles, COPY_JDK_NOTICES, \
-    FILES := $(JDK_LICENSE) $(JDK_NOTICE), \
+    FILES := $(JDK_LICENSE) $(JDK_NOTICE) $(JDK_ADDITIONAL_LICENSE_INFO), \
     DEST := $(LEGAL_DST_DIR), \
     FLATTEN := true, \
 ))
--- a/make/copy/Copy-java.desktop.gmk	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/copy/Copy-java.desktop.gmk	Mon Dec 18 10:28:43 2017 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 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
@@ -29,20 +29,6 @@
 
 ################################################################################
 
-TARGETS += \
-    $(INCLUDE_DST_DIR)/jawt.h \
-    $(INCLUDE_DST_OS_DIR)/jawt_md.h \
-    #
-
-$(INCLUDE_DST_DIR)/%.h: $(TOPDIR)/src/java.desktop/share/native/include/%.h
-	$(call install-file)
-
-$(INCLUDE_DST_OS_DIR)/%.h: \
-    $(TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_EXPORT_DIR)/native/include/%.h
-	$(call install-file)
-
-################################################################################
-
 ifneq ($(FREETYPE_BUNDLE_LIB_PATH), )
   # We need to bundle the freetype library, so it will be available at runtime
   # as well as link time.
--- a/make/copy/Copy-jdk.accessibility.gmk	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/copy/Copy-jdk.accessibility.gmk	Mon Dec 18 10:28:43 2017 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2104, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 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
@@ -23,19 +23,7 @@
 # questions.
 #
 
+################################################################################
+# Include CopyCommon.gmk to get exported header files to be properly copied.
+
 include CopyCommon.gmk
-
-################################################################################
-
-ifeq ($(OPENJDK_TARGET_OS), windows)
-  TARGETS += $(INCLUDE_DST_OS_DIR)/bridge/AccessBridgeCallbacks.h \
-      $(INCLUDE_DST_OS_DIR)/bridge/AccessBridgeCalls.h \
-      $(INCLUDE_DST_OS_DIR)/bridge/AccessBridgePackages.h
-
-  $(INCLUDE_DST_OS_DIR)/bridge/%: \
-      $(TOPDIR)/src/jdk.accessibility/windows/native/include/bridge/%
-		$(install-file)
-
-endif
-
-################################################################################
--- a/make/copy/Copy-jdk.jdwp.agent.gmk	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/copy/Copy-jdk.jdwp.agent.gmk	Mon Dec 18 10:28:43 2017 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 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
@@ -23,13 +23,7 @@
 # questions.
 #
 
+################################################################################
+# Include CopyCommon.gmk to get exported header files to be properly copied.
+
 include CopyCommon.gmk
-
-################################################################################
-
-TARGETS := $(INCLUDE_DST_DIR)/jdwpTransport.h
-
-$(INCLUDE_DST_DIR)/%.h: $(TOPDIR)/src/jdk.jdwp.agent/share/native/include/%.h
-	$(call install-file)
-
-################################################################################
--- a/make/copy/CopyCommon.gmk	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/copy/CopyCommon.gmk	Mon Dec 18 10:28:43 2017 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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
@@ -23,15 +23,48 @@
 # questions.
 #
 
-INCLUDE_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_include/$(MODULE)
 LIB_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)
 CONF_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_conf/$(MODULE)
 LEGAL_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)
 
-INCLUDE_DST_OS_DIR := $(INCLUDE_DST_DIR)/$(OPENJDK_TARGET_OS)
+################################################################################
+#
+# Copy exported include headers files to output directory, if present.
+#
 
+INCLUDE_TARGET_DIR := $(SUPPORT_OUTPUTDIR)/modules_include/$(MODULE)
+INCLUDE_SOURCE_DIR := $(TOPDIR)/src/$(MODULE)/share/native/include
+
+ifneq ($(wildcard $(INCLUDE_SOURCE_DIR)/*), )
+  $(eval $(call SetupCopyFiles, COPY_EXPORTED_INCLUDE, \
+      SRC := $(INCLUDE_SOURCE_DIR), \
+      DEST := $(INCLUDE_TARGET_DIR), \
+      FILES := $(shell $(FIND) $(INCLUDE_SOURCE_DIR) -type f), \
+  ))
+
+  TARGETS += $(COPY_EXPORTED_INCLUDE)
+endif
+
+# For historical reasons, the OS include directories have odd names.
+INCLUDE_TARGET_OS_SUBDIR := $(OPENJDK_TARGET_OS)
 ifeq ($(OPENJDK_TARGET_OS), windows)
-  INCLUDE_DST_OS_DIR := $(INCLUDE_DST_DIR)/win32
+  INCLUDE_TARGET_OS_SUBDIR := win32
 else ifeq ($(OPENJDK_TARGET_OS), macosx)
-  INCLUDE_DST_OS_DIR := $(INCLUDE_DST_DIR)/darwin
+  INCLUDE_TARGET_OS_SUBDIR := darwin
 endif
+
+# Use the most specific of OS and OS_TYPE.
+INCLUDE_SOURCE_OS_DIR := $(TOPDIR)/src/$(MODULE)/$(OPENJDK_TARGET_OS)/native/include
+ifeq ($(wildcard $(INCLUDE_SOURCE_OS_DIR)/*), )
+  INCLUDE_SOURCE_OS_DIR := $(TOPDIR)/src/$(MODULE)/$(OPENJDK_TARGET_OS_TYPE)/native/include
+endif
+
+ifneq ($(wildcard $(INCLUDE_SOURCE_OS_DIR)/*), )
+  $(eval $(call SetupCopyFiles, COPY_EXPORTED_INCLUDE_OS, \
+      SRC := $(INCLUDE_SOURCE_OS_DIR), \
+      DEST := $(INCLUDE_TARGET_DIR)/$(INCLUDE_TARGET_OS_SUBDIR), \
+      FILES := $(shell $(FIND) $(INCLUDE_SOURCE_OS_DIR) -type f), \
+  ))
+
+  TARGETS += $(COPY_EXPORTED_INCLUDE_OS)
+endif
--- a/make/gensrc/GensrcMisc.gmk	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/gensrc/GensrcMisc.gmk	Mon Dec 18 10:28:43 2017 -0800
@@ -38,7 +38,9 @@
         @@VERSION_NUMBER@@ => $(VERSION_NUMBER) ; \
         @@VERSION_PRE@@ => $(VERSION_PRE) ; \
         @@VERSION_BUILD@@ => $(VERSION_BUILD) ; \
-        @@VERSION_OPT@@ => $(VERSION_OPT), \
+        @@VERSION_OPT@@ => $(VERSION_OPT) ; \
+        @@VERSION_DATE@@ => $(VERSION_DATE) ; \
+        @@VENDOR_VERSION_STRING@@ => $(VENDOR_VERSION_STRING), \
 ))
 
 GENSRC_JAVA_BASE += $(BUILD_VERSION_JAVA)
--- a/make/gensrc/GensrcX11Wrappers.gmk	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/gensrc/GensrcX11Wrappers.gmk	Mon Dec 18 10:28:43 2017 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 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
@@ -92,8 +92,10 @@
   endif
 
   SIZER_CFLAGS := \
+      -I${TOPDIR}/src/hotspot/share/include \
+      -I${TOPDIR}/src/hotspot/os/$(HOTSPOT_TARGET_OS_TYPE)/include \
       -I$(TOPDIR)/src/java.base/share/native/include \
-      -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_EXPORT_DIR)/native/include \
+      -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/include \
       -I$(TOPDIR)/src/java.base/share/native/libjava \
       -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \
       -I$(TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \
--- a/make/hotspot/lib/CompileJvm.gmk	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/hotspot/lib/CompileJvm.gmk	Mon Dec 18 10:28:43 2017 -0800
@@ -57,9 +57,10 @@
     $(patsubst %,-I%,$(filter-out $(JVM_VARIANT_OUTPUTDIR)/gensrc/%, $(JVM_SRC_DIRS))) \
     -I$(JVM_VARIANT_OUTPUTDIR)/gensrc \
     -I$(TOPDIR)/src/hotspot/share/precompiled \
+    -I$(TOPDIR)/src/hotspot/share/include \
+    -I$(TOPDIR)/src/hotspot/os/$(HOTSPOT_TARGET_OS_TYPE)/include \
     -I$(TOPDIR)/src/java.base/share/native/include \
     -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/include \
-    -I$(TOPDIR)/src/java.management/share/native/include \
     -I$(TOPDIR)/src/java.base/share/native/libjimage \
     #
 
--- a/make/hotspot/lib/CompileLibjsig.gmk	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/hotspot/lib/CompileLibjsig.gmk	Mon Dec 18 10:28:43 2017 -0800
@@ -57,7 +57,7 @@
       endif
 
     else ifeq ($(OPENJDK_TARGET_OS), solaris)
-      LIBJSIG_CFLAGS := -m64 -KPIC -mt -I $(TOPDIR)/src/java.base/unix/native/include
+      LIBJSIG_CFLAGS := -m64 -KPIC -mt -I $(TOPDIR)/src/hotspot/os/$(HOTSPOT_TARGET_OS_TYPE)/include
       LIBJSIG_LDFLAGS := -m64 -mt -xnolib
       LIBJSIG_LIBS := $(LIBDL)
 
--- a/make/jprt.properties	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/jprt.properties	Mon Dec 18 10:28:43 2017 -0800
@@ -177,6 +177,7 @@
 
 # Not all test targets need the test image
 jprt.test.bundle.targets=\
+  ${my.make.rule.test.targets.svc}, \
   ${my.make.rule.test.targets.hotspot.reg}, \
   ${my.make.rule.test.targets.hotspot.gtest} \
   ${my.make.rule.test.targets.nativesanity} \
--- a/make/launcher/Launcher-jdk.compiler.gmk	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/launcher/Launcher-jdk.compiler.gmk	Mon Dec 18 10:28:43 2017 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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
@@ -31,11 +31,6 @@
    CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \
 ))
 
-$(eval $(call SetupBuildLauncher, javah, \
-    MAIN_CLASS := com.sun.tools.javah.Main, \
-    CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \
-))
-
 $(eval $(call SetupBuildLauncher, serialver, \
     MAIN_CLASS := sun.tools.serialver.SerialVer, \
     CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \
--- a/make/lib/Lib-java.management.gmk	Wed Dec 13 14:21:12 2017 -0800
+++ b/make/lib/Lib-java.management.gmk	Mon Dec 18 10:28:43 2017 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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
@@ -30,8 +30,8 @@
 
 ################################################################################
 
-LIBMANAGEMENT_SRC += $(TOPDIR)/src/java.management/share/native/libmanagement 
-LIBMANAGEMENT_CFLAGS := -I$(TOPDIR)/src/java.management/share/native/include \
+LIBMANAGEMENT_SRC += $(TOPDIR)/src/java.management/share/native/libmanagement
+LIBMANAGEMENT_CFLAGS := -I$(TOPDIR)/src/hotspot/share/include \
     $(addprefix -I,$(LIBMANAGEMENT_SRC)) \
     -I$(SUPPORT_OUTPUTDIR)/headers/java.management \
     $(LIBJAVA_HEADER_FLAGS) \
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -36,6 +36,7 @@
 #include "gc/shared/cardTableModRefBS.hpp"
 #include "nativeInst_ppc.hpp"
 #include "oops/objArrayKlass.hpp"
+#include "runtime/safepointMechanism.inline.hpp"
 #include "runtime/sharedRuntime.hpp"
 
 #define __ _masm->
@@ -1314,11 +1315,10 @@
     __ pop_frame();
   }
 
-  if (LoadPollAddressFromThread) {
-    // TODO: PPC port __ ld(polling_page, in_bytes(JavaThread::poll_address_offset()), R16_thread);
-    Unimplemented();
+  if (SafepointMechanism::uses_thread_local_poll()) {
+    __ ld(polling_page, in_bytes(Thread::polling_page_offset()), R16_thread);
   } else {
-    __ load_const_optimized(polling_page, (long)(address) os::get_polling_page(), R0); // TODO: PPC port: get_standard_polling_page()
+    __ load_const_optimized(polling_page, (long)(address) os::get_polling_page(), R0);
   }
 
   // Restore return pc relative to callers' sp.
@@ -1341,26 +1341,18 @@
 
 
 int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
-
-  if (LoadPollAddressFromThread) {
-    const Register poll_addr = tmp->as_register();
-    // TODO: PPC port __ ld(poll_addr, in_bytes(JavaThread::poll_address_offset()), R16_thread);
-    Unimplemented();
-    __ relocate(relocInfo::poll_type); // XXX
-    guarantee(info != NULL, "Shouldn't be NULL");
-    int offset = __ offset();
-    add_debug_info_for_branch(info);
-    __ load_from_polling_page(poll_addr);
-    return offset;
+  const Register poll_addr = tmp->as_register();
+  if (SafepointMechanism::uses_thread_local_poll()) {
+    __ ld(poll_addr, in_bytes(Thread::polling_page_offset()), R16_thread);
+  } else {
+    __ load_const_optimized(poll_addr, (intptr_t)os::get_polling_page(), R0);
   }
-
-  __ load_const_optimized(tmp->as_register(), (intptr_t)os::get_polling_page(), R0); // TODO: PPC port: get_standard_polling_page()
   if (info != NULL) {
     add_debug_info_for_branch(info);
   }
   int offset = __ offset();
   __ relocate(relocInfo::poll_type);
-  __ load_from_polling_page(tmp->as_register());
+  __ load_from_polling_page(poll_addr);
 
   return offset;
 }
--- a/src/hotspot/cpu/ppc/globalDefinitions_ppc.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/ppc/globalDefinitions_ppc.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -54,4 +54,6 @@
 
 #define SUPPORT_RESERVED_STACK_AREA
 
+#define THREAD_LOCAL_POLL
+
 #endif // CPU_PPC_VM_GLOBALDEFINITIONS_PPC_HPP
--- a/src/hotspot/cpu/ppc/globals_ppc.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/ppc/globals_ppc.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -83,7 +83,7 @@
 // 2x unrolled loop is shorter with more than 9 HeapWords.
 define_pd_global(intx, InitArrayShortSize, 9*BytesPerLong);
 
-define_pd_global(bool, ThreadLocalHandshakes, false);
+define_pd_global(bool, ThreadLocalHandshakes, true);
 
 // Platform dependent flag handling: flags only defined on this platform.
 #define ARCH_FLAGS(develop, \
@@ -95,12 +95,6 @@
                    constraint, \
                    writeable)  \
                                                                             \
-  /* Load poll address from thread. This is used to implement per-thread */ \
-  /* safepoints on platforms != IA64. */                                    \
-  product(bool, LoadPollAddressFromThread, false,                           \
-          "Load polling page address from thread object (required for "     \
-          "per-thread safepoints on platforms != IA64)")                    \
-                                                                            \
   product(uintx, PowerArchitecturePPC64, 0,                                 \
           "CPU Version: x for PowerX. Currently recognizes Power5 to "      \
           "Power8. Default is 0. Newer CPUs will be recognized as Power8.") \
--- a/src/hotspot/cpu/ppc/interp_masm_ppc.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/ppc/interp_masm_ppc.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -57,10 +57,10 @@
   static const Address d_tmp;
 
   // dispatch routines
-  void dispatch_next(TosState state, int step = 0);
+  void dispatch_next(TosState state, int step = 0, bool generate_poll = false);
   void dispatch_via (TosState state, address* table);
   void load_dispatch_table(Register dst, address* table);
-  void dispatch_Lbyte_code(TosState state, Register bytecode, address* table, bool verify = false);
+  void dispatch_Lbyte_code(TosState state, Register bytecode, address* table, bool generate_poll = false);
 
   // Called by shared interpreter generator.
   void dispatch_prolog(TosState state, int step = 0);
--- a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -29,6 +29,7 @@
 #include "interp_masm_ppc.hpp"
 #include "interpreter/interpreterRuntime.hpp"
 #include "prims/jvmtiThreadState.hpp"
+#include "runtime/safepointMechanism.hpp"
 #include "runtime/sharedRuntime.hpp"
 
 #ifdef PRODUCT
@@ -53,7 +54,7 @@
   }
 }
 
-void InterpreterMacroAssembler::dispatch_next(TosState state, int bcp_incr) {
+void InterpreterMacroAssembler::dispatch_next(TosState state, int bcp_incr, bool generate_poll) {
   Register bytecode = R12_scratch2;
   if (bcp_incr != 0) {
     lbzu(bytecode, bcp_incr, R14_bcp);
@@ -61,7 +62,7 @@
     lbz(bytecode, 0, R14_bcp);
   }
 
-  dispatch_Lbyte_code(state, bytecode, Interpreter::dispatch_table(state));
+  dispatch_Lbyte_code(state, bytecode, Interpreter::dispatch_table(state), generate_poll);
 }
 
 void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) {
@@ -203,16 +204,26 @@
 }
 
 void InterpreterMacroAssembler::dispatch_Lbyte_code(TosState state, Register bytecode,
-                                                    address* table, bool verify) {
-  if (verify) {
-    unimplemented("dispatch_Lbyte_code: verify"); // See Sparc Implementation to implement this
-  }
-
+                                                    address* table, bool generate_poll) {
   assert_different_registers(bytecode, R11_scratch1);
 
   // Calc dispatch table address.
   load_dispatch_table(R11_scratch1, table);
 
+  if (SafepointMechanism::uses_thread_local_poll() && generate_poll) {
+    address *sfpt_tbl = Interpreter::safept_table(state);
+    if (table != sfpt_tbl) {
+      Label dispatch;
+      ld(R0, in_bytes(Thread::polling_page_offset()), R16_thread);
+      // Armed page has poll_bit set, if poll bit is cleared just continue.
+      andi_(R0, R0, SafepointMechanism::poll_bit());
+      beq(CCR0, dispatch);
+      load_dispatch_table(R11_scratch1, sfpt_tbl);
+      align(32, 16);
+      bind(dispatch);
+    }
+  }
+
   sldi(R12_scratch2, bytecode, LogBytesPerWord);
   ldx(R11_scratch1, R11_scratch1, R12_scratch2);
 
--- a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -37,6 +37,8 @@
 #include "runtime/interfaceSupport.hpp"
 #include "runtime/objectMonitor.hpp"
 #include "runtime/os.hpp"
+#include "runtime/safepoint.hpp"
+#include "runtime/safepointMechanism.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "utilities/macros.hpp"
@@ -3019,6 +3021,18 @@
   stwx(R0, tmp1, tmp2);
 }
 
+void MacroAssembler::safepoint_poll(Label& slow_path, Register temp_reg) {
+  if (SafepointMechanism::uses_thread_local_poll()) {
+    ld(temp_reg, in_bytes(Thread::polling_page_offset()), R16_thread);
+    // Armed page has poll_bit set.
+    andi_(temp_reg, temp_reg, SafepointMechanism::poll_bit());
+  } else {
+    lwz(temp_reg, (RegisterOrConstant)(intptr_t)SafepointSynchronize::address_of_state());
+    cmpwi(CCR0, temp_reg, SafepointSynchronize::_not_synchronized);
+  }
+  bne(CCR0, slow_path);
+}
+
 
 // GC barrier helper macros
 
--- a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -647,6 +647,9 @@
   // Support for serializing memory accesses between threads
   void serialize_memory(Register thread, Register tmp1, Register tmp2);
 
+  // Check if safepoint requested and if so branch
+  void safepoint_poll(Label& slow_path, Register temp_reg);
+
   // GC barrier support.
   void card_write_barrier_post(Register Rstore_addr, Register Rnew_val, Register Rtmp);
   void card_table_write(jbyte* byte_map_base, Register Rtmp, Register Robj);
--- a/src/hotspot/cpu/ppc/ppc.ad	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/ppc/ppc.ad	Mon Dec 18 10:28:43 2017 -0800
@@ -1577,11 +1577,10 @@
   }
 
   if (method_needs_polling) {
-    if (LoadPollAddressFromThread) {
-      // TODO: PPC port __ ld(polling_page, in_bytes(JavaThread::poll_address_offset()), R16_thread);
-      Unimplemented();
+    if (SafepointMechanism::uses_thread_local_poll()) {
+      __ ld(polling_page, in_bytes(JavaThread::polling_page_offset()), R16_thread);
     } else {
-      __ load_const_optimized(polling_page, (long)(address) os::get_polling_page()); // TODO: PPC port: get_standard_polling_page()
+      __ load_const_optimized(polling_page, (long)(address) os::get_polling_page());
     }
   }
 
@@ -14147,7 +14146,6 @@
 
 instruct safePoint_poll(iRegPdst poll) %{
   match(SafePoint poll);
-  predicate(LoadPollAddressFromThread);
 
   // It caused problems to add the effect that r0 is killed, but this
   // effect no longer needs to be mentioned, since r0 is not contained
@@ -14159,24 +14157,6 @@
   ins_pipe(pipe_class_default);
 %}
 
-// Safepoint without per-thread support. Load address of page to poll
-// as constant.
-// Rscratch2RegP is R12.
-// LoadConPollAddr node is added in pd_post_matching_hook(). It must be
-// a seperate node so that the oop map is at the right location.
-instruct safePoint_poll_conPollAddr(rscratch2RegP poll) %{
-  match(SafePoint poll);
-  predicate(!LoadPollAddressFromThread);
-
-  // It caused problems to add the effect that r0 is killed, but this
-  // effect no longer needs to be mentioned, since r0 is not contained
-  // in a reg_class.
-
-  format %{ "LD      R0, #0, R12 \t// Safepoint poll for GC" %}
-  ins_encode( enc_poll(0x0, poll) );
-  ins_pipe(pipe_class_default);
-%}
-
 // ============================================================================
 // Call Instructions
 
--- a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -214,6 +214,7 @@
   // StackFrameStream construction (needed for deoptimization; see
   // compiledVFrame::create_stack_value).
   // If return_pc_adjustment != 0 adjust the return pc by return_pc_adjustment.
+  // Updated return pc is returned in R31 (if not return_pc_is_pre_saved).
 
   int i;
   int offset;
@@ -233,16 +234,17 @@
 
   BLOCK_COMMENT("push_frame_reg_args_and_save_live_registers {");
 
-  // Save r31 in the last slot of the not yet pushed frame so that we
-  // can use it as scratch reg.
-  __ std(R31, -reg_size, R1_SP);
+  // Save some registers in the last slots of the not yet pushed frame so that we
+  // can use them as scratch regs.
+  __ std(R31, -  reg_size, R1_SP);
+  __ std(R30, -2*reg_size, R1_SP);
   assert(-reg_size == register_save_offset - frame_size_in_bytes + ((regstosave_num-1)*reg_size),
          "consistency check");
 
   // save the flags
   // Do the save_LR_CR by hand and adjust the return pc if requested.
-  __ mfcr(R31);
-  __ std(R31, _abi(cr), R1_SP);
+  __ mfcr(R30);
+  __ std(R30, _abi(cr), R1_SP);
   switch (return_pc_location) {
     case return_pc_is_lr: __ mflr(R31); break;
     case return_pc_is_pre_saved: assert(return_pc_adjustment == 0, "unsupported"); break;
@@ -257,7 +259,7 @@
   }
 
   // push a new frame
-  __ push_frame(frame_size_in_bytes, R31);
+  __ push_frame(frame_size_in_bytes, R30);
 
   // save all registers (ints and floats)
   offset = register_save_offset;
@@ -267,7 +269,7 @@
 
     switch (reg_type) {
       case RegisterSaver::int_reg: {
-        if (reg_num != 31) { // We spilled R31 right at the beginning.
+        if (reg_num < 30) { // We spilled R30-31 right at the beginning.
           __ std(as_Register(reg_num), offset, R1_SP);
         }
         break;
@@ -278,8 +280,8 @@
       }
       case RegisterSaver::special_reg: {
         if (reg_num == SR_CTR_SpecialRegisterEnumValue) {
-          __ mfctr(R31);
-          __ std(R31, offset, R1_SP);
+          __ mfctr(R30);
+          __ std(R30, offset, R1_SP);
         } else {
           Unimplemented();
         }
@@ -2364,23 +2366,14 @@
     Register sync_state      = r_temp_5;
     Register suspend_flags   = r_temp_6;
 
-    __ load_const(sync_state_addr, SafepointSynchronize::address_of_state(), /*temp*/ sync_state);
-
-    // TODO: PPC port assert(4 == SafepointSynchronize::sz_state(), "unexpected field size");
-    __ lwz(sync_state, 0, sync_state_addr);
-
+    // No synchronization in progress nor yet synchronized
+    // (cmp-br-isync on one path, release (same as acquire on PPC64) on the other path).
+    __ safepoint_poll(sync, sync_state);
+
+    // Not suspended.
     // TODO: PPC port assert(4 == Thread::sz_suspend_flags(), "unexpected field size");
     __ lwz(suspend_flags, thread_(suspend_flags));
-
-    __ acquire();
-
-    Label do_safepoint;
-    // No synchronization in progress nor yet synchronized.
-    __ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
-    // Not suspended.
     __ cmpwi(CCR1, suspend_flags, 0);
-
-    __ bne(CCR0, sync);
     __ beq(CCR1, no_block);
 
     // Block. Save any potential method result value before the operation and
@@ -2388,6 +2381,7 @@
     // lets us share the oopMap we used when we went native rather than create
     // a distinct one for this pc.
     __ bind(sync);
+    __ isync();
 
     address entry_point = is_critical_native
       ? CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans_and_transition)
@@ -2410,7 +2404,7 @@
 
   // Transition from _thread_in_native_trans to _thread_in_Java.
   __ li(R0, _thread_in_Java);
-  __ release();
+  __ lwsync(); // Acquire safepoint and suspend state, release thread state.
   // TODO: PPC port assert(4 == JavaThread::sz_thread_state(), "unexpected field size");
   __ stw(R0, thread_(thread_state));
   __ bind(after_transition);
@@ -3093,7 +3087,7 @@
     return_pc_location = RegisterSaver::return_pc_is_thread_saved_exception_pc;
   }
 
-  // Save registers, fpu state, and flags.
+  // Save registers, fpu state, and flags. Set R31 = return pc.
   map = RegisterSaver::push_frame_reg_args_and_save_live_registers(masm,
                                                                    &frame_size_in_bytes,
                                                                    /*generate_oop_map=*/ true,
@@ -3142,6 +3136,19 @@
   // No exception case.
   __ BIND(noException);
 
+  if (SafepointMechanism::uses_thread_local_poll() && !cause_return) {
+    Label no_adjust;
+    // If our stashed return pc was modified by the runtime we avoid touching it
+    __ ld(R0, frame_size_in_bytes + _abi(lr), R1_SP);
+    __ cmpd(CCR0, R0, R31);
+    __ bne(CCR0, no_adjust);
+
+    // Adjust return pc forward to step over the safepoint poll instruction
+    __ addi(R31, R31, 4);
+    __ std(R31, frame_size_in_bytes + _abi(lr), R1_SP);
+
+    __ bind(no_adjust);
+  }
 
   // Normal exit, restore registers and exit.
   RegisterSaver::restore_live_registers_and_pop_frame(masm,
--- a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -1535,23 +1535,17 @@
   // Acquire isn't strictly necessary here because of the fence, but
   // sync_state is declared to be volatile, so we do it anyway
   // (cmp-br-isync on one path, release (same as acquire on PPC64) on the other path).
-  int sync_state_offs = __ load_const_optimized(sync_state_addr, SafepointSynchronize::address_of_state(), /*temp*/R0, true);
 
-  // TODO PPC port assert(4 == SafepointSynchronize::sz_state(), "unexpected field size");
-  __ lwz(sync_state, sync_state_offs, sync_state_addr);
+  Label do_safepoint, sync_check_done;
+  // No synchronization in progress nor yet synchronized.
+  __ safepoint_poll(do_safepoint, sync_state);
 
+  // Not suspended.
   // TODO PPC port assert(4 == Thread::sz_suspend_flags(), "unexpected field size");
   __ lwz(suspend_flags, thread_(suspend_flags));
+  __ cmpwi(CCR1, suspend_flags, 0);
+  __ beq(CCR1, sync_check_done);
 
-  Label sync_check_done;
-  Label do_safepoint;
-  // No synchronization in progress nor yet synchronized.
-  __ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
-  // Not suspended.
-  __ cmpwi(CCR1, suspend_flags, 0);
-
-  __ bne(CCR0, do_safepoint);
-  __ beq(CCR1, sync_check_done);
   __ bind(do_safepoint);
   __ isync();
   // Block. We do the call directly and leave the current
@@ -1592,7 +1586,7 @@
   // we don't want the current thread to continue until all our prior memory
   // accesses (including the new thread state) are visible to other threads.
   __ li(R0/*thread_state*/, _thread_in_Java);
-  __ release();
+  __ lwsync(); // Acquire safepoint and suspend state, release thread state.
   __ stw(R0/*thread_state*/, thread_(thread_state));
 
   if (CheckJNICalls) {
@@ -1858,10 +1852,7 @@
 
     // Safepoint check
     const Register sync_state = R11_scratch1;
-    int sync_state_offs = __ load_const_optimized(sync_state, SafepointSynchronize::address_of_state(), /*temp*/R0, true);
-    __ lwz(sync_state, sync_state_offs, sync_state);
-    __ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
-    __ bne(CCR0, slow_path);
+    __ safepoint_poll(slow_path, sync_state);
 
     // We don't generate local frame and don't align stack because
     // we not even call stub code (we generate the code inline)
@@ -1918,10 +1909,7 @@
 
     // Safepoint check
     const Register sync_state = R11_scratch1;
-    int sync_state_offs = __ load_const_optimized(sync_state, SafepointSynchronize::address_of_state(), /*temp*/R0, true);
-    __ lwz(sync_state, sync_state_offs, sync_state);
-    __ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
-    __ bne(CCR0, slow_path);
+    __ safepoint_poll(slow_path, sync_state);
 
     // We don't generate local frame and don't align stack because
     // we not even call stub code (we generate the code inline)
--- a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -1630,7 +1630,7 @@
     // Push returnAddress for "ret" on stack.
     __ push_ptr(R17_tos);
     // And away we go!
-    __ dispatch_next(vtos);
+    __ dispatch_next(vtos, 0 ,true);
     return;
   }
 
@@ -1643,7 +1643,6 @@
   const bool increment_invocation_counter_for_backward_branches = UseCompiler && UseLoopCounter;
   if (increment_invocation_counter_for_backward_branches) {
     Label Lforward;
-    __ dispatch_prolog(vtos);
 
     // Check branch direction.
     __ cmpdi(CCR0, Rdisp, 0);
@@ -1744,11 +1743,8 @@
     }
 
     __ bind(Lforward);
-    __ dispatch_epilog(vtos);
-
-  } else {
-    __ dispatch_next(vtos);
   }
+  __ dispatch_next(vtos, 0, true);
 }
 
 // Helper function for if_cmp* methods below.
@@ -1829,7 +1825,7 @@
   __ ld(R11_scratch1, in_bytes(Method::const_offset()), R19_method);
   __ add(R11_scratch1, R17_tos, R11_scratch1);
   __ addi(R14_bcp, R11_scratch1, in_bytes(ConstMethod::codes_offset()));
-  __ dispatch_next(vtos);
+  __ dispatch_next(vtos, 0, true);
 }
 
 void TemplateTable::wide_ret() {
@@ -1846,7 +1842,7 @@
   __ ld(Rscratch1, in_bytes(Method::const_offset()), R19_method);
   __ addi(Rscratch2, R17_tos, in_bytes(ConstMethod::codes_offset()));
   __ add(R14_bcp, Rscratch1, Rscratch2);
-  __ dispatch_next(vtos);
+  __ dispatch_next(vtos, 0, true);
 }
 
 void TemplateTable::tableswitch() {
@@ -1896,7 +1892,7 @@
   __ bind(Ldispatch);
 
   __ add(R14_bcp, Roffset, R14_bcp);
-  __ dispatch_next(vtos);
+  __ dispatch_next(vtos, 0, true);
 }
 
 void TemplateTable::lookupswitch() {
@@ -1960,7 +1956,7 @@
 
   __ bind(Lcontinue_execution);
   __ add(R14_bcp, Roffset, R14_bcp);
-  __ dispatch_next(vtos);
+  __ dispatch_next(vtos, 0, true);
 }
 
 // Table switch using binary search (value/offset pairs are ordered).
@@ -2093,7 +2089,7 @@
 
   __ extsw(Rj, Rj);
   __ add(R14_bcp, Rj, R14_bcp);
-  __ dispatch_next(vtos);
+  __ dispatch_next(vtos, 0 , true);
 }
 
 void TemplateTable::_return(TosState state) {
@@ -2124,6 +2120,17 @@
     __ bind(Lskip_register_finalizer);
   }
 
+  if (SafepointMechanism::uses_thread_local_poll() && _desc->bytecode() != Bytecodes::_return_register_finalizer) {
+    Label no_safepoint;
+    __ ld(R11_scratch1, in_bytes(Thread::polling_page_offset()), R16_thread);
+    __ andi_(R11_scratch1, R11_scratch1, SafepointMechanism::poll_bit());
+    __ beq(CCR0, no_safepoint);
+    __ push(state);
+    __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint));
+    __ pop(state);
+    __ bind(no_safepoint);
+  }
+
   // Move the result value into the correct register and remove memory stack frame.
   __ remove_activation(state, /* throw_monitor_exception */ true);
   // Restoration of lr done by remove_activation.
--- a/src/hotspot/cpu/s390/assembler_s390.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/s390/assembler_s390.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -1459,6 +1459,10 @@
     bcondLogNotZero          =  bcondLogNotZero_Carry | bcondLogNotZero_NoCarry,
     bcondLogCarry            =  bcondLogZero_Carry | bcondLogNotZero_Carry,
     bcondLogBorrow           =  /* bcondLogZero_Borrow | */ bcondLogNotZero_Borrow,
+    // Vector compare instructions
+    bcondVAlltrue    =  8,  // All  vector elements evaluate true
+    bcondVMixed      =  4,  // Some vector elements evaluate true, some false
+    bcondVAllfalse   =  1,  // All  vector elements evaluate false
     // string search instructions
     bcondFound       =  4,
     bcondNotFound    =  2,
@@ -3022,6 +3026,12 @@
   inline void z_btrue( Label& L);
   inline void z_bfalse(Label& L);
 
+  inline void z_bvat(Label& L);   // all true
+  inline void z_bvnt(Label& L);   // not all true (mixed or all false)
+  inline void z_bvmix(Label& L);  // mixed true and false
+  inline void z_bvaf(Label& L);   // not all false (mixed or all true)
+  inline void z_bvnf(Label& L);   // all false
+
   inline void z_brno( Label& L);
 
 
--- a/src/hotspot/cpu/s390/assembler_s390.inline.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/s390/assembler_s390.inline.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -1315,23 +1315,28 @@
 
 inline void Assembler::z_exrl(Register r1, Label& L) { z_exrl(r1, target(L)); }  // z10
 inline void Assembler::z_larl(Register r1, Label& L) { z_larl(r1, target(L)); }
-inline void Assembler::z_bru(   Label& L) { z_brc(bcondAlways,target(L)); }
-inline void Assembler::z_brul(  Label& L) { z_brcl(bcondAlways,target(L)); }
-inline void Assembler::z_brul( address a) { z_brcl(bcondAlways,a); }
-inline void Assembler::z_brh(   Label& L) { z_brc(bcondHigh,target(L)); }
-inline void Assembler::z_brl(   Label& L) { z_brc(bcondLow,target(L)); }
-inline void Assembler::z_bre(   Label& L) { z_brc(bcondEqual,target(L)); }
-inline void Assembler::z_brnh(  Label& L) { z_brc(bcondNotHigh,target(L)); }
-inline void Assembler::z_brnl(  Label& L) { z_brc(bcondNotLow,target(L)); }
-inline void Assembler::z_brne(  Label& L) { z_brc(bcondNotEqual,target(L)); }
-inline void Assembler::z_brz(   Label& L) { z_brc(bcondZero,target(L)); }
-inline void Assembler::z_brnz(  Label& L) { z_brc(bcondNotZero,target(L)); }
-inline void Assembler::z_braz(  Label& L) { z_brc(bcondAllZero,target(L)); }
-inline void Assembler::z_brnaz( Label& L) { z_brc(bcondNotAllZero,target(L)); }
+inline void Assembler::z_bru(   Label& L) { z_brc(bcondAlways, target(L)); }
+inline void Assembler::z_brul(  Label& L) { z_brcl(bcondAlways, target(L)); }
+inline void Assembler::z_brul( address a) { z_brcl(bcondAlways,a ); }
+inline void Assembler::z_brh(   Label& L) { z_brc(bcondHigh, target(L)); }
+inline void Assembler::z_brl(   Label& L) { z_brc(bcondLow, target(L)); }
+inline void Assembler::z_bre(   Label& L) { z_brc(bcondEqual, target(L)); }
+inline void Assembler::z_brnh(  Label& L) { z_brc(bcondNotHigh, target(L)); }
+inline void Assembler::z_brnl(  Label& L) { z_brc(bcondNotLow, target(L)); }
+inline void Assembler::z_brne(  Label& L) { z_brc(bcondNotEqual, target(L)); }
+inline void Assembler::z_brz(   Label& L) { z_brc(bcondZero, target(L)); }
+inline void Assembler::z_brnz(  Label& L) { z_brc(bcondNotZero, target(L)); }
+inline void Assembler::z_braz(  Label& L) { z_brc(bcondAllZero, target(L)); }
+inline void Assembler::z_brnaz( Label& L) { z_brc(bcondNotAllZero, target(L)); }
 inline void Assembler::z_brnp(  Label& L) { z_brc( bcondNotPositive, target( L)); }
-inline void Assembler::z_btrue( Label& L) { z_brc(bcondAllOne,target(L)); }
-inline void Assembler::z_bfalse(Label& L) { z_brc(bcondAllZero,target(L)); }
-inline void Assembler::z_brno(  Label& L) { z_brc(bcondNotOrdered,target(L)); }
+inline void Assembler::z_btrue( Label& L) { z_brc(bcondAllOne, target(L)); }
+inline void Assembler::z_bfalse(Label& L) { z_brc(bcondAllZero, target(L)); }
+inline void Assembler::z_bvat(  Label& L) { z_brc(bcondVAlltrue, target(L)); }
+inline void Assembler::z_bvnt(  Label& L) { z_brc((Assembler::branch_condition)(bcondVMixed | bcondVAllfalse), target(L)); }
+inline void Assembler::z_bvmix( Label& L) { z_brc(bcondVMixed, target(L)); }
+inline void Assembler::z_bvaf(  Label& L) { z_brc(bcondVAllfalse, target(L)); }
+inline void Assembler::z_bvnf(  Label& L) { z_brc((Assembler::branch_condition)(bcondVMixed | bcondVAlltrue), target(L)); }
+inline void Assembler::z_brno(  Label& L) { z_brc(bcondNotOrdered, target(L)); }
 inline void Assembler::z_brc( branch_condition m, Label& L) { z_brc(m, target(L)); }
 inline void Assembler::z_brcl(branch_condition m, Label& L) { z_brcl(m, target(L)); }
 
--- a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -36,6 +36,7 @@
 #include "gc/shared/cardTableModRefBS.hpp"
 #include "nativeInst_s390.hpp"
 #include "oops/objArrayKlass.hpp"
+#include "runtime/safepointMechanism.inline.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "vmreg_s390.inline.hpp"
 
@@ -1135,8 +1136,12 @@
          (result->is_single_fpu() && result->as_float_reg() == Z_F0) ||
          (result->is_double_fpu() && result->as_double_reg() == Z_F0), "convention");
 
-  AddressLiteral pp(os::get_polling_page());
-  __ load_const_optimized(Z_R1_scratch, pp);
+  if (SafepointMechanism::uses_thread_local_poll()) {
+    __ z_lg(Z_R1_scratch, Address(Z_thread, Thread::polling_page_offset()));
+  } else {
+    AddressLiteral pp(os::get_polling_page());
+    __ load_const_optimized(Z_R1_scratch, pp);
+  }
 
   // Pop the frame before the safepoint code.
   __ pop_frame_restore_retPC(initial_frame_size_in_bytes());
@@ -1154,13 +1159,18 @@
 }
 
 int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
-  AddressLiteral pp(os::get_polling_page());
-  __ load_const_optimized(tmp->as_register_lo(), pp);
+  const Register poll_addr = tmp->as_register_lo();
+  if (SafepointMechanism::uses_thread_local_poll()) {
+    __ z_lg(poll_addr, Address(Z_thread, Thread::polling_page_offset()));
+  } else {
+    AddressLiteral pp(os::get_polling_page());
+    __ load_const_optimized(poll_addr, pp);
+  }
   guarantee(info != NULL, "Shouldn't be NULL");
   add_debug_info_for_branch(info);
   int offset = __ offset();
   __ relocate(relocInfo::poll_type);
-  __ load_from_polling_page(tmp->as_register_lo());
+  __ load_from_polling_page(poll_addr);
   return offset;
 }
 
--- a/src/hotspot/cpu/s390/globalDefinitions_s390.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/s390/globalDefinitions_s390.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -54,4 +54,6 @@
 
 #define SUPPORT_RESERVED_STACK_AREA
 
+#define THREAD_LOCAL_POLL
+
 #endif // CPU_S390_VM_GLOBALDEFINITIONS_S390_HPP
--- a/src/hotspot/cpu/s390/globals_s390.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/s390/globals_s390.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -85,7 +85,7 @@
 // 8146801 (Short Array Allocation): No performance work done here yet.
 define_pd_global(intx, InitArrayShortSize, 1*BytesPerLong);
 
-define_pd_global(bool, ThreadLocalHandshakes, false);
+define_pd_global(bool, ThreadLocalHandshakes, true);
 
 #define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint, writeable) \
                                                                               \
--- a/src/hotspot/cpu/s390/interp_masm_s390.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/s390/interp_masm_s390.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -36,6 +36,7 @@
 #include "prims/jvmtiThreadState.hpp"
 #include "runtime/basicLock.hpp"
 #include "runtime/biasedLocking.hpp"
+#include "runtime/safepointMechanism.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/thread.inline.hpp"
 
@@ -74,16 +75,16 @@
   dispatch_next(state, step);
 }
 
-void InterpreterMacroAssembler::dispatch_next(TosState state, int bcp_incr) {
+void InterpreterMacroAssembler::dispatch_next(TosState state, int bcp_incr, bool generate_poll) {
   z_llgc(Z_bytecode, bcp_incr, Z_R0, Z_bcp);  // Load next bytecode.
   add2reg(Z_bcp, bcp_incr);                   // Advance bcp. Add2reg produces optimal code.
-  dispatch_base(state, Interpreter::dispatch_table(state));
+  dispatch_base(state, Interpreter::dispatch_table(state), generate_poll);
 }
 
 // Common code to dispatch and dispatch_only.
 // Dispatch value in Lbyte_code and increment Lbcp.
 
-void InterpreterMacroAssembler::dispatch_base(TosState state, address* table) {
+void InterpreterMacroAssembler::dispatch_base(TosState state, address* table, bool generate_poll) {
   verify_FPU(1, state);
 
 #ifdef ASSERT
@@ -109,7 +110,20 @@
   verify_oop(Z_tos, state);
 
   // Dispatch table to use.
-  load_absolute_address(Z_tmp_1, (address) table);  // Z_tmp_1 = table;
+  load_absolute_address(Z_tmp_1, (address)table);  // Z_tmp_1 = table;
+
+  if (SafepointMechanism::uses_thread_local_poll() && generate_poll) {
+    address *sfpt_tbl = Interpreter::safept_table(state);
+    if (table != sfpt_tbl) {
+      Label dispatch;
+      const Address poll_byte_addr(Z_thread, in_bytes(Thread::polling_page_offset()) + 7 /* Big Endian */);
+      // Armed page has poll_bit set, if poll bit is cleared just continue.
+      z_tm(poll_byte_addr, SafepointMechanism::poll_bit());
+      z_braz(dispatch);
+      load_absolute_address(Z_tmp_1, (address)sfpt_tbl);  // Z_tmp_1 = table;
+      bind(dispatch);
+    }
+  }
 
   // 0 <= Z_bytecode < 256 => Use a 32 bit shift, because it is shorter than sllg.
   // Z_bytecode must have been loaded zero-extended for this approach to be correct.
@@ -119,8 +133,8 @@
   z_br(Z_tmp_1);
 }
 
-void InterpreterMacroAssembler::dispatch_only(TosState state) {
-  dispatch_base(state, Interpreter::dispatch_table(state));
+void InterpreterMacroAssembler::dispatch_only(TosState state, bool generate_poll) {
+  dispatch_base(state, Interpreter::dispatch_table(state), generate_poll);
 }
 
 void InterpreterMacroAssembler::dispatch_only_normal(TosState state) {
--- a/src/hotspot/cpu/s390/interp_masm_s390.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/s390/interp_masm_s390.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -49,7 +49,7 @@
                             bool check_exceptions);
 
   // Base routine for all dispatches.
-  void dispatch_base(TosState state, address* table);
+  void dispatch_base(TosState state, address* table, bool generate_poll = false);
 
  public:
   InterpreterMacroAssembler(CodeBuffer* c)
@@ -78,11 +78,11 @@
   // dispatch routines
   void dispatch_prolog(TosState state, int step = 0);
   void dispatch_epilog(TosState state, int step = 0);
-  void dispatch_only(TosState state);
+  void dispatch_only(TosState state, bool generate_poll = false);
   // Dispatch normal table via Z_bytecode (assume Z_bytecode is loaded already).
   void dispatch_only_normal(TosState state);
   void dispatch_normal(TosState state);
-  void dispatch_next(TosState state, int step = 0);
+  void dispatch_next(TosState state, int step = 0, bool generate_poll = false);
   void dispatch_next_noverify_oop(TosState state, int step = 0);
   void dispatch_via(TosState state, address* table);
 
--- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -43,6 +43,8 @@
 #include "runtime/interfaceSupport.hpp"
 #include "runtime/objectMonitor.hpp"
 #include "runtime/os.hpp"
+#include "runtime/safepoint.hpp"
+#include "runtime/safepointMechanism.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "utilities/events.hpp"
@@ -2019,6 +2021,15 @@
   return here + offset;
 }
 
+void MacroAssembler::instr_size(Register size, Register pc) {
+  // Extract 2 most significant bits of current instruction.
+  z_llgc(size, Address(pc));
+  z_srl(size, 6);
+  // Compute (x+3)&6 which translates 0->2, 1->4, 2->4, 3->6.
+  z_ahi(size, 3);
+  z_nill(size, 6);
+}
+
 // Resize_frame with SP(new) = SP(old) - [offset].
 void MacroAssembler::resize_frame_sub(Register offset, Register fp, bool load_fp)
 {
@@ -2705,6 +2716,19 @@
   z_st(Z_R0, 0, tmp2, tmp1);
 }
 
+void MacroAssembler::safepoint_poll(Label& slow_path, Register temp_reg) {
+  if (SafepointMechanism::uses_thread_local_poll()) {
+    const Address poll_byte_addr(Z_thread, in_bytes(Thread::polling_page_offset()) + 7 /* Big Endian */);
+    // Armed page has poll_bit set.
+    z_tm(poll_byte_addr, SafepointMechanism::poll_bit());
+    z_brnaz(slow_path);
+  } else {
+    load_const_optimized(temp_reg, SafepointSynchronize::address_of_state());
+    z_cli(/*SafepointSynchronize::sz_state()*/4-1, temp_reg, SafepointSynchronize::_not_synchronized);
+    z_brne(slow_path);
+  }
+}
+
 // Don't rely on register locking, always use Z_R1 as scratch register instead.
 void MacroAssembler::bang_stack_with_offset(int offset) {
   // Stack grows down, caller passes positive offset.
@@ -4914,13 +4938,14 @@
 // The result is the number of characters copied before the first incompatible character was found.
 // If precise is true, the processing stops exactly at this point. Otherwise, the result may be off
 // by a few bytes. The result always indicates the number of copied characters.
+// When used as a character index, the returned value points to the first incompatible character.
 //
 // Note: Does not behave exactly like package private StringUTF16 compress java implementation in case of failure:
 // - Different number of characters may have been written to dead array (if precise is false).
 // - Returns a number <cnt instead of 0. (Result gets compared with cnt.)
 unsigned int MacroAssembler::string_compress(Register result, Register src, Register dst, Register cnt,
                                              Register tmp,    bool precise) {
-  assert_different_registers(Z_R0, Z_R1, src, dst, cnt, tmp);
+  assert_different_registers(Z_R0, Z_R1, result, src, dst, cnt, tmp);
 
   if (precise) {
     BLOCK_COMMENT("encode_iso_array {");
@@ -5027,7 +5052,7 @@
       z_vo(Vtmp1, Vtmp1, Vtmp2);
       z_vn(Vtmp1, Vtmp1, Vmask);
       z_vceqhs(Vtmp1, Vtmp1, Vzero);       // high half of all chars must be zero for successful compress.
-      z_brne(VectorBreak);                 // break vector loop, incompatible character found.
+      z_bvnt(VectorBreak);                 // break vector loop if not all vector elements compare eq -> incompatible character found.
                                            // re-process data from current iteration in break handler.
 
       //---<  pack & store characters  >---
@@ -5094,24 +5119,28 @@
     z_tmll(Rcnt, min_cnt-1);
     z_brnaz(ScalarShortcut);               // if all bits zero, there is nothing left to do for scalar loop.
                                            // Rix == 0 in all cases.
+    z_sllg(Z_R1, Rcnt, 1);                 // # src bytes already processed. Only lower 32 bits are valid!
+                                           //   Z_R1 contents must be treated as unsigned operand! For huge strings,
+                                           //   (Rcnt >= 2**30), the value may spill into the sign bit by sllg.
     z_lgfr(result, Rcnt);                  // all characters processed.
-    z_sgfr(Rdst, Rcnt);                    // restore ptr
-    z_sgfr(Rsrc, Rcnt);                    // restore ptr, double the element count for Rsrc restore
-    z_sgfr(Rsrc, Rcnt);
+    z_slgfr(Rdst, Rcnt);                   // restore ptr
+    z_slgfr(Rsrc, Z_R1);                   // restore ptr, double the element count for Rsrc restore
     z_bru(AllDone);
 
     bind(UnrolledBreak);
     z_lgfr(Z_R0, Rcnt);                    // # chars processed in total after unrolled loop
     z_nilf(Z_R0, ~(min_cnt-1));
-    z_sll(Rix, log_min_cnt);               // # chars processed so far in UnrolledLoop, excl. current iteration.
-    z_sr(Z_R0, Rix);                       // correct # chars processed in total.
+    z_sll(Rix, log_min_cnt);               // # chars not yet processed in UnrolledLoop (due to break), broken iteration not included.
+    z_sr(Z_R0, Rix);                       // fix # chars processed OK so far.
     if (!precise) {
       z_lgfr(result, Z_R0);
+      z_sllg(Z_R1, Z_R0, 1);               // # src bytes already processed. Only lower 32 bits are valid!
+                                           //   Z_R1 contents must be treated as unsigned operand! For huge strings,
+                                           //   (Rcnt >= 2**30), the value may spill into the sign bit by sllg.
       z_aghi(result, min_cnt/2);           // min_cnt/2 characters have already been written
                                            // but ptrs were not updated yet.
-      z_sgfr(Rdst, Z_R0);                  // restore ptr
-      z_sgfr(Rsrc, Z_R0);                  // restore ptr, double the element count for Rsrc restore
-      z_sgfr(Rsrc, Z_R0);
+      z_slgfr(Rdst, Z_R0);                 // restore ptr
+      z_slgfr(Rsrc, Z_R1);                 // restore ptr, double the element count for Rsrc restore
       z_bru(AllDone);
     }
     bind(UnrolledDone);
@@ -5165,7 +5194,7 @@
       z_sr(Rix, Z_R0);
     }
     z_lgfr(result, Rcnt);                  // # processed characters (if all runs ok).
-    z_brz(ScalarDone);
+    z_brz(ScalarDone);                     // uses CC from Rix calculation
 
     bind(ScalarLoop);
       z_llh(Z_R1, 0, Z_R0, Rsrc);
@@ -6452,27 +6481,6 @@
   Assembler::z_brc(Assembler::bcondOverflow /* CC==3 (iterate) */, retry);
 }
 
-void MacroAssembler::generate_safepoint_check(Label& slow_path, Register scratch, bool may_relocate) {
-  if (scratch == noreg) scratch = Z_R1;
-  address Astate = SafepointSynchronize::address_of_state();
-  BLOCK_COMMENT("safepoint check:");
-
-  if (may_relocate) {
-    ptrdiff_t total_distance = Astate - this->pc();
-    if (RelAddr::is_in_range_of_RelAddr32(total_distance)) {
-      RelocationHolder rspec = external_word_Relocation::spec(Astate);
-      (this)->relocate(rspec, relocInfo::pcrel_addr_format);
-      load_absolute_address(scratch, Astate);
-    } else {
-      load_const_optimized(scratch, Astate);
-    }
-  } else {
-    load_absolute_address(scratch, Astate);
-  }
-  z_cli(/*SafepointSynchronize::sz_state()*/4-1, scratch, SafepointSynchronize::_not_synchronized);
-  z_brne(slow_path);
-}
-
 
 void MacroAssembler::generate_type_profiling(const Register Rdata,
                                              const Register Rreceiver_klass,
--- a/src/hotspot/cpu/s390/macroAssembler_s390.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/s390/macroAssembler_s390.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -260,8 +260,6 @@
   //
   // Constants, loading constants, TOC support
   //
-  // Safepoint check factored out.
-  void generate_safepoint_check(Label& slow_path, Register scratch = noreg, bool may_relocate = true);
 
   // Load generic address: d <- base(a) + index(a) + disp(a).
   inline void load_address(Register d, const Address &a);
@@ -443,6 +441,9 @@
   // Get current PC + offset. Offset given in bytes, must be even!
   address get_PC(Register result, int64_t offset);
 
+  // Get size of instruction at pc (which must point to valid code).
+  void instr_size(Register size, Register pc);
+
   // Accessing, and in particular modifying, a stack location is only safe if
   // the stack pointer (Z_SP) is set such that the accessed stack location is
   // in the reserved range.
@@ -641,6 +642,9 @@
   // Support for serializing memory accesses between threads.
   void serialize_memory(Register thread, Register tmp1, Register tmp2);
 
+  // Check if safepoint requested and if so branch
+  void safepoint_poll(Label& slow_path, Register temp_reg);
+
   // Stack overflow checking
   void bang_stack_with_offset(int offset);
 
--- a/src/hotspot/cpu/s390/s390.ad	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/s390/s390.ad	Mon Dec 18 10:28:43 2017 -0800
@@ -919,8 +919,12 @@
 
   // Touch the polling page.
   if (need_polling) {
-    AddressLiteral pp(os::get_polling_page());
-    __ load_const_optimized(Z_R1_scratch, pp);
+    if (SafepointMechanism::uses_thread_local_poll()) {
+      __ z_lg(Z_R1_scratch, Address(Z_thread, Thread::polling_page_offset()));
+    } else {
+      AddressLiteral pp(os::get_polling_page());
+      __ load_const_optimized(Z_R1_scratch, pp);
+    }
     // We need to mark the code position where the load from the safepoint
     // polling page was emitted as relocInfo::poll_return_type here.
     __ relocate(relocInfo::poll_return_type);
--- a/src/hotspot/cpu/s390/sharedRuntime_s390.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/s390/sharedRuntime_s390.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -2165,7 +2165,7 @@
         __ serialize_memory(Z_thread, Z_R1, Z_R2);
       }
     }
-    __ generate_safepoint_check(sync, Z_R1, true);
+    __ safepoint_poll(sync, Z_R1);
 
     __ load_and_test_int(Z_R0, Address(Z_thread, JavaThread::suspend_flags_offset()));
     __ z_bre(no_block);
@@ -3190,12 +3190,18 @@
 
   bool cause_return = (poll_type == POLL_AT_RETURN);
   // Make room for return address (or push it again)
-  if (!cause_return)
+  if (!cause_return) {
     __ z_lg(Z_R14, Address(Z_thread, JavaThread::saved_exception_pc_offset()));
+  }
 
   // Save registers, fpu state, and flags
   map = RegisterSaver::save_live_registers(masm, RegisterSaver::all_registers);
 
+  if (SafepointMechanism::uses_thread_local_poll() && !cause_return) {
+    // Keep a copy of the return pc to detect if it gets modified.
+    __ z_lgr(Z_R6, Z_R14);
+  }
+
   // The following is basically a call_VM. However, we need the precise
   // address of the call in order to generate an oopmap. Hence, we do all the
   // work outselves.
@@ -3231,6 +3237,21 @@
   // No exception case
   __ bind(noException);
 
+  if (SafepointMechanism::uses_thread_local_poll() && !cause_return) {
+    Label no_adjust;
+     // If our stashed return pc was modified by the runtime we avoid touching it
+    const int offset_of_return_pc = _z_abi16(return_pc) + RegisterSaver::live_reg_frame_size(RegisterSaver::all_registers);
+    __ z_cg(Z_R6, offset_of_return_pc, Z_SP);
+    __ z_brne(no_adjust);
+
+    // Adjust return pc forward to step over the safepoint poll instruction
+    __ instr_size(Z_R1_scratch, Z_R6);
+    __ z_agr(Z_R6, Z_R1_scratch);
+    __ z_stg(Z_R6, offset_of_return_pc, Z_SP);
+
+    __ bind(no_adjust);
+  }
+
   // Normal exit, restore registers and exit.
   RegisterSaver::restore_live_registers(masm, RegisterSaver::all_registers);
 
--- a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -1633,7 +1633,7 @@
   // Check for safepoint operation in progress and/or pending suspend requests.
   {
     Label Continue, do_safepoint;
-    __ generate_safepoint_check(do_safepoint, Z_R1, true);
+    __ safepoint_poll(do_safepoint, Z_R1);
     // Check for suspend.
     __ load_and_test_int(Z_R0/*suspend_flags*/, thread_(suspend_flags));
     __ z_bre(Continue); // 0 -> no flag set -> not suspended
@@ -1937,7 +1937,7 @@
     Label    slow_path;
 
     // If we need a safepoint check, generate full interpreter entry.
-    __ generate_safepoint_check(slow_path, Z_R1, false);
+    __ safepoint_poll(slow_path, Z_R1);
 
     BLOCK_COMMENT("CRC32_update {");
 
@@ -1990,7 +1990,7 @@
     Label    slow_path;
 
     // If we need a safepoint check, generate full interpreter entry.
-    __ generate_safepoint_check(slow_path, Z_R1, false);
+    __ safepoint_poll(slow_path, Z_R1);
 
     // We don't generate local frame and don't align stack because
     // we call stub code and there is no safepoint on this path.
--- a/src/hotspot/cpu/s390/templateTable_s390.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/s390/templateTable_s390.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -1853,7 +1853,7 @@
     // Push return address for "ret" on stack.
     __ push_ptr(Z_tos);
     // And away we go!
-    __ dispatch_next(vtos);
+    __ dispatch_next(vtos, 0 , true);
     return;
   }
 
@@ -1961,7 +1961,7 @@
   // Z_tos: Return bci for jsr's, unused otherwise.
   // Z_bytecode: target bytecode
   // Z_bcp: target bcp
-  __ dispatch_only(vtos);
+  __ dispatch_only(vtos, true);
 
   // Out-of-line code runtime calls.
   if (UseLoopCounter) {
@@ -2072,7 +2072,7 @@
   __ get_method(Z_tos);
   __ mem2reg_opt(Z_R1_scratch, Address(Z_tos, Method::const_offset()));
   __ load_address(Z_bcp, Address(Z_R1_scratch, Z_tmp_1, ConstMethod::codes_offset()));
-  __ dispatch_next(vtos);
+  __ dispatch_next(vtos, 0 , true);
 }
 
 void TemplateTable::wide_ret() {
@@ -2085,7 +2085,7 @@
   __ get_method(Z_tos);
   __ mem2reg_opt(Z_R1_scratch, Address(Z_tos, Method::const_offset()));
   __ load_address(Z_bcp, Address(Z_R1_scratch, Z_tmp_1, ConstMethod::codes_offset()));
-  __ dispatch_next(vtos);
+  __ dispatch_next(vtos, 0, true);
 }
 
 void TemplateTable::tableswitch () {
@@ -2129,7 +2129,7 @@
   // Load next bytecode.
   __ z_llgc(Z_bytecode, Address(Z_bcp, index));
   __ z_agr(Z_bcp, index); // Advance bcp.
-  __ dispatch_only(vtos);
+  __ dispatch_only(vtos, true);
 
   // Handle default.
   __ bind(default_case);
@@ -2193,7 +2193,7 @@
   // Load next bytecode.
   __ z_llgc(Z_bytecode, Address(Z_bcp, offset, 0));
   __ z_agr(Z_bcp, offset); // Advance bcp.
-  __ dispatch_only(vtos);
+  __ dispatch_only(vtos, true);
 }
 
 
@@ -2302,7 +2302,7 @@
   // Load next bytecode.
   __ z_llgc(Z_bytecode, Address(Z_bcp, j));
   __ z_agr(Z_bcp, j);       // Advance bcp.
-  __ dispatch_only(vtos);
+  __ dispatch_only(vtos, true);
 
   // default case -> j = default offset
   __ bind(default_case);
@@ -2312,7 +2312,7 @@
   // Load next bytecode.
   __ z_llgc(Z_bytecode, Address(Z_bcp, j));
   __ z_agr(Z_bcp, j);       // Advance bcp.
-  __ dispatch_only(vtos);
+  __ dispatch_only(vtos, true);
 }
 
 void TemplateTable::_return(TosState state) {
@@ -2333,6 +2333,17 @@
     __ bind(skip_register_finalizer);
   }
 
+  if (SafepointMechanism::uses_thread_local_poll() && _desc->bytecode() != Bytecodes::_return_register_finalizer) {
+    Label no_safepoint;
+    const Address poll_byte_addr(Z_thread, in_bytes(Thread::polling_page_offset()) + 7 /* Big Endian */);
+    __ z_tm(poll_byte_addr, SafepointMechanism::poll_bit());
+    __ z_braz(no_safepoint);
+    __ push(state);
+    __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint));
+    __ pop(state);
+    __ bind(no_safepoint);
+  }
+
   if (state == itos) {
     // Narrow result if state is itos but result type is smaller.
     // Need to narrow in the return bytecode rather than in generate_return_entry
--- a/src/hotspot/cpu/sparc/stubGenerator_sparc.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/sparc/stubGenerator_sparc.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -5157,8 +5157,8 @@
     const Register gxp  = G1;   // Need to use global registers across RWs.
     const Register gyp  = G2;
     const Register gzp  = G3;
-    const Register offs = G4;
-    const Register disp = G5;
+    const Register disp = G4;
+    const Register offs = G5;
 
     __ mov(xptr, gxp);
     __ mov(yptr, gyp);
@@ -5569,8 +5569,8 @@
     // for (int i = xn; i >= 0; i--)
     __ bind(L_loop_i);
 
-    __ cmp_and_br_short(xpc, xp,// i >= 0
-                        Assembler::less, Assembler::pn, L_exit_loop_i);
+    __ cmp_and_brx_short(xpc, xp,// i >= 0
+                         Assembler::lessUnsigned, Assembler::pn, L_exit_loop_i);
     __ lduw(xpc, 0, rt);        // u64 x = xp[i]
     __ lduw(xpc, 4, rx);        //   ...
     __ sllx(rt, 32, rt);
@@ -5598,8 +5598,8 @@
 
     __ bind(L_loop_j);
 
-    __ cmp_and_br_short(ypc, yp,// j >= 0
-                        Assembler::less, Assembler::pn, L_exit);
+    __ cmp_and_brx_short(ypc, yp,// j >= 0
+                         Assembler::lessUnsigned, Assembler::pn, L_exit);
     __ clr(rc);                 // u64 c = 0
     __ lduw(ypc, 0, rt);        // u64 y = yp[j] (= *ypc)
     __ lduw(ypc, 4, ry);        //   ...
@@ -5615,8 +5615,8 @@
 
     __ bind(L_loop_i2);
 
-    __ cmp_and_br_short(xpc, xp,// i >= 0
-                        Assembler::less, Assembler::pn, L_exit_loop_i2);
+    __ cmp_and_brx_short(xpc, xp,// i >= 0
+                         Assembler::lessUnsigned, Assembler::pn, L_exit_loop_i2);
     __ lduw(xpc, 0, rt);        // u64 x = xp[i] (= *xpc)
     __ lduw(xpc, 4, rx);        //   ...
     __ sllx(rt, 32, rt);
--- a/src/hotspot/cpu/x86/assembler_x86.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/x86/assembler_x86.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -7449,6 +7449,27 @@
   emit_int8((unsigned char)(0xF0 & src2_enc<<4));
 }
 
+void Assembler::cmpps(XMMRegister dst, XMMRegister nds, XMMRegister src, int cop, int vector_len) {
+  assert(VM_Version::supports_avx(), "");
+  assert(!VM_Version::supports_evex(), "");
+  InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = simd_prefix_and_encode(dst, nds, src, VEX_SIMD_NONE, VEX_OPCODE_0F, &attributes);
+  emit_int8((unsigned char)0xC2);
+  emit_int8((unsigned char)(0xC0 | encode));
+  emit_int8((unsigned char)(0xF & cop));
+}
+
+void Assembler::blendvps(XMMRegister dst, XMMRegister nds, XMMRegister src1, XMMRegister src2, int vector_len) {
+  assert(VM_Version::supports_avx(), "");
+  assert(!VM_Version::supports_evex(), "");
+  InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src1->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
+  emit_int8((unsigned char)0x4A);
+  emit_int8((unsigned char)(0xC0 | encode));
+  int src2_enc = src2->encoding();
+  emit_int8((unsigned char)(0xF0 & src2_enc<<4));
+}
+
 void Assembler::vpblendd(XMMRegister dst, XMMRegister nds, XMMRegister src, int imm8, int vector_len) {
   assert(VM_Version::supports_avx2(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
--- a/src/hotspot/cpu/x86/assembler_x86.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/x86/assembler_x86.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -2114,9 +2114,11 @@
   // runtime code and native libraries.
   void vzeroupper();
 
-  // AVX support for vectorized conditional move (double). The following two instructions used only coupled.
+  // AVX support for vectorized conditional move (float/double). The following two instructions used only coupled.
   void cmppd(XMMRegister dst, XMMRegister nds, XMMRegister src, int cop, int vector_len);
   void blendvpd(XMMRegister dst, XMMRegister nds, XMMRegister src1, XMMRegister src2, int vector_len);
+  void cmpps(XMMRegister dst, XMMRegister nds, XMMRegister src, int cop, int vector_len);
+  void blendvps(XMMRegister dst, XMMRegister nds, XMMRegister src1, XMMRegister src2, int vector_len);
   void vpblendd(XMMRegister dst, XMMRegister nds, XMMRegister src, int imm8, int vector_len);
 
  protected:
--- a/src/hotspot/cpu/x86/x86.ad	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/cpu/x86/x86.ad	Mon Dec 18 10:28:43 2017 -0800
@@ -1263,6 +1263,7 @@
       if (!VM_Version::supports_cx8())
         ret_value = false;
       break;
+    case Op_CMoveVF:
     case Op_CMoveVD:
       if (UseAVX < 1 || UseAVX > 2)
         ret_value = false;
@@ -1304,6 +1305,9 @@
         if ((vlen == 32) && (VM_Version::supports_avx512bw() == false))
           ret_value = false;
         break;
+      case Op_CMoveVF:
+        if (vlen != 8)
+          ret_value  = false;
       case Op_CMoveVD:
         if (vlen != 4)
           ret_value  = false;
@@ -8170,6 +8174,22 @@
   ins_pipe( pipe_slow );
 %}
 
+instruct vcmov8F_reg(vecY dst, vecY src1, vecY src2, immI8 cop, cmpOp_vcmppd copnd) %{
+  predicate(UseAVX > 0 && UseAVX < 3 && n->as_Vector()->length() == 8);
+  match(Set dst (CMoveVF (Binary copnd cop) (Binary src1 src2)));
+  effect(TEMP dst, USE src1, USE src2);
+  format %{ "cmpps.$copnd  $dst, $src1, $src2  ! vcmovevf, cond=$cop\n\t"
+            "blendvps $dst,$src1,$src2,$dst ! vcmovevf\n\t"
+         %}
+  ins_encode %{
+    int vector_len = 1;
+    int cond = (Assembler::Condition)($copnd$$cmpcode);
+    __ cmpps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, cond, vector_len);
+    __ blendvps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, $dst$$XMMRegister, vector_len);
+  %}
+  ins_pipe( pipe_slow );
+%}
+
 instruct vcmov4D_reg(vecY dst, vecY src1, vecY src2, immI8 cop, cmpOp_vcmppd copnd) %{
   predicate(UseAVX > 0 && UseAVX < 3 && n->as_Vector()->length() == 4);
   match(Set dst (CMoveVD (Binary copnd cop) (Binary src1 src2)));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/os/posix/include/jvm_md.h	Mon Dec 18 10:28:43 2017 -0800
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  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.
+ */
+
+#ifndef _JAVASOFT_JVM_MD_H_
+#define _JAVASOFT_JVM_MD_H_
+
+/*
+ * This file is currently collecting system-specific dregs for the
+ * JNI conversion, which should be sorted out later.
+ */
+
+#include <dirent.h>             /* For DIR */
+#include <sys/param.h>          /* For MAXPATHLEN */
+#include <unistd.h>             /* For F_OK, R_OK, W_OK */
+#include <stddef.h>             /* For ptrdiff_t */
+#include <stdint.h>             /* For uintptr_t */
+
+#define JNI_ONLOAD_SYMBOLS   {"JNI_OnLoad"}
+#define JNI_ONUNLOAD_SYMBOLS {"JNI_OnUnload"}
+#define JVM_ONLOAD_SYMBOLS      {"JVM_OnLoad"}
+#define AGENT_ONLOAD_SYMBOLS    {"Agent_OnLoad"}
+#define AGENT_ONUNLOAD_SYMBOLS  {"Agent_OnUnload"}
+#define AGENT_ONATTACH_SYMBOLS  {"Agent_OnAttach"}
+
+#define JNI_LIB_PREFIX "lib"
+#ifdef __APPLE__
+#define JNI_LIB_SUFFIX ".dylib"
+#define VERSIONED_JNI_LIB_NAME(NAME, VERSION) JNI_LIB_PREFIX NAME "." VERSION JNI_LIB_SUFFIX
+#else
+#define JNI_LIB_SUFFIX ".so"
+#define VERSIONED_JNI_LIB_NAME(NAME, VERSION) JNI_LIB_PREFIX NAME JNI_LIB_SUFFIX "." VERSION
+#endif
+#define JNI_LIB_NAME(NAME) JNI_LIB_PREFIX NAME JNI_LIB_SUFFIX
+
+#if defined(AIX) || defined(SOLARIS)
+#define JVM_MAXPATHLEN MAXPATHLEN
+#else
+// Hack: MAXPATHLEN is 4095 on some Linux and 4096 on others. This may
+//       cause problems if JVM and the rest of JDK are built on different
+//       Linux releases. Here we define JVM_MAXPATHLEN to be MAXPATHLEN + 1,
+//       so buffers declared in VM are always >= 4096.
+#define JVM_MAXPATHLEN MAXPATHLEN + 1
+#endif
+
+#define JVM_R_OK    R_OK
+#define JVM_W_OK    W_OK
+#define JVM_X_OK    X_OK
+#define JVM_F_OK    F_OK
+
+/*
+ * File I/O
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <signal.h>
+
+/* Signals */
+
+#include <sys/socket.h>   // for socklen_t
+
+#define JVM_SIGINT     SIGINT
+#define JVM_SIGTERM    SIGTERM
+
+#define BREAK_SIGNAL     SIGQUIT           /* Thread dumping support.    */
+#ifdef SOLARIS
+#define ASYNC_SIGNAL     SIGJVM2           /* Event-based suspend/resume support */
+#endif // SOLARIS
+#define SHUTDOWN1_SIGNAL SIGHUP            /* Shutdown Hooks support.    */
+#define SHUTDOWN2_SIGNAL SIGINT
+#define SHUTDOWN3_SIGNAL SIGTERM
+
+/* With 1.4.1 libjsig added versioning: used in os_solaris.cpp and jsig.c */
+#define JSIG_VERSION_1_4_1   0x30140100
+
+#endif /* !_JAVASOFT_JVM_MD_H_ */
--- a/src/hotspot/os/posix/os_posix.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/os/posix/os_posix.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -243,8 +243,9 @@
   assert(fd != -1, "File descriptor is not valid");
 
   // allocate space for the file
-  if (util_posix_fallocate(fd, 0, (off_t)size) != 0) {
-    vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory."));
+  int ret = util_posix_fallocate(fd, 0, (off_t)size);
+  if (ret != 0) {
+    vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory. error(%d)", ret));
     return NULL;
   }
 
@@ -256,12 +257,13 @@
   char* addr = (char*)mmap(base, size, prot, flags, fd, 0);
 
   if (addr == MAP_FAILED) {
+    warning("Failed mmap to file. (%s)", os::strerror(errno));
     return NULL;
   }
   if (base != NULL && addr != base) {
     if (!os::release_memory(addr, size)) {
       warning("Could not release memory on unsuccessful file mapping");
-     }
+    }
     return NULL;
   }
   return addr;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/os/windows/include/jvm_md.h	Mon Dec 18 10:28:43 2017 -0800
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 1997, 2008, 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.
+ */
+
+#ifndef _JAVASOFT_JVM_MD_H_
+#define _JAVASOFT_JVM_MD_H_
+
+/*
+ * This file is currently collecting system-specific dregs for the
+ * JNI conversion, which should be sorted out later.
+ */
+
+#include <windows.h>
+#include <windef.h>
+#include <winbase.h>
+
+#include "jni.h"
+
+typedef int socklen_t;
+
+#define JNI_ONLOAD_SYMBOLS   {"_JNI_OnLoad@8", "JNI_OnLoad"}
+#define JNI_ONUNLOAD_SYMBOLS {"_JNI_OnUnload@8", "JNI_OnUnload"}
+#define JVM_ONLOAD_SYMBOLS      {"_JVM_OnLoad@12", "JVM_OnLoad"}
+#define AGENT_ONLOAD_SYMBOLS    {"_Agent_OnLoad@12", "Agent_OnLoad"}
+#define AGENT_ONUNLOAD_SYMBOLS  {"_Agent_OnUnload@4", "Agent_OnUnload"}
+#define AGENT_ONATTACH_SYMBOLS  {"_Agent_OnAttach@12", "Agent_OnAttach"}
+
+#define JNI_LIB_PREFIX ""
+#define JNI_LIB_SUFFIX ".dll"
+
+struct dirent {
+    char d_name[MAX_PATH];
+};
+
+typedef struct {
+    struct dirent dirent;
+    char *path;
+    HANDLE handle;
+    WIN32_FIND_DATA find_data;
+} DIR;
+
+#include <stddef.h>  /* For uintptr_t */
+#include <stdlib.h>
+
+#define JVM_MAXPATHLEN _MAX_PATH
+
+#define JVM_R_OK    4
+#define JVM_W_OK    2
+#define JVM_X_OK    1
+#define JVM_F_OK    0
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT void * JNICALL
+JVM_GetThreadInterruptEvent();
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif /* __cplusplus */
+
+/*
+ * File I/O
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <signal.h>
+
+/* Signals */
+
+#define JVM_SIGINT     SIGINT
+#define JVM_SIGTERM    SIGTERM
+
+#define SHUTDOWN1_SIGNAL SIGINT            /* Shutdown Hooks support. */
+#define SHUTDOWN2_SIGNAL SIGTERM
+
+#endif /* !_JAVASOFT_JVM_MD_H_ */
--- a/src/hotspot/share/adlc/formssel.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/adlc/formssel.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -4164,7 +4164,7 @@
     "AddVB","AddVS","AddVI","AddVL","AddVF","AddVD",
     "SubVB","SubVS","SubVI","SubVL","SubVF","SubVD",
     "MulVS","MulVI","MulVL","MulVF","MulVD",
-    "CMoveVD",
+    "CMoveVD", "CMoveVF",
     "DivVF","DivVD",
     "AbsVF","AbsVD",
     "NegVF","NegVD",
--- a/src/hotspot/share/c1/c1_GraphBuilder.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -1439,6 +1439,9 @@
   }
 
   if (needs_check) {
+    // Not a trivial method because C2 can do better with inlined check.
+    compilation()->set_would_profile(true);
+
     // Perform the registration of finalizable objects.
     ValueStack* state_before = copy_state_for_exception();
     load_local(objectType, 0);
@@ -3556,6 +3559,9 @@
 }
 
 bool GraphBuilder::try_inline_intrinsics(ciMethod* callee, bool ignore_return) {
+  // Not a trivial method because C2 may do intrinsics better.
+  compilation()->set_would_profile(true);
+
   // For calling is_intrinsic_available we need to transition to
   // the '_thread_in_vm' state because is_intrinsic_available()
   // accesses critical VM-internal data.
--- a/src/hotspot/share/ci/ciEnv.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/ci/ciEnv.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -899,64 +899,18 @@
 void ciEnv::validate_compile_task_dependencies(ciMethod* target) {
   if (failing())  return;  // no need for further checks
 
-  // First, check non-klass dependencies as we might return early and
-  // not check klass dependencies if the system dictionary
-  // modification counter hasn't changed (see below).
-  for (Dependencies::DepStream deps(dependencies()); deps.next(); ) {
-    if (deps.is_klass_type())  continue;  // skip klass dependencies
-    Klass* witness = deps.check_dependency();
-    if (witness != NULL) {
-      if (deps.type() == Dependencies::call_site_target_value) {
-        _inc_decompile_count_on_failure = false;
-        record_failure("call site target change");
-      } else {
-        record_failure("invalid non-klass dependency");
-      }
-      return;
+  bool counter_changed = system_dictionary_modification_counter_changed();
+  Dependencies::DepType result = dependencies()->validate_dependencies(_task, counter_changed);
+  if (result != Dependencies::end_marker) {
+    if (result == Dependencies::call_site_target_value) {
+      _inc_decompile_count_on_failure = false;
+      record_failure("call site target change");
+    } else if (Dependencies::is_klass_type(result)) {
+      record_failure("invalid non-klass dependency");
+    } else {
+      record_failure("concurrent class loading");
     }
   }
-
-  // Klass dependencies must be checked when the system dictionary
-  // changes.  If logging is enabled all violated dependences will be
-  // recorded in the log.  In debug mode check dependencies even if
-  // the system dictionary hasn't changed to verify that no invalid
-  // dependencies were inserted.  Any violated dependences in this
-  // case are dumped to the tty.
-  bool counter_changed = system_dictionary_modification_counter_changed();
-
-  bool verify_deps = trueInDebug;
-  if (!counter_changed && !verify_deps)  return;
-
-  int klass_violations = 0;
-  for (Dependencies::DepStream deps(dependencies()); deps.next(); ) {
-    if (!deps.is_klass_type())  continue;  // skip non-klass dependencies
-    Klass* witness = deps.check_dependency();
-    if (witness != NULL) {
-      klass_violations++;
-      if (!counter_changed) {
-        // Dependence failed but counter didn't change.  Log a message
-        // describing what failed and allow the assert at the end to
-        // trigger.
-        deps.print_dependency(witness);
-      } else if (xtty == NULL) {
-        // If we're not logging then a single violation is sufficient,
-        // otherwise we want to log all the dependences which were
-        // violated.
-        break;
-      }
-    }
-  }
-
-  if (klass_violations != 0) {
-#ifdef ASSERT
-    if (!counter_changed && !PrintCompilation) {
-      // Print out the compile task that failed
-      _task->print_tty();
-    }
-#endif
-    assert(counter_changed, "failed dependencies, but counter didn't change");
-    record_failure("concurrent class loading");
-  }
 }
 
 // ------------------------------------------------------------------
--- a/src/hotspot/share/code/dependencies.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/code/dependencies.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -30,6 +30,8 @@
 #include "classfile/javaClasses.inline.hpp"
 #include "code/dependencies.hpp"
 #include "compiler/compileLog.hpp"
+#include "compiler/compileBroker.hpp"
+#include "compiler/compileTask.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/oop.inline.hpp"
 #include "oops/objArrayKlass.hpp"
@@ -620,6 +622,72 @@
   guarantee(FIRST_TYPE <= dept && dept < TYPE_LIMIT, "invalid dependency type: %d", (int) dept);
 }
 
+Dependencies::DepType Dependencies::validate_dependencies(CompileTask* task, bool counter_changed, char** failure_detail) {
+  // First, check non-klass dependencies as we might return early and
+  // not check klass dependencies if the system dictionary
+  // modification counter hasn't changed (see below).
+  for (Dependencies::DepStream deps(this); deps.next(); ) {
+    if (deps.is_klass_type())  continue;  // skip klass dependencies
+    Klass* witness = deps.check_dependency();
+    if (witness != NULL) {
+      return deps.type();
+    }
+  }
+
+  // Klass dependencies must be checked when the system dictionary
+  // changes.  If logging is enabled all violated dependences will be
+  // recorded in the log.  In debug mode check dependencies even if
+  // the system dictionary hasn't changed to verify that no invalid
+  // dependencies were inserted.  Any violated dependences in this
+  // case are dumped to the tty.
+  if (!counter_changed && !trueInDebug) {
+    return end_marker;
+  }
+
+  int klass_violations = 0;
+  DepType result = end_marker;
+  for (Dependencies::DepStream deps(this); deps.next(); ) {
+    if (!deps.is_klass_type())  continue;  // skip non-klass dependencies
+    Klass* witness = deps.check_dependency();
+    if (witness != NULL) {
+      if (klass_violations == 0) {
+        result = deps.type();
+        if (failure_detail != NULL && klass_violations == 0) {
+          // Use a fixed size buffer to prevent the string stream from
+          // resizing in the context of an inner resource mark.
+          char* buffer = NEW_RESOURCE_ARRAY(char, O_BUFLEN);
+          stringStream st(buffer, O_BUFLEN);
+          deps.print_dependency(witness, true, &st);
+          *failure_detail = st.as_string();
+        }
+      }
+      klass_violations++;
+      if (!counter_changed) {
+        // Dependence failed but counter didn't change.  Log a message
+        // describing what failed and allow the assert at the end to
+        // trigger.
+        deps.print_dependency(witness);
+      } else if (xtty == NULL) {
+        // If we're not logging then a single violation is sufficient,
+        // otherwise we want to log all the dependences which were
+        // violated.
+        break;
+      }
+    }
+  }
+
+  if (klass_violations != 0) {
+#ifdef ASSERT
+    if (task != NULL && !counter_changed && !PrintCompilation) {
+      // Print out the compile task that failed
+      task->print_tty();
+    }
+#endif
+    assert(counter_changed, "failed dependencies, but counter didn't change");
+  }
+  return result;
+}
+
 // for the sake of the compiler log, print out current dependencies:
 void Dependencies::log_all_dependencies() {
   if (log() == NULL)  return;
--- a/src/hotspot/share/code/dependencies.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/code/dependencies.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -457,6 +457,8 @@
 
   void copy_to(nmethod* nm);
 
+  DepType validate_dependencies(CompileTask* task, bool counter_changed, char** failure_detail = NULL);
+
   void log_all_dependencies();
 
   void log_dependency(DepType dept, GrowableArray<ciBaseObject*>* args) {
--- a/src/hotspot/share/gc/g1/g1Arguments.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/gc/g1/g1Arguments.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -98,9 +98,9 @@
   // Enable loop strip mining to offer better pause time guarantees
   if (FLAG_IS_DEFAULT(UseCountedLoopSafepoints)) {
     FLAG_SET_DEFAULT(UseCountedLoopSafepoints, true);
-  }
-  if (UseCountedLoopSafepoints && FLAG_IS_DEFAULT(LoopStripMiningIter)) {
-    FLAG_SET_DEFAULT(LoopStripMiningIter, 1000);
+    if (FLAG_IS_DEFAULT(LoopStripMiningIter)) {
+      FLAG_SET_DEFAULT(LoopStripMiningIter, 1000);
+    }
   }
 #endif
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/include/jmm.h	Mon Dec 18 10:28:43 2017 -0800
@@ -0,0 +1,345 @@
+/*
+ * Copyright (c) 2003, 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.  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.
+ */
+
+#ifndef _JAVA_JMM_H_
+#define _JAVA_JMM_H_
+
+/*
+ * This is a private interface used by JDK for JVM monitoring
+ * and management.
+ *
+ * Bump the version number when either of the following happens:
+ *
+ * 1. There is a change in functions in JmmInterface.
+ *
+ * 2. There is a change in the contract between VM and Java classes.
+ */
+
+#include "jni.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+  JMM_VERSION_1   = 0x20010000,
+  JMM_VERSION_1_0 = 0x20010000,
+  JMM_VERSION_1_1 = 0x20010100, // JDK 6
+  JMM_VERSION_1_2 = 0x20010200, // JDK 7
+  JMM_VERSION_1_2_1 = 0x20010201, // JDK 7 GA
+  JMM_VERSION_1_2_2 = 0x20010202,
+  JMM_VERSION_2  = 0x20020000,  // JDK 10
+  JMM_VERSION     = 0x20020000
+};
+
+typedef struct {
+  unsigned int isLowMemoryDetectionSupported : 1;
+  unsigned int isCompilationTimeMonitoringSupported : 1;
+  unsigned int isThreadContentionMonitoringSupported : 1;
+  unsigned int isCurrentThreadCpuTimeSupported : 1;
+  unsigned int isOtherThreadCpuTimeSupported : 1;
+  unsigned int isObjectMonitorUsageSupported : 1;
+  unsigned int isSynchronizerUsageSupported : 1;
+  unsigned int isThreadAllocatedMemorySupported : 1;
+  unsigned int isRemoteDiagnosticCommandsSupported : 1;
+  unsigned int : 22;
+} jmmOptionalSupport;
+
+typedef enum {
+  JMM_CLASS_LOADED_COUNT             = 1,    /* Total number of loaded classes */
+  JMM_CLASS_UNLOADED_COUNT           = 2,    /* Total number of unloaded classes */
+  JMM_THREAD_TOTAL_COUNT             = 3,    /* Total number of threads that have been started */
+  JMM_THREAD_LIVE_COUNT              = 4,    /* Current number of live threads */
+  JMM_THREAD_PEAK_COUNT              = 5,    /* Peak number of live threads */
+  JMM_THREAD_DAEMON_COUNT            = 6,    /* Current number of daemon threads */
+  JMM_JVM_INIT_DONE_TIME_MS          = 7,    /* Time when the JVM finished initialization */
+  JMM_COMPILE_TOTAL_TIME_MS          = 8,    /* Total accumulated time spent in compilation */
+  JMM_GC_TIME_MS                     = 9,    /* Total accumulated time spent in collection */
+  JMM_GC_COUNT                       = 10,   /* Total number of collections */
+  JMM_JVM_UPTIME_MS                  = 11,   /* The JVM uptime in milliseconds */
+
+  JMM_INTERNAL_ATTRIBUTE_INDEX       = 100,
+  JMM_CLASS_LOADED_BYTES             = 101,  /* Number of bytes loaded instance classes */
+  JMM_CLASS_UNLOADED_BYTES           = 102,  /* Number of bytes unloaded instance classes */
+  JMM_TOTAL_CLASSLOAD_TIME_MS        = 103,  /* Accumulated VM class loader time (TraceClassLoadingTime) */
+  JMM_VM_GLOBAL_COUNT                = 104,  /* Number of VM internal flags */
+  JMM_SAFEPOINT_COUNT                = 105,  /* Total number of safepoints */
+  JMM_TOTAL_SAFEPOINTSYNC_TIME_MS    = 106,  /* Accumulated time spent getting to safepoints */
+  JMM_TOTAL_STOPPED_TIME_MS          = 107,  /* Accumulated time spent at safepoints */
+  JMM_TOTAL_APP_TIME_MS              = 108,  /* Accumulated time spent in Java application */
+  JMM_VM_THREAD_COUNT                = 109,  /* Current number of VM internal threads */
+  JMM_CLASS_INIT_TOTAL_COUNT         = 110,  /* Number of classes for which initializers were run */
+  JMM_CLASS_INIT_TOTAL_TIME_MS       = 111,  /* Accumulated time spent in class initializers */
+  JMM_METHOD_DATA_SIZE_BYTES         = 112,  /* Size of method data in memory */
+  JMM_CLASS_VERIFY_TOTAL_TIME_MS     = 113,  /* Accumulated time spent in class verifier */
+  JMM_SHARED_CLASS_LOADED_COUNT      = 114,  /* Number of shared classes loaded */
+  JMM_SHARED_CLASS_UNLOADED_COUNT    = 115,  /* Number of shared classes unloaded */
+  JMM_SHARED_CLASS_LOADED_BYTES      = 116,  /* Number of bytes loaded shared classes */
+  JMM_SHARED_CLASS_UNLOADED_BYTES    = 117,  /* Number of bytes unloaded shared classes */
+
+  JMM_OS_ATTRIBUTE_INDEX             = 200,
+  JMM_OS_PROCESS_ID                  = 201,  /* Process id of the JVM */
+  JMM_OS_MEM_TOTAL_PHYSICAL_BYTES    = 202,  /* Physical memory size */
+
+  JMM_GC_EXT_ATTRIBUTE_INFO_SIZE     = 401   /* the size of the GC specific attributes for a given GC memory manager */
+} jmmLongAttribute;
+
+typedef enum {
+  JMM_VERBOSE_GC                     = 21,
+  JMM_VERBOSE_CLASS                  = 22,
+  JMM_THREAD_CONTENTION_MONITORING   = 23,
+  JMM_THREAD_CPU_TIME                = 24,
+  JMM_THREAD_ALLOCATED_MEMORY        = 25
+} jmmBoolAttribute;
+
+
+enum {
+  JMM_THREAD_STATE_FLAG_SUSPENDED = 0x00100000,
+  JMM_THREAD_STATE_FLAG_NATIVE    = 0x00400000
+};
+
+#define JMM_THREAD_STATE_FLAG_MASK  0xFFF00000
+
+typedef enum {
+  JMM_STAT_PEAK_THREAD_COUNT         = 801,
+  JMM_STAT_THREAD_CONTENTION_COUNT   = 802,
+  JMM_STAT_THREAD_CONTENTION_TIME    = 803,
+  JMM_STAT_THREAD_CONTENTION_STAT    = 804,
+  JMM_STAT_PEAK_POOL_USAGE           = 805,
+  JMM_STAT_GC_STAT                   = 806
+} jmmStatisticType;
+
+typedef enum {
+  JMM_USAGE_THRESHOLD_HIGH            = 901,
+  JMM_USAGE_THRESHOLD_LOW             = 902,
+  JMM_COLLECTION_USAGE_THRESHOLD_HIGH = 903,
+  JMM_COLLECTION_USAGE_THRESHOLD_LOW  = 904
+} jmmThresholdType;
+
+/* Should match what is allowed in globals.hpp */
+typedef enum {
+  JMM_VMGLOBAL_TYPE_UNKNOWN  = 0,
+  JMM_VMGLOBAL_TYPE_JBOOLEAN = 1,
+  JMM_VMGLOBAL_TYPE_JSTRING  = 2,
+  JMM_VMGLOBAL_TYPE_JLONG    = 3,
+  JMM_VMGLOBAL_TYPE_JDOUBLE  = 4
+} jmmVMGlobalType;
+
+typedef enum {
+  JMM_VMGLOBAL_ORIGIN_DEFAULT      = 1,   /* Default value */
+  JMM_VMGLOBAL_ORIGIN_COMMAND_LINE = 2,   /* Set at command line (or JNI invocation) */
+  JMM_VMGLOBAL_ORIGIN_MANAGEMENT   = 3,   /* Set via management interface */
+  JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR  = 4,   /* Set via environment variables */
+  JMM_VMGLOBAL_ORIGIN_CONFIG_FILE  = 5,   /* Set via config file (such as .hotspotrc) */
+  JMM_VMGLOBAL_ORIGIN_ERGONOMIC    = 6,   /* Set via ergonomic */
+  JMM_VMGLOBAL_ORIGIN_ATTACH_ON_DEMAND = 7,   /* Set via attach */
+  JMM_VMGLOBAL_ORIGIN_OTHER        = 99   /* Set via some other mechanism */
+} jmmVMGlobalOrigin;
+
+typedef struct {
+  jstring           name;
+  jvalue            value;
+  jmmVMGlobalType   type;           /* Data type */
+  jmmVMGlobalOrigin origin;         /* Default or non-default value */
+  unsigned int      writeable : 1;  /* dynamically writeable */
+  unsigned int      external  : 1;  /* external supported interface */
+  unsigned int      reserved  : 30;
+  void *reserved1;
+  void *reserved2;
+} jmmVMGlobal;
+
+typedef struct {
+  const char*  name;
+  char         type;
+  const char*  description;
+} jmmExtAttributeInfo;
+
+/* Caller has to set the following fields before calling GetLastGCStat
+ *   o usage_before_gc               - array of MemoryUsage objects
+ *   o usage_after_gc                - array of MemoryUsage objects
+ *   o gc_ext_attribute_values_size - size of gc_ext_atttribute_values array
+ *   o gc_ext_attribtue_values      - array of jvalues
+ */
+typedef struct {
+  jlong        gc_index;                       /* Index of the collections */
+  jlong        start_time;                     /* Start time of the GC */
+  jlong        end_time;                       /* End time of the GC */
+  jobjectArray usage_before_gc;                /* Memory usage array before GC */
+  jobjectArray usage_after_gc;                 /* Memory usage array after GC */
+  jint         gc_ext_attribute_values_size;   /* set by the caller of GetGCStat */
+  jvalue*      gc_ext_attribute_values;        /* Array of jvalue for GC extension attributes */
+  jint         num_gc_ext_attributes;          /* number of GC extension attribute values s are filled */
+                                               /* -1 indicates gc_ext_attribute_values is not big enough */
+} jmmGCStat;
+
+typedef struct {
+  const char* name;                /* Name of the diagnostic command */
+  const char* description;         /* Short description */
+  const char* impact;              /* Impact on the JVM */
+  const char* permission_class;    /* Class name of the required permission if any */
+  const char* permission_name;     /* Permission name of the required permission if any */
+  const char* permission_action;   /* Action name of the required permission if any*/
+  int         num_arguments;       /* Number of supported options or arguments */
+  jboolean    enabled;             /* True if the diagnostic command can be invoked, false otherwise*/
+} dcmdInfo;
+
+typedef struct {
+  const char* name;                /* Option/Argument name*/
+  const char* description;         /* Short description */
+  const char* type;                /* Type: STRING, BOOLEAN, etc. */
+  const char* default_string;      /* Default value in a parsable string */
+  jboolean    mandatory;           /* True if the option/argument is mandatory */
+  jboolean    option;              /* True if it is an option, false if it is an argument */
+                                   /* (see diagnosticFramework.hpp for option/argument definitions) */
+  jboolean    multiple;            /* True is the option can be specified several time */
+  int         position;            /* Expected position for this argument (this field is */
+                                   /* meaningless for options) */
+} dcmdArgInfo;
+
+typedef struct jmmInterface_1_ {
+  void*        reserved1;
+  void*        reserved2;
+
+  jint         (JNICALL *GetVersion)             (JNIEnv *env);
+
+  jint         (JNICALL *GetOptionalSupport)     (JNIEnv *env,
+                                                  jmmOptionalSupport* support_ptr);
+
+  jint         (JNICALL *GetThreadInfo)          (JNIEnv *env,
+                                                  jlongArray ids,
+                                                  jint maxDepth,
+                                                  jobjectArray infoArray);
+
+  jobjectArray (JNICALL *GetMemoryPools)         (JNIEnv* env, jobject mgr);
+
+  jobjectArray (JNICALL *GetMemoryManagers)      (JNIEnv* env, jobject pool);
+
+  jobject      (JNICALL *GetMemoryPoolUsage)     (JNIEnv* env, jobject pool);
+  jobject      (JNICALL *GetPeakMemoryPoolUsage) (JNIEnv* env, jobject pool);
+
+  void         (JNICALL *GetThreadAllocatedMemory)
+                                                 (JNIEnv *env,
+                                                  jlongArray ids,
+                                                  jlongArray sizeArray);
+
+  jobject      (JNICALL *GetMemoryUsage)         (JNIEnv* env, jboolean heap);
+
+  jlong        (JNICALL *GetLongAttribute)       (JNIEnv *env, jobject obj, jmmLongAttribute att);
+  jboolean     (JNICALL *GetBoolAttribute)       (JNIEnv *env, jmmBoolAttribute att);
+  jboolean     (JNICALL *SetBoolAttribute)       (JNIEnv *env, jmmBoolAttribute att, jboolean flag);
+
+  jint         (JNICALL *GetLongAttributes)      (JNIEnv *env,
+                                                  jobject obj,
+                                                  jmmLongAttribute* atts,
+                                                  jint count,
+                                                  jlong* result);
+
+  jobjectArray (JNICALL *FindCircularBlockedThreads) (JNIEnv *env);
+
+  // Not used in JDK 6 or JDK 7
+  jlong        (JNICALL *GetThreadCpuTime)       (JNIEnv *env, jlong thread_id);
+
+  jobjectArray (JNICALL *GetVMGlobalNames)       (JNIEnv *env);
+  jint         (JNICALL *GetVMGlobals)           (JNIEnv *env,
+                                                  jobjectArray names,
+                                                  jmmVMGlobal *globals,
+                                                  jint count);
+
+  jint         (JNICALL *GetInternalThreadTimes) (JNIEnv *env,
+                                                  jobjectArray names,
+                                                  jlongArray times);
+
+  jboolean     (JNICALL *ResetStatistic)         (JNIEnv *env,
+                                                  jvalue obj,
+                                                  jmmStatisticType type);
+
+  void         (JNICALL *SetPoolSensor)          (JNIEnv *env,
+                                                  jobject pool,
+                                                  jmmThresholdType type,
+                                                  jobject sensor);
+
+  jlong        (JNICALL *SetPoolThreshold)       (JNIEnv *env,
+                                                  jobject pool,
+                                                  jmmThresholdType type,
+                                                  jlong threshold);
+  jobject      (JNICALL *GetPoolCollectionUsage) (JNIEnv* env, jobject pool);
+
+  jint         (JNICALL *GetGCExtAttributeInfo)  (JNIEnv *env,
+                                                  jobject mgr,
+                                                  jmmExtAttributeInfo *ext_info,
+                                                  jint count);
+  void         (JNICALL *GetLastGCStat)          (JNIEnv *env,
+                                                  jobject mgr,
+                                                  jmmGCStat *gc_stat);
+
+  jlong        (JNICALL *GetThreadCpuTimeWithKind)
+                                                 (JNIEnv *env,
+                                                  jlong thread_id,
+                                                  jboolean user_sys_cpu_time);
+  void         (JNICALL *GetThreadCpuTimesWithKind)
+                                                 (JNIEnv *env,
+                                                  jlongArray ids,
+                                                  jlongArray timeArray,
+                                                  jboolean user_sys_cpu_time);
+
+  jint         (JNICALL *DumpHeap0)              (JNIEnv *env,
+                                                  jstring outputfile,
+                                                  jboolean live);
+  jobjectArray (JNICALL *FindDeadlocks)          (JNIEnv *env,
+                                                  jboolean object_monitors_only);
+  void         (JNICALL *SetVMGlobal)            (JNIEnv *env,
+                                                  jstring flag_name,
+                                                  jvalue  new_value);
+  void*        reserved6;
+  jobjectArray (JNICALL *DumpThreads)            (JNIEnv *env,
+                                                  jlongArray ids,
+                                                  jboolean lockedMonitors,
+                                                  jboolean lockedSynchronizers,
+                                                  jint maxDepth);
+  void         (JNICALL *SetGCNotificationEnabled) (JNIEnv *env,
+                                                    jobject mgr,
+                                                    jboolean enabled);
+  jobjectArray (JNICALL *GetDiagnosticCommands)  (JNIEnv *env);
+  void         (JNICALL *GetDiagnosticCommandInfo)
+                                                 (JNIEnv *env,
+                                                  jobjectArray cmds,
+                                                  dcmdInfo *infoArray);
+  void         (JNICALL *GetDiagnosticCommandArgumentsInfo)
+                                                 (JNIEnv *env,
+                                                  jstring commandName,
+                                                  dcmdArgInfo *infoArray);
+  jstring      (JNICALL *ExecuteDiagnosticCommand)
+                                                 (JNIEnv *env,
+                                                  jstring command);
+  void         (JNICALL *SetDiagnosticFrameworkNotificationEnabled)
+                                                 (JNIEnv *env,
+                                                  jboolean enabled);
+} JmmInterface;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif /* __cplusplus */
+
+#endif /* !_JAVA_JMM_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/include/jvm.h	Mon Dec 18 10:28:43 2017 -0800
@@ -0,0 +1,1328 @@
+/*
+ * Copyright (c) 1997, 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.  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.
+ */
+
+#ifndef _JAVASOFT_JVM_H_
+#define _JAVASOFT_JVM_H_
+
+#include <sys/stat.h>
+
+#include "jni.h"
+#include "jvm_md.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This file contains additional functions exported from the VM.
+ * These functions are complementary to the standard JNI support.
+ * There are three parts to this file:
+ *
+ * First, this file contains the VM-related functions needed by native
+ * libraries in the standard Java API. For example, the java.lang.Object
+ * class needs VM-level functions that wait for and notify monitors.
+ *
+ * Second, this file contains the functions and constant definitions
+ * needed by the byte code verifier and class file format checker.
+ * These functions allow the verifier and format checker to be written
+ * in a VM-independent way.
+ *
+ * Third, this file contains various I/O and network operations needed
+ * by the standard Java I/O and network APIs.
+ */
+
+/*
+ * Bump the version number when either of the following happens:
+ *
+ * 1. There is a change in JVM_* functions.
+ *
+ * 2. There is a change in the contract between VM and Java classes.
+ *    For example, if the VM relies on a new private field in Thread
+ *    class.
+ */
+
+#define JVM_INTERFACE_VERSION 5
+
+JNIEXPORT jint JNICALL
+JVM_GetInterfaceVersion(void);
+
+/*************************************************************************
+ PART 1: Functions for Native Libraries
+ ************************************************************************/
+/*
+ * java.lang.Object
+ */
+JNIEXPORT jint JNICALL
+JVM_IHashCode(JNIEnv *env, jobject obj);
+
+JNIEXPORT void JNICALL
+JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms);
+
+JNIEXPORT void JNICALL
+JVM_MonitorNotify(JNIEnv *env, jobject obj);
+
+JNIEXPORT void JNICALL
+JVM_MonitorNotifyAll(JNIEnv *env, jobject obj);
+
+JNIEXPORT jobject JNICALL
+JVM_Clone(JNIEnv *env, jobject obj);
+
+/*
+ * java.lang.String
+ */
+JNIEXPORT jstring JNICALL
+JVM_InternString(JNIEnv *env, jstring str);
+
+/*
+ * java.lang.System
+ */
+JNIEXPORT jlong JNICALL
+JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored);
+
+JNIEXPORT jlong JNICALL
+JVM_NanoTime(JNIEnv *env, jclass ignored);
+
+JNIEXPORT jlong JNICALL
+JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs);
+
+JNIEXPORT void JNICALL
+JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
+              jobject dst, jint dst_pos, jint length);
+
+JNIEXPORT jobject JNICALL
+JVM_InitProperties(JNIEnv *env, jobject p);
+
+
+/*
+ * java.lang.Runtime
+ */
+JNIEXPORT void JNICALL
+JVM_Halt(jint code);
+
+JNIEXPORT void JNICALL
+JVM_GC(void);
+
+/* Returns the number of real-time milliseconds that have elapsed since the
+ * least-recently-inspected heap object was last inspected by the garbage
+ * collector.
+ *
+ * For simple stop-the-world collectors this value is just the time
+ * since the most recent collection.  For generational collectors it is the
+ * time since the oldest generation was most recently collected.  Other
+ * collectors are free to return a pessimistic estimate of the elapsed time, or
+ * simply the time since the last full collection was performed.
+ *
+ * Note that in the presence of reference objects, a given object that is no
+ * longer strongly reachable may have to be inspected multiple times before it
+ * can be reclaimed.
+ */
+JNIEXPORT jlong JNICALL
+JVM_MaxObjectInspectionAge(void);
+
+JNIEXPORT jlong JNICALL
+JVM_TotalMemory(void);
+
+JNIEXPORT jlong JNICALL
+JVM_FreeMemory(void);
+
+JNIEXPORT jlong JNICALL
+JVM_MaxMemory(void);
+
+JNIEXPORT jint JNICALL
+JVM_ActiveProcessorCount(void);
+
+JNIEXPORT void * JNICALL
+JVM_LoadLibrary(const char *name);
+
+JNIEXPORT void JNICALL
+JVM_UnloadLibrary(void * handle);
+
+JNIEXPORT void * JNICALL
+JVM_FindLibraryEntry(void *handle, const char *name);
+
+JNIEXPORT jboolean JNICALL
+JVM_IsSupportedJNIVersion(jint version);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetVmArguments(JNIEnv *env);
+
+
+/*
+ * java.lang.Throwable
+ */
+JNIEXPORT void JNICALL
+JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
+
+/*
+ * java.lang.StackTraceElement
+ */
+JNIEXPORT void JNICALL
+JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable);
+
+JNIEXPORT void JNICALL
+JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo);
+
+/*
+ * java.lang.StackWalker
+ */
+enum {
+  JVM_STACKWALK_FILL_CLASS_REFS_ONLY       = 0x2,
+  JVM_STACKWALK_GET_CALLER_CLASS           = 0x04,
+  JVM_STACKWALK_SHOW_HIDDEN_FRAMES         = 0x20,
+  JVM_STACKWALK_FILL_LIVE_STACK_FRAMES     = 0x100
+};
+
+JNIEXPORT jobject JNICALL
+JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jlong mode,
+                  jint skip_frames, jint frame_count, jint start_index,
+                  jobjectArray frames);
+
+JNIEXPORT jint JNICALL
+JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jlong mode, jlong anchor,
+                  jint frame_count, jint start_index,
+                  jobjectArray frames);
+
+/*
+ * java.lang.Thread
+ */
+JNIEXPORT void JNICALL
+JVM_StartThread(JNIEnv *env, jobject thread);
+
+JNIEXPORT void JNICALL
+JVM_StopThread(JNIEnv *env, jobject thread, jobject exception);
+
+JNIEXPORT jboolean JNICALL
+JVM_IsThreadAlive(JNIEnv *env, jobject thread);
+
+JNIEXPORT void JNICALL
+JVM_SuspendThread(JNIEnv *env, jobject thread);
+
+JNIEXPORT void JNICALL
+JVM_ResumeThread(JNIEnv *env, jobject thread);
+
+JNIEXPORT void JNICALL
+JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
+
+JNIEXPORT void JNICALL
+JVM_Yield(JNIEnv *env, jclass threadClass);
+
+JNIEXPORT void JNICALL
+JVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis);
+
+JNIEXPORT jobject JNICALL
+JVM_CurrentThread(JNIEnv *env, jclass threadClass);
+
+JNIEXPORT jint JNICALL
+JVM_CountStackFrames(JNIEnv *env, jobject thread);
+
+JNIEXPORT void JNICALL
+JVM_Interrupt(JNIEnv *env, jobject thread);
+
+JNIEXPORT jboolean JNICALL
+JVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted);
+
+JNIEXPORT jboolean JNICALL
+JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj);
+
+JNIEXPORT void JNICALL
+JVM_DumpAllStacks(JNIEnv *env, jclass unused);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetAllThreads(JNIEnv *env, jclass dummy);
+
+JNIEXPORT void JNICALL
+JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name);
+
+/* getStackTrace() and getAllStackTraces() method */
+JNIEXPORT jobjectArray JNICALL
+JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
+
+/*
+ * java.lang.SecurityManager
+ */
+JNIEXPORT jobjectArray JNICALL
+JVM_GetClassContext(JNIEnv *env);
+
+/*
+ * java.lang.Package
+ */
+JNIEXPORT jstring JNICALL
+JVM_GetSystemPackage(JNIEnv *env, jstring name);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetSystemPackages(JNIEnv *env);
+
+/*
+ * java.lang.ref.Reference
+ */
+JNIEXPORT jobject JNICALL
+JVM_GetAndClearReferencePendingList(JNIEnv *env);
+
+JNIEXPORT jboolean JNICALL
+JVM_HasReferencePendingList(JNIEnv *env);
+
+JNIEXPORT void JNICALL
+JVM_WaitForReferencePendingList(JNIEnv *env);
+
+/*
+ * java.io.ObjectInputStream
+ */
+JNIEXPORT jobject JNICALL
+JVM_LatestUserDefinedLoader(JNIEnv *env);
+
+/*
+ * java.lang.reflect.Array
+ */
+JNIEXPORT jint JNICALL
+JVM_GetArrayLength(JNIEnv *env, jobject arr);
+
+JNIEXPORT jobject JNICALL
+JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index);
+
+JNIEXPORT jvalue JNICALL
+JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode);
+
+JNIEXPORT void JNICALL
+JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val);
+
+JNIEXPORT void JNICALL
+JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v,
+                             unsigned char vCode);
+
+JNIEXPORT jobject JNICALL
+JVM_NewArray(JNIEnv *env, jclass eltClass, jint length);
+
+JNIEXPORT jobject JNICALL
+JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
+
+/*
+ * java.lang.Class and java.lang.ClassLoader
+ */
+
+#define JVM_CALLER_DEPTH -1
+
+/*
+ * Returns the immediate caller class of the native method invoking
+ * JVM_GetCallerClass.  The Method.invoke and other frames due to
+ * reflection machinery are skipped.
+ *
+ * The depth parameter must be -1 (JVM_DEPTH). The caller is expected
+ * to be marked with sun.reflect.CallerSensitive.  The JVM will throw
+ * an error if it is not marked propertly.
+ */
+JNIEXPORT jclass JNICALL
+JVM_GetCallerClass(JNIEnv *env, int depth);
+
+
+/*
+ * Find primitive classes
+ * utf: class name
+ */
+JNIEXPORT jclass JNICALL
+JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
+
+
+/*
+ * Find a class from a boot class loader. Returns NULL if class not found.
+ */
+JNIEXPORT jclass JNICALL
+JVM_FindClassFromBootLoader(JNIEnv *env, const char *name);
+
+/*
+ * Find a class from a given class loader.  Throws ClassNotFoundException.
+ *  name:   name of class
+ *  init:   whether initialization is done
+ *  loader: class loader to look up the class. This may not be the same as the caller's
+ *          class loader.
+ *  caller: initiating class. The initiating class may be null when a security
+ *          manager is not installed.
+ */
+JNIEXPORT jclass JNICALL
+JVM_FindClassFromCaller(JNIEnv *env, const char *name, jboolean init,
+                        jobject loader, jclass caller);
+
+/*
+ * Find a class from a given class.
+ */
+JNIEXPORT jclass JNICALL
+JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init,
+                             jclass from);
+
+/* Find a loaded class cached by the VM */
+JNIEXPORT jclass JNICALL
+JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name);
+
+/* Define a class */
+JNIEXPORT jclass JNICALL
+JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
+                jsize len, jobject pd);
+
+/* Define a class with a source (added in JDK1.5) */
+JNIEXPORT jclass JNICALL
+JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader,
+                          const jbyte *buf, jsize len, jobject pd,
+                          const char *source);
+
+/*
+ * Module support funcions
+ */
+
+/*
+ * Define a module with the specified packages and bind the module to the
+ * given class loader.
+ *  module:       module to define
+ *  is_open:      specifies if module is open (currently ignored)
+ *  version:      the module version
+ *  location:     the module location
+ *  packages:     list of packages in the module
+ *  num_packages: number of packages in the module
+ */
+JNIEXPORT void JNICALL
+JVM_DefineModule(JNIEnv *env, jobject module, jboolean is_open, jstring version,
+                 jstring location, const char* const* packages, jsize num_packages);
+
+/*
+ * Set the boot loader's unnamed module.
+ *  module: boot loader's unnamed module
+ */
+JNIEXPORT void JNICALL
+JVM_SetBootLoaderUnnamedModule(JNIEnv *env, jobject module);
+
+/*
+ * Do a qualified export of a package.
+ *  from_module: module containing the package to export
+ *  package:     name of the package to export
+ *  to_module:   module to export the package to
+ */
+JNIEXPORT void JNICALL
+JVM_AddModuleExports(JNIEnv *env, jobject from_module, const char* package, jobject to_module);
+
+/*
+ * Do an export of a package to all unnamed modules.
+ *  from_module: module containing the package to export
+ *  package:     name of the package to export to all unnamed modules
+ */
+JNIEXPORT void JNICALL
+JVM_AddModuleExportsToAllUnnamed(JNIEnv *env, jobject from_module, const char* package);
+
+/*
+ * Do an unqualified export of a package.
+ *  from_module: module containing the package to export
+ *  package:     name of the package to export
+ */
+JNIEXPORT void JNICALL
+JVM_AddModuleExportsToAll(JNIEnv *env, jobject from_module, const char* package);
+
+/*
+ * Add a module to the list of modules that a given module can read.
+ *  from_module:   module requesting read access
+ *  source_module: module that from_module wants to read
+ */
+JNIEXPORT void JNICALL
+JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject source_module);
+
+/*
+ * Reflection support functions
+ */
+
+JNIEXPORT jstring JNICALL
+JVM_GetClassName(JNIEnv *env, jclass cls);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetClassInterfaces(JNIEnv *env, jclass cls);
+
+JNIEXPORT jboolean JNICALL
+JVM_IsInterface(JNIEnv *env, jclass cls);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetClassSigners(JNIEnv *env, jclass cls);
+
+JNIEXPORT void JNICALL
+JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers);
+
+JNIEXPORT jobject JNICALL
+JVM_GetProtectionDomain(JNIEnv *env, jclass cls);
+
+JNIEXPORT jboolean JNICALL
+JVM_IsArrayClass(JNIEnv *env, jclass cls);
+
+JNIEXPORT jboolean JNICALL
+JVM_IsPrimitiveClass(JNIEnv *env, jclass cls);
+
+JNIEXPORT jint JNICALL
+JVM_GetClassModifiers(JNIEnv *env, jclass cls);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass);
+
+JNIEXPORT jclass JNICALL
+JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass);
+
+JNIEXPORT jstring JNICALL
+JVM_GetSimpleBinaryName(JNIEnv *env, jclass ofClass);
+
+/* Generics support (JDK 1.5) */
+JNIEXPORT jstring JNICALL
+JVM_GetClassSignature(JNIEnv *env, jclass cls);
+
+/* Annotations support (JDK 1.5) */
+JNIEXPORT jbyteArray JNICALL
+JVM_GetClassAnnotations(JNIEnv *env, jclass cls);
+
+/* Type use annotations support (JDK 1.8) */
+
+JNIEXPORT jbyteArray JNICALL
+JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls);
+
+JNIEXPORT jbyteArray JNICALL
+JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field);
+
+JNIEXPORT jbyteArray JNICALL
+JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method);
+
+/*
+ * New (JDK 1.4) reflection implementation
+ */
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly);
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly);
+
+/* Differs from JVM_GetClassModifiers in treatment of inner classes.
+   This returns the access flags for the class as specified in the
+   class file rather than searching the InnerClasses attribute (if
+   present) to find the source-level access flags. Only the values of
+   the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
+   valid. */
+JNIEXPORT jint JNICALL
+JVM_GetClassAccessFlags(JNIEnv *env, jclass cls);
+
+/* The following two reflection routines are still needed due to startup time issues */
+/*
+ * java.lang.reflect.Method
+ */
+JNIEXPORT jobject JNICALL
+JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0);
+
+/*
+ * java.lang.reflect.Constructor
+ */
+JNIEXPORT jobject JNICALL
+JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
+
+/*
+ * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5)
+ */
+
+JNIEXPORT jobject JNICALL
+JVM_GetClassConstantPool(JNIEnv *env, jclass cls);
+
+JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize
+(JNIEnv *env, jobject unused, jobject jcpool);
+
+JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jint JNICALL JVM_ConstantPoolGetClassRefIndexAt
+(JNIEnv *env, jobject obj, jobject unused, jint index);
+
+JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jint JNICALL JVM_ConstantPoolGetNameAndTypeRefIndexAt
+(JNIEnv *env, jobject obj, jobject unused, jint index);
+
+JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetNameAndTypeRefInfoAt
+(JNIEnv *env, jobject obj, jobject unused, jint index);
+
+JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+JNIEXPORT jbyte JNICALL JVM_ConstantPoolGetTagAt
+(JNIEnv *env, jobject unused, jobject jcpool, jint index);
+
+/*
+ * Parameter reflection
+ */
+
+JNIEXPORT jobjectArray JNICALL
+JVM_GetMethodParameters(JNIEnv *env, jobject method);
+
+/*
+ * java.security.*
+ */
+
+JNIEXPORT jobject JNICALL
+JVM_DoPrivileged(JNIEnv *env, jclass cls,
+                 jobject action, jobject context, jboolean wrapException);
+
+JNIEXPORT jobject JNICALL
+JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls);
+
+JNIEXPORT jobject JNICALL
+JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls);
+
+/*
+ * Signal support, used to implement the shutdown sequence.  Every VM must
+ * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts
+ * (^C) and the latter for external termination (kill, system shutdown, etc.).
+ * Other platform-dependent signal values may also be supported.
+ */
+
+JNIEXPORT void * JNICALL
+JVM_RegisterSignal(jint sig, void *handler);
+
+JNIEXPORT jboolean JNICALL
+JVM_RaiseSignal(jint sig);
+
+JNIEXPORT jint JNICALL
+JVM_FindSignal(const char *name);
+
+/*
+ * Retrieve the assertion directives for the specified class.
+ */
+JNIEXPORT jboolean JNICALL
+JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls);
+
+/*
+ * Retrieve the assertion directives from the VM.
+ */
+JNIEXPORT jobject JNICALL
+JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused);
+
+/*
+ * java.util.concurrent.atomic.AtomicLong
+ */
+JNIEXPORT jboolean JNICALL
+JVM_SupportsCX8(void);
+
+/*
+ * com.sun.dtrace.jsdt support
+ */
+
+#define JVM_TRACING_DTRACE_VERSION 1
+
+/*
+ * Structure to pass one probe description to JVM
+ */
+typedef struct {
+    jmethodID method;
+    jstring   function;
+    jstring   name;
+    void*            reserved[4];     // for future use
+} JVM_DTraceProbe;
+
+/**
+ * Encapsulates the stability ratings for a DTrace provider field
+ */
+typedef struct {
+    jint nameStability;
+    jint dataStability;
+    jint dependencyClass;
+} JVM_DTraceInterfaceAttributes;
+
+/*
+ * Structure to pass one provider description to JVM
+ */
+typedef struct {
+    jstring                       name;
+    JVM_DTraceProbe*              probes;
+    jint                          probe_count;
+    JVM_DTraceInterfaceAttributes providerAttributes;
+    JVM_DTraceInterfaceAttributes moduleAttributes;
+    JVM_DTraceInterfaceAttributes functionAttributes;
+    JVM_DTraceInterfaceAttributes nameAttributes;
+    JVM_DTraceInterfaceAttributes argsAttributes;
+    void*                         reserved[4]; // for future use
+} JVM_DTraceProvider;
+
+/*
+ * Get the version number the JVM was built with
+ */
+JNIEXPORT jint JNICALL
+JVM_DTraceGetVersion(JNIEnv* env);
+
+/*
+ * Register new probe with given signature, return global handle
+ *
+ * The version passed in is the version that the library code was
+ * built with.
+ */
+JNIEXPORT jlong JNICALL
+JVM_DTraceActivate(JNIEnv* env, jint version, jstring module_name,
+  jint providers_count, JVM_DTraceProvider* providers);
+
+/*
+ * Check JSDT probe
+ */
+JNIEXPORT jboolean JNICALL
+JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method);
+
+/*
+ * Destroy custom DOF
+ */
+JNIEXPORT void JNICALL
+JVM_DTraceDispose(JNIEnv* env, jlong activation_handle);
+
+/*
+ * Check to see if DTrace is supported by OS
+ */
+JNIEXPORT jboolean JNICALL
+JVM_DTraceIsSupported(JNIEnv* env);
+
+/*************************************************************************
+ PART 2: Support for the Verifier and Class File Format Checker
+ ************************************************************************/
+/*
+ * Return the class name in UTF format. The result is valid
+ * until JVM_ReleaseUTf is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetClassNameUTF(JNIEnv *env, jclass cb);
+
+/*
+ * Returns the constant pool types in the buffer provided by "types."
+ */
+JNIEXPORT void JNICALL
+JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types);
+
+/*
+ * Returns the number of Constant Pool entries.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb);
+
+/*
+ * Returns the number of *declared* fields or methods.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetClassFieldsCount(JNIEnv *env, jclass cb);
+
+JNIEXPORT jint JNICALL
+JVM_GetClassMethodsCount(JNIEnv *env, jclass cb);
+
+/*
+ * Returns the CP indexes of exceptions raised by a given method.
+ * Places the result in the given buffer.
+ *
+ * The method is identified by method_index.
+ */
+JNIEXPORT void JNICALL
+JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index,
+                                unsigned short *exceptions);
+/*
+ * Returns the number of exceptions raised by a given method.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index);
+
+/*
+ * Returns the byte code sequence of a given method.
+ * Places the result in the given buffer.
+ *
+ * The method is identified by method_index.
+ */
+JNIEXPORT void JNICALL
+JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index,
+                        unsigned char *code);
+
+/*
+ * Returns the length of the byte code sequence of a given method.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index);
+
+/*
+ * A structure used to a capture exception table entry in a Java method.
+ */
+typedef struct {
+    jint start_pc;
+    jint end_pc;
+    jint handler_pc;
+    jint catchType;
+} JVM_ExceptionTableEntryType;
+
+/*
+ * Returns the exception table entry at entry_index of a given method.
+ * Places the result in the given buffer.
+ *
+ * The method is identified by method_index.
+ */
+JNIEXPORT void JNICALL
+JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index,
+                                   jint entry_index,
+                                   JVM_ExceptionTableEntryType *entry);
+
+/*
+ * Returns the length of the exception table of a given method.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Returns the modifiers of a given field.
+ * The field is identified by field_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Returns the modifiers of a given method.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Returns the number of local variables of a given method.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Returns the number of arguments (including this pointer) of a given method.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Returns the maximum amount of stack (in words) used by a given method.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Is a given method a constructor.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jboolean JNICALL
+JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Is the given method generated by the VM.
+ * The method is identified by method_index.
+ */
+JNIEXPORT jboolean JNICALL
+JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cb, int index);
+
+/*
+ * Returns the name of a given method in UTF format.
+ * The result remains valid until JVM_ReleaseUTF is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the signature of a given method in UTF format.
+ * The result remains valid until JVM_ReleaseUTF is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the name of the field referred to at a given constant pool
+ * index.
+ *
+ * The result is in UTF format and remains valid until JVM_ReleaseUTF
+ * is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the name of the method referred to at a given constant pool
+ * index.
+ *
+ * The result is in UTF format and remains valid until JVM_ReleaseUTF
+ * is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the signature of the method referred to at a given constant pool
+ * index.
+ *
+ * The result is in UTF format and remains valid until JVM_ReleaseUTF
+ * is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the signature of the field referred to at a given constant pool
+ * index.
+ *
+ * The result is in UTF format and remains valid until JVM_ReleaseUTF
+ * is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the class name referred to at a given constant pool index.
+ *
+ * The result is in UTF format and remains valid until JVM_ReleaseUTF
+ * is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the class name referred to at a given constant pool index.
+ *
+ * The constant pool entry must refer to a CONSTANT_Fieldref.
+ *
+ * The result is in UTF format and remains valid until JVM_ReleaseUTF
+ * is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the class name referred to at a given constant pool index.
+ *
+ * The constant pool entry must refer to CONSTANT_Methodref or
+ * CONSTANT_InterfaceMethodref.
+ *
+ * The result is in UTF format and remains valid until JVM_ReleaseUTF
+ * is called.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ */
+JNIEXPORT const char * JNICALL
+JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index);
+
+/*
+ * Returns the modifiers of a field in calledClass. The field is
+ * referred to in class cb at constant pool entry index.
+ *
+ * The caller must treat the string as a constant and not modify it
+ * in any way.
+ *
+ * Returns -1 if the field does not exist in calledClass.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
+
+/*
+ * Returns the modifiers of a method in calledClass. The method is
+ * referred to in class cb at constant pool entry index.
+ *
+ * Returns -1 if the method does not exist in calledClass.
+ */
+JNIEXPORT jint JNICALL
+JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
+
+/*
+ * Releases the UTF string obtained from the VM.
+ */
+JNIEXPORT void JNICALL
+JVM_ReleaseUTF(const char *utf);
+
+/*
+ * Compare if two classes are in the same package.
+ */
+JNIEXPORT jboolean JNICALL
+JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
+
+/* Get classfile constants */
+#include "classfile_constants.h"
+
+/*
+ * A function defined by the byte-code verifier and called by the VM.
+ * This is not a function implemented in the VM.
+ *
+ * Returns JNI_FALSE if verification fails. A detailed error message
+ * will be places in msg_buf, whose length is specified by buf_len.
+ */
+typedef jboolean (*verifier_fn_t)(JNIEnv *env,
+                                  jclass cb,
+                                  char * msg_buf,
+                                  jint buf_len);
+
+
+/*
+ * Support for a VM-independent class format checker.
+ */
+typedef struct {
+    unsigned long code;    /* byte code */
+    unsigned long excs;    /* exceptions */
+    unsigned long etab;    /* catch table */
+    unsigned long lnum;    /* line number */
+    unsigned long lvar;    /* local vars */
+} method_size_info;
+
+typedef struct {
+    unsigned int constants;    /* constant pool */
+    unsigned int fields;
+    unsigned int methods;
+    unsigned int interfaces;
+    unsigned int fields2;      /* number of static 2-word fields */
+    unsigned int innerclasses; /* # of records in InnerClasses attr */
+
+    method_size_info clinit;   /* memory used in clinit */
+    method_size_info main;     /* used everywhere else */
+} class_size_info;
+
+/*
+ * Functions defined in libjava.so to perform string conversions.
+ *
+ */
+
+typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str);
+
+typedef char *(*to_c_string_fn_t)(JNIEnv *env, jstring s, jboolean *b);
+
+/* This is the function defined in libjava.so that performs class
+ * format checks. This functions fills in size information about
+ * the class file and returns:
+ *
+ *   0: good
+ *  -1: out of memory
+ *  -2: bad format
+ *  -3: unsupported version
+ *  -4: bad class name
+ */
+
+typedef jint (*check_format_fn_t)(char *class_name,
+                                  unsigned char *data,
+                                  unsigned int data_size,
+                                  class_size_info *class_size,
+                                  char *message_buffer,
+                                  jint buffer_length,
+                                  jboolean measure_only,
+                                  jboolean check_relaxed);
+
+#define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \
+                                        JVM_ACC_FINAL | \
+                                        JVM_ACC_SUPER | \
+                                        JVM_ACC_INTERFACE | \
+                                        JVM_ACC_ABSTRACT | \
+                                        JVM_ACC_ANNOTATION | \
+                                        JVM_ACC_ENUM | \
+                                        JVM_ACC_SYNTHETIC)
+
+#define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \
+                                        JVM_ACC_PRIVATE | \
+                                        JVM_ACC_PROTECTED | \
+                                        JVM_ACC_STATIC | \
+                                        JVM_ACC_FINAL | \
+                                        JVM_ACC_VOLATILE | \
+                                        JVM_ACC_TRANSIENT | \
+                                        JVM_ACC_ENUM | \
+                                        JVM_ACC_SYNTHETIC)
+
+#define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \
+                                         JVM_ACC_PRIVATE | \
+                                         JVM_ACC_PROTECTED | \
+                                         JVM_ACC_STATIC | \
+                                         JVM_ACC_FINAL | \
+                                         JVM_ACC_SYNCHRONIZED | \
+                                         JVM_ACC_BRIDGE | \
+                                         JVM_ACC_VARARGS | \
+                                         JVM_ACC_NATIVE | \
+                                         JVM_ACC_ABSTRACT | \
+                                         JVM_ACC_STRICT | \
+                                         JVM_ACC_SYNTHETIC)
+
+/*
+ * This is the function defined in libjava.so to perform path
+ * canonicalization. VM call this function before opening jar files
+ * to load system classes.
+ *
+ */
+
+typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len);
+
+/*************************************************************************
+ PART 3: I/O and Network Support
+ ************************************************************************/
+
+/*
+ * Convert a pathname into native format.  This function does syntactic
+ * cleanup, such as removing redundant separator characters.  It modifies
+ * the given pathname string in place.
+ */
+JNIEXPORT char * JNICALL
+JVM_NativePath(char *);
+
+/*
+ * The standard printing functions supported by the Java VM. (Should they
+ * be renamed to JVM_* in the future?
+ */
+
+/* jio_snprintf() and jio_vsnprintf() behave like snprintf(3) and vsnprintf(3),
+ *  respectively, with the following differences:
+ * - The string written to str is always zero-terminated, also in case of
+ *   truncation (count is too small to hold the result string), unless count
+ *   is 0. In case of truncation count-1 characters are written and '\0'
+ *   appendend.
+ * - If count is too small to hold the whole string, -1 is returned across
+ *   all platforms. */
+
+JNIEXPORT int
+jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
+
+JNIEXPORT int
+jio_snprintf(char *str, size_t count, const char *fmt, ...);
+
+JNIEXPORT int
+jio_fprintf(FILE *, const char *fmt, ...);
+
+JNIEXPORT int
+jio_vfprintf(FILE *, const char *fmt, va_list args);
+
+
+JNIEXPORT void * JNICALL
+JVM_RawMonitorCreate(void);
+
+JNIEXPORT void JNICALL
+JVM_RawMonitorDestroy(void *mon);
+
+JNIEXPORT jint JNICALL
+JVM_RawMonitorEnter(void *mon);
+
+JNIEXPORT void JNICALL
+JVM_RawMonitorExit(void *mon);
+
+/*
+ * java.lang.management support
+ */
+JNIEXPORT void* JNICALL
+JVM_GetManagement(jint version);
+
+/*
+ * com.sun.tools.attach.VirtualMachine support
+ *
+ * Initialize the agent properties with the properties maintained in the VM.
+ */
+JNIEXPORT jobject JNICALL
+JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
+
+JNIEXPORT jstring JNICALL
+JVM_GetTemporaryDirectory(JNIEnv *env);
+
+/* Generics reflection support.
+ *
+ * Returns information about the given class's EnclosingMethod
+ * attribute, if present, or null if the class had no enclosing
+ * method.
+ *
+ * If non-null, the returned array contains three elements. Element 0
+ * is the java.lang.Class of which the enclosing method is a member,
+ * and elements 1 and 2 are the java.lang.Strings for the enclosing
+ * method's name and descriptor, respectively.
+ */
+JNIEXPORT jobjectArray JNICALL
+JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass);
+
+/* =========================================================================
+ * The following defines a private JVM interface that the JDK can query
+ * for the JVM version and capabilities.  sun.misc.Version defines
+ * the methods for getting the VM version and its capabilities.
+ *
+ * When a new bit is added, the following should be updated to provide
+ * access to the new capability:
+ *    HS:   JVM_GetVersionInfo and Abstract_VM_Version class
+ *    SDK:  Version class
+ *
+ * Similary, a private JDK interface JDK_GetVersionInfo0 is defined for
+ * JVM to query for the JDK version and capabilities.
+ *
+ * When a new bit is added, the following should be updated to provide
+ * access to the new capability:
+ *    HS:   JDK_Version class
+ *    SDK:  JDK_GetVersionInfo0
+ *
+ * ==========================================================================
+ */
+typedef struct {
+    unsigned int jvm_version;  /* Encoded $VNUM as specified by JEP-223 */
+    unsigned int patch_version : 8; /* JEP-223 patch version */
+    unsigned int reserved3 : 8;
+    unsigned int reserved1 : 16;
+    unsigned int reserved2;
+
+    /* The following bits represents JVM supports that JDK has dependency on.
+     * JDK can use these bits to determine which JVM version
+     * and support it has to maintain runtime compatibility.
+     *
+     * When a new bit is added in a minor or update release, make sure
+     * the new bit is also added in the main/baseline.
+     */
+    unsigned int is_attach_supported : 1;
+    unsigned int : 31;
+    unsigned int : 32;
+    unsigned int : 32;
+} jvm_version_info;
+
+#define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
+#define JVM_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
+#define JVM_VERSION_SECURITY(version) ((version & 0x0000FF00) >> 8)
+#define JVM_VERSION_BUILD(version) ((version & 0x000000FF))
+
+JNIEXPORT void JNICALL
+JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size);
+
+typedef struct {
+    unsigned int jdk_version; /* Encoded $VNUM as specified by JEP-223 */
+    unsigned int patch_version : 8; /* JEP-223 patch version */
+    unsigned int reserved3 : 8;
+    unsigned int reserved1 : 16;
+    unsigned int reserved2;
+
+    /* The following bits represents new JDK supports that VM has dependency on.
+     * VM implementation can use these bits to determine which JDK version
+     * and support it has to maintain runtime compatibility.
+     *
+     * When a new bit is added in a minor or update release, make sure
+     * the new bit is also added in the main/baseline.
+     */
+    unsigned int thread_park_blocker : 1;
+    unsigned int post_vm_init_hook_enabled : 1;
+    unsigned int pending_list_uses_discovered_field : 1;
+    unsigned int : 29;
+    unsigned int : 32;
+    unsigned int : 32;
+} jdk_version_info;
+
+#define JDK_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
+#define JDK_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
+#define JDK_VERSION_SECURITY(version) ((version & 0x0000FF00) >> 8)
+#define JDK_VERSION_BUILD(version) ((version & 0x000000FF))
+
+/*
+ * This is the function JDK_GetVersionInfo0 defined in libjava.so
+ * that is dynamically looked up by JVM.
+ */
+typedef void (*jdk_version_info_fn_t)(jdk_version_info* info, size_t info_size);
+
+/*
+ * This structure is used by the launcher to get the default thread
+ * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a
+ * version of 1.1.  As it is not supported otherwise, it has been removed
+ * from jni.h
+ */
+typedef struct JDK1_1InitArgs {
+    jint version;
+
+    char **properties;
+    jint checkSource;
+    jint nativeStackSize;
+    jint javaStackSize;
+    jint minHeapSize;
+    jint maxHeapSize;
+    jint verifyMode;
+    char *classpath;
+
+    jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args);
+    void (JNICALL *exit)(jint code);
+    void (JNICALL *abort)(void);
+
+    jint enableClassGC;
+    jint enableVerboseGC;
+    jint disableAsyncGC;
+    jint verbose;
+    jboolean debugging;
+    jint debugPort;
+} JDK1_1InitArgs;
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+
+#endif /* __cplusplus */
+
+#endif /* !_JAVASOFT_JVM_H_ */
--- a/src/hotspot/share/jvmci/jvmciEnv.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/jvmci/jvmciEnv.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -410,8 +410,8 @@
 // ------------------------------------------------------------------
 // Check for changes to the system dictionary during compilation
 // class loads, evolution, breakpoints
-JVMCIEnv::CodeInstallResult JVMCIEnv::check_for_system_dictionary_modification(Dependencies* dependencies, Handle compiled_code,
-                                                                               JVMCIEnv* env, char** failure_detail) {
+JVMCIEnv::CodeInstallResult JVMCIEnv::validate_compile_task_dependencies(Dependencies* dependencies, Handle compiled_code,
+                                                                         JVMCIEnv* env, char** failure_detail) {
   // If JVMTI capabilities were enabled during compile, the compilation is invalidated.
   if (env != NULL) {
     if (!env->_jvmti_can_hotswap_or_post_breakpoint && JvmtiExport::can_hotswap_or_post_breakpoint()) {
@@ -422,37 +422,20 @@
 
   // Dependencies must be checked when the system dictionary changes
   // or if we don't know whether it has changed (i.e., env == NULL).
-  // In debug mode, always check dependencies.
-  bool counter_changed = env != NULL && env->_system_dictionary_modification_counter != SystemDictionary::number_of_modifications();
-  bool verify_deps = env == NULL || trueInDebug || JavaAssertions::enabled(SystemDictionary::HotSpotInstalledCode_klass()->name()->as_C_string(), true);
-  if (!counter_changed && !verify_deps) {
+  bool counter_changed = env == NULL || env->_system_dictionary_modification_counter != SystemDictionary::number_of_modifications();
+  CompileTask* task = env == NULL ? NULL : env->task();
+  Dependencies::DepType result = dependencies->validate_dependencies(task, counter_changed, failure_detail);
+  if (result == Dependencies::end_marker) {
     return JVMCIEnv::ok;
   }
 
-  for (Dependencies::DepStream deps(dependencies); deps.next(); ) {
-    Klass* witness = deps.check_dependency();
-    if (witness != NULL) {
-      // Use a fixed size buffer to prevent the string stream from
-      // resizing in the context of an inner resource mark.
-      char* buffer = NEW_RESOURCE_ARRAY(char, O_BUFLEN);
-      stringStream st(buffer, O_BUFLEN);
-      deps.print_dependency(witness, true, &st);
-      *failure_detail = st.as_string();
-      if (env == NULL || counter_changed || deps.type() == Dependencies::evol_method) {
-        return JVMCIEnv::dependencies_failed;
-      } else {
-        // The dependencies were invalid at the time of installation
-        // without any intervening modification of the system
-        // dictionary.  That means they were invalidly constructed.
-        return JVMCIEnv::dependencies_invalid;
-      }
-    }
-    if (LogCompilation) {
-      deps.log_dependency();
-    }
+  if (!Dependencies::is_klass_type(result) || counter_changed) {
+    return JVMCIEnv::dependencies_failed;
   }
-
-  return JVMCIEnv::ok;
+  // The dependencies were invalid at the time of installation
+  // without any intervening modification of the system
+  // dictionary.  That means they were invalidly constructed.
+  return JVMCIEnv::dependencies_invalid;
 }
 
 // ------------------------------------------------------------------
@@ -492,8 +475,15 @@
     // Encode the dependencies now, so we can check them right away.
     dependencies->encode_content_bytes();
 
+    // Record the dependencies for the current compile in the log
+    if (LogCompilation) {
+      for (Dependencies::DepStream deps(dependencies); deps.next(); ) {
+        deps.log_dependency();
+      }
+    }
+
     // Check for {class loads, evolution, breakpoints} during compilation
-    result = check_for_system_dictionary_modification(dependencies, compiled_code, env, &failure_detail);
+    result = validate_compile_task_dependencies(dependencies, compiled_code, env, &failure_detail);
     if (result != JVMCIEnv::ok) {
       // While not a true deoptimization, it is a preemptive decompile.
       MethodData* mdp = method()->method_data();
--- a/src/hotspot/share/jvmci/jvmciEnv.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/jvmci/jvmciEnv.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -138,8 +138,8 @@
 
   // Helper routine for determining the validity of a compilation
   // with respect to concurrent class loading.
-  static JVMCIEnv::CodeInstallResult check_for_system_dictionary_modification(Dependencies* target, Handle compiled_code,
-                                                                              JVMCIEnv* env, char** failure_detail);
+  static JVMCIEnv::CodeInstallResult validate_compile_task_dependencies(Dependencies* target, Handle compiled_code,
+                                                                        JVMCIEnv* env, char** failure_detail);
 
 public:
   CompileTask* task() { return _task; }
--- a/src/hotspot/share/opto/c2_globals.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/opto/c2_globals.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -195,6 +195,9 @@
   product(bool, UseSubwordForMaxVector, true,                               \
           "Use Subword Analysis to set maximum vector size")                \
                                                                             \
+  product(bool, UseVectorCmov, false,                                       \
+          "Use Vectorized Cmov")                                            \
+                                                                            \
   develop(intx, UnrollLimitForProfileCheck, 1,                              \
           "Don't use profile_trip_cnt() to restrict unrolling until "       \
           "unrolling would push the number of unrolled iterations above "   \
--- a/src/hotspot/share/opto/classes.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/opto/classes.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -66,6 +66,7 @@
 macro(CMoveD)
 macro(CMoveVD)
 macro(CMoveF)
+macro(CMoveVF)
 macro(CMoveI)
 macro(CMoveL)
 macro(CMoveP)
--- a/src/hotspot/share/opto/loopopts.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/opto/loopopts.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -528,13 +528,12 @@
     BasicType bt = phi->type()->basic_type();
     switch (bt) {
     case T_DOUBLE:
+    case T_FLOAT:
       if (C->use_cmove()) {
         continue; //TODO: maybe we want to add some cost
       }
-    case T_FLOAT: {
       cost += Matcher::float_cmove_cost(); // Could be very expensive
       break;
-    }
     case T_LONG: {
       cost += Matcher::long_cmove_cost(); // May encodes as 2 CMOV's
     }
@@ -613,8 +612,9 @@
   }
   // Check for highly predictable branch.  No point in CMOV'ing if
   // we are going to predict accurately all the time.
-  if (C->use_cmove() && cmp_op == Op_CmpD) ;//keep going
-  else if (iff->_prob < infrequent_prob ||
+  if (C->use_cmove() && (cmp_op == Op_CmpF || cmp_op == Op_CmpD)) {
+    //keep going
+  } else if (iff->_prob < infrequent_prob ||
       iff->_prob > (1.0f - infrequent_prob))
     return NULL;
 
--- a/src/hotspot/share/opto/matcher.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/opto/matcher.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -2267,6 +2267,7 @@
       case Op_CMoveL:
       case Op_CMoveN:
       case Op_CMoveP:
+      case Op_CMoveVF:
       case Op_CMoveVD:  {
         // Restructure into a binary tree for Matching.  It's possible that
         // we could move this code up next to the graph reshaping for IfNodes
--- a/src/hotspot/share/opto/superword.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/opto/superword.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -58,7 +58,7 @@
   _mem_slice_tail(arena(), 8,  0, NULL),  // memory slice tails
   _node_info(arena(), 8,  0, SWNodeInfo::initial), // info needed per node
   _clone_map(phase->C->clone_map()),      // map of nodes created in cloning
-  _cmovev_kit(_arena, this),              // map to facilitate CMoveVD creation
+  _cmovev_kit(_arena, this),              // map to facilitate CMoveV creation
   _align_to_ref(NULL),                    // memory reference to align vectors to
   _disjoint_ptrs(arena(), 8,  0, OrderedPair::initial), // runtime disambiguated pointer pairs
   _dg(_arena),                            // dependence graph
@@ -511,8 +511,7 @@
     combine_packs();
 
     construct_my_pack_map();
-
-    if (_do_vector_loop) {
+    if (UseVectorCmov) {
       merge_packs_to_cmovd();
     }
 
@@ -1249,8 +1248,8 @@
 
 //------------------------------data_size---------------------------
 int SuperWord::data_size(Node* s) {
-  Node* use = NULL; //test if the node is a candidate for CMoveVD optimization, then return the size of CMov
-  if (_do_vector_loop) {
+  Node* use = NULL; //test if the node is a candidate for CMoveV optimization, then return the size of CMov
+  if (UseVectorCmov) {
     use = _cmovev_kit.is_Bool_candidate(s);
     if (use != NULL) {
       return data_size(use);
@@ -1260,6 +1259,7 @@
       return data_size(use);
     }
   }
+
   int bsize = type2aelembytes(velt_basic_type(s));
   assert(bsize != 0, "valid size");
   return bsize;
@@ -1718,6 +1718,9 @@
   if (!cmovd->is_CMove()) {
     return NULL;
   }
+  if (cmovd->Opcode() != Op_CMoveF && cmovd->Opcode() != Op_CMoveD) {
+    return NULL;
+  }
   if (pack(cmovd) != NULL) { // already in the cmov pack
     return NULL;
   }
@@ -2377,7 +2380,13 @@
         }
         BasicType bt = velt_basic_type(n);
         const TypeVect* vt = TypeVect::make(bt, vlen);
-        vn = new CMoveVDNode(cc, src1, src2, vt);
+        assert(bt == T_FLOAT || bt == T_DOUBLE, "Only vectorization for FP cmovs is supported");
+        if (bt == T_FLOAT) {
+          vn = new CMoveVFNode(cc, src1, src2, vt);
+        } else {
+          assert(bt == T_DOUBLE, "Expected double");
+          vn = new CMoveVDNode(cc, src1, src2, vt);
+        }
         NOT_PRODUCT(if(is_trace_cmov()) {tty->print("SWPointer::output: created new CMove node %d: ", vn->_idx); vn->dump();})
       } else if (opc == Op_FmaD || opc == Op_FmaF) {
         // Promote operands to vector
--- a/src/hotspot/share/opto/vectornode.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/opto/vectornode.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -92,6 +92,9 @@
   case Op_FmaF:
     assert(bt == T_FLOAT, "must be");
     return Op_FmaVF;
+  case Op_CMoveF:
+    assert(bt == T_FLOAT, "must be");
+    return Op_CMoveVF;
   case Op_CMoveD:
     assert(bt == T_DOUBLE, "must be");
     return Op_CMoveVD;
--- a/src/hotspot/share/opto/vectornode.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/opto/vectornode.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -277,8 +277,16 @@
   virtual int Opcode() const;
 };
 
+//------------------------------CMoveVFNode--------------------------------------
+// Vector float conditional move
+class CMoveVFNode : public VectorNode {
+public:
+  CMoveVFNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {}
+  virtual int Opcode() const;
+};
+
 //------------------------------CMoveVDNode--------------------------------------
-// Vector multiply double
+// Vector double conditional move
 class CMoveVDNode : public VectorNode {
 public:
   CMoveVDNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {}
--- a/src/hotspot/share/prims/nativeLookup.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/prims/nativeLookup.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -224,7 +224,13 @@
       st.print_raw(long_name);
       if (os_style) os::print_jni_name_suffix_on(&st, args_size);
       char* jni_name = st.as_string();
-      return (address)os::dll_lookup(dll, jni_name);
+      address critical_entry = (address)os::dll_lookup(dll, jni_name);
+      // Close the handle to avoid keeping the library alive if the native method holder is unloaded.
+      // This is fine because the library is still kept alive by JNI (see JVM_LoadLibrary). As soon
+      // as the holder class and the library are unloaded (see JVM_UnloadLibrary), the native wrapper
+      // that calls 'critical_entry' becomes unreachable and is unloaded as well.
+      os::dll_unload(dll);
+      return critical_entry;
     }
   }
 
@@ -245,7 +251,6 @@
                 + (method->is_static() ? 1 : 0) // class for static methods
                 + method->size_of_parameters(); // actual parameters
 
-
   // 1) Try JNI short style
   entry = lookup_style(method, pure_name, "",        args_size, true,  in_base_library, CHECK_NULL);
   if (entry != NULL) return entry;
--- a/src/hotspot/share/runtime/arguments.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/runtime/arguments.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -674,6 +674,14 @@
   return false;
 }
 
+// Verifies the correctness of the entries in the special_jvm_flags table.
+// If there is a semantic error (i.e. a bug in the table) such as the obsoletion
+// version being earlier than the deprecation version, then a warning is issued
+// and verification fails - by returning false. If it is detected that the table
+// is out of date, with respect to the current version, then a warning is issued
+// but verification does not fail. This allows the VM to operate when the version
+// is first updated, without needing to update all the impacted flags at the
+// same time.
 static bool verify_special_jvm_flags() {
   bool success = true;
   for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
@@ -710,7 +718,6 @@
       if (!version_less_than(JDK_Version::current(), flag.obsolete_in)) {
         if (Flag::find_flag(flag.name) != NULL) {
           warning("Global variable for obsolete special flag entry \"%s\" should be removed", flag.name);
-          success = false;
         }
       }
     }
@@ -720,7 +727,6 @@
       if (!version_less_than(JDK_Version::current(), flag.expired_in)) {
         if (Flag::find_flag(flag.name) != NULL) {
           warning("Global variable for expired flag entry \"%s\" should be removed", flag.name);
-          success = false;
         }
       }
     }
--- a/src/hotspot/share/runtime/java.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/runtime/java.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -357,7 +357,7 @@
     MemTracker::final_report(tty);
   }
 
-  Threads::log_smr_statistics();
+  ThreadsSMRSupport::log_smr_statistics();
 }
 
 #else // PRODUCT MODE STATISTICS
@@ -399,7 +399,7 @@
     Method::print_touched_methods(tty);
   }
 
-  Threads::log_smr_statistics();
+  ThreadsSMRSupport::log_smr_statistics();
 }
 
 #endif
--- a/src/hotspot/share/runtime/thread.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/runtime/thread.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -107,7 +107,6 @@
 #include "utilities/events.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/preserveException.hpp"
-#include "utilities/resourceHash.hpp"
 #include "utilities/vmError.hpp"
 #if INCLUDE_ALL_GCS
 #include "gc/cms/concurrentMarkSweepThread.hpp"
@@ -207,7 +206,7 @@
 
 void JavaThread::smr_delete() {
   if (_on_thread_list) {
-    Threads::smr_delete(this);
+    ThreadsSMRSupport::smr_delete(this);
   } else {
     delete this;
   }
@@ -419,7 +418,7 @@
   assert(!thread->is_Java_thread() || Thread::current() == thread ||
          !((JavaThread *) thread)->on_thread_list() ||
          SafepointSynchronize::is_at_safepoint() ||
-         Threads::is_a_protected_JavaThread_with_lock((JavaThread *) thread),
+         ThreadsSMRSupport::is_a_protected_JavaThread_with_lock((JavaThread *) thread),
          "possibility of dangling Thread pointer");
 }
 #endif
@@ -3443,103 +3442,15 @@
 // would like. We are actively migrating Threads_lock uses to other
 // mechanisms in order to reduce Threads_lock contention.
 
-JavaThread*           Threads::_thread_list = NULL;
-int                   Threads::_number_of_threads = 0;
-int                   Threads::_number_of_non_daemon_threads = 0;
-int                   Threads::_return_code = 0;
-int                   Threads::_thread_claim_parity = 0;
-size_t                JavaThread::_stack_size_at_create = 0;
-// Safe Memory Reclamation (SMR) support:
-Monitor*              Threads::_smr_delete_lock =
-                          new Monitor(Monitor::special, "smr_delete_lock",
-                                      false /* allow_vm_block */,
-                                      Monitor::_safepoint_check_never);
-// The '_cnt', '_max' and '_times" fields are enabled via
-// -XX:+EnableThreadSMRStatistics:
-
-// # of parallel threads in _smr_delete_lock->wait().
-// Impl note: Hard to imagine > 64K waiting threads so this could be 16-bit,
-// but there is no nice 16-bit _FORMAT support.
-uint                  Threads::_smr_delete_lock_wait_cnt = 0;
-
-// Max # of parallel threads in _smr_delete_lock->wait().
-// Impl note: See _smr_delete_lock_wait_cnt note.
-uint                  Threads::_smr_delete_lock_wait_max = 0;
-
-// Flag to indicate when an _smr_delete_lock->notify() is needed.
-// Impl note: See _smr_delete_lock_wait_cnt note.
-volatile uint         Threads::_smr_delete_notify = 0;
-
-// # of threads deleted over VM lifetime.
-// Impl note: Atomically incremented over VM lifetime so use unsigned for more
-// range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc
-// isn't available everywhere (or is it?).
-volatile uint         Threads::_smr_deleted_thread_cnt = 0;
-
-// Max time in millis to delete a thread.
-// Impl note: 16-bit might be too small on an overloaded machine. Use
-// unsigned since this is a time value. Set via Atomic::cmpxchg() in a
-// loop for correctness.
-volatile uint         Threads::_smr_deleted_thread_time_max = 0;
-
-// Cumulative time in millis to delete threads.
-// Impl note: Atomically added to over VM lifetime so use unsigned for more
-// range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc
-// isn't available everywhere (or is it?).
-volatile uint         Threads::_smr_deleted_thread_times = 0;
-
-ThreadsList* volatile Threads::_smr_java_thread_list = new ThreadsList(0);
-
-// # of ThreadsLists allocated over VM lifetime.
-// Impl note: We allocate a new ThreadsList for every thread create and
-// every thread delete so we need a bigger type than the
-// _smr_deleted_thread_cnt field.
-uint64_t              Threads::_smr_java_thread_list_alloc_cnt = 1;
-
-// # of ThreadsLists freed over VM lifetime.
-// Impl note: See _smr_java_thread_list_alloc_cnt note.
-uint64_t              Threads::_smr_java_thread_list_free_cnt = 0;
-
-// Max size ThreadsList allocated.
-// Impl note: Max # of threads alive at one time should fit in unsigned 32-bit.
-uint                  Threads::_smr_java_thread_list_max = 0;
-
-// Max # of nested ThreadsLists for a thread.
-// Impl note: Hard to imagine > 64K nested ThreadsLists so this could be
-// 16-bit, but there is no nice 16-bit _FORMAT support.
-uint                  Threads::_smr_nested_thread_list_max = 0;
-
-// # of ThreadsListHandles deleted over VM lifetime.
-// Impl note: Atomically incremented over VM lifetime so use unsigned for
-// more range. There will be fewer ThreadsListHandles than threads so
-// unsigned 32-bit should be fine.
-volatile uint         Threads::_smr_tlh_cnt = 0;
-
-// Max time in millis to delete a ThreadsListHandle.
-// Impl note: 16-bit might be too small on an overloaded machine. Use
-// unsigned since this is a time value. Set via Atomic::cmpxchg() in a
-// loop for correctness.
-volatile uint         Threads::_smr_tlh_time_max = 0;
-
-// Cumulative time in millis to delete ThreadsListHandles.
-// Impl note: Atomically added to over VM lifetime so use unsigned for more
-// range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc
-// isn't available everywhere (or is it?).
-volatile uint         Threads::_smr_tlh_times = 0;
-
-ThreadsList*          Threads::_smr_to_delete_list = NULL;
-
-// # of parallel ThreadsLists on the to-delete list.
-// Impl note: Hard to imagine > 64K ThreadsLists needing to be deleted so
-// this could be 16-bit, but there is no nice 16-bit _FORMAT support.
-uint                  Threads::_smr_to_delete_list_cnt = 0;
-
-// Max # of parallel ThreadsLists on the to-delete list.
-// Impl note: See _smr_to_delete_list_cnt note.
-uint                  Threads::_smr_to_delete_list_max = 0;
+JavaThread* Threads::_thread_list = NULL;
+int         Threads::_number_of_threads = 0;
+int         Threads::_number_of_non_daemon_threads = 0;
+int         Threads::_return_code = 0;
+int         Threads::_thread_claim_parity = 0;
+size_t      JavaThread::_stack_size_at_create = 0;
 
 #ifdef ASSERT
-bool                  Threads::_vm_complete = false;
+bool        Threads::_vm_complete = false;
 #endif
 
 static inline void *prefetch_and_load_ptr(void **addr, intx prefetch_interval) {
@@ -3561,12 +3472,8 @@
          MACRO_current_p++,                                                                                               \
              X = (JavaThread*)prefetch_and_load_ptr((void**)MACRO_current_p, (intx)MACRO_scan_interval))
 
-inline ThreadsList* Threads::get_smr_java_thread_list() {
-  return (ThreadsList*)OrderAccess::load_acquire(&_smr_java_thread_list);
-}
-
 // All JavaThreads
-#define ALL_JAVA_THREADS(X) DO_JAVA_THREADS(get_smr_java_thread_list(), X)
+#define ALL_JAVA_THREADS(X) DO_JAVA_THREADS(ThreadsSMRSupport::get_smr_java_thread_list(), X)
 
 // All JavaThreads + all non-JavaThreads (i.e., every thread in the system)
 void Threads::threads_do(ThreadClosure* tc) {
@@ -3667,240 +3574,6 @@
                                          vmSymbols::void_method_signature(), CHECK);
 }
 
-// Safe Memory Reclamation (SMR) support:
-//
-
-// Acquire a stable ThreadsList.
-//
-ThreadsList *Threads::acquire_stable_list(Thread *self, bool is_ThreadsListSetter) {
-  assert(self != NULL, "sanity check");
-  // acquire_stable_list_nested_path() will grab the Threads_lock
-  // so let's make sure the ThreadsListHandle is in a safe place.
-  // ThreadsListSetter cannot make this check on this code path.
-  debug_only(if (!is_ThreadsListSetter && StrictSafepointChecks) self->check_for_valid_safepoint_state(/* potential_vm_operation */ false);)
-
-  if (self->get_threads_hazard_ptr() == NULL) {
-    // The typical case is first.
-    return acquire_stable_list_fast_path(self);
-  }
-
-  // The nested case is rare.
-  return acquire_stable_list_nested_path(self);
-}
-
-// Fast path (and lock free) way to acquire a stable ThreadsList.
-//
-ThreadsList *Threads::acquire_stable_list_fast_path(Thread *self) {
-  assert(self != NULL, "sanity check");
-  assert(self->get_threads_hazard_ptr() == NULL, "sanity check");
-  assert(self->get_nested_threads_hazard_ptr() == NULL,
-         "cannot have a nested hazard ptr with a NULL regular hazard ptr");
-
-  ThreadsList* threads;
-
-  // Stable recording of a hazard ptr for SMR. This code does not use
-  // locks so its use of the _smr_java_thread_list & _threads_hazard_ptr
-  // fields is racy relative to code that uses those fields with locks.
-  // OrderAccess and Atomic functions are used to deal with those races.
-  //
-  while (true) {
-    threads = get_smr_java_thread_list();
-
-    // Publish a tagged hazard ptr to denote that the hazard ptr is not
-    // yet verified as being stable. Due to the fence after the hazard
-    // ptr write, it will be sequentially consistent w.r.t. the
-    // sequentially consistent writes of the ThreadsList, even on
-    // non-multiple copy atomic machines where stores can be observed
-    // in different order from different observer threads.
-    ThreadsList* unverified_threads = Thread::tag_hazard_ptr(threads);
-    self->set_threads_hazard_ptr(unverified_threads);
-
-    // If _smr_java_thread_list has changed, we have lost a race with
-    // Threads::add() or Threads::remove() and have to try again.
-    if (get_smr_java_thread_list() != threads) {
-      continue;
-    }
-
-    // We try to remove the tag which will verify the hazard ptr as
-    // being stable. This exchange can race with a scanning thread
-    // which might invalidate the tagged hazard ptr to keep it from
-    // being followed to access JavaThread ptrs. If we lose the race,
-    // we simply retry. If we win the race, then the stable hazard
-    // ptr is officially published.
-    if (self->cmpxchg_threads_hazard_ptr(threads, unverified_threads) == unverified_threads) {
-      break;
-    }
-  }
-
-  // A stable hazard ptr has been published letting other threads know
-  // that the ThreadsList and the JavaThreads reachable from this list
-  // are protected and hence they should not be deleted until everyone
-  // agrees it is safe to do so.
-
-  return threads;
-}
-
-// Acquire a nested stable ThreadsList; this is rare so it uses
-// Threads_lock.
-//
-ThreadsList *Threads::acquire_stable_list_nested_path(Thread *self) {
-  assert(self != NULL, "sanity check");
-  assert(self->get_threads_hazard_ptr() != NULL,
-         "cannot have a NULL regular hazard ptr when acquiring a nested hazard ptr");
-
-  // The thread already has a hazard ptr (ThreadsList ref) so we need
-  // to create a nested ThreadsListHandle with the current ThreadsList
-  // since it might be different than our current hazard ptr. The need
-  // for a nested ThreadsListHandle is rare so we do this while holding
-  // the Threads_lock so we don't race with the scanning code; the code
-  // is so much simpler this way.
-
-  NestedThreadsList* node;
-  {
-    // Only grab the Threads_lock if we don't already own it.
-    MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
-    node = new NestedThreadsList(get_smr_java_thread_list());
-    // We insert at the front of the list to match up with the delete
-    // in release_stable_list().
-    node->set_next(self->get_nested_threads_hazard_ptr());
-    self->set_nested_threads_hazard_ptr(node);
-    if (EnableThreadSMRStatistics) {
-      self->inc_nested_threads_hazard_ptr_cnt();
-      if (self->nested_threads_hazard_ptr_cnt() > _smr_nested_thread_list_max) {
-        _smr_nested_thread_list_max = self->nested_threads_hazard_ptr_cnt();
-      }
-    }
-  }
-  log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::acquire_stable_list: add NestedThreadsList node containing ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(node->t_list()));
-
-  return node->t_list();
-}
-
-inline void Threads::add_smr_deleted_thread_times(uint add_value) {
-  Atomic::add(add_value, &_smr_deleted_thread_times);
-}
-
-inline void Threads::inc_smr_deleted_thread_cnt() {
-  Atomic::inc(&_smr_deleted_thread_cnt);
-}
-
-// Release a stable ThreadsList.
-//
-void Threads::release_stable_list(Thread *self) {
-  assert(self != NULL, "sanity check");
-  // release_stable_list_nested_path() will grab the Threads_lock
-  // so let's make sure the ThreadsListHandle is in a safe place.
-  debug_only(if (StrictSafepointChecks) self->check_for_valid_safepoint_state(/* potential_vm_operation */ false);)
-
-  if (self->get_nested_threads_hazard_ptr() == NULL) {
-    // The typical case is first.
-    release_stable_list_fast_path(self);
-    return;
-  }
-
-  // The nested case is rare.
-  release_stable_list_nested_path(self);
-}
-
-// Fast path way to release a stable ThreadsList. The release portion
-// is lock-free, but the wake up portion is not.
-//
-void Threads::release_stable_list_fast_path(Thread *self) {
-  assert(self != NULL, "sanity check");
-  assert(self->get_threads_hazard_ptr() != NULL, "sanity check");
-  assert(self->get_nested_threads_hazard_ptr() == NULL,
-         "cannot have a nested hazard ptr when releasing a regular hazard ptr");
-
-  // After releasing the hazard ptr, other threads may go ahead and
-  // free up some memory temporarily used by a ThreadsList snapshot.
-  self->set_threads_hazard_ptr(NULL);
-
-  // We use double-check locking to reduce traffic on the system
-  // wide smr_delete_lock.
-  if (Threads::smr_delete_notify()) {
-    // An exiting thread might be waiting in smr_delete(); we need to
-    // check with smr_delete_lock to be sure.
-    release_stable_list_wake_up((char *) "regular hazard ptr");
-  }
-}
-
-// Release a nested stable ThreadsList; this is rare so it uses
-// Threads_lock.
-//
-void Threads::release_stable_list_nested_path(Thread *self) {
-  assert(self != NULL, "sanity check");
-  assert(self->get_nested_threads_hazard_ptr() != NULL, "sanity check");
-  assert(self->get_threads_hazard_ptr() != NULL,
-         "must have a regular hazard ptr to have nested hazard ptrs");
-
-  // We have a nested ThreadsListHandle so we have to release it first.
-  // The need for a nested ThreadsListHandle is rare so we do this while
-  // holding the Threads_lock so we don't race with the scanning code;
-  // the code is so much simpler this way.
-
-  NestedThreadsList *node;
-  {
-    // Only grab the Threads_lock if we don't already own it.
-    MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
-    // We remove from the front of the list to match up with the insert
-    // in acquire_stable_list().
-    node = self->get_nested_threads_hazard_ptr();
-    self->set_nested_threads_hazard_ptr(node->next());
-    if (EnableThreadSMRStatistics) {
-      self->dec_nested_threads_hazard_ptr_cnt();
-    }
-  }
-
-  // An exiting thread might be waiting in smr_delete(); we need to
-  // check with smr_delete_lock to be sure.
-  release_stable_list_wake_up((char *) "nested hazard ptr");
-
-  log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::release_stable_list: delete NestedThreadsList node containing ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(node->t_list()));
-
-  delete node;
-}
-
-// Wake up portion of the release stable ThreadsList protocol;
-// uses the smr_delete_lock().
-//
-void Threads::release_stable_list_wake_up(char *log_str) {
-  assert(log_str != NULL, "sanity check");
-
-  // Note: smr_delete_lock is held in smr_delete() for the entire
-  // hazard ptr search so that we do not lose this notify() if
-  // the exiting thread has to wait. That code path also holds
-  // Threads_lock (which was grabbed before smr_delete_lock) so that
-  // threads_do() can be called. This means the system can't start a
-  // safepoint which means this thread can't take too long to get to
-  // a safepoint because of being blocked on smr_delete_lock.
-  //
-  MonitorLockerEx ml(Threads::smr_delete_lock(), Monitor::_no_safepoint_check_flag);
-  if (Threads::smr_delete_notify()) {
-    // Notify any exiting JavaThreads that are waiting in smr_delete()
-    // that we've released a ThreadsList.
-    ml.notify_all();
-    log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::release_stable_list notified %s", os::current_thread_id(), log_str);
-  }
-}
-
-inline void Threads::update_smr_deleted_thread_time_max(uint new_value) {
-  while (true) {
-    uint cur_value = _smr_deleted_thread_time_max;
-    if (new_value <= cur_value) {
-      // No need to update max value so we're done.
-      break;
-    }
-    if (Atomic::cmpxchg(new_value, &_smr_deleted_thread_time_max, cur_value) == cur_value) {
-      // Updated max value so we're done. Otherwise try it all again.
-      break;
-    }
-  }
-}
-
-inline ThreadsList* Threads::xchg_smr_java_thread_list(ThreadsList* new_list) {
-  return (ThreadsList*)Atomic::xchg(new_list, &_smr_java_thread_list);
-}
-
 void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) {
   TraceTime timer("Initialize java.lang classes", TRACETIME_LOG(Info, startuptime));
 
@@ -4666,501 +4339,6 @@
   return JNI_FALSE;
 }
 
-// Hash table of pointers found by a scan. Used for collecting hazard
-// pointers (ThreadsList references). Also used for collecting JavaThreads
-// that are indirectly referenced by hazard ptrs. An instance of this
-// class only contains one type of pointer.
-//
-class ThreadScanHashtable : public CHeapObj<mtThread> {
- private:
-  static bool ptr_equals(void * const& s1, void * const& s2) {
-    return s1 == s2;
-  }
-
-  static unsigned int ptr_hash(void * const& s1) {
-    // 2654435761 = 2^32 * Phi (golden ratio)
-    return (unsigned int)(((uint32_t)(uintptr_t)s1) * 2654435761u);
-  }
-
-  int _table_size;
-  // ResourceHashtable SIZE is specified at compile time so our
-  // dynamic _table_size is unused for now; 1031 is the first prime
-  // after 1024.
-  typedef ResourceHashtable<void *, int, &ThreadScanHashtable::ptr_hash,
-                            &ThreadScanHashtable::ptr_equals, 1031,
-                            ResourceObj::C_HEAP, mtThread> PtrTable;
-  PtrTable * _ptrs;
-
- public:
-  // ResourceHashtable is passed to various functions and populated in
-  // different places so we allocate it using C_HEAP to make it immune
-  // from any ResourceMarks that happen to be in the code paths.
-  ThreadScanHashtable(int table_size) : _table_size(table_size), _ptrs(new (ResourceObj::C_HEAP, mtThread) PtrTable()) {}
-
-  ~ThreadScanHashtable() { delete _ptrs; }
-
-  bool has_entry(void *pointer) {
-    int *val_ptr = _ptrs->get(pointer);
-    return val_ptr != NULL && *val_ptr == 1;
-  }
-
-  void add_entry(void *pointer) {
-    _ptrs->put(pointer, 1);
-  }
-};
-
-// Closure to gather JavaThreads indirectly referenced by hazard ptrs
-// (ThreadsList references) into a hash table. This closure handles part 2
-// of the dance - adding all the JavaThreads referenced by the hazard
-// pointer (ThreadsList reference) to the hash table.
-//
-class AddThreadHazardPointerThreadClosure : public ThreadClosure {
- private:
-  ThreadScanHashtable *_table;
-
- public:
-  AddThreadHazardPointerThreadClosure(ThreadScanHashtable *table) : _table(table) {}
-
-  virtual void do_thread(Thread *thread) {
-    if (!_table->has_entry((void*)thread)) {
-      // The same JavaThread might be on more than one ThreadsList or
-      // more than one thread might be using the same ThreadsList. In
-      // either case, we only need a single entry for a JavaThread.
-      _table->add_entry((void*)thread);
-    }
-  }
-};
-
-// Closure to gather JavaThreads indirectly referenced by hazard ptrs
-// (ThreadsList references) into a hash table. This closure handles part 1
-// of the dance - hazard ptr chain walking and dispatch to another
-// closure.
-//
-class ScanHazardPtrGatherProtectedThreadsClosure : public ThreadClosure {
- private:
-  ThreadScanHashtable *_table;
- public:
-  ScanHazardPtrGatherProtectedThreadsClosure(ThreadScanHashtable *table) : _table(table) {}
-
-  virtual void do_thread(Thread *thread) {
-    assert_locked_or_safepoint(Threads_lock);
-
-    if (thread == NULL) return;
-
-    // This code races with Threads::acquire_stable_list() which is
-    // lock-free so we have to handle some special situations.
-    //
-    ThreadsList *current_list = NULL;
-    while (true) {
-      current_list = thread->get_threads_hazard_ptr();
-      // No hazard ptr so nothing more to do.
-      if (current_list == NULL) {
-        assert(thread->get_nested_threads_hazard_ptr() == NULL,
-               "cannot have a nested hazard ptr with a NULL regular hazard ptr");
-        return;
-      }
-
-      // If the hazard ptr is verified as stable (since it is not tagged),
-      // then it is safe to use.
-      if (!Thread::is_hazard_ptr_tagged(current_list)) break;
-
-      // The hazard ptr is tagged as not yet verified as being stable
-      // so we are racing with acquire_stable_list(). This exchange
-      // attempts to invalidate the hazard ptr. If we win the race,
-      // then we can ignore this unstable hazard ptr and the other
-      // thread will retry the attempt to publish a stable hazard ptr.
-      // If we lose the race, then we retry our attempt to look at the
-      // hazard ptr.
-      if (thread->cmpxchg_threads_hazard_ptr(NULL, current_list) == current_list) return;
-    }
-
-    // The current JavaThread has a hazard ptr (ThreadsList reference)
-    // which might be _smr_java_thread_list or it might be an older
-    // ThreadsList that has been removed but not freed. In either case,
-    // the hazard ptr is protecting all the JavaThreads on that
-    // ThreadsList.
-    AddThreadHazardPointerThreadClosure add_cl(_table);
-    current_list->threads_do(&add_cl);
-
-    // Any NestedThreadsLists are also protecting JavaThreads so
-    // gather those also; the ThreadsLists may be different.
-    for (NestedThreadsList* node = thread->get_nested_threads_hazard_ptr();
-         node != NULL; node = node->next()) {
-      node->t_list()->threads_do(&add_cl);
-    }
-  }
-};
-
-// Closure to print JavaThreads that have a hazard ptr (ThreadsList
-// reference) that contains an indirect reference to a specific JavaThread.
-//
-class ScanHazardPtrPrintMatchingThreadsClosure : public ThreadClosure {
- private:
-  JavaThread *_thread;
- public:
-  ScanHazardPtrPrintMatchingThreadsClosure(JavaThread *thread) : _thread(thread) {}
-
-  virtual void do_thread(Thread *thread) {
-    assert_locked_or_safepoint(Threads_lock);
-
-    if (thread == NULL) return;
-    ThreadsList *current_list = thread->get_threads_hazard_ptr();
-    if (current_list == NULL) {
-      assert(thread->get_nested_threads_hazard_ptr() == NULL,
-             "cannot have a nested hazard ptr with a NULL regular hazard ptr");
-      return;
-    }
-    // If the hazard ptr is unverified, then ignore it.
-    if (Thread::is_hazard_ptr_tagged(current_list)) return;
-
-    // The current JavaThread has a hazard ptr (ThreadsList reference)
-    // which might be _smr_java_thread_list or it might be an older
-    // ThreadsList that has been removed but not freed. In either case,
-    // the hazard ptr is protecting all the JavaThreads on that
-    // ThreadsList, but we only care about matching a specific JavaThread.
-    DO_JAVA_THREADS(current_list, p) {
-      if (p == _thread) {
-        log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::smr_delete: thread1=" INTPTR_FORMAT " has a hazard pointer for thread2=" INTPTR_FORMAT, os::current_thread_id(), p2i(thread), p2i(_thread));
-        break;
-      }
-    }
-
-    // Any NestedThreadsLists are also protecting JavaThreads so
-    // check those also; the ThreadsLists may be different.
-    for (NestedThreadsList* node = thread->get_nested_threads_hazard_ptr();
-         node != NULL; node = node->next()) {
-      DO_JAVA_THREADS(node->t_list(), p) {
-        if (p == _thread) {
-          log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::smr_delete: thread1=" INTPTR_FORMAT " has a nested hazard pointer for thread2=" INTPTR_FORMAT, os::current_thread_id(), p2i(thread), p2i(_thread));
-          return;
-        }
-      }
-    }
-  }
-};
-
-// Return true if the specified JavaThread is protected by a hazard
-// pointer (ThreadsList reference). Otherwise, returns false.
-//
-bool Threads::is_a_protected_JavaThread(JavaThread *thread) {
-  assert_locked_or_safepoint(Threads_lock);
-
-  // Hash table size should be first power of two higher than twice
-  // the length of the Threads list.
-  int hash_table_size = MIN2(_number_of_threads, 32) << 1;
-  hash_table_size--;
-  hash_table_size |= hash_table_size >> 1;
-  hash_table_size |= hash_table_size >> 2;
-  hash_table_size |= hash_table_size >> 4;
-  hash_table_size |= hash_table_size >> 8;
-  hash_table_size |= hash_table_size >> 16;
-  hash_table_size++;
-
-  // Gather a hash table of the JavaThreads indirectly referenced by
-  // hazard ptrs.
-  ThreadScanHashtable *scan_table = new ThreadScanHashtable(hash_table_size);
-  ScanHazardPtrGatherProtectedThreadsClosure scan_cl(scan_table);
-  Threads::threads_do(&scan_cl);
-
-  bool thread_is_protected = false;
-  if (scan_table->has_entry((void*)thread)) {
-    thread_is_protected = true;
-  }
-  delete scan_table;
-  return thread_is_protected;
-}
-
-// Safely delete a JavaThread when it is no longer in use by a
-// ThreadsListHandle.
-//
-void Threads::smr_delete(JavaThread *thread) {
-  assert(!Threads_lock->owned_by_self(), "sanity");
-
-  bool has_logged_once = false;
-  elapsedTimer timer;
-  if (EnableThreadSMRStatistics) {
-    timer.start();
-  }
-
-  while (true) {
-    {
-      // No safepoint check because this JavaThread is not on the
-      // Threads list.
-      MutexLockerEx ml(Threads_lock, Mutex::_no_safepoint_check_flag);
-      // Cannot use a MonitorLockerEx helper here because we have
-      // to drop the Threads_lock first if we wait.
-      Threads::smr_delete_lock()->lock_without_safepoint_check();
-      // Set the smr_delete_notify flag after we grab smr_delete_lock
-      // and before we scan hazard ptrs because we're doing
-      // double-check locking in release_stable_list().
-      Threads::set_smr_delete_notify();
-
-      if (!is_a_protected_JavaThread(thread)) {
-        // This is the common case.
-        Threads::clear_smr_delete_notify();
-        Threads::smr_delete_lock()->unlock();
-        break;
-      }
-      if (!has_logged_once) {
-        has_logged_once = true;
-        log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::smr_delete: thread=" INTPTR_FORMAT " is not deleted.", os::current_thread_id(), p2i(thread));
-        if (log_is_enabled(Debug, os, thread)) {
-          ScanHazardPtrPrintMatchingThreadsClosure scan_cl(thread);
-          Threads::threads_do(&scan_cl);
-        }
-      }
-    } // We have to drop the Threads_lock to wait or delete the thread
-
-    if (EnableThreadSMRStatistics) {
-      _smr_delete_lock_wait_cnt++;
-      if (_smr_delete_lock_wait_cnt > _smr_delete_lock_wait_max) {
-        _smr_delete_lock_wait_max = _smr_delete_lock_wait_cnt;
-      }
-    }
-    // Wait for a release_stable_list() call before we check again. No
-    // safepoint check, no timeout, and not as suspend equivalent flag
-    // because this JavaThread is not on the Threads list.
-    Threads::smr_delete_lock()->wait(Mutex::_no_safepoint_check_flag, 0,
-                                     !Mutex::_as_suspend_equivalent_flag);
-    if (EnableThreadSMRStatistics) {
-      _smr_delete_lock_wait_cnt--;
-    }
-
-    Threads::clear_smr_delete_notify();
-    Threads::smr_delete_lock()->unlock();
-    // Retry the whole scenario.
-  }
-
-  if (ThreadLocalHandshakes) {
-    // The thread is about to be deleted so cancel any handshake.
-    thread->cancel_handshake();
-  }
-
-  delete thread;
-  if (EnableThreadSMRStatistics) {
-    timer.stop();
-    uint millis = (uint)timer.milliseconds();
-    Threads::inc_smr_deleted_thread_cnt();
-    Threads::add_smr_deleted_thread_times(millis);
-    Threads::update_smr_deleted_thread_time_max(millis);
-  }
-
-  log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::smr_delete: thread=" INTPTR_FORMAT " is deleted.", os::current_thread_id(), p2i(thread));
-}
-
-bool Threads::smr_delete_notify() {
-  // Use load_acquire() in order to see any updates to _smr_delete_notify
-  // earlier than when smr_delete_lock is grabbed.
-  return (OrderAccess::load_acquire(&_smr_delete_notify) != 0);
-}
-
-// set_smr_delete_notify() and clear_smr_delete_notify() are called
-// under the protection of the smr_delete_lock, but we also use an
-// Atomic operation to ensure the memory update is seen earlier than
-// when the smr_delete_lock is dropped.
-//
-void Threads::set_smr_delete_notify() {
-  Atomic::inc(&_smr_delete_notify);
-}
-
-void Threads::clear_smr_delete_notify() {
-  Atomic::dec(&_smr_delete_notify);
-}
-
-// Closure to gather hazard ptrs (ThreadsList references) into a hash table.
-//
-class ScanHazardPtrGatherThreadsListClosure : public ThreadClosure {
- private:
-  ThreadScanHashtable *_table;
- public:
-  ScanHazardPtrGatherThreadsListClosure(ThreadScanHashtable *table) : _table(table) {}
-
-  virtual void do_thread(Thread* thread) {
-    assert_locked_or_safepoint(Threads_lock);
-
-    if (thread == NULL) return;
-    ThreadsList *threads = thread->get_threads_hazard_ptr();
-    if (threads == NULL) {
-      assert(thread->get_nested_threads_hazard_ptr() == NULL,
-             "cannot have a nested hazard ptr with a NULL regular hazard ptr");
-      return;
-    }
-    // In this closure we always ignore the tag that might mark this
-    // hazard ptr as not yet verified. If we happen to catch an
-    // unverified hazard ptr that is subsequently discarded (not
-    // published), then the only side effect is that we might keep a
-    // to-be-deleted ThreadsList alive a little longer.
-    threads = Thread::untag_hazard_ptr(threads);
-    if (!_table->has_entry((void*)threads)) {
-      _table->add_entry((void*)threads);
-    }
-
-    // Any NestedThreadsLists are also protecting JavaThreads so
-    // gather those also; the ThreadsLists may be different.
-    for (NestedThreadsList* node = thread->get_nested_threads_hazard_ptr();
-         node != NULL; node = node->next()) {
-      threads = node->t_list();
-      if (!_table->has_entry((void*)threads)) {
-        _table->add_entry((void*)threads);
-      }
-    }
-  }
-};
-
-// Safely free a ThreadsList after a Threads::add() or Threads::remove().
-// The specified ThreadsList may not get deleted during this call if it
-// is still in-use (referenced by a hazard ptr). Other ThreadsLists
-// in the chain may get deleted by this call if they are no longer in-use.
-void Threads::smr_free_list(ThreadsList* threads) {
-  assert_locked_or_safepoint(Threads_lock);
-
-  threads->set_next_list(_smr_to_delete_list);
-  _smr_to_delete_list = threads;
-  if (EnableThreadSMRStatistics) {
-    _smr_to_delete_list_cnt++;
-    if (_smr_to_delete_list_cnt > _smr_to_delete_list_max) {
-      _smr_to_delete_list_max = _smr_to_delete_list_cnt;
-    }
-  }
-
-  // Hash table size should be first power of two higher than twice the length of the ThreadsList
-  int hash_table_size = MIN2(_number_of_threads, 32) << 1;
-  hash_table_size--;
-  hash_table_size |= hash_table_size >> 1;
-  hash_table_size |= hash_table_size >> 2;
-  hash_table_size |= hash_table_size >> 4;
-  hash_table_size |= hash_table_size >> 8;
-  hash_table_size |= hash_table_size >> 16;
-  hash_table_size++;
-
-  // Gather a hash table of the current hazard ptrs:
-  ThreadScanHashtable *scan_table = new ThreadScanHashtable(hash_table_size);
-  ScanHazardPtrGatherThreadsListClosure scan_cl(scan_table);
-  Threads::threads_do(&scan_cl);
-
-  // Walk through the linked list of pending freeable ThreadsLists
-  // and free the ones that are not referenced from hazard ptrs.
-  ThreadsList* current = _smr_to_delete_list;
-  ThreadsList* prev = NULL;
-  ThreadsList* next = NULL;
-  bool threads_is_freed = false;
-  while (current != NULL) {
-    next = current->next_list();
-    if (!scan_table->has_entry((void*)current)) {
-      // This ThreadsList is not referenced by a hazard ptr.
-      if (prev != NULL) {
-        prev->set_next_list(next);
-      }
-      if (_smr_to_delete_list == current) {
-        _smr_to_delete_list = next;
-      }
-
-      log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::smr_free_list: threads=" INTPTR_FORMAT " is freed.", os::current_thread_id(), p2i(current));
-      if (current == threads) threads_is_freed = true;
-      delete current;
-      if (EnableThreadSMRStatistics) {
-        _smr_java_thread_list_free_cnt++;
-        _smr_to_delete_list_cnt--;
-      }
-    } else {
-      prev = current;
-    }
-    current = next;
-  }
-
-  if (!threads_is_freed) {
-    // Only report "is not freed" on the original call to
-    // smr_free_list() for this ThreadsList.
-    log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::smr_free_list: threads=" INTPTR_FORMAT " is not freed.", os::current_thread_id(), p2i(threads));
-  }
-
-  delete scan_table;
-}
-
-// Remove a JavaThread from a ThreadsList. The returned ThreadsList is a
-// new copy of the specified ThreadsList with the specified JavaThread
-// removed.
-ThreadsList *ThreadsList::remove_thread(ThreadsList* list, JavaThread* java_thread) {
-  assert(list->_length > 0, "sanity");
-
-  uint i = 0;
-  DO_JAVA_THREADS(list, current) {
-    if (current == java_thread) {
-      break;
-    }
-    i++;
-  }
-  assert(i < list->_length, "did not find JavaThread on the list");
-  const uint index = i;
-  const uint new_length = list->_length - 1;
-  const uint head_length = index;
-  const uint tail_length = (new_length >= index) ? (new_length - index) : 0;
-  ThreadsList *const new_list = new ThreadsList(new_length);
-
-  if (head_length > 0) {
-    Copy::disjoint_words((HeapWord*)list->_threads, (HeapWord*)new_list->_threads, head_length);
-  }
-  if (tail_length > 0) {
-    Copy::disjoint_words((HeapWord*)list->_threads + index + 1, (HeapWord*)new_list->_threads + index, tail_length);
-  }
-
-  return new_list;
-}
-
-// Add a JavaThread to a ThreadsList. The returned ThreadsList is a
-// new copy of the specified ThreadsList with the specified JavaThread
-// appended to the end.
-ThreadsList *ThreadsList::add_thread(ThreadsList *list, JavaThread *java_thread) {
-  const uint index = list->_length;
-  const uint new_length = index + 1;
-  const uint head_length = index;
-  ThreadsList *const new_list = new ThreadsList(new_length);
-
-  if (head_length > 0) {
-    Copy::disjoint_words((HeapWord*)list->_threads, (HeapWord*)new_list->_threads, head_length);
-  }
-  *(JavaThread**)(new_list->_threads + index) = java_thread;
-
-  return new_list;
-}
-
-int ThreadsList::find_index_of_JavaThread(JavaThread *target) {
-  if (target == NULL) {
-    return -1;
-  }
-  for (uint i = 0; i < length(); i++) {
-    if (target == thread_at(i)) {
-      return (int)i;
-    }
-  }
-  return -1;
-}
-
-JavaThread* ThreadsList::find_JavaThread_from_java_tid(jlong java_tid) const {
-  DO_JAVA_THREADS(this, thread) {
-    oop tobj = thread->threadObj();
-    // Ignore the thread if it hasn't run yet, has exited
-    // or is starting to exit.
-    if (tobj != NULL && !thread->is_exiting() &&
-        java_tid == java_lang_Thread::thread_id(tobj)) {
-      // found a match
-      return thread;
-    }
-  }
-  return NULL;
-}
-
-bool ThreadsList::includes(const JavaThread * const p) const {
-  if (p == NULL) {
-    return false;
-  }
-  DO_JAVA_THREADS(this, q) {
-    if (q == p) {
-      return true;
-    }
-  }
-  return false;
-}
 
 void Threads::add(JavaThread* p, bool force_daemon) {
   // The threads lock must be owned at this point
@@ -5189,18 +4367,7 @@
   ThreadService::add_thread(p, daemon);
 
   // Maintain fast thread list
-  ThreadsList *new_list = ThreadsList::add_thread(get_smr_java_thread_list(), p);
-  if (EnableThreadSMRStatistics) {
-    _smr_java_thread_list_alloc_cnt++;
-    if (new_list->length() > _smr_java_thread_list_max) {
-      _smr_java_thread_list_max = new_list->length();
-    }
-  }
-  // Initial _smr_java_thread_list will not generate a "Threads::add" mesg.
-  log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::add: new ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(new_list));
-
-  ThreadsList *old_list = xchg_smr_java_thread_list(new_list);
-  smr_free_list(old_list);
+  ThreadsSMRSupport::add_thread(p);
 
   // Possible GC point.
   Events::log(p, "Thread added: " INTPTR_FORMAT, p2i(p));
@@ -5215,20 +4382,10 @@
   // that we do not remove thread without safepoint code notice
   { MutexLocker ml(Threads_lock);
 
-    assert(get_smr_java_thread_list()->includes(p), "p must be present");
+    assert(ThreadsSMRSupport::get_smr_java_thread_list()->includes(p), "p must be present");
 
     // Maintain fast thread list
-    ThreadsList *new_list = ThreadsList::remove_thread(get_smr_java_thread_list(), p);
-    if (EnableThreadSMRStatistics) {
-      _smr_java_thread_list_alloc_cnt++;
-      // This list is smaller so no need to check for a "longest" update.
-    }
-
-    // Final _smr_java_thread_list will not generate a "Threads::remove" mesg.
-    log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::remove: new ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(new_list));
-
-    ThreadsList *old_list = xchg_smr_java_thread_list(new_list);
-    smr_free_list(old_list);
+    ThreadsSMRSupport::remove_thread(p);
 
     JavaThread* current = _thread_list;
     JavaThread* prev    = NULL;
@@ -5453,7 +4610,7 @@
   }
 #endif // INCLUDE_SERVICES
 
-  print_smr_info_on(st);
+  ThreadsSMRSupport::print_smr_info_on(st);
   st->cr();
 
   ALL_JAVA_THREADS(p) {
@@ -5486,101 +4643,6 @@
   st->flush();
 }
 
-// Log Threads class SMR info.
-void Threads::log_smr_statistics() {
-  LogTarget(Info, thread, smr) log;
-  if (log.is_enabled()) {
-    LogStream out(log);
-    print_smr_info_on(&out);
-  }
-}
-
-// Print Threads class SMR info.
-void Threads::print_smr_info_on(outputStream* st) {
-  // Only grab the Threads_lock if we don't already own it
-  // and if we are not reporting an error.
-  MutexLockerEx ml((Threads_lock->owned_by_self() || VMError::is_error_reported()) ? NULL : Threads_lock);
-
-  st->print_cr("Threads class SMR info:");
-  st->print_cr("_smr_java_thread_list=" INTPTR_FORMAT ", length=%u, "
-               "elements={", p2i(_smr_java_thread_list),
-               _smr_java_thread_list->length());
-  print_smr_info_elements_on(st, _smr_java_thread_list);
-  st->print_cr("}");
-  if (_smr_to_delete_list != NULL) {
-    st->print_cr("_smr_to_delete_list=" INTPTR_FORMAT ", length=%u, "
-                 "elements={", p2i(_smr_to_delete_list),
-                 _smr_to_delete_list->length());
-    print_smr_info_elements_on(st, _smr_to_delete_list);
-    st->print_cr("}");
-    for (ThreadsList *t_list = _smr_to_delete_list->next_list();
-         t_list != NULL; t_list = t_list->next_list()) {
-      st->print("next-> " INTPTR_FORMAT ", length=%u, "
-                "elements={", p2i(t_list), t_list->length());
-      print_smr_info_elements_on(st, t_list);
-      st->print_cr("}");
-    }
-  }
-  if (!EnableThreadSMRStatistics) {
-    return;
-  }
-  st->print_cr("_smr_java_thread_list_alloc_cnt=" UINT64_FORMAT ","
-               "_smr_java_thread_list_free_cnt=" UINT64_FORMAT ","
-               "_smr_java_thread_list_max=%u, "
-               "_smr_nested_thread_list_max=%u",
-               _smr_java_thread_list_alloc_cnt,
-               _smr_java_thread_list_free_cnt,
-               _smr_java_thread_list_max,
-               _smr_nested_thread_list_max);
-  if (_smr_tlh_cnt > 0) {
-    st->print_cr("_smr_tlh_cnt=%u"
-                 ", _smr_tlh_times=%u"
-                 ", avg_smr_tlh_time=%0.2f"
-                 ", _smr_tlh_time_max=%u",
-                 _smr_tlh_cnt, _smr_tlh_times,
-                 ((double) _smr_tlh_times / _smr_tlh_cnt),
-                 _smr_tlh_time_max);
-  }
-  if (_smr_deleted_thread_cnt > 0) {
-    st->print_cr("_smr_deleted_thread_cnt=%u"
-                 ", _smr_deleted_thread_times=%u"
-                 ", avg_smr_deleted_thread_time=%0.2f"
-                 ", _smr_deleted_thread_time_max=%u",
-                 _smr_deleted_thread_cnt, _smr_deleted_thread_times,
-                 ((double) _smr_deleted_thread_times / _smr_deleted_thread_cnt),
-                 _smr_deleted_thread_time_max);
-  }
-  st->print_cr("_smr_delete_lock_wait_cnt=%u, _smr_delete_lock_wait_max=%u",
-               _smr_delete_lock_wait_cnt, _smr_delete_lock_wait_max);
-  st->print_cr("_smr_to_delete_list_cnt=%u, _smr_to_delete_list_max=%u",
-               _smr_to_delete_list_cnt, _smr_to_delete_list_max);
-}
-
-// Print ThreadsList elements (4 per line).
-void Threads::print_smr_info_elements_on(outputStream* st,
-                                         ThreadsList* t_list) {
-  uint cnt = 0;
-  JavaThreadIterator jti(t_list);
-  for (JavaThread *jt = jti.first(); jt != NULL; jt = jti.next()) {
-    st->print(INTPTR_FORMAT, p2i(jt));
-    if (cnt < t_list->length() - 1) {
-      // Separate with comma or comma-space except for the last one.
-      if (((cnt + 1) % 4) == 0) {
-        // Four INTPTR_FORMAT fit on an 80 column line so end the
-        // current line with just a comma.
-        st->print_cr(",");
-      } else {
-        // Not the last one on the current line so use comma-space:
-        st->print(", ");
-      }
-    } else {
-      // Last one so just end the current line.
-      st->cr();
-    }
-    cnt++;
-  }
-}
-
 void Threads::print_on_error(Thread* this_thread, outputStream* st, Thread* current, char* buf,
                              int buflen, bool* found_current) {
   if (this_thread != NULL) {
@@ -5617,7 +4679,7 @@
 // memory (even in resource area), it might deadlock the error handler.
 void Threads::print_on_error(outputStream* st, Thread* current, char* buf,
                              int buflen) {
-  print_smr_info_on(st);
+  ThreadsSMRSupport::print_smr_info_on(st);
   st->cr();
 
   bool found_current = false;
--- a/src/hotspot/share/runtime/thread.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/runtime/thread.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -58,6 +58,7 @@
 
 class ThreadSafepointState;
 class ThreadsList;
+class ThreadsSMRSupport;
 class NestedThreadsList;
 
 class JvmtiThreadState;
@@ -103,7 +104,6 @@
 //   - WatcherThread
 
 class Thread: public ThreadShadow {
-  friend class Threads;
   friend class VMStructs;
   friend class JVMCIVMStructs;
  private:
@@ -121,12 +121,14 @@
  protected:
   // Support for forcing alignment of thread objects for biased locking
   void*       _real_malloc_address;
+
   // JavaThread lifecycle support:
-  friend class ScanHazardPtrGatherProtectedThreadsClosure;
-  friend class ScanHazardPtrGatherThreadsListClosure;
-  friend class ScanHazardPtrPrintMatchingThreadsClosure;
-  friend class ThreadsListHandle;
-  friend class ThreadsListSetter;
+  friend class ScanHazardPtrGatherProtectedThreadsClosure;  // for cmpxchg_threads_hazard_ptr(), get_threads_hazard_ptr(), is_hazard_ptr_tagged() access
+  friend class ScanHazardPtrGatherThreadsListClosure;  // for get_nested_threads_hazard_ptr(), get_threads_hazard_ptr(), untag_hazard_ptr() access
+  friend class ScanHazardPtrPrintMatchingThreadsClosure;  // for get_threads_hazard_ptr(), is_hazard_ptr_tagged() access
+  friend class ThreadsListSetter;  // for get_threads_hazard_ptr() access
+  friend class ThreadsSMRSupport;  // for get_threads_hazard_ptr() access
+
   ThreadsList* volatile _threads_hazard_ptr;
   ThreadsList*          cmpxchg_threads_hazard_ptr(ThreadsList* exchange_value, ThreadsList* compare_value);
   ThreadsList*          get_threads_hazard_ptr();
@@ -2126,62 +2128,18 @@
 class Threads: AllStatic {
   friend class VMStructs;
  private:
-  // Safe Memory Reclamation (SMR) support:
-  // The coordination between Threads::release_stable_list() and
-  // Threads::smr_delete() uses the smr_delete_lock in order to
-  // reduce the traffic on the Threads_lock.
-  static Monitor*              _smr_delete_lock;
-  // The '_cnt', '_max' and '_times" fields are enabled via
-  // -XX:+EnableThreadSMRStatistics (see thread.cpp for a
-  // description about each field):
-  static uint                  _smr_delete_lock_wait_cnt;
-  static uint                  _smr_delete_lock_wait_max;
-  // The smr_delete_notify flag is used for proper double-check
-  // locking in order to reduce the traffic on the smr_delete_lock.
-  static volatile uint         _smr_delete_notify;
-  static volatile uint         _smr_deleted_thread_cnt;
-  static volatile uint         _smr_deleted_thread_time_max;
-  static volatile uint         _smr_deleted_thread_times;
-  static ThreadsList* volatile _smr_java_thread_list;
-  static uint64_t              _smr_java_thread_list_alloc_cnt;
-  static uint64_t              _smr_java_thread_list_free_cnt;
-  static uint                  _smr_java_thread_list_max;
-  static uint                  _smr_nested_thread_list_max;
-  static volatile uint         _smr_tlh_cnt;
-  static volatile uint         _smr_tlh_time_max;
-  static volatile uint         _smr_tlh_times;
-  static ThreadsList*          _smr_to_delete_list;
-  static uint                  _smr_to_delete_list_cnt;
-  static uint                  _smr_to_delete_list_max;
-
-  static JavaThread*           _thread_list;
-  static int                   _number_of_threads;
-  static int                   _number_of_non_daemon_threads;
-  static int                   _return_code;
-  static int                   _thread_claim_parity;
+  static JavaThread* _thread_list;
+  static int         _number_of_threads;
+  static int         _number_of_non_daemon_threads;
+  static int         _return_code;
+  static int         _thread_claim_parity;
 #ifdef ASSERT
-  static bool                  _vm_complete;
+  static bool        _vm_complete;
 #endif
 
   static void initialize_java_lang_classes(JavaThread* main_thread, TRAPS);
   static void initialize_jsr292_core_classes(TRAPS);
 
-  static ThreadsList *acquire_stable_list_fast_path(Thread *self);
-  static ThreadsList *acquire_stable_list_nested_path(Thread *self);
-  static void add_smr_deleted_thread_times(uint add_value);
-  static void clear_smr_delete_notify();
-  static ThreadsList* get_smr_java_thread_list();
-  static void inc_smr_deleted_thread_cnt();
-  static void release_stable_list_fast_path(Thread *self);
-  static void release_stable_list_nested_path(Thread *self);
-  static void release_stable_list_wake_up(char *log_str);
-  static void set_smr_delete_notify();
-  static Monitor* smr_delete_lock() { return _smr_delete_lock; }
-  static bool smr_delete_notify();
-  static void smr_free_list(ThreadsList* threads);
-  static void update_smr_deleted_thread_time_max(uint new_value);
-  static ThreadsList* xchg_smr_java_thread_list(ThreadsList* new_list);
-
  public:
   // Thread management
   // force_daemon is a concession to JNI, where we may need to add a
@@ -2191,19 +2149,6 @@
   static void threads_do(ThreadClosure* tc);
   static void possibly_parallel_threads_do(bool is_par, ThreadClosure* tc);
 
-  // SMR support:
-  static ThreadsList *acquire_stable_list(Thread *self, bool is_ThreadsListSetter);
-  static void release_stable_list(Thread *self);
-  static bool is_a_protected_JavaThread(JavaThread *thread);
-  static bool is_a_protected_JavaThread_with_lock(JavaThread *thread) {
-    MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
-    return is_a_protected_JavaThread(thread);
-  }
-  static void smr_delete(JavaThread *thread);
-  static void inc_smr_tlh_cnt();
-  static void update_smr_tlh_time_max(uint new_value);
-  static void add_smr_tlh_times(uint add_value);
-
   // Initializes the vm and creates the vm thread
   static jint create_vm(JavaVMInitArgs* args, bool* canTryAgain);
   static void convert_vm_init_libraries_to_agents();
@@ -2264,10 +2209,7 @@
 
   // Verification
   static void verify();
-  static void log_smr_statistics();
   static void print_on(outputStream* st, bool print_stacks, bool internal_format, bool print_concurrent_locks);
-  static void print_smr_info_on(outputStream* st);
-  static void print_smr_info_elements_on(outputStream* st, ThreadsList* t_list);
   static void print(bool print_stacks, bool internal_format) {
     // this function is only used by debug.cpp
     print_on(tty, print_stacks, internal_format, false /* no concurrent lock printed */);
--- a/src/hotspot/share/runtime/thread.inline.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/runtime/thread.inline.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -28,7 +28,6 @@
 #include "runtime/atomic.hpp"
 #include "runtime/os.inline.hpp"
 #include "runtime/thread.hpp"
-#include "runtime/threadSMR.hpp"
 
 inline void Thread::set_suspend_flag(SuspendFlags f) {
   assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch");
@@ -212,26 +211,4 @@
   OrderAccess::release_store((volatile jint *) &_terminated, (jint) _thread_terminated);
 }
 
-inline void Threads::add_smr_tlh_times(uint add_value) {
-  Atomic::add(add_value, &_smr_tlh_times);
-}
-
-inline void Threads::inc_smr_tlh_cnt() {
-  Atomic::inc(&_smr_tlh_cnt);
-}
-
-inline void Threads::update_smr_tlh_time_max(uint new_value) {
-  while (true) {
-    uint cur_value = _smr_tlh_time_max;
-    if (new_value <= cur_value) {
-      // No need to update max value so we're done.
-      break;
-    }
-    if (Atomic::cmpxchg(new_value, &_smr_tlh_time_max, cur_value) == cur_value) {
-      // Updated max value so we're done. Otherwise try it all again.
-      break;
-    }
-  }
-}
-
 #endif // SHARE_VM_RUNTIME_THREAD_INLINE_HPP
--- a/src/hotspot/share/runtime/threadSMR.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/runtime/threadSMR.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -23,10 +23,357 @@
  */
 
 #include "precompiled.hpp"
+#include "logging/logStream.hpp"
 #include "memory/allocation.inline.hpp"
 #include "runtime/thread.inline.hpp"
-#include "runtime/threadSMR.hpp"
+#include "runtime/threadSMR.inline.hpp"
 #include "services/threadService.hpp"
+#include "utilities/globalDefinitions.hpp"
+#include "utilities/resourceHash.hpp"
+
+Monitor*              ThreadsSMRSupport::_smr_delete_lock =
+                          new Monitor(Monitor::special, "smr_delete_lock",
+                                      false /* allow_vm_block */,
+                                      Monitor::_safepoint_check_never);
+// The '_cnt', '_max' and '_times" fields are enabled via
+// -XX:+EnableThreadSMRStatistics:
+
+// # of parallel threads in _smr_delete_lock->wait().
+// Impl note: Hard to imagine > 64K waiting threads so this could be 16-bit,
+// but there is no nice 16-bit _FORMAT support.
+uint                  ThreadsSMRSupport::_smr_delete_lock_wait_cnt = 0;
+
+// Max # of parallel threads in _smr_delete_lock->wait().
+// Impl note: See _smr_delete_lock_wait_cnt note.
+uint                  ThreadsSMRSupport::_smr_delete_lock_wait_max = 0;
+
+// Flag to indicate when an _smr_delete_lock->notify() is needed.
+// Impl note: See _smr_delete_lock_wait_cnt note.
+volatile uint         ThreadsSMRSupport::_smr_delete_notify = 0;
+
+// # of threads deleted over VM lifetime.
+// Impl note: Atomically incremented over VM lifetime so use unsigned for more
+// range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc
+// isn't available everywhere (or is it?).
+volatile uint         ThreadsSMRSupport::_smr_deleted_thread_cnt = 0;
+
+// Max time in millis to delete a thread.
+// Impl note: 16-bit might be too small on an overloaded machine. Use
+// unsigned since this is a time value. Set via Atomic::cmpxchg() in a
+// loop for correctness.
+volatile uint         ThreadsSMRSupport::_smr_deleted_thread_time_max = 0;
+
+// Cumulative time in millis to delete threads.
+// Impl note: Atomically added to over VM lifetime so use unsigned for more
+// range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc
+// isn't available everywhere (or is it?).
+volatile uint         ThreadsSMRSupport::_smr_deleted_thread_times = 0;
+
+ThreadsList* volatile ThreadsSMRSupport::_smr_java_thread_list = new ThreadsList(0);
+
+// # of ThreadsLists allocated over VM lifetime.
+// Impl note: We allocate a new ThreadsList for every thread create and
+// every thread delete so we need a bigger type than the
+// _smr_deleted_thread_cnt field.
+uint64_t              ThreadsSMRSupport::_smr_java_thread_list_alloc_cnt = 1;
+
+// # of ThreadsLists freed over VM lifetime.
+// Impl note: See _smr_java_thread_list_alloc_cnt note.
+uint64_t              ThreadsSMRSupport::_smr_java_thread_list_free_cnt = 0;
+
+// Max size ThreadsList allocated.
+// Impl note: Max # of threads alive at one time should fit in unsigned 32-bit.
+uint                  ThreadsSMRSupport::_smr_java_thread_list_max = 0;
+
+// Max # of nested ThreadsLists for a thread.
+// Impl note: Hard to imagine > 64K nested ThreadsLists so this could be
+// 16-bit, but there is no nice 16-bit _FORMAT support.
+uint                  ThreadsSMRSupport::_smr_nested_thread_list_max = 0;
+
+// # of ThreadsListHandles deleted over VM lifetime.
+// Impl note: Atomically incremented over VM lifetime so use unsigned for
+// more range. There will be fewer ThreadsListHandles than threads so
+// unsigned 32-bit should be fine.
+volatile uint         ThreadsSMRSupport::_smr_tlh_cnt = 0;
+
+// Max time in millis to delete a ThreadsListHandle.
+// Impl note: 16-bit might be too small on an overloaded machine. Use
+// unsigned since this is a time value. Set via Atomic::cmpxchg() in a
+// loop for correctness.
+volatile uint         ThreadsSMRSupport::_smr_tlh_time_max = 0;
+
+// Cumulative time in millis to delete ThreadsListHandles.
+// Impl note: Atomically added to over VM lifetime so use unsigned for more
+// range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc
+// isn't available everywhere (or is it?).
+volatile uint         ThreadsSMRSupport::_smr_tlh_times = 0;
+
+ThreadsList*          ThreadsSMRSupport::_smr_to_delete_list = NULL;
+
+// # of parallel ThreadsLists on the to-delete list.
+// Impl note: Hard to imagine > 64K ThreadsLists needing to be deleted so
+// this could be 16-bit, but there is no nice 16-bit _FORMAT support.
+uint                  ThreadsSMRSupport::_smr_to_delete_list_cnt = 0;
+
+// Max # of parallel ThreadsLists on the to-delete list.
+// Impl note: See _smr_to_delete_list_cnt note.
+uint                  ThreadsSMRSupport::_smr_to_delete_list_max = 0;
+
+
+// 'inline' functions first so the definitions are before first use:
+
+inline void ThreadsSMRSupport::add_smr_deleted_thread_times(uint add_value) {
+  Atomic::add(add_value, &_smr_deleted_thread_times);
+}
+
+inline void ThreadsSMRSupport::inc_smr_deleted_thread_cnt() {
+  Atomic::inc(&_smr_deleted_thread_cnt);
+}
+
+inline void ThreadsSMRSupport::inc_smr_java_thread_list_alloc_cnt() {
+  _smr_java_thread_list_alloc_cnt++;
+}
+
+inline void ThreadsSMRSupport::update_smr_deleted_thread_time_max(uint new_value) {
+  while (true) {
+    uint cur_value = _smr_deleted_thread_time_max;
+    if (new_value <= cur_value) {
+      // No need to update max value so we're done.
+      break;
+    }
+    if (Atomic::cmpxchg(new_value, &_smr_deleted_thread_time_max, cur_value) == cur_value) {
+      // Updated max value so we're done. Otherwise try it all again.
+      break;
+    }
+  }
+}
+
+inline void ThreadsSMRSupport::update_smr_java_thread_list_max(uint new_value) {
+  if (new_value > _smr_java_thread_list_max) {
+    _smr_java_thread_list_max = new_value;
+  }
+}
+
+inline ThreadsList* ThreadsSMRSupport::xchg_smr_java_thread_list(ThreadsList* new_list) {
+  return (ThreadsList*)Atomic::xchg(new_list, &_smr_java_thread_list);
+}
+
+
+// Hash table of pointers found by a scan. Used for collecting hazard
+// pointers (ThreadsList references). Also used for collecting JavaThreads
+// that are indirectly referenced by hazard ptrs. An instance of this
+// class only contains one type of pointer.
+//
+class ThreadScanHashtable : public CHeapObj<mtThread> {
+ private:
+  static bool ptr_equals(void * const& s1, void * const& s2) {
+    return s1 == s2;
+  }
+
+  static unsigned int ptr_hash(void * const& s1) {
+    // 2654435761 = 2^32 * Phi (golden ratio)
+    return (unsigned int)(((uint32_t)(uintptr_t)s1) * 2654435761u);
+  }
+
+  int _table_size;
+  // ResourceHashtable SIZE is specified at compile time so our
+  // dynamic _table_size is unused for now; 1031 is the first prime
+  // after 1024.
+  typedef ResourceHashtable<void *, int, &ThreadScanHashtable::ptr_hash,
+                            &ThreadScanHashtable::ptr_equals, 1031,
+                            ResourceObj::C_HEAP, mtThread> PtrTable;
+  PtrTable * _ptrs;
+
+ public:
+  // ResourceHashtable is passed to various functions and populated in
+  // different places so we allocate it using C_HEAP to make it immune
+  // from any ResourceMarks that happen to be in the code paths.
+  ThreadScanHashtable(int table_size) : _table_size(table_size), _ptrs(new (ResourceObj::C_HEAP, mtThread) PtrTable()) {}
+
+  ~ThreadScanHashtable() { delete _ptrs; }
+
+  bool has_entry(void *pointer) {
+    int *val_ptr = _ptrs->get(pointer);
+    return val_ptr != NULL && *val_ptr == 1;
+  }
+
+  void add_entry(void *pointer) {
+    _ptrs->put(pointer, 1);
+  }
+};
+
+// Closure to gather JavaThreads indirectly referenced by hazard ptrs
+// (ThreadsList references) into a hash table. This closure handles part 2
+// of the dance - adding all the JavaThreads referenced by the hazard
+// pointer (ThreadsList reference) to the hash table.
+//
+class AddThreadHazardPointerThreadClosure : public ThreadClosure {
+ private:
+  ThreadScanHashtable *_table;
+
+ public:
+  AddThreadHazardPointerThreadClosure(ThreadScanHashtable *table) : _table(table) {}
+
+  virtual void do_thread(Thread *thread) {
+    if (!_table->has_entry((void*)thread)) {
+      // The same JavaThread might be on more than one ThreadsList or
+      // more than one thread might be using the same ThreadsList. In
+      // either case, we only need a single entry for a JavaThread.
+      _table->add_entry((void*)thread);
+    }
+  }
+};
+
+// Closure to gather JavaThreads indirectly referenced by hazard ptrs
+// (ThreadsList references) into a hash table. This closure handles part 1
+// of the dance - hazard ptr chain walking and dispatch to another
+// closure.
+//
+class ScanHazardPtrGatherProtectedThreadsClosure : public ThreadClosure {
+ private:
+  ThreadScanHashtable *_table;
+ public:
+  ScanHazardPtrGatherProtectedThreadsClosure(ThreadScanHashtable *table) : _table(table) {}
+
+  virtual void do_thread(Thread *thread) {
+    assert_locked_or_safepoint(Threads_lock);
+
+    if (thread == NULL) return;
+
+    // This code races with ThreadsSMRSupport::acquire_stable_list() which
+    // is lock-free so we have to handle some special situations.
+    //
+    ThreadsList *current_list = NULL;
+    while (true) {
+      current_list = thread->get_threads_hazard_ptr();
+      // No hazard ptr so nothing more to do.
+      if (current_list == NULL) {
+        assert(thread->get_nested_threads_hazard_ptr() == NULL,
+               "cannot have a nested hazard ptr with a NULL regular hazard ptr");
+        return;
+      }
+
+      // If the hazard ptr is verified as stable (since it is not tagged),
+      // then it is safe to use.
+      if (!Thread::is_hazard_ptr_tagged(current_list)) break;
+
+      // The hazard ptr is tagged as not yet verified as being stable
+      // so we are racing with acquire_stable_list(). This exchange
+      // attempts to invalidate the hazard ptr. If we win the race,
+      // then we can ignore this unstable hazard ptr and the other
+      // thread will retry the attempt to publish a stable hazard ptr.
+      // If we lose the race, then we retry our attempt to look at the
+      // hazard ptr.
+      if (thread->cmpxchg_threads_hazard_ptr(NULL, current_list) == current_list) return;
+    }
+
+    // The current JavaThread has a hazard ptr (ThreadsList reference)
+    // which might be _smr_java_thread_list or it might be an older
+    // ThreadsList that has been removed but not freed. In either case,
+    // the hazard ptr is protecting all the JavaThreads on that
+    // ThreadsList.
+    AddThreadHazardPointerThreadClosure add_cl(_table);
+    current_list->threads_do(&add_cl);
+
+    // Any NestedThreadsLists are also protecting JavaThreads so
+    // gather those also; the ThreadsLists may be different.
+    for (NestedThreadsList* node = thread->get_nested_threads_hazard_ptr();
+         node != NULL; node = node->next()) {
+      node->t_list()->threads_do(&add_cl);
+    }
+  }
+};
+
+// Closure to gather hazard ptrs (ThreadsList references) into a hash table.
+//
+class ScanHazardPtrGatherThreadsListClosure : public ThreadClosure {
+ private:
+  ThreadScanHashtable *_table;
+ public:
+  ScanHazardPtrGatherThreadsListClosure(ThreadScanHashtable *table) : _table(table) {}
+
+  virtual void do_thread(Thread* thread) {
+    assert_locked_or_safepoint(Threads_lock);
+
+    if (thread == NULL) return;
+    ThreadsList *threads = thread->get_threads_hazard_ptr();
+    if (threads == NULL) {
+      assert(thread->get_nested_threads_hazard_ptr() == NULL,
+             "cannot have a nested hazard ptr with a NULL regular hazard ptr");
+      return;
+    }
+    // In this closure we always ignore the tag that might mark this
+    // hazard ptr as not yet verified. If we happen to catch an
+    // unverified hazard ptr that is subsequently discarded (not
+    // published), then the only side effect is that we might keep a
+    // to-be-deleted ThreadsList alive a little longer.
+    threads = Thread::untag_hazard_ptr(threads);
+    if (!_table->has_entry((void*)threads)) {
+      _table->add_entry((void*)threads);
+    }
+
+    // Any NestedThreadsLists are also protecting JavaThreads so
+    // gather those also; the ThreadsLists may be different.
+    for (NestedThreadsList* node = thread->get_nested_threads_hazard_ptr();
+         node != NULL; node = node->next()) {
+      threads = node->t_list();
+      if (!_table->has_entry((void*)threads)) {
+        _table->add_entry((void*)threads);
+      }
+    }
+  }
+};
+
+// Closure to print JavaThreads that have a hazard ptr (ThreadsList
+// reference) that contains an indirect reference to a specific JavaThread.
+//
+class ScanHazardPtrPrintMatchingThreadsClosure : public ThreadClosure {
+ private:
+  JavaThread *_thread;
+ public:
+  ScanHazardPtrPrintMatchingThreadsClosure(JavaThread *thread) : _thread(thread) {}
+
+  virtual void do_thread(Thread *thread) {
+    assert_locked_or_safepoint(Threads_lock);
+
+    if (thread == NULL) return;
+    ThreadsList *current_list = thread->get_threads_hazard_ptr();
+    if (current_list == NULL) {
+      assert(thread->get_nested_threads_hazard_ptr() == NULL,
+             "cannot have a nested hazard ptr with a NULL regular hazard ptr");
+      return;
+    }
+    // If the hazard ptr is unverified, then ignore it.
+    if (Thread::is_hazard_ptr_tagged(current_list)) return;
+
+    // The current JavaThread has a hazard ptr (ThreadsList reference)
+    // which might be _smr_java_thread_list or it might be an older
+    // ThreadsList that has been removed but not freed. In either case,
+    // the hazard ptr is protecting all the JavaThreads on that
+    // ThreadsList, but we only care about matching a specific JavaThread.
+    JavaThreadIterator jti(current_list);
+    for (JavaThread *p = jti.first(); p != NULL; p = jti.next()) {
+      if (p == _thread) {
+        log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_delete: thread1=" INTPTR_FORMAT " has a hazard pointer for thread2=" INTPTR_FORMAT, os::current_thread_id(), p2i(thread), p2i(_thread));
+        break;
+      }
+    }
+
+    // Any NestedThreadsLists are also protecting JavaThreads so
+    // check those also; the ThreadsLists may be different.
+    for (NestedThreadsList* node = thread->get_nested_threads_hazard_ptr();
+         node != NULL; node = node->next()) {
+      JavaThreadIterator jti(node->t_list());
+      for (JavaThread *p = jti.first(); p != NULL; p = jti.next()) {
+        if (p == _thread) {
+          log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_delete: thread1=" INTPTR_FORMAT " has a nested hazard pointer for thread2=" INTPTR_FORMAT, os::current_thread_id(), p2i(thread), p2i(_thread));
+          return;
+        }
+      }
+    }
+  }
+};
+
 
 // 'entries + 1' so we always have at least one entry.
 ThreadsList::ThreadsList(int entries) : _length(entries), _threads(NEW_C_HEAP_ARRAY(JavaThread*, entries + 1, mtThread)), _next_list(NULL) {
@@ -37,20 +384,87 @@
   FREE_C_HEAP_ARRAY(JavaThread*, _threads);
 }
 
-ThreadsListSetter::~ThreadsListSetter() {
-  if (_target_needs_release) {
-    // The hazard ptr in the target needs to be released.
-    Threads::release_stable_list(_target);
+// Add a JavaThread to a ThreadsList. The returned ThreadsList is a
+// new copy of the specified ThreadsList with the specified JavaThread
+// appended to the end.
+ThreadsList *ThreadsList::add_thread(ThreadsList *list, JavaThread *java_thread) {
+  const uint index = list->_length;
+  const uint new_length = index + 1;
+  const uint head_length = index;
+  ThreadsList *const new_list = new ThreadsList(new_length);
+
+  if (head_length > 0) {
+    Copy::disjoint_words((HeapWord*)list->_threads, (HeapWord*)new_list->_threads, head_length);
   }
+  *(JavaThread**)(new_list->_threads + index) = java_thread;
+
+  return new_list;
 }
 
-void ThreadsListSetter::set() {
-  assert(_target->get_threads_hazard_ptr() == NULL, "hazard ptr should not already be set");
-  (void) Threads::acquire_stable_list(_target, /* is_ThreadsListSetter */ true);
-  _target_needs_release = true;
+int ThreadsList::find_index_of_JavaThread(JavaThread *target) {
+  if (target == NULL) {
+    return -1;
+  }
+  for (uint i = 0; i < length(); i++) {
+    if (target == thread_at(i)) {
+      return (int)i;
+    }
+  }
+  return -1;
 }
 
-ThreadsListHandle::ThreadsListHandle(Thread *self) : _list(Threads::acquire_stable_list(self, /* is_ThreadsListSetter */ false)), _self(self) {
+JavaThread* ThreadsList::find_JavaThread_from_java_tid(jlong java_tid) const {
+  for (uint i = 0; i < length(); i++) {
+    JavaThread* thread = thread_at(i);
+    oop tobj = thread->threadObj();
+    // Ignore the thread if it hasn't run yet, has exited
+    // or is starting to exit.
+    if (tobj != NULL && !thread->is_exiting() &&
+        java_tid == java_lang_Thread::thread_id(tobj)) {
+      // found a match
+      return thread;
+    }
+  }
+  return NULL;
+}
+
+bool ThreadsList::includes(const JavaThread * const p) const {
+  if (p == NULL) {
+    return false;
+  }
+  for (uint i = 0; i < length(); i++) {
+    if (thread_at(i) == p) {
+      return true;
+    }
+  }
+  return false;
+}
+
+// Remove a JavaThread from a ThreadsList. The returned ThreadsList is a
+// new copy of the specified ThreadsList with the specified JavaThread
+// removed.
+ThreadsList *ThreadsList::remove_thread(ThreadsList* list, JavaThread* java_thread) {
+  assert(list->_length > 0, "sanity");
+
+  uint i = (uint)list->find_index_of_JavaThread(java_thread);
+  assert(i < list->_length, "did not find JavaThread on the list");
+  const uint index = i;
+  const uint new_length = list->_length - 1;
+  const uint head_length = index;
+  const uint tail_length = (new_length >= index) ? (new_length - index) : 0;
+  ThreadsList *const new_list = new ThreadsList(new_length);
+
+  if (head_length > 0) {
+    Copy::disjoint_words((HeapWord*)list->_threads, (HeapWord*)new_list->_threads, head_length);
+  }
+  if (tail_length > 0) {
+    Copy::disjoint_words((HeapWord*)list->_threads + index + 1, (HeapWord*)new_list->_threads + index, tail_length);
+  }
+
+  return new_list;
+}
+
+ThreadsListHandle::ThreadsListHandle(Thread *self) : _list(ThreadsSMRSupport::acquire_stable_list(self, /* is_ThreadsListSetter */ false)), _self(self) {
   assert(self == Thread::current(), "sanity check");
   if (EnableThreadSMRStatistics) {
     _timer.start();
@@ -58,13 +472,11 @@
 }
 
 ThreadsListHandle::~ThreadsListHandle() {
-  Threads::release_stable_list(_self);
+  ThreadsSMRSupport::release_stable_list(_self);
   if (EnableThreadSMRStatistics) {
     _timer.stop();
     uint millis = (uint)_timer.milliseconds();
-    Threads::inc_smr_tlh_cnt();
-    Threads::add_smr_tlh_times(millis);
-    Threads::update_smr_tlh_time_max(millis);
+    ThreadsSMRSupport::update_smr_tlh_stats(millis);
   }
 }
 
@@ -119,3 +531,546 @@
   *jt_pp = java_thread;
   return true;
 }
+
+ThreadsListSetter::~ThreadsListSetter() {
+  if (_target_needs_release) {
+    // The hazard ptr in the target needs to be released.
+    ThreadsSMRSupport::release_stable_list(_target);
+  }
+}
+
+void ThreadsListSetter::set() {
+  assert(_target->get_threads_hazard_ptr() == NULL, "hazard ptr should not already be set");
+  (void) ThreadsSMRSupport::acquire_stable_list(_target, /* is_ThreadsListSetter */ true);
+  _target_needs_release = true;
+}
+
+// Acquire a stable ThreadsList.
+//
+ThreadsList *ThreadsSMRSupport::acquire_stable_list(Thread *self, bool is_ThreadsListSetter) {
+  assert(self != NULL, "sanity check");
+  // acquire_stable_list_nested_path() will grab the Threads_lock
+  // so let's make sure the ThreadsListHandle is in a safe place.
+  // ThreadsListSetter cannot make this check on this code path.
+  debug_only(if (!is_ThreadsListSetter && StrictSafepointChecks) self->check_for_valid_safepoint_state(/* potential_vm_operation */ false);)
+
+  if (self->get_threads_hazard_ptr() == NULL) {
+    // The typical case is first.
+    return acquire_stable_list_fast_path(self);
+  }
+
+  // The nested case is rare.
+  return acquire_stable_list_nested_path(self);
+}
+
+// Fast path (and lock free) way to acquire a stable ThreadsList.
+//
+ThreadsList *ThreadsSMRSupport::acquire_stable_list_fast_path(Thread *self) {
+  assert(self != NULL, "sanity check");
+  assert(self->get_threads_hazard_ptr() == NULL, "sanity check");
+  assert(self->get_nested_threads_hazard_ptr() == NULL,
+         "cannot have a nested hazard ptr with a NULL regular hazard ptr");
+
+  ThreadsList* threads;
+
+  // Stable recording of a hazard ptr for SMR. This code does not use
+  // locks so its use of the _smr_java_thread_list & _threads_hazard_ptr
+  // fields is racy relative to code that uses those fields with locks.
+  // OrderAccess and Atomic functions are used to deal with those races.
+  //
+  while (true) {
+    threads = get_smr_java_thread_list();
+
+    // Publish a tagged hazard ptr to denote that the hazard ptr is not
+    // yet verified as being stable. Due to the fence after the hazard
+    // ptr write, it will be sequentially consistent w.r.t. the
+    // sequentially consistent writes of the ThreadsList, even on
+    // non-multiple copy atomic machines where stores can be observed
+    // in different order from different observer threads.
+    ThreadsList* unverified_threads = Thread::tag_hazard_ptr(threads);
+    self->set_threads_hazard_ptr(unverified_threads);
+
+    // If _smr_java_thread_list has changed, we have lost a race with
+    // Threads::add() or Threads::remove() and have to try again.
+    if (get_smr_java_thread_list() != threads) {
+      continue;
+    }
+
+    // We try to remove the tag which will verify the hazard ptr as
+    // being stable. This exchange can race with a scanning thread
+    // which might invalidate the tagged hazard ptr to keep it from
+    // being followed to access JavaThread ptrs. If we lose the race,
+    // we simply retry. If we win the race, then the stable hazard
+    // ptr is officially published.
+    if (self->cmpxchg_threads_hazard_ptr(threads, unverified_threads) == unverified_threads) {
+      break;
+    }
+  }
+
+  // A stable hazard ptr has been published letting other threads know
+  // that the ThreadsList and the JavaThreads reachable from this list
+  // are protected and hence they should not be deleted until everyone
+  // agrees it is safe to do so.
+
+  return threads;
+}
+
+// Acquire a nested stable ThreadsList; this is rare so it uses
+// Threads_lock.
+//
+ThreadsList *ThreadsSMRSupport::acquire_stable_list_nested_path(Thread *self) {
+  assert(self != NULL, "sanity check");
+  assert(self->get_threads_hazard_ptr() != NULL,
+         "cannot have a NULL regular hazard ptr when acquiring a nested hazard ptr");
+
+  // The thread already has a hazard ptr (ThreadsList ref) so we need
+  // to create a nested ThreadsListHandle with the current ThreadsList
+  // since it might be different than our current hazard ptr. The need
+  // for a nested ThreadsListHandle is rare so we do this while holding
+  // the Threads_lock so we don't race with the scanning code; the code
+  // is so much simpler this way.
+
+  NestedThreadsList* node;
+  {
+    // Only grab the Threads_lock if we don't already own it.
+    MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
+    node = new NestedThreadsList(get_smr_java_thread_list());
+    // We insert at the front of the list to match up with the delete
+    // in release_stable_list().
+    node->set_next(self->get_nested_threads_hazard_ptr());
+    self->set_nested_threads_hazard_ptr(node);
+    if (EnableThreadSMRStatistics) {
+      self->inc_nested_threads_hazard_ptr_cnt();
+      if (self->nested_threads_hazard_ptr_cnt() > _smr_nested_thread_list_max) {
+        _smr_nested_thread_list_max = self->nested_threads_hazard_ptr_cnt();
+      }
+    }
+  }
+  log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::acquire_stable_list: add NestedThreadsList node containing ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(node->t_list()));
+
+  return node->t_list();
+}
+
+void ThreadsSMRSupport::add_thread(JavaThread *thread){
+  ThreadsList *new_list = ThreadsList::add_thread(ThreadsSMRSupport::get_smr_java_thread_list(), thread);
+  if (EnableThreadSMRStatistics) {
+    ThreadsSMRSupport::inc_smr_java_thread_list_alloc_cnt();
+    ThreadsSMRSupport::update_smr_java_thread_list_max(new_list->length());
+  }
+  // Initial _smr_java_thread_list will not generate a "Threads::add" mesg.
+  log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::add: new ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(new_list));
+
+  ThreadsList *old_list = ThreadsSMRSupport::xchg_smr_java_thread_list(new_list);
+  ThreadsSMRSupport::smr_free_list(old_list);
+}
+
+// set_smr_delete_notify() and clear_smr_delete_notify() are called
+// under the protection of the smr_delete_lock, but we also use an
+// Atomic operation to ensure the memory update is seen earlier than
+// when the smr_delete_lock is dropped.
+//
+void ThreadsSMRSupport::clear_smr_delete_notify() {
+  Atomic::dec(&_smr_delete_notify);
+}
+
+// Return true if the specified JavaThread is protected by a hazard
+// pointer (ThreadsList reference). Otherwise, returns false.
+//
+bool ThreadsSMRSupport::is_a_protected_JavaThread(JavaThread *thread) {
+  assert_locked_or_safepoint(Threads_lock);
+
+  // Hash table size should be first power of two higher than twice
+  // the length of the Threads list.
+  int hash_table_size = MIN2((int)get_smr_java_thread_list()->length(), 32) << 1;
+  hash_table_size--;
+  hash_table_size |= hash_table_size >> 1;
+  hash_table_size |= hash_table_size >> 2;
+  hash_table_size |= hash_table_size >> 4;
+  hash_table_size |= hash_table_size >> 8;
+  hash_table_size |= hash_table_size >> 16;
+  hash_table_size++;
+
+  // Gather a hash table of the JavaThreads indirectly referenced by
+  // hazard ptrs.
+  ThreadScanHashtable *scan_table = new ThreadScanHashtable(hash_table_size);
+  ScanHazardPtrGatherProtectedThreadsClosure scan_cl(scan_table);
+  Threads::threads_do(&scan_cl);
+
+  bool thread_is_protected = false;
+  if (scan_table->has_entry((void*)thread)) {
+    thread_is_protected = true;
+  }
+  delete scan_table;
+  return thread_is_protected;
+}
+
+// Release a stable ThreadsList.
+//
+void ThreadsSMRSupport::release_stable_list(Thread *self) {
+  assert(self != NULL, "sanity check");
+  // release_stable_list_nested_path() will grab the Threads_lock
+  // so let's make sure the ThreadsListHandle is in a safe place.
+  debug_only(if (StrictSafepointChecks) self->check_for_valid_safepoint_state(/* potential_vm_operation */ false);)
+
+  if (self->get_nested_threads_hazard_ptr() == NULL) {
+    // The typical case is first.
+    release_stable_list_fast_path(self);
+    return;
+  }
+
+  // The nested case is rare.
+  release_stable_list_nested_path(self);
+}
+
+// Fast path way to release a stable ThreadsList. The release portion
+// is lock-free, but the wake up portion is not.
+//
+void ThreadsSMRSupport::release_stable_list_fast_path(Thread *self) {
+  assert(self != NULL, "sanity check");
+  assert(self->get_threads_hazard_ptr() != NULL, "sanity check");
+  assert(self->get_nested_threads_hazard_ptr() == NULL,
+         "cannot have a nested hazard ptr when releasing a regular hazard ptr");
+
+  // After releasing the hazard ptr, other threads may go ahead and
+  // free up some memory temporarily used by a ThreadsList snapshot.
+  self->set_threads_hazard_ptr(NULL);
+
+  // We use double-check locking to reduce traffic on the system
+  // wide smr_delete_lock.
+  if (ThreadsSMRSupport::smr_delete_notify()) {
+    // An exiting thread might be waiting in smr_delete(); we need to
+    // check with smr_delete_lock to be sure.
+    release_stable_list_wake_up((char *) "regular hazard ptr");
+  }
+}
+
+// Release a nested stable ThreadsList; this is rare so it uses
+// Threads_lock.
+//
+void ThreadsSMRSupport::release_stable_list_nested_path(Thread *self) {
+  assert(self != NULL, "sanity check");
+  assert(self->get_nested_threads_hazard_ptr() != NULL, "sanity check");
+  assert(self->get_threads_hazard_ptr() != NULL,
+         "must have a regular hazard ptr to have nested hazard ptrs");
+
+  // We have a nested ThreadsListHandle so we have to release it first.
+  // The need for a nested ThreadsListHandle is rare so we do this while
+  // holding the Threads_lock so we don't race with the scanning code;
+  // the code is so much simpler this way.
+
+  NestedThreadsList *node;
+  {
+    // Only grab the Threads_lock if we don't already own it.
+    MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
+    // We remove from the front of the list to match up with the insert
+    // in acquire_stable_list().
+    node = self->get_nested_threads_hazard_ptr();
+    self->set_nested_threads_hazard_ptr(node->next());
+    if (EnableThreadSMRStatistics) {
+      self->dec_nested_threads_hazard_ptr_cnt();
+    }
+  }
+
+  // An exiting thread might be waiting in smr_delete(); we need to
+  // check with smr_delete_lock to be sure.
+  release_stable_list_wake_up((char *) "nested hazard ptr");
+
+  log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::release_stable_list: delete NestedThreadsList node containing ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(node->t_list()));
+
+  delete node;
+}
+
+// Wake up portion of the release stable ThreadsList protocol;
+// uses the smr_delete_lock().
+//
+void ThreadsSMRSupport::release_stable_list_wake_up(char *log_str) {
+  assert(log_str != NULL, "sanity check");
+
+  // Note: smr_delete_lock is held in smr_delete() for the entire
+  // hazard ptr search so that we do not lose this notify() if
+  // the exiting thread has to wait. That code path also holds
+  // Threads_lock (which was grabbed before smr_delete_lock) so that
+  // threads_do() can be called. This means the system can't start a
+  // safepoint which means this thread can't take too long to get to
+  // a safepoint because of being blocked on smr_delete_lock.
+  //
+  MonitorLockerEx ml(ThreadsSMRSupport::smr_delete_lock(), Monitor::_no_safepoint_check_flag);
+  if (ThreadsSMRSupport::smr_delete_notify()) {
+    // Notify any exiting JavaThreads that are waiting in smr_delete()
+    // that we've released a ThreadsList.
+    ml.notify_all();
+    log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::release_stable_list notified %s", os::current_thread_id(), log_str);
+  }
+}
+
+void ThreadsSMRSupport::remove_thread(JavaThread *thread) {
+  ThreadsList *new_list = ThreadsList::remove_thread(ThreadsSMRSupport::get_smr_java_thread_list(), thread);
+  if (EnableThreadSMRStatistics) {
+    ThreadsSMRSupport::inc_smr_java_thread_list_alloc_cnt();
+    // This list is smaller so no need to check for a "longest" update.
+  }
+
+  // Final _smr_java_thread_list will not generate a "Threads::remove" mesg.
+  log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::remove: new ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(new_list));
+
+  ThreadsList *old_list = ThreadsSMRSupport::xchg_smr_java_thread_list(new_list);
+  ThreadsSMRSupport::smr_free_list(old_list);
+}
+
+// See note for clear_smr_delete_notify().
+//
+void ThreadsSMRSupport::set_smr_delete_notify() {
+  Atomic::inc(&_smr_delete_notify);
+}
+
+// Safely delete a JavaThread when it is no longer in use by a
+// ThreadsListHandle.
+//
+void ThreadsSMRSupport::smr_delete(JavaThread *thread) {
+  assert(!Threads_lock->owned_by_self(), "sanity");
+
+  bool has_logged_once = false;
+  elapsedTimer timer;
+  if (EnableThreadSMRStatistics) {
+    timer.start();
+  }
+
+  while (true) {
+    {
+      // No safepoint check because this JavaThread is not on the
+      // Threads list.
+      MutexLockerEx ml(Threads_lock, Mutex::_no_safepoint_check_flag);
+      // Cannot use a MonitorLockerEx helper here because we have
+      // to drop the Threads_lock first if we wait.
+      ThreadsSMRSupport::smr_delete_lock()->lock_without_safepoint_check();
+      // Set the smr_delete_notify flag after we grab smr_delete_lock
+      // and before we scan hazard ptrs because we're doing
+      // double-check locking in release_stable_list().
+      ThreadsSMRSupport::set_smr_delete_notify();
+
+      if (!is_a_protected_JavaThread(thread)) {
+        // This is the common case.
+        ThreadsSMRSupport::clear_smr_delete_notify();
+        ThreadsSMRSupport::smr_delete_lock()->unlock();
+        break;
+      }
+      if (!has_logged_once) {
+        has_logged_once = true;
+        log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_delete: thread=" INTPTR_FORMAT " is not deleted.", os::current_thread_id(), p2i(thread));
+        if (log_is_enabled(Debug, os, thread)) {
+          ScanHazardPtrPrintMatchingThreadsClosure scan_cl(thread);
+          Threads::threads_do(&scan_cl);
+        }
+      }
+    } // We have to drop the Threads_lock to wait or delete the thread
+
+    if (EnableThreadSMRStatistics) {
+      _smr_delete_lock_wait_cnt++;
+      if (_smr_delete_lock_wait_cnt > _smr_delete_lock_wait_max) {
+        _smr_delete_lock_wait_max = _smr_delete_lock_wait_cnt;
+      }
+    }
+    // Wait for a release_stable_list() call before we check again. No
+    // safepoint check, no timeout, and not as suspend equivalent flag
+    // because this JavaThread is not on the Threads list.
+    ThreadsSMRSupport::smr_delete_lock()->wait(Mutex::_no_safepoint_check_flag, 0,
+                                     !Mutex::_as_suspend_equivalent_flag);
+    if (EnableThreadSMRStatistics) {
+      _smr_delete_lock_wait_cnt--;
+    }
+
+    ThreadsSMRSupport::clear_smr_delete_notify();
+    ThreadsSMRSupport::smr_delete_lock()->unlock();
+    // Retry the whole scenario.
+  }
+
+  if (ThreadLocalHandshakes) {
+    // The thread is about to be deleted so cancel any handshake.
+    thread->cancel_handshake();
+  }
+
+  delete thread;
+  if (EnableThreadSMRStatistics) {
+    timer.stop();
+    uint millis = (uint)timer.milliseconds();
+    ThreadsSMRSupport::inc_smr_deleted_thread_cnt();
+    ThreadsSMRSupport::add_smr_deleted_thread_times(millis);
+    ThreadsSMRSupport::update_smr_deleted_thread_time_max(millis);
+  }
+
+  log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_delete: thread=" INTPTR_FORMAT " is deleted.", os::current_thread_id(), p2i(thread));
+}
+
+bool ThreadsSMRSupport::smr_delete_notify() {
+  // Use load_acquire() in order to see any updates to _smr_delete_notify
+  // earlier than when smr_delete_lock is grabbed.
+  return (OrderAccess::load_acquire(&_smr_delete_notify) != 0);
+}
+
+// Safely free a ThreadsList after a Threads::add() or Threads::remove().
+// The specified ThreadsList may not get deleted during this call if it
+// is still in-use (referenced by a hazard ptr). Other ThreadsLists
+// in the chain may get deleted by this call if they are no longer in-use.
+void ThreadsSMRSupport::smr_free_list(ThreadsList* threads) {
+  assert_locked_or_safepoint(Threads_lock);
+
+  threads->set_next_list(_smr_to_delete_list);
+  _smr_to_delete_list = threads;
+  if (EnableThreadSMRStatistics) {
+    _smr_to_delete_list_cnt++;
+    if (_smr_to_delete_list_cnt > _smr_to_delete_list_max) {
+      _smr_to_delete_list_max = _smr_to_delete_list_cnt;
+    }
+  }
+
+  // Hash table size should be first power of two higher than twice the length of the ThreadsList
+  int hash_table_size = MIN2((int)get_smr_java_thread_list()->length(), 32) << 1;
+  hash_table_size--;
+  hash_table_size |= hash_table_size >> 1;
+  hash_table_size |= hash_table_size >> 2;
+  hash_table_size |= hash_table_size >> 4;
+  hash_table_size |= hash_table_size >> 8;
+  hash_table_size |= hash_table_size >> 16;
+  hash_table_size++;
+
+  // Gather a hash table of the current hazard ptrs:
+  ThreadScanHashtable *scan_table = new ThreadScanHashtable(hash_table_size);
+  ScanHazardPtrGatherThreadsListClosure scan_cl(scan_table);
+  Threads::threads_do(&scan_cl);
+
+  // Walk through the linked list of pending freeable ThreadsLists
+  // and free the ones that are not referenced from hazard ptrs.
+  ThreadsList* current = _smr_to_delete_list;
+  ThreadsList* prev = NULL;
+  ThreadsList* next = NULL;
+  bool threads_is_freed = false;
+  while (current != NULL) {
+    next = current->next_list();
+    if (!scan_table->has_entry((void*)current)) {
+      // This ThreadsList is not referenced by a hazard ptr.
+      if (prev != NULL) {
+        prev->set_next_list(next);
+      }
+      if (_smr_to_delete_list == current) {
+        _smr_to_delete_list = next;
+      }
+
+      log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_free_list: threads=" INTPTR_FORMAT " is freed.", os::current_thread_id(), p2i(current));
+      if (current == threads) threads_is_freed = true;
+      delete current;
+      if (EnableThreadSMRStatistics) {
+        _smr_java_thread_list_free_cnt++;
+        _smr_to_delete_list_cnt--;
+      }
+    } else {
+      prev = current;
+    }
+    current = next;
+  }
+
+  if (!threads_is_freed) {
+    // Only report "is not freed" on the original call to
+    // smr_free_list() for this ThreadsList.
+    log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_free_list: threads=" INTPTR_FORMAT " is not freed.", os::current_thread_id(), p2i(threads));
+  }
+
+  delete scan_table;
+}
+
+
+// Debug, logging, and printing stuff at the end:
+
+// Log Threads class SMR info.
+void ThreadsSMRSupport::log_smr_statistics() {
+  LogTarget(Info, thread, smr) log;
+  if (log.is_enabled()) {
+    LogStream out(log);
+    print_smr_info_on(&out);
+  }
+}
+
+// Print Threads class SMR info.
+void ThreadsSMRSupport::print_smr_info_on(outputStream* st) {
+  // Only grab the Threads_lock if we don't already own it
+  // and if we are not reporting an error.
+  MutexLockerEx ml((Threads_lock->owned_by_self() || VMError::is_error_reported()) ? NULL : Threads_lock);
+
+  st->print_cr("Threads class SMR info:");
+  st->print_cr("_smr_java_thread_list=" INTPTR_FORMAT ", length=%u, "
+               "elements={", p2i(_smr_java_thread_list),
+               _smr_java_thread_list->length());
+  print_smr_info_elements_on(st, _smr_java_thread_list);
+  st->print_cr("}");
+  if (_smr_to_delete_list != NULL) {
+    st->print_cr("_smr_to_delete_list=" INTPTR_FORMAT ", length=%u, "
+                 "elements={", p2i(_smr_to_delete_list),
+                 _smr_to_delete_list->length());
+    print_smr_info_elements_on(st, _smr_to_delete_list);
+    st->print_cr("}");
+    for (ThreadsList *t_list = _smr_to_delete_list->next_list();
+         t_list != NULL; t_list = t_list->next_list()) {
+      st->print("next-> " INTPTR_FORMAT ", length=%u, "
+                "elements={", p2i(t_list), t_list->length());
+      print_smr_info_elements_on(st, t_list);
+      st->print_cr("}");
+    }
+  }
+  if (!EnableThreadSMRStatistics) {
+    return;
+  }
+  st->print_cr("_smr_java_thread_list_alloc_cnt=" UINT64_FORMAT ","
+               "_smr_java_thread_list_free_cnt=" UINT64_FORMAT ","
+               "_smr_java_thread_list_max=%u, "
+               "_smr_nested_thread_list_max=%u",
+               _smr_java_thread_list_alloc_cnt,
+               _smr_java_thread_list_free_cnt,
+               _smr_java_thread_list_max,
+               _smr_nested_thread_list_max);
+  if (_smr_tlh_cnt > 0) {
+    st->print_cr("_smr_tlh_cnt=%u"
+                 ", _smr_tlh_times=%u"
+                 ", avg_smr_tlh_time=%0.2f"
+                 ", _smr_tlh_time_max=%u",
+                 _smr_tlh_cnt, _smr_tlh_times,
+                 ((double) _smr_tlh_times / _smr_tlh_cnt),
+                 _smr_tlh_time_max);
+  }
+  if (_smr_deleted_thread_cnt > 0) {
+    st->print_cr("_smr_deleted_thread_cnt=%u"
+                 ", _smr_deleted_thread_times=%u"
+                 ", avg_smr_deleted_thread_time=%0.2f"
+                 ", _smr_deleted_thread_time_max=%u",
+                 _smr_deleted_thread_cnt, _smr_deleted_thread_times,
+                 ((double) _smr_deleted_thread_times / _smr_deleted_thread_cnt),
+                 _smr_deleted_thread_time_max);
+  }
+  st->print_cr("_smr_delete_lock_wait_cnt=%u, _smr_delete_lock_wait_max=%u",
+               _smr_delete_lock_wait_cnt, _smr_delete_lock_wait_max);
+  st->print_cr("_smr_to_delete_list_cnt=%u, _smr_to_delete_list_max=%u",
+               _smr_to_delete_list_cnt, _smr_to_delete_list_max);
+}
+
+// Print ThreadsList elements (4 per line).
+void ThreadsSMRSupport::print_smr_info_elements_on(outputStream* st,
+                                         ThreadsList* t_list) {
+  uint cnt = 0;
+  JavaThreadIterator jti(t_list);
+  for (JavaThread *jt = jti.first(); jt != NULL; jt = jti.next()) {
+    st->print(INTPTR_FORMAT, p2i(jt));
+    if (cnt < t_list->length() - 1) {
+      // Separate with comma or comma-space except for the last one.
+      if (((cnt + 1) % 4) == 0) {
+        // Four INTPTR_FORMAT fit on an 80 column line so end the
+        // current line with just a comma.
+        st->print_cr(",");
+      } else {
+        // Not the last one on the current line so use comma-space:
+        st->print(", ");
+      }
+    } else {
+      // Last one so just end the current line.
+      st->cr();
+    }
+    cnt++;
+  }
+}
--- a/src/hotspot/share/runtime/threadSMR.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/runtime/threadSMR.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -77,11 +77,77 @@
 // longer protected by a ThreadsListHandle.
 
 
+// SMR Support for the Threads class.
+//
+class ThreadsSMRSupport : AllStatic {
+  // The coordination between ThreadsSMRSupport::release_stable_list() and
+  // ThreadsSMRSupport::smr_delete() uses the smr_delete_lock in order to
+  // reduce the traffic on the Threads_lock.
+  static Monitor*              _smr_delete_lock;
+  // The '_cnt', '_max' and '_times" fields are enabled via
+  // -XX:+EnableThreadSMRStatistics (see thread.cpp for a
+  // description about each field):
+  static uint                  _smr_delete_lock_wait_cnt;
+  static uint                  _smr_delete_lock_wait_max;
+  // The smr_delete_notify flag is used for proper double-check
+  // locking in order to reduce the traffic on the smr_delete_lock.
+  static volatile uint         _smr_delete_notify;
+  static volatile uint         _smr_deleted_thread_cnt;
+  static volatile uint         _smr_deleted_thread_time_max;
+  static volatile uint         _smr_deleted_thread_times;
+  static ThreadsList* volatile _smr_java_thread_list;
+  static uint64_t              _smr_java_thread_list_alloc_cnt;
+  static uint64_t              _smr_java_thread_list_free_cnt;
+  static uint                  _smr_java_thread_list_max;
+  static uint                  _smr_nested_thread_list_max;
+  static volatile uint         _smr_tlh_cnt;
+  static volatile uint         _smr_tlh_time_max;
+  static volatile uint         _smr_tlh_times;
+  static ThreadsList*          _smr_to_delete_list;
+  static uint                  _smr_to_delete_list_cnt;
+  static uint                  _smr_to_delete_list_max;
+
+  static ThreadsList *acquire_stable_list_fast_path(Thread *self);
+  static ThreadsList *acquire_stable_list_nested_path(Thread *self);
+  static void add_smr_deleted_thread_times(uint add_value);
+  static void add_smr_tlh_times(uint add_value);
+  static void clear_smr_delete_notify();
+  static void inc_smr_deleted_thread_cnt();
+  static void inc_smr_java_thread_list_alloc_cnt();
+  static void inc_smr_tlh_cnt();
+  static bool is_a_protected_JavaThread(JavaThread *thread);
+  static void release_stable_list_fast_path(Thread *self);
+  static void release_stable_list_nested_path(Thread *self);
+  static void release_stable_list_wake_up(char *log_str);
+  static void set_smr_delete_notify();
+  static Monitor* smr_delete_lock() { return _smr_delete_lock; }
+  static bool smr_delete_notify();
+  static void smr_free_list(ThreadsList* threads);
+  static void update_smr_deleted_thread_time_max(uint new_value);
+  static void update_smr_java_thread_list_max(uint new_value);
+  static void update_smr_tlh_time_max(uint new_value);
+  static ThreadsList* xchg_smr_java_thread_list(ThreadsList* new_list);
+
+ public:
+  static ThreadsList *acquire_stable_list(Thread *self, bool is_ThreadsListSetter);
+  static void add_thread(JavaThread *thread);
+  static ThreadsList* get_smr_java_thread_list();
+  static bool is_a_protected_JavaThread_with_lock(JavaThread *thread);
+  static void release_stable_list(Thread *self);
+  static void remove_thread(JavaThread *thread);
+  static void smr_delete(JavaThread *thread);
+  static void update_smr_tlh_stats(uint millis);
+
+  // Logging and printing support:
+  static void log_smr_statistics();
+  static void print_smr_info_elements_on(outputStream* st, ThreadsList* t_list);
+  static void print_smr_info_on(outputStream* st);
+};
+
 // A fast list of JavaThreads.
 //
 class ThreadsList : public CHeapObj<mtThread> {
-  friend class ScanHazardPtrGatherProtectedThreadsClosure;
-  friend class Threads;
+  friend class ThreadsSMRSupport;  // for next_list(), set_next_list() access
 
   const uint _length;
   ThreadsList* _next_list;
@@ -93,6 +159,9 @@
   ThreadsList *next_list() const        { return _next_list; }
   void set_next_list(ThreadsList *list) { _next_list = list; }
 
+  static ThreadsList* add_thread(ThreadsList* list, JavaThread* java_thread);
+  static ThreadsList* remove_thread(ThreadsList* list, JavaThread* java_thread);
+
 public:
   ThreadsList(int entries);
   ~ThreadsList();
@@ -110,9 +179,6 @@
   int find_index_of_JavaThread(JavaThread* target);
   JavaThread* find_JavaThread_from_java_tid(jlong java_tid) const;
   bool includes(const JavaThread * const p) const;
-
-  static ThreadsList* add_thread(ThreadsList* list, JavaThread* java_thread);
-  static ThreadsList* remove_thread(ThreadsList* list, JavaThread* java_thread);
 };
 
 // Linked list of ThreadsLists to support nested ThreadsListHandles.
--- a/src/hotspot/share/runtime/threadSMR.inline.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/runtime/threadSMR.inline.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -52,6 +52,32 @@
   }
 }
 
+// These three inlines are private to ThreadsSMRSupport, but
+// they are called by public inline update_smr_tlh_stats() below:
+
+inline void ThreadsSMRSupport::add_smr_tlh_times(uint add_value) {
+  Atomic::add(add_value, &_smr_tlh_times);
+}
+
+inline void ThreadsSMRSupport::inc_smr_tlh_cnt() {
+  Atomic::inc(&_smr_tlh_cnt);
+}
+
+inline void ThreadsSMRSupport::update_smr_tlh_time_max(uint new_value) {
+  while (true) {
+    uint cur_value = _smr_tlh_time_max;
+    if (new_value <= cur_value) {
+      // No need to update max value so we're done.
+      break;
+    }
+    if (Atomic::cmpxchg(new_value, &_smr_tlh_time_max, cur_value) == cur_value) {
+      // Updated max value so we're done. Otherwise try it all again.
+      break;
+    }
+  }
+}
+
+
 inline ThreadsList* ThreadsListSetter::list() {
   ThreadsList *ret = _target->get_threads_hazard_ptr();
   assert(ret != NULL, "hazard ptr should be set");
@@ -59,4 +85,19 @@
   return ret;
 }
 
+inline ThreadsList* ThreadsSMRSupport::get_smr_java_thread_list() {
+  return (ThreadsList*)OrderAccess::load_acquire(&_smr_java_thread_list);
+}
+
+inline bool ThreadsSMRSupport::is_a_protected_JavaThread_with_lock(JavaThread *thread) {
+  MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
+  return is_a_protected_JavaThread(thread);
+}
+
+inline void ThreadsSMRSupport::update_smr_tlh_stats(uint millis) {
+  ThreadsSMRSupport::inc_smr_tlh_cnt();
+  ThreadsSMRSupport::add_smr_tlh_times(millis);
+  ThreadsSMRSupport::update_smr_tlh_time_max(millis);
+}
+
 #endif // SHARE_VM_RUNTIME_THREADSMR_INLINE_HPP
--- a/src/hotspot/share/runtime/vmStructs.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/runtime/vmStructs.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -1991,6 +1991,7 @@
   declare_c2_type(MulVDNode, VectorNode)                                  \
   declare_c2_type(FmaVDNode, VectorNode)                                  \
   declare_c2_type(FmaVFNode, VectorNode)                                  \
+  declare_c2_type(CMoveVFNode, VectorNode)                                \
   declare_c2_type(CMoveVDNode, VectorNode)                                \
   declare_c2_type(MulReductionVDNode, ReductionNode)                      \
   declare_c2_type(DivVFNode, VectorNode)                                  \
--- a/src/hotspot/share/runtime/vm_operations.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/runtime/vm_operations.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -29,6 +29,7 @@
 #include "memory/allocation.hpp"
 #include "oops/oop.hpp"
 #include "runtime/thread.hpp"
+#include "runtime/threadSMR.hpp"
 #include "code/codeCache.hpp"
 
 // The following classes are used for operations
--- a/src/hotspot/share/runtime/vm_version.cpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/runtime/vm_version.cpp	Mon Dec 18 10:28:43 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -48,14 +48,14 @@
   #error HOTSPOT_VERSION_STRING must be defined
 #endif
 
-#ifndef VERSION_MAJOR
-  #error VERSION_MAJOR must be defined
+#ifndef VERSION_FEATURE
+  #error VERSION_FEATURE must be defined
 #endif
-#ifndef VERSION_MINOR
-  #error VERSION_MINOR must be defined
+#ifndef VERSION_INTERIM
+  #error VERSION_INTERIM must be defined
 #endif
-#ifndef VERSION_SECURITY
-  #error VERSION_SECURITY must be defined
+#ifndef VERSION_UPDATE
+  #error VERSION_UPDATE must be defined
 #endif
 #ifndef VERSION_PATCH
   #error VERSION_PATCH must be defined
@@ -76,9 +76,9 @@
 
 // HOTSPOT_VERSION_STRING equals the JDK VERSION_STRING (unless overridden
 // in a standalone build).
-int Abstract_VM_Version::_vm_major_version = VERSION_MAJOR;
-int Abstract_VM_Version::_vm_minor_version = VERSION_MINOR;
-int Abstract_VM_Version::_vm_security_version = VERSION_SECURITY;
+int Abstract_VM_Version::_vm_major_version = VERSION_FEATURE;
+int Abstract_VM_Version::_vm_minor_version = VERSION_INTERIM;
+int Abstract_VM_Version::_vm_security_version = VERSION_UPDATE;
 int Abstract_VM_Version::_vm_patch_version = VERSION_PATCH;
 int Abstract_VM_Version::_vm_build_number = VERSION_BUILD;
 unsigned int Abstract_VM_Version::_parallel_worker_threads = 0;
--- a/src/hotspot/share/services/threadService.hpp	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/hotspot/share/services/threadService.hpp	Mon Dec 18 10:28:43 2017 -0800
@@ -33,6 +33,7 @@
 #include "runtime/objectMonitor.inline.hpp"
 #include "runtime/perfData.hpp"
 #include "runtime/thread.hpp"
+#include "runtime/threadSMR.hpp"
 #include "services/management.hpp"
 #include "services/serviceUtil.hpp"
 
--- a/src/java.base/share/classes/java/lang/Runtime.java	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/java.base/share/classes/java/lang/Runtime.java	Mon Dec 18 10:28:43 2017 -0800
@@ -899,81 +899,68 @@
      *
      * <h2><a id="verNum">Version numbers</a></h2>
      *
-     * <p> A <em>version number</em>, {@code $VNUM}, is a non-empty sequence
-     * of elements separated by period characters (U+002E).  An element is
-     * either zero, or an unsigned integer numeral without leading zeros.  The
-     * final element in a version number must not be zero.  The format is:
-     * </p>
+     * <p> A <em>version number</em>, {@code $VNUM}, is a non-empty sequence of
+     * elements separated by period characters (U+002E).  An element is either
+     * zero, or an unsigned integer numeral without leading zeros.  The final
+     * element in a version number must not be zero.  When an element is
+     * incremented, all subsequent elements are removed.  The format is: </p>
      *
      * <blockquote><pre>
-     *     [1-9][0-9]*((\.0)*\.[1-9][0-9]*)*
+     * [1-9][0-9]*((\.0)*\.[1-9][0-9]*)*
      * </pre></blockquote>
      *
-     * <p> The sequence may be of arbitrary length but the first three
-     * elements are assigned specific meanings, as follows:</p>
+     * <p> The sequence may be of arbitrary length but the first four elements
+     * are assigned specific meanings, as follows:</p>
      *
      * <blockquote><pre>
-     *     $MAJOR.$MINOR.$SECURITY
+     * $FEATURE.$INTERIM.$UPDATE.$PATCH
      * </pre></blockquote>
      *
      * <ul>
      *
-     * <li><p> <a id="major">{@code $MAJOR}</a> --- The major version
-     * number, incremented for a major release that contains significant new
-     * features as specified in a new edition of the Java&#160;SE Platform
-     * Specification, <em>e.g.</em>, <a
-     * href="https://jcp.org/en/jsr/detail?id=337">JSR 337</a> for
-     * Java&#160;SE&#160;8.  Features may be removed in a major release, given
-     * advance notice at least one major release ahead of time, and
-     * incompatible changes may be made when justified. The {@code $MAJOR}
-     * version number of JDK&#160;8 is {@code 8}; the {@code $MAJOR} version
-     * number of JDK&#160;9 is {@code 9}.  When {@code $MAJOR} is incremented,
-     * all subsequent elements are removed. </p></li>
+     * <li><p> <a id="FEATURE">{@code $FEATURE}</a> &#x2014; The
+     * feature-release counter, incremented for every feature release
+     * regardless of release content.  Features may be added in a feature
+     * release; they may also be removed, if advance notice was given at least
+     * one feature release ahead of time.  Incompatible changes may be made
+     * when justified. </p></li>
      *
-     * <li><p> <a id="minor">{@code $MINOR}</a> --- The minor version
-     * number, incremented for a minor update release that may contain
-     * compatible bug fixes, revisions to standard APIs mandated by a
-     * <a href="https://jcp.org/en/procedures/jcp2#5.3">Maintenance Release</a>
-     * of the relevant Platform Specification, and implementation features
-     * outside the scope of that Specification such as new JDK-specific APIs,
-     * additional service providers, new garbage collectors, and ports to new
-     * hardware architectures. </p></li>
+     * <li><p> <a id="INTERIM">{@code $INTERIM}</a> &#x2014; The
+     * interim-release counter, incremented for non-feature releases that
+     * contain compatible bug fixes and enhancements but no incompatible
+     * changes, no feature removals, and no changes to standard APIs.
+     * </p></li>
      *
-     * <li><p> <a id="security">{@code $SECURITY}</a> --- The security
-     * level, incremented for a security update release that contains critical
-     * fixes including those necessary to improve security.  {@code $SECURITY}
-     * is <strong>not</strong> reset when {@code $MINOR} is incremented.  A
-     * higher value of {@code $SECURITY} for a given {@code $MAJOR} value,
-     * therefore, always indicates a more secure release, regardless of the
-     * value of {@code $MINOR}. </p></li>
+     * <li><p> <a id="UPDATE">{@code $UPDATE}</a> &#x2014; The update-release
+     * counter, incremented for compatible update releases that fix security
+     * issues, regressions, and bugs in newer features. </p></li>
+     *
+     * <li><p> <a id="PATCH">{@code $PATCH}</a> &#x2014; The emergency
+     * patch-release counter, incremented only when it's necessary to produce
+     * an emergency release to fix a critical issue. </p></li>
      *
      * </ul>
      *
-     * <p> The fourth and later elements of a version number are free for use
-     * by downstream consumers of this code base.  Such a consumer may,
-     * <em>e.g.</em>, use the fourth element to identify patch releases which
-     * contain a small number of critical non-security fixes in addition to
-     * the security fixes in the corresponding security release. </p>
+     * <p> The fifth and later elements of a version number are free for use by
+     * platform implementors, to identify implementor-specific patch
+     * releases. </p>
      *
-     * <p> The version number does not include trailing zero elements;
-     * <em>i.e.</em>, {@code $SECURITY} is omitted if it has the value zero,
-     * and {@code $MINOR} is omitted if both {@code $MINOR} and {@code
-     * $SECURITY} have the value zero. </p>
+     * <p> A version number never has trailing zero elements.  If an element
+     * and all those that follow it logically have the value zero then all of
+     * them are omitted. </p>
      *
      * <p> The sequence of numerals in a version number is compared to another
      * such sequence in numerical, pointwise fashion; <em>e.g.</em>, {@code
-     * 9.9.1} is less than {@code 9.10.3}. If one sequence is shorter than
-     * another then the missing elements of the shorter sequence are
-     * considered to be less than the corresponding elements of the longer
-     * sequence; <em>e.g.</em>, {@code 9.1.2} is less than {@code 9.1.2.1}.
-     * </p>
+     * 10.0.4} is less than {@code 10.1.2}.  If one sequence is shorter than
+     * another then the missing elements of the shorter sequence are considered
+     * to be less than the corresponding elements of the longer sequence;
+     * <em>e.g.</em>, {@code 10.0.2} is less than {@code 10.0.2.1}. </p>
      *
      * <h2><a id="verStr">Version strings</a></h2>
      *
-     * <p> A <em>version string</em>, {@code $VSTR}, consists of a version
-     * number {@code $VNUM}, as described above, optionally followed by
-     * pre-release and build information, in one of the following formats:
-     * </p>
+     * <p> A <em>version string</em>, {@code $VSTR}, is a version number {@code
+     * $VNUM}, as described above, optionally followed by pre-release and build
+     * information, in one of the following formats: </p>
      *
      * <blockquote><pre>
      *     $VNUM(-$PRE)?\+$BUILD(-$OPT)?
@@ -986,19 +973,19 @@
      * <ul>
      *
      * <li><p> <a id="pre">{@code $PRE}</a>, matching {@code ([a-zA-Z0-9]+)}
-     * --- A pre-release identifier.  Typically {@code ea}, for a
-     * potentially unstable early-access release under active development,
-     * or {@code internal}, for an internal developer build. </p></li>
+     * &#x2014; A pre-release identifier.  Typically {@code ea}, for a
+     * potentially unstable early-access release under active development, or
+     * {@code internal}, for an internal developer build. </p></li>
      *
      * <li><p> <a id="build">{@code $BUILD}</a>, matching {@code
-     * (0|[1-9][0-9]*)} --- The build number, incremented for each promoted
+     * (0|[1-9][0-9]*)} &#x2014; The build number, incremented for each promoted
      * build.  {@code $BUILD} is reset to {@code 1} when any portion of {@code
      * $VNUM} is incremented. </p></li>
      *
-     * <li><p> <a id="opt">{@code $OPT}</a>, matching {@code
-     * ([-a-zA-Z0-9.]+)} --- Additional build information, if desired.  In
-     * the case of an {@code internal} build this will often contain the date
-     * and time of the build. </p></li>
+     * <li><p> <a id="opt">{@code $OPT}</a>, matching {@code ([-a-zA-Z0-9.]+)}
+     * &#x2014; Additional build information, if desired.  In the case of an
+     * {@code internal} build this will often contain the date and time of the
+     * build. </p></li>
      *
      * </ul>
      *
@@ -1082,7 +1069,7 @@
                 throw new NullPointerException();
 
             // Shortcut to avoid initializing VersionPattern when creating
-            // major version constants during startup
+            // feature-version constants during startup
             if (isSimpleNumber(s)) {
                 return new Version(List.of(Integer.parseInt(s)),
                         Optional.empty(), Optional.empty(), Optional.empty());
@@ -1139,43 +1126,114 @@
         }
 
         /**
-         * Returns the <a href="#major">major</a> version number.
+         * Returns the value of the <a href="#FEATURE">feature</a> element of
+         * the version number.
          *
-         * @return  The major version number
+         * @return The value of the feature element
+         *
+         * @since 10
          */
-        public int major() {
+        public int feature() {
             return version.get(0);
         }
 
         /**
-         * Returns the <a href="#minor">minor</a> version number or zero if it
-         * was not set.
+         * Returns the value of the <a href="#INTERIM">interim</a> element of
+         * the version number, or zero if it is absent.
          *
-         * @return  The minor version number or zero if it was not set
+         * @return The value of the interim element, or zero
+         *
+         * @since 10
          */
-        public int minor() {
+        public int interim() {
             return (version.size() > 1 ? version.get(1) : 0);
         }
 
         /**
-         * Returns the <a href="#security">security</a> version number or zero
-         * if it was not set.
+         * Returns the value of the <a href="#UPDATE">update</a> element of the
+         * version number, or zero if it is absent.
          *
-         * @return  The security version number or zero if it was not set
+         * @return The value of the update element, or zero
+         *
+         * @since 10
          */
-        public int security() {
+        public int update() {
             return (version.size() > 2 ? version.get(2) : 0);
         }
 
         /**
-         * Returns an unmodifiable {@link java.util.List List} of the
-         * integer numerals contained in the <a href="#verNum">version
-         * number</a>.  The {@code List} always contains at least one
-         * element corresponding to the <a href="#major">major version
-         * number</a>.
+         * Returns the value of the <a href="#PATCH">patch</a> element of the
+         * version number, or zero if it is absent.
          *
-         * @return  An unmodifiable list of the integer numerals
-         *          contained in the version number
+         * @return The value of the patch element, or zero
+         *
+         * @since 10
+         */
+        public int patch() {
+            return (version.size() > 3 ? version.get(3) : 0);
+        }
+
+        /**
+         * Returns the value of the major element of the version number.
+         *
+         * @deprecated As of Java&nbsp;SE 10, the first element of a version
+         * number is not the major-release number but the feature-release
+         * counter, incremented for every time-based release.  Use the {@link
+         * #feature()} method in preference to this method.  For compatibility,
+         * this method returns the value of the <a href="FEATURE">feature</a>
+         * element.
+         *
+         * @return The value of the feature element
+         */
+        @Deprecated(since = "10")
+        public int major() {
+            return feature();
+        }
+
+        /**
+         * Returns the value of the minor element of the version number, or
+         * zero if it is absent.
+         *
+         * @deprecated As of Java&nbsp;SE 10, the second element of a version
+         * number is not the minor-release number but the interim-release
+         * counter, incremented for every interim release.  Use the {@link
+         * #interim()} method in preference to this method.  For compatibility,
+         * this method returns the value of the <a href="INTERIM">interim</a>
+         * element, or zero if it is absent.
+         *
+         * @return The value of the interim element, or zero
+         */
+        @Deprecated(since = "10")
+        public int minor() {
+            return interim();
+        }
+
+        /**
+         * Returns the value of the security element of the version number, or
+         * zero if it is absent.
+         *
+         * @deprecated As of Java&nbsp;SE 10, the third element of a version
+         * number is not the security level but the update-release counter,
+         * incremented for every update release.  Use the {@link #update()}
+         * method in preference to this method.  For compatibility, this method
+         * returns the value of the <a href="UPDATE">update</a> element, or
+         * zero if it is absent.
+         *
+         * @return  The value of the update element, or zero
+         */
+        @Deprecated(since = "10")
+        public int security() {
+            return update();
+        }
+
+        /**
+         * Returns an unmodifiable {@link java.util.List List} of the integers
+         * represented in the <a href="#verNum">version number</a>.  The {@code
+         * List} always contains at least one element corresponding to the <a
+         * href="#feature">feature version number</a>.
+         *
+         * @return  An unmodifiable list of the integers
+         *          represented in the version number
          */
         public List<Integer> version() {
             return version;
--- a/src/java.base/share/classes/java/lang/System.java	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/java.base/share/classes/java/lang/System.java	Mon Dec 18 10:28:43 2017 -0800
@@ -550,8 +550,10 @@
      * System properties. The following properties are guaranteed to be defined:
      * <dl>
      * <dt>java.version         <dd>Java version number
+     * <dt>java.version.date    <dd>Java version date
      * <dt>java.vendor          <dd>Java vendor specific string
      * <dt>java.vendor.url      <dd>Java vendor URL
+     * <dt>java.vendor.version  <dd>Java vendor version
      * <dt>java.home            <dd>Java installation directory
      * <dt>java.class.version   <dd>Java class version number
      * <dt>java.class.path      <dd>Java classpath
@@ -591,12 +593,18 @@
      * </thead>
      * <tbody>
      * <tr><th scope="row"><code>java.version</code></th>
-     *     <td>Java Runtime Environment version which may be interpreted
+     *     <td>Java Runtime Environment version, which may be interpreted
      *     as a {@link Runtime.Version}</td></tr>
+     * <tr><th scope="row"><code>java.version.date</code></th>
+     *     <td>Java Runtime Environment version date, in ISO-8601 YYYY-MM-DD
+     *     format, which may be interpreted as a {@link
+     *     java.time.LocalDate}</td></tr>
      * <tr><th scope="row"><code>java.vendor</code></th>
      *     <td>Java Runtime Environment vendor</td></tr>
      * <tr><th scope="row"><code>java.vendor.url</code></th>
      *     <td>Java vendor URL</td></tr>
+     * <tr><th scope="row"><code>java.vendor.version</code></th>
+     *     <td>Java vendor version</td></tr>
      * <tr><th scope="row"><code>java.home</code></th>
      *     <td>Java installation directory</td></tr>
      * <tr><th scope="row"><code>java.vm.specification.version</code></th>
--- a/src/java.base/share/classes/java/lang/VersionProps.java.template	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/java.base/share/classes/java/lang/VersionProps.java.template	Mon Dec 18 10:28:43 2017 -0800
@@ -32,13 +32,15 @@
 
 class VersionProps {
 
-
     private static final String launcher_name =
         "@@LAUNCHER_NAME@@";
 
     private static final String java_version =
         "@@VERSION_SHORT@@";
 
+    private static final String java_version_date =
+        "@@VERSION_DATE@@";
+
     private static final String java_runtime_name =
         "@@RUNTIME_NAME@@";
 
@@ -57,14 +59,27 @@
     private static final String VERSION_OPT =
         "@@VERSION_OPT@@";
 
+    private static final boolean isLTS =
+        "@@VERSION_OPT@@".startsWith("LTS");
+
+    private static final String VENDOR_VERSION_STRING =
+        "@@VENDOR_VERSION_STRING@@";
+
+    private static final String vendor_version =
+        (VENDOR_VERSION_STRING.length() > 0
+         ? " " + VENDOR_VERSION_STRING : "");
+
     static {
         init();
     }
 
     public static void init() {
         System.setProperty("java.version", java_version);
+        System.setProperty("java.version.date", java_version_date);
         System.setProperty("java.runtime.version", java_runtime_version);
         System.setProperty("java.runtime.name", java_runtime_name);
+        if (VENDOR_VERSION_STRING.length() > 0)
+            System.setProperty("java.vendor.version", VENDOR_VERSION_STRING);
     }
 
     private static int parseVersionNumber(String version, int prevIndex, int index) {
@@ -162,31 +177,36 @@
 
         /* First line: platform version. */
         if (err) {
-            ps.println(launcher_name + " version \"" + java_version + "\"");
+            ps.println(launcher_name + " version \"" + java_version + "\""
+                       + " " + java_version_date
+                       + (isLTS ? " LTS" : ""));
         } else {
             /* Use a format more in line with GNU conventions */
-            ps.println(launcher_name + " " + java_version);
+            ps.println(launcher_name + " " + java_version
+                       + " " + java_version_date
+                       + (isLTS ? " LTS" : ""));
         }
 
         /* Second line: runtime version (ie, libraries). */
         String jdk_debug_level = System.getProperty("jdk.debug", "release");
-        /* Debug level is not printed for "release" builds */
         if ("release".equals(jdk_debug_level)) {
+           /* Do not show debug level "release" builds */
             jdk_debug_level = "";
         } else {
             jdk_debug_level = jdk_debug_level + " ";
         }
 
-        ps.print(java_runtime_name + " (" + jdk_debug_level + "build " + java_runtime_version);
-
-        ps.println(')');
+        ps.println(java_runtime_name + vendor_version
+                   + " (" + jdk_debug_level + "build " + java_runtime_version + ")");
 
         /* Third line: JVM information. */
         String java_vm_name    = System.getProperty("java.vm.name");
         String java_vm_version = System.getProperty("java.vm.version");
         String java_vm_info    = System.getProperty("java.vm.info");
-        ps.println(java_vm_name + " (" + jdk_debug_level + "build " + java_vm_version + ", " +
-                   java_vm_info + ")");
+        ps.println(java_vm_name + vendor_version
+                   + " (" + jdk_debug_level + "build " + java_vm_version + ", "
+                            + java_vm_info + ")");
+
     }
 
 }
--- a/src/java.base/share/classes/java/util/Optional.java	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/java.base/share/classes/java/util/Optional.java	Mon Dec 18 10:28:43 2017 -0800
@@ -32,8 +32,9 @@
 
 /**
  * A container object which may or may not contain a non-{@code null} value.
- * If a value is present, {@code isPresent()} returns {@code true} and
- * {@code get()} returns the value.
+ * If a value is present, {@code isPresent()} returns {@code true}. If no
+ * value is present, the object is considered <i>empty</i> and
+ * {@code isPresent()} returns {@code false}.
  *
  * <p>Additional methods that depend on the presence or absence of a contained
  * value are provided, such as {@link #orElse(Object) orElse()}
@@ -137,14 +138,10 @@
      * {@code NoSuchElementException}.
      *
      * @apiNote
-     * The methods {@link #orElse(Object) orElse} and
-     * {@link #orElseGet(Supplier) orElseGet}
-     * are generally preferable to this method, as they return a substitute
-     * value if the value is absent, instead of throwing an exception.
+     * The preferred alternative to this method is {@link #orElseThrow()}.
      *
      * @return the non-{@code null} value described by this {@code Optional}
      * @throws NoSuchElementException if no value is present
-     * @see Optional#isPresent()
      */
     public T get() {
         if (value == null) {
@@ -362,6 +359,21 @@
     }
 
     /**
+     * If a value is present, returns the value, otherwise throws
+     * {@code NoSuchElementException}.
+     *
+     * @return the non-{@code null} value described by this {@code Optional}
+     * @throws NoSuchElementException if no value is present
+     * @since 10
+     */
+    public T orElseThrow() {
+        if (value == null) {
+            throw new NoSuchElementException("No value present");
+        }
+        return value;
+    }
+
+    /**
      * If a value is present, returns the value, otherwise throws an exception
      * produced by the exception supplying function.
      *
--- a/src/java.base/share/classes/java/util/OptionalDouble.java	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/java.base/share/classes/java/util/OptionalDouble.java	Mon Dec 18 10:28:43 2017 -0800
@@ -30,9 +30,10 @@
 import java.util.stream.DoubleStream;
 
 /**
- * A container object which may or may not contain a {@code double} value.  If a
- * value is present, {@code isPresent()} returns {@code true} and
- * {@code getAsDouble()} returns the value.
+ * A container object which may or may not contain a {@code double} value.
+ * If a value is present, {@code isPresent()} returns {@code true}. If no
+ * value is present, the object is considered <i>empty</i> and
+ * {@code isPresent()} returns {@code false}.
  *
  * <p>Additional methods that depend on the presence or absence of a contained
  * value are provided, such as {@link #orElse(double) orElse()}
@@ -117,14 +118,10 @@
      * {@code NoSuchElementException}.
      *
      * @apiNote
-     * The methods {@link #orElse(double) orElse} and
-     * {@link #orElseGet(DoubleSupplier) orElseGet}
-     * are generally preferable to this method, as they return a substitute
-     * value if the value is absent, instead of throwing an exception.
+     * The preferred alternative to this method is {@link #orElseThrow()}.
      *
      * @return the value described by this {@code OptionalDouble}
      * @throws NoSuchElementException if no value is present
-     * @see OptionalDouble#isPresent()
      */
     public double getAsDouble() {
         if (!isPresent) {
@@ -226,6 +223,21 @@
     }
 
     /**
+     * If a value is present, returns the value, otherwise throws
+     * {@code NoSuchElementException}.
+     *
+     * @return the value described by this {@code OptionalDouble}
+     * @throws NoSuchElementException if no value is present
+     * @since 10
+     */
+    public double orElseThrow() {
+        if (!isPresent) {
+            throw new NoSuchElementException("No value present");
+        }
+        return value;
+    }
+
+    /**
      * If a value is present, returns the value, otherwise throws an exception
      * produced by the exception supplying function.
      *
--- a/src/java.base/share/classes/java/util/OptionalInt.java	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/java.base/share/classes/java/util/OptionalInt.java	Mon Dec 18 10:28:43 2017 -0800
@@ -30,9 +30,10 @@
 import java.util.stream.IntStream;
 
 /**
- * A container object which may or may not contain an {@code int} value.  If a
- * value is present, {@code isPresent()} returns {@code true} and
- * {@code getAsInt()} returns the value.
+ * A container object which may or may not contain an {@code int} value.
+ * If a value is present, {@code isPresent()} returns {@code true}. If no
+ * value is present, the object is considered <i>empty</i> and
+ * {@code isPresent()} returns {@code false}.
  *
  * <p>Additional methods that depend on the presence or absence of a contained
  * value are provided, such as {@link #orElse(int) orElse()}
@@ -117,14 +118,10 @@
      * {@code NoSuchElementException}.
      *
      * @apiNote
-     * The methods {@link #orElse(int) orElse} and
-     * {@link #orElseGet(IntSupplier) orElseGet}
-     * are generally preferable to this method, as they return a substitute
-     * value if the value is absent, instead of throwing an exception.
+     * The preferred alternative to this method is {@link #orElseThrow()}.
      *
      * @return the value described by this {@code OptionalInt}
      * @throws NoSuchElementException if no value is present
-     * @see OptionalInt#isPresent()
      */
     public int getAsInt() {
         if (!isPresent) {
@@ -225,6 +222,21 @@
     }
 
     /**
+     * If a value is present, returns the value, otherwise throws
+     * {@code NoSuchElementException}.
+     *
+     * @return the value described by this {@code OptionalInt}
+     * @throws NoSuchElementException if no value is present
+     * @since 10
+     */
+    public int orElseThrow() {
+        if (!isPresent) {
+            throw new NoSuchElementException("No value present");
+        }
+        return value;
+    }
+
+    /**
      * If a value is present, returns the value, otherwise throws an exception
      * produced by the exception supplying function.
      *
--- a/src/java.base/share/classes/java/util/OptionalLong.java	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/java.base/share/classes/java/util/OptionalLong.java	Mon Dec 18 10:28:43 2017 -0800
@@ -30,9 +30,10 @@
 import java.util.stream.LongStream;
 
 /**
- * A container object which may or may not contain a {@code long} value.  If a
- * value is present, {@code isPresent()} returns {@code true} and
- * {@code getAsLong()} returns the value.
+ * A container object which may or may not contain a {@code long} value.
+ * If a value is present, {@code isPresent()} returns {@code true}. If no
+ * value is present, the object is considered <i>empty</i> and
+ * {@code isPresent()} returns {@code false}.
  *
  * <p>Additional methods that depend on the presence or absence of a contained
  * value are provided, such as {@link #orElse(long) orElse()}
@@ -117,14 +118,10 @@
      * {@code NoSuchElementException}.
      *
      * @apiNote
-     * The methods {@link #orElse(long) orElse} and
-     * {@link #orElseGet(LongSupplier) orElseGet}
-     * are generally preferable to this method, as they return a substitute
-     * value if the value is absent, instead of throwing an exception.
+     * The preferred alternative to this method is {@link #orElseThrow()}.
      *
      * @return the value described by this {@code OptionalLong}
      * @throws NoSuchElementException if no value is present
-     * @see OptionalLong#isPresent()
      */
     public long getAsLong() {
         if (!isPresent) {
@@ -225,6 +222,21 @@
     }
 
     /**
+     * If a value is present, returns the value, otherwise throws
+     * {@code NoSuchElementException}.
+     *
+     * @return the value described by this {@code OptionalLong}
+     * @throws NoSuchElementException if no value is present
+     * @since 10
+     */
+    public long orElseThrow() {
+        if (!isPresent) {
+            throw new NoSuchElementException("No value present");
+        }
+        return value;
+    }
+
+    /**
      * If a value is present, returns the value, otherwise throws an exception
      * produced by the exception supplying function.
      *
--- a/src/java.base/share/classes/java/util/jar/JarFile.java	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/java.base/share/classes/java/util/jar/JarFile.java	Mon Dec 18 10:28:43 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -112,9 +112,9 @@
  * <li>
  * {@code jdk.util.jar.version} can be assigned a value that is the
  * {@code String} representation of a non-negative integer
- * {@code <= Runtime.version().major()}.  The value is used to set the effective
+ * {@code <= Runtime.version().feature()}.  The value is used to set the effective
  * runtime version to something other than the default value obtained by
- * evaluating {@code Runtime.version().major()}. The effective runtime version
+ * evaluating {@code Runtime.version().feature()}. The effective runtime version
  * is the version that the {@link JarFile#JarFile(File, boolean, int, Runtime.Version)}
  * constructor uses when the value of the last argument is
  * {@code JarFile.runtimeVersion()}.
@@ -143,7 +143,7 @@
 public
 class JarFile extends ZipFile {
     private final static Runtime.Version BASE_VERSION;
-    private final static int BASE_VERSION_MAJOR;
+    private final static int BASE_VERSION_FEATURE;
     private final static Runtime.Version RUNTIME_VERSION;
     private final static boolean MULTI_RELEASE_ENABLED;
     private final static boolean MULTI_RELEASE_FORCED;
@@ -153,7 +153,7 @@
     private boolean jvInitialized;
     private boolean verify;
     private final Runtime.Version version;  // current version
-    private final int versionMajor;         // version.major()
+    private final int versionFeature;         // version.feature()
     private boolean isMultiRelease;         // is jar multi-release?
 
     // indicates if Class-Path attribute present
@@ -170,14 +170,14 @@
         JUZFA = jdk.internal.misc.SharedSecrets.getJavaUtilZipFileAccess();
         // multi-release jar file versions >= 9
         BASE_VERSION = Runtime.Version.parse(Integer.toString(8));
-        BASE_VERSION_MAJOR = BASE_VERSION.major();
+        BASE_VERSION_FEATURE = BASE_VERSION.feature();
         String jarVersion = GetPropertyAction.privilegedGetProperty("jdk.util.jar.version");
-        int runtimeVersion = Runtime.version().major();
+        int runtimeVersion = Runtime.version().feature();
         if (jarVersion != null) {
             int jarVer = Integer.parseInt(jarVersion);
             runtimeVersion = (jarVer > runtimeVersion)
                     ? runtimeVersion
-                    : Math.max(jarVer, BASE_VERSION_MAJOR);
+                    : Math.max(jarVer, BASE_VERSION_FEATURE);
         }
         RUNTIME_VERSION = Runtime.Version.parse(Integer.toString(runtimeVersion));
         String enableMultiRelease = GetPropertyAction
@@ -224,10 +224,10 @@
      * Returns the version that represents the effective runtime versioned
      * configuration of a multi-release jar file.
      * <p>
-     * By default the major version number of the returned {@code Version} will
-     * be equal to the major version number of {@code Runtime.version()}.
+     * By default the feature version number of the returned {@code Version} will
+     * be equal to the feature version number of {@code Runtime.version()}.
      * However, if the {@code jdk.util.jar.version} property is set, the
-     * returned {@code Version} is derived from that property and major version
+     * returned {@code Version} is derived from that property and feature version
      * numbers may not be equal.
      *
      * @return the version that represents the runtime versioned configuration
@@ -322,7 +322,7 @@
      * <p>
      * The canonical form derived from the version parameter is
      * {@code Runtime.Version.parse(Integer.toString(n))} where {@code n} is
-     * {@code Math.max(version.major(), JarFile.baseVersion().major())}.
+     * {@code Math.max(version.feature(), JarFile.baseVersion().feature())}.
      *
      * @param file the jar file to be opened for reading
      * @param verify whether or not to verify the jar file if
@@ -341,17 +341,17 @@
         super(file, mode);
         this.verify = verify;
         Objects.requireNonNull(version);
-        if (MULTI_RELEASE_FORCED || version.major() == RUNTIME_VERSION.major()) {
+        if (MULTI_RELEASE_FORCED || version.feature() == RUNTIME_VERSION.feature()) {
             // This deals with the common case where the value from JarFile.runtimeVersion() is passed
             this.version = RUNTIME_VERSION;
-        } else if (version.major() <= BASE_VERSION_MAJOR) {
+        } else if (version.feature() <= BASE_VERSION_FEATURE) {
             // This also deals with the common case where the value from JarFile.baseVersion() is passed
             this.version = BASE_VERSION;
         } else {
             // Canonicalize
-            this.version = Runtime.Version.parse(Integer.toString(version.major()));
+            this.version = Runtime.Version.parse(Integer.toString(version.feature()));
         }
-        this.versionMajor = this.version.major();
+        this.versionFeature = this.version.feature();
     }
 
     /**
@@ -579,7 +579,7 @@
                 // filter out dir META-INF/versions/ and META-INF/versions/*/
                 // and any entry with version > 'version'
                 if (index == -1 || index == (name.length() - 1) ||
-                    Integer.parseInt(name, off, index, 10) > versionMajor) {
+                    Integer.parseInt(name, off, index, 10) > versionFeature) {
                     return null;
                 }
             } catch (NumberFormatException x) {
@@ -592,11 +592,11 @@
     }
 
     private JarEntry getVersionedEntry(String name, JarEntry je) {
-        if (BASE_VERSION_MAJOR < versionMajor) {
+        if (BASE_VERSION_FEATURE < versionFeature) {
             if (!name.startsWith(META_INF)) {
                 // search for versioned entry
-                int v = versionMajor;
-                while (v > BASE_VERSION_MAJOR) {
+                int v = versionFeature;
+                while (v > BASE_VERSION_FEATURE) {
                     JarFileEntry vje = getEntry0(META_INF_VERSIONS + v + "/" + name);
                     if (vje != null) {
                         return vje.withBasename(name);
@@ -673,7 +673,7 @@
         }
 
         JarFileEntry realEntry() {
-            if (isMultiRelease() && versionMajor != BASE_VERSION_MAJOR) {
+            if (isMultiRelease() && versionFeature != BASE_VERSION_FEATURE) {
                 String entryName = super.getName();
                 return entryName == basename || entryName.equals(basename) ?
                         this : new JarFileEntry(entryName, this);
--- a/src/java.base/share/classes/java/util/zip/Deflater.java	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/java.base/share/classes/java/util/zip/Deflater.java	Mon Dec 18 10:28:43 2017 -0800
@@ -25,6 +25,9 @@
 
 package java.util.zip;
 
+import java.lang.ref.Cleaner.Cleanable;
+import jdk.internal.ref.CleanerFactory;
+
 /**
  * This class provides support for general purpose compression using the
  * popular ZLIB compression library. The ZLIB compression library was
@@ -88,7 +91,7 @@
 
 public class Deflater {
 
-    private final ZStreamRef zsRef;
+    private final DeflaterZStreamRef zsRef;
     private byte[] buf = new byte[0];
     private int off, len;
     private int level, strategy;
@@ -183,9 +186,8 @@
     public Deflater(int level, boolean nowrap) {
         this.level = level;
         this.strategy = DEFAULT_STRATEGY;
-        this.zsRef = ZStreamRef.get(this,
-                () -> init(level, DEFAULT_STRATEGY, nowrap),
-                Deflater::end);
+        this.zsRef = DeflaterZStreamRef.get(this,
+                                    init(level, DEFAULT_STRATEGY, nowrap));
     }
 
     /**
@@ -591,4 +593,75 @@
     private static native int getAdler(long addr);
     private static native void reset(long addr);
     private static native void end(long addr);
+
+    /**
+     * A reference to the native zlib's z_stream structure. It also
+     * serves as the "cleaner" to clean up the native resource when
+     * the Deflater is ended, closed or cleaned.
+     */
+    static class DeflaterZStreamRef implements Runnable {
+
+        private long address;
+        private final Cleanable cleanable;
+
+        private DeflaterZStreamRef(Deflater owner, long addr) {
+            this.cleanable = (owner != null) ? CleanerFactory.cleaner().register(owner, this) : null;
+            this.address = addr;
+        }
+
+        long address() {
+            return address;
+        }
+
+        void clean() {
+            cleanable.clean();
+        }
+
+        public synchronized void run() {
+            long addr = address;
+            address = 0;
+            if (addr != 0) {
+                end(addr);
+            }
+        }
+
+        /*
+         * If {@code Deflater} has been subclassed and the {@code end} method is
+         * overridden, uses {@code finalizer} mechanism for resource cleanup. So
+         * {@code end} method can be called when the {@code Deflater} is unreachable.
+         * This mechanism will be removed when the {@code finalize} method is
+         * removed from {@code Deflater}.
+         */
+        static DeflaterZStreamRef get(Deflater owner, long addr) {
+            Class<?> clz = owner.getClass();
+            while (clz != Deflater.class) {
+                try {
+                    clz.getDeclaredMethod("end");
+                    return new FinalizableZStreamRef(owner, addr);
+                } catch (NoSuchMethodException nsme) {}
+                clz = clz.getSuperclass();
+            }
+            return new DeflaterZStreamRef(owner, addr);
+        }
+
+        private static class FinalizableZStreamRef extends DeflaterZStreamRef {
+            final Deflater owner;
+
+            FinalizableZStreamRef (Deflater owner, long addr) {
+                super(null, addr);
+                this.owner = owner;
+            }
+
+            @Override
+            void clean() {
+                run();
+            }
+
+            @Override
+            @SuppressWarnings("deprecation")
+            protected void finalize() {
+                owner.end();
+            }
+        }
+    }
 }
--- a/src/java.base/share/classes/java/util/zip/Inflater.java	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/java.base/share/classes/java/util/zip/Inflater.java	Mon Dec 18 10:28:43 2017 -0800
@@ -25,6 +25,9 @@
 
 package java.util.zip;
 
+import java.lang.ref.Cleaner.Cleanable;
+import jdk.internal.ref.CleanerFactory;
+
 /**
  * This class provides support for general purpose decompression using the
  * popular ZLIB compression library. The ZLIB compression library was
@@ -88,7 +91,7 @@
 
 public class Inflater {
 
-    private final ZStreamRef zsRef;
+    private final InflaterZStreamRef zsRef;
     private byte[] buf = defaultBuf;
     private int off, len;
     private boolean finished;
@@ -115,7 +118,7 @@
      * @param nowrap if true then support GZIP compatible compression
      */
     public Inflater(boolean nowrap) {
-        this.zsRef = ZStreamRef.get(this, () -> init(nowrap), Inflater::end);
+        this.zsRef = InflaterZStreamRef.get(this, init(nowrap));
     }
 
     /**
@@ -428,4 +431,75 @@
     private static native int getAdler(long addr);
     private static native void reset(long addr);
     private static native void end(long addr);
+
+    /**
+     * A reference to the native zlib's z_stream structure. It also
+     * serves as the "cleaner" to clean up the native resource when
+     * the Inflater is ended, closed or cleaned.
+     */
+    static class InflaterZStreamRef implements Runnable {
+
+        private long address;
+        private final Cleanable cleanable;
+
+        private InflaterZStreamRef(Inflater owner, long addr) {
+            this.cleanable = (owner != null) ? CleanerFactory.cleaner().register(owner, this) : null;
+            this.address = addr;
+        }
+
+        long address() {
+            return address;
+        }
+
+        void clean() {
+            cleanable.clean();
+        }
+
+        public synchronized void run() {
+            long addr = address;
+            address = 0;
+            if (addr != 0) {
+                end(addr);
+            }
+        }
+
+        /*
+         * If {@code Inflater} has been subclassed and the {@code end} method is
+         * overridden, uses {@code finalizer} mechanism for resource cleanup. So
+         * {@code end} method can be called when the {@code Inflater} is unreachable.
+         * This mechanism will be removed when the {@code finalize} method is
+         * removed from {@code Inflater}.
+         */
+        static InflaterZStreamRef get(Inflater owner, long addr) {
+            Class<?> clz = owner.getClass();
+            while (clz != Inflater.class) {
+                try {
+                    clz.getDeclaredMethod("end");
+                    return new FinalizableZStreamRef(owner, addr);
+                } catch (NoSuchMethodException nsme) {}
+                clz = clz.getSuperclass();
+            }
+            return new InflaterZStreamRef(owner, addr);
+        }
+
+        private static class FinalizableZStreamRef extends InflaterZStreamRef {
+            final Inflater owner;
+
+            FinalizableZStreamRef(Inflater owner, long addr) {
+                super(null, addr);
+                this.owner = owner;
+            }
+
+            @Override
+            void clean() {
+                run();
+            }
+
+            @Override
+            @SuppressWarnings("deprecation")
+            protected void finalize() {
+                owner.end();
+            }
+        }
+    }
 }
--- a/src/java.base/share/classes/java/util/zip/ZStreamRef.java	Wed Dec 13 14:21:12 2017 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.util.zip;
-
-import java.util.function.LongConsumer;
-import java.util.function.LongSupplier;
-import java.lang.ref.Cleaner.Cleanable;
-import jdk.internal.ref.CleanerFactory;
-
-/**
- * A reference to the native zlib's z_stream structure. It also
- * serves as the "cleaner" to clean up the native resource when
- * the deflater or infalter is ended, closed or cleaned.
- */
-class ZStreamRef implements Runnable {
-
-    private LongConsumer end;
-    private long address;
-    private final Cleanable cleanable;
-
-    private ZStreamRef (Object owner, LongSupplier addr, LongConsumer end) {
-        this.cleanable = CleanerFactory.cleaner().register(owner, this);
-        this.end = end;
-        this.address = addr.getAsLong();
-    }
-
-    long address() {
-        return address;
-    }
-
-    void clean() {
-        cleanable.clean();
-    }
-
-    public synchronized void run() {
-        long addr = address;
-        address = 0;
-        if (addr != 0) {
-            end.accept(addr);
-        }
-    }
-
-    private ZStreamRef (LongSupplier addr, LongConsumer end) {
-        this.cleanable = null;
-        this.end = end;
-        this.address = addr.getAsLong();
-    }
-
-    /*
-     * If {@code Inflater/Deflater} has been subclassed and the {@code end} method
-     * is overridden, uses {@code finalizer} mechanism for resource cleanup. So
-     * {@code end} method can be called when the {@code Inflater/Deflater} is
-     * unreachable. This mechanism will be removed when the {@code finalize} method
-     * is removed from {@code Inflater/Deflater}.
-     */
-    static ZStreamRef get(Object owner, LongSupplier addr, LongConsumer end) {
-        Class<?> clz = owner.getClass();
-        while (clz != Deflater.class && clz != Inflater.class) {
-            try {
-                clz.getDeclaredMethod("end");
-                return new FinalizableZStreamRef(owner, addr, end);
-            } catch (NoSuchMethodException nsme) {}
-            clz = clz.getSuperclass();
-        }
-        return new ZStreamRef(owner, addr, end);
-    }
-
-    private static class FinalizableZStreamRef extends ZStreamRef {
-        final Object owner;
-
-        FinalizableZStreamRef (Object owner, LongSupplier addr, LongConsumer end) {
-            super(addr, end);
-            this.owner = owner;
-        }
-
-        @Override
-        void clean() {
-            run();
-        }
-
-        @Override
-        @SuppressWarnings("deprecation")
-        protected void finalize() {
-            if (owner instanceof Inflater)
-                ((Inflater)owner).end();
-            else
-                ((Deflater)owner).end();
-        }
-    }
-}
--- a/src/java.base/share/classes/java/util/zip/ZipFile.java	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/java.base/share/classes/java/util/zip/ZipFile.java	Mon Dec 18 10:28:43 2017 -0800
@@ -412,6 +412,21 @@
         }
     }
 
+    private static class InflaterCleanupAction implements Runnable {
+        private final Inflater inf;
+        private final CleanableResource res;
+
+        InflaterCleanupAction(Inflater inf, CleanableResource res) {
+            this.inf = inf;
+            this.res = res;
+        }
+
+        @Override
+        public void run() {
+            res.releaseInflater(inf);
+        }
+    }
+
     private class ZipFileInflaterInputStream extends InflaterInputStream {
         private volatile boolean closeRequested;
         private boolean eof = false;
@@ -427,8 +442,8 @@
                                            Inflater inf, int size) {
             super(zfin, inf, size);
             this.cleanable = CleanerFactory.cleaner().register(this,
-                    () -> res.releaseInflater(inf));
-       }
+                    new InflaterCleanupAction(inf, res));
+        }
 
         public void close() throws IOException {
             if (closeRequested)
--- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Wed Dec 13 14:21:12 2017 -0800
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Mon Dec 18 10:28:43 2017 -0800
@@ -1058,11 +1058,6 @@
                 System.err.println(form.format(source));
                 keyPass = storePass;
             }
-            if (newPass != null && !Arrays.equals(storePass, newPass)) {
-                Object[] source = {"-new"};
-                System.err.println(form.format(source));
-                newPass = storePass;
-            }
             if (destKeyPass != null && !Arrays.equals(storePass, destKeyPass)) {
                 Object[] source = {"-destkeypass"};
                 System.err.println(form.format(source));
@@ -1243,10 +1238,7 @@
             doSelfCert(alias, dname, sigAlgName);
             kssave = true;
         } else if (command == STOREPASSWD) {
-            storePassNew = newPass;
-            if (storePassNew == null) {
-                storePassNew = getNewPasswd("keystore password", storePass);
-            }
+            doChangeStorePasswd();
             kssave = true;
         } else if (command == GENCERT) {
             if (alias == null) {
@@ -2258,8 +2250,9 @@
             newPass = destKeyPass;
             pp = new PasswordProtection(destKeyPass);
         } else if (objs.snd != null) {
-            newPass = objs.snd;
-            pp = new PasswordProtection(objs.snd);
+            newPass = P12KEYSTORE.equalsIgnoreCase(storetype) ?
+                    storePass : objs.snd;
+            pp = new PasswordProtection(newPass);
         }
 
         try {
@@ -2762,6 +2755,28 @@
             }
         }
     }
+
+    private void doChangeStorePasswd() throws Exception {
+        storePassNew = newPass;
+        if (storePassNew == null) {
+            storePassNew = getNewPasswd("keystore password", storePass);
+        }
+        if (P12KEYSTORE.equalsIgnoreCase(storetype)) {
+            // When storetype is PKCS12, we need to change all keypass as well
+            for (String alias : Collections.list(keyStore.aliases())) {
+                if (!keyStore.isCertificateEntry(alias)) {
+                    // keyPass should be either null or same with storePass,
+                    // but keep it in case one day we want to "normalize"
+                    // a PKCS12 keystore having different passwords.
+                    Pair<Entry, char[]> objs
+                            = recoverEntry(keyStore, alias, storePass, keyPass);
+                    keyStore.setEntry(alias, objs.fst,
+                            new PasswordProtection(storePassNew));
+                }
+            }
+        }
+    }
+
     /**
      * Creates a self-signed certificate, and stores it as a single-element
      * certificate chain.
--- a/src/java.base/share/native/include/jvm.h	Wed Dec 13 14:21:12 2017 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1328 +0,0 @@
-/*
- * Copyright (c) 1997, 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.  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.
- */
-
-#ifndef _JAVASOFT_JVM_H_
-#define _JAVASOFT_JVM_H_
-
-#include <sys/stat.h>
-
-#include "jni.h"
-#include "jvm_md.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * This file contains additional functions exported from the VM.
- * These functions are complementary to the standard JNI support.
- * There are three parts to this file:
- *
- * First, this file contains the VM-related functions needed by native
- * libraries in the standard Java API. For example, the java.lang.Object
- * class needs VM-level functions that wait for and notify monitors.
- *
- * Second, this file contains the functions and constant definitions
- * needed by the byte code verifier and class file format checker.
- * These functions allow the verifier and format checker to be written
- * in a VM-independent way.
- *
- * Third, this file contains various I/O and network operations needed
- * by the standard Java I/O and network APIs.
- */
-
-/*
- * Bump the version number when either of the following happens:
- *
- * 1. There is a change in JVM_* functions.
- *
- * 2. There is a change in the contract between VM and Java classes.
- *    For example, if the VM relies on a new private field in Thread
- *    class.
- */
-
-#define JVM_INTERFACE_VERSION 5
-
-JNIEXPORT jint JNICALL
-JVM_GetInterfaceVersion(void);
-
-/*************************************************************************
- PART 1: Functions for Native Libraries
- ************************************************************************/
-/*
- * java.lang.Object
- */
-JNIEXPORT jint JNICALL
-JVM_IHashCode(JNIEnv *env, jobject obj);
-
-JNIEXPORT void JNICALL
-JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms);
-
-JNIEXPORT void JNICALL
-JVM_MonitorNotify(JNIEnv *env, jobject obj);
-
-JNIEXPORT void JNICALL
-JVM_MonitorNotifyAll(JNIEnv *env, jobject obj);
-
-JNIEXPORT jobject JNICALL
-JVM_Clone(JNIEnv *env, jobject obj);
-
-/*
- * java.lang.String
- */
-JNIEXPORT jstring JNICALL
-JVM_InternString(JNIEnv *env, jstring str);
-
-/*
- * java.lang.System
- */
-JNIEXPORT jlong JNICALL
-JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored);
-
-JNIEXPORT jlong JNICALL
-JVM_NanoTime(JNIEnv *env, jclass ignored);
-
-JNIEXPORT jlong JNICALL
-JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs);
-
-JNIEXPORT void JNICALL
-JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
-              jobject dst, jint dst_pos, jint length);
-
-JNIEXPORT jobject JNICALL
-JVM_InitProperties(JNIEnv *env, jobject p);
-
-
-/*
- * java.lang.Runtime
- */
-JNIEXPORT void JNICALL
-JVM_Halt(jint code);
-
-JNIEXPORT void JNICALL
-JVM_GC(void);
-
-/* Returns the number of real-time milliseconds that have elapsed since the
- * least-recently-inspected heap object was last inspected by the garbage
- * collector.
- *
- * For simple stop-the-world collectors this value is just the time
- * since the most recent collection.  For generational collectors it is the
- * time since the oldest generation was most recently collected.  Other
- * collectors are free to return a pessimistic estimate of the elapsed time, or
- * simply the time since the last full collection was performed.
- *
- * Note that in the presence of reference objects, a given object that is no
- * longer strongly reachable may have to be inspected multiple times before it
- * can be reclaimed.
- */
-JNIEXPORT jlong JNICALL
-JVM_MaxObjectInspectionAge(void);
-
-JNIEXPORT jlong JNICALL
-JVM_TotalMemory(void);
-
-JNIEXPORT jlong JNICALL
-JVM_FreeMemory(void);
-
-JNIEXPORT jlong JNICALL
-JVM_MaxMemory(void);
-
-JNIEXPORT jint JNICALL
-JVM_ActiveProcessorCount(void);
-
-JNIEXPORT void * JNICALL
-JVM_LoadLibrary(const char *name);
-
-JNIEXPORT void JNICALL
-JVM_UnloadLibrary(void * handle);
-
-JNIEXPORT void * JNICALL
-JVM_FindLibraryEntry(void *handle, const char *name);
-
-JNIEXPORT jboolean JNICALL
-JVM_IsSupportedJNIVersion(jint version);
-
-JNIEXPORT jobjectArray JNICALL
-JVM_GetVmArguments(JNIEnv *env);
-
-
-/*
- * java.lang.Throwable
- */
-JNIEXPORT void JNICALL
-JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
-
-/*
- * java.lang.StackTraceElement
- */
-JNIEXPORT void JNICALL
-JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable);
-
-JNIEXPORT void JNICALL
-JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo);
-
-/*
- * java.lang.StackWalker
- */
-enum {
-  JVM_STACKWALK_FILL_CLASS_REFS_ONLY       = 0x2,
-  JVM_STACKWALK_GET_CALLER_CLASS           = 0x04,
-  JVM_STACKWALK_SHOW_HIDDEN_FRAMES         = 0x20,
-  JVM_STACKWALK_FILL_LIVE_STACK_FRAMES     = 0x100
-};
-
-JNIEXPORT jobject JNICALL
-JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jlong mode,
-                  jint skip_frames, jint frame_count, jint start_index,
-                  jobjectArray frames);
-
-JNIEXPORT jint JNICALL
-JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jlong mode, jlong anchor,
-                  jint frame_count, jint start_index,
-                  jobjectArray frames);
-
-/*
- * java.lang.Thread
- */
-JNIEXPORT void JNICALL
-JVM_StartThread(JNIEnv *env, jobject thread);
-
-JNIEXPORT void JNICALL
-JVM_StopThread(JNIEnv *env, jobject thread, jobject exception);
-
-JNIEXPORT jboolean JNICALL
-JVM_IsThreadAlive(JNIEnv *env, jobject thread);
-
-JNIEXPORT void JNICALL
-JVM_SuspendThread(JNIEnv *env, jobject thread);
-
-JNIEXPORT void JNICALL
-JVM_ResumeThread(JNIEnv *env, jobject thread);
-
-JNIEXPORT void JNICALL
-JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
-
-JNIEXPORT void JNICALL
-JVM_Yield(JNIEnv *env, jclass threadClass);
-
-JNIEXPORT void JNICALL
-JVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis);
-
-JNIEXPORT jobject JNICALL
-JVM_CurrentThread(JNIEnv *env, jclass threadClass);
-
-JNIEXPORT jint JNICALL
-JVM_CountStackFrames(JNIEnv *env, jobject thread);
-
-JNIEXPORT void JNICALL
-JVM_Interrupt(JNIEnv *env, jobject thread);
-
-JNIEXPORT jboolean JNICALL
-JVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted);
-
-JNIEXPORT jboolean JNICALL
-JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj);
-
-JNIEXPORT void JNICALL
-JVM_DumpAllStacks(JNIEnv *env, jclass unused);
-
-JNIEXPORT jobjectArray JNICALL
-JVM_GetAllThreads(JNIEnv *env, jclass dummy);
-
-JNIEXPORT void JNICALL
-JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name);
-
-/* getStackTrace() and getAllStackTraces() method */
-JNIEXPORT jobjectArray JNICALL
-JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
-
-/*
- * java.lang.SecurityManager
- */
-JNIEXPORT jobjectArray JNICALL
-JVM_GetClassContext(JNIEnv *env);
-
-/*
- * java.lang.Package
- */
-JNIEXPORT jstring JNICALL
-JVM_GetSystemPackage(JNIEnv *env, jstring name);
-
-JNIEXPORT jobjectArray JNICALL
-JVM_GetSystemPackages(JNIEnv *env);
-
-/*
- * java.lang.ref.Reference
- */
-JNIEXPORT jobject JNICALL
-JVM_GetAndClearReferencePendingList(JNIEnv *env);
-
-JNIEXPORT jboolean JNICALL
-JVM_HasReferencePendingList(JNIEnv *env);
-
-JNIEXPORT void JNICALL
-JVM_WaitForReferencePendingList(JNIEnv *env);
-
-/*
- * java.io.ObjectInputStream
- */
-JNIEXPORT jobject JNICALL
-JVM_LatestUserDefinedLoader(JNIEnv *env);
-
-/*
- * java.lang.reflect.Array
- */
-JNIEXPORT jint JNICALL
-JVM_GetArrayLength(JNIEnv *env, jobject arr);
-
-JNIEXPORT jobject JNICALL
-JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index);
-
-JNIEXPORT jvalue JNICALL
-JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode);
-
-JNIEXPORT void JNICALL
-JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val);
-
-JNIEXPORT void JNICALL
-JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v,
-                             unsigned char vCode);
-
-JNIEXPORT jobject JNICALL
-JVM_NewArray(JNIEnv *env, jclass eltClass, jint length);
-
-JNIEXPORT jobject JNICALL
-JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
-
-/*
- * java.lang.Class and java.lang.ClassLoader
- */
-
-#define JVM_CALLER_DEPTH -1
-
-/*
- * Returns the immediate caller class of the native method invoking
- * JVM_GetCallerClass.  The Method.invoke and other frames due to
- * reflection machinery are skipped.
- *
- * The depth parameter must be -1 (JVM_DEPTH). The caller is expected
- * to be marked with sun.reflect.CallerSensitive.  The JVM will throw
- * an error if it is not marked propertly.
- */
-JNIEXPORT jclass JNICALL
-JVM_GetCallerClass(JNIEnv *env, int depth);
-
-
-/*
- * Find primitive classes
- * utf: class name
- */
-JNIEXPORT jclass JNICALL
-JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
-
-
-/*
- * Find a class from a boot class loader. Returns NULL if class not found.
- */
-JNIEXPORT jclass JNICALL
-JVM_FindClassFromBootLoader(JNIEnv *env, const char *name);
-
-/*
- * Find a class from a given class loader.  Throws ClassNotFoundException.
- *  name:   name of class
- *  init:   whether initialization is done
- *  loader: class loader to look up the class. This may not be the same as the caller's
- *          class loader.
- *  caller: initiating class. The initiating class may be null when a security
- *          manager is not installed.
- */
-JNIEXPORT jclass JNICALL
-JVM_FindClassFromCaller(JNIEnv *env, const char *name, jboolean init,
-                        jobject loader, jclass caller);
-
-/*
- * Find a class from a given class.
- */
-JNIEXPORT jclass JNICALL
-JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init,
-                             jclass from);
-
-/* Find a loaded class cached by the VM */
-JNIEXPORT jclass JNICALL
-JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name);
-
-/* Define a class */
-JNIEXPORT jclass JNICALL
-JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
-                jsize len, jobject pd);
-
-/* Define a class with a source (added in JDK1.5) */
-JNIEXPORT jclass JNICALL
-JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader,
-                          const jbyte *buf, jsize len, jobject pd,
-                          const char *source);
-
-/*
- * Module support funcions
- */
-
-/*
- * Define a module with the specified packages and bind the module to the
- * given class loader.
- *  module:       module to define
- *  is_open:      specifies if module is open (currently ignored)
- *  version:      the module version
- *  location:     the module location
- *  packages:     list of packages in the module
- *  num_packages: number of packages in the module
- */
-JNIEXPORT void JNICALL
-JVM_DefineModule(JNIEnv *env, jobject module, jboolean is_open, jstring version,
-                 jstring location, const char* const* packages, jsize num_packages);
-
-/*
- * Set the boot loader's unnamed module.
- *  module: boot loader's unnamed module
- */
-JNIEXPORT void JNICALL
-JVM_SetBootLoaderUnnamedModule(JNIEnv *env, jobject module);
-
-/*
- * Do a qualified export of a package.
- *  from_module: module containing the package to export
- *  package:     name of the package to export
- *  to_module:   module to export the package to
- */
-JNIEXPORT void JNICALL
-JVM_AddModuleExports(JNIEnv *env, jobject from_module, const char* package, jobject to_module);
-
-/*
- * Do an export of a package to all unnamed modules.
- *  from_module: module containing the package to export
- *  package:     name of the package to export to all unnamed modules
- */
-JNIEXPORT void JNICALL
-JVM_AddModuleExportsToAllUnnamed(JNIEnv *env, jobject from_module, const char* package);
-
-/*
- * Do an unqualified export of a package.
- *  from_module: module containing the package to export
- *  package:     name of the package to export
- */
-JNIEXPORT void JNICALL
-JVM_AddModuleExportsToAll(JNIEnv *env, jobject from_module, const char* package);
-
-/*
- * Add a module to the list of modules that a given module can read.
- *  from_module:   module requesting read access
- *  source_module: module that from_module wants to read
- */
-JNIEXPORT void JNICALL
-JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject source_module);
-
-/*
- * Reflection support functions
- */
-
-JNIEXPORT jstring JNICALL
-JVM_GetClassName(JNIEnv *env, jclass cls);
-
-JNIEXPORT jobjectArray JNICALL
-JVM_GetClassInterfaces(JNIEnv *env, jclass cls);
-
-JNIEXPORT jboolean JNICALL
-JVM_IsInterface(JNIEnv *env, jclass cls);
-
-JNIEXPORT jobjectArray JNICALL
-JVM_GetClassSigners(JNIEnv *env, jclass cls);
-
-JNIEXPORT void JNICALL
-JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers);
-
-JNIEXPORT jobject JNICALL
-JVM_GetProtectionDomain(JNIEnv *env, jclass cls);
-
-JNIEXPORT jboolean JNICALL
-JVM_IsArrayClass(JNIEnv *env, jclass cls);
-
-JNIEXPORT jboolean JNICALL
-JVM_IsPrimitiveClass(JNIEnv *env, jclass cls);
-
-JNIEXPORT jint JNICALL
-JVM_GetClassModifiers(JNIEnv *env, jclass cls);
-
-JNIEXPORT jobjectArray JNICALL
-JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass);
-
-JNIEXPORT jclass JNICALL
-JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass);
-
-JNIEXPORT jstring JNICALL
-JVM_GetSimpleBinaryName(JNIEnv *env, jclass ofClass);
-
-/* Generics support (JDK 1.5) */
-JNIEXPORT jstring JNICALL
-JVM_GetClassSignature(JNIEnv *env, jclass cls);
-
-/* Annotations support (JDK 1.5) */
-JNIEXPORT jbyteArray JNICALL
-JVM_GetClassAnnotations(JNIEnv *env, jclass cls);
-
-/* Type use annotations support (JDK 1.8) */
-
-JNIEXPORT jbyteArray JNICALL
-JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls);
-
-JNIEXPORT jbyteArray JNICALL
-JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field);
-
-JNIEXPORT jbyteArray JNICALL
-JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method);
-
-/*
- * New (JDK 1.4) reflection implementation
- */
-
-JNIEXPORT jobjectArray JNICALL
-JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly);
-
-JNIEXPORT jobjectArray JNICALL
-JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly);
-
-JNIEXPORT jobjectArray JNICALL
-JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly);
-
-/* Differs from JVM_GetClassModifiers in treatment of inner classes.
-   This returns the access flags for the class as specified in the
-   class file rather than searching the InnerClasses attribute (if
-   present) to find the source-level access flags. Only the values of
-   the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
-   valid. */
-JNIEXPORT jint JNICALL
-JVM_GetClassAccessFlags(JNIEnv *env, jclass cls);
-
-/* The following two reflection routines are still needed due to startup time issues */
-/*
- * java.lang.reflect.Method
- */
-JNIEXPORT jobject JNICALL
-JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0);
-
-/*
- * java.lang.reflect.Constructor
- */
-JNIEXPORT jobject JNICALL
-JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
-
-/*
- * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5)
- */
-
-JNIEXPORT jobject JNICALL
-JVM_GetClassConstantPool(JNIEnv *env, jclass cls);
-
-JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize
-(JNIEnv *env, jobject unused, jobject jcpool);
-
-JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt
-(JNIEnv *env, jobject unused, jobject jcpool, jint index);
-
-JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded
-(JNIEnv *env, jobject unused, jobject jcpool, jint index);
-
-JNIEXPORT jint JNICALL JVM_ConstantPoolGetClassRefIndexAt
-(JNIEnv *env, jobject obj, jobject unused, jint index);
-
-JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt
-(JNIEnv *env, jobject unused, jobject jcpool, jint index);
-
-JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded
-(JNIEnv *env, jobject unused, jobject jcpool, jint index);
-
-JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt
-(JNIEnv *env, jobject unused, jobject jcpool, jint index);
-
-JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded
-(JNIEnv *env, jobject unused, jobject jcpool, jint index);
-
-JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt
-(JNIEnv *env, jobject unused, jobject jcpool, jint index);
-
-JNIEXPORT jint JNICALL JVM_ConstantPoolGetNameAndTypeRefIndexAt
-(JNIEnv *env, jobject obj, jobject unused, jint index);
-
-JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetNameAndTypeRefInfoAt
-(JNIEnv *env, jobject obj, jobject unused, jint index);
-
-JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt
-(JNIEnv *env, jobject unused, jobject jcpool, jint index);
-
-JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt
-(JNIEnv *env, jobject unused, jobject jcpool, jint index);
-
-JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt
-(JNIEnv *env, jobject unused, jobject jcpool, jint index);
-
-JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt
-(JNIEnv *env, jobject unused, jobject jcpool, jint index);
-
-JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt
-(JNIEnv *env, jobject unused, jobject jcpool, jint index);
-
-JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At
-(JNIEnv *env, jobject unused, jobject jcpool, jint index);
-
-JNIEXPORT jbyte JNICALL JVM_ConstantPoolGetTagAt
-(JNIEnv *env, jobject unused, jobject jcpool, jint index);
-
-/*
- * Parameter reflection
- */
-
-JNIEXPORT jobjectArray JNICALL
-JVM_GetMethodParameters(JNIEnv *env, jobject method);
-
-/*
- * java.security.*
- */
-
-JNIEXPORT jobject JNICALL
-JVM_DoPrivileged(JNIEnv *env, jclass cls,
-                 jobject action, jobject context, jboolean wrapException);
-
-JNIEXPORT jobject JNICALL
-JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls);
-
-JNIEXPORT jobject JNICALL
-JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls);
-
-/*
- * Signal support, used to implement the shutdown sequence.  Every VM must
- * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts
- * (^C) and the latter for external termination (kill, system shutdown, etc.).
- * Other platform-dependent signal values may also be supported.
- */
-
-JNIEXPORT void * JNICALL