changeset 29048:39a3bcf89286

Merge
author duke
date Wed, 05 Jul 2017 20:21:01 +0200
parents 65feae01b278 c46ad26fb278
children 95b1d97a4660
files hotspot/src/os/bsd/vm/dtraceJSDT_bsd.cpp hotspot/src/os/linux/vm/dtraceJSDT_linux.cpp hotspot/src/os/solaris/vm/dtraceJSDT_solaris.cpp hotspot/src/os/windows/vm/dtraceJSDT_windows.cpp hotspot/src/share/vm/runtime/dtraceJSDT.cpp hotspot/src/share/vm/runtime/dtraceJSDT.hpp jdk/make/data/charsetmapping/dbcs jdk/make/data/charsetmapping/extsbcs jdk/make/data/charsetmapping/sbcs jdk/make/data/charsetmapping/standard-charsets jdk/src/java.desktop/macosx/classes/sun/datatransfer/resources/flavormap.properties jdk/src/java.desktop/share/classes/java/awt/datatransfer/Clipboard.java jdk/src/java.desktop/share/classes/java/awt/datatransfer/ClipboardOwner.java jdk/src/java.desktop/share/classes/java/awt/datatransfer/DataFlavor.java jdk/src/java.desktop/share/classes/java/awt/datatransfer/FlavorEvent.java jdk/src/java.desktop/share/classes/java/awt/datatransfer/FlavorListener.java jdk/src/java.desktop/share/classes/java/awt/datatransfer/FlavorMap.java jdk/src/java.desktop/share/classes/java/awt/datatransfer/FlavorTable.java jdk/src/java.desktop/share/classes/java/awt/datatransfer/MimeType.java jdk/src/java.desktop/share/classes/java/awt/datatransfer/MimeTypeParameterList.java jdk/src/java.desktop/share/classes/java/awt/datatransfer/MimeTypeParseException.java jdk/src/java.desktop/share/classes/java/awt/datatransfer/StringSelection.java jdk/src/java.desktop/share/classes/java/awt/datatransfer/SystemFlavorMap.java jdk/src/java.desktop/share/classes/java/awt/datatransfer/Transferable.java jdk/src/java.desktop/share/classes/java/awt/datatransfer/UnsupportedFlavorException.java jdk/src/java.desktop/share/classes/java/awt/datatransfer/package.html jdk/src/java.desktop/share/classes/sun/datatransfer/DataFlavorUtil.java jdk/src/java.desktop/share/classes/sun/datatransfer/DesktopDatatransferService.java jdk/src/java.desktop/unix/classes/sun/awt/X11/XAWTFormatter.java jdk/src/java.desktop/unix/classes/sun/datatransfer/resources/flavormap.properties jdk/src/java.desktop/windows/classes/sun/datatransfer/resources/flavormap.properties jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/Big5_HKSCS.java jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/Big5_Solaris.java jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/DelegatableDecoder.java jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/DoubleByte.java jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/EUC_JP.java jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/EUC_JP_Open.java jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ExtendedCharsets.java jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/HKSCS.java jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/MS950_HKSCS_XP.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/Probe.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/ProbeName.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/Provider.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/ProviderFactory.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/ProviderName.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/dtrace/ArgsAttributes.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/dtrace/Attributes.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/dtrace/DependencyClass.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/dtrace/FunctionAttributes.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/dtrace/FunctionName.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/dtrace/ModuleAttributes.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/dtrace/ModuleName.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/dtrace/NameAttributes.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/dtrace/ProviderAttributes.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/dtrace/StabilityLevel.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/dtrace/package-info.java jdk/src/jdk.runtime/share/classes/com/sun/tracing/package-info.java jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool/PolicyTool.java jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool/Resources.java jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool/Resources_de.java jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool/Resources_es.java jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool/Resources_fr.java jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool/Resources_it.java jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool/Resources_ja.java jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool/Resources_ko.java jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool/Resources_pt_BR.java jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool/Resources_sv.java jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool/Resources_zh_CN.java jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool/Resources_zh_HK.java jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool/Resources_zh_TW.java jdk/src/jdk.runtime/share/classes/sun/tracing/MultiplexProviderFactory.java jdk/src/jdk.runtime/share/classes/sun/tracing/NullProviderFactory.java jdk/src/jdk.runtime/share/classes/sun/tracing/PrintStreamProviderFactory.java jdk/src/jdk.runtime/share/classes/sun/tracing/ProbeSkeleton.java jdk/src/jdk.runtime/share/classes/sun/tracing/ProviderSkeleton.java jdk/src/jdk.runtime/share/classes/sun/tracing/dtrace/Activation.java jdk/src/jdk.runtime/share/classes/sun/tracing/dtrace/DTraceProbe.java jdk/src/jdk.runtime/share/classes/sun/tracing/dtrace/DTraceProvider.java jdk/src/jdk.runtime/share/classes/sun/tracing/dtrace/DTraceProviderFactory.java jdk/src/jdk.runtime/share/classes/sun/tracing/dtrace/JVM.java jdk/src/jdk.runtime/share/classes/sun/tracing/package-info.java jdk/src/jdk.runtime/share/native/libjsdt/JVM.c jdk/src/jdk.runtime/share/native/libjsdt/jvm_symbols.h jdk/src/jdk.runtime/unix/native/libjsdt/jvm_symbols_md.c jdk/src/jdk.runtime/windows/native/libjsdt/jvm_symbols_md.c jdk/test/com/sun/tracing/BasicFunctionality.java jdk/test/com/sun/tracing/BasicWithSecurityMgr.java jdk/test/java/awt/color/LoadProfileWithSM.java jdk/test/java/awt/color/LoadStandardProfilesTest.java
diffstat 454 files changed, 25464 insertions(+), 26276 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags-top-repo	Thu Feb 19 11:24:01 2015 -0800
+++ b/.hgtags-top-repo	Wed Jul 05 20:21:01 2017 +0200
@@ -293,3 +293,4 @@
 0064e246d83f6f9fc245c19b6d05041ecaf4b6d4 jdk9-b48
 d91ed1951b948210590ce1394bea5515357246ba jdk9-b49
 d1f37d39ff2421f956a6ddf316cf763807bc3363 jdk9-b50
+6207b4b8731ca75c51b031c47daa813ab92ef558 jdk9-b51
--- a/Makefile	Thu Feb 19 11:24:01 2015 -0800
+++ b/Makefile	Wed Jul 05 20:21:01 2017 +0200
@@ -48,6 +48,17 @@
 endif
 root_dir:=$(patsubst %/,%,$(dir $(makefile_path)))
 
+ifeq ($(MAIN_TARGETS), )
+  COMMAND_LINE_VARIABLES:=$(subst =command,,$(filter %=command,$(foreach var,$(.VARIABLES),$(var)=$(firstword $(origin $(var))))))
+  MAKE_CONTROL_VARIABLES:=LOG CONF SPEC JOBS TEST IGNORE_OLD_CONFIG
+  UNKNOWN_COMMAND_LINE_VARIABLES:=$(strip $(filter-out $(MAKE_CONTROL_VARIABLES), $(COMMAND_LINE_VARIABLES)))
+  ifneq ($(UNKNOWN_COMMAND_LINE_VARIABLES), )
+    $(info Note: Command line contains non-control variables: $(UNKNOWN_COMMAND_LINE_VARIABLES).)
+    $(info Make sure it is not mistyped, and that you intend to override this variable.)
+    $(info 'make help' will list known control variables)
+  endif
+endif
+
 ifneq ($(findstring qp,$(MAKEFLAGS)),)
   # When called with -qp, assume an external part (e.g. bash completion) is trying
   # to understand our targets.
@@ -148,62 +159,64 @@
 # Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
 # If you add more global targets, please update the variable global_targets in MakeHelpers.
 
+# Helper macro to allow $(info) to properly print strings beginning with spaces.
+_:=
+
 help:
 	$(info )
 	$(info OpenJDK Makefile help)
 	$(info =====================)
 	$(info )
 	$(info Common make targets)
-	$(info .  make [default]         # Compile all modules in langtools, hotspot, jaxp, jaxws,)
-	$(info .                         # corba and jdk and create a runnable "exploded" image)
-	$(info .  make all               # Compile everything, all repos, docs and images)
-	$(info .  make images            # Create complete jdk and jre images)
-	$(info .  make <phase>           # Compile the specified phase and everything it depends on)
-	$(info .                         # (gensrc, java, copy, libs, launchers, gendata, rmic))
-	$(info .  make *-only            # Applies to most targets and disables compling the)
-	$(info .                         # dependencies for the target. This is faster but may)
-	$(info .                         # result in incorrect build results!)
-	$(info .  make docs              # Create all docs)
-	$(info .  make docs-javadoc      # Create just javadocs, depends on less than full docs)
-	$(info .  make profiles          # Create complete jre compact profile images)
-	$(info .  make bootcycle-images  # Build images twice, second time with newly built JDK)
-	$(info .  make install           # Install the generated images locally)
-	$(info .  make reconfigure       # Rerun configure with the same arguments as last time)
-	$(info .  make help              # Give some help on using make)
-	$(info .  make test              # Run tests, default is all tests (see TEST below))
+	$(info $(_) make [default]         # Compile all modules in langtools, hotspot, jdk, jaxws,)
+	$(info $(_)                        # jaxp and corba, and create a runnable "exploded" image)
+	$(info $(_) make all               # Compile everything, all repos, docs and images)
+	$(info $(_) make images            # Create complete j2sdk and j2re images)
+	$(info $(_) make <phase>           # Build the specified phase and everything it depends on)
+	$(info $(_)                        # (gensrc, java, copy, libs, launchers, gendata, rmic))
+	$(info $(_) make *-only            # Applies to most targets and disables compling the)
+	$(info $(_)                        # dependencies for the target. This is faster but may)
+	$(info $(_)                        # result in incorrect build results!)
+	$(info $(_) make docs              # Create all docs)
+	$(info $(_) make docs-javadoc      # Create just javadocs, depends on less than full docs)
+	$(info $(_) make profiles          # Create complete j2re compact profile images)
+	$(info $(_) make bootcycle-images  # Build images twice, second time with newly built JDK)
+	$(info $(_) make install           # Install the generated images locally)
+	$(info $(_) make reconfigure       # Rerun configure with the same arguments as last time)
+	$(info $(_) make help              # Give some help on using make)
+	$(info $(_) make test              # Run tests, default is all tests (see TEST below))
 	$(info )
 	$(info Targets for cleaning)
-	$(info .  make clean             # Remove all files generated by make, but not those)
-	$(info .                         # generated by configure)
-	$(info .  make dist-clean        # Remove all files, including configuration)
-	$(info .  make clean-<outputdir> # Remove the subdir in the output dir with the name)
-	$(info .  make clean-<phase>     # Remove all build results related to a certain build)
-	$(info .                         # phase (gensrc, java, libs, launchers))
-	$(info .  make clean-<module>    # Remove all build results related to a certain module)
-	$(info .  make clean-<module>-<phase> # Remove all build results related to a certain)
-	$(info .                         # module and phase)
+	$(info $(_) make clean             # Remove all files generated by make, but not those)
+	$(info $(_)                        # generated by configure)
+	$(info $(_) make dist-clean        # Remove all files, including configuration)
+	$(info $(_) make clean-<outputdir> # Remove the subdir in the output dir with the name)
+	$(info $(_) make clean-<phase>     # Remove all build results related to a certain build)
+	$(info $(_)                        # phase (gensrc, java, libs, launchers))
+	$(info $(_) make clean-<module>    # Remove all build results related to a certain module)
+	$(info $(_) make clean-<module>-<phase> # Remove all build results related to a certain)
+	$(info $(_)                        # module and phase)
 	$(info )
 	$(info Targets for specific modules)
-	$(info .  make <module>          # Build <module> and everything it depends on. )
-	$(info .  make <module>-<phase>  # Compile the specified phase for the specified module)
-	$(info .                         # and everything it depends on)
-	$(info .                         # (gensrc, java, copy, libs, launchers, gendata, rmic))
+	$(info $(_) make <module>          # Build <module> and everything it depends on.)
+	$(info $(_) make <module>-<phase>  # Compile the specified phase for the specified module)
+	$(info $(_)                        # and everything it depends on)
+	$(info $(_)                        # (gensrc, java, copy, libs, launchers, gendata, rmic))
 	$(info )
-	$(info Useful make variables)
-	$(info .  make CONF=             # Build all configurations (note, assignment is empty))
-	$(info .  make CONF=<substring>  # Build the configuration(s) with a name matching)
-	$(info .                         # <substring>)
-	$(info )
-	$(info .  make LOG=<loglevel>    # Change the log level from warn to <loglevel>)
-	$(info .                         # Available log levels are:)
-	$(info .                         # 'warn' (default), 'info', 'debug' and 'trace')
-	$(info .                         # To see executed command lines, use LOG=debug)
-	$(info )
-	$(info .  make JOBS=<n>          # Run <n> parallel make jobs)
-	$(info .                         # Note that -jN does not work as expected!)
-	$(info )
-	$(info .  make test TEST=<test>  # Only run the given test or tests, e.g.)
-	$(info .                         # make test TEST="jdk_lang jdk_net")
+	$(info Make control variables)
+	$(info $(_) CONF=                  # Build all configurations (note, assignment is empty))
+	$(info $(_) CONF=<substring>       # Build the configuration(s) with a name matching)
+	$(info $(_)                        # <substring>)
+	$(info $(_) SPEC=<spec file>       # Build the configuration given by the spec file)
+	$(info $(_) LOG=<loglevel>         # Change the log level from warn to <loglevel>)
+	$(info $(_)                        # Available log levels are:)
+	$(info $(_)                        # 'warn' (default), 'info', 'debug' and 'trace')
+	$(info $(_)                        # To see executed command lines, use LOG=debug)
+	$(info $(_) JOBS=<n>               # Run <n> parallel make jobs)
+	$(info $(_)                        # Note that -jN does not work as expected!)
+	$(info $(_) IGNORE_OLD_CONFIG=true # Skip tests if spec file is up to date)
+	$(info $(_) make test TEST=<test>  # Only run the given test or tests, e.g.)
+	$(info $(_)                        # make test TEST="jdk_lang jdk_net")
 	$(info )
 
 .PHONY: help
--- a/common/autoconf/basics.m4	Thu Feb 19 11:24:01 2015 -0800
+++ b/common/autoconf/basics.m4	Wed Jul 05 20:21:01 2017 +0200
@@ -899,10 +899,6 @@
   fi
   AC_SUBST(IS_GNU_TIME)
 
-  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
-    BASIC_REQUIRE_PROGS(COMM, comm)
-  fi
-
   if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
     BASIC_REQUIRE_PROGS(DSYMUTIL, dsymutil)
     BASIC_REQUIRE_PROGS(XATTR, xattr)
--- a/common/autoconf/flags.m4	Thu Feb 19 11:24:01 2015 -0800
+++ b/common/autoconf/flags.m4	Wed Jul 05 20:21:01 2017 +0200
@@ -558,15 +558,23 @@
     CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
     CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
-    -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
-    -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
-    -DWIN32 -DIAL"
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK \
+        -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
+        -DWIN32_LEAN_AND_MEAN \
+        -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
+        -DWIN32 -DIAL"
     if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
     else
       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
     fi
+    # If building with Visual Studio 2010, we can still use _STATIC_CPPLIB to
+    # avoid bundling msvcpNNN.dll. Doesn't work with newer versions of visual
+    # studio.
+    if test "x$TOOLCHAIN_VERSION" = "x2010"; then
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
+          -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB"
+    fi
   fi
 
   ###############################################################################
--- a/common/autoconf/generated-configure.sh	Thu Feb 19 11:24:01 2015 -0800
+++ b/common/autoconf/generated-configure.sh	Wed Jul 05 20:21:01 2017 +0200
@@ -646,6 +646,7 @@
 ENABLE_INTREE_EC
 SALIB_NAME
 HOTSPOT_MAKE_ARGS
+MSVCP_DLL
 MSVCR_DLL
 LIBCXX
 LLVM_LIBS
@@ -1079,6 +1080,7 @@
 with_override_jdk
 with_import_hotspot
 with_toolchain_type
+with_toolchain_version
 with_jtreg
 with_extra_cflags
 with_extra_cxxflags
@@ -1103,6 +1105,7 @@
 with_zlib
 with_stdc__lib
 with_msvcr_dll
+with_msvcp_dll
 with_dxsdk
 with_dxsdk_lib
 with_dxsdk_include
@@ -1934,6 +1937,10 @@
                           source
   --with-toolchain-type   the toolchain type (or family) to use, use '--help'
                           to show possible values [platform dependent]
+  --with-toolchain-version
+                          the version of the toolchain to look for, use
+                          '--help' to show possible values [platform
+                          dependent]
   --with-jtreg            Regression Test Harness [probed]
   --with-extra-cflags     extra flags to be used when compiling jdk c-files
   --with-extra-cxxflags   extra flags to be used when compiling jdk c++-files
@@ -1969,8 +1976,10 @@
                           force linking of the C++ runtime on Linux to either
                           static or dynamic, default is static with dynamic as
                           fallback
-  --with-msvcr-dll        copy this msvcr100.dll into the built JDK (Windows
-                          only) [probed]
+  --with-msvcr-dll        path to microsoft C runtime dll (msvcr*.dll)
+                          (Windows only) [probed]
+  --with-msvcp-dll        path to microsoft C++ runtime dll (msvcp*.dll)
+                          (Windows only) [probed]
   --with-dxsdk            Deprecated. Option is kept for backwards
                           compatibility and is ignored
   --with-dxsdk-lib        Deprecated. Option is kept for backwards
@@ -4309,12 +4318,59 @@
 # questions.
 #
 
-
-
-
-
-
-
+################################################################################
+
+VALID_VS_VERSIONS="2010 2012 2013"
+
+VS_DESCRIPTION_2010="Microsoft Visual Studio 2010"
+VS_VERSION_INTERNAL_2010=100
+VS_MSVCR_2010=msvcr100.dll
+# We don't use msvcp on Visual Studio 2010
+#VS_MSVCP_2010=msvcp100.dll
+VS_ENVVAR_2010="VS100COMNTOOLS"
+VS_VS_INSTALLDIR_2010="Microsoft Visual Studio 10.0"
+VS_SDK_INSTALLDIR_2010="Microsoft SDKs/Windows/v7.1"
+VS_VS_PLATFORM_NAME_2010="v100"
+VS_SDK_PLATFORM_NAME_2010="Windows7.1SDK"
+
+VS_DESCRIPTION_2012="Microsoft Visual Studio 2012"
+VS_VERSION_INTERNAL_2012=110
+VS_MSVCR_2012=msvcr110.dll
+VS_MSVCP_2012=msvcp110.dll
+VS_ENVVAR_2012="VS110COMNTOOLS"
+VS_VS_INSTALLDIR_2012="Microsoft Visual Studio 11.0"
+VS_SDK_INSTALLDIR_2012=
+VS_VS_PLATFORM_NAME_2012="v110"
+VS_SDK_PLATFORM_NAME_2012=
+
+VS_DESCRIPTION_2013="Microsoft Visual Studio 2013"
+VS_VERSION_INTERNAL_2013=120
+VS_MSVCR_2013=msvcr120.dll
+VS_MSVCP_2013=msvcp120.dll
+VS_ENVVAR_2013="VS120COMNTOOLS"
+VS_VS_INSTALLDIR_2013="Microsoft Visual Studio 12.0"
+VS_SDK_INSTALLDIR_2013=
+VS_VS_PLATFORM_NAME_2013="v120"
+VS_SDK_PLATFORM_NAME_2013=
+
+################################################################################
+
+
+
+################################################################################
+
+
+
+################################################################################
+# Finds the bat or cmd file in Visual Studio or the SDK that sets up a proper
+# build environment and assigns it to VS_ENV_CMD
+
+
+################################################################################
+
+
+
+################################################################################
 # Check if the VS env variables were setup prior to running configure.
 # If not, then find vcvarsall.bat and run it automatically, and integrate
 # the set env variables into the spec file.
@@ -4329,13 +4385,15 @@
 
 
 
+
+
 # This line needs to be here, verbatim, after all includes and the dummy hook
 # definitions. It is replaced with custom functionality when building
 # custom sources.
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1423567509
+DATE_WHEN_GENERATED=1424202275
 
 ###############################################################################
 #
@@ -18830,202 +18888,6 @@
   fi
 
 
-  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
-
-
-
-  # Publish this variable in the help.
-
-
-  if test "x$COMM" = x; then
-    # The variable is not set by user, try to locate tool using the code snippet
-    for ac_prog in comm
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_COMM+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $COMM in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_COMM="$COMM" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_COMM="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-COMM=$ac_cv_path_COMM
-if test -n "$COMM"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $COMM" >&5
-$as_echo "$COMM" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$COMM" && break
-done
-
-  else
-    # The variable is set, but is it from the command line or the environment?
-
-    # Try to remove the string !COMM! from our list.
-    try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!COMM!/}
-    if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then
-      # If it failed, the variable was not from the command line. Ignore it,
-      # but warn the user (except for BASH, which is always set by the calling BASH).
-      if test "xCOMM" != xBASH; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of COMM from the environment. Use command line variables instead." >&5
-$as_echo "$as_me: WARNING: Ignoring value of COMM from the environment. Use command line variables instead." >&2;}
-      fi
-      # Try to locate tool using the code snippet
-      for ac_prog in comm
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_COMM+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $COMM in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_COMM="$COMM" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_COMM="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-COMM=$ac_cv_path_COMM
-if test -n "$COMM"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $COMM" >&5
-$as_echo "$COMM" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$COMM" && break
-done
-
-    else
-      # If it succeeded, then it was overridden by the user. We will use it
-      # for the tool.
-
-      # First remove it from the list of overridden variables, so we can test
-      # for unknown variables in the end.
-      CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
-
-      # Check if the provided tool contains a complete path.
-      tool_specified="$COMM"
-      tool_basename="${tool_specified##*/}"
-      if test "x$tool_basename" = "x$tool_specified"; then
-        # A command without a complete path is provided, search $PATH.
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool COMM=$tool_basename" >&5
-$as_echo "$as_me: Will search for user supplied tool COMM=$tool_basename" >&6;}
-        # Extract the first word of "$tool_basename", so it can be a program name with args.
-set dummy $tool_basename; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_COMM+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $COMM in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_COMM="$COMM" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_COMM="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-COMM=$ac_cv_path_COMM
-if test -n "$COMM"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $COMM" >&5
-$as_echo "$COMM" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-        if test "x$COMM" = x; then
-          as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5
-        fi
-      else
-        # Otherwise we believe it is a complete path. Use it as it is.
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool COMM=$tool_specified" >&5
-$as_echo "$as_me: Will use user supplied tool COMM=$tool_specified" >&6;}
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for COMM" >&5
-$as_echo_n "checking for COMM... " >&6; }
-        if test ! -x "$tool_specified"; then
-          { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
-$as_echo "not found" >&6; }
-          as_fn_error $? "User supplied tool COMM=$tool_specified does not exist or is not executable" "$LINENO" 5
-        fi
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5
-$as_echo "$tool_specified" >&6; }
-      fi
-    fi
-  fi
-
-
-
-  if test "x$COMM" = x; then
-    as_fn_error $? "Could not find required tool for COMM" "$LINENO" 5
-  fi
-
-
-  fi
-
   if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
 
 
@@ -26700,41 +26562,177 @@
 
   # First-hand choice is to locate and run the vsvars bat file.
 
-  if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
-    VCVARSFILE="vc/bin/vcvars32.bat"
-  else
-    VCVARSFILE="vc/bin/amd64/vcvars64.bat"
+
+# Check whether --with-toolchain-version was given.
+if test "${with_toolchain_version+set}" = set; then :
+  withval=$with_toolchain_version;
+fi
+
+
+  if test "x$with_toolchain_version" = xlist; then
+    # List all toolchains
+    { $as_echo "$as_me:${as_lineno-$LINENO}: The following toolchain versions are valid on this platform:" >&5
+$as_echo "$as_me: The following toolchain versions are valid on this platform:" >&6;}
+    for version in $VALID_VS_VERSIONS; do
+      eval VS_DESCRIPTION=\${VS_DESCRIPTION_$version}
+      $PRINTF "  %-10s  %s\n" $version "$VS_DESCRIPTION"
+    done
+
+    exit 0
+  elif test "x$with_toolchain_version" != x; then
+    # User override; check that it is valid
+    if test "x${VALID_VS_VERSIONS/$with_toolchain_version/}" = "x${VALID_VS_VERSIONS}"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Visual Studio version $with_toolchain_version is not valid." >&5
+$as_echo "$as_me: Visual Studio version $with_toolchain_version is not valid." >&6;}
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Valid Visual Studio versions: $VALID_VS_VERSIONS." >&5
+$as_echo "$as_me: Valid Visual Studio versions: $VALID_VS_VERSIONS." >&6;}
+      as_fn_error $? "Cannot continue." "$LINENO" 5
+    fi
+    VS_VERSIONS_PROBE_LIST="$with_toolchain_version"
+  else
+    # No flag given, use default
+    VS_VERSIONS_PROBE_LIST="$VALID_VS_VERSIONS"
+  fi
+
+  for VS_VERSION in $VS_VERSIONS_PROBE_LIST; do
+
+  VS_VERSION="$VS_VERSION"
+  eval VS_COMNTOOLS_VAR="\${VS_ENVVAR_${VS_VERSION}}"
+  eval VS_COMNTOOLS="\$${VS_COMNTOOLS_VAR}"
+  eval VS_INSTALL_DIR="\${VS_VS_INSTALLDIR_${VS_VERSION}}"
+  eval SDK_INSTALL_DIR="\${VS_SDK_INSTALLDIR_${VS_VERSION}}"
+
+  # When using --with-tools-dir, assume it points to the correct and default
+  # version of Visual Studio or that --with-toolchain-version was also set.
+  if test "x$with_tools_dir" != x; then
+
+  if test "x$VS_ENV_CMD" = x; then
+    VS_VERSION="${VS_VERSION}"
+    VS_BASE="$with_tools_dir/../.."
+    METHOD="--with-tools-dir"
+
+    if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+      VCVARSFILE="vc/bin/vcvars32.bat"
+    else
+      VCVARSFILE="vc/bin/amd64/vcvars64.bat"
+    fi
+
+
+  windows_path="$VS_BASE"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    VS_BASE="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    VS_BASE="$unix_path"
+  fi
+
+    if test -d "$VS_BASE"; then
+      if test -f "$VS_BASE/$VCVARSFILE"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5
+$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;}
+        VS_ENV_CMD="$VS_BASE/$VCVARSFILE"
+        # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
+        # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013
+        eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
+      else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5
+$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5
+$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;}
+      fi
+    fi
+  fi
+
+
+  if test "x$VS_ENV_CMD" = x; then
+    VS_VERSION="${VS_VERSION}"
+    VS_BASE="$with_tools_dir/../../.."
+    METHOD="--with-tools-dir"
+
+    if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+      VCVARSFILE="vc/bin/vcvars32.bat"
+    else
+      VCVARSFILE="vc/bin/amd64/vcvars64.bat"
+    fi
+
+
+  windows_path="$VS_BASE"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    VS_BASE="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    VS_BASE="$unix_path"
+  fi
+
+    if test -d "$VS_BASE"; then
+      if test -f "$VS_BASE/$VCVARSFILE"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5
+$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;}
+        VS_ENV_CMD="$VS_BASE/$VCVARSFILE"
+        # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
+        # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013
+        eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
+      else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5
+$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5
+$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;}
+      fi
+    fi
+  fi
+
+    if test "x$VS_ENV_CMD" = x; then
+      # Having specified an argument which is incorrect will produce an instant failure;
+      # we should not go on looking
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The path given by --with-tools-dir does not contain a valid" >&5
+$as_echo "$as_me: The path given by --with-tools-dir does not contain a valid" >&6;}
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Visual Studio installation. Please point to the VC/bin or VC/bin/amd64" >&5
+$as_echo "$as_me: Visual Studio installation. Please point to the VC/bin or VC/bin/amd64" >&6;}
+      { $as_echo "$as_me:${as_lineno-$LINENO}: directory within the Visual Studio installation" >&5
+$as_echo "$as_me: directory within the Visual Studio installation" >&6;}
+      as_fn_error $? "Cannot locate a valid Visual Studio installation" "$LINENO" 5
+    fi
   fi
 
   VS_ENV_CMD=""
   VS_ENV_ARGS=""
-  if test "x$with_toolsdir" != x; then
+
+  if test "x$VS_COMNTOOLS" != x; then
 
   if test "x$VS_ENV_CMD" = x; then
-    VS100BASE="$with_toolsdir/../.."
-    METHOD="--with-tools-dir"
-
-  windows_path="$VS100BASE"
-  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
-    unix_path=`$CYGPATH -u "$windows_path"`
-    VS100BASE="$unix_path"
-  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
-    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
-    VS100BASE="$unix_path"
-  fi
-
-    if test -d "$VS100BASE"; then
-      if test -f "$VS100BASE/$VCVARSFILE"; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5
-$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;}
-        VS_ENV_CMD="$VS100BASE/$VCVARSFILE"
+    VS_VERSION="${VS_VERSION}"
+    VS_BASE="$VS_COMNTOOLS/../.."
+    METHOD="$VS_COMNTOOLS_VAR variable"
+
+    if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+      VCVARSFILE="vc/bin/vcvars32.bat"
+    else
+      VCVARSFILE="vc/bin/amd64/vcvars64.bat"
+    fi
+
+
+  windows_path="$VS_BASE"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    VS_BASE="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    VS_BASE="$unix_path"
+  fi
+
+    if test -d "$VS_BASE"; then
+      if test -f "$VS_BASE/$VCVARSFILE"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5
+$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;}
+        VS_ENV_CMD="$VS_BASE/$VCVARSFILE"
         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013
-        # TODO: improve detection for other versions of VS
-        PLATFORM_TOOLSET="v100"
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5
-$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;}
+        eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
+      else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5
+$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;}
         { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5
 $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;}
       fi
@@ -26742,44 +26740,40 @@
   fi
 
   fi
-
-  if test "x$with_toolsdir" != x && test "x$VS_ENV_CMD" = x; then
-    # Having specified an argument which is incorrect will produce an instant failure;
-    # we should not go on looking
-    { $as_echo "$as_me:${as_lineno-$LINENO}: The path given by --with-tools-dir does not contain a valid Visual Studio installation" >&5
-$as_echo "$as_me: The path given by --with-tools-dir does not contain a valid Visual Studio installation" >&6;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Please point to the VC/bin directory within the Visual Studio installation" >&5
-$as_echo "$as_me: Please point to the VC/bin directory within the Visual Studio installation" >&6;}
-    as_fn_error $? "Cannot locate a valid Visual Studio installation" "$LINENO" 5
-  fi
-
-  if test "x$VS100COMNTOOLS" != x; then
+  if test "x$PROGRAMFILES" != x; then
 
   if test "x$VS_ENV_CMD" = x; then
-    VS100BASE="$VS100COMNTOOLS/../.."
-    METHOD="VS100COMNTOOLS variable"
-
-  windows_path="$VS100BASE"
-  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
-    unix_path=`$CYGPATH -u "$windows_path"`
-    VS100BASE="$unix_path"
-  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
-    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
-    VS100BASE="$unix_path"
-  fi
-
-    if test -d "$VS100BASE"; then
-      if test -f "$VS100BASE/$VCVARSFILE"; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5
-$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;}
-        VS_ENV_CMD="$VS100BASE/$VCVARSFILE"
+    VS_VERSION="${VS_VERSION}"
+    VS_BASE="$PROGRAMFILES/$VS_INSTALL_DIR"
+    METHOD="well-known name"
+
+    if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+      VCVARSFILE="vc/bin/vcvars32.bat"
+    else
+      VCVARSFILE="vc/bin/amd64/vcvars64.bat"
+    fi
+
+
+  windows_path="$VS_BASE"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    VS_BASE="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    VS_BASE="$unix_path"
+  fi
+
+    if test -d "$VS_BASE"; then
+      if test -f "$VS_BASE/$VCVARSFILE"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5
+$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;}
+        VS_ENV_CMD="$VS_BASE/$VCVARSFILE"
         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013
-        # TODO: improve detection for other versions of VS
-        PLATFORM_TOOLSET="v100"
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5
-$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;}
+        eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
+      else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5
+$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;}
         { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5
 $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;}
       fi
@@ -26787,33 +26781,42 @@
   fi
 
   fi
-  if test "x$PROGRAMFILES" != x; then
+  # Work around the insanely named ProgramFiles(x86) env variable
+  PROGRAMFILES_X86="`env | $SED -n 's/^ProgramFiles(x86)=//p'`"
+  if test "x$PROGRAMFILES_X86" != x; then
 
   if test "x$VS_ENV_CMD" = x; then
-    VS100BASE="$PROGRAMFILES/Microsoft Visual Studio 10.0"
+    VS_VERSION="${VS_VERSION}"
+    VS_BASE="$PROGRAMFILES_X86/$VS_INSTALL_DIR"
     METHOD="well-known name"
 
-  windows_path="$VS100BASE"
-  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
-    unix_path=`$CYGPATH -u "$windows_path"`
-    VS100BASE="$unix_path"
-  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
-    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
-    VS100BASE="$unix_path"
-  fi
-
-    if test -d "$VS100BASE"; then
-      if test -f "$VS100BASE/$VCVARSFILE"; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5
-$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;}
-        VS_ENV_CMD="$VS100BASE/$VCVARSFILE"
+    if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+      VCVARSFILE="vc/bin/vcvars32.bat"
+    else
+      VCVARSFILE="vc/bin/amd64/vcvars64.bat"
+    fi
+
+
+  windows_path="$VS_BASE"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    VS_BASE="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    VS_BASE="$unix_path"
+  fi
+
+    if test -d "$VS_BASE"; then
+      if test -f "$VS_BASE/$VCVARSFILE"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5
+$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;}
+        VS_ENV_CMD="$VS_BASE/$VCVARSFILE"
         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013
-        # TODO: improve detection for other versions of VS
-        PLATFORM_TOOLSET="v100"
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5
-$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;}
+        eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
+      else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5
+$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;}
         { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5
 $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;}
       fi
@@ -26823,30 +26826,37 @@
   fi
 
   if test "x$VS_ENV_CMD" = x; then
-    VS100BASE="C:/Program Files/Microsoft Visual Studio 10.0"
+    VS_VERSION="${VS_VERSION}"
+    VS_BASE="C:/Program Files/$VS_INSTALL_DIR"
     METHOD="well-known name"
 
-  windows_path="$VS100BASE"
-  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
-    unix_path=`$CYGPATH -u "$windows_path"`
-    VS100BASE="$unix_path"
-  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
-    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
-    VS100BASE="$unix_path"
-  fi
-
-    if test -d "$VS100BASE"; then
-      if test -f "$VS100BASE/$VCVARSFILE"; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5
-$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;}
-        VS_ENV_CMD="$VS100BASE/$VCVARSFILE"
+    if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+      VCVARSFILE="vc/bin/vcvars32.bat"
+    else
+      VCVARSFILE="vc/bin/amd64/vcvars64.bat"
+    fi
+
+
+  windows_path="$VS_BASE"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    VS_BASE="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    VS_BASE="$unix_path"
+  fi
+
+    if test -d "$VS_BASE"; then
+      if test -f "$VS_BASE/$VCVARSFILE"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5
+$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;}
+        VS_ENV_CMD="$VS_BASE/$VCVARSFILE"
         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013
-        # TODO: improve detection for other versions of VS
-        PLATFORM_TOOLSET="v100"
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5
-$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;}
+        eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
+      else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5
+$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;}
         { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5
 $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;}
       fi
@@ -26855,30 +26865,37 @@
 
 
   if test "x$VS_ENV_CMD" = x; then
-    VS100BASE="C:/Program Files (x86)/Microsoft Visual Studio 10.0"
+    VS_VERSION="${VS_VERSION}"
+    VS_BASE="C:/Program Files (x86)/$VS_INSTALL_DIR"
     METHOD="well-known name"
 
-  windows_path="$VS100BASE"
-  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
-    unix_path=`$CYGPATH -u "$windows_path"`
-    VS100BASE="$unix_path"
-  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
-    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
-    VS100BASE="$unix_path"
-  fi
-
-    if test -d "$VS100BASE"; then
-      if test -f "$VS100BASE/$VCVARSFILE"; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5
-$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;}
-        VS_ENV_CMD="$VS100BASE/$VCVARSFILE"
+    if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+      VCVARSFILE="vc/bin/vcvars32.bat"
+    else
+      VCVARSFILE="vc/bin/amd64/vcvars64.bat"
+    fi
+
+
+  windows_path="$VS_BASE"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    VS_BASE="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    VS_BASE="$unix_path"
+  fi
+
+    if test -d "$VS_BASE"; then
+      if test -f "$VS_BASE/$VCVARSFILE"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5
+$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;}
+        VS_ENV_CMD="$VS_BASE/$VCVARSFILE"
         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013
-        # TODO: improve detection for other versions of VS
-        PLATFORM_TOOLSET="v100"
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS100BASE using $METHOD" >&5
-$as_echo "$as_me: Found Visual Studio installation at $VS100BASE using $METHOD" >&6;}
+        eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
+      else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5
+$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;}
         { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5
 $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;}
       fi
@@ -26886,10 +26903,12 @@
   fi
 
 
-  if test "x$ProgramW6432" != x; then
+  if test "x$SDK_INSTALL_DIR" != x; then
+    if test "x$ProgramW6432" != x; then
 
   if test "x$VS_ENV_CMD" = x; then
-    WIN_SDK_BASE="$ProgramW6432/Microsoft SDKs/Windows/v7.1/Bin"
+    VS_VERSION="${VS_VERSION}"
+    WIN_SDK_BASE="$ProgramW6432/$SDK_INSTALL_DIR"
     METHOD="well-known name"
 
   windows_path="$WIN_SDK_BASE"
@@ -26904,15 +26923,15 @@
     if test -d "$WIN_SDK_BASE"; then
       # There have been cases of partial or broken SDK installations. A missing
       # lib dir is not going to work.
-      if test ! -d "$WIN_SDK_BASE/../lib"; then
+      if test ! -d "$WIN_SDK_BASE/lib"; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
         { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: Installation is broken, lib dir is missing. Ignoring" >&5
 $as_echo "$as_me: Warning: Installation is broken, lib dir is missing. Ignoring" >&6;}
-      elif test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then
+      elif test -f "$WIN_SDK_BASE/Bin/SetEnv.Cmd"; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
-        VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd"
+        VS_ENV_CMD="$WIN_SDK_BASE/Bin/SetEnv.Cmd"
         if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
           VS_ENV_ARGS="/x86"
         else
@@ -26921,7 +26940,7 @@
         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK
         # TODO: improve detection for other versions of SDK
-        PLATFORM_TOOLSET="Windows7.1SDK"
+        eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}"
       else
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
@@ -26931,11 +26950,12 @@
     fi
   fi
 
-  fi
-  if test "x$PROGRAMW6432" != x; then
+    fi
+    if test "x$PROGRAMW6432" != x; then
 
   if test "x$VS_ENV_CMD" = x; then
-    WIN_SDK_BASE="$PROGRAMW6432/Microsoft SDKs/Windows/v7.1/Bin"
+    VS_VERSION="${VS_VERSION}"
+    WIN_SDK_BASE="$PROGRAMW6432/$SDK_INSTALL_DIR"
     METHOD="well-known name"
 
   windows_path="$WIN_SDK_BASE"
@@ -26950,15 +26970,15 @@
     if test -d "$WIN_SDK_BASE"; then
       # There have been cases of partial or broken SDK installations. A missing
       # lib dir is not going to work.
-      if test ! -d "$WIN_SDK_BASE/../lib"; then
+      if test ! -d "$WIN_SDK_BASE/lib"; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
         { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: Installation is broken, lib dir is missing. Ignoring" >&5
 $as_echo "$as_me: Warning: Installation is broken, lib dir is missing. Ignoring" >&6;}
-      elif test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then
+      elif test -f "$WIN_SDK_BASE/Bin/SetEnv.Cmd"; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
-        VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd"
+        VS_ENV_CMD="$WIN_SDK_BASE/Bin/SetEnv.Cmd"
         if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
           VS_ENV_ARGS="/x86"
         else
@@ -26967,7 +26987,7 @@
         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK
         # TODO: improve detection for other versions of SDK
-        PLATFORM_TOOLSET="Windows7.1SDK"
+        eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}"
       else
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
@@ -26977,11 +26997,12 @@
     fi
   fi
 
-  fi
-  if test "x$PROGRAMFILES" != x; then
+    fi
+    if test "x$PROGRAMFILES" != x; then
 
   if test "x$VS_ENV_CMD" = x; then
-    WIN_SDK_BASE="$PROGRAMFILES/Microsoft SDKs/Windows/v7.1/Bin"
+    VS_VERSION="${VS_VERSION}"
+    WIN_SDK_BASE="$PROGRAMFILES/$SDK_INSTALL_DIR"
     METHOD="well-known name"
 
   windows_path="$WIN_SDK_BASE"
@@ -26996,15 +27017,15 @@
     if test -d "$WIN_SDK_BASE"; then
       # There have been cases of partial or broken SDK installations. A missing
       # lib dir is not going to work.
-      if test ! -d "$WIN_SDK_BASE/../lib"; then
+      if test ! -d "$WIN_SDK_BASE/lib"; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
         { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: Installation is broken, lib dir is missing. Ignoring" >&5
 $as_echo "$as_me: Warning: Installation is broken, lib dir is missing. Ignoring" >&6;}
-      elif test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then
+      elif test -f "$WIN_SDK_BASE/Bin/SetEnv.Cmd"; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
-        VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd"
+        VS_ENV_CMD="$WIN_SDK_BASE/Bin/SetEnv.Cmd"
         if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
           VS_ENV_ARGS="/x86"
         else
@@ -27013,7 +27034,7 @@
         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK
         # TODO: improve detection for other versions of SDK
-        PLATFORM_TOOLSET="Windows7.1SDK"
+        eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}"
       else
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
@@ -27023,10 +27044,11 @@
     fi
   fi
 
-  fi
+    fi
 
   if test "x$VS_ENV_CMD" = x; then
-    WIN_SDK_BASE="C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin"
+    VS_VERSION="${VS_VERSION}"
+    WIN_SDK_BASE="C:/Program Files/$SDK_INSTALL_DIR"
     METHOD="well-known name"
 
   windows_path="$WIN_SDK_BASE"
@@ -27041,15 +27063,15 @@
     if test -d "$WIN_SDK_BASE"; then
       # There have been cases of partial or broken SDK installations. A missing
       # lib dir is not going to work.
-      if test ! -d "$WIN_SDK_BASE/../lib"; then
+      if test ! -d "$WIN_SDK_BASE/lib"; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
         { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: Installation is broken, lib dir is missing. Ignoring" >&5
 $as_echo "$as_me: Warning: Installation is broken, lib dir is missing. Ignoring" >&6;}
-      elif test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then
+      elif test -f "$WIN_SDK_BASE/Bin/SetEnv.Cmd"; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
-        VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd"
+        VS_ENV_CMD="$WIN_SDK_BASE/Bin/SetEnv.Cmd"
         if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
           VS_ENV_ARGS="/x86"
         else
@@ -27058,7 +27080,7 @@
         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK
         # TODO: improve detection for other versions of SDK
-        PLATFORM_TOOLSET="Windows7.1SDK"
+        eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}"
       else
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
@@ -27070,7 +27092,8 @@
 
 
   if test "x$VS_ENV_CMD" = x; then
-    WIN_SDK_BASE="C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1/Bin"
+    VS_VERSION="${VS_VERSION}"
+    WIN_SDK_BASE="C:/Program Files (x86)/$SDK_INSTALL_DIR"
     METHOD="well-known name"
 
   windows_path="$WIN_SDK_BASE"
@@ -27085,15 +27108,15 @@
     if test -d "$WIN_SDK_BASE"; then
       # There have been cases of partial or broken SDK installations. A missing
       # lib dir is not going to work.
-      if test ! -d "$WIN_SDK_BASE/../lib"; then
+      if test ! -d "$WIN_SDK_BASE/lib"; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
         { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: Installation is broken, lib dir is missing. Ignoring" >&5
 $as_echo "$as_me: Warning: Installation is broken, lib dir is missing. Ignoring" >&6;}
-      elif test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then
+      elif test -f "$WIN_SDK_BASE/Bin/SetEnv.Cmd"; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
-        VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd"
+        VS_ENV_CMD="$WIN_SDK_BASE/Bin/SetEnv.Cmd"
         if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
           VS_ENV_ARGS="/x86"
         else
@@ -27102,7 +27125,7 @@
         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK
         # TODO: improve detection for other versions of SDK
-        PLATFORM_TOOLSET="Windows7.1SDK"
+        eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}"
       else
         { $as_echo "$as_me:${as_lineno-$LINENO}: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&5
 $as_echo "$as_me: Found Windows SDK installation at $WIN_SDK_BASE using $METHOD" >&6;}
@@ -27112,6 +27135,21 @@
     fi
   fi
 
+  fi
+
+    if test "x$VS_ENV_CMD" != x; then
+      TOOLCHAIN_VERSION=$VS_VERSION
+      eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}"
+      eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}"
+      eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}"
+      eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}"
+      # The rest of the variables are already evaled while probing
+      { $as_echo "$as_me:${as_lineno-$LINENO}: Found $VS_DESCRIPTION" >&5
+$as_echo "$as_me: Found $VS_DESCRIPTION" >&6;}
+      break
+    fi
+  done
+
 
   if test "x$VS_ENV_CMD" != x; then
     # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file.
@@ -41034,8 +41072,8 @@
     CC_VERSION_OUTPUT=`$CC 2>&1 | $HEAD -n 1 | $TR -d '\r'`
     COMPILER_CPU_TEST=`$ECHO $CC_VERSION_OUTPUT | $SED -n "s/^.* \(.*\)$/\1/p"`
     if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
-      if test "x$COMPILER_CPU_TEST" != "x80x86"; then
-        as_fn_error $? "Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"80x86\"." "$LINENO" 5
+      if test "x$COMPILER_CPU_TEST" != "x80x86" -a "x$COMPILER_CPU_TEST" != "xx86"; then
+        as_fn_error $? "Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"80x86\" or \"x86\"." "$LINENO" 5
       fi
     elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
       if test "x$COMPILER_CPU_TEST" != "xx64"; then
@@ -42683,15 +42721,23 @@
     CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
     CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
-    -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
-    -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
-    -DWIN32 -DIAL"
+    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK \
+        -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
+        -DWIN32_LEAN_AND_MEAN \
+        -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
+        -DWIN32 -DIAL"
     if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
     else
       COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
     fi
+    # If building with Visual Studio 2010, we can still use _STATIC_CPPLIB to
+    # avoid bundling msvcpNNN.dll. Doesn't work with newer versions of visual
+    # studio.
+    if test "x$TOOLCHAIN_VERSION" = "x2010"; then
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
+          -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB"
+    fi
   fi
 
   ###############################################################################
@@ -49842,16 +49888,17 @@
   if test "x$with_msvcr_dll" != x; then
     # If given explicitely by user, do not probe. If not present, fail directly.
 
-  POSSIBLE_MSVCR_DLL="$with_msvcr_dll"
+  DLL_NAME="$DLL_NAME"
+  POSSIBLE_MSVC_DLL="$with_msvcr_dll"
   METHOD="--with-msvcr-dll"
-  if test -e "$POSSIBLE_MSVCR_DLL"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&5
-$as_echo "$as_me: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&6;}
+  if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&5
+$as_echo "$as_me: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&6;}
 
     # Need to check if the found msvcr is correct architecture
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found msvcr100.dll architecture" >&5
-$as_echo_n "checking found msvcr100.dll architecture... " >&6; }
-    MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found $DLL_NAME architecture" >&5
+$as_echo_n "checking found $DLL_NAME architecture... " >&6; }
+    MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
       # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
       # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
@@ -49867,28 +49914,32 @@
         CORRECT_MSVCR_ARCH=x86-64
       fi
     fi
-    if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
+    if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
 $as_echo "ok" >&6; }
-      MSVCR_DLL="$POSSIBLE_MSVCR_DLL"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for msvcr100.dll" >&5
-$as_echo_n "checking for msvcr100.dll... " >&6; }
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVCR_DLL" >&5
-$as_echo "$MSVCR_DLL" >&6; }
+      MSVC_DLL="$POSSIBLE_MSVC_DLL"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $DLL_NAME" >&5
+$as_echo_n "checking for $DLL_NAME... " >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVC_DLL" >&5
+$as_echo "$MSVC_DLL" >&6; }
     else
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: incorrect, ignoring" >&5
 $as_echo "incorrect, ignoring" >&6; }
-      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE" >&5
-$as_echo "$as_me: The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE" >&6;}
-    fi
-  fi
-
-    if test "x$MSVCR_DLL" = x; then
-      as_fn_error $? "Could not find a proper msvcr100.dll as specified by --with-msvcr-dll" "$LINENO" 5
-    fi
-  fi
-
-  if test "x$MSVCR_DLL" = x; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&5
+$as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&6;}
+    fi
+  fi
+
+    if test "x$MSVC_DLL" = x; then
+      as_fn_error $? "Could not find a proper $MSVCR_NAME as specified by --with-msvcr-dll" "$LINENO" 5
+    fi
+  else
+
+  VAR_NAME="MSVCR_DLL"
+  DLL_NAME="${MSVCR_NAME}"
+  MSVC_DLL=
+
+  if test "x$MSVC_DLL" = x; then
     # Probe: Using well-known location from Visual Studio 10.0
     if test "x$VCINSTALLDIR" != x; then
       CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR"
@@ -49903,21 +49954,23 @@
   fi
 
       if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-        POSSIBLE_MSVCR_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC100.CRT/msvcr100.dll"
-      else
-        POSSIBLE_MSVCR_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC100.CRT/msvcr100.dll"
-      fi
-
-  POSSIBLE_MSVCR_DLL="$POSSIBLE_MSVCR_DLL"
+        POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
+      else
+        POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
+      fi
+      $ECHO "POSSIBLE_MSVC_DLL $POSSIBLEMSVC_DLL"
+
+  DLL_NAME="$DLL_NAME"
+  POSSIBLE_MSVC_DLL="$POSSIBLE_MSVC_DLL"
   METHOD="well-known location in VCINSTALLDIR"
-  if test -e "$POSSIBLE_MSVCR_DLL"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&5
-$as_echo "$as_me: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&6;}
+  if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&5
+$as_echo "$as_me: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&6;}
 
     # Need to check if the found msvcr is correct architecture
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found msvcr100.dll architecture" >&5
-$as_echo_n "checking found msvcr100.dll architecture... " >&6; }
-    MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found $DLL_NAME architecture" >&5
+$as_echo_n "checking found $DLL_NAME architecture... " >&6; }
+    MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
       # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
       # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
@@ -49933,39 +49986,40 @@
         CORRECT_MSVCR_ARCH=x86-64
       fi
     fi
-    if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
+    if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
 $as_echo "ok" >&6; }
-      MSVCR_DLL="$POSSIBLE_MSVCR_DLL"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for msvcr100.dll" >&5
-$as_echo_n "checking for msvcr100.dll... " >&6; }
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVCR_DLL" >&5
-$as_echo "$MSVCR_DLL" >&6; }
+      MSVC_DLL="$POSSIBLE_MSVC_DLL"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $DLL_NAME" >&5
+$as_echo_n "checking for $DLL_NAME... " >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVC_DLL" >&5
+$as_echo "$MSVC_DLL" >&6; }
     else
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: incorrect, ignoring" >&5
 $as_echo "incorrect, ignoring" >&6; }
-      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE" >&5
-$as_echo "$as_me: The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE" >&6;}
-    fi
-  fi
-
-    fi
-  fi
-
-  if test "x$MSVCR_DLL" = x; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&5
+$as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&6;}
+    fi
+  fi
+
+    fi
+  fi
+
+  if test "x$MSVC_DLL" = x; then
     # Probe: Check in the Boot JDK directory.
-    POSSIBLE_MSVCR_DLL="$BOOT_JDK/bin/msvcr100.dll"
-
-  POSSIBLE_MSVCR_DLL="$POSSIBLE_MSVCR_DLL"
+    POSSIBLE_MSVC_DLL="$BOOT_JDK/bin/$DLL_NAME"
+
+  DLL_NAME="$DLL_NAME"
+  POSSIBLE_MSVC_DLL="$POSSIBLE_MSVC_DLL"
   METHOD="well-known location in Boot JDK"
-  if test -e "$POSSIBLE_MSVCR_DLL"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&5
-$as_echo "$as_me: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&6;}
+  if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&5
+$as_echo "$as_me: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&6;}
 
     # Need to check if the found msvcr is correct architecture
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found msvcr100.dll architecture" >&5
-$as_echo_n "checking found msvcr100.dll architecture... " >&6; }
-    MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found $DLL_NAME architecture" >&5
+$as_echo_n "checking found $DLL_NAME architecture... " >&6; }
+    MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
       # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
       # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
@@ -49981,25 +50035,25 @@
         CORRECT_MSVCR_ARCH=x86-64
       fi
     fi
-    if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
+    if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
 $as_echo "ok" >&6; }
-      MSVCR_DLL="$POSSIBLE_MSVCR_DLL"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for msvcr100.dll" >&5
-$as_echo_n "checking for msvcr100.dll... " >&6; }
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVCR_DLL" >&5
-$as_echo "$MSVCR_DLL" >&6; }
+      MSVC_DLL="$POSSIBLE_MSVC_DLL"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $DLL_NAME" >&5
+$as_echo_n "checking for $DLL_NAME... " >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVC_DLL" >&5
+$as_echo "$MSVC_DLL" >&6; }
     else
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: incorrect, ignoring" >&5
 $as_echo "incorrect, ignoring" >&6; }
-      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE" >&5
-$as_echo "$as_me: The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE" >&6;}
-    fi
-  fi
-
-  fi
-
-  if test "x$MSVCR_DLL" = x; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&5
+$as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&6;}
+    fi
+  fi
+
+  fi
+
+  if test "x$MSVC_DLL" = x; then
     # Probe: Look in the Windows system32 directory
     CYGWIN_SYSTEMROOT="$SYSTEMROOT"
 
@@ -50012,18 +50066,19 @@
     CYGWIN_SYSTEMROOT="$unix_path"
   fi
 
-    POSSIBLE_MSVCR_DLL="$CYGWIN_SYSTEMROOT/system32/msvcr100.dll"
-
-  POSSIBLE_MSVCR_DLL="$POSSIBLE_MSVCR_DLL"
+    POSSIBLE_MSVC_DLL="$CYGWIN_SYSTEMROOT/system32/$DLL_NAME"
+
+  DLL_NAME="$DLL_NAME"
+  POSSIBLE_MSVC_DLL="$POSSIBLE_MSVC_DLL"
   METHOD="well-known location in SYSTEMROOT"
-  if test -e "$POSSIBLE_MSVCR_DLL"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&5
-$as_echo "$as_me: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&6;}
+  if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&5
+$as_echo "$as_me: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&6;}
 
     # Need to check if the found msvcr is correct architecture
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found msvcr100.dll architecture" >&5
-$as_echo_n "checking found msvcr100.dll architecture... " >&6; }
-    MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found $DLL_NAME architecture" >&5
+$as_echo_n "checking found $DLL_NAME architecture... " >&6; }
+    MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
       # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
       # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
@@ -50039,25 +50094,25 @@
         CORRECT_MSVCR_ARCH=x86-64
       fi
     fi
-    if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
+    if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
 $as_echo "ok" >&6; }
-      MSVCR_DLL="$POSSIBLE_MSVCR_DLL"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for msvcr100.dll" >&5
-$as_echo_n "checking for msvcr100.dll... " >&6; }
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVCR_DLL" >&5
-$as_echo "$MSVCR_DLL" >&6; }
+      MSVC_DLL="$POSSIBLE_MSVC_DLL"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $DLL_NAME" >&5
+$as_echo_n "checking for $DLL_NAME... " >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVC_DLL" >&5
+$as_echo "$MSVC_DLL" >&6; }
     else
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: incorrect, ignoring" >&5
 $as_echo "incorrect, ignoring" >&6; }
-      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE" >&5
-$as_echo "$as_me: The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE" >&6;}
-    fi
-  fi
-
-  fi
-
-  if test "x$MSVCR_DLL" = x; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&5
+$as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&6;}
+    fi
+  fi
+
+  fi
+
+  if test "x$MSVC_DLL" = x; then
     # Probe: If Visual Studio Express is installed, there is usually one with the debugger
     if test "x$VS100COMNTOOLS" != x; then
       CYGWIN_VS_TOOLS_DIR="$VS100COMNTOOLS/.."
@@ -50072,21 +50127,24 @@
   fi
 
       if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-        POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name msvcr100.dll | $GREP -i /x64/ | $HEAD --lines 1`
-      else
-        POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name msvcr100.dll | $GREP -i /x86/ | $HEAD --lines 1`
-      fi
-
-  POSSIBLE_MSVCR_DLL="$POSSIBLE_MSVCR_DLL"
+        POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
+	    | $GREP -i /x64/ | $HEAD --lines 1`
+      else
+        POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
+	    | $GREP -i /x86/ | $HEAD --lines 1`
+      fi
+
+  DLL_NAME="$DLL_NAME"
+  POSSIBLE_MSVC_DLL="$POSSIBLE_MSVC_DLL"
   METHOD="search of VS100COMNTOOLS"
-  if test -e "$POSSIBLE_MSVCR_DLL"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&5
-$as_echo "$as_me: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&6;}
+  if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&5
+$as_echo "$as_me: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&6;}
 
     # Need to check if the found msvcr is correct architecture
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found msvcr100.dll architecture" >&5
-$as_echo_n "checking found msvcr100.dll architecture... " >&6; }
-    MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found $DLL_NAME architecture" >&5
+$as_echo_n "checking found $DLL_NAME architecture... " >&6; }
+    MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
       # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
       # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
@@ -50102,50 +50160,54 @@
         CORRECT_MSVCR_ARCH=x86-64
       fi
     fi
-    if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
+    if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
 $as_echo "ok" >&6; }
-      MSVCR_DLL="$POSSIBLE_MSVCR_DLL"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for msvcr100.dll" >&5
-$as_echo_n "checking for msvcr100.dll... " >&6; }
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVCR_DLL" >&5
-$as_echo "$MSVCR_DLL" >&6; }
+      MSVC_DLL="$POSSIBLE_MSVC_DLL"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $DLL_NAME" >&5
+$as_echo_n "checking for $DLL_NAME... " >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVC_DLL" >&5
+$as_echo "$MSVC_DLL" >&6; }
     else
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: incorrect, ignoring" >&5
 $as_echo "incorrect, ignoring" >&6; }
-      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE" >&5
-$as_echo "$as_me: The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE" >&6;}
-    fi
-  fi
-
-    fi
-  fi
-
-  if test "x$MSVCR_DLL" = x; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&5
+$as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&6;}
+    fi
+  fi
+
+    fi
+  fi
+
+  if test "x$MSVC_DLL" = x; then
     # Probe: Search wildly in the VCINSTALLDIR. We've probably lost by now.
-    # (This was the original behaviour; kept since it might turn up something)
+    # (This was the original behaviour; kept since it might turn something up)
     if test "x$CYGWIN_VC_INSTALL_DIR" != x; then
       if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-        POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name msvcr100.dll | $GREP x64 | $HEAD --lines 1`
-      else
-        POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name msvcr100.dll | $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $HEAD --lines 1`
-        if test "x$POSSIBLE_MSVCR_DLL" = x; then
+        POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
+	    | $GREP x64 | $HEAD --lines 1`
+      else
+        POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
+	    | $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $HEAD --lines 1`
+        if test "x$POSSIBLE_MSVC_DLL" = x; then
           # We're grasping at straws now...
-          POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name msvcr100.dll | $HEAD --lines 1`
-        fi
-      fi
-
-
-  POSSIBLE_MSVCR_DLL="$POSSIBLE_MSVCR_DLL"
+          POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
+	      | $HEAD --lines 1`
+        fi
+      fi
+
+
+  DLL_NAME="$DLL_NAME"
+  POSSIBLE_MSVC_DLL="$POSSIBLE_MSVC_DLL"
   METHOD="search of VCINSTALLDIR"
-  if test -e "$POSSIBLE_MSVCR_DLL"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&5
-$as_echo "$as_me: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&6;}
+  if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&5
+$as_echo "$as_me: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&6;}
 
     # Need to check if the found msvcr is correct architecture
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found msvcr100.dll architecture" >&5
-$as_echo_n "checking found msvcr100.dll architecture... " >&6; }
-    MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found $DLL_NAME architecture" >&5
+$as_echo_n "checking found $DLL_NAME architecture... " >&6; }
+    MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
       # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
       # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
@@ -50161,33 +50223,34 @@
         CORRECT_MSVCR_ARCH=x86-64
       fi
     fi
-    if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
+    if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
 $as_echo "ok" >&6; }
-      MSVCR_DLL="$POSSIBLE_MSVCR_DLL"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for msvcr100.dll" >&5
-$as_echo_n "checking for msvcr100.dll... " >&6; }
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVCR_DLL" >&5
-$as_echo "$MSVCR_DLL" >&6; }
+      MSVC_DLL="$POSSIBLE_MSVC_DLL"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $DLL_NAME" >&5
+$as_echo_n "checking for $DLL_NAME... " >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVC_DLL" >&5
+$as_echo "$MSVC_DLL" >&6; }
     else
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: incorrect, ignoring" >&5
 $as_echo "incorrect, ignoring" >&6; }
-      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE" >&5
-$as_echo "$as_me: The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE" >&6;}
-    fi
-  fi
-
-    fi
-  fi
-
-  if test "x$MSVCR_DLL" = x; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for msvcr100.dll" >&5
-$as_echo_n "checking for msvcr100.dll... " >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&5
+$as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&6;}
+    fi
+  fi
+
+    fi
+  fi
+
+  if test "x$MSVC_DLL" = x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $DLL_NAME" >&5
+$as_echo_n "checking for $DLL_NAME... " >&6; }
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-    as_fn_error $? "Could not find msvcr100.dll. Please specify using --with-msvcr-dll." "$LINENO" 5
-  fi
-
+    as_fn_error $? "Could not find $DLL_NAME. Please specify using --with-msvcr-dll." "$LINENO" 5
+  fi
+
+  MSVCR_DLL=$MSVC_DLL
 
   if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
 
@@ -50310,6 +50373,512 @@
     MSVCR_DLL="`cd "$path"; $THEPWDCMD -L`"
   fi
 
+  MSVCR_DLL=$MSVCR_DLL
+
+
+  fi
+
+
+# Check whether --with-msvcp-dll was given.
+if test "${with_msvcp_dll+set}" = set; then :
+  withval=$with_msvcp_dll;
+fi
+
+
+  if test "x$MSVCP_NAME" != "x"; then
+    if test "x$with_msvcp_dll" != x; then
+      # If given explicitely by user, do not probe. If not present, fail directly.
+
+  DLL_NAME="$DLL_NAME"
+  POSSIBLE_MSVC_DLL="$with_msvcp_dll"
+  METHOD="--with-msvcp-dll"
+  if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&5
+$as_echo "$as_me: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&6;}
+
+    # Need to check if the found msvcr is correct architecture
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found $DLL_NAME architecture" >&5
+$as_echo_n "checking found $DLL_NAME architecture... " >&6; }
+    MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+      # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
+      # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+        CORRECT_MSVCR_ARCH="PE32 executable"
+      else
+        CORRECT_MSVCR_ARCH="PE32+ executable"
+      fi
+    else
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+        CORRECT_MSVCR_ARCH=386
+      else
+        CORRECT_MSVCR_ARCH=x86-64
+      fi
+    fi
+    if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+      MSVC_DLL="$POSSIBLE_MSVC_DLL"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $DLL_NAME" >&5
+$as_echo_n "checking for $DLL_NAME... " >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVC_DLL" >&5
+$as_echo "$MSVC_DLL" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: incorrect, ignoring" >&5
+$as_echo "incorrect, ignoring" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&5
+$as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&6;}
+    fi
+  fi
+
+      if test "x$MSVC_DLL" = x; then
+        as_fn_error $? "Could not find a proper $MSVCP_NAME as specified by --with-msvcp-dll" "$LINENO" 5
+      fi
+    else
+
+  VAR_NAME="MSVCP_DLL"
+  DLL_NAME="${MSVCP_NAME}"
+  MSVC_DLL=
+
+  if test "x$MSVC_DLL" = x; then
+    # Probe: Using well-known location from Visual Studio 10.0
+    if test "x$VCINSTALLDIR" != x; then
+      CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR"
+
+  windows_path="$CYGWIN_VC_INSTALL_DIR"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    CYGWIN_VC_INSTALL_DIR="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    CYGWIN_VC_INSTALL_DIR="$unix_path"
+  fi
+
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
+        POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
+      else
+        POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
+      fi
+      $ECHO "POSSIBLE_MSVC_DLL $POSSIBLEMSVC_DLL"
+
+  DLL_NAME="$DLL_NAME"
+  POSSIBLE_MSVC_DLL="$POSSIBLE_MSVC_DLL"
+  METHOD="well-known location in VCINSTALLDIR"
+  if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&5
+$as_echo "$as_me: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&6;}
+
+    # Need to check if the found msvcr is correct architecture
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found $DLL_NAME architecture" >&5
+$as_echo_n "checking found $DLL_NAME architecture... " >&6; }
+    MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+      # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
+      # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+        CORRECT_MSVCR_ARCH="PE32 executable"
+      else
+        CORRECT_MSVCR_ARCH="PE32+ executable"
+      fi
+    else
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+        CORRECT_MSVCR_ARCH=386
+      else
+        CORRECT_MSVCR_ARCH=x86-64
+      fi
+    fi
+    if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+      MSVC_DLL="$POSSIBLE_MSVC_DLL"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $DLL_NAME" >&5
+$as_echo_n "checking for $DLL_NAME... " >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVC_DLL" >&5
+$as_echo "$MSVC_DLL" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: incorrect, ignoring" >&5
+$as_echo "incorrect, ignoring" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&5
+$as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&6;}
+    fi
+  fi
+
+    fi
+  fi
+
+  if test "x$MSVC_DLL" = x; then
+    # Probe: Check in the Boot JDK directory.
+    POSSIBLE_MSVC_DLL="$BOOT_JDK/bin/$DLL_NAME"
+
+  DLL_NAME="$DLL_NAME"
+  POSSIBLE_MSVC_DLL="$POSSIBLE_MSVC_DLL"
+  METHOD="well-known location in Boot JDK"
+  if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&5
+$as_echo "$as_me: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&6;}
+
+    # Need to check if the found msvcr is correct architecture
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found $DLL_NAME architecture" >&5
+$as_echo_n "checking found $DLL_NAME architecture... " >&6; }
+    MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+      # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
+      # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+        CORRECT_MSVCR_ARCH="PE32 executable"
+      else
+        CORRECT_MSVCR_ARCH="PE32+ executable"
+      fi
+    else
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+        CORRECT_MSVCR_ARCH=386
+      else
+        CORRECT_MSVCR_ARCH=x86-64
+      fi
+    fi
+    if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+      MSVC_DLL="$POSSIBLE_MSVC_DLL"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $DLL_NAME" >&5
+$as_echo_n "checking for $DLL_NAME... " >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVC_DLL" >&5
+$as_echo "$MSVC_DLL" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: incorrect, ignoring" >&5
+$as_echo "incorrect, ignoring" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&5
+$as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&6;}
+    fi
+  fi
+
+  fi
+
+  if test "x$MSVC_DLL" = x; then
+    # Probe: Look in the Windows system32 directory
+    CYGWIN_SYSTEMROOT="$SYSTEMROOT"
+
+  windows_path="$CYGWIN_SYSTEMROOT"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    CYGWIN_SYSTEMROOT="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    CYGWIN_SYSTEMROOT="$unix_path"
+  fi
+
+    POSSIBLE_MSVC_DLL="$CYGWIN_SYSTEMROOT/system32/$DLL_NAME"
+
+  DLL_NAME="$DLL_NAME"
+  POSSIBLE_MSVC_DLL="$POSSIBLE_MSVC_DLL"
+  METHOD="well-known location in SYSTEMROOT"
+  if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&5
+$as_echo "$as_me: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&6;}
+
+    # Need to check if the found msvcr is correct architecture
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found $DLL_NAME architecture" >&5
+$as_echo_n "checking found $DLL_NAME architecture... " >&6; }
+    MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+      # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
+      # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+        CORRECT_MSVCR_ARCH="PE32 executable"
+      else
+        CORRECT_MSVCR_ARCH="PE32+ executable"
+      fi
+    else
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+        CORRECT_MSVCR_ARCH=386
+      else
+        CORRECT_MSVCR_ARCH=x86-64
+      fi
+    fi
+    if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+      MSVC_DLL="$POSSIBLE_MSVC_DLL"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $DLL_NAME" >&5
+$as_echo_n "checking for $DLL_NAME... " >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVC_DLL" >&5
+$as_echo "$MSVC_DLL" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: incorrect, ignoring" >&5
+$as_echo "incorrect, ignoring" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&5
+$as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&6;}
+    fi
+  fi
+
+  fi
+
+  if test "x$MSVC_DLL" = x; then
+    # Probe: If Visual Studio Express is installed, there is usually one with the debugger
+    if test "x$VS100COMNTOOLS" != x; then
+      CYGWIN_VS_TOOLS_DIR="$VS100COMNTOOLS/.."
+
+  windows_path="$CYGWIN_VS_TOOLS_DIR"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    CYGWIN_VS_TOOLS_DIR="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    CYGWIN_VS_TOOLS_DIR="$unix_path"
+  fi
+
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
+        POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
+	    | $GREP -i /x64/ | $HEAD --lines 1`
+      else
+        POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
+	    | $GREP -i /x86/ | $HEAD --lines 1`
+      fi
+
+  DLL_NAME="$DLL_NAME"
+  POSSIBLE_MSVC_DLL="$POSSIBLE_MSVC_DLL"
+  METHOD="search of VS100COMNTOOLS"
+  if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&5
+$as_echo "$as_me: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&6;}
+
+    # Need to check if the found msvcr is correct architecture
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found $DLL_NAME architecture" >&5
+$as_echo_n "checking found $DLL_NAME architecture... " >&6; }
+    MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+      # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
+      # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+        CORRECT_MSVCR_ARCH="PE32 executable"
+      else
+        CORRECT_MSVCR_ARCH="PE32+ executable"
+      fi
+    else
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+        CORRECT_MSVCR_ARCH=386
+      else
+        CORRECT_MSVCR_ARCH=x86-64
+      fi
+    fi
+    if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+      MSVC_DLL="$POSSIBLE_MSVC_DLL"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $DLL_NAME" >&5
+$as_echo_n "checking for $DLL_NAME... " >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVC_DLL" >&5
+$as_echo "$MSVC_DLL" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: incorrect, ignoring" >&5
+$as_echo "incorrect, ignoring" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&5
+$as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&6;}
+    fi
+  fi
+
+    fi
+  fi
+
+  if test "x$MSVC_DLL" = x; then
+    # Probe: Search wildly in the VCINSTALLDIR. We've probably lost by now.
+    # (This was the original behaviour; kept since it might turn something up)
+    if test "x$CYGWIN_VC_INSTALL_DIR" != x; then
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
+        POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
+	    | $GREP x64 | $HEAD --lines 1`
+      else
+        POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
+	    | $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $HEAD --lines 1`
+        if test "x$POSSIBLE_MSVC_DLL" = x; then
+          # We're grasping at straws now...
+          POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
+	      | $HEAD --lines 1`
+        fi
+      fi
+
+
+  DLL_NAME="$DLL_NAME"
+  POSSIBLE_MSVC_DLL="$POSSIBLE_MSVC_DLL"
+  METHOD="search of VCINSTALLDIR"
+  if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&5
+$as_echo "$as_me: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&6;}
+
+    # Need to check if the found msvcr is correct architecture
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking found $DLL_NAME architecture" >&5
+$as_echo_n "checking found $DLL_NAME architecture... " >&6; }
+    MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+      # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
+      # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+        CORRECT_MSVCR_ARCH="PE32 executable"
+      else
+        CORRECT_MSVCR_ARCH="PE32+ executable"
+      fi
+    else
+      if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+        CORRECT_MSVCR_ARCH=386
+      else
+        CORRECT_MSVCR_ARCH=x86-64
+      fi
+    fi
+    if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+      MSVC_DLL="$POSSIBLE_MSVC_DLL"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $DLL_NAME" >&5
+$as_echo_n "checking for $DLL_NAME... " >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSVC_DLL" >&5
+$as_echo "$MSVC_DLL" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: incorrect, ignoring" >&5
+$as_echo "incorrect, ignoring" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&5
+$as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" >&6;}
+    fi
+  fi
+
+    fi
+  fi
+
+  if test "x$MSVC_DLL" = x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $DLL_NAME" >&5
+$as_echo_n "checking for $DLL_NAME... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    as_fn_error $? "Could not find $DLL_NAME. Please specify using --with-msvcr-dll." "$LINENO" 5
+  fi
+
+  MSVCP_DLL=$MSVC_DLL
+
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+  # Input might be given as Windows format, start by converting to
+  # unix format.
+  path="$MSVCP_DLL"
+  new_path=`$CYGPATH -u "$path"`
+
+  # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
+  # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
+  # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
+  # "foo.exe" is OK but "foo" is an error.
+  #
+  # This test is therefore slightly more accurate than "test -f" to check for file precense.
+  # It is also a way to make sure we got the proper file name for the real test later on.
+  test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
+  if test "x$test_shortpath" = x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: The path of MSVCP_DLL, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of MSVCP_DLL, which resolves as \"$path\", is invalid." >&6;}
+    as_fn_error $? "Cannot locate the the path of MSVCP_DLL" "$LINENO" 5
+  fi
+
+  # Call helper function which possibly converts this using DOS-style short mode.
+  # If so, the updated path is stored in $new_path.
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+    path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+    if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+      # Going to short mode and back again did indeed matter. Since short mode is
+      # case insensitive, let's make it lowercase to improve readability.
+      shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+      # Now convert it back to Unix-stile (cygpath)
+      input_path=`$CYGPATH -u "$shortmode_path"`
+      new_path="$input_path"
+    fi
+  fi
+
+  test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+  if test "x$test_cygdrive_prefix" = x; then
+    # As a simple fix, exclude /usr/bin since it's not a real path.
+    if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
+      # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+      # a path prefixed by /cygdrive for fixpath to work.
+      new_path="$CYGWIN_ROOT_PATH$input_path"
+    fi
+  fi
+
+
+  if test "x$path" != "x$new_path"; then
+    MSVCP_DLL="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting MSVCP_DLL to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting MSVCP_DLL to \"$new_path\"" >&6;}
+  fi
+
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+  path="$MSVCP_DLL"
+  has_colon=`$ECHO $path | $GREP ^.:`
+  new_path="$path"
+  if test "x$has_colon" = x; then
+    # Not in mixed or Windows style, start by that.
+    new_path=`cmd //c echo $path`
+  fi
+
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+  fi
+
+
+  windows_path="$new_path"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    new_path="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    new_path="$unix_path"
+  fi
+
+  if test "x$path" != "x$new_path"; then
+    MSVCP_DLL="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting MSVCP_DLL to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting MSVCP_DLL to \"$new_path\"" >&6;}
+  fi
+
+  # Save the first 10 bytes of this path to the storage, so fixpath can work.
+  all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
+
+  else
+    # We're on a unix platform. Hooray! :)
+    path="$MSVCP_DLL"
+    has_space=`$ECHO "$path" | $GREP " "`
+    if test "x$has_space" != x; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: The path of MSVCP_DLL, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of MSVCP_DLL, which resolves as \"$path\", is invalid." >&6;}
+      as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
+    fi
+
+    # Use eval to expand a potential ~
+    eval path="$path"
+    if test ! -f "$path" && test ! -d "$path"; then
+      as_fn_error $? "The path of MSVCP_DLL, which resolves as \"$path\", is not found." "$LINENO" 5
+    fi
+
+    MSVCP_DLL="`cd "$path"; $THEPWDCMD -L`"
+  fi
+
+  MSVCP_DLL=$MSVCP_DLL
+
+
+    fi
+  fi
 
 
 
@@ -50341,7 +50910,6 @@
   fi
 
 
-
 ###############################################################################
 #
 # We need to do some final tweaking, when everything else is done.
@@ -52470,7 +53038,10 @@
     printf "* Environment:    $WINDOWS_ENV_VENDOR version $WINDOWS_ENV_VERSION (root at $WINDOWS_ENV_ROOT_PATH)\n"
   fi
   printf "* Boot JDK:       $BOOT_JDK_VERSION (at $BOOT_JDK)\n"
-  printf "* Toolchain:      $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)\n"
+  if test "x$TOOLCHAIN_VERSION" != "x"; then
+    print_version=" $TOOLCHAIN_VERSION"
+  fi
+  printf "* Toolchain:      $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION$print_version)\n"
   printf "* C Compiler:     Version $CC_VERSION_NUMBER (at $CC)\n"
   printf "* C++ Compiler:   Version $CXX_VERSION_NUMBER (at $CXX)\n"
 
--- a/common/autoconf/help.m4	Thu Feb 19 11:24:01 2015 -0800
+++ b/common/autoconf/help.m4	Wed Jul 05 20:21:01 2017 +0200
@@ -209,7 +209,10 @@
     printf "* Environment:    $WINDOWS_ENV_VENDOR version $WINDOWS_ENV_VERSION (root at $WINDOWS_ENV_ROOT_PATH)\n"
   fi
   printf "* Boot JDK:       $BOOT_JDK_VERSION (at $BOOT_JDK)\n"
-  printf "* Toolchain:      $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)\n"
+  if test "x$TOOLCHAIN_VERSION" != "x"; then
+    print_version=" $TOOLCHAIN_VERSION"
+  fi
+  printf "* Toolchain:      $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION$print_version)\n" 
   printf "* C Compiler:     Version $CC_VERSION_NUMBER (at $CC)\n"
   printf "* C++ Compiler:   Version $CXX_VERSION_NUMBER (at $CXX)\n"
 
--- a/common/autoconf/libraries.m4	Thu Feb 19 11:24:01 2015 -0800
+++ b/common/autoconf/libraries.m4	Wed Jul 05 20:21:01 2017 +0200
@@ -1124,10 +1124,9 @@
 AC_DEFUN_ONCE([LIB_SETUP_ON_WINDOWS],
 [
   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
-    TOOLCHAIN_SETUP_MSVCR_DLL
+    TOOLCHAIN_SETUP_VS_RUNTIME_DLLS
     BASIC_DEPRECATED_ARG_WITH([dxsdk])
     BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
     BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
   fi
-  AC_SUBST(MSVCR_DLL)
 ])
--- a/common/autoconf/spec.gmk.in	Thu Feb 19 11:24:01 2015 -0800
+++ b/common/autoconf/spec.gmk.in	Wed Jul 05 20:21:01 2017 +0200
@@ -583,6 +583,7 @@
 USE_EXTERNAL_LIBZ:=@USE_EXTERNAL_LIBZ@
 LIBZIP_CAN_USE_MMAP:=@LIBZIP_CAN_USE_MMAP@
 MSVCR_DLL:=@MSVCR_DLL@
+MSVCP_DLL:=@MSVCP_DLL@
 
 
 # ADD_SRCS takes a single argument with source roots
--- a/common/autoconf/toolchain.m4	Thu Feb 19 11:24:01 2015 -0800
+++ b/common/autoconf/toolchain.m4	Wed Jul 05 20:21:01 2017 +0200
@@ -691,8 +691,8 @@
     CC_VERSION_OUTPUT=`$CC 2>&1 | $HEAD -n 1 | $TR -d '\r'`
     COMPILER_CPU_TEST=`$ECHO $CC_VERSION_OUTPUT | $SED -n "s/^.* \(.*\)$/\1/p"`
     if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
-      if test "x$COMPILER_CPU_TEST" != "x80x86"; then
-        AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86".])
+      if test "x$COMPILER_CPU_TEST" != "x80x86" -a "x$COMPILER_CPU_TEST" != "xx86"; then
+        AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86" or "x86".])
       fi
     elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
       if test "x$COMPILER_CPU_TEST" != "xx64"; then
--- a/common/autoconf/toolchain_windows.m4	Thu Feb 19 11:24:01 2015 -0800
+++ b/common/autoconf/toolchain_windows.m4	Wed Jul 05 20:21:01 2017 +0200
@@ -23,43 +23,90 @@
 # questions.
 #
 
+################################################################################
+
+VALID_VS_VERSIONS="2010 2012 2013"
+
+VS_DESCRIPTION_2010="Microsoft Visual Studio 2010"
+VS_VERSION_INTERNAL_2010=100
+VS_MSVCR_2010=msvcr100.dll
+# We don't use msvcp on Visual Studio 2010
+#VS_MSVCP_2010=msvcp100.dll
+VS_ENVVAR_2010="VS100COMNTOOLS"
+VS_VS_INSTALLDIR_2010="Microsoft Visual Studio 10.0"
+VS_SDK_INSTALLDIR_2010="Microsoft SDKs/Windows/v7.1"
+VS_VS_PLATFORM_NAME_2010="v100"
+VS_SDK_PLATFORM_NAME_2010="Windows7.1SDK"
+
+VS_DESCRIPTION_2012="Microsoft Visual Studio 2012"
+VS_VERSION_INTERNAL_2012=110
+VS_MSVCR_2012=msvcr110.dll
+VS_MSVCP_2012=msvcp110.dll
+VS_ENVVAR_2012="VS110COMNTOOLS"
+VS_VS_INSTALLDIR_2012="Microsoft Visual Studio 11.0"
+VS_SDK_INSTALLDIR_2012=
+VS_VS_PLATFORM_NAME_2012="v110"
+VS_SDK_PLATFORM_NAME_2012=
+
+VS_DESCRIPTION_2013="Microsoft Visual Studio 2013"
+VS_VERSION_INTERNAL_2013=120
+VS_MSVCR_2013=msvcr120.dll
+VS_MSVCP_2013=msvcp120.dll
+VS_ENVVAR_2013="VS120COMNTOOLS"
+VS_VS_INSTALLDIR_2013="Microsoft Visual Studio 12.0"
+VS_SDK_INSTALLDIR_2013=
+VS_VS_PLATFORM_NAME_2013="v120"
+VS_SDK_PLATFORM_NAME_2013=
+
+################################################################################
+
 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT],
 [
   if test "x$VS_ENV_CMD" = x; then
-    VS100BASE="$1"
-    METHOD="$2"
-    BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VS100BASE)
-    if test -d "$VS100BASE"; then
-      if test -f "$VS100BASE/$VCVARSFILE"; then
-        AC_MSG_NOTICE([Found Visual Studio installation at $VS100BASE using $METHOD])
-        VS_ENV_CMD="$VS100BASE/$VCVARSFILE"
+    VS_VERSION="$1"
+    VS_BASE="$2"
+    METHOD="$3"
+
+    if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
+      VCVARSFILE="vc/bin/vcvars32.bat"
+    else
+      VCVARSFILE="vc/bin/amd64/vcvars64.bat"
+    fi
+  
+    BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VS_BASE)
+    if test -d "$VS_BASE"; then
+      if test -f "$VS_BASE/$VCVARSFILE"; then
+        AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD])
+        VS_ENV_CMD="$VS_BASE/$VCVARSFILE"
         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013
-        # TODO: improve detection for other versions of VS
-        PLATFORM_TOOLSET="v100"
+        eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
       else
-        AC_MSG_NOTICE([Found Visual Studio installation at $VS100BASE using $METHOD])
+        AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD])
         AC_MSG_NOTICE([Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring])
       fi
     fi
   fi
 ])
 
+################################################################################
+
 AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT],
 [
   if test "x$VS_ENV_CMD" = x; then
-    WIN_SDK_BASE="$1"
-    METHOD="$2"
+    VS_VERSION="$1"
+    WIN_SDK_BASE="$2"
+    METHOD="$3"
     BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(WIN_SDK_BASE)
     if test -d "$WIN_SDK_BASE"; then
       # There have been cases of partial or broken SDK installations. A missing
       # lib dir is not going to work.
-      if test ! -d "$WIN_SDK_BASE/../lib"; then
+      if test ! -d "$WIN_SDK_BASE/lib"; then
         AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
         AC_MSG_NOTICE([Warning: Installation is broken, lib dir is missing. Ignoring])
-      elif test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then
+      elif test -f "$WIN_SDK_BASE/Bin/SetEnv.Cmd"; then
         AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
-        VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd"
+        VS_ENV_CMD="$WIN_SDK_BASE/Bin/SetEnv.Cmd"
         if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
           VS_ENV_ARGS="/x86"
         else
@@ -68,7 +115,7 @@
         # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
         # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK
         # TODO: improve detection for other versions of SDK
-        PLATFORM_TOOLSET="Windows7.1SDK"
+        eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}"
       else
         AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
         AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring])
@@ -77,50 +124,121 @@
   fi
 ])
 
+################################################################################
+# Finds the bat or cmd file in Visual Studio or the SDK that sets up a proper
+# build environment and assigns it to VS_ENV_CMD
 AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE],
 [
-  if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
-    VCVARSFILE="vc/bin/vcvars32.bat"
-  else
-    VCVARSFILE="vc/bin/amd64/vcvars64.bat"
+  VS_VERSION="$1"
+  eval VS_COMNTOOLS_VAR="\${VS_ENVVAR_${VS_VERSION}}"
+  eval VS_COMNTOOLS="\$${VS_COMNTOOLS_VAR}"
+  eval VS_INSTALL_DIR="\${VS_VS_INSTALLDIR_${VS_VERSION}}"
+  eval SDK_INSTALL_DIR="\${VS_SDK_INSTALLDIR_${VS_VERSION}}"
+
+  # When using --with-tools-dir, assume it points to the correct and default
+  # version of Visual Studio or that --with-toolchain-version was also set.
+  if test "x$with_tools_dir" != x; then
+    TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
+        [$with_tools_dir/../..], [--with-tools-dir])
+    TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
+        [$with_tools_dir/../../..], [--with-tools-dir])
+    if test "x$VS_ENV_CMD" = x; then
+      # Having specified an argument which is incorrect will produce an instant failure;
+      # we should not go on looking
+      AC_MSG_NOTICE([The path given by --with-tools-dir does not contain a valid])
+      AC_MSG_NOTICE([Visual Studio installation. Please point to the VC/bin or VC/bin/amd64])
+      AC_MSG_NOTICE([directory within the Visual Studio installation])
+      AC_MSG_ERROR([Cannot locate a valid Visual Studio installation])
+    fi
   fi
 
   VS_ENV_CMD=""
   VS_ENV_ARGS=""
-  if test "x$with_toolsdir" != x; then
-    TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$with_toolsdir/../..], [--with-tools-dir])
+
+  if test "x$VS_COMNTOOLS" != x; then
+    TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
+        [$VS_COMNTOOLS/../..], [$VS_COMNTOOLS_VAR variable])
+  fi
+  if test "x$PROGRAMFILES" != x; then
+    TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
+        [$PROGRAMFILES/$VS_INSTALL_DIR], [well-known name])
+  fi
+  # Work around the insanely named ProgramFiles(x86) env variable
+  PROGRAMFILES_X86="`env | $SED -n 's/^ProgramFiles(x86)=//p'`"
+  if test "x$PROGRAMFILES_X86" != x; then
+    TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
+        [$PROGRAMFILES_X86/$VS_INSTALL_DIR], [well-known name])
+  fi
+  TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
+      [C:/Program Files/$VS_INSTALL_DIR], [well-known name])
+  TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
+      [C:/Program Files (x86)/$VS_INSTALL_DIR], [well-known name])
+
+  if test "x$SDK_INSTALL_DIR" != x; then
+    if test "x$ProgramW6432" != x; then
+      TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
+          [$ProgramW6432/$SDK_INSTALL_DIR], [well-known name])
+    fi
+    if test "x$PROGRAMW6432" != x; then
+      TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
+          [$PROGRAMW6432/$SDK_INSTALL_DIR], [well-known name])
+    fi
+    if test "x$PROGRAMFILES" != x; then
+      TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
+          [$PROGRAMFILES/$SDK_INSTALL_DIR], [well-known name])
+    fi
+    TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
+        [C:/Program Files/$SDK_INSTALL_DIR], [well-known name])
+    TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
+        [C:/Program Files (x86)/$SDK_INSTALL_DIR], [well-known name])
+  fi
+])
+
+################################################################################
+
+AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO],
+[
+  AC_ARG_WITH(toolchain-version, [AS_HELP_STRING([--with-toolchain-version],
+      [the version of the toolchain to look for, use '--help' to show possible values @<:@platform dependent@:>@])])
+
+  if test "x$with_toolchain_version" = xlist; then
+    # List all toolchains
+    AC_MSG_NOTICE([The following toolchain versions are valid on this platform:])
+    for version in $VALID_VS_VERSIONS; do
+      eval VS_DESCRIPTION=\${VS_DESCRIPTION_$version}
+      $PRINTF "  %-10s  %s\n" $version "$VS_DESCRIPTION"
+    done
+
+    exit 0
+  elif test "x$with_toolchain_version" != x; then
+    # User override; check that it is valid
+    if test "x${VALID_VS_VERSIONS/$with_toolchain_version/}" = "x${VALID_VS_VERSIONS}"; then
+      AC_MSG_NOTICE([Visual Studio version $with_toolchain_version is not valid.])
+      AC_MSG_NOTICE([Valid Visual Studio versions: $VALID_VS_VERSIONS.])
+      AC_MSG_ERROR([Cannot continue.])
+    fi
+    VS_VERSIONS_PROBE_LIST="$with_toolchain_version"
+  else
+    # No flag given, use default
+    VS_VERSIONS_PROBE_LIST="$VALID_VS_VERSIONS"
   fi
 
-  if test "x$with_toolsdir" != x && test "x$VS_ENV_CMD" = x; then
-    # Having specified an argument which is incorrect will produce an instant failure;
-    # we should not go on looking
-    AC_MSG_NOTICE([The path given by --with-tools-dir does not contain a valid Visual Studio installation])
-    AC_MSG_NOTICE([Please point to the VC/bin directory within the Visual Studio installation])
-    AC_MSG_ERROR([Cannot locate a valid Visual Studio installation])
-  fi
-
-  if test "x$VS100COMNTOOLS" != x; then
-    TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$VS100COMNTOOLS/../..], [VS100COMNTOOLS variable])
-  fi
-  if test "x$PROGRAMFILES" != x; then
-    TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$PROGRAMFILES/Microsoft Visual Studio 10.0], [well-known name])
-  fi
-  TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files/Microsoft Visual Studio 10.0], [well-known name])
-  TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files (x86)/Microsoft Visual Studio 10.0], [well-known name])
-
-  if test "x$ProgramW6432" != x; then
-    TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$ProgramW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
-  fi
-  if test "x$PROGRAMW6432" != x; then
-    TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$PROGRAMW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
-  fi
-  if test "x$PROGRAMFILES" != x; then
-    TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$PROGRAMFILES/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
-  fi
-  TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
-  TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
+  for VS_VERSION in $VS_VERSIONS_PROBE_LIST; do
+    TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE([$VS_VERSION])
+    if test "x$VS_ENV_CMD" != x; then
+      TOOLCHAIN_VERSION=$VS_VERSION
+      eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}"
+      eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}"
+      eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}"
+      eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}"
+      # The rest of the variables are already evaled while probing
+      AC_MSG_NOTICE([Found $VS_DESCRIPTION])
+      break
+    fi
+  done
 ])
 
+################################################################################
 # Check if the VS env variables were setup prior to running configure.
 # If not, then find vcvarsall.bat and run it automatically, and integrate
 # the set env variables into the spec file.
@@ -142,7 +260,8 @@
   fi
 
   # First-hand choice is to locate and run the vsvars bat file.
-  TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE
+  TOOLCHAIN_FIND_VISUAL_STUDIO
+
   if test "x$VS_ENV_CMD" != x; then
     # We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file.
     BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD)
@@ -262,16 +381,17 @@
   fi
 ])
 
-AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL],
+AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL],
 [
-  POSSIBLE_MSVCR_DLL="$1"
-  METHOD="$2"
-  if test -e "$POSSIBLE_MSVCR_DLL"; then
-    AC_MSG_NOTICE([Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD])
-
+  DLL_NAME="$1"
+  POSSIBLE_MSVC_DLL="$2"
+  METHOD="$3"
+  if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
+    AC_MSG_NOTICE([Found $1 at $POSSIBLE_MSVC_DLL using $METHOD])
+    
     # Need to check if the found msvcr is correct architecture
-    AC_MSG_CHECKING([found msvcr100.dll architecture])
-    MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"`
+    AC_MSG_CHECKING([found $1 architecture])
+    MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
       # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
       # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
@@ -287,96 +407,135 @@
         CORRECT_MSVCR_ARCH=x86-64
       fi
     fi
-    if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
+    if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
       AC_MSG_RESULT([ok])
-      MSVCR_DLL="$POSSIBLE_MSVCR_DLL"
-      AC_MSG_CHECKING([for msvcr100.dll])
-      AC_MSG_RESULT([$MSVCR_DLL])
+      MSVC_DLL="$POSSIBLE_MSVC_DLL"
+      AC_MSG_CHECKING([for $1])
+      AC_MSG_RESULT([$MSVC_DLL])
     else
       AC_MSG_RESULT([incorrect, ignoring])
-      AC_MSG_NOTICE([The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE])
+      AC_MSG_NOTICE([The file type of the located $1 is $MSVC_DLL_FILETYPE])
     fi
   fi
 ])
 
-AC_DEFUN([TOOLCHAIN_SETUP_MSVCR_DLL],
+AC_DEFUN([TOOLCHAIN_SETUP_MSVC_DLL],
 [
-  AC_ARG_WITH(msvcr-dll, [AS_HELP_STRING([--with-msvcr-dll],
-      [copy this msvcr100.dll into the built JDK (Windows only) @<:@probed@:>@])])
+  VAR_NAME="$1"
+  DLL_NAME="$2"
+  MSVC_DLL=
 
-  if test "x$with_msvcr_dll" != x; then
-    # If given explicitely by user, do not probe. If not present, fail directly.
-    TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$with_msvcr_dll], [--with-msvcr-dll])
-    if test "x$MSVCR_DLL" = x; then
-      AC_MSG_ERROR([Could not find a proper msvcr100.dll as specified by --with-msvcr-dll])
-    fi
-  fi
-
-  if test "x$MSVCR_DLL" = x; then
+  if test "x$MSVC_DLL" = x; then
     # Probe: Using well-known location from Visual Studio 10.0
     if test "x$VCINSTALLDIR" != x; then
       CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR"
       BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_VC_INSTALL_DIR)
       if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-        POSSIBLE_MSVCR_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC100.CRT/msvcr100.dll"
+        POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
       else
-        POSSIBLE_MSVCR_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC100.CRT/msvcr100.dll"
+        POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
       fi
-      TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [well-known location in VCINSTALLDIR])
+      $ECHO "POSSIBLE_MSVC_DLL $POSSIBLEMSVC_DLL"
+      TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
+          [well-known location in VCINSTALLDIR])
     fi
   fi
 
-  if test "x$MSVCR_DLL" = x; then
+  if test "x$MSVC_DLL" = x; then
     # Probe: Check in the Boot JDK directory.
-    POSSIBLE_MSVCR_DLL="$BOOT_JDK/bin/msvcr100.dll"
-    TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [well-known location in Boot JDK])
+    POSSIBLE_MSVC_DLL="$BOOT_JDK/bin/$DLL_NAME"
+    TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
+        [well-known location in Boot JDK])
+  fi
+  
+  if test "x$MSVC_DLL" = x; then
+    # Probe: Look in the Windows system32 directory 
+    CYGWIN_SYSTEMROOT="$SYSTEMROOT"
+    BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_SYSTEMROOT)
+    POSSIBLE_MSVC_DLL="$CYGWIN_SYSTEMROOT/system32/$DLL_NAME"
+    TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
+        [well-known location in SYSTEMROOT])
   fi
 
-  if test "x$MSVCR_DLL" = x; then
-    # Probe: Look in the Windows system32 directory
-    CYGWIN_SYSTEMROOT="$SYSTEMROOT"
-    BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_SYSTEMROOT)
-    POSSIBLE_MSVCR_DLL="$CYGWIN_SYSTEMROOT/system32/msvcr100.dll"
-    TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [well-known location in SYSTEMROOT])
-  fi
-
-  if test "x$MSVCR_DLL" = x; then
+  if test "x$MSVC_DLL" = x; then
     # Probe: If Visual Studio Express is installed, there is usually one with the debugger
     if test "x$VS100COMNTOOLS" != x; then
       CYGWIN_VS_TOOLS_DIR="$VS100COMNTOOLS/.."
       BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_VS_TOOLS_DIR)
       if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-        POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name msvcr100.dll | $GREP -i /x64/ | $HEAD --lines 1`
+        POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
+	    | $GREP -i /x64/ | $HEAD --lines 1`
       else
-        POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name msvcr100.dll | $GREP -i /x86/ | $HEAD --lines 1`
+        POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
+	    | $GREP -i /x86/ | $HEAD --lines 1`
       fi
-      TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [search of VS100COMNTOOLS])
+      TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
+          [search of VS100COMNTOOLS])
     fi
   fi
-
-  if test "x$MSVCR_DLL" = x; then
+      
+  if test "x$MSVC_DLL" = x; then
     # Probe: Search wildly in the VCINSTALLDIR. We've probably lost by now.
-    # (This was the original behaviour; kept since it might turn up something)
+    # (This was the original behaviour; kept since it might turn something up)
     if test "x$CYGWIN_VC_INSTALL_DIR" != x; then
       if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-        POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name msvcr100.dll | $GREP x64 | $HEAD --lines 1`
+        POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
+	    | $GREP x64 | $HEAD --lines 1`
       else
-        POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name msvcr100.dll | $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $HEAD --lines 1`
-        if test "x$POSSIBLE_MSVCR_DLL" = x; then
+        POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
+	    | $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $HEAD --lines 1`
+        if test "x$POSSIBLE_MSVC_DLL" = x; then
           # We're grasping at straws now...
-          POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name msvcr100.dll | $HEAD --lines 1`
+          POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
+	      | $HEAD --lines 1`
         fi
       fi
-
-      TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [search of VCINSTALLDIR])
+      
+      TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
+          [search of VCINSTALLDIR])
     fi
   fi
-
-  if test "x$MSVCR_DLL" = x; then
-    AC_MSG_CHECKING([for msvcr100.dll])
+  
+  if test "x$MSVC_DLL" = x; then
+    AC_MSG_CHECKING([for $DLL_NAME])
     AC_MSG_RESULT([no])
-    AC_MSG_ERROR([Could not find msvcr100.dll. Please specify using --with-msvcr-dll.])
+    AC_MSG_ERROR([Could not find $DLL_NAME. Please specify using --with-msvcr-dll.])
   fi
 
-  BASIC_FIXUP_PATH(MSVCR_DLL)
+  $1=$MSVC_DLL
+  BASIC_FIXUP_PATH($1)
+  AC_SUBST($1, [$]$1)
 ])
+
+AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS],
+[
+  AC_ARG_WITH(msvcr-dll, [AS_HELP_STRING([--with-msvcr-dll],
+      [path to microsoft C runtime dll (msvcr*.dll) (Windows only) @<:@probed@:>@])])
+
+  if test "x$with_msvcr_dll" != x; then
+    # If given explicitely by user, do not probe. If not present, fail directly.
+    TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$with_msvcr_dll],
+        [--with-msvcr-dll])
+    if test "x$MSVC_DLL" = x; then
+      AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by --with-msvcr-dll])
+    fi
+  else
+    TOOLCHAIN_SETUP_MSVC_DLL([MSVCR_DLL], [${MSVCR_NAME}])
+  fi
+
+  AC_ARG_WITH(msvcp-dll, [AS_HELP_STRING([--with-msvcp-dll],
+      [path to microsoft C++ runtime dll (msvcp*.dll) (Windows only) @<:@probed@:>@])])
+
+  if test "x$MSVCP_NAME" != "x"; then
+    if test "x$with_msvcp_dll" != x; then
+      # If given explicitely by user, do not probe. If not present, fail directly.
+      TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$with_msvcp_dll],
+          [--with-msvcp-dll])
+      if test "x$MSVC_DLL" = x; then
+        AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by --with-msvcp-dll])
+      fi
+    else
+      TOOLCHAIN_SETUP_MSVC_DLL([MSVCP_DLL], [${MSVCP_NAME}])
+    fi
+  fi
+])
--- a/common/bin/unshuffle_list.txt	Thu Feb 19 11:24:01 2015 -0800
+++ b/common/bin/unshuffle_list.txt	Wed Jul 05 20:21:01 2017 +0200
@@ -1303,6 +1303,7 @@
 jdk/src/jdk.dev/share/classes/com/sun/jarsigner : jdk/src/share/classes/com/sun/jarsigner
 jdk/src/jdk.dev/share/classes/com/sun/tools/hat : jdk/src/share/classes/com/sun/tools/hat
 jdk/src/jdk.dev/share/classes/sun/security/tools/jarsigner : jdk/src/share/classes/sun/security/tools/jarsigner
+jdk/src/jdk.dev/share/classes/sun/security/tools/policytool : jdk/src/share/classes/sun/security/tools/policytool
 jdk/src/jdk.dev/share/classes/sun/tools/jar : jdk/src/share/classes/sun/tools/jar
 jdk/src/jdk.dev/share/classes/sun/tools/native2ascii : jdk/src/share/classes/sun/tools/native2ascii
 jdk/src/jdk.hprof.agent/share/classes/com/sun/demo/jvmti/hprof : jdk/src/share/classes/com/sun/demo/jvmti/hprof
@@ -1443,7 +1444,6 @@
 jdk/src/jdk.rmic/share/classes/sun/tools/tree : jdk/src/share/classes/sun/tools/tree
 jdk/src/jdk.rmic/share/classes/sun/tools/util : jdk/src/share/classes/sun/tools/util
 jdk/src/jdk.runtime/share/classes/com/sun/tracing : jdk/src/share/classes/com/sun/tracing
-jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool : jdk/src/share/classes/sun/security/tools/policytool
 jdk/src/jdk.runtime/share/classes/sun/tracing : jdk/src/share/classes/sun/tracing
 jdk/src/jdk.runtime/share/native/common-unpack/bands.cpp : jdk/src/share/native/com/sun/java/util/jar/pack/bands.cpp
 jdk/src/jdk.runtime/share/native/common-unpack/bands.h : jdk/src/share/native/com/sun/java/util/jar/pack/bands.h
--- a/corba/.hgtags	Thu Feb 19 11:24:01 2015 -0800
+++ b/corba/.hgtags	Wed Jul 05 20:21:01 2017 +0200
@@ -293,3 +293,4 @@
 a13c49c5f2899b702652a460ed7aa73123e671e6 jdk9-b48
 9285d14eb7b6b0815679bae98dd936dbc136218d jdk9-b49
 224f593393e5b01b3c8f1e591b7f4b1790a3737a jdk9-b50
+2309c02386d1fa4ced5051873ffb9e04874f7a44 jdk9-b51
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/spi/orb/ORB.java	Thu Feb 19 11:24:01 2015 -0800
+++ b/corba/src/java.corba/share/classes/com/sun/corba/se/spi/orb/ORB.java	Wed Jul 05 20:21:01 2017 +0200
@@ -176,42 +176,9 @@
         staticWrapper = ORBUtilSystemException.get(
             CORBALogDomains.RPC_PRESENTATION ) ;
 
-        boolean useDynamicStub =
-            ((Boolean)AccessController.doPrivileged(
-                new PrivilegedAction() {
-                    public java.lang.Object run() {
-                        return Boolean.valueOf( Boolean.getBoolean (
-                            ORBConstants.USE_DYNAMIC_STUB_PROPERTY ) ) ;
-                    }
-                }
-            )).booleanValue() ;
+        boolean useDynamicStub = false;
 
-        PresentationManager.StubFactoryFactory dynamicStubFactoryFactory =
-            (PresentationManager.StubFactoryFactory)AccessController.doPrivileged(
-                new PrivilegedAction() {
-                    public java.lang.Object run() {
-                        PresentationManager.StubFactoryFactory sff =
-                            PresentationDefaults.getProxyStubFactoryFactory() ;
-
-                        String className = System.getProperty(
-                            ORBConstants.DYNAMIC_STUB_FACTORY_FACTORY_CLASS,
-                            "com.sun.corba.se.impl.presentation.rmi.bcel.StubFactoryFactoryBCELImpl" ) ;
-
-                        try {
-                            // First try the configured class name, if any
-                            Class<?> cls =
-                                sun.corba.SharedSecrets.getJavaCorbaAccess().loadClass(className);
-                            sff = (PresentationManager.StubFactoryFactory)cls.newInstance();
-                        } catch (Exception exc) {
-                            // Use the default. Log the error as a warning.
-                            staticWrapper.errorInSettingDynamicStubFactoryFactory(
-                                exc, className ) ;
-                        }
-
-                        return sff ;
-                    }
-                }
-            ) ;
+        PresentationManager.StubFactoryFactory dynamicStubFactoryFactory = null;
 
         PresentationManager pm = new PresentationManagerImpl( useDynamicStub ) ;
         pm.setStubFactoryFactory( false,
--- a/corba/src/java.corba/share/classes/sun/corba/SharedSecrets.java	Thu Feb 19 11:24:01 2015 -0800
+++ b/corba/src/java.corba/share/classes/sun/corba/SharedSecrets.java	Wed Jul 05 20:21:01 2017 +0200
@@ -28,7 +28,9 @@
 import com.sun.corba.se.impl.io.ValueUtility;
 import sun.misc.Unsafe;
 
+import java.lang.reflect.Field;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 /** A repository of "shared secrets", which are a mechanism for
     calling implementation-private methods in another package without
@@ -41,9 +43,23 @@
 
 // SharedSecrets cloned in corba repo to avoid build issues
 public class SharedSecrets {
-    private static final Unsafe unsafe = Unsafe.getUnsafe();
+    private static final Unsafe unsafe = getUnsafe();
     private static JavaCorbaAccess javaCorbaAccess;
 
+     private static Unsafe getUnsafe() {
+          PrivilegedAction<Unsafe> pa = () -> {
+               Class<?> unsafeClass = sun.misc.Unsafe.class ;
+               try {
+                    Field f = unsafeClass.getDeclaredField("theUnsafe");
+                    f.setAccessible(true);
+                    return (Unsafe) f.get(null);
+               } catch (Exception e) {
+                    throw new Error(e);
+               }
+          };
+          return AccessController.doPrivileged(pa);
+     }
+
     public static JavaCorbaAccess getJavaCorbaAccess() {
         if (javaCorbaAccess == null) {
             // Ensure ValueUtility is initialized; we know that that class
--- a/hotspot/.hgtags	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/.hgtags	Wed Jul 05 20:21:01 2017 +0200
@@ -453,3 +453,4 @@
 cc775a4a24c7f5d9e624b4205e9fbd48a17331f6 jdk9-b48
 360cd1fc42f10941a9fd17cc32d5b85a22d12a0b jdk9-b49
 e0947f58c9c1426aa0d98b98ebb78357b27a7b99 jdk9-b50
+403b9cbadb04d3d1201823591cf931dc93b38e3a jdk9-b51
--- a/hotspot/agent/src/os/linux/ps_proc.c	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/agent/src/os/linux/ps_proc.c	Wed Jul 05 20:21:01 2017 +0200
@@ -27,9 +27,11 @@
 #include <string.h>
 #include <signal.h>
 #include <errno.h>
+#include <elf.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/ptrace.h>
+#include <sys/uio.h>
 #include "libproc_impl.h"
 
 #if defined(x86_64) && !defined(amd64)
@@ -138,6 +140,15 @@
    return false;
  }
  return true;
+#elif defined(PTRACE_GETREGSET)
+ struct iovec iov;
+ iov.iov_base = user;
+ iov.iov_len = sizeof(*user);
+ if (ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, (void*) &iov) < 0) {
+   print_debug("ptrace(PTRACE_GETREGSET, ...) failed for lwp %d\n", pid);
+   return false;
+ }
+ return true;
 #else
  print_debug("ptrace(PTRACE_GETREGS, ...) not supported\n");
  return false;
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java	Wed Jul 05 20:21:01 2017 +0200
@@ -423,12 +423,22 @@
 
     protected void writeMethods() throws IOException {
         MethodArray methods = klass.getMethods();
-        final int len = methods.length();
+        ArrayList<Method> valid_methods = new ArrayList<Method>();
+        for (int i = 0; i < methods.length(); i++) {
+            Method m = methods.at(i);
+            long accessFlags = m.getAccessFlags();
+            // overpass method
+            if (accessFlags == (JVM_ACC_PUBLIC | JVM_ACC_SYNTHETIC | JVM_ACC_BRIDGE)) {
+                continue;
+            }
+            valid_methods.add(m);
+        }
+        final int len = valid_methods.size();
         // write number of methods
         dos.writeShort((short) len);
         if (DEBUG) debugMessage("number of methods = " + len);
         for (int m = 0; m < len; m++) {
-            writeMethod(methods.at(m));
+            writeMethod(valid_methods.get(m));
         }
     }
 
--- a/hotspot/make/aix/makefiles/mapfile-vers-debug	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/make/aix/makefiles/mapfile-vers-debug	Wed Jul 05 20:21:01 2017 +0200
@@ -62,11 +62,6 @@
                 JVM_DefineClassWithSourceCond;
                 JVM_DesiredAssertionStatus;
                 JVM_DoPrivileged;
-                JVM_DTraceGetVersion;
-                JVM_DTraceActivate;
-                JVM_DTraceIsProbeEnabled;
-                JVM_DTraceIsSupported;
-                JVM_DTraceDispose;
                 JVM_DumpAllStacks;
                 JVM_DumpThreads;
                 JVM_FillInStackTrace;
--- a/hotspot/make/aix/makefiles/mapfile-vers-product	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/make/aix/makefiles/mapfile-vers-product	Wed Jul 05 20:21:01 2017 +0200
@@ -62,11 +62,6 @@
                 JVM_DefineClassWithSourceCond;
                 JVM_DesiredAssertionStatus;
                 JVM_DoPrivileged;
-                JVM_DTraceGetVersion;
-                JVM_DTraceActivate;
-                JVM_DTraceIsProbeEnabled;
-                JVM_DTraceIsSupported;
-                JVM_DTraceDispose;
                 JVM_DumpAllStacks;
                 JVM_DumpThreads;
                 JVM_FillInStackTrace;
--- a/hotspot/make/bsd/makefiles/mapfile-vers-darwin-debug	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-darwin-debug	Wed Jul 05 20:21:01 2017 +0200
@@ -60,11 +60,6 @@
                 _JVM_DefineClassWithSourceCond
                 _JVM_DesiredAssertionStatus
                 _JVM_DoPrivileged
-                _JVM_DTraceGetVersion
-                _JVM_DTraceActivate
-                _JVM_DTraceIsProbeEnabled
-                _JVM_DTraceIsSupported
-                _JVM_DTraceDispose
                 _JVM_DumpAllStacks
                 _JVM_DumpThreads
                 _JVM_FillInStackTrace
--- a/hotspot/make/bsd/makefiles/mapfile-vers-darwin-product	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-darwin-product	Wed Jul 05 20:21:01 2017 +0200
@@ -60,11 +60,6 @@
                 _JVM_DefineClassWithSourceCond
                 _JVM_DesiredAssertionStatus
                 _JVM_DoPrivileged
-                _JVM_DTraceGetVersion
-                _JVM_DTraceActivate
-                _JVM_DTraceIsProbeEnabled
-                _JVM_DTraceIsSupported
-                _JVM_DTraceDispose
                 _JVM_DumpAllStacks
                 _JVM_DumpThreads
                 _JVM_FillInStackTrace
--- a/hotspot/make/bsd/makefiles/mapfile-vers-debug	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-debug	Wed Jul 05 20:21:01 2017 +0200
@@ -62,11 +62,6 @@
                 JVM_DefineClassWithSourceCond;
                 JVM_DesiredAssertionStatus;
                 JVM_DoPrivileged;
-                JVM_DTraceGetVersion;
-                JVM_DTraceActivate;
-                JVM_DTraceIsProbeEnabled;
-                JVM_DTraceIsSupported;
-                JVM_DTraceDispose;
                 JVM_DumpAllStacks;
                 JVM_DumpThreads;
                 JVM_FillInStackTrace;
--- a/hotspot/make/bsd/makefiles/mapfile-vers-product	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-product	Wed Jul 05 20:21:01 2017 +0200
@@ -62,11 +62,6 @@
                 JVM_DefineClassWithSourceCond;
                 JVM_DesiredAssertionStatus;
                 JVM_DoPrivileged;
-                JVM_DTraceGetVersion;
-                JVM_DTraceActivate;
-                JVM_DTraceIsProbeEnabled;
-                JVM_DTraceIsSupported;
-                JVM_DTraceDispose;
                 JVM_DumpAllStacks;
                 JVM_DumpThreads;
                 JVM_FillInStackTrace;
--- a/hotspot/make/linux/makefiles/mapfile-vers-debug	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/make/linux/makefiles/mapfile-vers-debug	Wed Jul 05 20:21:01 2017 +0200
@@ -62,11 +62,6 @@
                 JVM_DefineClassWithSourceCond;
                 JVM_DesiredAssertionStatus;
                 JVM_DoPrivileged;
-                JVM_DTraceGetVersion;
-                JVM_DTraceActivate;
-                JVM_DTraceIsProbeEnabled;
-                JVM_DTraceIsSupported;
-                JVM_DTraceDispose;
                 JVM_DumpAllStacks;
                 JVM_DumpThreads;
                 JVM_FillInStackTrace;
--- a/hotspot/make/linux/makefiles/mapfile-vers-product	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/make/linux/makefiles/mapfile-vers-product	Wed Jul 05 20:21:01 2017 +0200
@@ -62,11 +62,6 @@
                 JVM_DefineClassWithSourceCond;
                 JVM_DesiredAssertionStatus;
                 JVM_DoPrivileged;
-                JVM_DTraceGetVersion;
-                JVM_DTraceActivate;
-                JVM_DTraceIsProbeEnabled;
-                JVM_DTraceIsSupported;
-                JVM_DTraceDispose;
                 JVM_DumpAllStacks;
                 JVM_DumpThreads;
                 JVM_FillInStackTrace;
--- a/hotspot/make/solaris/makefiles/dtrace.make	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/make/solaris/makefiles/dtrace.make	Wed Jul 05 20:21:01 2017 +0200
@@ -336,16 +336,10 @@
 
 .PHONY: dtraceCheck
 
-SYSTEM_DTRACE_H = /usr/include/dtrace.h
 SYSTEM_DTRACE_PROG = /usr/sbin/dtrace
 PATCH_DTRACE_PROG = /opt/SUNWdtrd/sbin/dtrace
 systemDtraceFound := $(wildcard ${SYSTEM_DTRACE_PROG})
 patchDtraceFound := $(wildcard ${PATCH_DTRACE_PROG})
-systemDtraceHdrFound := $(wildcard $(SYSTEM_DTRACE_H))
-
-ifneq ("$(systemDtraceHdrFound)", "") 
-CFLAGS += -DHAVE_DTRACE_H
-endif
 
 ifneq ("$(patchDtraceFound)", "")
 DTRACE_PROG=$(PATCH_DTRACE_PROG)
--- a/hotspot/make/solaris/makefiles/mapfile-vers	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/make/solaris/makefiles/mapfile-vers	Wed Jul 05 20:21:01 2017 +0200
@@ -62,11 +62,6 @@
                 JVM_DefineClassWithSourceCond;
                 JVM_DesiredAssertionStatus;
                 JVM_DoPrivileged;
-                JVM_DTraceGetVersion;
-                JVM_DTraceActivate;
-                JVM_DTraceIsProbeEnabled;
-                JVM_DTraceIsSupported;
-                JVM_DTraceDispose;
                 JVM_DumpAllStacks;
                 JVM_DumpThreads;
                 JVM_FillInStackTrace;
--- a/hotspot/src/cpu/ppc/vm/ppc.ad	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/ppc/vm/ppc.ad	Wed Jul 05 20:21:01 2017 +0200
@@ -6365,58 +6365,6 @@
 // Prefetch instructions.
 // Must be safe to execute with invalid address (cannot fault).
 
-instruct prefetchr(indirectMemory mem, iRegLsrc src) %{
-  match(PrefetchRead (AddP mem src));
-  ins_cost(MEMORY_REF_COST);
-
-  format %{ "PREFETCH $mem, 0, $src \t// Prefetch read-many" %}
-  size(4);
-  ins_encode %{
-    // TODO: PPC port $archOpcode(ppc64Opcode_dcbt);
-    __ dcbt($src$$Register, $mem$$base$$Register);
-  %}
-  ins_pipe(pipe_class_memory);
-%}
-
-instruct prefetchr_no_offset(indirectMemory mem) %{
-  match(PrefetchRead mem);
-  ins_cost(MEMORY_REF_COST);
-
-  format %{ "PREFETCH $mem" %}
-  size(4);
-  ins_encode %{
-    // TODO: PPC port $archOpcode(ppc64Opcode_dcbt);
-    __ dcbt($mem$$base$$Register);
-  %}
-  ins_pipe(pipe_class_memory);
-%}
-
-instruct prefetchw(indirectMemory mem, iRegLsrc src) %{
-  match(PrefetchWrite (AddP mem src));
-  ins_cost(MEMORY_REF_COST);
-
-  format %{ "PREFETCH $mem, 2, $src \t// Prefetch write-many (and read)" %}
-  size(4);
-  ins_encode %{
-    // TODO: PPC port $archOpcode(ppc64Opcode_dcbtst);
-    __ dcbtst($src$$Register, $mem$$base$$Register);
-  %}
-  ins_pipe(pipe_class_memory);
-%}
-
-instruct prefetchw_no_offset(indirectMemory mem) %{
-  match(PrefetchWrite mem);
-  ins_cost(MEMORY_REF_COST);
-
-  format %{ "PREFETCH $mem" %}
-  size(4);
-  ins_encode %{
-    // TODO: PPC port $archOpcode(ppc64Opcode_dcbtst);
-    __ dcbtst($mem$$base$$Register);
-  %}
-  ins_pipe(pipe_class_memory);
-%}
-
 // Special prefetch versions which use the dcbz instruction.
 instruct prefetch_alloc_zero(indirectMemory mem, iRegLsrc src) %{
   match(PrefetchAllocation (AddP mem src));
--- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, 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
@@ -1436,26 +1436,6 @@
 }
 
 
-void LIR_Assembler::prefetchr(LIR_Opr src) {
-  LIR_Address* addr = src->as_address_ptr();
-  Address from_addr = as_Address(addr);
-
-  if (VM_Version::has_v9()) {
-    __ prefetch(from_addr, Assembler::severalReads);
-  }
-}
-
-
-void LIR_Assembler::prefetchw(LIR_Opr src) {
-  LIR_Address* addr = src->as_address_ptr();
-  Address from_addr = as_Address(addr);
-
-  if (VM_Version::has_v9()) {
-    __ prefetch(from_addr, Assembler::severalWritesAndPossiblyReads);
-  }
-}
-
-
 void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) {
   Address addr;
   if (src->is_single_word()) {
--- a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.inline.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.inline.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -630,7 +630,12 @@
 
 inline void MacroAssembler::ldf(FloatRegisterImpl::Width w, const Address& a, FloatRegister d, int offset) {
   relocate(a.rspec(offset));
-  ldf(w, a.base(), a.disp() + offset, d);
+  if (a.has_index()) {
+    assert(offset == 0, "");
+    ldf(w, a.base(), a.index(), d);
+  } else {
+    ldf(w, a.base(), a.disp() + offset, d);
+  }
 }
 
 // returns if membar generates anything, obviously this code should mirror
--- a/hotspot/src/cpu/sparc/vm/nativeInst_sparc.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/sparc/vm/nativeInst_sparc.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -36,11 +36,6 @@
 #include "c1/c1_Runtime1.hpp"
 #endif
 
-
-bool NativeInstruction::is_dtrace_trap() {
-  return !is_nop();
-}
-
 void NativeInstruction::set_data64_sethi(address instaddr, intptr_t x) {
   ResourceMark rm;
   CodeBuffer buf(instaddr, 10 * BytesPerInstWord );
--- a/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -51,7 +51,6 @@
     nop_instruction_size        =    4
   };
 
-  bool is_dtrace_trap();
   bool is_nop()                        { return long_at(0) == nop_instruction(); }
   bool is_call()                       { return is_op(long_at(0), Assembler::call_op); }
   bool is_sethi()                      { return (is_op2(long_at(0), Assembler::sethi_op2)
--- a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -2758,540 +2758,6 @@
 
 }
 
-#ifdef HAVE_DTRACE_H
-// ---------------------------------------------------------------------------
-// Generate a dtrace nmethod for a given signature.  The method takes arguments
-// in the Java compiled code convention, marshals them to the native
-// abi and then leaves nops at the position you would expect to call a native
-// function. When the probe is enabled the nops are replaced with a trap
-// instruction that dtrace inserts and the trace will cause a notification
-// to dtrace.
-//
-// The probes are only able to take primitive types and java/lang/String as
-// arguments.  No other java types are allowed. Strings are converted to utf8
-// strings so that from dtrace point of view java strings are converted to C
-// strings. There is an arbitrary fixed limit on the total space that a method
-// can use for converting the strings. (256 chars per string in the signature).
-// So any java string larger then this is truncated.
-
-static int  fp_offset[ConcreteRegisterImpl::number_of_registers] = { 0 };
-static bool offsets_initialized = false;
-
-nmethod *SharedRuntime::generate_dtrace_nmethod(
-    MacroAssembler *masm, methodHandle method) {
-
-
-  // generate_dtrace_nmethod is guarded by a mutex so we are sure to
-  // be single threaded in this method.
-  assert(AdapterHandlerLibrary_lock->owned_by_self(), "must be");
-
-  // Fill in the signature array, for the calling-convention call.
-  int total_args_passed = method->size_of_parameters();
-
-  BasicType* in_sig_bt  = NEW_RESOURCE_ARRAY(BasicType, total_args_passed);
-  VMRegPair  *in_regs   = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed);
-
-  // The signature we are going to use for the trap that dtrace will see
-  // java/lang/String is converted. We drop "this" and any other object
-  // is converted to NULL.  (A one-slot java/lang/Long object reference
-  // is converted to a two-slot long, which is why we double the allocation).
-  BasicType* out_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed * 2);
-  VMRegPair* out_regs   = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed * 2);
-
-  int i=0;
-  int total_strings = 0;
-  int first_arg_to_pass = 0;
-  int total_c_args = 0;
-
-  // Skip the receiver as dtrace doesn't want to see it
-  if( !method->is_static() ) {
-    in_sig_bt[i++] = T_OBJECT;
-    first_arg_to_pass = 1;
-  }
-
-  SignatureStream ss(method->signature());
-  for ( ; !ss.at_return_type(); ss.next()) {
-    BasicType bt = ss.type();
-    in_sig_bt[i++] = bt;  // Collect remaining bits of signature
-    out_sig_bt[total_c_args++] = bt;
-    if( bt == T_OBJECT) {
-      Symbol* s = ss.as_symbol_or_null();
-      if (s == vmSymbols::java_lang_String()) {
-        total_strings++;
-        out_sig_bt[total_c_args-1] = T_ADDRESS;
-      } else if (s == vmSymbols::java_lang_Boolean() ||
-                 s == vmSymbols::java_lang_Byte()) {
-        out_sig_bt[total_c_args-1] = T_BYTE;
-      } else if (s == vmSymbols::java_lang_Character() ||
-                 s == vmSymbols::java_lang_Short()) {
-        out_sig_bt[total_c_args-1] = T_SHORT;
-      } else if (s == vmSymbols::java_lang_Integer() ||
-                 s == vmSymbols::java_lang_Float()) {
-        out_sig_bt[total_c_args-1] = T_INT;
-      } else if (s == vmSymbols::java_lang_Long() ||
-                 s == vmSymbols::java_lang_Double()) {
-        out_sig_bt[total_c_args-1] = T_LONG;
-        out_sig_bt[total_c_args++] = T_VOID;
-      }
-    } else if ( bt == T_LONG || bt == T_DOUBLE ) {
-      in_sig_bt[i++] = T_VOID;   // Longs & doubles take 2 Java slots
-      // We convert double to long
-      out_sig_bt[total_c_args-1] = T_LONG;
-      out_sig_bt[total_c_args++] = T_VOID;
-    } else if ( bt == T_FLOAT) {
-      // We convert float to int
-      out_sig_bt[total_c_args-1] = T_INT;
-    }
-  }
-
-  assert(i==total_args_passed, "validly parsed signature");
-
-  // Now get the compiled-Java layout as input arguments
-  int comp_args_on_stack;
-  comp_args_on_stack = SharedRuntime::java_calling_convention(
-      in_sig_bt, in_regs, total_args_passed, false);
-
-  // We have received a description of where all the java arg are located
-  // on entry to the wrapper. We need to convert these args to where
-  // the a  native (non-jni) function would expect them. To figure out
-  // where they go we convert the java signature to a C signature and remove
-  // T_VOID for any long/double we might have received.
-
-
-  // Now figure out where the args must be stored and how much stack space
-  // they require (neglecting out_preserve_stack_slots but space for storing
-  // the 1st six register arguments). It's weird see int_stk_helper.
-  //
-  int out_arg_slots;
-  out_arg_slots = c_calling_convention(out_sig_bt, out_regs, NULL, total_c_args);
-
-  // Calculate the total number of stack slots we will need.
-
-  // First count the abi requirement plus all of the outgoing args
-  int stack_slots = SharedRuntime::out_preserve_stack_slots() + out_arg_slots;
-
-  // Plus a temp for possible converion of float/double/long register args
-
-  int conversion_temp = stack_slots;
-  stack_slots += 2;
-
-
-  // Now space for the string(s) we must convert
-
-  int string_locs = stack_slots;
-  stack_slots += total_strings *
-                   (max_dtrace_string_size / VMRegImpl::stack_slot_size);
-
-  // Ok The space we have allocated will look like:
-  //
-  //
-  // FP-> |                     |
-  //      |---------------------|
-  //      | string[n]           |
-  //      |---------------------| <- string_locs[n]
-  //      | string[n-1]         |
-  //      |---------------------| <- string_locs[n-1]
-  //      | ...                 |
-  //      | ...                 |
-  //      |---------------------| <- string_locs[1]
-  //      | string[0]           |
-  //      |---------------------| <- string_locs[0]
-  //      | temp                |
-  //      |---------------------| <- conversion_temp
-  //      | outbound memory     |
-  //      | based arguments     |
-  //      |                     |
-  //      |---------------------|
-  //      |                     |
-  // SP-> | out_preserved_slots |
-  //
-  //
-
-  // Now compute actual number of stack words we need rounding to make
-  // stack properly aligned.
-  stack_slots = round_to(stack_slots, 4 * VMRegImpl::slots_per_word);
-
-  int stack_size = stack_slots * VMRegImpl::stack_slot_size;
-
-  intptr_t start = (intptr_t)__ pc();
-
-  // First thing make an ic check to see if we should even be here
-
-  {
-    Label L;
-    const Register temp_reg = G3_scratch;
-    AddressLiteral ic_miss(SharedRuntime::get_ic_miss_stub());
-    __ verify_oop(O0);
-    __ ld_ptr(O0, oopDesc::klass_offset_in_bytes(), temp_reg);
-    __ cmp_and_brx_short(temp_reg, G5_inline_cache_reg, Assembler::equal, Assembler::pt, L);
-
-    __ jump_to(ic_miss, temp_reg);
-    __ delayed()->nop();
-    __ align(CodeEntryAlignment);
-    __ bind(L);
-  }
-
-  int vep_offset = ((intptr_t)__ pc()) - start;
-
-
-  // The instruction at the verified entry point must be 5 bytes or longer
-  // because it can be patched on the fly by make_non_entrant. The stack bang
-  // instruction fits that requirement.
-
-  // Generate stack overflow check before creating frame
-  __ generate_stack_overflow_check(stack_size);
-
-  assert(((intptr_t)__ pc() - start - vep_offset) >= 5,
-         "valid size for make_non_entrant");
-
-  // Generate a new frame for the wrapper.
-  __ save(SP, -stack_size, SP);
-
-  // Frame is now completed as far a size and linkage.
-
-  int frame_complete = ((intptr_t)__ pc()) - start;
-
-#ifdef ASSERT
-  bool reg_destroyed[RegisterImpl::number_of_registers];
-  bool freg_destroyed[FloatRegisterImpl::number_of_registers];
-  for ( int r = 0 ; r < RegisterImpl::number_of_registers ; r++ ) {
-    reg_destroyed[r] = false;
-  }
-  for ( int f = 0 ; f < FloatRegisterImpl::number_of_registers ; f++ ) {
-    freg_destroyed[f] = false;
-  }
-
-#endif /* ASSERT */
-
-  VMRegPair zero;
-  const Register g0 = G0; // without this we get a compiler warning (why??)
-  zero.set2(g0->as_VMReg());
-
-  int c_arg, j_arg;
-
-  Register conversion_off = noreg;
-
-  for (j_arg = first_arg_to_pass, c_arg = 0 ;
-       j_arg < total_args_passed ; j_arg++, c_arg++ ) {
-
-    VMRegPair src = in_regs[j_arg];
-    VMRegPair dst = out_regs[c_arg];
-
-#ifdef ASSERT
-    if (src.first()->is_Register()) {
-      assert(!reg_destroyed[src.first()->as_Register()->encoding()], "ack!");
-    } else if (src.first()->is_FloatRegister()) {
-      assert(!freg_destroyed[src.first()->as_FloatRegister()->encoding(
-                                               FloatRegisterImpl::S)], "ack!");
-    }
-    if (dst.first()->is_Register()) {
-      reg_destroyed[dst.first()->as_Register()->encoding()] = true;
-    } else if (dst.first()->is_FloatRegister()) {
-      freg_destroyed[dst.first()->as_FloatRegister()->encoding(
-                                                 FloatRegisterImpl::S)] = true;
-    }
-#endif /* ASSERT */
-
-    switch (in_sig_bt[j_arg]) {
-      case T_ARRAY:
-      case T_OBJECT:
-        {
-          if (out_sig_bt[c_arg] == T_BYTE  || out_sig_bt[c_arg] == T_SHORT ||
-              out_sig_bt[c_arg] == T_INT || out_sig_bt[c_arg] == T_LONG) {
-            // need to unbox a one-slot value
-            Register in_reg = L0;
-            Register tmp = L2;
-            if ( src.first()->is_reg() ) {
-              in_reg = src.first()->as_Register();
-            } else {
-              assert(Assembler::is_simm13(reg2offset(src.first()) + STACK_BIAS),
-                     "must be");
-              __ ld_ptr(FP, reg2offset(src.first()) + STACK_BIAS, in_reg);
-            }
-            // If the final destination is an acceptable register
-            if ( dst.first()->is_reg() ) {
-              if ( dst.is_single_phys_reg() || out_sig_bt[c_arg] != T_LONG ) {
-                tmp = dst.first()->as_Register();
-              }
-            }
-
-            Label skipUnbox;
-            if ( wordSize == 4 && out_sig_bt[c_arg] == T_LONG ) {
-              __ mov(G0, tmp->successor());
-            }
-            __ br_null(in_reg, true, Assembler::pn, skipUnbox);
-            __ delayed()->mov(G0, tmp);
-
-            BasicType bt = out_sig_bt[c_arg];
-            int box_offset = java_lang_boxing_object::value_offset_in_bytes(bt);
-            switch (bt) {
-                case T_BYTE:
-                  __ ldub(in_reg, box_offset, tmp); break;
-                case T_SHORT:
-                  __ lduh(in_reg, box_offset, tmp); break;
-                case T_INT:
-                  __ ld(in_reg, box_offset, tmp); break;
-                case T_LONG:
-                  __ ld_long(in_reg, box_offset, tmp); break;
-                default: ShouldNotReachHere();
-            }
-
-            __ bind(skipUnbox);
-            // If tmp wasn't final destination copy to final destination
-            if (tmp == L2) {
-              VMRegPair tmp_as_VM = reg64_to_VMRegPair(L2);
-              if (out_sig_bt[c_arg] == T_LONG) {
-                long_move(masm, tmp_as_VM, dst);
-              } else {
-                move32_64(masm, tmp_as_VM, out_regs[c_arg]);
-              }
-            }
-            if (out_sig_bt[c_arg] == T_LONG) {
-              assert(out_sig_bt[c_arg+1] == T_VOID, "must be");
-              ++c_arg; // move over the T_VOID to keep the loop indices in sync
-            }
-          } else if (out_sig_bt[c_arg] == T_ADDRESS) {
-            Register s =
-                src.first()->is_reg() ? src.first()->as_Register() : L2;
-            Register d =
-                dst.first()->is_reg() ? dst.first()->as_Register() : L2;
-
-            // We store the oop now so that the conversion pass can reach
-            // while in the inner frame. This will be the only store if
-            // the oop is NULL.
-            if (s != L2) {
-              // src is register
-              if (d != L2) {
-                // dst is register
-                __ mov(s, d);
-              } else {
-                assert(Assembler::is_simm13(reg2offset(dst.first()) +
-                          STACK_BIAS), "must be");
-                __ st_ptr(s, SP, reg2offset(dst.first()) + STACK_BIAS);
-              }
-            } else {
-                // src not a register
-                assert(Assembler::is_simm13(reg2offset(src.first()) +
-                           STACK_BIAS), "must be");
-                __ ld_ptr(FP, reg2offset(src.first()) + STACK_BIAS, d);
-                if (d == L2) {
-                  assert(Assembler::is_simm13(reg2offset(dst.first()) +
-                             STACK_BIAS), "must be");
-                  __ st_ptr(d, SP, reg2offset(dst.first()) + STACK_BIAS);
-                }
-            }
-          } else if (out_sig_bt[c_arg] != T_VOID) {
-            // Convert the arg to NULL
-            if (dst.first()->is_reg()) {
-              __ mov(G0, dst.first()->as_Register());
-            } else {
-              assert(Assembler::is_simm13(reg2offset(dst.first()) +
-                         STACK_BIAS), "must be");
-              __ st_ptr(G0, SP, reg2offset(dst.first()) + STACK_BIAS);
-            }
-          }
-        }
-        break;
-      case T_VOID:
-        break;
-
-      case T_FLOAT:
-        if (src.first()->is_stack()) {
-          // Stack to stack/reg is simple
-          move32_64(masm, src, dst);
-        } else {
-          if (dst.first()->is_reg()) {
-            // freg -> reg
-            int off =
-              STACK_BIAS + conversion_temp * VMRegImpl::stack_slot_size;
-            Register d = dst.first()->as_Register();
-            if (Assembler::is_simm13(off)) {
-              __ stf(FloatRegisterImpl::S, src.first()->as_FloatRegister(),
-                     SP, off);
-              __ ld(SP, off, d);
-            } else {
-              if (conversion_off == noreg) {
-                __ set(off, L6);
-                conversion_off = L6;
-              }
-              __ stf(FloatRegisterImpl::S, src.first()->as_FloatRegister(),
-                     SP, conversion_off);
-              __ ld(SP, conversion_off , d);
-            }
-          } else {
-            // freg -> mem
-            int off = STACK_BIAS + reg2offset(dst.first());
-            if (Assembler::is_simm13(off)) {
-              __ stf(FloatRegisterImpl::S, src.first()->as_FloatRegister(),
-                     SP, off);
-            } else {
-              if (conversion_off == noreg) {
-                __ set(off, L6);
-                conversion_off = L6;
-              }
-              __ stf(FloatRegisterImpl::S, src.first()->as_FloatRegister(),
-                     SP, conversion_off);
-            }
-          }
-        }
-        break;
-
-      case T_DOUBLE:
-        assert( j_arg + 1 < total_args_passed &&
-                in_sig_bt[j_arg + 1] == T_VOID &&
-                out_sig_bt[c_arg+1] == T_VOID, "bad arg list");
-        if (src.first()->is_stack()) {
-          // Stack to stack/reg is simple
-          long_move(masm, src, dst);
-        } else {
-          Register d = dst.first()->is_reg() ? dst.first()->as_Register() : L2;
-
-          // Destination could be an odd reg on 32bit in which case
-          // we can't load direct to the destination.
-
-          if (!d->is_even() && wordSize == 4) {
-            d = L2;
-          }
-          int off = STACK_BIAS + conversion_temp * VMRegImpl::stack_slot_size;
-          if (Assembler::is_simm13(off)) {
-            __ stf(FloatRegisterImpl::D, src.first()->as_FloatRegister(),
-                   SP, off);
-            __ ld_long(SP, off, d);
-          } else {
-            if (conversion_off == noreg) {
-              __ set(off, L6);
-              conversion_off = L6;
-            }
-            __ stf(FloatRegisterImpl::D, src.first()->as_FloatRegister(),
-                   SP, conversion_off);
-            __ ld_long(SP, conversion_off, d);
-          }
-          if (d == L2) {
-            long_move(masm, reg64_to_VMRegPair(L2), dst);
-          }
-        }
-        break;
-
-      case T_LONG :
-        // 32bit can't do a split move of something like g1 -> O0, O1
-        // so use a memory temp
-        if (src.is_single_phys_reg() && wordSize == 4) {
-          Register tmp = L2;
-          if (dst.first()->is_reg() &&
-              (wordSize == 8 || dst.first()->as_Register()->is_even())) {
-            tmp = dst.first()->as_Register();
-          }
-
-          int off = STACK_BIAS + conversion_temp * VMRegImpl::stack_slot_size;
-          if (Assembler::is_simm13(off)) {
-            __ stx(src.first()->as_Register(), SP, off);
-            __ ld_long(SP, off, tmp);
-          } else {
-            if (conversion_off == noreg) {
-              __ set(off, L6);
-              conversion_off = L6;
-            }
-            __ stx(src.first()->as_Register(), SP, conversion_off);
-            __ ld_long(SP, conversion_off, tmp);
-          }
-
-          if (tmp == L2) {
-            long_move(masm, reg64_to_VMRegPair(L2), dst);
-          }
-        } else {
-          long_move(masm, src, dst);
-        }
-        break;
-
-      case T_ADDRESS: assert(false, "found T_ADDRESS in java args");
-
-      default:
-        move32_64(masm, src, dst);
-    }
-  }
-
-
-  // If we have any strings we must store any register based arg to the stack
-  // This includes any still live xmm registers too.
-
-  if (total_strings > 0 ) {
-
-    // protect all the arg registers
-    __ save_frame(0);
-    __ mov(G2_thread, L7_thread_cache);
-    const Register L2_string_off = L2;
-
-    // Get first string offset
-    __ set(string_locs * VMRegImpl::stack_slot_size, L2_string_off);
-
-    for (c_arg = 0 ; c_arg < total_c_args ; c_arg++ ) {
-      if (out_sig_bt[c_arg] == T_ADDRESS) {
-
-        VMRegPair dst = out_regs[c_arg];
-        const Register d = dst.first()->is_reg() ?
-            dst.first()->as_Register()->after_save() : noreg;
-
-        // It's a string the oop and it was already copied to the out arg
-        // position
-        if (d != noreg) {
-          __ mov(d, O0);
-        } else {
-          assert(Assembler::is_simm13(reg2offset(dst.first()) + STACK_BIAS),
-                 "must be");
-          __ ld_ptr(FP,  reg2offset(dst.first()) + STACK_BIAS, O0);
-        }
-        Label skip;
-
-        __ br_null(O0, false, Assembler::pn, skip);
-        __ delayed()->add(FP, L2_string_off, O1);
-
-        if (d != noreg) {
-          __ mov(O1, d);
-        } else {
-          assert(Assembler::is_simm13(reg2offset(dst.first()) + STACK_BIAS),
-                 "must be");
-          __ st_ptr(O1, FP,  reg2offset(dst.first()) + STACK_BIAS);
-        }
-
-        __ call(CAST_FROM_FN_PTR(address, SharedRuntime::get_utf),
-                relocInfo::runtime_call_type);
-        __ delayed()->add(L2_string_off, max_dtrace_string_size, L2_string_off);
-
-        __ bind(skip);
-
-      }
-
-    }
-    __ mov(L7_thread_cache, G2_thread);
-    __ restore();
-
-  }
-
-
-  // Ok now we are done. Need to place the nop that dtrace wants in order to
-  // patch in the trap
-
-  int patch_offset = ((intptr_t)__ pc()) - start;
-
-  __ nop();
-
-
-  // Return
-
-  __ ret();
-  __ delayed()->restore();
-
-  __ flush();
-
-  nmethod *nm = nmethod::new_dtrace_nmethod(
-      method, masm->code(), vep_offset, patch_offset, frame_complete,
-      stack_slots / VMRegImpl::slots_per_word);
-  return nm;
-
-}
-
-#endif // HAVE_DTRACE_H
-
 // this function returns the adjust size (in number of words) to a c2i adapter
 // activation for use during deoptimization
 int Deoptimization::last_frame_adjust(int callee_parameters, int callee_locals) {
--- a/hotspot/src/cpu/sparc/vm/sparc.ad	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/sparc/vm/sparc.ad	Wed Jul 05 20:21:01 2017 +0200
@@ -889,8 +889,6 @@
           !(n->ideal_Opcode()==Op_LoadD_unaligned && ld_op==Op_LoadF) &&
           !(n->ideal_Opcode()==Op_ConvI2F   && ld_op==Op_LoadF) &&
           !(n->ideal_Opcode()==Op_ConvI2D   && ld_op==Op_LoadF) &&
-          !(n->ideal_Opcode()==Op_PrefetchRead  && ld_op==Op_LoadI) &&
-          !(n->ideal_Opcode()==Op_PrefetchWrite && ld_op==Op_LoadI) &&
           !(n->ideal_Opcode()==Op_PrefetchAllocation && ld_op==Op_LoadI) &&
           !(n->ideal_Opcode()==Op_LoadVector && ld_op==Op_LoadD) &&
           !(n->rule() == loadUB_rule)) {
@@ -6316,33 +6314,9 @@
   ins_pipe(loadConFD);
 %}
 
-// Prefetch instructions.
+// Prefetch instructions for allocation.
 // Must be safe to execute with invalid address (cannot fault).
 
-instruct prefetchr( memory mem ) %{
-  match( PrefetchRead mem );
-  ins_cost(MEMORY_REF_COST);
-  size(4);
-
-  format %{ "PREFETCH $mem,0\t! Prefetch read-many" %}
-  opcode(Assembler::prefetch_op3);
-  ins_encode( form3_mem_prefetch_read( mem ) );
-  ins_pipe(iload_mem);
-%}
-
-instruct prefetchw( memory mem ) %{
-  match( PrefetchWrite mem );
-  ins_cost(MEMORY_REF_COST);
-  size(4);
-
-  format %{ "PREFETCH $mem,2\t! Prefetch write-many (and read)" %}
-  opcode(Assembler::prefetch_op3);
-  ins_encode( form3_mem_prefetch_write( mem ) );
-  ins_pipe(iload_mem);
-%}
-
-// Prefetch instructions for allocation.
-
 instruct prefetchAlloc( memory mem ) %{
   predicate(AllocatePrefetchInstr == 0);
   match( PrefetchAllocation mem );
--- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, 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
@@ -1398,50 +1398,6 @@
 }
 
 
-void LIR_Assembler::prefetchr(LIR_Opr src) {
-  LIR_Address* addr = src->as_address_ptr();
-  Address from_addr = as_Address(addr);
-
-  if (VM_Version::supports_sse()) {
-    switch (ReadPrefetchInstr) {
-      case 0:
-        __ prefetchnta(from_addr); break;
-      case 1:
-        __ prefetcht0(from_addr); break;
-      case 2:
-        __ prefetcht2(from_addr); break;
-      default:
-        ShouldNotReachHere(); break;
-    }
-  } else if (VM_Version::supports_3dnow_prefetch()) {
-    __ prefetchr(from_addr);
-  }
-}
-
-
-void LIR_Assembler::prefetchw(LIR_Opr src) {
-  LIR_Address* addr = src->as_address_ptr();
-  Address from_addr = as_Address(addr);
-
-  if (VM_Version::supports_sse()) {
-    switch (AllocatePrefetchInstr) {
-      case 0:
-        __ prefetchnta(from_addr); break;
-      case 1:
-        __ prefetcht0(from_addr); break;
-      case 2:
-        __ prefetcht2(from_addr); break;
-      case 3:
-        __ prefetchw(from_addr); break;
-      default:
-        ShouldNotReachHere(); break;
-    }
-  } else if (VM_Version::supports_3dnow_prefetch()) {
-    __ prefetchw(from_addr);
-  }
-}
-
-
 NEEDS_CLEANUP; // This could be static?
 Address::ScaleFactor LIR_Assembler::array_element_size(BasicType type) const {
   int elem_size = type2aelembytes(type);
--- a/hotspot/src/cpu/x86/vm/globals_x86.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, 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
@@ -90,9 +90,6 @@
   product(intx, FenceInstruction, 0,                                        \
           "(Unsafe,Unstable) Experimental")                                 \
                                                                             \
-  product(intx,  ReadPrefetchInstr, 0,                                      \
-          "Prefetch instruction to prefetch ahead")                         \
-                                                                            \
   product(bool, UseStoreImmI16, true,                                       \
           "Use store immediate 16-bits value instruction on x86")           \
                                                                             \
--- a/hotspot/src/cpu/x86/vm/nativeInst_x86.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/x86/vm/nativeInst_x86.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -602,7 +602,3 @@
   else
     return addr_at(0) + length + sbyte_at(offset);
 }
-
-bool NativeInstruction::is_dtrace_trap() {
-  return (*(int32_t*)this & 0xff) == 0xcc;
-}
--- a/hotspot/src/cpu/x86/vm/nativeInst_x86.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/x86/vm/nativeInst_x86.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -59,7 +59,6 @@
   };
 
   bool is_nop()                        { return ubyte_at(0) == nop_instruction_code; }
-  bool is_dtrace_trap();
   inline bool is_call();
   inline bool is_illegal();
   inline bool is_return();
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -2415,381 +2415,6 @@
 
 }
 
-#ifdef HAVE_DTRACE_H
-// ---------------------------------------------------------------------------
-// Generate a dtrace nmethod for a given signature.  The method takes arguments
-// in the Java compiled code convention, marshals them to the native
-// abi and then leaves nops at the position you would expect to call a native
-// function. When the probe is enabled the nops are replaced with a trap
-// instruction that dtrace inserts and the trace will cause a notification
-// to dtrace.
-//
-// The probes are only able to take primitive types and java/lang/String as
-// arguments.  No other java types are allowed. Strings are converted to utf8
-// strings so that from dtrace point of view java strings are converted to C
-// strings. There is an arbitrary fixed limit on the total space that a method
-// can use for converting the strings. (256 chars per string in the signature).
-// So any java string larger then this is truncated.
-
-nmethod *SharedRuntime::generate_dtrace_nmethod(
-    MacroAssembler *masm, methodHandle method) {
-
-  // generate_dtrace_nmethod is guarded by a mutex so we are sure to
-  // be single threaded in this method.
-  assert(AdapterHandlerLibrary_lock->owned_by_self(), "must be");
-
-  // Fill in the signature array, for the calling-convention call.
-  int total_args_passed = method->size_of_parameters();
-
-  BasicType* in_sig_bt  = NEW_RESOURCE_ARRAY(BasicType, total_args_passed);
-  VMRegPair  *in_regs   = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed);
-
-  // The signature we are going to use for the trap that dtrace will see
-  // java/lang/String is converted. We drop "this" and any other object
-  // is converted to NULL.  (A one-slot java/lang/Long object reference
-  // is converted to a two-slot long, which is why we double the allocation).
-  BasicType* out_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed * 2);
-  VMRegPair* out_regs   = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed * 2);
-
-  int i=0;
-  int total_strings = 0;
-  int first_arg_to_pass = 0;
-  int total_c_args = 0;
-
-  if( !method->is_static() ) {  // Pass in receiver first
-    in_sig_bt[i++] = T_OBJECT;
-    first_arg_to_pass = 1;
-  }
-
-  // We need to convert the java args to where a native (non-jni) function
-  // would expect them. To figure out where they go we convert the java
-  // signature to a C signature.
-
-  SignatureStream ss(method->signature());
-  for ( ; !ss.at_return_type(); ss.next()) {
-    BasicType bt = ss.type();
-    in_sig_bt[i++] = bt;  // Collect remaining bits of signature
-    out_sig_bt[total_c_args++] = bt;
-    if( bt == T_OBJECT) {
-      Symbol* s = ss.as_symbol_or_null();   // symbol is created
-      if (s == vmSymbols::java_lang_String()) {
-        total_strings++;
-        out_sig_bt[total_c_args-1] = T_ADDRESS;
-      } else if (s == vmSymbols::java_lang_Boolean() ||
-                 s == vmSymbols::java_lang_Character() ||
-                 s == vmSymbols::java_lang_Byte() ||
-                 s == vmSymbols::java_lang_Short() ||
-                 s == vmSymbols::java_lang_Integer() ||
-                 s == vmSymbols::java_lang_Float()) {
-        out_sig_bt[total_c_args-1] = T_INT;
-      } else if (s == vmSymbols::java_lang_Long() ||
-                 s == vmSymbols::java_lang_Double()) {
-        out_sig_bt[total_c_args-1] = T_LONG;
-        out_sig_bt[total_c_args++] = T_VOID;
-      }
-    } else if ( bt == T_LONG || bt == T_DOUBLE ) {
-      in_sig_bt[i++] = T_VOID;   // Longs & doubles take 2 Java slots
-      out_sig_bt[total_c_args++] = T_VOID;
-    }
-  }
-
-  assert(i==total_args_passed, "validly parsed signature");
-
-  // Now get the compiled-Java layout as input arguments
-  int comp_args_on_stack;
-  comp_args_on_stack = SharedRuntime::java_calling_convention(
-      in_sig_bt, in_regs, total_args_passed, false);
-
-  // Now figure out where the args must be stored and how much stack space
-  // they require (neglecting out_preserve_stack_slots).
-
-  int out_arg_slots;
-  out_arg_slots = c_calling_convention(out_sig_bt, out_regs, NULL, total_c_args);
-
-  // Calculate the total number of stack slots we will need.
-
-  // First count the abi requirement plus all of the outgoing args
-  int stack_slots = SharedRuntime::out_preserve_stack_slots() + out_arg_slots;
-
-  // Now space for the string(s) we must convert
-
-  int* string_locs   = NEW_RESOURCE_ARRAY(int, total_strings + 1);
-  for (i = 0; i < total_strings ; i++) {
-    string_locs[i] = stack_slots;
-    stack_slots += max_dtrace_string_size / VMRegImpl::stack_slot_size;
-  }
-
-  // + 2 for return address (which we own) and saved rbp,
-
-  stack_slots += 2;
-
-  // Ok The space we have allocated will look like:
-  //
-  //
-  // FP-> |                     |
-  //      |---------------------|
-  //      | string[n]           |
-  //      |---------------------| <- string_locs[n]
-  //      | string[n-1]         |
-  //      |---------------------| <- string_locs[n-1]
-  //      | ...                 |
-  //      | ...                 |
-  //      |---------------------| <- string_locs[1]
-  //      | string[0]           |
-  //      |---------------------| <- string_locs[0]
-  //      | outbound memory     |
-  //      | based arguments     |
-  //      |                     |
-  //      |---------------------|
-  //      |                     |
-  // SP-> | out_preserved_slots |
-  //
-  //
-
-  // Now compute actual number of stack words we need rounding to make
-  // stack properly aligned.
-  stack_slots = round_to(stack_slots, 2 * VMRegImpl::slots_per_word);
-
-  int stack_size = stack_slots * VMRegImpl::stack_slot_size;
-
-  intptr_t start = (intptr_t)__ pc();
-
-  // First thing make an ic check to see if we should even be here
-
-  // We are free to use all registers as temps without saving them and
-  // restoring them except rbp. rbp, is the only callee save register
-  // as far as the interpreter and the compiler(s) are concerned.
-
-  const Register ic_reg = rax;
-  const Register receiver = rcx;
-  Label hit;
-  Label exception_pending;
-
-
-  __ verify_oop(receiver);
-  __ cmpl(ic_reg, Address(receiver, oopDesc::klass_offset_in_bytes()));
-  __ jcc(Assembler::equal, hit);
-
-  __ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
-
-  // verified entry must be aligned for code patching.
-  // and the first 5 bytes must be in the same cache line
-  // if we align at 8 then we will be sure 5 bytes are in the same line
-  __ align(8);
-
-  __ bind(hit);
-
-  int vep_offset = ((intptr_t)__ pc()) - start;
-
-
-  // The instruction at the verified entry point must be 5 bytes or longer
-  // because it can be patched on the fly by make_non_entrant. The stack bang
-  // instruction fits that requirement.
-
-  // Generate stack overflow check
-
-
-  if (UseStackBanging) {
-    if (stack_size <= StackShadowPages*os::vm_page_size()) {
-      __ bang_stack_with_offset(StackShadowPages*os::vm_page_size());
-    } else {
-      __ movl(rax, stack_size);
-      __ bang_stack_size(rax, rbx);
-    }
-  } else {
-    // need a 5 byte instruction to allow MT safe patching to non-entrant
-    __ fat_nop();
-  }
-
-  assert(((int)__ pc() - start - vep_offset) >= 5,
-         "valid size for make_non_entrant");
-
-  // Generate a new frame for the wrapper.
-  __ enter();
-
-  // -2 because return address is already present and so is saved rbp,
-  if (stack_size - 2*wordSize != 0) {
-    __ subl(rsp, stack_size - 2*wordSize);
-  }
-
-  // Frame is now completed as far a size and linkage.
-
-  int frame_complete = ((intptr_t)__ pc()) - start;
-
-  // First thing we do store all the args as if we are doing the call.
-  // Since the C calling convention is stack based that ensures that
-  // all the Java register args are stored before we need to convert any
-  // string we might have.
-
-  int sid = 0;
-  int c_arg, j_arg;
-  int string_reg = 0;
-
-  for (j_arg = first_arg_to_pass, c_arg = 0 ;
-       j_arg < total_args_passed ; j_arg++, c_arg++ ) {
-
-    VMRegPair src = in_regs[j_arg];
-    VMRegPair dst = out_regs[c_arg];
-    assert(dst.first()->is_stack() || in_sig_bt[j_arg] == T_VOID,
-           "stack based abi assumed");
-
-    switch (in_sig_bt[j_arg]) {
-
-      case T_ARRAY:
-      case T_OBJECT:
-        if (out_sig_bt[c_arg] == T_ADDRESS) {
-          // Any register based arg for a java string after the first
-          // will be destroyed by the call to get_utf so we store
-          // the original value in the location the utf string address
-          // will eventually be stored.
-          if (src.first()->is_reg()) {
-            if (string_reg++ != 0) {
-              simple_move32(masm, src, dst);
-            }
-          }
-        } else if (out_sig_bt[c_arg] == T_INT || out_sig_bt[c_arg] == T_LONG) {
-          // need to unbox a one-word value
-          Register in_reg = rax;
-          if ( src.first()->is_reg() ) {
-            in_reg = src.first()->as_Register();
-          } else {
-            simple_move32(masm, src, in_reg->as_VMReg());
-          }
-          Label skipUnbox;
-          __ movl(Address(rsp, reg2offset_out(dst.first())), NULL_WORD);
-          if ( out_sig_bt[c_arg] == T_LONG ) {
-            __ movl(Address(rsp, reg2offset_out(dst.second())), NULL_WORD);
-          }
-          __ testl(in_reg, in_reg);
-          __ jcc(Assembler::zero, skipUnbox);
-          assert(dst.first()->is_stack() &&
-                 (!dst.second()->is_valid() || dst.second()->is_stack()),
-                 "value(s) must go into stack slots");
-
-          BasicType bt = out_sig_bt[c_arg];
-          int box_offset = java_lang_boxing_object::value_offset_in_bytes(bt);
-          if ( bt == T_LONG ) {
-            __ movl(rbx, Address(in_reg,
-                                 box_offset + VMRegImpl::stack_slot_size));
-            __ movl(Address(rsp, reg2offset_out(dst.second())), rbx);
-          }
-          __ movl(in_reg,  Address(in_reg, box_offset));
-          __ movl(Address(rsp, reg2offset_out(dst.first())), in_reg);
-          __ bind(skipUnbox);
-        } else {
-          // Convert the arg to NULL
-          __ movl(Address(rsp, reg2offset_out(dst.first())), NULL_WORD);
-        }
-        if (out_sig_bt[c_arg] == T_LONG) {
-          assert(out_sig_bt[c_arg+1] == T_VOID, "must be");
-          ++c_arg; // Move over the T_VOID To keep the loop indices in sync
-        }
-        break;
-
-      case T_VOID:
-        break;
-
-      case T_FLOAT:
-        float_move(masm, src, dst);
-        break;
-
-      case T_DOUBLE:
-        assert( j_arg + 1 < total_args_passed &&
-                in_sig_bt[j_arg + 1] == T_VOID, "bad arg list");
-        double_move(masm, src, dst);
-        break;
-
-      case T_LONG :
-        long_move(masm, src, dst);
-        break;
-
-      case T_ADDRESS: assert(false, "found T_ADDRESS in java args");
-
-      default:
-        simple_move32(masm, src, dst);
-    }
-  }
-
-  // Now we must convert any string we have to utf8
-  //
-
-  for (sid = 0, j_arg = first_arg_to_pass, c_arg = 0 ;
-       sid < total_strings ; j_arg++, c_arg++ ) {
-
-    if (out_sig_bt[c_arg] == T_ADDRESS) {
-
-      Address utf8_addr = Address(
-          rsp, string_locs[sid++] * VMRegImpl::stack_slot_size);
-      __ leal(rax, utf8_addr);
-
-      // The first string we find might still be in the original java arg
-      // register
-      VMReg orig_loc = in_regs[j_arg].first();
-      Register string_oop;
-
-      // This is where the argument will eventually reside
-      Address dest = Address(rsp, reg2offset_out(out_regs[c_arg].first()));
-
-      if (sid == 1 && orig_loc->is_reg()) {
-        string_oop = orig_loc->as_Register();
-        assert(string_oop != rax, "smashed arg");
-      } else {
-
-        if (orig_loc->is_reg()) {
-          // Get the copy of the jls object
-          __ movl(rcx, dest);
-        } else {
-          // arg is still in the original location
-          __ movl(rcx, Address(rbp, reg2offset_in(orig_loc)));
-        }
-        string_oop = rcx;
-
-      }
-      Label nullString;
-      __ movl(dest, NULL_WORD);
-      __ testl(string_oop, string_oop);
-      __ jcc(Assembler::zero, nullString);
-
-      // Now we can store the address of the utf string as the argument
-      __ movl(dest, rax);
-
-      // And do the conversion
-      __ call_VM_leaf(CAST_FROM_FN_PTR(
-             address, SharedRuntime::get_utf), string_oop, rax);
-      __ bind(nullString);
-    }
-
-    if (in_sig_bt[j_arg] == T_OBJECT && out_sig_bt[c_arg] == T_LONG) {
-      assert(out_sig_bt[c_arg+1] == T_VOID, "must be");
-      ++c_arg; // Move over the T_VOID To keep the loop indices in sync
-    }
-  }
-
-
-  // Ok now we are done. Need to place the nop that dtrace wants in order to
-  // patch in the trap
-
-  int patch_offset = ((intptr_t)__ pc()) - start;
-
-  __ nop();
-
-
-  // Return
-
-  __ leave();
-  __ ret(0);
-
-  __ flush();
-
-  nmethod *nm = nmethod::new_dtrace_nmethod(
-      method, masm->code(), vep_offset, patch_offset, frame_complete,
-      stack_slots / VMRegImpl::slots_per_word);
-  return nm;
-
-}
-
-#endif // HAVE_DTRACE_H
-
 // this function returns the adjust size (in number of words) to a c2i adapter
 // activation for use during deoptimization
 int Deoptimization::last_frame_adjust(int callee_parameters, int callee_locals ) {
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -2650,630 +2650,6 @@
 
 }
 
-#ifdef HAVE_DTRACE_H
-// ---------------------------------------------------------------------------
-// Generate a dtrace nmethod for a given signature.  The method takes arguments
-// in the Java compiled code convention, marshals them to the native
-// abi and then leaves nops at the position you would expect to call a native
-// function. When the probe is enabled the nops are replaced with a trap
-// instruction that dtrace inserts and the trace will cause a notification
-// to dtrace.
-//
-// The probes are only able to take primitive types and java/lang/String as
-// arguments.  No other java types are allowed. Strings are converted to utf8
-// strings so that from dtrace point of view java strings are converted to C
-// strings. There is an arbitrary fixed limit on the total space that a method
-// can use for converting the strings. (256 chars per string in the signature).
-// So any java string larger then this is truncated.
-
-static int  fp_offset[ConcreteRegisterImpl::number_of_registers] = { 0 };
-static bool offsets_initialized = false;
-
-
-nmethod *SharedRuntime::generate_dtrace_nmethod(MacroAssembler *masm,
-                                                methodHandle method) {
-
-
-  // generate_dtrace_nmethod is guarded by a mutex so we are sure to
-  // be single threaded in this method.
-  assert(AdapterHandlerLibrary_lock->owned_by_self(), "must be");
-
-  if (!offsets_initialized) {
-    fp_offset[c_rarg0->as_VMReg()->value()] = -1 * wordSize;
-    fp_offset[c_rarg1->as_VMReg()->value()] = -2 * wordSize;
-    fp_offset[c_rarg2->as_VMReg()->value()] = -3 * wordSize;
-    fp_offset[c_rarg3->as_VMReg()->value()] = -4 * wordSize;
-    fp_offset[c_rarg4->as_VMReg()->value()] = -5 * wordSize;
-    fp_offset[c_rarg5->as_VMReg()->value()] = -6 * wordSize;
-
-    fp_offset[c_farg0->as_VMReg()->value()] = -7 * wordSize;
-    fp_offset[c_farg1->as_VMReg()->value()] = -8 * wordSize;
-    fp_offset[c_farg2->as_VMReg()->value()] = -9 * wordSize;
-    fp_offset[c_farg3->as_VMReg()->value()] = -10 * wordSize;
-    fp_offset[c_farg4->as_VMReg()->value()] = -11 * wordSize;
-    fp_offset[c_farg5->as_VMReg()->value()] = -12 * wordSize;
-    fp_offset[c_farg6->as_VMReg()->value()] = -13 * wordSize;
-    fp_offset[c_farg7->as_VMReg()->value()] = -14 * wordSize;
-
-    offsets_initialized = true;
-  }
-  // Fill in the signature array, for the calling-convention call.
-  int total_args_passed = method->size_of_parameters();
-
-  BasicType* in_sig_bt  = NEW_RESOURCE_ARRAY(BasicType, total_args_passed);
-  VMRegPair  *in_regs   = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed);
-
-  // The signature we are going to use for the trap that dtrace will see
-  // java/lang/String is converted. We drop "this" and any other object
-  // is converted to NULL.  (A one-slot java/lang/Long object reference
-  // is converted to a two-slot long, which is why we double the allocation).
-  BasicType* out_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed * 2);
-  VMRegPair* out_regs   = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed * 2);
-
-  int i=0;
-  int total_strings = 0;
-  int first_arg_to_pass = 0;
-  int total_c_args = 0;
-
-  // Skip the receiver as dtrace doesn't want to see it
-  if( !method->is_static() ) {
-    in_sig_bt[i++] = T_OBJECT;
-    first_arg_to_pass = 1;
-  }
-
-  // We need to convert the java args to where a native (non-jni) function
-  // would expect them. To figure out where they go we convert the java
-  // signature to a C signature.
-
-  SignatureStream ss(method->signature());
-  for ( ; !ss.at_return_type(); ss.next()) {
-    BasicType bt = ss.type();
-    in_sig_bt[i++] = bt;  // Collect remaining bits of signature
-    out_sig_bt[total_c_args++] = bt;
-    if( bt == T_OBJECT) {
-      Symbol* s = ss.as_symbol_or_null();   // symbol is created
-      if (s == vmSymbols::java_lang_String()) {
-        total_strings++;
-        out_sig_bt[total_c_args-1] = T_ADDRESS;
-      } else if (s == vmSymbols::java_lang_Boolean() ||
-                 s == vmSymbols::java_lang_Character() ||
-                 s == vmSymbols::java_lang_Byte() ||
-                 s == vmSymbols::java_lang_Short() ||
-                 s == vmSymbols::java_lang_Integer() ||
-                 s == vmSymbols::java_lang_Float()) {
-        out_sig_bt[total_c_args-1] = T_INT;
-      } else if (s == vmSymbols::java_lang_Long() ||
-                 s == vmSymbols::java_lang_Double()) {
-        out_sig_bt[total_c_args-1] = T_LONG;
-        out_sig_bt[total_c_args++] = T_VOID;
-      }
-    } else if ( bt == T_LONG || bt == T_DOUBLE ) {
-      in_sig_bt[i++] = T_VOID;   // Longs & doubles take 2 Java slots
-      // We convert double to long
-      out_sig_bt[total_c_args-1] = T_LONG;
-      out_sig_bt[total_c_args++] = T_VOID;
-    } else if ( bt == T_FLOAT) {
-      // We convert float to int
-      out_sig_bt[total_c_args-1] = T_INT;
-    }
-  }
-
-  assert(i==total_args_passed, "validly parsed signature");
-
-  // Now get the compiled-Java layout as input arguments
-  int comp_args_on_stack;
-  comp_args_on_stack = SharedRuntime::java_calling_convention(
-      in_sig_bt, in_regs, total_args_passed, false);
-
-  // Now figure out where the args must be stored and how much stack space
-  // they require (neglecting out_preserve_stack_slots but space for storing
-  // the 1st six register arguments). It's weird see int_stk_helper.
-
-  int out_arg_slots;
-  out_arg_slots = c_calling_convention(out_sig_bt, out_regs, NULL, total_c_args);
-
-  // Calculate the total number of stack slots we will need.
-
-  // First count the abi requirement plus all of the outgoing args
-  int stack_slots = SharedRuntime::out_preserve_stack_slots() + out_arg_slots;
-
-  // Now space for the string(s) we must convert
-  int* string_locs   = NEW_RESOURCE_ARRAY(int, total_strings + 1);
-  for (i = 0; i < total_strings ; i++) {
-    string_locs[i] = stack_slots;
-    stack_slots += max_dtrace_string_size / VMRegImpl::stack_slot_size;
-  }
-
-  // Plus the temps we might need to juggle register args
-  // regs take two slots each
-  stack_slots += (Argument::n_int_register_parameters_c +
-                  Argument::n_float_register_parameters_c) * 2;
-
-
-  // + 4 for return address (which we own) and saved rbp,
-
-  stack_slots += 4;
-
-  // Ok The space we have allocated will look like:
-  //
-  //
-  // FP-> |                     |
-  //      |---------------------|
-  //      | string[n]           |
-  //      |---------------------| <- string_locs[n]
-  //      | string[n-1]         |
-  //      |---------------------| <- string_locs[n-1]
-  //      | ...                 |
-  //      | ...                 |
-  //      |---------------------| <- string_locs[1]
-  //      | string[0]           |
-  //      |---------------------| <- string_locs[0]
-  //      | outbound memory     |
-  //      | based arguments     |
-  //      |                     |
-  //      |---------------------|
-  //      |                     |
-  // SP-> | out_preserved_slots |
-  //
-  //
-
-  // Now compute actual number of stack words we need rounding to make
-  // stack properly aligned.
-  stack_slots = round_to(stack_slots, 4 * VMRegImpl::slots_per_word);
-
-  int stack_size = stack_slots * VMRegImpl::stack_slot_size;
-
-  intptr_t start = (intptr_t)__ pc();
-
-  // First thing make an ic check to see if we should even be here
-
-  // We are free to use all registers as temps without saving them and
-  // restoring them except rbp. rbp, is the only callee save register
-  // as far as the interpreter and the compiler(s) are concerned.
-
-  const Register ic_reg = rax;
-  const Register receiver = rcx;
-  Label hit;
-  Label exception_pending;
-
-
-  __ verify_oop(receiver);
-  __ cmpl(ic_reg, Address(receiver, oopDesc::klass_offset_in_bytes()));
-  __ jcc(Assembler::equal, hit);
-
-  __ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
-
-  // verified entry must be aligned for code patching.
-  // and the first 5 bytes must be in the same cache line
-  // if we align at 8 then we will be sure 5 bytes are in the same line
-  __ align(8);
-
-  __ bind(hit);
-
-  int vep_offset = ((intptr_t)__ pc()) - start;
-
-
-  // The instruction at the verified entry point must be 5 bytes or longer
-  // because it can be patched on the fly by make_non_entrant. The stack bang
-  // instruction fits that requirement.
-
-  // Generate stack overflow check
-
-  if (UseStackBanging) {
-    if (stack_size <= StackShadowPages*os::vm_page_size()) {
-      __ bang_stack_with_offset(StackShadowPages*os::vm_page_size());
-    } else {
-      __ movl(rax, stack_size);
-      __ bang_stack_size(rax, rbx);
-    }
-  } else {
-    // need a 5 byte instruction to allow MT safe patching to non-entrant
-    __ fat_nop();
-  }
-
-  assert(((uintptr_t)__ pc() - start - vep_offset) >= 5,
-         "valid size for make_non_entrant");
-
-  // Generate a new frame for the wrapper.
-  __ enter();
-
-  // -4 because return address is already present and so is saved rbp,
-  if (stack_size - 2*wordSize != 0) {
-    __ subq(rsp, stack_size - 2*wordSize);
-  }
-
-  // Frame is now completed as far a size and linkage.
-
-  int frame_complete = ((intptr_t)__ pc()) - start;
-
-  int c_arg, j_arg;
-
-  // State of input register args
-
-  bool  live[ConcreteRegisterImpl::number_of_registers];
-
-  live[j_rarg0->as_VMReg()->value()] = false;
-  live[j_rarg1->as_VMReg()->value()] = false;
-  live[j_rarg2->as_VMReg()->value()] = false;
-  live[j_rarg3->as_VMReg()->value()] = false;
-  live[j_rarg4->as_VMReg()->value()] = false;
-  live[j_rarg5->as_VMReg()->value()] = false;
-
-  live[j_farg0->as_VMReg()->value()] = false;
-  live[j_farg1->as_VMReg()->value()] = false;
-  live[j_farg2->as_VMReg()->value()] = false;
-  live[j_farg3->as_VMReg()->value()] = false;
-  live[j_farg4->as_VMReg()->value()] = false;
-  live[j_farg5->as_VMReg()->value()] = false;
-  live[j_farg6->as_VMReg()->value()] = false;
-  live[j_farg7->as_VMReg()->value()] = false;
-
-
-  bool rax_is_zero = false;
-
-  // All args (except strings) destined for the stack are moved first
-  for (j_arg = first_arg_to_pass, c_arg = 0 ;
-       j_arg < total_args_passed ; j_arg++, c_arg++ ) {
-    VMRegPair src = in_regs[j_arg];
-    VMRegPair dst = out_regs[c_arg];
-
-    // Get the real reg value or a dummy (rsp)
-
-    int src_reg = src.first()->is_reg() ?
-                  src.first()->value() :
-                  rsp->as_VMReg()->value();
-
-    bool useless =  in_sig_bt[j_arg] == T_ARRAY ||
-                    (in_sig_bt[j_arg] == T_OBJECT &&
-                     out_sig_bt[c_arg] != T_INT &&
-                     out_sig_bt[c_arg] != T_ADDRESS &&
-                     out_sig_bt[c_arg] != T_LONG);
-
-    live[src_reg] = !useless;
-
-    if (dst.first()->is_stack()) {
-
-      // Even though a string arg in a register is still live after this loop
-      // after the string conversion loop (next) it will be dead so we take
-      // advantage of that now for simpler code to manage live.
-
-      live[src_reg] = false;
-      switch (in_sig_bt[j_arg]) {
-
-        case T_ARRAY:
-        case T_OBJECT:
-          {
-            Address stack_dst(rsp, reg2offset_out(dst.first()));
-
-            if (out_sig_bt[c_arg] == T_INT || out_sig_bt[c_arg] == T_LONG) {
-              // need to unbox a one-word value
-              Register in_reg = rax;
-              if ( src.first()->is_reg() ) {
-                in_reg = src.first()->as_Register();
-              } else {
-                __ movq(rax, Address(rbp, reg2offset_in(src.first())));
-                rax_is_zero = false;
-              }
-              Label skipUnbox;
-              __ movptr(Address(rsp, reg2offset_out(dst.first())),
-                        (int32_t)NULL_WORD);
-              __ testq(in_reg, in_reg);
-              __ jcc(Assembler::zero, skipUnbox);
-
-              BasicType bt = out_sig_bt[c_arg];
-              int box_offset = java_lang_boxing_object::value_offset_in_bytes(bt);
-              Address src1(in_reg, box_offset);
-              if ( bt == T_LONG ) {
-                __ movq(in_reg,  src1);
-                __ movq(stack_dst, in_reg);
-                assert(out_sig_bt[c_arg+1] == T_VOID, "must be");
-                ++c_arg; // skip over T_VOID to keep the loop indices in sync
-              } else {
-                __ movl(in_reg,  src1);
-                __ movl(stack_dst, in_reg);
-              }
-
-              __ bind(skipUnbox);
-            } else if (out_sig_bt[c_arg] != T_ADDRESS) {
-              // Convert the arg to NULL
-              if (!rax_is_zero) {
-                __ xorq(rax, rax);
-                rax_is_zero = true;
-              }
-              __ movq(stack_dst, rax);
-            }
-          }
-          break;
-
-        case T_VOID:
-          break;
-
-        case T_FLOAT:
-          // This does the right thing since we know it is destined for the
-          // stack
-          float_move(masm, src, dst);
-          break;
-
-        case T_DOUBLE:
-          // This does the right thing since we know it is destined for the
-          // stack
-          double_move(masm, src, dst);
-          break;
-
-        case T_LONG :
-          long_move(masm, src, dst);
-          break;
-
-        case T_ADDRESS: assert(false, "found T_ADDRESS in java args");
-
-        default:
-          move32_64(masm, src, dst);
-      }
-    }
-
-  }
-
-  // If we have any strings we must store any register based arg to the stack
-  // This includes any still live xmm registers too.
-
-  int sid = 0;
-
-  if (total_strings > 0 ) {
-    for (j_arg = first_arg_to_pass, c_arg = 0 ;
-         j_arg < total_args_passed ; j_arg++, c_arg++ ) {
-      VMRegPair src = in_regs[j_arg];
-      VMRegPair dst = out_regs[c_arg];
-
-      if (src.first()->is_reg()) {
-        Address src_tmp(rbp, fp_offset[src.first()->value()]);
-
-        // string oops were left untouched by the previous loop even if the
-        // eventual (converted) arg is destined for the stack so park them
-        // away now (except for first)
-
-        if (out_sig_bt[c_arg] == T_ADDRESS) {
-          Address utf8_addr = Address(
-              rsp, string_locs[sid++] * VMRegImpl::stack_slot_size);
-          if (sid != 1) {
-            // The first string arg won't be killed until after the utf8
-            // conversion
-            __ movq(utf8_addr, src.first()->as_Register());
-          }
-        } else if (dst.first()->is_reg()) {
-          if (in_sig_bt[j_arg] == T_FLOAT || in_sig_bt[j_arg] == T_DOUBLE) {
-
-            // Convert the xmm register to an int and store it in the reserved
-            // location for the eventual c register arg
-            XMMRegister f = src.first()->as_XMMRegister();
-            if (in_sig_bt[j_arg] == T_FLOAT) {
-              __ movflt(src_tmp, f);
-            } else {
-              __ movdbl(src_tmp, f);
-            }
-          } else {
-            // If the arg is an oop type we don't support don't bother to store
-            // it remember string was handled above.
-            bool useless =  in_sig_bt[j_arg] == T_ARRAY ||
-                            (in_sig_bt[j_arg] == T_OBJECT &&
-                             out_sig_bt[c_arg] != T_INT &&
-                             out_sig_bt[c_arg] != T_LONG);
-
-            if (!useless) {
-              __ movq(src_tmp, src.first()->as_Register());
-            }
-          }
-        }
-      }
-      if (in_sig_bt[j_arg] == T_OBJECT && out_sig_bt[c_arg] == T_LONG) {
-        assert(out_sig_bt[c_arg+1] == T_VOID, "must be");
-        ++c_arg; // skip over T_VOID to keep the loop indices in sync
-      }
-    }
-
-    // Now that the volatile registers are safe, convert all the strings
-    sid = 0;
-
-    for (j_arg = first_arg_to_pass, c_arg = 0 ;
-         j_arg < total_args_passed ; j_arg++, c_arg++ ) {
-      if (out_sig_bt[c_arg] == T_ADDRESS) {
-        // It's a string
-        Address utf8_addr = Address(
-            rsp, string_locs[sid++] * VMRegImpl::stack_slot_size);
-        // The first string we find might still be in the original java arg
-        // register
-
-        VMReg src = in_regs[j_arg].first();
-
-        // We will need to eventually save the final argument to the trap
-        // in the von-volatile location dedicated to src. This is the offset
-        // from fp we will use.
-        int src_off = src->is_reg() ?
-            fp_offset[src->value()] : reg2offset_in(src);
-
-        // This is where the argument will eventually reside
-        VMRegPair dst = out_regs[c_arg];
-
-        if (src->is_reg()) {
-          if (sid == 1) {
-            __ movq(c_rarg0, src->as_Register());
-          } else {
-            __ movq(c_rarg0, utf8_addr);
-          }
-        } else {
-          // arg is still in the original location
-          __ movq(c_rarg0, Address(rbp, reg2offset_in(src)));
-        }
-        Label done, convert;
-
-        // see if the oop is NULL
-        __ testq(c_rarg0, c_rarg0);
-        __ jcc(Assembler::notEqual, convert);
-
-        if (dst.first()->is_reg()) {
-          // Save the ptr to utf string in the origina src loc or the tmp
-          // dedicated to it
-          __ movq(Address(rbp, src_off), c_rarg0);
-        } else {
-          __ movq(Address(rsp, reg2offset_out(dst.first())), c_rarg0);
-        }
-        __ jmp(done);
-
-        __ bind(convert);
-
-        __ lea(c_rarg1, utf8_addr);
-        if (dst.first()->is_reg()) {
-          __ movq(Address(rbp, src_off), c_rarg1);
-        } else {
-          __ movq(Address(rsp, reg2offset_out(dst.first())), c_rarg1);
-        }
-        // And do the conversion
-        __ call(RuntimeAddress(
-                CAST_FROM_FN_PTR(address, SharedRuntime::get_utf)));
-
-        __ bind(done);
-      }
-      if (in_sig_bt[j_arg] == T_OBJECT && out_sig_bt[c_arg] == T_LONG) {
-        assert(out_sig_bt[c_arg+1] == T_VOID, "must be");
-        ++c_arg; // skip over T_VOID to keep the loop indices in sync
-      }
-    }
-    // The get_utf call killed all the c_arg registers
-    live[c_rarg0->as_VMReg()->value()] = false;
-    live[c_rarg1->as_VMReg()->value()] = false;
-    live[c_rarg2->as_VMReg()->value()] = false;
-    live[c_rarg3->as_VMReg()->value()] = false;
-    live[c_rarg4->as_VMReg()->value()] = false;
-    live[c_rarg5->as_VMReg()->value()] = false;
-
-    live[c_farg0->as_VMReg()->value()] = false;
-    live[c_farg1->as_VMReg()->value()] = false;
-    live[c_farg2->as_VMReg()->value()] = false;
-    live[c_farg3->as_VMReg()->value()] = false;
-    live[c_farg4->as_VMReg()->value()] = false;
-    live[c_farg5->as_VMReg()->value()] = false;
-    live[c_farg6->as_VMReg()->value()] = false;
-    live[c_farg7->as_VMReg()->value()] = false;
-  }
-
-  // Now we can finally move the register args to their desired locations
-
-  rax_is_zero = false;
-
-  for (j_arg = first_arg_to_pass, c_arg = 0 ;
-       j_arg < total_args_passed ; j_arg++, c_arg++ ) {
-
-    VMRegPair src = in_regs[j_arg];
-    VMRegPair dst = out_regs[c_arg];
-
-    // Only need to look for args destined for the interger registers (since we
-    // convert float/double args to look like int/long outbound)
-    if (dst.first()->is_reg()) {
-      Register r =  dst.first()->as_Register();
-
-      // Check if the java arg is unsupported and thereofre useless
-      bool useless =  in_sig_bt[j_arg] == T_ARRAY ||
-                      (in_sig_bt[j_arg] == T_OBJECT &&
-                       out_sig_bt[c_arg] != T_INT &&
-                       out_sig_bt[c_arg] != T_ADDRESS &&
-                       out_sig_bt[c_arg] != T_LONG);
-
-
-      // If we're going to kill an existing arg save it first
-      if (live[dst.first()->value()]) {
-        // you can't kill yourself
-        if (src.first() != dst.first()) {
-          __ movq(Address(rbp, fp_offset[dst.first()->value()]), r);
-        }
-      }
-      if (src.first()->is_reg()) {
-        if (live[src.first()->value()] ) {
-          if (in_sig_bt[j_arg] == T_FLOAT) {
-            __ movdl(r, src.first()->as_XMMRegister());
-          } else if (in_sig_bt[j_arg] == T_DOUBLE) {
-            __ movdq(r, src.first()->as_XMMRegister());
-          } else if (r != src.first()->as_Register()) {
-            if (!useless) {
-              __ movq(r, src.first()->as_Register());
-            }
-          }
-        } else {
-          // If the arg is an oop type we don't support don't bother to store
-          // it
-          if (!useless) {
-            if (in_sig_bt[j_arg] == T_DOUBLE ||
-                in_sig_bt[j_arg] == T_LONG  ||
-                in_sig_bt[j_arg] == T_OBJECT ) {
-              __ movq(r, Address(rbp, fp_offset[src.first()->value()]));
-            } else {
-              __ movl(r, Address(rbp, fp_offset[src.first()->value()]));
-            }
-          }
-        }
-        live[src.first()->value()] = false;
-      } else if (!useless) {
-        // full sized move even for int should be ok
-        __ movq(r, Address(rbp, reg2offset_in(src.first())));
-      }
-
-      // At this point r has the original java arg in the final location
-      // (assuming it wasn't useless). If the java arg was an oop
-      // we have a bit more to do
-
-      if (in_sig_bt[j_arg] == T_ARRAY || in_sig_bt[j_arg] == T_OBJECT ) {
-        if (out_sig_bt[c_arg] == T_INT || out_sig_bt[c_arg] == T_LONG) {
-          // need to unbox a one-word value
-          Label skip;
-          __ testq(r, r);
-          __ jcc(Assembler::equal, skip);
-          BasicType bt = out_sig_bt[c_arg];
-          int box_offset = java_lang_boxing_object::value_offset_in_bytes(bt);
-          Address src1(r, box_offset);
-          if ( bt == T_LONG ) {
-            __ movq(r, src1);
-          } else {
-            __ movl(r, src1);
-          }
-          __ bind(skip);
-
-        } else if (out_sig_bt[c_arg] != T_ADDRESS) {
-          // Convert the arg to NULL
-          __ xorq(r, r);
-        }
-      }
-
-      // dst can longer be holding an input value
-      live[dst.first()->value()] = false;
-    }
-    if (in_sig_bt[j_arg] == T_OBJECT && out_sig_bt[c_arg] == T_LONG) {
-      assert(out_sig_bt[c_arg+1] == T_VOID, "must be");
-      ++c_arg; // skip over T_VOID to keep the loop indices in sync
-    }
-  }
-
-
-  // Ok now we are done. Need to place the nop that dtrace wants in order to
-  // patch in the trap
-  int patch_offset = ((intptr_t)__ pc()) - start;
-
-  __ nop();
-
-
-  // Return
-
-  __ leave();
-  __ ret(0);
-
-  __ flush();
-
-  nmethod *nm = nmethod::new_dtrace_nmethod(
-      method, masm->code(), vep_offset, patch_offset, frame_complete,
-      stack_slots / VMRegImpl::slots_per_word);
-  return nm;
-
-}
-
-#endif // HAVE_DTRACE_H
-
 // this function returns the adjust size (in number of words) to a c2i adapter
 // activation for use during deoptimization
 int Deoptimization::last_frame_adjust(int callee_parameters, int callee_locals ) {
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -924,15 +924,9 @@
   }
 #endif // COMPILER2
 
-  assert(0 <= ReadPrefetchInstr && ReadPrefetchInstr <= 3, "invalid value");
   assert(0 <= AllocatePrefetchInstr && AllocatePrefetchInstr <= 3, "invalid value");
 
   // set valid Prefetch instruction
-  if( ReadPrefetchInstr < 0 ) ReadPrefetchInstr = 0;
-  if( ReadPrefetchInstr > 3 ) ReadPrefetchInstr = 3;
-  if( ReadPrefetchInstr == 3 && !supports_3dnow_prefetch() ) ReadPrefetchInstr = 0;
-  if( !supports_sse() && supports_3dnow_prefetch() ) ReadPrefetchInstr = 3;
-
   if( AllocatePrefetchInstr < 0 ) AllocatePrefetchInstr = 0;
   if( AllocatePrefetchInstr > 3 ) AllocatePrefetchInstr = 3;
   if( AllocatePrefetchInstr == 3 && !supports_3dnow_prefetch() ) AllocatePrefetchInstr=0;
--- a/hotspot/src/cpu/x86/vm/x86_32.ad	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/x86/vm/x86_32.ad	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 //
-// Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+// Copyright (c) 1997, 2015, 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
@@ -6061,103 +6061,9 @@
   ins_pipe( fpu_reg_mem );
 %}
 
-// Prefetch instructions.
+// Prefetch instructions for allocation.
 // Must be safe to execute with invalid address (cannot fault).
 
-instruct prefetchr0( memory mem ) %{
-  predicate(UseSSE==0 && !VM_Version::supports_3dnow_prefetch());
-  match(PrefetchRead mem);
-  ins_cost(0);
-  size(0);
-  format %{ "PREFETCHR (non-SSE is empty encoding)" %}
-  ins_encode();
-  ins_pipe(empty);
-%}
-
-instruct prefetchr( memory mem ) %{
-  predicate(UseSSE==0 && VM_Version::supports_3dnow_prefetch() || ReadPrefetchInstr==3);
-  match(PrefetchRead mem);
-  ins_cost(100);
-
-  format %{ "PREFETCHR $mem\t! Prefetch into level 1 cache for read" %}
-  ins_encode %{
-    __ prefetchr($mem$$Address);
-  %}
-  ins_pipe(ialu_mem);
-%}
-
-instruct prefetchrNTA( memory mem ) %{
-  predicate(UseSSE>=1 && ReadPrefetchInstr==0);
-  match(PrefetchRead mem);
-  ins_cost(100);
-
-  format %{ "PREFETCHNTA $mem\t! Prefetch into non-temporal cache for read" %}
-  ins_encode %{
-    __ prefetchnta($mem$$Address);
-  %}
-  ins_pipe(ialu_mem);
-%}
-
-instruct prefetchrT0( memory mem ) %{
-  predicate(UseSSE>=1 && ReadPrefetchInstr==1);
-  match(PrefetchRead mem);
-  ins_cost(100);
-
-  format %{ "PREFETCHT0 $mem\t! Prefetch into L1 and L2 caches for read" %}
-  ins_encode %{
-    __ prefetcht0($mem$$Address);
-  %}
-  ins_pipe(ialu_mem);
-%}
-
-instruct prefetchrT2( memory mem ) %{
-  predicate(UseSSE>=1 && ReadPrefetchInstr==2);
-  match(PrefetchRead mem);
-  ins_cost(100);
-
-  format %{ "PREFETCHT2 $mem\t! Prefetch into L2 cache for read" %}
-  ins_encode %{
-    __ prefetcht2($mem$$Address);
-  %}
-  ins_pipe(ialu_mem);
-%}
-
-instruct prefetchw0( memory mem ) %{
-  predicate(UseSSE==0 && !VM_Version::supports_3dnow_prefetch());
-  match(PrefetchWrite mem);
-  ins_cost(0);
-  size(0);
-  format %{ "Prefetch (non-SSE is empty encoding)" %}
-  ins_encode();
-  ins_pipe(empty);
-%}
-
-instruct prefetchw( memory mem ) %{
-  predicate(UseSSE==0 && VM_Version::supports_3dnow_prefetch());
-  match( PrefetchWrite mem );
-  ins_cost(100);
-
-  format %{ "PREFETCHW $mem\t! Prefetch into L1 cache and mark modified" %}
-  ins_encode %{
-    __ prefetchw($mem$$Address);
-  %}
-  ins_pipe(ialu_mem);
-%}
-
-instruct prefetchwNTA( memory mem ) %{
-  predicate(UseSSE>=1);
-  match(PrefetchWrite mem);
-  ins_cost(100);
-
-  format %{ "PREFETCHNTA $mem\t! Prefetch into non-temporal cache for write" %}
-  ins_encode %{
-    __ prefetchnta($mem$$Address);
-  %}
-  ins_pipe(ialu_mem);
-%}
-
-// Prefetch instructions for allocation.
-
 instruct prefetchAlloc0( memory mem ) %{
   predicate(UseSSE==0 && AllocatePrefetchInstr!=3);
   match(PrefetchAllocation mem);
--- a/hotspot/src/cpu/x86/vm/x86_64.ad	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/cpu/x86/vm/x86_64.ad	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 //
-// Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+// Copyright (c) 2003, 2015, 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
@@ -5319,70 +5319,9 @@
   ins_pipe(pipe_slow); // XXX
 %}
 
-// Prefetch instructions.
+// Prefetch instructions for allocation.
 // Must be safe to execute with invalid address (cannot fault).
 
-instruct prefetchr( memory mem ) %{
-  predicate(ReadPrefetchInstr==3);
-  match(PrefetchRead mem);
-  ins_cost(125);
-
-  format %{ "PREFETCHR $mem\t# Prefetch into level 1 cache" %}
-  ins_encode %{
-    __ prefetchr($mem$$Address);
-  %}
-  ins_pipe(ialu_mem);
-%}
-
-instruct prefetchrNTA( memory mem ) %{
-  predicate(ReadPrefetchInstr==0);
-  match(PrefetchRead mem);
-  ins_cost(125);
-
-  format %{ "PREFETCHNTA $mem\t# Prefetch into non-temporal cache for read" %}
-  ins_encode %{
-    __ prefetchnta($mem$$Address);
-  %}
-  ins_pipe(ialu_mem);
-%}
-
-instruct prefetchrT0( memory mem ) %{
-  predicate(ReadPrefetchInstr==1);
-  match(PrefetchRead mem);
-  ins_cost(125);
-
-  format %{ "PREFETCHT0 $mem\t# prefetch into L1 and L2 caches for read" %}
-  ins_encode %{
-    __ prefetcht0($mem$$Address);
-  %}
-  ins_pipe(ialu_mem);
-%}
-
-instruct prefetchrT2( memory mem ) %{
-  predicate(ReadPrefetchInstr==2);
-  match(PrefetchRead mem);
-  ins_cost(125);
-
-  format %{ "PREFETCHT2 $mem\t# prefetch into L2 caches for read" %}
-  ins_encode %{
-    __ prefetcht2($mem$$Address);
-  %}
-  ins_pipe(ialu_mem);
-%}
-
-instruct prefetchwNTA( memory mem ) %{
-  match(PrefetchWrite mem);
-  ins_cost(125);
-
-  format %{ "PREFETCHNTA $mem\t# Prefetch to non-temporal cache for write" %}
-  ins_encode %{
-    __ prefetchnta($mem$$Address);
-  %}
-  ins_pipe(ialu_mem);
-%}
-
-// Prefetch instructions for allocation.
-
 instruct prefetchAlloc( memory mem ) %{
   predicate(AllocatePrefetchInstr==3);
   match(PrefetchAllocation mem);
--- a/hotspot/src/os/aix/vm/vmError_aix.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/os/aix/vm/vmError_aix.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -80,7 +80,6 @@
 }
 
 int VMError::get_resetted_sigflags(int sig) {
-  // Handle all program errors.
   for (int i = 0; i < NUM_SIGNALS; i++) {
     if (SIGNALS[i] == sig) {
       return resettedSigflags[i];
@@ -90,7 +89,6 @@
 }
 
 address VMError::get_resetted_sighandler(int sig) {
-  // Handle all program errors.
   for (int i = 0; i < NUM_SIGNALS; i++) {
     if (SIGNALS[i] == sig) {
       return resettedSighandler[i];
@@ -100,12 +98,19 @@
 }
 
 static void crash_handler(int sig, siginfo_t* info, void* ucVoid) {
+
   // Unmask current signal.
   sigset_t newset;
   sigemptyset(&newset);
   sigaddset(&newset, sig);
+  // and all other synchronous signals too.
+  for (int i = 0; i < NUM_SIGNALS; i++) {
+    sigaddset(&newset, SIGNALS[i]);
+  }
+  sigthreadmask(SIG_UNBLOCK, &newset, NULL);
 
-  Unimplemented();
+  VMError err(NULL, sig, NULL, info, ucVoid);
+  err.report_and_die();
 }
 
 void VMError::reset_signal_handlers() {
--- a/hotspot/src/os/bsd/vm/dtraceJSDT_bsd.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "classfile/javaClasses.hpp"
-#include "code/codeBlob.hpp"
-#include "memory/allocation.hpp"
-#include "prims/jvm.h"
-#include "runtime/dtraceJSDT.hpp"
-#include "runtime/jniHandles.hpp"
-#include "runtime/os.hpp"
-#include "runtime/signature.hpp"
-#include "utilities/globalDefinitions.hpp"
-
-/*
- * JSDT java dtrace probes have never been implemented in macosx.  It is unknown if the solaris implementation
- * is close or if significant implementation work is necessary.  The future of the solaris implementation also
- * appears to be unclear since compiling code with JSDT probes produces the following warning:
- * "warning: ProviderFactory is internal proprietary API and may be removed in a future release"
- */
-
-int DTraceJSDT::pd_activate(
-    void* baseAddress, jstring module,
-    jint providers_count, JVM_DTraceProvider* providers) {
-  return -1;
-}
-
-void DTraceJSDT::pd_dispose(int handle) {
-}
-
-jboolean DTraceJSDT::pd_is_supported() {
-  return false;
-}
--- a/hotspot/src/os/bsd/vm/vmError_bsd.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/os/bsd/vm/vmError_bsd.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -63,9 +63,15 @@
   } while (yes);
 }
 
+// handle all synchronous program error signals which may happen during error
+// reporting. They must be unblocked, caught, handled.
+
+static const int SIGNALS[] = { SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP }; // add more if needed
+static const int NUM_SIGNALS = sizeof(SIGNALS) / sizeof(int);
+
 // Space for our "saved" signal flags and handlers
-static int resettedSigflags[2];
-static address resettedSighandler[2];
+static int resettedSigflags[NUM_SIGNALS];
+static address resettedSighandler[NUM_SIGNALS];
 
 static void save_signal(int idx, int sig)
 {
@@ -78,19 +84,19 @@
 }
 
 int VMError::get_resetted_sigflags(int sig) {
-  if(SIGSEGV == sig) {
-    return resettedSigflags[0];
-  } else if(SIGBUS == sig) {
-    return resettedSigflags[1];
+  for (int i = 0; i < NUM_SIGNALS; i++) {
+    if (SIGNALS[i] == sig) {
+      return resettedSigflags[i];
+    }
   }
   return -1;
 }
 
 address VMError::get_resetted_sighandler(int sig) {
-  if(SIGSEGV == sig) {
-    return resettedSighandler[0];
-  } else if(SIGBUS == sig) {
-    return resettedSighandler[1];
+  for (int i = 0; i < NUM_SIGNALS; i++) {
+    if (SIGNALS[i] == sig) {
+      return resettedSighandler[i];
+    }
   }
   return NULL;
 }
@@ -100,16 +106,25 @@
   sigset_t newset;
   sigemptyset(&newset);
   sigaddset(&newset, sig);
-  sigprocmask(SIG_UNBLOCK, &newset, NULL);
+  // also unmask other synchronous signals
+  for (int i = 0; i < NUM_SIGNALS; i++) {
+    sigaddset(&newset, SIGNALS[i]);
+  }
+  pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
 
   VMError err(NULL, sig, NULL, info, ucVoid);
   err.report_and_die();
 }
 
 void VMError::reset_signal_handlers() {
-  // Save sigflags for resetted signals
-  save_signal(0, SIGSEGV);
-  save_signal(1, SIGBUS);
-  os::signal(SIGSEGV, CAST_FROM_FN_PTR(void *, crash_handler));
-  os::signal(SIGBUS, CAST_FROM_FN_PTR(void *, crash_handler));
+  // install signal handlers for all synchronous program error signals
+  sigset_t newset;
+  sigemptyset(&newset);
+
+  for (int i = 0; i < NUM_SIGNALS; i++) {
+    save_signal(i, SIGNALS[i]);
+    os::signal(SIGNALS[i], CAST_FROM_FN_PTR(void *, crash_handler));
+    sigaddset(&newset, SIGNALS[i]);
+  }
+  pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
 }
--- a/hotspot/src/os/linux/vm/dtraceJSDT_linux.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "classfile/javaClasses.hpp"
-#include "code/codeBlob.hpp"
-#include "memory/allocation.hpp"
-#include "prims/jvm.h"
-#include "runtime/dtraceJSDT.hpp"
-#include "runtime/jniHandles.hpp"
-#include "runtime/os.hpp"
-#include "runtime/signature.hpp"
-#include "utilities/globalDefinitions.hpp"
-
-int DTraceJSDT::pd_activate(
-    void* baseAddress, jstring module,
-    jint providers_count, JVM_DTraceProvider* providers) {
-  return -1;
-}
-
-void DTraceJSDT::pd_dispose(int handle) {
-}
-
-jboolean DTraceJSDT::pd_is_supported() {
-  return false;
-}
--- a/hotspot/src/os/linux/vm/vmError_linux.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/os/linux/vm/vmError_linux.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -63,9 +63,15 @@
   } while (yes);
 }
 
+// handle all synchronous program error signals which may happen during error
+// reporting. They must be unblocked, caught, handled.
+
+static const int SIGNALS[] = { SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP }; // add more if needed
+static const int NUM_SIGNALS = sizeof(SIGNALS) / sizeof(int);
+
 // Space for our "saved" signal flags and handlers
-static int resettedSigflags[2];
-static address resettedSighandler[2];
+static int resettedSigflags[NUM_SIGNALS];
+static address resettedSighandler[NUM_SIGNALS];
 
 static void save_signal(int idx, int sig)
 {
@@ -78,19 +84,19 @@
 }
 
 int VMError::get_resetted_sigflags(int sig) {
-  if(SIGSEGV == sig) {
-    return resettedSigflags[0];
-  } else if(SIGBUS == sig) {
-    return resettedSigflags[1];
+  for (int i = 0; i < NUM_SIGNALS; i++) {
+    if (SIGNALS[i] == sig) {
+      return resettedSigflags[i];
+    }
   }
   return -1;
 }
 
 address VMError::get_resetted_sighandler(int sig) {
-  if(SIGSEGV == sig) {
-    return resettedSighandler[0];
-  } else if(SIGBUS == sig) {
-    return resettedSighandler[1];
+  for (int i = 0; i < NUM_SIGNALS; i++) {
+    if (SIGNALS[i] == sig) {
+      return resettedSighandler[i];
+    }
   }
   return NULL;
 }
@@ -100,16 +106,26 @@
   sigset_t newset;
   sigemptyset(&newset);
   sigaddset(&newset, sig);
-  sigprocmask(SIG_UNBLOCK, &newset, NULL);
+  // also unmask other synchronous signals
+  for (int i = 0; i < NUM_SIGNALS; i++) {
+    sigaddset(&newset, SIGNALS[i]);
+  }
+  pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
 
   VMError err(NULL, sig, NULL, info, ucVoid);
   err.report_and_die();
 }
 
 void VMError::reset_signal_handlers() {
-  // Save sigflags for resetted signals
-  save_signal(0, SIGSEGV);
-  save_signal(1, SIGBUS);
-  os::signal(SIGSEGV, CAST_FROM_FN_PTR(void *, crash_handler));
-  os::signal(SIGBUS, CAST_FROM_FN_PTR(void *, crash_handler));
+  // install signal handlers for all synchronous program error signals
+  sigset_t newset;
+  sigemptyset(&newset);
+
+  for (int i = 0; i < NUM_SIGNALS; i++) {
+    save_signal(i, SIGNALS[i]);
+    os::signal(SIGNALS[i], CAST_FROM_FN_PTR(void *, crash_handler));
+    sigaddset(&newset, SIGNALS[i]);
+  }
+  pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
+
 }
--- a/hotspot/src/os/solaris/vm/dtraceJSDT_solaris.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,655 +0,0 @@
-/*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "classfile/javaClasses.hpp"
-#include "code/codeBlob.hpp"
-#include "memory/allocation.hpp"
-#include "prims/jvm.h"
-#include "runtime/dtraceJSDT.hpp"
-#include "runtime/jniHandles.hpp"
-#include "runtime/os.hpp"
-#include "runtime/signature.hpp"
-#include "utilities/globalDefinitions.hpp"
-
-#ifdef HAVE_DTRACE_H
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <dtrace.h>
-
-static const char* devname    = "/dev/dtrace/helper";
-static const char* olddevname = "/devices/pseudo/dtrace@0:helper";
-
-static const char* string_sig = "uintptr_t";
-static const char* int_sig    = "long";
-static const char* long_sig   = "long long";
-
-static void printDOFHelper(dof_helper_t* helper);
-
-static int dofhelper_open() {
-  int fd;
-  if ((fd = open64(devname, O_RDWR)) < 0) {
-    // Optimize next calls
-    devname = olddevname;
-    if ((fd = open64(devname, O_RDWR)) < 0) {
-      return -1;
-    }
-  }
-  return fd;
-}
-
-static jint dof_register(jstring module, uint8_t* dof, void* modaddr) {
-  int probe;
-  dof_helper_t dh;
-  int fd;
-
-  memset(&dh, 0, sizeof(dh));
-
-  char* module_name = java_lang_String::as_utf8_string(
-        JNIHandles::resolve_non_null(module));
-  jio_snprintf(dh.dofhp_mod, sizeof(dh.dofhp_mod), "%s", module_name);
-  dh.dofhp_dof  = (uint64_t)dof;
-  dh.dofhp_addr = (uint64_t)modaddr;
-
-  fd = dofhelper_open();
-  if (fd < 0)
-    return -1;
-  probe = ioctl(fd, DTRACEHIOC_ADDDOF, &dh);
-  close(fd);
-  if (PrintDTraceDOF) {
-    printDOFHelper(&dh);
-    tty->print_cr("DOF helper id = %d", probe);
-  }
-  return probe;
-}
-
-int DTraceJSDT::pd_activate(
-    void* moduleBaseAddress, jstring module,
-    jint providers_count, JVM_DTraceProvider* providers) {
-
-  // We need sections:
-  //  (1) STRTAB
-  //  (
-  //    (2) PROVIDER
-  //    (3) PROBES
-  //    (4) PROBOFFS
-  //    (5) PROBARGS
-  //  ) * Number of Providers
-
-  // Type of sections we create
-  enum {
-    STRTAB = 0,
-    PROVIDERS = 1,
-    PROBES = 2,
-    PROBE_OFFSETS = 3,
-    ARG_OFFSETS = 4,
-    NUM_SECTIONS = 5
-  };
-
-  static int alignment_for[NUM_SECTIONS] = { 1, 4, 8, 4, 1 };
-
-  ResourceMark rm;
-
-  uint32_t num_sections = 1 + 4 * providers_count;
-  uint32_t offset = sizeof(dof_hdr_t) + (num_sections * sizeof(dof_sec_t));
-  uint32_t* secoffs = NEW_RESOURCE_ARRAY(uint32_t, num_sections);
-  uint32_t* secsize = NEW_RESOURCE_ARRAY(uint32_t, num_sections);
-
-  // Store offsets of all strings here in such order:
-  //  zero-string (always 0)
-  //  provider1-name
-  //    probe1-function
-  //    probe1-name
-  //    arg-1
-  //    arg-2
-  //    ...
-  //    probe2-function
-  //    probe2-name
-  //    arg-1
-  //    arg-2
-  //  provider2-name
-  //    ...
-
-  uint32_t strcount  = 0;
-  // Count the number of strings we'll need
-  for(int prvc = 0; prvc < providers_count; ++prvc) {
-    JVM_DTraceProvider* provider = &providers[prvc];
-    // Provider name
-    ++strcount;
-    for(int prbc = 0; prbc < provider->probe_count; ++prbc) {
-      JVM_DTraceProbe* p = &(provider->probes[prbc]);
-      Symbol* sig = Method::resolve_jmethod_id(p->method)->signature();
-      // function + name + one per argument
-      strcount += 2 + ArgumentCount(sig).size();
-    }
-  }
-
-  // Create place for string offsets
-  uint32_t* stroffs = NEW_RESOURCE_ARRAY(uint32_t, strcount + 1);
-  uint32_t string_index = 0;
-  uint32_t curstr = 0;
-
-  // First we need an empty string: ""
-  stroffs[curstr++] = string_index;
-  string_index += strlen("") + 1;
-
-  for(int prvc = 0; prvc < providers_count; ++prvc) {
-    JVM_DTraceProvider* provider = &providers[prvc];
-    char* provider_name = java_lang_String::as_utf8_string(
-        JNIHandles::resolve_non_null(provider->name));
-    stroffs[curstr++] = string_index;
-    string_index += strlen(provider_name) + 1;
-
-    // All probes
-    for(int prbc = 0; prbc < provider->probe_count; ++prbc) {
-      JVM_DTraceProbe* p = &(provider->probes[prbc]);
-
-      char* function = java_lang_String::as_utf8_string(
-          JNIHandles::resolve_non_null(p->function));
-      stroffs[curstr++] = string_index;
-      string_index += strlen(function) + 1;
-
-      char* name = java_lang_String::as_utf8_string(
-          JNIHandles::resolve_non_null(p->name));
-      stroffs[curstr++] = string_index;
-      string_index += strlen(name) + 1;
-
-      Symbol* sig = Method::resolve_jmethod_id(p->method)->signature();
-      SignatureStream ss(sig);
-      for ( ; !ss.at_return_type(); ss.next()) {
-        BasicType bt = ss.type();
-        const char* t = NULL;
-        if (bt == T_OBJECT &&
-            ss.as_symbol_or_null() == vmSymbols::java_lang_String()) {
-          t = string_sig;
-        } else if (bt == T_LONG) {
-          t = long_sig;
-        } else {
-          t = int_sig;
-        }
-        stroffs[curstr++] = string_index;
-        string_index += strlen(t) + 1;
-      }
-    }
-  }
-  secoffs[STRTAB] = offset;
-  secsize[STRTAB] = string_index;
-  offset += string_index;
-
-  // Calculate the size of the rest
-  for(int prvc = 0; prvc < providers_count; ++prvc) {
-    JVM_DTraceProvider* provider = &providers[prvc];
-    size_t provider_sec  = PROVIDERS     + prvc * 4;
-    size_t probe_sec     = PROBES        + prvc * 4;
-    size_t probeoffs_sec = PROBE_OFFSETS + prvc * 4;
-    size_t argoffs_sec   = ARG_OFFSETS   + prvc * 4;
-
-    // Allocate space for the provider data struction
-    secoffs[provider_sec] = align_size_up(offset, alignment_for[PROVIDERS]);
-    secsize[provider_sec] = sizeof(dof_provider_t);
-    offset = secoffs[provider_sec] + secsize[provider_sec];
-
-    // Allocate space for all the probes
-    secoffs[probe_sec] = align_size_up(offset, alignment_for[PROBES]);
-    secsize[probe_sec] = sizeof(dof_probe_t) * provider->probe_count;
-    offset = secoffs[probe_sec] + secsize[probe_sec];
-
-    // Allocate space for the probe offsets
-    secoffs[probeoffs_sec] = align_size_up(offset, alignment_for[PROBE_OFFSETS]);
-    secsize[probeoffs_sec] = sizeof(uint32_t) * provider->probe_count;
-    offset = secoffs[probeoffs_sec] + secsize[probeoffs_sec];
-
-    // We need number of arguments argoffs
-    uint32_t argscount = 0;
-    for(int prbc = 0; prbc < provider->probe_count; ++prbc) {
-       JVM_DTraceProbe* p = &(provider->probes[prbc]);
-       Symbol* sig = Method::resolve_jmethod_id(p->method)->signature();
-       argscount += ArgumentCount(sig).size();
-    }
-    secoffs[argoffs_sec] = align_size_up(offset, alignment_for[ARG_OFFSETS]);
-    secsize[argoffs_sec] = sizeof(uint8_t) * argscount;
-    offset = secoffs[argoffs_sec] + secsize[argoffs_sec];
-  }
-
-  uint32_t size = offset;
-
-  uint8_t* dof = NEW_RESOURCE_ARRAY(uint8_t, size);
-  if (!dof) {
-    return -1;
-  }
-  memset((void*)dof, 0, size);
-
-  // Fill memory with proper values
-  dof_hdr_t* hdr = (dof_hdr_t*)dof;
-  hdr->dofh_ident[DOF_ID_MAG0]     = DOF_MAG_MAG0;
-  hdr->dofh_ident[DOF_ID_MAG1]     = DOF_MAG_MAG1;
-  hdr->dofh_ident[DOF_ID_MAG2]     = DOF_MAG_MAG2;
-  hdr->dofh_ident[DOF_ID_MAG3]     = DOF_MAG_MAG3;
-  hdr->dofh_ident[DOF_ID_MODEL]    = DOF_MODEL_NATIVE;  // No variants
-  hdr->dofh_ident[DOF_ID_ENCODING] = DOF_ENCODE_NATIVE; // No variants
-  hdr->dofh_ident[DOF_ID_VERSION]  = DOF_VERSION_1;     // No variants
-  hdr->dofh_ident[DOF_ID_DIFVERS]  = DIF_VERSION_2;     // No variants
-  // all other fields of ident to zero
-
-  hdr->dofh_flags   = 0;
-  hdr->dofh_hdrsize = sizeof(dof_hdr_t);
-  hdr->dofh_secsize = sizeof(dof_sec_t);
-  hdr->dofh_secnum  = num_sections;
-  hdr->dofh_secoff  = sizeof(dof_hdr_t);
-  hdr->dofh_loadsz  = size;
-  hdr->dofh_filesz  = size;
-
-  // First section: STRTAB
-  dof_sec_t* sec = (dof_sec_t*)(dof + sizeof(dof_hdr_t));
-  sec->dofs_type    = DOF_SECT_STRTAB;
-  sec->dofs_align   = alignment_for[STRTAB];
-  sec->dofs_flags   = DOF_SECF_LOAD;
-  sec->dofs_entsize = 0;
-  sec->dofs_offset  = secoffs[STRTAB];
-  sec->dofs_size    = secsize[STRTAB];
-  // Make data for this section
-  char* str = (char*)(dof + sec->dofs_offset);
-
-  *str = 0; str += 1; // ""
-
-  // Run through all strings again
-  for(int prvc = 0; prvc < providers_count; ++prvc) {
-    JVM_DTraceProvider* provider = &providers[prvc];
-    char* provider_name = java_lang_String::as_utf8_string(
-        JNIHandles::resolve_non_null(provider->name));
-    strcpy(str, provider_name);
-    str += strlen(provider_name) + 1;
-
-    // All probes
-    for(int prbc = 0; prbc < provider->probe_count; ++prbc) {
-      JVM_DTraceProbe* p = &(provider->probes[prbc]);
-
-      char* function = java_lang_String::as_utf8_string(
-          JNIHandles::resolve_non_null(p->function));
-      strcpy(str, function);
-      str += strlen(str) + 1;
-
-      char* name = java_lang_String::as_utf8_string(
-          JNIHandles::resolve_non_null(p->name));
-      strcpy(str, name);
-      str += strlen(name) + 1;
-
-      Symbol* sig = Method::resolve_jmethod_id(p->method)->signature();
-      SignatureStream ss(sig);
-      for ( ; !ss.at_return_type(); ss.next()) {
-        BasicType bt = ss.type();
-        const char* t;
-        if (bt == T_OBJECT &&
-            ss.as_symbol_or_null() == vmSymbols::java_lang_String()) {
-          t = string_sig;
-        } else if (bt == T_LONG) {
-          t = long_sig;
-        } else {
-          t = int_sig;
-        }
-        strcpy(str, t);
-        str += strlen(t) + 1;
-      }
-    }
-  }
-
-  curstr = 1;
-  for(int prvc = 0; prvc < providers_count; ++prvc) {
-    JVM_DTraceProvider* provider = &providers[prvc];
-    size_t provider_sec  = PROVIDERS     + prvc * 4;
-    size_t probe_sec     = PROBES        + prvc * 4;
-    size_t probeoffs_sec = PROBE_OFFSETS + prvc * 4;
-    size_t argoffs_sec   = ARG_OFFSETS   + prvc * 4;
-
-    // PROVIDER ///////////////////////////////////////////////////////////////
-    // Section header
-    sec = (dof_sec_t*)
-        (dof + sizeof(dof_hdr_t) + sizeof(dof_sec_t) * provider_sec);
-    sec->dofs_type    = DOF_SECT_PROVIDER;
-    sec->dofs_align   = alignment_for[PROVIDERS];
-    sec->dofs_flags   = DOF_SECF_LOAD;
-    sec->dofs_entsize = 0;
-    sec->dofs_offset  = secoffs[provider_sec];
-    sec->dofs_size    = secsize[provider_sec];
-    // Make provider decriiption
-    dof_provider_t* prv = (dof_provider_t*)(dof + sec->dofs_offset);
-    prv->dofpv_strtab   = STRTAB;
-    prv->dofpv_probes   = probe_sec;
-    prv->dofpv_prargs   = argoffs_sec;
-    prv->dofpv_proffs   = probeoffs_sec;
-    prv->dofpv_name     = stroffs[curstr++]; // Index in string table
-    prv->dofpv_provattr = DOF_ATTR(
-        provider->providerAttributes.nameStability,
-        provider->providerAttributes.dataStability,
-        provider->providerAttributes.dependencyClass);
-    prv->dofpv_modattr = DOF_ATTR(
-        provider->moduleAttributes.nameStability,
-        provider->moduleAttributes.dataStability,
-        provider->moduleAttributes.dependencyClass);
-    prv->dofpv_funcattr = DOF_ATTR(
-        provider->functionAttributes.nameStability,
-        provider->functionAttributes.dataStability,
-        provider->functionAttributes.dependencyClass);
-    prv->dofpv_nameattr = DOF_ATTR(
-        provider->nameAttributes.nameStability,
-        provider->nameAttributes.dataStability,
-        provider->nameAttributes.dependencyClass);
-    prv->dofpv_argsattr = DOF_ATTR(
-        provider->argsAttributes.nameStability,
-        provider->argsAttributes.dataStability,
-        provider->argsAttributes.dependencyClass);
-
-    // PROBES /////////////////////////////////////////////////////////////////
-    // Section header
-    sec = (dof_sec_t*)
-        (dof + sizeof(dof_hdr_t) + sizeof(dof_sec_t) * probe_sec);
-    sec->dofs_type    = DOF_SECT_PROBES;
-    sec->dofs_align   = alignment_for[PROBES];
-    sec->dofs_flags   = DOF_SECF_LOAD;
-    sec->dofs_entsize = sizeof(dof_probe_t);
-    sec->dofs_offset  = secoffs[probe_sec];
-    sec->dofs_size    = secsize[probe_sec];
-    // Make probes descriptions
-    uint32_t argsoffs = 0;
-    for(int prbc = 0; prbc < provider->probe_count; ++prbc) {
-      JVM_DTraceProbe* probe = &(provider->probes[prbc]);
-      Method* m = Method::resolve_jmethod_id(probe->method);
-      int arg_count = ArgumentCount(m->signature()).size();
-      assert(m->code() != NULL, "must have an nmethod");
-
-      dof_probe_t* prb =
-         (dof_probe_t*)(dof + sec->dofs_offset + prbc * sizeof(dof_probe_t));
-
-      prb->dofpr_addr   = (uint64_t)m->code()->entry_point();
-      prb->dofpr_func   = stroffs[curstr++]; // Index in string table
-      prb->dofpr_name   = stroffs[curstr++]; // Index in string table
-      prb->dofpr_nargv  = stroffs[curstr  ]; // Index in string table
-      // We spent siglen strings here
-      curstr += arg_count;
-      prb->dofpr_xargv  = prb->dofpr_nargv;  // Same bunch of strings
-      prb->dofpr_argidx = argsoffs;
-      prb->dofpr_offidx = prbc;
-      prb->dofpr_nargc  = arg_count;
-      prb->dofpr_xargc  = arg_count;
-      prb->dofpr_noffs  = 1; // Number of offsets
-      // Next bunch of offsets
-      argsoffs += arg_count;
-    }
-
-    // PROFFS /////////////////////////////////////////////////////////////////
-    // Section header
-    sec = (dof_sec_t*)
-        (dof + sizeof(dof_hdr_t) + sizeof(dof_sec_t) * probeoffs_sec);
-    sec->dofs_type    = DOF_SECT_PROFFS;
-    sec->dofs_align   = alignment_for[PROBE_OFFSETS];
-    sec->dofs_flags   = DOF_SECF_LOAD;
-    sec->dofs_entsize = sizeof(uint32_t);
-    sec->dofs_offset  = secoffs[probeoffs_sec];
-    sec->dofs_size    = secsize[probeoffs_sec];
-    // Make offsets
-    for (int prbc = 0; prbc < provider->probe_count; ++prbc) {
-      uint32_t* pof =
-          (uint32_t*)(dof + sec->dofs_offset + sizeof(uint32_t) * prbc);
-      JVM_DTraceProbe* probe = &(provider->probes[prbc]);
-      Method* m = Method::resolve_jmethod_id(probe->method);
-      *pof = m->code()->trap_offset();
-    }
-
-    // PRARGS /////////////////////////////////////////////////////////////////
-    // Section header
-    sec = (dof_sec_t*)
-        (dof + sizeof(dof_hdr_t) + sizeof(dof_sec_t) * argoffs_sec);
-    sec->dofs_type    = DOF_SECT_PRARGS;
-    sec->dofs_align   = alignment_for[ARG_OFFSETS];
-    sec->dofs_flags   = DOF_SECF_LOAD;
-    sec->dofs_entsize = sizeof(uint8_t);
-    sec->dofs_offset  = secoffs[argoffs_sec];
-    sec->dofs_size    = secsize[argoffs_sec];
-    // Make arguments
-    uint8_t* par = (uint8_t*)(dof + sec->dofs_offset);
-    for (int prbc = 0; prbc < provider->probe_count; ++prbc) {
-      JVM_DTraceProbe* p = &(provider->probes[prbc]);
-      Symbol* sig = Method::resolve_jmethod_id(p->method)->signature();
-      uint8_t count = (uint8_t)ArgumentCount(sig).size();
-      for (uint8_t i = 0; i < count; ++i) {
-        *par++ = i;
-      }
-    }
-  }
-
-  // Register module
-  return dof_register(module, dof, moduleBaseAddress);
-}
-
-
-void DTraceJSDT::pd_dispose(int handle) {
-  int fd;
-  if (handle == -1) {
-    return;
-  }
-  fd = dofhelper_open();
-  if (fd < 0)
-    return;
-  ioctl(fd, DTRACEHIOC_REMOVE, handle);
-  close(fd);
-}
-
-jboolean DTraceJSDT::pd_is_supported() {
-  int fd = dofhelper_open();
-  if (fd < 0) {
-    return false;
-  }
-  close(fd);
-  return true;
-}
-
-static const char* dofSecTypeFor(uint32_t type) {
-  switch (type) {
-    case 0:  return "DOF_SECT_NONE";
-    case 1:  return "DOF_SECT_COMMENTS";
-    case 2:  return "DOF_SECT_SOURCE";
-    case 3:  return "DOF_SECT_ECBDESC";
-    case 4:  return "DOF_SECT_PROBEDESC";
-    case 5:  return "DOF_SECT_ACTDESC";
-    case 6:  return "DOF_SECT_DIFOHDR";
-    case 7:  return "DOF_SECT_DIF";
-    case 8:  return "DOF_SECT_STRTAB";
-    case 9:  return "DOF_SECT_VARTAB";
-    case 10: return "DOF_SECT_RELTAB";
-    case 11: return "DOF_SECT_TYPETAB";
-    case 12: return "DOF_SECT_URELHDR";
-    case 13: return "DOF_SECT_KRELHDR";
-    case 14: return "DOF_SECT_OPTDESC";
-    case 15: return "DOF_SECT_PROVIDER";
-    case 16: return "DOF_SECT_PROBES";
-    case 17: return "DOF_SECT_PRARGS";
-    case 18: return "DOF_SECT_PROFFS";
-    case 19: return "DOF_SECT_INTTAB";
-    case 20: return "DOF_SECT_UTSNAME";
-    case 21: return "DOF_SECT_XLTAB";
-    case 22: return "DOF_SECT_XLMEMBERS";
-    case 23: return "DOF_SECT_XLIMPORT";
-    case 24: return "DOF_SECT_XLEXPORT";
-    case 25: return "DOF_SECT_PREXPORT";
-    case 26: return "DOF_SECT_PRENOFFS";
-    default: return "<unknown>";
-  }
-}
-
-static void printDOFStringTabSec(void* dof, dof_sec_t* sec) {
-  size_t tab = sec->dofs_offset;
-  size_t limit = sec->dofs_size;
-  tty->print_cr("//   String Table:");
-  for (size_t idx = 0; idx < limit; /*empty*/) {
-    char* str = ((char*)dof) + tab + idx;
-    tty->print_cr("//   [0x%x + 0x%x] '%s'", tab, idx, str);
-    idx += strlen(str) + 1;
-  }
-}
-
-static void printDOFProviderSec(void* dof, dof_sec_t* sec) {
-  dof_provider_t* prov = (dof_provider_t*)((char*)dof + sec->dofs_offset);
-  tty->print_cr("//   dof_provider_t {");
-  tty->print_cr("//     dofpv_strtab = %d", prov->dofpv_strtab);
-  tty->print_cr("//     dofpv_probes = %d", prov->dofpv_probes);
-  tty->print_cr("//     dofpv_prargs = %d", prov->dofpv_prargs);
-  tty->print_cr("//     dofpv_proffs = %d", prov->dofpv_proffs);
-  tty->print_cr("//     dofpv_name = 0x%x", prov->dofpv_name);
-  tty->print_cr("//     dofpv_provattr = 0x%08x", prov->dofpv_provattr);
-  tty->print_cr("//     dofpv_modattr = 0x%08x", prov->dofpv_modattr);
-  tty->print_cr("//     dofpv_funcattr = 0x%08x", prov->dofpv_funcattr);
-  tty->print_cr("//     dofpv_nameattr = 0x%08x", prov->dofpv_nameattr);
-  tty->print_cr("//     dofpv_argsattr = 0x%08x", prov->dofpv_argsattr);
-  tty->print_cr("//   }");
-}
-
-static void printDOFProbesSec(void* dof, dof_sec_t* sec) {
-  size_t idx = sec->dofs_offset;
-  size_t limit = idx + sec->dofs_size;
-  for (size_t idx = sec->dofs_offset; idx < limit; idx += sec->dofs_entsize) {
-    dof_probe_t* prb = (dof_probe_t*)((char*)dof + idx);
-    tty->print_cr("//   dof_probe_t {");
-    tty->print_cr("//     dofpr_addr = 0x%016llx", prb->dofpr_addr);
-    tty->print_cr("//     dofpr_func = 0x%x", prb->dofpr_func);
-    tty->print_cr("//     dofpr_name = 0x%x", prb->dofpr_name);
-    tty->print_cr("//     dofpr_nargv = 0x%x", prb->dofpr_nargv);
-    tty->print_cr("//     dofpr_xargv = 0x%x", prb->dofpr_xargv);
-    tty->print_cr("//     dofpr_argidx = 0x%x", prb->dofpr_argidx);
-    tty->print_cr("//     dofpr_offidx = 0x%x", prb->dofpr_offidx);
-    tty->print_cr("//     dofpr_nargc = %d", prb->dofpr_nargc);
-    tty->print_cr("//     dofpr_xargc = %d", prb->dofpr_xargc);
-    tty->print_cr("//     dofpr_noffs = %d", prb->dofpr_noffs);
-    tty->print_cr("//   }");
-  }
-}
-
-static void printDOFOffsetsSec(void* dof, dof_sec_t* sec) {
-  size_t tab = sec->dofs_offset;
-  size_t limit = sec->dofs_size;
-  tty->print_cr("//   Offsets:");
-  for (size_t idx = 0; idx < limit; idx += sec->dofs_entsize) {
-    uint32_t* off = (uint32_t*)((char*)dof + tab + idx);
-    tty->print_cr("//   [0x%x + 0x%x]: %d", tab, idx, *off);
-  }
-}
-
-static void printDOFArgsSec(void* dof, dof_sec_t* sec) {
-  size_t tab = sec->dofs_offset;
-  size_t limit = sec->dofs_size;
-  tty->print_cr("//   Arguments:");
-  for (size_t idx = 0; idx < limit; idx += sec->dofs_entsize) {
-    uint8_t* arg = (uint8_t*)((char*)dof + tab + idx);
-    tty->print_cr("//   [0x%x + 0x%x]: %d", tab, idx, *arg);
-  }
-}
-
-static void printDOFSection(void* dof, dof_sec_t* sec) {
-  tty->print_cr("//   dof_sec_t {");
-  tty->print_cr("//     dofs_type = 0x%x /* %s */",
-                sec->dofs_type, dofSecTypeFor(sec->dofs_type));
-  tty->print_cr("//     dofs_align = %d", sec->dofs_align);
-  tty->print_cr("//     dofs_flags = 0x%x", sec->dofs_flags);
-  tty->print_cr("//     dofs_entsize = %d", sec->dofs_entsize);
-  tty->print_cr("//     dofs_offset = 0x%llx", sec->dofs_offset);
-  tty->print_cr("//     dofs_size = %lld", sec->dofs_size);
-  tty->print_cr("//   }");
-  switch (sec->dofs_type) {
-    case DOF_SECT_STRTAB:    printDOFStringTabSec(dof, sec); break;
-    case DOF_SECT_PROVIDER:  printDOFProviderSec(dof, sec);  break;
-    case DOF_SECT_PROBES:    printDOFProbesSec(dof, sec);    break;
-    case DOF_SECT_PROFFS:    printDOFOffsetsSec(dof, sec);   break;
-    case DOF_SECT_PRARGS:    printDOFArgsSec(dof, sec);      break;
-    default: tty->print_cr("//   <section type not recognized>");
-  }
-}
-
-static void printDOFHeader(dof_hdr_t* hdr) {
-  tty->print_cr("//   dof_hdr_t {");
-  tty->print_cr("//     dofh_ident[DOF_ID_MAG0] = 0x%x",
-                hdr->dofh_ident[DOF_ID_MAG0]);
-  tty->print_cr("//     dofh_ident[DOF_ID_MAG1] = 0x%x",
-                hdr->dofh_ident[DOF_ID_MAG1]);
-  tty->print_cr("//     dofh_ident[DOF_ID_MAG2] = 0x%x",
-                hdr->dofh_ident[DOF_ID_MAG2]);
-  tty->print_cr("//     dofh_ident[DOF_ID_MAG3] = 0x%x",
-                hdr->dofh_ident[DOF_ID_MAG3]);
-  tty->print_cr("//     dofh_ident[DOF_ID_MODEL] = 0x%x",
-                hdr->dofh_ident[DOF_ID_MODEL]);
-  tty->print_cr("//     dofh_ident[DOF_ID_ENCODING] = 0x%x",
-                hdr->dofh_ident[DOF_ID_ENCODING]);
-  tty->print_cr("//     dofh_ident[DOF_ID_VERSION] = 0x%x",
-                hdr->dofh_ident[DOF_ID_VERSION]);
-  tty->print_cr("//     dofh_ident[DOF_ID_DIFVERS] = 0x%x",
-                hdr->dofh_ident[DOF_ID_DIFVERS]);
-  tty->print_cr("//     dofh_flags = 0x%x", hdr->dofh_flags);
-  tty->print_cr("//     dofh_hdrsize = %d", hdr->dofh_hdrsize);
-  tty->print_cr("//     dofh_secsize = %d", hdr->dofh_secsize);
-  tty->print_cr("//     dofh_secnum = %d", hdr->dofh_secnum);
-  tty->print_cr("//     dofh_secoff = %lld", hdr->dofh_secoff);
-  tty->print_cr("//     dofh_loadsz = %lld", hdr->dofh_loadsz);
-  tty->print_cr("//     dofh_filesz = %lld", hdr->dofh_filesz);
-  tty->print_cr("//   }");
-}
-
-static void printDOF(void* dof) {
-  dof_hdr_t* hdr = (dof_hdr_t*)dof;
-  printDOFHeader(hdr);
-  for (int i = 0; i < hdr->dofh_secnum; ++i) {
-    dof_sec_t* sec =
-      (dof_sec_t*)((char*)dof + sizeof(dof_hdr_t) + i * sizeof(dof_sec_t));
-    tty->print_cr("//   [Section #%d]", i);
-    printDOFSection(dof, sec);
-  }
-}
-
-static void printDOFHelper(dof_helper_t* helper) {
-  tty->print_cr("// dof_helper_t {");
-  tty->print_cr("//   dofhp_mod = \"%s\"", helper->dofhp_mod);
-  tty->print_cr("//   dofhp_addr = 0x%016llx", helper->dofhp_addr);
-  tty->print_cr("//   dofhp_dof = 0x%016llx", helper->dofhp_dof);
-  printDOF((void*)helper->dofhp_dof);
-  tty->print_cr("// }");
-  size_t len = ((dof_hdr_t*)helper)->dofh_loadsz;
-  tty->print_data((void*)helper->dofhp_dof, len, true);
-}
-
-#else // ndef HAVE_DTRACE_H
-
-// Get here if we're not building on at least Solaris 10
-int DTraceJSDT::pd_activate(
-  void* baseAddress, jstring module,
-  jint provider_count, JVM_DTraceProvider* providers) {
-  return -1;
-}
-
-void DTraceJSDT::pd_dispose(int handle) {
-}
-
-jboolean DTraceJSDT::pd_is_supported() {
-  return false;
-}
-#endif
--- a/hotspot/src/os/solaris/vm/vmError_solaris.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/os/solaris/vm/vmError_solaris.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -30,6 +30,7 @@
 
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <thread.h>
 #include <signal.h>
 
 void VMError::show_message_box(char *buf, int buflen) {
@@ -59,9 +60,15 @@
   } while (yes);
 }
 
+// handle all synchronous program error signals which may happen during error
+// reporting. They must be unblocked, caught, handled.
+
+static const int SIGNALS[] = { SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP }; // add more if needed
+static const int NUM_SIGNALS = sizeof(SIGNALS) / sizeof(int);
+
 // Space for our "saved" signal flags and handlers
-static int resettedSigflags[2];
-static address resettedSighandler[2];
+static int resettedSigflags[NUM_SIGNALS];
+static address resettedSighandler[NUM_SIGNALS];
 
 static void save_signal(int idx, int sig)
 {
@@ -74,19 +81,19 @@
 }
 
 int VMError::get_resetted_sigflags(int sig) {
-  if(SIGSEGV == sig) {
-    return resettedSigflags[0];
-  } else if(SIGBUS == sig) {
-    return resettedSigflags[1];
+  for (int i = 0; i < NUM_SIGNALS; i++) {
+    if (SIGNALS[i] == sig) {
+      return resettedSigflags[i];
+    }
   }
   return -1;
 }
 
 address VMError::get_resetted_sighandler(int sig) {
-  if(SIGSEGV == sig) {
-    return resettedSighandler[0];
-  } else if(SIGBUS == sig) {
-    return resettedSighandler[1];
+  for (int i = 0; i < NUM_SIGNALS; i++) {
+    if (SIGNALS[i] == sig) {
+      return resettedSighandler[i];
+    }
   }
   return NULL;
 }
@@ -96,16 +103,25 @@
   sigset_t newset;
   sigemptyset(&newset);
   sigaddset(&newset, sig);
-  sigprocmask(SIG_UNBLOCK, &newset, NULL);
+  // also unmask other synchronous signals
+  for (int i = 0; i < NUM_SIGNALS; i++) {
+    sigaddset(&newset, SIGNALS[i]);
+  }
+  thr_sigsetmask(SIG_UNBLOCK, &newset, NULL);
 
   VMError err(NULL, sig, NULL, info, ucVoid);
   err.report_and_die();
 }
 
 void VMError::reset_signal_handlers() {
-  // Save sigflags for resetted signals
-  save_signal(0, SIGSEGV);
-  save_signal(1, SIGBUS);
-  os::signal(SIGSEGV, CAST_FROM_FN_PTR(void *, crash_handler));
-  os::signal(SIGBUS, CAST_FROM_FN_PTR(void *, crash_handler));
+  // install signal handlers for all synchronous program error signals
+  sigset_t newset;
+  sigemptyset(&newset);
+
+  for (int i = 0; i < NUM_SIGNALS; i++) {
+    save_signal(i, SIGNALS[i]);
+    os::signal(SIGNALS[i], CAST_FROM_FN_PTR(void *, crash_handler));
+    sigaddset(&newset, SIGNALS[i]);
+  }
+  thr_sigsetmask(SIG_UNBLOCK, &newset, NULL);
 }
--- a/hotspot/src/os/windows/vm/dtraceJSDT_windows.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "classfile/javaClasses.hpp"
-#include "code/codeBlob.hpp"
-#include "memory/allocation.hpp"
-#include "prims/jvm.h"
-#include "runtime/dtraceJSDT.hpp"
-#include "runtime/jniHandles.hpp"
-#include "runtime/os.hpp"
-#include "runtime/signature.hpp"
-#include "utilities/globalDefinitions.hpp"
-
-int DTraceJSDT::pd_activate(
-    void* baseAddress, jstring module,
-    jint providers_count, JVM_DTraceProvider* providers) {
-  return -1;
-}
-
-void DTraceJSDT::pd_dispose(int handle) {
-}
-
-jboolean DTraceJSDT::pd_is_supported() {
-  return false;
-}
--- a/hotspot/src/share/vm/adlc/formssel.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/adlc/formssel.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, 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
@@ -3489,9 +3489,7 @@
     "GetAndAddL", "GetAndSetL", "GetAndSetN",
   };
   int cnt = sizeof(needs_ideal_memory_list)/sizeof(char*);
-  if( strcmp(_opType,"PrefetchRead")==0 ||
-      strcmp(_opType,"PrefetchWrite")==0 ||
-      strcmp(_opType,"PrefetchAllocation")==0 )
+  if( strcmp(_opType,"PrefetchAllocation")==0 )
     return 1;
   if( _lChild ) {
     const char *opType = _lChild->_opType;
--- a/hotspot/src/share/vm/asm/codeBuffer.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/asm/codeBuffer.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -42,7 +42,6 @@
                  Verified_Entry,
                  Frame_Complete, // Offset in the code where the frame setup is (for forte stackwalks) is complete
                  OSR_Entry,
-                 Dtrace_trap = OSR_Entry,  // dtrace probes can never have an OSR entry so reuse it
                  Exceptions,     // Offset where exception handler lives
                  Deopt,          // Offset where deopt handler lives
                  DeoptMH,        // Offset where MethodHandle deopt handler lives
--- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -964,8 +964,6 @@
 void Canonicalizer::do_UnsafeGetObject(UnsafeGetObject* x) {}
 void Canonicalizer::do_UnsafePutObject(UnsafePutObject* x) {}
 void Canonicalizer::do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) {}
-void Canonicalizer::do_UnsafePrefetchRead (UnsafePrefetchRead*  x) {}
-void Canonicalizer::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {}
 void Canonicalizer::do_ProfileCall(ProfileCall* x) {}
 void Canonicalizer::do_ProfileReturnType(ProfileReturnType* x) {}
 void Canonicalizer::do_ProfileInvoke(ProfileInvoke* x) {}
--- a/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -101,8 +101,6 @@
   virtual void do_UnsafeGetObject(UnsafeGetObject* x);
   virtual void do_UnsafePutObject(UnsafePutObject* x);
   virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x);
-  virtual void do_UnsafePrefetchRead (UnsafePrefetchRead*  x);
-  virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x);
   virtual void do_ProfileCall    (ProfileCall*     x);
   virtual void do_ProfileReturnType (ProfileReturnType*  x);
   virtual void do_ProfileInvoke  (ProfileInvoke*   x);
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -3497,11 +3497,6 @@
     case vmIntrinsics::_putFloat_raw  : return append_unsafe_put_raw(callee, T_FLOAT);
     case vmIntrinsics::_putDouble_raw : return append_unsafe_put_raw(callee, T_DOUBLE);
 
-    case vmIntrinsics::_prefetchRead        : return append_unsafe_prefetch(callee, false, false);
-    case vmIntrinsics::_prefetchWrite       : return append_unsafe_prefetch(callee, false, true);
-    case vmIntrinsics::_prefetchReadStatic  : return append_unsafe_prefetch(callee, true,  false);
-    case vmIntrinsics::_prefetchWriteStatic : return append_unsafe_prefetch(callee, true,  true);
-
     case vmIntrinsics::_checkIndex    :
       if (!InlineNIOCheckIndex) return false;
       preserves_state = true;
@@ -4258,27 +4253,6 @@
 }
 
 
-bool GraphBuilder::append_unsafe_prefetch(ciMethod* callee, bool is_static, bool is_store) {
-  if (InlineUnsafeOps) {
-    Values* args = state()->pop_arguments(callee->arg_size());
-    int obj_arg_index = 1; // Assume non-static case
-    if (is_static) {
-      obj_arg_index = 0;
-    } else {
-      null_check(args->at(0));
-    }
-    Instruction* offset = args->at(obj_arg_index + 1);
-#ifndef _LP64
-    offset = append(new Convert(Bytecodes::_l2i, offset, as_ValueType(T_INT)));
-#endif
-    Instruction* op = is_store ? append(new UnsafePrefetchWrite(args->at(obj_arg_index), offset))
-                               : append(new UnsafePrefetchRead (args->at(obj_arg_index), offset));
-    compilation()->set_has_unsafe_access(true);
-  }
-  return InlineUnsafeOps;
-}
-
-
 void GraphBuilder::append_unsafe_CAS(ciMethod* callee) {
   ValueStack* state_before = copy_state_for_exception();
   ValueType* result_type = as_ValueType(callee->return_type());
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -368,7 +368,6 @@
   bool append_unsafe_put_obj(ciMethod* callee, BasicType t, bool is_volatile);
   bool append_unsafe_get_raw(ciMethod* callee, BasicType t);
   bool append_unsafe_put_raw(ciMethod* callee, BasicType t);
-  bool append_unsafe_prefetch(ciMethod* callee, bool is_store, bool is_static);
   void append_unsafe_CAS(ciMethod* callee);
   bool append_unsafe_get_and_set_obj(ciMethod* callee, bool is_add);
 
--- a/hotspot/src/share/vm/c1/c1_Instruction.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_Instruction.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -103,9 +103,6 @@
 class       UnsafeGetObject;
 class       UnsafePutObject;
 class         UnsafeGetAndSetObject;
-class       UnsafePrefetch;
-class         UnsafePrefetchRead;
-class         UnsafePrefetchWrite;
 class   ProfileCall;
 class   ProfileReturnType;
 class   ProfileInvoke;
@@ -209,8 +206,6 @@
   virtual void do_UnsafeGetObject(UnsafeGetObject* x) = 0;
   virtual void do_UnsafePutObject(UnsafePutObject* x) = 0;
   virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) = 0;
-  virtual void do_UnsafePrefetchRead (UnsafePrefetchRead*  x) = 0;
-  virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) = 0;
   virtual void do_ProfileCall    (ProfileCall*     x) = 0;
   virtual void do_ProfileReturnType (ProfileReturnType*  x) = 0;
   virtual void do_ProfileInvoke  (ProfileInvoke*   x) = 0;
@@ -2442,34 +2437,6 @@
                                                    f->visit(&_value); }
 };
 
-BASE(UnsafePrefetch, UnsafeObjectOp)
- public:
-  UnsafePrefetch(Value object, Value offset)
-  : UnsafeObjectOp(T_VOID, object, offset, false, false)
-  {
-  }
-};
-
-
-LEAF(UnsafePrefetchRead, UnsafePrefetch)
- public:
-  UnsafePrefetchRead(Value object, Value offset)
-  : UnsafePrefetch(object, offset)
-  {
-    ASSERT_VALUES
-  }
-};
-
-
-LEAF(UnsafePrefetchWrite, UnsafePrefetch)
- public:
-  UnsafePrefetchWrite(Value object, Value offset)
-  : UnsafePrefetch(object, offset)
-  {
-    ASSERT_VALUES
-  }
-};
-
 LEAF(ProfileCall, Instruction)
  private:
   ciMethod*        _method;
--- a/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -853,11 +853,6 @@
   output()->put(')');
 }
 
-void InstructionPrinter::do_UnsafePrefetchRead(UnsafePrefetchRead* x) {
-  print_unsafe_object_op(x, "UnsafePrefetchRead");
-  output()->put(')');
-}
-
 void InstructionPrinter::do_RangeCheckPredicate(RangeCheckPredicate* x) {
 
   if (x->x() != NULL && x->y() != NULL) {
@@ -880,11 +875,6 @@
 }
 #endif
 
-void InstructionPrinter::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {
-  print_unsafe_object_op(x, "UnsafePrefetchWrite");
-  output()->put(')');
-}
-
 void InstructionPrinter::do_ProfileCall(ProfileCall* x) {
   output()->print("profile ");
   print_value(x->recv());
--- a/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -129,8 +129,6 @@
   virtual void do_UnsafeGetObject(UnsafeGetObject* x);
   virtual void do_UnsafePutObject(UnsafePutObject* x);
   virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x);
-  virtual void do_UnsafePrefetchRead (UnsafePrefetchRead*  x);
-  virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x);
   virtual void do_ProfileCall    (ProfileCall*     x);
   virtual void do_ProfileReturnType (ProfileReturnType*  x);
   virtual void do_ProfileInvoke  (ProfileInvoke*   x);
--- a/hotspot/src/share/vm/c1/c1_LIR.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_LIR.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -527,8 +527,6 @@
     case lir_move:           // input and result always valid, may have info
     case lir_pack64:         // input and result always valid
     case lir_unpack64:       // input and result always valid
-    case lir_prefetchr:      // input always valid, result and info always invalid
-    case lir_prefetchw:      // input always valid, result and info always invalid
     {
       assert(op->as_Op1() != NULL, "must be");
       LIR_Op1* op1 = (LIR_Op1*)op;
@@ -1266,13 +1264,6 @@
 }
 
 
-void LIR_List::prefetch(LIR_Address* addr, bool is_store) {
-  append(new LIR_Op1(
-            is_store ? lir_prefetchw : lir_prefetchr,
-            LIR_OprFact::address(addr)));
-}
-
-
 void LIR_List::store_mem_int(jint v, LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code) {
   append(new LIR_Op1(
             lir_move,
--- a/hotspot/src/share/vm/c1/c1_LIR.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_LIR.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, 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
@@ -925,8 +925,6 @@
       , lir_branch
       , lir_cond_float_branch
       , lir_move
-      , lir_prefetchr
-      , lir_prefetchw
       , lir_convert
       , lir_alloc_object
       , lir_monaddr
@@ -2212,8 +2210,6 @@
 
   void load(LIR_Address* addr, LIR_Opr src, CodeEmitInfo* info = NULL, LIR_PatchCode patch_code = lir_patch_none);
 
-  void prefetch(LIR_Address* addr, bool is_store);
-
   void store_mem_int(jint v,    LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
   void store_mem_oop(jobject o, LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
   void store(LIR_Opr src, LIR_Address* addr, CodeEmitInfo* info = NULL, LIR_PatchCode patch_code = lir_patch_none);
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -503,14 +503,6 @@
       }
       break;
 
-    case lir_prefetchr:
-      prefetchr(op->in_opr());
-      break;
-
-    case lir_prefetchw:
-      prefetchw(op->in_opr());
-      break;
-
     case lir_roundfp: {
       LIR_OpRoundFP* round_op = op->as_OpRoundFP();
       roundfp_op(round_op->in_opr(), round_op->tmp(), round_op->result_opr(), round_op->pop_fpu_stack());
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, 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
@@ -182,9 +182,6 @@
                    LIR_PatchCode patch_code,
                    CodeEmitInfo* info, bool wide, bool unaligned);
 
-  void prefetchr  (LIR_Opr src);
-  void prefetchw  (LIR_Opr src);
-
   void shift_op(LIR_Code code, LIR_Opr left, LIR_Opr count, LIR_Opr dest, LIR_Opr tmp);
   void shift_op(LIR_Code code, LIR_Opr left, jint  count, LIR_Opr dest);
 
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, 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
@@ -2385,35 +2385,6 @@
 }
 
 
-void LIRGenerator::do_UnsafePrefetch(UnsafePrefetch* x, bool is_store) {
-  LIRItem src(x->object(), this);
-  LIRItem off(x->offset(), this);
-
-  src.load_item();
-  if (off.is_constant() && can_inline_as_constant(x->offset())) {
-    // let it be a constant
-    off.dont_load_item();
-  } else {
-    off.load_item();
-  }
-
-  set_no_result(x);
-
-  LIR_Address* addr = generate_address(src.result(), off.result(), 0, 0, T_BYTE);
-  __ prefetch(addr, is_store);
-}
-
-
-void LIRGenerator::do_UnsafePrefetchRead(UnsafePrefetchRead* x) {
-  do_UnsafePrefetch(x, false);
-}
-
-
-void LIRGenerator::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {
-  do_UnsafePrefetch(x, true);
-}
-
-
 void LIRGenerator::do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux) {
   int lng = x->length();
 
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, 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
@@ -251,8 +251,6 @@
   void do_Reference_get(Intrinsic* x);
   void do_update_CRC32(Intrinsic* x);
 
-  void do_UnsafePrefetch(UnsafePrefetch* x, bool is_store);
-
   LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
   LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
 
@@ -539,8 +537,6 @@
   virtual void do_UnsafeGetObject(UnsafeGetObject* x);
   virtual void do_UnsafePutObject(UnsafePutObject* x);
   virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x);
-  virtual void do_UnsafePrefetchRead (UnsafePrefetchRead*  x);
-  virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x);
   virtual void do_ProfileCall    (ProfileCall*     x);
   virtual void do_ProfileReturnType (ProfileReturnType* x);
   virtual void do_ProfileInvoke  (ProfileInvoke*   x);
--- a/hotspot/src/share/vm/c1/c1_Optimizer.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_Optimizer.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -528,8 +528,6 @@
   void do_UnsafeGetObject(UnsafeGetObject* x);
   void do_UnsafePutObject(UnsafePutObject* x);
   void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x);
-  void do_UnsafePrefetchRead (UnsafePrefetchRead*  x);
-  void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x);
   void do_ProfileCall    (ProfileCall*     x);
   void do_ProfileReturnType (ProfileReturnType*  x);
   void do_ProfileInvoke  (ProfileInvoke*   x);
@@ -716,8 +714,6 @@
 void NullCheckVisitor::do_UnsafeGetObject(UnsafeGetObject* x) {}
 void NullCheckVisitor::do_UnsafePutObject(UnsafePutObject* x) {}
 void NullCheckVisitor::do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) {}
-void NullCheckVisitor::do_UnsafePrefetchRead (UnsafePrefetchRead*  x) {}
-void NullCheckVisitor::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {}
 void NullCheckVisitor::do_ProfileCall    (ProfileCall*     x) { nce()->clear_last_explicit_null_check();
                                                                 nce()->handle_ProfileCall(x); }
 void NullCheckVisitor::do_ProfileReturnType (ProfileReturnType* x) { nce()->handle_ProfileReturnType(x); }
--- a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, 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
@@ -159,8 +159,6 @@
     void do_UnsafeGetRaw   (UnsafeGetRaw*    x) { /* nothing to do */ };
     void do_UnsafeGetObject(UnsafeGetObject* x) { /* nothing to do */ };
     void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) { /* nothing to do */ };
-    void do_UnsafePrefetchRead (UnsafePrefetchRead*  x) { /* nothing to do */ };
-    void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) { /* nothing to do */ };
     void do_ProfileCall    (ProfileCall*     x) { /* nothing to do */ };
     void do_ProfileReturnType (ProfileReturnType*  x) { /* nothing to do */ };
     void do_ProfileInvoke  (ProfileInvoke*   x) { /* nothing to do */ };
--- a/hotspot/src/share/vm/c1/c1_ValueMap.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/c1/c1_ValueMap.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -200,8 +200,6 @@
   void do_RoundFP        (RoundFP*         x) { /* nothing to do */ }
   void do_UnsafeGetRaw   (UnsafeGetRaw*    x) { /* nothing to do */ }
   void do_UnsafeGetObject(UnsafeGetObject* x) { /* nothing to do */ }
-  void do_UnsafePrefetchRead (UnsafePrefetchRead*  x) { /* nothing to do */ }
-  void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) { /* nothing to do */ }
   void do_ProfileCall    (ProfileCall*     x) { /* nothing to do */ }
   void do_ProfileReturnType (ProfileReturnType*  x) { /* nothing to do */ }
   void do_ProfileInvoke  (ProfileInvoke*   x) { /* nothing to do */ };
--- a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -501,32 +501,31 @@
   return fields;
 }
 
-void ciInstanceKlass::compute_injected_fields_helper() {
+bool ciInstanceKlass::compute_injected_fields_helper() {
   ASSERT_IN_VM;
   InstanceKlass* k = get_instanceKlass();
 
   for (InternalFieldStream fs(k); !fs.done(); fs.next()) {
     if (fs.access_flags().is_static())  continue;
-    _has_injected_fields++;
-    break;
+    return true;
   }
+  return false;
 }
 
-bool ciInstanceKlass::compute_injected_fields() {
-  assert(_has_injected_fields == -1, "shouldn't be initialized yet");
+void ciInstanceKlass::compute_injected_fields() {
   assert(is_loaded(), "must be loaded");
 
+  int has_injected_fields = 0;
   if (super() != NULL && super()->has_injected_fields()) {
-    _has_injected_fields = 1;
-    return true;
+    has_injected_fields = 1;
+  } else {
+    GUARDED_VM_ENTRY({
+        has_injected_fields = compute_injected_fields_helper() ? 1 : 0;
+      });
   }
-
-  _has_injected_fields = 0;
-  GUARDED_VM_ENTRY({
-      compute_injected_fields_helper();
-    });
-
-  return _has_injected_fields > 0 ? true : false;
+  // may be concurrently initialized for shared ciInstanceKlass objects
+  assert(_has_injected_fields == -1 || _has_injected_fields == has_injected_fields, "broken concurrent initialization");
+  _has_injected_fields = has_injected_fields;
 }
 
 // ------------------------------------------------------------------
--- a/hotspot/src/share/vm/ci/ciInstanceKlass.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/ci/ciInstanceKlass.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -72,8 +72,8 @@
   //   Itsef: more than one implementors.
   ciInstanceKlass*       _implementor;
 
-  bool compute_injected_fields();
-  void compute_injected_fields_helper();
+  void compute_injected_fields();
+  bool compute_injected_fields_helper();
 
 protected:
   ciInstanceKlass(KlassHandle h_k);
@@ -193,7 +193,7 @@
 
   bool has_injected_fields() {
     if (_has_injected_fields == -1) {
-      return compute_injected_fields();
+      compute_injected_fields();
     }
     return _has_injected_fields > 0 ? true : false;
   }
--- a/hotspot/src/share/vm/ci/ciMethod.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/ci/ciMethod.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -70,7 +70,8 @@
 // Loaded method.
 ciMethod::ciMethod(methodHandle h_m, ciInstanceKlass* holder) :
   ciMetadata(h_m()),
-  _holder(holder)
+  _holder(holder),
+  _has_injected_profile(false)
 {
   assert(h_m() != NULL, "no null method");
 
@@ -168,7 +169,8 @@
   _liveness(               NULL),
   _can_be_statically_bound(false),
   _method_blocks(          NULL),
-  _method_data(            NULL)
+  _method_data(            NULL),
+  _has_injected_profile(   false)
 #if defined(COMPILER2) || defined(SHARK)
   ,
   _flow(                   NULL),
--- a/hotspot/src/share/vm/ci/ciMethod.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/ci/ciMethod.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -79,6 +79,7 @@
   bool _is_c1_compilable;
   bool _is_c2_compilable;
   bool _can_be_statically_bound;
+  bool _has_injected_profile;
 
   // Lazy fields, filled in on demand
   address              _code;
@@ -286,6 +287,9 @@
   int instructions_size();
   int scale_count(int count, float prof_factor = 1.);  // make MDO count commensurate with IIC
 
+  bool has_injected_profile() const { return _has_injected_profile;     }
+  void set_injected_profile(bool x) {        _has_injected_profile = x; }
+
   // Stack walking support
   bool is_ignored_by_security_stack_walk() const;
 
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -243,7 +243,6 @@
   template(returnType_name,                           "returnType")                               \
   template(signature_name,                            "signature")                                \
   template(slot_name,                                 "slot")                                     \
-  template(selectAlternative_name,                    "selectAlternative")                        \
                                                                                                   \
   /* Support for annotations (JDK 1.5 and above) */                                               \
                                                                                                   \
@@ -295,8 +294,7 @@
   template(setTarget_signature,                       "(Ljava/lang/invoke/MethodHandle;)V")       \
   NOT_LP64(  do_alias(intptr_signature,               int_signature)  )                           \
   LP64_ONLY( do_alias(intptr_signature,               long_signature) )                           \
-  template(selectAlternative_signature, "(ZLjava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodHandle;)Ljava/lang/invoke/MethodHandle;") \
-                                                                      \
+                                                                                                  \
   /* common method and field names */                                                             \
   template(object_initializer_name,                   "<init>")                                   \
   template(class_initializer_name,                    "<clinit>")                                 \
@@ -868,6 +866,12 @@
    do_name(     fullFence_name,                                  "fullFence")                                           \
    do_alias(    fullFence_signature,                              void_method_signature)                                \
                                                                                                                         \
+  /* Custom branch frequencies profiling support for JSR292 */                                                          \
+  do_class(java_lang_invoke_MethodHandleImpl,               "java/lang/invoke/MethodHandleImpl")                        \
+  do_intrinsic(_profileBoolean, java_lang_invoke_MethodHandleImpl, profileBoolean_name, profileBoolean_signature,    F_S)  \
+   do_name(     profileBoolean_name,                               "profileBoolean")                                     \
+   do_signature(profileBoolean_signature,                           "(Z[I)Z")                                            \
+                                                                                                                        \
   /* unsafe memory references (there are a lot of them...) */                                                           \
   do_signature(getObject_signature,       "(Ljava/lang/Object;J)Ljava/lang/Object;")                                    \
   do_signature(putObject_signature,       "(Ljava/lang/Object;JLjava/lang/Object;)V")                                   \
@@ -1017,18 +1021,6 @@
   do_intrinsic(_getAndSetObject,          sun_misc_Unsafe,        getAndSetObject_name, getAndSetObject_signature,  F_R)\
    do_name(     getAndSetObject_name,                             "getAndSetObject")                                    \
    do_signature(getAndSetObject_signature,                        "(Ljava/lang/Object;JLjava/lang/Object;)Ljava/lang/Object;" ) \
-                                                                                                                        \
-  /* prefetch_signature is shared by all prefetch variants */                                                           \
-  do_signature( prefetch_signature,        "(Ljava/lang/Object;J)V")                                                    \
-                                                                                                                        \
-  do_intrinsic(_prefetchRead,             sun_misc_Unsafe,        prefetchRead_name, prefetch_signature,         F_RN)  \
-   do_name(     prefetchRead_name,                               "prefetchRead")                                        \
-  do_intrinsic(_prefetchWrite,            sun_misc_Unsafe,        prefetchWrite_name, prefetch_signature,        F_RN)  \
-   do_name(     prefetchWrite_name,                              "prefetchWrite")                                       \
-  do_intrinsic(_prefetchReadStatic,       sun_misc_Unsafe,        prefetchReadStatic_name, prefetch_signature,   F_SN)  \
-   do_name(     prefetchReadStatic_name,                         "prefetchReadStatic")                                  \
-  do_intrinsic(_prefetchWriteStatic,      sun_misc_Unsafe,        prefetchWriteStatic_name, prefetch_signature,  F_SN)  \
-   do_name(     prefetchWriteStatic_name,                        "prefetchWriteStatic")                                 \
     /*== LAST_COMPILER_INLINE*/                                                                                         \
     /*the compiler does have special inlining code for these; bytecode inline is just fine */                           \
                                                                                                                         \
@@ -1203,7 +1195,7 @@
     #undef VM_INTRINSIC_ENUM
 
     ID_LIMIT,
-    LAST_COMPILER_INLINE = _prefetchWriteStatic,
+    LAST_COMPILER_INLINE = _getAndSetObject,
     FIRST_MH_SIG_POLY    = _invokeGeneric,
     FIRST_MH_STATIC      = _linkToVirtual,
     LAST_MH_SIG_POLY     = _linkToInterface,
--- a/hotspot/src/share/vm/code/nmethod.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/code/nmethod.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -477,9 +477,6 @@
 #if INCLUDE_RTM_OPT
   _rtm_state               = NoRTM;
 #endif
-#ifdef HAVE_DTRACE_H
-  _trap_offset             = 0;
-#endif // def HAVE_DTRACE_H
 }
 
 nmethod* nmethod::new_native_nmethod(methodHandle method,
@@ -520,44 +517,6 @@
   return nm;
 }
 
-#ifdef HAVE_DTRACE_H
-nmethod* nmethod::new_dtrace_nmethod(methodHandle method,
-                                     CodeBuffer *code_buffer,
-                                     int vep_offset,
-                                     int trap_offset,
-                                     int frame_complete,
-                                     int frame_size) {
-  code_buffer->finalize_oop_references(method);
-  // create nmethod
-  nmethod* nm = NULL;
-  {
-    MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
-    int nmethod_size = allocation_size(code_buffer, sizeof(nmethod));
-    CodeOffsets offsets;
-    offsets.set_value(CodeOffsets::Verified_Entry, vep_offset);
-    offsets.set_value(CodeOffsets::Dtrace_trap, trap_offset);
-    offsets.set_value(CodeOffsets::Frame_Complete, frame_complete);
-
-    nm = new (nmethod_size, CompLevel_none) nmethod(method(), nmethod_size,
-                                    &offsets, code_buffer, frame_size);
-
-    NOT_PRODUCT(if (nm != NULL)  nmethod_stats.note_nmethod(nm));
-    if (PrintAssembly && nm != NULL) {
-      Disassembler::decode(nm);
-    }
-  }
-  // verify nmethod
-  debug_only(if (nm) nm->verify();) // might block
-
-  if (nm != NULL) {
-    nm->log_new_nmethod();
-  }
-
-  return nm;
-}
-
-#endif // def HAVE_DTRACE_H
-
 nmethod* nmethod::new_nmethod(methodHandle method,
   int compile_id,
   int entry_bci,
@@ -718,91 +677,6 @@
   }
 }
 
-// For dtrace wrappers
-#ifdef HAVE_DTRACE_H
-nmethod::nmethod(
-  Method* method,
-  int nmethod_size,
-  CodeOffsets* offsets,
-  CodeBuffer* code_buffer,
-  int frame_size)
-  : CodeBlob("dtrace nmethod", code_buffer, sizeof(nmethod),
-             nmethod_size, offsets->value(CodeOffsets::Frame_Complete), frame_size, NULL),
-  _native_receiver_sp_offset(in_ByteSize(-1)),
-  _native_basic_lock_sp_offset(in_ByteSize(-1))
-{
-  {
-    debug_only(No_Safepoint_Verifier nsv;)
-    assert_locked_or_safepoint(CodeCache_lock);
-
-    init_defaults();
-    _method                  = method;
-    _entry_bci               = InvocationEntryBci;
-    // We have no exception handler or deopt handler make the
-    // values something that will never match a pc like the nmethod vtable entry
-    _exception_offset        = 0;
-    _deoptimize_offset       = 0;
-    _deoptimize_mh_offset    = 0;
-    _unwind_handler_offset   = -1;
-    _trap_offset             = offsets->value(CodeOffsets::Dtrace_trap);
-    _orig_pc_offset          = 0;
-    _consts_offset           = data_offset();
-    _stub_offset             = data_offset();
-    _oops_offset             = data_offset();
-    _metadata_offset         = _oops_offset         + round_to(code_buffer->total_oop_size(), oopSize);
-    _scopes_data_offset      = _metadata_offset     + round_to(code_buffer->total_metadata_size(), wordSize);
-    _scopes_pcs_offset       = _scopes_data_offset;
-    _dependencies_offset     = _scopes_pcs_offset;
-    _handler_table_offset    = _dependencies_offset;
-    _nul_chk_table_offset    = _handler_table_offset;
-    _nmethod_end_offset      = _nul_chk_table_offset;
-    _compile_id              = 0;  // default
-    _comp_level              = CompLevel_none;
-    _entry_point             = code_begin()          + offsets->value(CodeOffsets::Entry);
-    _verified_entry_point    = code_begin()          + offsets->value(CodeOffsets::Verified_Entry);
-    _osr_entry_point         = NULL;
-    _exception_cache         = NULL;
-    _pc_desc_cache.reset_to(NULL);
-    _hotness_counter         = NMethodSweeper::hotness_counter_reset_val();
-
-    code_buffer->copy_values_to(this);
-    if (ScavengeRootsInCode) {
-      if (detect_scavenge_root_oops()) {
-        CodeCache::add_scavenge_root_nmethod(this);
-      }
-      Universe::heap()->register_nmethod(this);
-    }
-    DEBUG_ONLY(verify_scavenge_root_oops();)
-    CodeCache::commit(this);
-  }
-
-  if (PrintNMethods || PrintDebugInfo || PrintRelocations || PrintDependencies) {
-    ttyLocker ttyl;  // keep the following output all in one block
-    // This output goes directly to the tty, not the compiler log.
-    // To enable tools to match it up with the compilation activity,
-    // be sure to tag this tty output with the compile ID.
-    if (xtty != NULL) {
-      xtty->begin_head("print_dtrace_nmethod");
-      xtty->method(_method);
-      xtty->stamp();
-      xtty->end_head(" address='" INTPTR_FORMAT "'", (intptr_t) this);
-    }
-    // print the header part first
-    print();
-    // then print the requested information
-    if (PrintNMethods) {
-      print_code();
-    }
-    if (PrintRelocations) {
-      print_relocations();
-    }
-    if (xtty != NULL) {
-      xtty->tail("print_dtrace_nmethod");
-    }
-  }
-}
-#endif // def HAVE_DTRACE_H
-
 void* nmethod::operator new(size_t size, int nmethod_size, int comp_level) throw () {
   return CodeCache::allocate(nmethod_size, CodeCache::get_code_blob_type(comp_level));
 }
@@ -2310,17 +2184,6 @@
 #endif // !SHARK
 }
 
-
-oop nmethod::embeddedOop_at(u_char* p) {
-  RelocIterator iter(this, p, p + 1);
-  while (iter.next())
-    if (iter.type() == relocInfo::oop_type) {
-      return iter.oop_reloc()->oop_value();
-    }
-  return NULL;
-}
-
-
 inline bool includes(void* p, void* from, void* to) {
   return from <= p && p < to;
 }
--- a/hotspot/src/share/vm/code/nmethod.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/code/nmethod.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -157,9 +157,6 @@
   // Offset of the unwind handler if it exists
   int _unwind_handler_offset;
 
-#ifdef HAVE_DTRACE_H
-  int _trap_offset;
-#endif // def HAVE_DTRACE_H
   int _consts_offset;
   int _stub_offset;
   int _oops_offset;                       // offset to where embedded oop table begins (inside data)
@@ -261,15 +258,6 @@
           ByteSize basic_lock_sp_offset,       /* synchronized natives only */
           OopMapSet* oop_maps);
 
-#ifdef HAVE_DTRACE_H
-  // For native wrappers
-  nmethod(Method* method,
-          int nmethod_size,
-          CodeOffsets* offsets,
-          CodeBuffer *code_buffer,
-          int frame_size);
-#endif // def HAVE_DTRACE_H
-
   // Creation support
   nmethod(Method* method,
           int nmethod_size,
@@ -333,22 +321,6 @@
                                      ByteSize basic_lock_sp_offset,
                                      OopMapSet* oop_maps);
 
-#ifdef HAVE_DTRACE_H
-  // The method we generate for a dtrace probe has to look
-  // like an nmethod as far as the rest of the system is concerned
-  // which is somewhat unfortunate.
-  static nmethod* new_dtrace_nmethod(methodHandle method,
-                                     CodeBuffer *code_buffer,
-                                     int vep_offset,
-                                     int trap_offset,
-                                     int frame_complete,
-                                     int frame_size);
-
-  int trap_offset() const      { return _trap_offset; }
-  address trap_address() const { return insts_begin() + _trap_offset; }
-
-#endif // def HAVE_DTRACE_H
-
   // accessors
   Method* method() const                          { return _method; }
   AbstractCompiler* compiler() const              { return _compiler; }
@@ -730,11 +702,6 @@
   int  compile_id() const                         { return _compile_id; }
   const char* compile_kind() const;
 
-  // For debugging
-  // CompiledIC*    IC_at(char* p) const;
-  // PrimitiveIC*   primitiveIC_at(char* p) const;
-  oop embeddedOop_at(address p);
-
   // tells if any of this method's dependencies have been invalidated
   // (this is expensive!)
   static void check_all_dependencies(DepChange& changes);
--- a/hotspot/src/share/vm/compiler/disassembler.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/compiler/disassembler.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -345,21 +345,6 @@
       if (WizardMode) st->print(" " INTPTR_FORMAT, (intptr_t)adr);
       return;
     }
-
-    oop obj;
-    if (_nm != NULL
-        && (obj = _nm->embeddedOop_at(cur_insn())) != NULL
-        && (address) obj == adr
-        && Universe::heap()->is_in(obj)
-        && Universe::heap()->is_in(obj->klass())) {
-      julong c = st->count();
-      obj->print_value_on(st);
-      if (st->count() == c) {
-        // No output.  (Can happen in product builds.)
-        st->print("(a %s)", obj->klass()->external_name());
-      }
-      return;
-    }
   }
 
   // Fall through to a simple (hexadecimal) numeral.
--- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -308,7 +308,7 @@
 
   inline ParScanThreadState& thread_state(int i);
 
-  void trace_promotion_failed(YoungGCTracer& gc_tracer);
+  void trace_promotion_failed(const YoungGCTracer* gc_tracer);
   void reset(int active_workers, bool promotion_failed);
   void flush();
 
@@ -357,10 +357,10 @@
   return ((ParScanThreadState*)_data)[i];
 }
 
-void ParScanThreadStateSet::trace_promotion_failed(YoungGCTracer& gc_tracer) {
+void ParScanThreadStateSet::trace_promotion_failed(const YoungGCTracer* gc_tracer) {
   for (int i = 0; i < length(); ++i) {
     if (thread_state(i).promotion_failed()) {
-      gc_tracer.report_promotion_failed(thread_state(i).promotion_failed_info());
+      gc_tracer->report_promotion_failed(thread_state(i).promotion_failed_info());
       thread_state(i).promotion_failed_info().reset();
     }
   }
@@ -883,7 +883,7 @@
 
 // A Generation that does parallel young-gen collection.
 
-void ParNewGeneration::handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set, ParNewTracer& gc_tracer) {
+void ParNewGeneration::handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set) {
   assert(_promo_failure_scan_stack.is_empty(), "post condition");
   _promo_failure_scan_stack.clear(true); // Clear cached segments.
 
@@ -899,10 +899,10 @@
   _next_gen->promotion_failure_occurred();
 
   // Trace promotion failure in the parallel GC threads
-  thread_state_set.trace_promotion_failed(gc_tracer);
+  thread_state_set.trace_promotion_failed(gc_tracer());
   // Single threaded code may have reported promotion failure to the global state
   if (_promotion_failed_info.has_failed()) {
-    gc_tracer.report_promotion_failed(_promotion_failed_info);
+    _gc_tracer.report_promotion_failed(_promotion_failed_info);
   }
   // Reset the PromotionFailureALot counters.
   NOT_PRODUCT(Universe::heap()->reset_promotion_should_fail();)
@@ -941,9 +941,8 @@
   }
   assert(to()->is_empty(), "Else not collection_attempt_is_safe");
 
-  ParNewTracer gc_tracer;
-  gc_tracer.report_gc_start(gch->gc_cause(), _gc_timer->gc_start());
-  gch->trace_heap_before_gc(&gc_tracer);
+  _gc_tracer.report_gc_start(gch->gc_cause(), _gc_timer->gc_start());
+  gch->trace_heap_before_gc(gc_tracer());
 
   init_assuming_no_promotion_failure();
 
@@ -952,7 +951,7 @@
     size_policy->minor_collection_begin();
   }
 
-  GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL, gc_tracer.gc_id());
+  GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL, _gc_tracer.gc_id());
   // Capture heap used before collection (for printing).
   size_t gch_prev_used = gch->used();
 
@@ -994,7 +993,7 @@
 
   // Trace and reset failed promotion info.
   if (promotion_failed()) {
-    thread_state_set.trace_promotion_failed(gc_tracer);
+    thread_state_set.trace_promotion_failed(gc_tracer());
   }
 
   // Process (weak) reference objects found during scavenge.
@@ -1015,16 +1014,16 @@
     ParNewRefProcTaskExecutor task_executor(*this, thread_state_set);
     stats = rp->process_discovered_references(&is_alive, &keep_alive,
                                               &evacuate_followers, &task_executor,
-                                              _gc_timer, gc_tracer.gc_id());
+                                              _gc_timer, _gc_tracer.gc_id());
   } else {
     thread_state_set.flush();
     gch->set_par_threads(0);  // 0 ==> non-parallel.
     gch->save_marks();
     stats = rp->process_discovered_references(&is_alive, &keep_alive,
                                               &evacuate_followers, NULL,
-                                              _gc_timer, gc_tracer.gc_id());
+                                              _gc_timer, _gc_tracer.gc_id());
   }
-  gc_tracer.report_gc_reference_stats(stats);
+  _gc_tracer.report_gc_reference_stats(stats);
   if (!promotion_failed()) {
     // Swap the survivor spaces.
     eden()->clear(SpaceDecorator::Mangle);
@@ -1049,7 +1048,7 @@
 
     adjust_desired_tenuring_threshold();
   } else {
-    handle_promotion_failed(gch, thread_state_set, gc_tracer);
+    handle_promotion_failed(gch, thread_state_set);
   }
   // set new iteration safe limit for the survivor spaces
   from()->set_concurrent_iteration_safe_limit(from()->top());
@@ -1088,12 +1087,12 @@
   }
   rp->verify_no_references_recorded();
 
-  gch->trace_heap_after_gc(&gc_tracer);
-  gc_tracer.report_tenuring_threshold(tenuring_threshold());
+  gch->trace_heap_after_gc(gc_tracer());
+  _gc_tracer.report_tenuring_threshold(tenuring_threshold());
 
   _gc_timer->register_gc_end();
 
-  gc_tracer.report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions());
+  _gc_tracer.report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions());
 }
 
 static int sum;
--- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -333,6 +333,9 @@
   // references to live referent.
   DefNewGeneration::IsAliveClosure _is_alive_closure;
 
+  // GC tracer that should be used during collection.
+  ParNewTracer _gc_tracer;
+
   static oop real_forwardee_slow(oop obj);
   static void waste_some_time();
 
@@ -340,7 +343,7 @@
   // word being overwritten with a self-forwarding-pointer.
   void preserve_mark_if_necessary(oop obj, markOop m);
 
-  void handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set, ParNewTracer& gc_tracer);
+  void handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set);
 
  protected:
 
@@ -411,6 +414,10 @@
     return _plab_stats.desired_plab_sz();
   }
 
+  const ParNewTracer* gc_tracer() const {
+    return &_gc_tracer;
+  }
+
   static oop real_forwardee(oop obj);
 
   DEBUG_ONLY(static bool is_legal_forward_ptr(oop p);)
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -663,7 +663,7 @@
   }
 }
 
-void ParallelScavengeHeap::trace_heap(GCWhen::Type when, GCTracer* gc_tracer) {
+void ParallelScavengeHeap::trace_heap(GCWhen::Type when, const GCTracer* gc_tracer) {
   const PSHeapSummary& heap_summary = create_ps_heap_summary();
   gc_tracer->report_gc_heap_summary(when, heap_summary);
 
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -64,7 +64,7 @@
   // The task manager
   static GCTaskManager* _gc_task_manager;
 
-  void trace_heap(GCWhen::Type when, GCTracer* tracer);
+  void trace_heap(GCWhen::Type when, const GCTracer* tracer);
 
  protected:
   static inline size_t total_invocations();
--- a/hotspot/src/share/vm/gc_implementation/shared/gcTrace.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/gc_implementation/shared/gcTrace.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -162,7 +162,7 @@
   _tenuring_threshold = UNSET_TENURING_THRESHOLD;
 }
 
-void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) {
+void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) const {
   assert_set_gc_id();
 
   send_promotion_failed_event(pf_info);
--- a/hotspot/src/share/vm/gc_implementation/shared/gcTrace.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/gc_implementation/shared/gcTrace.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -153,7 +153,7 @@
   virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions);
 
  public:
-  void report_promotion_failed(const PromotionFailedInfo& pf_info);
+  void report_promotion_failed(const PromotionFailedInfo& pf_info) const;
   void report_tenuring_threshold(const uint tenuring_threshold);
 
   /*
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -132,7 +132,7 @@
   assert_locked_or_safepoint(CodeCache_lock);
 }
 
-void CollectedHeap::trace_heap(GCWhen::Type when, GCTracer* gc_tracer) {
+void CollectedHeap::trace_heap(GCWhen::Type when, const GCTracer* gc_tracer) {
   const GCHeapSummary& heap_summary = create_heap_summary();
   gc_tracer->report_gc_heap_summary(when, heap_summary);
 
@@ -140,11 +140,11 @@
   gc_tracer->report_metaspace_summary(when, metaspace_summary);
 }
 
-void CollectedHeap::trace_heap_before_gc(GCTracer* gc_tracer) {
+void CollectedHeap::trace_heap_before_gc(const GCTracer* gc_tracer) {
   trace_heap(GCWhen::BeforeGC, gc_tracer);
 }
 
-void CollectedHeap::trace_heap_after_gc(GCTracer* gc_tracer) {
+void CollectedHeap::trace_heap_after_gc(const GCTracer* gc_tracer) {
   trace_heap(GCWhen::AfterGC, gc_tracer);
 }
 
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -175,7 +175,7 @@
   // Fill with a single object (either an int array or a java.lang.Object).
   static inline void fill_with_object_impl(HeapWord* start, size_t words, bool zap = true);
 
-  virtual void trace_heap(GCWhen::Type when, GCTracer* tracer);
+  virtual void trace_heap(GCWhen::Type when, const GCTracer* tracer);
 
   // Verification functions
   virtual void check_for_bad_heap_word_value(HeapWord* addr, size_t size)
@@ -606,8 +606,8 @@
   virtual void register_nmethod(nmethod* nm);
   virtual void unregister_nmethod(nmethod* nm);
 
-  void trace_heap_before_gc(GCTracer* gc_tracer);
-  void trace_heap_after_gc(GCTracer* gc_tracer);
+  void trace_heap_before_gc(const GCTracer* gc_tracer);
+  void trace_heap_after_gc(const GCTracer* gc_tracer);
 
   // Heap verification
   virtual void verify(bool silent, VerifyOption option) = 0;
--- a/hotspot/src/share/vm/gc_interface/gcCause.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/gc_interface/gcCause.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -103,9 +103,6 @@
     case _last_ditch_collection:
       return "Last ditch collection";
 
-    case _dcmd_gc_run:
-      return "Diagnostic Command";
-
     case _last_gc_cause:
       return "ILLEGAL VALUE - last gc cause - ILLEGAL VALUE";
 
--- a/hotspot/src/share/vm/gc_interface/gcCause.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/gc_interface/gcCause.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -74,9 +74,6 @@
     _g1_humongous_allocation,
 
     _last_ditch_collection,
-
-    _dcmd_gc_run,
-
     _last_gc_cause
   };
 
--- a/hotspot/src/share/vm/memory/allocation.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/memory/allocation.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -275,31 +275,30 @@
     Chunk* cur = NULL;
     Chunk* next;
     {
-    // if we have more than n chunks, free all of them
-    ThreadCritical tc;
-    if (_num_chunks > n) {
-      // free chunks at end of queue, for better locality
+      // if we have more than n chunks, free all of them
+      ThreadCritical tc;
+      if (_num_chunks > n) {
+        // free chunks at end of queue, for better locality
         cur = _first;
-      for (size_t i = 0; i < (n - 1) && cur != NULL; i++) cur = cur->next();
+        for (size_t i = 0; i < (n - 1) && cur != NULL; i++) cur = cur->next();
 
-      if (cur != NULL) {
+        if (cur != NULL) {
           next = cur->next();
-        cur->set_next(NULL);
-        cur = next;
+          cur->set_next(NULL);
+          cur = next;
 
-          _num_chunks = n;
+          // Free all remaining chunks while in ThreadCritical lock
+          // so NMT adjustment is stable.
+          while(cur != NULL) {
+            next = cur->next();
+            os::free(cur);
+            _num_chunks--;
+            cur = next;
+          }
         }
       }
     }
-
-    // Free all remaining chunks, outside of ThreadCritical
-    // to avoid deadlock with NMT
-        while(cur != NULL) {
-          next = cur->next();
-      os::free(cur);
-          cur = next;
-        }
-      }
+  }
 
   // Accessors to preallocated pool's
   static ChunkPool* large_pool()  { assert(_large_pool  != NULL, "must be initialized"); return _large_pool;  }
@@ -384,7 +383,9 @@
    case Chunk::medium_size: ChunkPool::medium_pool()->free(c); break;
    case Chunk::init_size:   ChunkPool::small_pool()->free(c); break;
    case Chunk::tiny_size:   ChunkPool::tiny_pool()->free(c); break;
-   default:                 os::free(c);
+   default:
+     ThreadCritical tc;  // Free chunks under TC lock so that NMT adjustment is stable.
+     os::free(c);
   }
 }
 
--- a/hotspot/src/share/vm/memory/filemap.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/memory/filemap.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, 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
@@ -388,7 +388,8 @@
   remove(_full_path);
   int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444);
   if (fd < 0) {
-    fail_stop("Unable to create shared archive file %s.", _full_path);
+    fail_stop("Unable to create shared archive file %s: (%s).", _full_path,
+              strerror(errno));
   }
   _fd = fd;
   _file_offset = 0;
--- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, 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
@@ -108,12 +108,11 @@
   // Allocate space for the heap.
 
   char* heap_address;
-  size_t total_reserved = 0;
   ReservedSpace heap_rs;
 
   size_t heap_alignment = collector_policy()->heap_alignment();
 
-  heap_address = allocate(heap_alignment, &total_reserved, &heap_rs);
+  heap_address = allocate(heap_alignment, &heap_rs);
 
   if (!heap_rs.is_reserved()) {
     vm_shutdown_during_initialization(
@@ -149,7 +148,6 @@
 
 
 char* GenCollectedHeap::allocate(size_t alignment,
-                                 size_t* _total_reserved,
                                  ReservedSpace* heap_rs){
   const char overflow_msg[] = "The size of the object heap + VM data exceeds "
     "the maximum representable size";
@@ -171,8 +169,6 @@
          err_msg("Gen size; total_reserved=" SIZE_FORMAT ", alignment="
                  SIZE_FORMAT, total_reserved, alignment));
 
-  *_total_reserved = total_reserved;
-
   *heap_rs = Universe::reserve_heap(total_reserved, alignment);
   return heap_rs->base();
 }
--- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, 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
@@ -124,7 +124,9 @@
 
   // Returns JNI_OK on success
   virtual jint initialize();
-  char* allocate(size_t alignment, size_t* _total_reserved, ReservedSpace* heap_rs);
+
+  // Reserve aligned space for the heap as needed by the contained generations.
+  char* allocate(size_t alignment, ReservedSpace* heap_rs);
 
   // Does operations required after initialization has been done.
   void post_initialize();
--- a/hotspot/src/share/vm/memory/tenuredGeneration.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/memory/tenuredGeneration.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
 #include "precompiled.hpp"
 #include "gc_implementation/shared/collectorCounters.hpp"
 #include "gc_implementation/shared/gcTimer.hpp"
-#include "gc_implementation/shared/parGCAllocBuffer.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/blockOffsetTable.inline.hpp"
 #include "memory/cardGeneration.inline.hpp"
--- a/hotspot/src/share/vm/opto/callnode.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/callnode.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1982,6 +1982,7 @@
 
 
 Node *ArrayCopyNode::Ideal(PhaseGVN *phase, bool can_reshape) {
+  if (remove_dead_region(phase, can_reshape))  return this;
 
   if (StressArrayCopyMacroNode && !can_reshape) return NULL;
 
--- a/hotspot/src/share/vm/opto/classes.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/classes.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -200,6 +200,7 @@
 macro(Opaque1)
 macro(Opaque2)
 macro(Opaque3)
+macro(ProfileBoolean)
 macro(OrI)
 macro(OrL)
 macro(OverflowAddI)
@@ -216,8 +217,6 @@
 macro(PopCountL)
 macro(PowD)
 macro(PrefetchAllocation)
-macro(PrefetchRead)
-macro(PrefetchWrite)
 macro(Proj)
 macro(RShiftI)
 macro(RShiftL)
--- a/hotspot/src/share/vm/opto/compile.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/compile.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -3105,6 +3105,7 @@
   default:
     assert( !n->is_Call(), "" );
     assert( !n->is_Mem(), "" );
+    assert( nop != Op_ProfileBoolean, "should be eliminated during IGVN");
     break;
   }
 
@@ -3321,6 +3322,9 @@
 bool Compile::too_many_traps(ciMethod* method,
                              int bci,
                              Deoptimization::DeoptReason reason) {
+  if (method->has_injected_profile()) {
+    return false;
+  }
   ciMethodData* md = method->method_data();
   if (md->is_empty()) {
     // Assume the trap has not occurred, or that it occurred only
@@ -3370,6 +3374,9 @@
 bool Compile::too_many_recompiles(ciMethod* method,
                                   int bci,
                                   Deoptimization::DeoptReason reason) {
+  if (method->has_injected_profile()) {
+    return false;
+  }
   ciMethodData* md = method->method_data();
   if (md->is_empty()) {
     // Assume the trap has not occurred, or that it occurred only
--- a/hotspot/src/share/vm/opto/divnode.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/divnode.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -219,7 +219,7 @@
 static bool magic_long_divide_constants(jlong d, jlong &M, jint &s) {
   int64_t p;
   uint64_t ad, anc, delta, q1, r1, q2, r2, t;
-  const uint64_t two63 = 0x8000000000000000LL;     // 2**63.
+  const uint64_t two63 = UCONST64(0x8000000000000000);     // 2**63.
 
   ad = ABS(d);
   if (d == 0 || d == 1) return false;
--- a/hotspot/src/share/vm/opto/escape.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/escape.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -206,6 +206,11 @@
     _verify = false;
   }
 #endif
+  // Bytecode analyzer BCEscapeAnalyzer, used for Call nodes
+  // processing, calls to CI to resolve symbols (types, fields, methods)
+  // referenced in bytecode. During symbol resolution VM may throw
+  // an exception which CI cleans and converts to compilation failure.
+  if (C->failing())  return false;
 
   // 2. Finish Graph construction by propagating references to all
   //    java objects through graph.
--- a/hotspot/src/share/vm/opto/graphKit.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/graphKit.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1986,6 +1986,11 @@
         Deoptimization::trap_request_index(trap_request) < 0 &&
         too_many_recompiles(reason)) {
       // This BCI is causing too many recompilations.
+      if (C->log() != NULL) {
+        C->log()->elem("observe that='trap_action_change' reason='%s' from='%s' to='none'",
+                Deoptimization::trap_reason_name(reason),
+                Deoptimization::trap_action_name(action));
+      }
       action = Deoptimization::Action_none;
       trap_request = Deoptimization::make_trap_request(reason, action);
     } else {
@@ -2760,7 +2765,7 @@
   Deoptimization::DeoptReason reason = Deoptimization::reason_class_check(spec_klass != NULL);
 
   // Make sure we haven't already deoptimized from this tactic.
-  if (too_many_traps(reason))
+  if (too_many_traps(reason) || too_many_recompiles(reason))
     return NULL;
 
   // (No, this isn't a call, but it's enough like a virtual call
@@ -2782,8 +2787,7 @@
                                             &exact_obj);
       { PreserveJVMState pjvms(this);
         set_control(slow_ctl);
-        uncommon_trap(reason,
-                      Deoptimization::Action_maybe_recompile);
+        uncommon_trap_exact(reason, Deoptimization::Action_maybe_recompile);
       }
       if (safe_for_replace) {
         replace_in_map(not_null_obj, exact_obj);
@@ -2812,8 +2816,12 @@
   if (type != NULL) {
     Deoptimization::DeoptReason class_reason = Deoptimization::Reason_speculate_class_check;
     Deoptimization::DeoptReason null_reason = Deoptimization::Reason_speculate_null_check;
-    if (!too_many_traps(null_reason) &&
-        !too_many_traps(class_reason)) {
+    ciMethod* trap_method = (sfpt == NULL) ? method() : sfpt->jvms()->method();
+    int trap_bci = (sfpt == NULL) ? bci() : sfpt->jvms()->bci();
+
+    if (!too_many_traps(null_reason) && !too_many_recompiles(null_reason) &&
+        !C->too_many_traps(trap_method, trap_bci, class_reason) &&
+        !C->too_many_recompiles(trap_method, trap_bci, class_reason)) {
       Node* not_null_obj = NULL;
       // not_null is true if we know the object is not null and
       // there's no need for a null check
@@ -2833,19 +2841,18 @@
         GraphKit kit(sfpt->jvms());
         PreserveJVMState pjvms(&kit);
         kit.set_control(slow_ctl);
-        kit.uncommon_trap(class_reason,
-                          Deoptimization::Action_maybe_recompile);
+        kit.uncommon_trap_exact(class_reason, Deoptimization::Action_maybe_recompile);
       } else {
         PreserveJVMState pjvms(this);
         set_control(slow_ctl);
-        uncommon_trap(class_reason,
-                      Deoptimization::Action_maybe_recompile);
+        uncommon_trap_exact(class_reason, Deoptimization::Action_maybe_recompile);
       }
       replace_in_map(not_null_obj, exact_obj);
       obj = exact_obj;
     }
   } else {
-    if (!too_many_traps(Deoptimization::Reason_null_assert)) {
+    if (!too_many_traps(Deoptimization::Reason_null_assert) &&
+        !too_many_recompiles(Deoptimization::Reason_null_assert)) {
       Node* exact_obj = null_assert(obj);
       replace_in_map(obj, exact_obj);
       obj = exact_obj;
--- a/hotspot/src/share/vm/opto/graphKit.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/graphKit.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -714,6 +714,15 @@
                   klass, reason_string, must_throw, keep_exact_action);
   }
 
+  // Bail out to the interpreter and keep exact action (avoid switching to Action_none).
+  void uncommon_trap_exact(Deoptimization::DeoptReason reason,
+                           Deoptimization::DeoptAction action,
+                           ciKlass* klass = NULL, const char* reason_string = NULL,
+                           bool must_throw = false) {
+    uncommon_trap(Deoptimization::make_trap_request(reason, action),
+                  klass, reason_string, must_throw, /*keep_exact_action=*/true);
+  }
+
   // SP when bytecode needs to be reexecuted.
   virtual int reexecute_sp() { return sp(); }
 
--- a/hotspot/src/share/vm/opto/ifnode.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/ifnode.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -145,10 +145,18 @@
       Node* v = u->fast_out(k); // User of the phi
       // CNC - Allow only really simple patterns.
       // In particular I disallow AddP of the Phi, a fairly common pattern
-      if( v == cmp ) continue;  // The compare is OK
-      if( (v->is_ConstraintCast()) &&
-          v->in(0)->in(0) == iff )
-        continue;               // CastPP/II of the IfNode is OK
+      if (v == cmp) continue;  // The compare is OK
+      if (v->is_ConstraintCast()) {
+        // If the cast is derived from data flow edges, it may not have a control edge.
+        // If so, it should be safe to split. But follow-up code can not deal with
+        // this (l. 359). So skip.
+        if (v->in(0) == NULL) {
+          return NULL;
+        }
+        if (v->in(0)->in(0) == iff) {
+          continue;               // CastPP/II of the IfNode is OK
+        }
+      }
       // Disabled following code because I cannot tell if exactly one
       // path dominates without a real dominator check. CNC 9/9/1999
       //uint vop = v->Opcode();
--- a/hotspot/src/share/vm/opto/library_call.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -41,6 +41,7 @@
 #include "opto/movenode.hpp"
 #include "opto/mulnode.hpp"
 #include "opto/narrowptrnode.hpp"
+#include "opto/opaquenode.hpp"
 #include "opto/parse.hpp"
 #include "opto/runtime.hpp"
 #include "opto/subnode.hpp"
@@ -232,7 +233,6 @@
   // Unsafe.getObject should be recorded in an SATB log buffer.
   void insert_pre_barrier(Node* base_oop, Node* offset, Node* pre_val, bool need_mem_bar);
   bool inline_unsafe_access(bool is_native_ptr, bool is_store, BasicType type, bool is_volatile);
-  bool inline_unsafe_prefetch(bool is_native_ptr, bool is_store, bool is_static);
   static bool klass_needs_init_guard(Node* kls);
   bool inline_unsafe_allocate();
   bool inline_unsafe_copyMemory();
@@ -287,6 +287,8 @@
   bool inline_updateBytesCRC32();
   bool inline_updateByteBufferCRC32();
   bool inline_multiplyToLen();
+
+  bool inline_profileBoolean();
 };
 
 
@@ -796,11 +798,6 @@
   case vmIntrinsics::_putFloatVolatile:         return inline_unsafe_access(!is_native_ptr,  is_store, T_FLOAT,    is_volatile);
   case vmIntrinsics::_putDoubleVolatile:        return inline_unsafe_access(!is_native_ptr,  is_store, T_DOUBLE,   is_volatile);
 
-  case vmIntrinsics::_prefetchRead:             return inline_unsafe_prefetch(!is_native_ptr, !is_store, !is_static);
-  case vmIntrinsics::_prefetchWrite:            return inline_unsafe_prefetch(!is_native_ptr,  is_store, !is_static);
-  case vmIntrinsics::_prefetchReadStatic:       return inline_unsafe_prefetch(!is_native_ptr, !is_store,  is_static);
-  case vmIntrinsics::_prefetchWriteStatic:      return inline_unsafe_prefetch(!is_native_ptr,  is_store,  is_static);
-
   case vmIntrinsics::_compareAndSwapObject:     return inline_unsafe_load_store(T_OBJECT, LS_cmpxchg);
   case vmIntrinsics::_compareAndSwapInt:        return inline_unsafe_load_store(T_INT,    LS_cmpxchg);
   case vmIntrinsics::_compareAndSwapLong:       return inline_unsafe_load_store(T_LONG,   LS_cmpxchg);
@@ -900,6 +897,9 @@
   case vmIntrinsics::_updateByteBufferCRC32:
     return inline_updateByteBufferCRC32();
 
+  case vmIntrinsics::_profileBoolean:
+    return inline_profileBoolean();
+
   default:
     // If you get here, it may be that someone has added a new intrinsic
     // to the list in vmSymbols.hpp without implementing it here.
@@ -2506,7 +2506,7 @@
 
   Node* receiver = argument(0);  // type: oop
 
-  // Build address expression.  See the code in inline_unsafe_prefetch.
+  // Build address expression.
   Node* adr;
   Node* heap_base_oop = top();
   Node* offset = top();
@@ -2695,73 +2695,6 @@
   return true;
 }
 
-//----------------------------inline_unsafe_prefetch----------------------------
-
-bool LibraryCallKit::inline_unsafe_prefetch(bool is_native_ptr, bool is_store, bool is_static) {
-#ifndef PRODUCT
-  {
-    ResourceMark rm;
-    // Check the signatures.
-    ciSignature* sig = callee()->signature();
-#ifdef ASSERT
-    // Object getObject(Object base, int/long offset), etc.
-    BasicType rtype = sig->return_type()->basic_type();
-    if (!is_native_ptr) {
-      assert(sig->count() == 2, "oop prefetch has 2 arguments");
-      assert(sig->type_at(0)->basic_type() == T_OBJECT, "prefetch base is object");
-      assert(sig->type_at(1)->basic_type() == T_LONG, "prefetcha offset is correct");
-    } else {
-      assert(sig->count() == 1, "native prefetch has 1 argument");
-      assert(sig->type_at(0)->basic_type() == T_LONG, "prefetch base is long");
-    }
-#endif // ASSERT
-  }
-#endif // !PRODUCT
-
-  C->set_has_unsafe_access(true);  // Mark eventual nmethod as "unsafe".
-
-  const int idx = is_static ? 0 : 1;
-  if (!is_static) {
-    null_check_receiver();
-    if (stopped()) {
-      return true;
-    }
-  }
-
-  // Build address expression.  See the code in inline_unsafe_access.
-  Node *adr;
-  if (!is_native_ptr) {
-    // The base is either a Java object or a value produced by Unsafe.staticFieldBase
-    Node* base   = argument(idx + 0);  // type: oop
-    // The offset is a value produced by Unsafe.staticFieldOffset or Unsafe.objectFieldOffset
-    Node* offset = argument(idx + 1);  // type: long
-    // We currently rely on the cookies produced by Unsafe.xxxFieldOffset
-    // to be plain byte offsets, which are also the same as those accepted
-    // by oopDesc::field_base.
-    assert(Unsafe_field_offset_to_byte_offset(11) == 11,
-           "fieldOffset must be byte-scaled");
-    // 32-bit machines ignore the high half!
-    offset = ConvL2X(offset);
-    adr = make_unsafe_address(base, offset);
-  } else {
-    Node* ptr = argument(idx + 0);  // type: long
-    ptr = ConvL2X(ptr);  // adjust Java long to machine word
-    adr = make_unsafe_address(NULL, ptr);
-  }
-
-  // Generate the read or write prefetch
-  Node *prefetch;
-  if (is_store) {
-    prefetch = new PrefetchWriteNode(i_o(), adr);
-  } else {
-    prefetch = new PrefetchReadNode(i_o(), adr);
-  }
-  prefetch->init_req(0, control());
-  set_i_o(_gvn.transform(prefetch));
-
-  return true;
-}
-
 //----------------------------inline_unsafe_load_store----------------------------
 // This method serves a couple of different customers (depending on LoadStoreKind):
 //
@@ -4734,6 +4667,8 @@
   // tightly_coupled_allocation()
   AllocateArrayNode* alloc = tightly_coupled_allocation(dest, NULL);
 
+  ciMethod* trap_method = method();
+  int trap_bci = bci();
   SafePointNode* sfpt = NULL;
   if (alloc != NULL) {
     // The JVM state for uncommon traps between the allocation and
@@ -4758,6 +4693,9 @@
 
     sfpt->set_i_o(map()->i_o());
     sfpt->set_memory(map()->memory());
+
+    trap_method = jvms->method();
+    trap_bci = jvms->bci();
   }
 
   bool validated = false;
@@ -4862,7 +4800,7 @@
     }
   }
 
-  if (!too_many_traps(Deoptimization::Reason_intrinsic) && !src->is_top() && !dest->is_top()) {
+  if (!C->too_many_traps(trap_method, trap_bci, Deoptimization::Reason_intrinsic) && !src->is_top() && !dest->is_top()) {
     // validate arguments: enables transformation the ArrayCopyNode
     validated = true;
 
@@ -5867,3 +5805,47 @@
 
   return instof_false;  // even if it is NULL
 }
+
+bool LibraryCallKit::inline_profileBoolean() {
+  Node* counts = argument(1);
+  const TypeAryPtr* ary = NULL;
+  ciArray* aobj = NULL;
+  if (counts->is_Con()
+      && (ary = counts->bottom_type()->isa_aryptr()) != NULL
+      && (aobj = ary->const_oop()->as_array()) != NULL
+      && (aobj->length() == 2)) {
+    // Profile is int[2] where [0] and [1] correspond to false and true value occurrences respectively.
+    jint false_cnt = aobj->element_value(0).as_int();
+    jint  true_cnt = aobj->element_value(1).as_int();
+
+    method()->set_injected_profile(true);
+
+    if (C->log() != NULL) {
+      C->log()->elem("observe source='profileBoolean' false='%d' true='%d'",
+                     false_cnt, true_cnt);
+    }
+
+    if (false_cnt + true_cnt == 0) {
+      // According to profile, never executed.
+      uncommon_trap_exact(Deoptimization::Reason_intrinsic,
+                          Deoptimization::Action_reinterpret);
+      return true;
+    }
+    // Stop profiling.
+    // MethodHandleImpl::profileBoolean() has profiling logic in it's bytecode.
+    // By replacing method's body with profile data (represented as ProfileBooleanNode
+    // on IR level) we effectively disable profiling.
+    // It enables full speed execution once optimized code is generated.
+    Node* profile = _gvn.transform(new ProfileBooleanNode(argument(0), false_cnt, true_cnt));
+    C->record_for_igvn(profile);
+    set_result(profile);
+    return true;
+  } else {
+    // Continue profiling.
+    // Profile data isn't available at the moment. So, execute method's bytecode version.
+    // Usually, when GWT LambdaForms are profiled it means that a stand-alone nmethod
+    // is compiled and counters aren't available since corresponding MethodHandle
+    // isn't a compile-time constant.
+    return false;
+  }
+}
--- a/hotspot/src/share/vm/opto/matcher.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/matcher.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -884,8 +884,6 @@
   // %%% Kludgery.  Instead, fix ideal adr_type methods for all these cases:
   if (nidx == Compile::AliasIdxTop && midx == Compile::AliasIdxRaw) {
     switch (n->Opcode()) {
-    case Op_PrefetchRead:
-    case Op_PrefetchWrite:
     case Op_PrefetchAllocation:
       nidx = Compile::AliasIdxRaw;
       nat = TypeRawPtr::BOTTOM;
--- a/hotspot/src/share/vm/opto/memnode.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/memnode.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -1376,26 +1376,6 @@
 
 //------------------------------Prefetch---------------------------------------
 
-// Non-faulting prefetch load.  Prefetch for many reads.
-class PrefetchReadNode : public Node {
-public:
-  PrefetchReadNode(Node *abio, Node *adr) : Node(0,abio,adr) {}
-  virtual int Opcode() const;
-  virtual uint ideal_reg() const { return NotAMachineReg; }
-  virtual uint match_edge(uint idx) const { return idx==2; }
-  virtual const Type *bottom_type() const { return Type::ABIO; }
-};
-
-// Non-faulting prefetch load.  Prefetch for many reads & many writes.
-class PrefetchWriteNode : public Node {
-public:
-  PrefetchWriteNode(Node *abio, Node *adr) : Node(0,abio,adr) {}
-  virtual int Opcode() const;
-  virtual uint ideal_reg() const { return NotAMachineReg; }
-  virtual uint match_edge(uint idx) const { return idx==2; }
-  virtual const Type *bottom_type() const { return Type::ABIO; }
-};
-
 // Allocation prefetch which may fault, TLAB size have to be adjusted.
 class PrefetchAllocationNode : public Node {
 public:
--- a/hotspot/src/share/vm/opto/opaquenode.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/opaquenode.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -60,4 +60,27 @@
   return (&n == this);          // Always fail except on self
 }
 
+//=============================================================================
 
+uint ProfileBooleanNode::hash() const { return NO_HASH; }
+uint ProfileBooleanNode::cmp( const Node &n ) const {
+  return (&n == this);
+}
+
+Node *ProfileBooleanNode::Ideal(PhaseGVN *phase, bool can_reshape) {
+  if (can_reshape && _delay_removal) {
+    _delay_removal = false;
+    return this;
+  } else {
+    return NULL;
+  }
+}
+
+Node *ProfileBooleanNode::Identity( PhaseTransform *phase ) {
+  if (_delay_removal) {
+    return this;
+  } else {
+    assert(_consumed, "profile should be consumed before elimination");
+    return in(1);
+  }
+}
--- a/hotspot/src/share/vm/opto/opaquenode.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/opaquenode.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -87,5 +87,31 @@
   bool rtm_opt() const { return (_opt == RTM_OPT); }
 };
 
+//------------------------------ProfileBooleanNode-------------------------------
+// A node represents value profile for a boolean during parsing.
+// Once parsing is over, the node goes away (during IGVN).
+// It is used to override branch frequencies from MDO (see has_injected_profile in parse2.cpp).
+class ProfileBooleanNode : public Node {
+  uint _false_cnt;
+  uint _true_cnt;
+  bool _consumed;
+  bool _delay_removal;
+  virtual uint hash() const ;                  // { return NO_HASH; }
+  virtual uint cmp( const Node &n ) const;
+  public:
+  ProfileBooleanNode(Node *n, uint false_cnt, uint true_cnt) : Node(0, n),
+          _false_cnt(false_cnt), _true_cnt(true_cnt), _delay_removal(true), _consumed(false) {}
+
+  uint false_count() const { return _false_cnt; }
+  uint  true_count() const { return  _true_cnt; }
+
+  void consume() { _consumed = true;  }
+
+  virtual int Opcode() const;
+  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
+  virtual Node *Identity(PhaseTransform *phase);
+  virtual const Type *bottom_type() const { return TypeInt::BOOL; }
+};
+
 #endif // SHARE_VM_OPTO_OPAQUENODE_HPP
 
--- a/hotspot/src/share/vm/opto/parse.hpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/parse.hpp	Wed Jul 05 20:21:01 2017 +0200
@@ -555,8 +555,8 @@
   void do_jsr();
   void do_ret();
 
-  float   dynamic_branch_prediction(float &cnt);
-  float   branch_prediction(float &cnt, BoolTest::mask btest, int target_bci);
+  float   dynamic_branch_prediction(float &cnt, BoolTest::mask btest, Node* test);
+  float   branch_prediction(float &cnt, BoolTest::mask btest, int target_bci, Node* test);
   bool    seems_never_taken(float prob) const;
   bool    path_is_suitable_for_uncommon_trap(float prob) const;
   bool    seems_stable_comparison() const;
--- a/hotspot/src/share/vm/opto/parse2.cpp	Thu Feb 19 11:24:01 2015 -0800
+++ b/hotspot/src/share/vm/opto/parse2.cpp	Wed Jul 05 20:21:01 2017 +0200
@@ -37,6 +37,7 @@
 #include "opto/matcher.hpp"
 #include "opto/memnode.hpp"
 #include "opto/mulnode.hpp"
+#include "opto/opaquenode.hpp"
 #include "opto/parse.hpp"
 #include "opto/runtime.hpp"
 #include "runtime/deoptimization.hpp"
@@ -763,35 +764,64 @@
   merge_common(target, pnum);
 }
 
+static bool has_injected_profile(BoolTest::mask btest, Node* test, int& taken, int& not_taken) {