changeset 48587:fd4052846c2f condy-folding

Automatic merge with condy
author mcimadamore
date Thu, 14 Dec 2017 22:06:54 +0100
parents 072c54670176 9d1bd3ea7ce2
children 14015b37d62f
files src/java.base/share/classes/java/lang/String.java src/java.base/share/classes/java/lang/StringDecoderUTF8.java 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.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/TMSchema.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsBorders.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsButtonListener.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsClassicLookAndFeel.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopIconUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopPaneUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopProperty.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsEditorPaneUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsGraphicsUtils.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUIAccessor.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsOptionPaneUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsPasswordFieldUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupWindow.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsScrollPaneUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsSeparatorUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneDivider.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTextAreaUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTextFieldUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTextPaneUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTextUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsToolBarSeparatorUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsToolBarUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/Computer.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/DetailsView.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/Directory.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/Error.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/File.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/FloppyDrive.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/HardDrive.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/HomeFolder.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/Inform.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/JavaCup32.png src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/ListView.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/NewFolder.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/Question.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/TreeClosed.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/TreeLeaf.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/TreeOpen.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/UpFolder.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/Warn.gif src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/image-delayed.png src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/icons/image-failed.png src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows.properties src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_de.properties src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_es.properties src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_fr.properties src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_it.properties src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_ja.properties src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_ko.properties src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_pt_BR.properties src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_sv.properties src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_zh_CN.properties src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources/windows_zh_TW.properties src/java.desktop/share/classes/sun/swing/plaf/windows/ClassicSortArrowIcon.java src/java.desktop/share/native/libfontmanager/harfbuzz/hb-cache-private.hh src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ucdn/unicodedata_db.h src/java.desktop/unix/classes/sun/awt/windows/ThemeReader.java src/java.management/share/native/include/jmm.h src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java 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/java/util/Calendar/Bug8185841.java test/jdk/java/io/FileInputStream/FinalizeShdCallClose.java test/jdk/java/io/FileOutputStream/FinalizeShdCallClose.java test/jdk/lib/testlibrary/jdk/testlibrary/RandomFactory.java test/jdk/sun/security/tools/keytool/p12importks.sh test/langtools/jdk/javadoc/doclet/testBadPackageFileInJar/badPackageFileInJar.jar test/langtools/jdk/javadoc/doclet/testGroupOption/C.java test/langtools/jdk/javadoc/doclet/testMemberInheritence/TestMemberInheritence.java test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/A.java test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/B.java test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/C.java test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/X.java test/langtools/jdk/javadoc/doclet/testMemberInheritence/diamond/Z.java test/langtools/jdk/javadoc/doclet/testMemberInheritence/inheritDist/A.java test/langtools/jdk/javadoc/doclet/testMemberInheritence/inheritDist/B.java test/langtools/jdk/javadoc/doclet/testMemberInheritence/inheritDist/C.java test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg/BaseClass.java test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg/BaseInterface.java test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg/SubClass.java test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg1/Implementer.java test/langtools/jdk/javadoc/doclet/testMemberInheritence/pkg1/Interface.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestBadOverride.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestMultiInheritence.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverrideMethods.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverridenMethodDocCopy.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverridenPrivateMethods.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverridenPrivateMethodsWithPackageFlag.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg1/BaseClass.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg1/SubClass.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg2/SubClass.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I0.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I1.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I2.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I3.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I4.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg4/Foo.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg5/Classes.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg5/Interfaces.java test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg5/TestEnum.java test/langtools/tools/javac/T5090006/AssertionFailureTest.java test/langtools/tools/javac/T5090006/broken.jar 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 951 files changed, 60975 insertions(+), 49007 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Dec 14 20:55:06 2017 +0100
+++ b/.hgtags	Thu Dec 14 22:06:54 2017 +0100
@@ -459,3 +459,5 @@
 a2008587c13fa05fa2dbfcb09fe987576fbedfd1 jdk-10+32
 bbd692ad4fa300ecca7939ffbe3b1d5e52a28cc6 jdk-10+33
 89deac44e51517841491ba86ff44aa82a5ca96b3 jdk-10+34
+d8c634b016c628622c9abbdc6bf50509e5dedbec jdk-10+35
+0ee20aad71c4f33c426372b4c8bcc1235ce2ec08 jdk-11+0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADDITIONAL_LICENSE_INFO	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/MacBundles.gmk	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/ReleaseFile.gmk	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/autoconf/flags.m4	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/autoconf/generated-configure.sh	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/autoconf/jdk-version.m4	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/autoconf/platform.m4	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/autoconf/spec.gmk.in	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/autoconf/version-numbers	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/conf/jib-profiles.js	Thu Dec 14 22:06:54 2017 +0100
@@ -662,6 +662,16 @@
         }
     });
 
+    // For open profiles, the non-debug jdk bundles, need an "open" prefix on the
+    // remote bundle names, forming the word "openjdk". See JDK-8188789.
+    common.main_profile_names.forEach(function (name) {
+        var openName = name + common.open_suffix;
+        profiles[openName].artifacts["jdk"].remote = replaceAll(
+            "\/jdk-", "/openjdk-",
+            replaceAll("\/\\1", "/open\\1",
+                       profiles[openName].artifacts["jdk"].remote));
+    });
+
     // Profiles used to run tests. Used in JPRT and Mach 5.
     var testOnlyProfiles = {
         "run-test-jprt": {
@@ -1040,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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/copy/Copy-java.base.gmk	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/copy/Copy-java.desktop.gmk	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/copy/Copy-jdk.accessibility.gmk	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/copy/Copy-jdk.jdwp.agent.gmk	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/copy/CopyCommon.gmk	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/gensrc/GensrcMisc.gmk	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/gensrc/GensrcX11Wrappers.gmk	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/hotspot/lib/CompileJvm.gmk	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/hotspot/lib/CompileLibjsig.gmk	Thu Dec 14 22:06:54 2017 +0100
@@ -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/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java	Thu Dec 14 22:06:54 2017 +0100
@@ -37,6 +37,7 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 import org.xml.sax.SAXNotRecognizedException;
@@ -52,21 +53,32 @@
 
     static final String LDML_DTD_SYSTEM_ID = "http://www.unicode.org/cldr/dtd/2.0/ldml.dtd";
     static final String SPPL_LDML_DTD_SYSTEM_ID = "http://www.unicode.org/cldr/dtd/2.0/ldmlSupplemental.dtd";
+    static final String BCP47_LDML_DTD_SYSTEM_ID = "http://www.unicode.org/cldr/dtd/2.0/ldmlBCP47.dtd";
+
 
     private static String CLDR_BASE = "../CLDR/21.0.1/";
     static String LOCAL_LDML_DTD;
     static String LOCAL_SPPL_LDML_DTD;
+    static String LOCAL_BCP47_LDML_DTD;
     private static String SOURCE_FILE_DIR;
     private static String SPPL_SOURCE_FILE;
     private static String NUMBERING_SOURCE_FILE;
     private static String METAZONES_SOURCE_FILE;
     private static String LIKELYSUBTAGS_SOURCE_FILE;
+    private static String TIMEZONE_SOURCE_FILE;
     static String DESTINATION_DIR = "build/gensrc";
 
     static final String LOCALE_NAME_PREFIX = "locale.displayname.";
+    static final String LOCALE_SEPARATOR = LOCALE_NAME_PREFIX + "separator";
+    static final String LOCALE_KEYTYPE = LOCALE_NAME_PREFIX + "keytype";
+    static final String LOCALE_KEY_PREFIX = LOCALE_NAME_PREFIX + "key.";
+    static final String LOCALE_TYPE_PREFIX = LOCALE_NAME_PREFIX + "type.";
+    static final String LOCALE_TYPE_PREFIX_CA = LOCALE_TYPE_PREFIX + "ca.";
     static final String CURRENCY_SYMBOL_PREFIX = "currency.symbol.";
     static final String CURRENCY_NAME_PREFIX = "currency.displayname.";
     static final String CALENDAR_NAME_PREFIX = "calendarname.";
+    static final String CALENDAR_FIRSTDAY_PREFIX = "firstDay.";
+    static final String CALENDAR_MINDAYS_PREFIX = "minDays.";
     static final String TIMEZONE_ID_PREFIX = "timezone.id.";
     static final String ZONE_NAME_PREFIX = "timezone.displayname.";
     static final String METAZONE_ID_PREFIX = "metazone.id.";
@@ -76,6 +88,7 @@
     private static LikelySubtagsParseHandler handlerLikelySubtags;
     static NumberingSystemsParseHandler handlerNumbering;
     static MetaZonesParseHandler handlerMetaZones;
+    static TimeZoneParseHandler handlerTimeZone;
     private static BundleGenerator bundleGenerator;
 
     // java.base module related
@@ -201,11 +214,13 @@
         // Set up path names
         LOCAL_LDML_DTD = CLDR_BASE + "/dtd/ldml.dtd";
         LOCAL_SPPL_LDML_DTD = CLDR_BASE + "/dtd/ldmlSupplemental.dtd";
+        LOCAL_BCP47_LDML_DTD = CLDR_BASE + "/dtd/ldmlBCP47.dtd";
         SOURCE_FILE_DIR = CLDR_BASE + "/main";
         SPPL_SOURCE_FILE = CLDR_BASE + "/supplemental/supplementalData.xml";
         LIKELYSUBTAGS_SOURCE_FILE = CLDR_BASE + "/supplemental/likelySubtags.xml";
         NUMBERING_SOURCE_FILE = CLDR_BASE + "/supplemental/numberingSystems.xml";
         METAZONES_SOURCE_FILE = CLDR_BASE + "/supplemental/metaZones.xml";
+        TIMEZONE_SOURCE_FILE = CLDR_BASE + "/bcp47/timezone.xml";
 
         if (BASE_LOCALES.isEmpty()) {
             setupBaseLocales("en-US");
@@ -215,10 +230,10 @@
 
         // Parse data independent of locales
         parseSupplemental();
+        parseBCP47();
 
         List<Bundle> bundles = readBundleList();
         convertBundles(bundles);
-        convertBundles(addedBundles);
     }
 
     private static void usage() {
@@ -314,34 +329,19 @@
     }
 
     private static final Map<String, Map<String, Object>> cldrBundles = new HashMap<>();
-    // this list will contain additional bundles to be generated for Region dependent Data.
-    private static List<Bundle> addedBundles = new ArrayList<>();
 
     private static Map<String, SortedSet<String>> metaInfo = new HashMap<>();
 
     static {
         // For generating information on supported locales.
-        metaInfo.put("LocaleNames", new TreeSet<>());
-        metaInfo.put("CurrencyNames", new TreeSet<>());
-        metaInfo.put("TimeZoneNames", new TreeSet<>());
-        metaInfo.put("CalendarData", new TreeSet<>());
-        metaInfo.put("FormatData", new TreeSet<>());
         metaInfo.put("AvailableLocales", new TreeSet<>());
     }
 
-
-    private static Set<String> calendarDataFields = Set.of("firstDayOfWeek", "minimalDaysInFirstWeek");
-
     static Map<String, Object> getCLDRBundle(String id) throws Exception {
         Map<String, Object> bundle = cldrBundles.get(id);
         if (bundle != null) {
             return bundle;
         }
-        SAXParserFactory factory = SAXParserFactory.newInstance();
-        factory.setValidating(true);
-        SAXParser parser = factory.newSAXParser();
-        enableFileAccess(parser);
-        LDMLParseHandler handler = new LDMLParseHandler(id);
         File file = new File(SOURCE_FILE_DIR + File.separator + id + ".xml");
         if (!file.exists()) {
             // Skip if the file doesn't exist.
@@ -349,14 +349,15 @@
         }
 
         info("..... main directory .....");
-        info("Reading file " + file);
-        parser.parse(file, handler);
+        LDMLParseHandler handler = new LDMLParseHandler(id);
+        parseLDMLFile(file, handler);
 
         bundle = handler.getData();
         cldrBundles.put(id, bundle);
-        String country = getCountryCode(id);
-        if (country != null) {
-            bundle = handlerSuppl.getData(country);
+
+        if (id.equals("root")) {
+            // Calendar data (firstDayOfWeek & minDaysInFirstWeek)
+            bundle = handlerSuppl.getData("root");
             if (bundle != null) {
                 //merge two maps into one map
                 Map<String, Object> temp = cldrBundles.remove(id);
@@ -379,98 +380,44 @@
         // SupplementalData file also provides the "parent" locales which
         // are othrwise not to be fallen back. Process them here as well.
         //
-        info("..... Parsing supplementalData.xml .....");
-        SAXParserFactory factorySuppl = SAXParserFactory.newInstance();
-        factorySuppl.setValidating(true);
-        SAXParser parserSuppl = factorySuppl.newSAXParser();
-        enableFileAccess(parserSuppl);
         handlerSuppl = new SupplementDataParseHandler();
-        File fileSupply = new File(SPPL_SOURCE_FILE);
-        parserSuppl.parse(fileSupply, handlerSuppl);
+        parseLDMLFile(new File(SPPL_SOURCE_FILE), handlerSuppl);
         Map<String, Object> parentData = handlerSuppl.getData("root");
-        parentData.keySet().forEach(key -> {
+        parentData.keySet().stream()
+                .filter(key -> key.startsWith(PARENT_LOCALE_PREFIX))
+                .forEach(key -> {
                 parentLocalesMap.put(key, new TreeSet(
                     Arrays.asList(((String)parentData.get(key)).split(" "))));
             });
 
         // Parse numberingSystems to get digit zero character information.
-        SAXParserFactory numberingParser = SAXParserFactory.newInstance();
-        numberingParser.setValidating(true);
-        SAXParser parserNumbering = numberingParser.newSAXParser();
-        enableFileAccess(parserNumbering);
         handlerNumbering = new NumberingSystemsParseHandler();
-        File fileNumbering = new File(NUMBERING_SOURCE_FILE);
-        parserNumbering.parse(fileNumbering, handlerNumbering);
+        parseLDMLFile(new File(NUMBERING_SOURCE_FILE), handlerNumbering);
 
         // Parse metaZones to create mappings between Olson tzids and CLDR meta zone names
-        info("..... Parsing metaZones.xml .....");
-        SAXParserFactory metazonesParser = SAXParserFactory.newInstance();
-        metazonesParser.setValidating(true);
-        SAXParser parserMetaZones = metazonesParser.newSAXParser();
-        enableFileAccess(parserMetaZones);
         handlerMetaZones = new MetaZonesParseHandler();
-        File fileMetaZones = new File(METAZONES_SOURCE_FILE);
-        parserMetaZones.parse(fileMetaZones, handlerMetaZones);
+        parseLDMLFile(new File(METAZONES_SOURCE_FILE), handlerMetaZones);
 
         // Parse likelySubtags
-        info("..... Parsing likelySubtags.xml .....");
-        SAXParserFactory likelySubtagsParser = SAXParserFactory.newInstance();
-        likelySubtagsParser.setValidating(true);
-        SAXParser parserLikelySubtags = likelySubtagsParser.newSAXParser();
-        enableFileAccess(parserLikelySubtags);
         handlerLikelySubtags = new LikelySubtagsParseHandler();
-        File fileLikelySubtags = new File(LIKELYSUBTAGS_SOURCE_FILE);
-        parserLikelySubtags.parse(fileLikelySubtags, handlerLikelySubtags);
+        parseLDMLFile(new File(LIKELYSUBTAGS_SOURCE_FILE), handlerLikelySubtags);
     }
 
-    /**
-     * This method will check if a new region dependent Bundle needs to be
-     * generated for this Locale id and targetMap. New Bundle will be generated
-     * when Locale id has non empty script and country code and targetMap
-     * contains region dependent data. This method will also remove region
-     * dependent data from this targetMap after candidate locales check. E.g. It
-     * will call genRegionDependentBundle() in case of az_Latn_AZ locale and
-     * remove region dependent data from this targetMap so that az_Latn_AZ
-     * bundle will not be created. For az_Cyrl_AZ, new Bundle will be generated
-     * but region dependent data will not be removed from targetMap as its candidate
-     * locales are [az_Cyrl_AZ, az_Cyrl, root], which does not include az_AZ for
-     * fallback.
-     *
-     */
+    // Parsers for data in "bcp47" directory
+    //
+    private static void parseBCP47() throws Exception {
+        // Parse timezone
+        handlerTimeZone = new TimeZoneParseHandler();
+        parseLDMLFile(new File(TIMEZONE_SOURCE_FILE), handlerTimeZone);
+    }
 
-    private static void checkRegionDependentBundle(Map<String, Object> targetMap, String id) {
-        if ((CLDRConverter.getScript(id) != "")
-                && (CLDRConverter.getCountryCode(id) != "")) {
-            Map<String, Object> regionDepDataMap = targetMap
-                    .keySet()
-                    .stream()
-                    .filter(calendarDataFields::contains)
-                    .collect(Collectors.toMap(k -> k, targetMap::get));
-            if (!regionDepDataMap.isEmpty()) {
-                Locale cldrLoc = new Locale(CLDRConverter.getLanguageCode(id),
-                                            CLDRConverter.getCountryCode(id));
-                genRegionDependentBundle(regionDepDataMap, cldrLoc);
-                if (checkCandidateLocales(id, cldrLoc)) {
-                    // Remove matchedKeys from this targetMap only if checkCandidateLocales() returns true.
-                    regionDepDataMap.keySet().forEach(targetMap::remove);
-                }
-            }
-        }
-    }
-    /**
-     * This method will generate a new Bundle for region dependent data,
-     * minimalDaysInFirstWeek and firstDayOfWeek. Newly generated Bundle will be added
-     * to addedBundles list.
-     */
-    private static void genRegionDependentBundle(Map<String, Object> targetMap, Locale cldrLoc) {
-        String localeId = cldrLoc.toString();
-        StringBuilder sb = getCandLocales(cldrLoc);
-        if (sb.indexOf(localeId) == -1) {
-            sb.append(localeId);
-        }
-        Bundle bundle = new Bundle(localeId, sb.toString(), null, null);
-        cldrBundles.put(localeId, targetMap);
-        addedBundles.add(bundle);
+    private static void parseLDMLFile(File srcfile, AbstractLDMLHandler handler) throws Exception {
+        info("..... Parsing " + srcfile.getName() + " .....");
+        SAXParserFactory pf = SAXParserFactory.newInstance();
+        pf.setValidating(true);
+        SAXParser parser = pf.newSAXParser();
+        enableFileAccess(parser);
+        parser.parse(srcfile, handler);
     }
 
     private static StringBuilder getCandLocales(Locale cldrLoc) {
@@ -491,16 +438,6 @@
         return candList;
     }
 
-    /**
-     * This method will return true, if for a given locale, its language and
-     * country specific locale will exist in runtime lookup path. E.g. it will
-     * return true for bs_Latn_BA.
-     */
-    private static boolean checkCandidateLocales(String id, Locale cldrLoc) {
-        return(getCandidateLocales(Locale.forLanguageTag(id.replaceAll("_", "-")))
-                .contains(cldrLoc));
-    }
-
     private static void convertBundles(List<Bundle> bundles) throws Exception {
         // parent locales map. The mappings are put in base metaInfo file
         // for now.
@@ -514,8 +451,6 @@
 
             Map<String, Object> targetMap = bundle.getTargetMap();
 
-            // check if new region DependentBundle needs to be generated for this Locale.
-            checkRegionDependentBundle(targetMap, bundle.getID());
             EnumSet<Bundle.Type> bundleTypes = bundle.getBundleTypes();
 
             if (bundle.isRoot()) {
@@ -528,40 +463,30 @@
             if (bundleTypes.contains(Bundle.Type.LOCALENAMES)) {
                 Map<String, Object> localeNamesMap = extractLocaleNames(targetMap, bundle.getID());
                 if (!localeNamesMap.isEmpty() || bundle.isRoot()) {
-                    metaInfo.get("LocaleNames").add(toLanguageTag(bundle.getID()));
-                    addLikelySubtags(metaInfo, "LocaleNames", bundle.getID());
                     bundleGenerator.generateBundle("util", "LocaleNames", bundle.getJavaID(), true, localeNamesMap, BundleType.OPEN);
                 }
             }
             if (bundleTypes.contains(Bundle.Type.CURRENCYNAMES)) {
                 Map<String, Object> currencyNamesMap = extractCurrencyNames(targetMap, bundle.getID(), bundle.getCurrencies());
                 if (!currencyNamesMap.isEmpty() || bundle.isRoot()) {
-                    metaInfo.get("CurrencyNames").add(toLanguageTag(bundle.getID()));
-                    addLikelySubtags(metaInfo, "CurrencyNames", bundle.getID());
                     bundleGenerator.generateBundle("util", "CurrencyNames", bundle.getJavaID(), true, currencyNamesMap, BundleType.OPEN);
                 }
             }
             if (bundleTypes.contains(Bundle.Type.TIMEZONENAMES)) {
                 Map<String, Object> zoneNamesMap = extractZoneNames(targetMap, bundle.getID());
                 if (!zoneNamesMap.isEmpty() || bundle.isRoot()) {
-                    metaInfo.get("TimeZoneNames").add(toLanguageTag(bundle.getID()));
-                    addLikelySubtags(metaInfo, "TimeZoneNames", bundle.getID());
                     bundleGenerator.generateBundle("util", "TimeZoneNames", bundle.getJavaID(), true, zoneNamesMap, BundleType.TIMEZONE);
                 }
             }
             if (bundleTypes.contains(Bundle.Type.CALENDARDATA)) {
                 Map<String, Object> calendarDataMap = extractCalendarData(targetMap, bundle.getID());
                 if (!calendarDataMap.isEmpty() || bundle.isRoot()) {
-                    metaInfo.get("CalendarData").add(toLanguageTag(bundle.getID()));
-                    addLikelySubtags(metaInfo, "CalendarData", bundle.getID());
                     bundleGenerator.generateBundle("util", "CalendarData", bundle.getJavaID(), true, calendarDataMap, BundleType.PLAIN);
                 }
             }
             if (bundleTypes.contains(Bundle.Type.FORMATDATA)) {
                 Map<String, Object> formatDataMap = extractFormatData(targetMap, bundle.getID());
                 if (!formatDataMap.isEmpty() || bundle.isRoot()) {
-                    metaInfo.get("FormatData").add(toLanguageTag(bundle.getID()));
-                    addLikelySubtags(metaInfo, "FormatData", bundle.getID());
                     bundleGenerator.generateBundle("text", "FormatData", bundle.getJavaID(), true, formatDataMap, BundleType.PLAIN);
                 }
             }
@@ -570,43 +495,9 @@
             metaInfo.get("AvailableLocales").add(toLanguageTag(bundle.getID()));
             addLikelySubtags(metaInfo, "AvailableLocales", bundle.getID());
         }
-        addCldrImplicitLocales(metaInfo);
         bundleGenerator.generateMetaInfo(metaInfo);
     }
 
-    /**
-     * These are the Locales that are implicitly supported by CLDR.
-     * Adding them explicitly as likelySubtags here, will ensure that
-     * COMPAT locales do not precede them during ResourceBundle search path.
-     */
-    private static void addCldrImplicitLocales(Map<String, SortedSet<String>> metaInfo) {
-        metaInfo.get("LocaleNames").add("zh-Hans-CN");
-        metaInfo.get("LocaleNames").add("zh-Hans-SG");
-        metaInfo.get("LocaleNames").add("zh-Hant-HK");
-        metaInfo.get("LocaleNames").add("zh-Hant-MO");
-        metaInfo.get("LocaleNames").add("zh-Hant-TW");
-        metaInfo.get("CurrencyNames").add("zh-Hans-CN");
-        metaInfo.get("CurrencyNames").add("zh-Hans-SG");
-        metaInfo.get("CurrencyNames").add("zh-Hant-HK");
-        metaInfo.get("CurrencyNames").add("zh-Hant-MO");
-        metaInfo.get("CurrencyNames").add("zh-Hant-TW");
-        metaInfo.get("TimeZoneNames").add("zh-Hans-CN");
-        metaInfo.get("TimeZoneNames").add("zh-Hans-SG");
-        metaInfo.get("TimeZoneNames").add("zh-Hant-HK");
-        metaInfo.get("TimeZoneNames").add("zh-Hant-MO");
-        metaInfo.get("TimeZoneNames").add("zh-Hant-TW");
-        metaInfo.get("TimeZoneNames").add("zh-HK");
-        metaInfo.get("CalendarData").add("zh-Hans-CN");
-        metaInfo.get("CalendarData").add("zh-Hans-SG");
-        metaInfo.get("CalendarData").add("zh-Hant-HK");
-        metaInfo.get("CalendarData").add("zh-Hant-MO");
-        metaInfo.get("CalendarData").add("zh-Hant-TW");
-        metaInfo.get("FormatData").add("zh-Hans-CN");
-        metaInfo.get("FormatData").add("zh-Hans-SG");
-        metaInfo.get("FormatData").add("zh-Hant-HK");
-        metaInfo.get("FormatData").add("zh-Hant-MO");
-        metaInfo.get("FormatData").add("zh-Hant-TW");
-    }
     static final Map<String, String> aliases = new HashMap<>();
 
     /**
@@ -656,14 +547,6 @@
         return Locale.forLanguageTag(id.replaceAll("_", "-")).getCountry();
     }
 
-    /*
-     * Returns the script portion of the given id.
-     * If id is "root", "" is returned.
-     */
-    static String getScript(String id) {
-        return "root".equals(id) ? "" : Locale.forLanguageTag(id.replaceAll("_", "-")).getScript();
-    }
-
     private static class KeyComparator implements Comparator<String> {
         static KeyComparator INSTANCE = new KeyComparator();
 
@@ -695,9 +578,25 @@
         Map<String, Object> localeNames = new TreeMap<>(KeyComparator.INSTANCE);
         for (String key : map.keySet()) {
             if (key.startsWith(LOCALE_NAME_PREFIX)) {
-                localeNames.put(key.substring(LOCALE_NAME_PREFIX.length()), map.get(key));
+                switch (key) {
+                    case LOCALE_SEPARATOR:
+                        localeNames.put("ListCompositionPattern", map.get(key));
+                        break;
+                    case LOCALE_KEYTYPE:
+                        localeNames.put("ListKeyTypePattern", map.get(key));
+                        break;
+                    default:
+                        localeNames.put(key.substring(LOCALE_NAME_PREFIX.length()), map.get(key));
+                        break;
+                }
             }
         }
+
+        if (id.equals("root")) {
+            // Add display name pattern, which is not in CLDR
+            localeNames.put("DisplayNamePattern", "{0,choice,0#|1#{1}|2#{1} ({2})}");
+        }
+
         return localeNames;
     }
 
@@ -778,10 +677,30 @@
         return names;
     }
 
+    /**
+     * Extracts the language independent calendar data. Each of the two keys,
+     * "firstDayOfWeek" and "minimalDaysInFirstWeek" has a string value consists of
+     * one or multiple occurrences of:
+     *  i: rg1 rg2 ... rgn;
+     * where "i" is the data for the following regions (delimited by a space) after
+     * ":", and ends with a ";".
+     */
     private static Map<String, Object> extractCalendarData(Map<String, Object> map, String id) {
         Map<String, Object> calendarData = new LinkedHashMap<>();
-        copyIfPresent(map, "firstDayOfWeek", calendarData);
-        copyIfPresent(map, "minimalDaysInFirstWeek", calendarData);
+        if (id.equals("root")) {
+            calendarData.put("firstDayOfWeek",
+                IntStream.range(1, 8)
+                    .mapToObj(String::valueOf)
+                    .filter(d -> map.keySet().contains(CALENDAR_FIRSTDAY_PREFIX + d))
+                    .map(d -> d + ": " + map.get(CALENDAR_FIRSTDAY_PREFIX + d))
+                    .collect(Collectors.joining(";")));
+            calendarData.put("minimalDaysInFirstWeek",
+                IntStream.range(0, 7)
+                    .mapToObj(String::valueOf)
+                    .filter(d -> map.keySet().contains(CALENDAR_MINDAYS_PREFIX + d))
+                    .map(d -> d + ": " + map.get(CALENDAR_MINDAYS_PREFIX + d))
+                    .collect(Collectors.joining(";")));
+        }
         return calendarData;
     }
 
@@ -844,17 +763,19 @@
 
         for (String key : map.keySet()) {
         // Copy available calendar names
-            if (key.startsWith(CLDRConverter.CALENDAR_NAME_PREFIX)) {
-                String type = key.substring(CLDRConverter.CALENDAR_NAME_PREFIX.length());
+            if (key.startsWith(CLDRConverter.LOCALE_TYPE_PREFIX_CA)) {
+                String type = key.substring(CLDRConverter.LOCALE_TYPE_PREFIX_CA.length());
                 for (CalendarType calendarType : CalendarType.values()) {
                     if (calendarType == CalendarType.GENERIC) {
                         continue;
                     }
                     if (type.equals(calendarType.lname())) {
                         Object value = map.get(key);
-                        formatData.put(key, value);
-                        String ukey = CLDRConverter.CALENDAR_NAME_PREFIX + calendarType.uname();
-                        if (!key.equals(ukey)) {
+                        String dataKey = key.replace(LOCALE_TYPE_PREFIX_CA,
+                                CALENDAR_NAME_PREFIX);
+                        formatData.put(dataKey, value);
+                        String ukey = CALENDAR_NAME_PREFIX + calendarType.uname();
+                        if (!dataKey.equals(ukey)) {
                             formatData.put(ukey, value);
                         }
                     }
@@ -874,6 +795,18 @@
             copyIfPresent(map, "NumberElements", formatData);
         }
         copyIfPresent(map, "NumberPatterns", formatData);
+
+        // put extra number elements for available scripts into formatData, if it is "root"
+        if (id.equals("root")) {
+            handlerNumbering.keySet().stream()
+                .filter(k -> !numberingScripts.contains(k))
+                .forEach(k -> {
+                    String[] ne = (String[])map.get("latn.NumberElements");
+                    String[] neNew = Arrays.copyOf(ne, ne.length);
+                    neNew[4] = handlerNumbering.get(k).substring(0, 1);
+                    formatData.put(k + ".NumberElements", neNew);
+                });
+        }
         return formatData;
     }
 
--- a/make/jdk/src/classes/build/tools/cldrconverter/LDMLParseHandler.java	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/jdk/src/classes/build/tools/cldrconverter/LDMLParseHandler.java	Thu Dec 14 22:06:54 2017 +0100
@@ -76,12 +76,16 @@
             // ignore this element - it has language and territory elements that aren't locale data
             pushIgnoredContainer(qName);
             break;
-        case "type":
-            if ("calendar".equals(attributes.getValue("key"))) {
-                pushStringEntry(qName, attributes, CLDRConverter.CALENDAR_NAME_PREFIX + attributes.getValue("type"));
-            } else {
-                pushIgnoredContainer(qName);
-            }
+
+        // for LocaleNames
+        // copy string
+        case "localeSeparator":
+            pushStringEntry(qName, attributes,
+                CLDRConverter.LOCALE_SEPARATOR);
+            break;
+        case "localeKeyTypePattern":
+            pushStringEntry(qName, attributes,
+                CLDRConverter.LOCALE_KEYTYPE);
             break;
 
         case "language":
@@ -96,6 +100,24 @@
                 attributes.getValue("type"));
             break;
 
+        case "key":
+            // for LocaleNames
+            // copy string
+            pushStringEntry(qName, attributes,
+                CLDRConverter.LOCALE_KEY_PREFIX +
+                convertOldKeyName(attributes.getValue("type")));
+            break;
+
+        case "type":
+            // for LocaleNames/CalendarNames
+            // copy string
+            pushStringEntry(qName, attributes,
+                CLDRConverter.LOCALE_TYPE_PREFIX +
+                convertOldKeyName(attributes.getValue("key")) + "." +
+                attributes.getValue("type"));
+
+            break;
+
         //
         // Currency information
         //
@@ -515,26 +537,10 @@
                 currentNumberingSystem = script + ".";
                 String digits = CLDRConverter.handlerNumbering.get(script);
                 if (digits == null) {
-                    throw new InternalError("null digits for " + script);
-                }
-                if (Character.isSurrogate(digits.charAt(0))) {
-                    // DecimalFormatSymbols doesn't support supplementary characters as digit zero.
                     pushIgnoredContainer(qName);
                     break;
                 }
-                // in case digits are in the reversed order, reverse back the order.
-                if (digits.charAt(0) > digits.charAt(digits.length() - 1)) {
-                    StringBuilder sb = new StringBuilder(digits);
-                    digits = sb.reverse().toString();
-                }
-                // Check if the order is sequential.
-                char c0 = digits.charAt(0);
-                for (int i = 1; i < digits.length(); i++) {
-                    if (digits.charAt(i) != c0 + i) {
-                        pushIgnoredContainer(qName);
-                        break symbols;
-                    }
-                }
+
                 @SuppressWarnings("unchecked")
                 List<String> numberingScripts = (List<String>) get("numberingScripts");
                 if (numberingScripts == null) {
@@ -924,17 +930,35 @@
                 }
             }
         } else if (currentContainer instanceof Entry) {
-                Entry<?> entry = (Entry<?>) currentContainer;
-                Object value = entry.getValue();
-                if (value != null) {
-                    String key = entry.getKey();
-                    // Tweak for MonthNames for the root locale, Needed for
-                    // SimpleDateFormat.format()/parse() roundtrip.
-                    if (id.equals("root") && key.startsWith("MonthNames")) {
-                        value = new DateFormatSymbols(Locale.US).getShortMonths();
-                    }
-                    put(entry.getKey(), value);
+            Entry<?> entry = (Entry<?>) currentContainer;
+            Object value = entry.getValue();
+            if (value != null) {
+                String key = entry.getKey();
+                // Tweak for MonthNames for the root locale, Needed for
+                // SimpleDateFormat.format()/parse() roundtrip.
+                if (id.equals("root") && key.startsWith("MonthNames")) {
+                    value = new DateFormatSymbols(Locale.US).getShortMonths();
                 }
+                put(entry.getKey(), value);
             }
         }
     }
+
+    public String convertOldKeyName(String key) {
+        // Explicitly obtained from "alias" attribute in each "key" element.
+        switch (key) {
+            case "calendar":
+                return "ca";
+            case "currency":
+                return "cu";
+            case "collation":
+                return "co";
+            case "numbers":
+                return "nu";
+            case "timezone":
+                return "tz";
+            default:
+                return key;
+        }
+    }
+}
--- a/make/jdk/src/classes/build/tools/cldrconverter/NumberingSystemsParseHandler.java	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/jdk/src/classes/build/tools/cldrconverter/NumberingSystemsParseHandler.java	Thu Dec 14 22:06:54 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, 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
@@ -54,9 +54,32 @@
     public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
         switch (qName) {
         case "numberingSystem":
-            if ("numeric".equals(attributes.getValue("type"))) {
-                // eg, <numberingSystem id="latn" type="numeric" digits="0123456789"/>
-                put(attributes.getValue("id"), attributes.getValue("digits"));
+            numberingSystem: {
+                if ("numeric".equals(attributes.getValue("type"))) {
+                    // eg, <numberingSystem id="latn" type="numeric" digits="0123456789"/>
+                    String script = attributes.getValue("id");
+                    String digits = attributes.getValue("digits");
+
+                    if (Character.isSurrogate(digits.charAt(0))) {
+                        // DecimalFormatSymbols doesn't support supplementary characters as digit zero.
+                        break numberingSystem;
+                    }
+                    // in case digits are in the reversed order, reverse back the order.
+                    if (digits.charAt(0) > digits.charAt(digits.length() - 1)) {
+                        StringBuilder sb = new StringBuilder(digits);
+                        digits = sb.reverse().toString();
+                    }
+                    // Check if the order is sequential.
+                    char c0 = digits.charAt(0);
+                    for (int i = 1; i < digits.length(); i++) {
+                        if (digits.charAt(i) != c0 + i) {
+                            break numberingSystem;
+                        }
+                    }
+
+                    // script/digits are acceptable.
+                    put(script, digits);
+                }
             }
             pushIgnoredContainer(qName);
             break;
--- a/make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java	Thu Dec 14 22:06:54 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, 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
@@ -256,20 +256,21 @@
         CLDRConverter.info("Generating file " + file);
 
         try (PrintWriter out = new PrintWriter(file, "us-ascii")) {
-            out.println(CopyrightHeaders.getOpenJDKCopyright());
+            out.printf(CopyrightHeaders.getOpenJDKCopyright());
 
-            out.println((CLDRConverter.isBaseModule ? "package sun.util.cldr;\n\n" :
+            out.printf((CLDRConverter.isBaseModule ? "package sun.util.cldr;\n\n" :
                                   "package sun.util.resources.cldr.provider;\n\n")
                       + "import java.util.HashMap;\n"
                       + "import java.util.Locale;\n"
                       + "import java.util.Map;\n"
-                      + "import sun.util.locale.provider.LocaleProviderAdapter;\n"
-                      + "import sun.util.locale.provider.LocaleDataMetaInfo;\n");
+                      + "import sun.util.locale.provider.LocaleDataMetaInfo;\n"
+                      + "import sun.util.locale.provider.LocaleProviderAdapter;\n\n");
             out.printf("public class %s implements LocaleDataMetaInfo {\n", className);
-            out.println("    private static final Map<String, String> resourceNameToLocales = new HashMap<>();\n" +
-                        (CLDRConverter.isBaseModule ?
-                        "    private static final Map<Locale, String[]> parentLocalesMap = new HashMap<>();\n\n" : "\n") +
-                        "    static {\n");
+            out.printf("    private static final Map<String, String> resourceNameToLocales = new HashMap<>();\n" +
+                       (CLDRConverter.isBaseModule ?
+                       "    private static final Map<Locale, String[]> parentLocalesMap = new HashMap<>();\n\n" :
+                       "\n") +
+                       "    static {\n");
 
             for (String key : metaInfo.keySet()) {
                 if (key.startsWith(CLDRConverter.PARENT_LOCALE_PREFIX)) {
@@ -296,30 +297,50 @@
                     }
                     out.printf("\n             });\n");
                 } else {
-                    out.printf("        resourceNameToLocales.put(\"%s\",\n", key);
-                    out.printf("              \"%s\");\n",
-                    toLocaleList(key.equals("FormatData") ? metaInfo.get("AvailableLocales") :
-                                            metaInfo.get(key), false));
+                    if ("AvailableLocales".equals(key)) {
+                        out.printf("        resourceNameToLocales.put(\"%s\",\n", key);
+                        out.printf("              \"%s\");\n", toLocaleList(metaInfo.get(key), false));
+                    }
                 }
             }
-            out.println("    }\n\n");
 
-            out.println("    @Override\n" +
+            out.printf("    }\n\n");
+
+            // end of static initializer block.
+
+            // Short TZ names for delayed initialization
+            if (CLDRConverter.isBaseModule) {
+                out.printf("    private static class TZShortIDMapHolder {\n");
+                out.printf("        static final Map<String, String> tzShortIDMap = new HashMap<>();\n");
+                out.printf("        static {\n");
+                CLDRConverter.handlerTimeZone.getData().entrySet().stream()
+                    .forEach(e -> {
+                        out.printf("            tzShortIDMap.put(\"%s\", \"%s\");\n", e.getKey(),
+                                ((String)e.getValue()));
+                    });
+                out.printf("        }\n    }\n\n");
+            }
+
+            out.printf("    @Override\n" +
                         "    public LocaleProviderAdapter.Type getType() {\n" +
                         "        return LocaleProviderAdapter.Type.CLDR;\n" +
                         "    }\n\n");
 
-            out.println("    @Override\n" +
+            out.printf("    @Override\n" +
                         "    public String availableLanguageTags(String category) {\n" +
                         "        return resourceNameToLocales.getOrDefault(category, \"\");\n" +
                         "    }\n\n");
 
             if (CLDRConverter.isBaseModule) {
+                out.printf("    @Override\n" +
+                           "    public Map<String, String> tzShortIDs() {\n" +
+                           "        return TZShortIDMapHolder.tzShortIDMap;\n" +
+                           "    }\n\n");
                 out.printf("    public Map<Locale, String[]> parentLocales() {\n" +
                            "        return parentLocalesMap;\n" +
                            "    }\n}");
             } else {
-                out.println("}");
+                out.printf("}");
             }
         }
     }
--- a/make/jdk/src/classes/build/tools/cldrconverter/SupplementDataParseHandler.java	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/jdk/src/classes/build/tools/cldrconverter/SupplementDataParseHandler.java	Thu Dec 14 22:06:54 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, 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
@@ -84,53 +84,18 @@
             values.put(CLDRConverter.PARENT_LOCALE_PREFIX+key,
                 parentLocalesMap.get(key));
             });
-        } else {
-            String countryData = getWeekData(id, JAVA_FIRSTDAY, firstDayMap);
-        if (countryData != null) {
-            values.put(JAVA_FIRSTDAY, countryData);
-        }
-            String minDaysData = getWeekData(id, JAVA_MINDAY, minDaysMap);
-        if (minDaysData != null) {
-            values.put(JAVA_MINDAY, minDaysData);
-        }
+            firstDayMap.keySet().forEach(key -> {
+            values.put(CLDRConverter.CALENDAR_FIRSTDAY_PREFIX+firstDayMap.get(key),
+                key);
+            });
+            minDaysMap.keySet().forEach(key -> {
+            values.put(CLDRConverter.CALENDAR_MINDAYS_PREFIX+minDaysMap.get(key),
+                key);
+            });
         }
         return values.isEmpty() ? null : values;
     }
 
-    /**
-     * It returns either firstDay or minDays in the JRE format for the country.
-     *
-     * @param country       territory code of the requested data
-     * @param jreDataName   JAVA_FIRSTDAY or JAVA_MINDAY
-     * @param dataMap       firstDayMap or minDaysMap
-     * @return the value for the given jreDataName, or null if requested value
-     *         (firstDay/minDays) is not available although that is highly unlikely
-     *         because of the default value for the world (001).
-     */
-    String getWeekData(String country, final String jreDataName, final Map<String, Object> dataMap) {
-        String countryValue = null;
-        String defaultWorldValue = null;
-        for (String key : dataMap.keySet()) {
-            if (key.contains(country)) {
-                if (jreDataName.equals(JAVA_FIRSTDAY)) {
-                    countryValue = DAY_OF_WEEK_MAP.get((String) dataMap.get(key));
-                } else if (jreDataName.equals(JAVA_MINDAY)) {
-                    countryValue = (String) dataMap.get(key);
-                }
-                if (countryValue != null) {
-                    return countryValue;
-                }
-            } else if (key.contains(WORLD)) {
-                if (jreDataName.equals(JAVA_FIRSTDAY)) {
-                    defaultWorldValue = DAY_OF_WEEK_MAP.get((String) dataMap.get(key));
-                } else if (jreDataName.equals(JAVA_MINDAY)) {
-                    defaultWorldValue = (String) dataMap.get(key);
-                }
-            }
-        }
-        return defaultWorldValue;
-    }
-
     @Override
     public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException {
         // avoid HTTP traffic to unicode.org
@@ -152,7 +117,33 @@
         switch (qName) {
         case "firstDay":
             if (!isIgnored(attributes)) {
-                firstDayMap.put(attributes.getValue("territories"), attributes.getValue("day"));
+                String fd;
+
+                switch (attributes.getValue("day")) {
+                    case "sun":
+                        fd = "1";
+                        break;
+                    default:
+                    case "mon":
+                        fd = "2";
+                        break;
+                    case "tue":
+                        fd = "3";
+                        break;
+                    case "wed":
+                        fd = "4";
+                        break;
+                    case "thu":
+                        fd = "5";
+                        break;
+                    case "fri":
+                        fd = "6";
+                        break;
+                    case "sat":
+                        fd = "7";
+                        break;
+                }
+                firstDayMap.put(attributes.getValue("territories"), fd);
             }
             break;
         case "minDays":
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/jdk/src/classes/build/tools/cldrconverter/TimeZoneParseHandler.java	Thu Dec 14 22:06:54 2017 +0100
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  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 build.tools.cldrconverter;
+
+import java.io.File;
+import java.io.IOException;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Handles parsing of timezone.xml and produces a map from short timezone IDs to
+ * tz database IDs.
+ */
+
+class TimeZoneParseHandler extends AbstractLDMLHandler<Object> {
+
+    @Override
+    public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException {
+        // avoid HTTP traffic to unicode.org
+        if (systemID.startsWith(CLDRConverter.BCP47_LDML_DTD_SYSTEM_ID)) {
+            return new InputSource((new File(CLDRConverter.LOCAL_BCP47_LDML_DTD)).toURI().toString());
+        }
+        return null;
+    }
+
+    @Override
+    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+        switch (qName) {
+        case "type":
+            if (!isIgnored(attributes) && !attributes.getValue("deprecated").equals("true")) {
+                put(attributes.getValue("name"), attributes.getValue("alias"));
+            }
+            break;
+        default:
+            // treat anything else as a container
+            pushContainer(qName, attributes);
+            break;
+        }
+    }
+}
--- a/make/jprt.properties	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/jprt.properties	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/launcher/Launcher-jdk.compiler.gmk	Thu Dec 14 22:06:54 2017 +0100
@@ -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/Awt2dLibraries.gmk	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/lib/Awt2dLibraries.gmk	Thu Dec 14 22:06:54 2017 +0100
@@ -681,7 +681,7 @@
     DISABLED_WARNINGS_CXX_solstudio := \
         truncwarn wvarhidenmem wvarhidemem wbadlkginit identexpected \
         hidevf w_novirtualdescr arrowrtn2, \
-    DISABLED_WARNINGS_microsoft := 4267 4244 4018 4090 4996 4146 4334 4819, \
+    DISABLED_WARNINGS_microsoft := 4267 4244 4018 4090 4996 4146 4334 4819 4101, \
     MAPFILE := $(BUILD_LIBFONTMANAGER_MAPFILE), \
     LDFLAGS := $(subst -Wl$(COMMA)-z$(COMMA)defs,,$(LDFLAGS_JDKLIB)) $(LDFLAGS_CXX_JDK) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
--- a/make/lib/Lib-java.management.gmk	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/lib/Lib-java.management.gmk	Thu Dec 14 22:06:54 2017 +0100
@@ -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/make/mapfiles/libjava/mapfile-vers	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/mapfiles/libjava/mapfile-vers	Thu Dec 14 22:06:54 2017 +0100
@@ -74,7 +74,7 @@
 		JNU_ThrowStringIndexOutOfBoundsException;
 		JNU_ToString;
 
-		Java_java_io_FileDescriptor_close;
+		Java_java_io_FileDescriptor_close0;
 		Java_java_io_FileDescriptor_initIDs;
 		Java_java_io_FileDescriptor_sync;
 		Java_java_io_FileDescriptor_getAppend;
--- a/make/nashorn/build.xml	Thu Dec 14 20:55:06 2017 +0100
+++ b/make/nashorn/build.xml	Thu Dec 14 22:06:54 2017 +0100
@@ -265,7 +265,7 @@
   </target>
 
   <!-- generate javadoc for Nashorn classes -->
-  <target name="javadoc" depends="jar">
+  <target name="javadoc" depends="jar" unless="test.class">
     <javadoc destdir="${dist.javadoc.dir}" use="yes"
         windowtitle="${nashorn.product.name} ${nashorn.version}"
         additionalparam="-quiet" failonerror="true" useexternalfile="true"> 
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/ppc/globalDefinitions_ppc.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/ppc/globals_ppc.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/ppc/interp_masm_ppc.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/ppc/ppc.ad	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/s390/assembler_s390.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/s390/assembler_s390.inline.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/s390/globalDefinitions_s390.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/s390/globals_s390.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/s390/interp_masm_s390.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/s390/interp_masm_s390.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/s390/macroAssembler_s390.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/s390/s390.ad	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/s390/sharedRuntime_s390.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/s390/templateTable_s390.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/sparc/stubGenerator_sparc.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/x86/assembler_x86.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/x86/assembler_x86.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/cpu/x86/x86.ad	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/os/posix/os_posix.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/adlc/formssel.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -1449,6 +1449,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);
@@ -3566,6 +3569,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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/ci/ciEnv.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -926,64 +926,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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/code/dependencies.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/code/dependencies.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/gc/g1/g1Arguments.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/jvmci/jvmciEnv.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/jvmci/jvmciEnv.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/opto/c2_globals.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/opto/classes.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/opto/loopopts.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/opto/matcher.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/opto/superword.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/opto/vectornode.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/opto/vectornode.hpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/prims/nativeLookup.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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/java.cpp	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/runtime/java.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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	Thu Dec 14 20:55:06 2017 +0100
+++ b/src/hotspot/share/runtime/thread.cpp	Thu Dec 14 22:06:54 2017 +0100
@@ -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_H